@json-to-office/jto 0.8.2 → 0.9.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/README.md +4 -4
- package/dist/cli.js +1505 -120
- package/dist/cli.js.map +1 -1
- package/dist/client/assets/HomePage-CtePCdPD.js +99 -0
- package/dist/client/assets/HomePage-CtePCdPD.js.map +1 -0
- package/dist/client/assets/{JsonEditorPage-DCvwatOj.js → JsonEditorPage-Dk_qYbQR.js} +3 -3
- package/dist/client/assets/{JsonEditorPage-DCvwatOj.js.map → JsonEditorPage-Dk_qYbQR.js.map} +1 -1
- package/dist/client/assets/{MonacoPluginProvider-DrTR8ld3.js → MonacoPluginProvider-BmWwTUcW.js} +3 -3
- package/dist/client/assets/{MonacoPluginProvider-DrTR8ld3.js.map → MonacoPluginProvider-BmWwTUcW.js.map} +1 -1
- package/dist/client/assets/{button-D_d9zKq6.js → button-jTamq7gj.js} +2 -2
- package/dist/client/assets/{button-D_d9zKq6.js.map → button-jTamq7gj.js.map} +1 -1
- package/dist/client/assets/{editor-AIcSsY9W.js → editor-QOUTSCme.js} +2 -2
- package/dist/client/assets/{editor-AIcSsY9W.js.map → editor-QOUTSCme.js.map} +1 -1
- package/dist/client/assets/{editor-monaco-json-DHxCqVbk.js → editor-monaco-json-Bi4IKPau.js} +2 -2
- package/dist/client/assets/{editor-monaco-json-DHxCqVbk.js.map → editor-monaco-json-Bi4IKPau.js.map} +1 -1
- package/dist/client/assets/index-CLUTL9ST.js +5 -0
- package/dist/client/assets/index-CLUTL9ST.js.map +1 -0
- package/dist/client/assets/index-DKIIAAih.css +1 -0
- package/dist/client/assets/preview-CtIrY86t.js +3 -0
- package/dist/client/assets/preview-CtIrY86t.js.map +1 -0
- package/dist/client/assets/{radix-ui-BZ5iKMtq.js → radix-ui-BiXCNJNt.js} +2 -2
- package/dist/client/assets/{radix-ui-BZ5iKMtq.js.map → radix-ui-BiXCNJNt.js.map} +1 -1
- package/dist/client/assets/{state-vendor-BDrPu9qj.js → state-vendor-DTum9m7F.js} +2 -2
- package/dist/client/assets/{state-vendor-BDrPu9qj.js.map → state-vendor-DTum9m7F.js.map} +1 -1
- package/dist/client/assets/{ui-vendor-Dyg3GRT-.js → ui-vendor-D3QbouTA.js} +10 -5
- package/dist/client/assets/ui-vendor-D3QbouTA.js.map +1 -0
- package/dist/client/index.html +5 -4
- package/dist/client/templates/Wiseair 16-9.pptx.json +6254 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +30 -12
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
- package/dist/client/assets/HomePage-N11lGfcq.js +0 -99
- package/dist/client/assets/HomePage-N11lGfcq.js.map +0 -1
- package/dist/client/assets/index-B0s8Zyy_.css +0 -1
- package/dist/client/assets/index-DmdAtyxx.js +0 -3
- package/dist/client/assets/index-DmdAtyxx.js.map +0 -1
- package/dist/client/assets/preview-BrqBUZLp.js +0 -3
- package/dist/client/assets/preview-BrqBUZLp.js.map +0 -1
- package/dist/client/assets/ui-vendor-Dyg3GRT-.js.map +0 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-QOUTSCme.js","assets/react-vendor-CTFDOf2G.js","assets/editor-monaco-json-Bi4IKPau.js","assets/index-CLUTL9ST.js","assets/query-vendor-Df8-oete.js","assets/radix-ui-BiXCNJNt.js","assets/ui-vendor-D3QbouTA.js","assets/monaco-editor-BcgxPCqT.js","assets/state-vendor-DTum9m7F.js","assets/index-DKIIAAih.css","assets/MonacoPluginProvider-BmWwTUcW.js","assets/button-jTamq7gj.js","assets/preview-CtIrY86t.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var om=Object.defineProperty;var lm=(e,t,n)=>t in e?om(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Mo=(e,t,n)=>lm(e,typeof t!="symbol"?t+"":t,n);import{c as Ee,r as y,j as c,R as cc,g as Za}from"./react-vendor-CTFDOf2G.js";import{B as _e}from"./button-jTamq7gj.js";import{c as H,T as ei,C as um,E as cm,F as kt,S as nn,a as dm,b as Xe,d as Qe,e as et,u as dc,f as Wi,s as Ss,_ as fc,g as ti,A as fm,h as pm,i as hm,j as mm,k as lr,l as pi,W as gm}from"./index-CLUTL9ST.js";import{b as pc,c as Ba,d as hc,e as mc,f as Gi,g as Ki,D as Yi,O as Xi,h as gc,S as rr,i as xm,V as ym,j as xc,I as bm,k as vm,l as yc,m as wm,n as bc,o as km,p as Sm,G as _m,q as vc,r as wc,L as kc,s as Sc,t as jm,u as Cm,v as Nm,w as _c,x as jc,y as Cc,z as Nc,A as Ec,B as Ic,E as zc,F as Tc,H as Ac,J as Pc,K as Oc,M as Em,N as Im,Q as Dc,U as zm,W as Tm,X as Am,Y as Pm,Z as Om,_ as Dm,$ as Rm,a0 as Mm,a1 as $m,a2 as Rc,a3 as Mc,a4 as $c,a5 as Fc,a6 as Lc,a7 as Zc,a8 as Bc,a9 as Vc,aa as Uc,ab as Fm,ac as Jc,ad as Hc,ae as qc}from"./radix-ui-BiXCNJNt.js";import{X as jn,a as qr,C as an,b as ln,d as Lm,e as Qi,f as Wc,P as Zm,g as $o,h as sa,F as Gc,S as Kc,B as Fo,i as Bm,j as Vm,k as Um,l as es,m as Jm,M as Hm,n as qm,o as Wm,p as Yc,q as Gm,r as Lo,s as Si,t as Km,I as Xc,G as Ym,u as Xm,R as Qm,v as eg,T as Qc,E as tg,w as ng,x as rg,y as ig,z as ed,A as Va,D as td,H as sg,J as nd,L as aa,K as ag,N as og,O as Zo,Q as oa,U as lg}from"./ui-vendor-D3QbouTA.js";import{i as ug,u as Ae,a as la,b as yn,g as ua,c as Ot,T as rd,d as ni,S as cg,O as dg,e as fg,M as pg,D as hg}from"./MonacoPluginProvider-BmWwTUcW.js";import{a as mg,d as gg,p as xg,b as yg,u as bg,e as vg}from"./state-vendor-DTum9m7F.js";import{b as wg}from"./query-vendor-Df8-oete.js";var Wr=e=>e.type==="checkbox",vn=e=>e instanceof Date,ct=e=>e==null;const id=e=>typeof e=="object";var We=e=>!ct(e)&&!Array.isArray(e)&&id(e)&&!vn(e),sd=e=>We(e)&&e.target?Wr(e.target)?e.target.checked:e.target.value:e,kg=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,ad=(e,t)=>e.has(kg(t)),Sg=e=>{const t=e.constructor&&e.constructor.prototype;return We(t)&&t.hasOwnProperty("isPrototypeOf")},Ua=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function mt(e){let t;const n=Array.isArray(e),r=typeof FileList<"u"?e instanceof FileList:!1;if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(Ua&&(e instanceof Blob||r))&&(n||We(e)))if(t=n?[]:{},!n&&!Sg(e))t=e;else for(const i in e)e.hasOwnProperty(i)&&(t[i]=mt(e[i]));else return e;return t}var ts=e=>Array.isArray(e)?e.filter(Boolean):[],qe=e=>e===void 0,se=(e,t,n)=>{if(!t||!We(e))return n;const r=ts(t.split(/[,[\].]+?/)).reduce((i,s)=>ct(i)?i:i[s],e);return qe(r)||r===e?qe(e[t])?n:e[t]:r},Ct=e=>typeof e=="boolean",Ja=e=>/^\w*$/.test(e),od=e=>ts(e.replace(/["|']|\]/g,"").split(/\.|\[/)),Oe=(e,t,n)=>{let r=-1;const i=Ja(t)?[t]:od(t),s=i.length,a=s-1;for(;++r<s;){const o=i[r];let l=n;if(r!==a){const u=e[o];l=We(u)||Array.isArray(u)?u:isNaN(+i[r+1])?{}:[]}if(o==="__proto__"||o==="constructor"||o==="prototype")return;e[o]=l,e=e[o]}return e};const _i={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Pt={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Ht={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},ld=Ee.createContext(null),ns=()=>Ee.useContext(ld),_g=e=>{const{children:t,...n}=e;return Ee.createElement(ld.Provider,{value:n},t)};var ud=(e,t,n,r=!0)=>{const i={defaultValues:t._defaultValues};for(const s in e)Object.defineProperty(i,s,{get:()=>{const a=s;return t._proxyFormState[a]!==Pt.all&&(t._proxyFormState[a]=!r||Pt.all),n&&(n[a]=!0),e[a]}});return i},gt=e=>We(e)&&!Object.keys(e).length,cd=(e,t,n,r)=>{n(e);const{name:i,...s}=e;return gt(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(a=>t[a]===(!r||Pt.all))},Cr=e=>Array.isArray(e)?e:[e],dd=(e,t,n)=>!e||!t||e===t||Cr(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r)));function Ha(e){const t=Ee.useRef(e);t.current=e,Ee.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}function jg(e){const t=ns(),{control:n=t.control,disabled:r,name:i,exact:s}=e||{},[a,o]=Ee.useState(n._formState),l=Ee.useRef(!0),u=Ee.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),f=Ee.useRef(i);return f.current=i,Ha({disabled:r,next:d=>l.current&&dd(f.current,d.name,s)&&cd(d,u.current,n._updateFormState)&&o({...n._formState,...d}),subject:n._subjects.state}),Ee.useEffect(()=>(l.current=!0,u.current.isValid&&n._updateValid(!0),()=>{l.current=!1}),[n]),Ee.useMemo(()=>ud(a,n,u.current,!1),[a,n])}var Bt=e=>typeof e=="string",fd=(e,t,n,r,i)=>Bt(e)?(r&&t.watch.add(e),se(n,e,i)):Array.isArray(e)?e.map(s=>(r&&t.watch.add(s),se(n,s))):(r&&(t.watchAll=!0),n);function Cg(e){const t=ns(),{control:n=t.control,name:r,defaultValue:i,disabled:s,exact:a}=e||{},o=Ee.useRef(r);o.current=r,Ha({disabled:s,subject:n._subjects.values,next:f=>{dd(o.current,f.name,a)&&u(mt(fd(o.current,n._names,f.values||n._formValues,!1,i)))}});const[l,u]=Ee.useState(n._getWatch(r,i));return Ee.useEffect(()=>n._removeUnmounted()),l}function Ng(e){const t=ns(),{name:n,disabled:r,control:i=t.control,shouldUnregister:s}=e,a=ad(i._names.array,n),o=Cg({control:i,name:n,defaultValue:se(i._formValues,n,se(i._defaultValues,n,e.defaultValue)),exact:!0}),l=jg({control:i,name:n,exact:!0}),u=Ee.useRef(i.register(n,{...e.rules,value:o,...Ct(e.disabled)?{disabled:e.disabled}:{}})),f=Ee.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!se(l.errors,n)},isDirty:{enumerable:!0,get:()=>!!se(l.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!se(l.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!se(l.validatingFields,n)},error:{enumerable:!0,get:()=>se(l.errors,n)}}),[l,n]),d=Ee.useMemo(()=>({name:n,value:o,...Ct(r)||l.disabled?{disabled:l.disabled||r}:{},onChange:p=>u.current.onChange({target:{value:sd(p),name:n},type:_i.CHANGE}),onBlur:()=>u.current.onBlur({target:{value:se(i._formValues,n),name:n},type:_i.BLUR}),ref:p=>{const h=se(i._fields,n);h&&p&&(h._f.ref={focus:()=>p.focus(),select:()=>p.select(),setCustomValidity:m=>p.setCustomValidity(m),reportValidity:()=>p.reportValidity()})}}),[n,i._formValues,r,l.disabled,o,i._fields]);return Ee.useEffect(()=>{const p=i._options.shouldUnregister||s,h=(m,w)=>{const S=se(i._fields,m);S&&S._f&&(S._f.mount=w)};if(h(n,!0),p){const m=mt(se(i._options.defaultValues,n));Oe(i._defaultValues,n,m),qe(se(i._formValues,n))&&Oe(i._formValues,n,m)}return!a&&i.register(n),()=>{(a?p&&!i._state.action:p)?i.unregister(n):h(n,!1)}},[n,i,a,s]),Ee.useEffect(()=>{i._updateDisabledField({disabled:r,fields:i._fields,name:n})},[r,n,i]),Ee.useMemo(()=>({field:d,formState:l,fieldState:f}),[d,l,f])}const Eg=e=>e.render(Ng(e));var Ig=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},Bo=e=>({isOnSubmit:!e||e===Pt.onSubmit,isOnBlur:e===Pt.onBlur,isOnChange:e===Pt.onChange,isOnAll:e===Pt.all,isOnTouch:e===Pt.onTouched}),Vo=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const Nr=(e,t,n,r)=>{for(const i of n||Object.keys(e)){const s=se(e,i);if(s){const{_f:a,...o}=s;if(a){if(a.refs&&a.refs[0]&&t(a.refs[0],i)&&!r)return!0;if(a.ref&&t(a.ref,a.name)&&!r)return!0;if(Nr(o,t))break}else if(We(o)&&Nr(o,t))break}}};var zg=(e,t,n)=>{const r=Cr(se(e,n));return Oe(r,"root",t[n]),Oe(e,n,r),e},qa=e=>e.type==="file",Zt=e=>typeof e=="function",ji=e=>{if(!Ua)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},hi=e=>Bt(e),Wa=e=>e.type==="radio",Ci=e=>e instanceof RegExp;const Uo={value:!1,isValid:!1},Jo={value:!0,isValid:!0};var pd=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===""?Jo:{value:e[0].value,isValid:!0}:Jo:Uo}return Uo};const Ho={isValid:!1,value:null};var hd=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,Ho):Ho;function qo(e,t,n="validate"){if(hi(e)||Array.isArray(e)&&e.every(hi)||Ct(e)&&!e)return{type:n,message:hi(e)?e:"",ref:t}}var An=e=>We(e)&&!Ci(e)?e:{value:e,message:""},Wo=async(e,t,n,r,i,s)=>{const{ref:a,refs:o,required:l,maxLength:u,minLength:f,min:d,max:p,pattern:h,validate:m,name:w,valueAsNumber:S,mount:x}=e._f,_=se(n,w);if(!x||t.has(w))return{};const g=o?o[0]:a,T=R=>{i&&g.reportValidity&&(g.setCustomValidity(Ct(R)?"":R||""),g.reportValidity())},E={},k=Wa(a),N=Wr(a),M=k||N,Y=(S||qa(a))&&qe(a.value)&&qe(_)||ji(a)&&a.value===""||_===""||Array.isArray(_)&&!_.length,C=Ig.bind(null,w,r,E),B=(R,U,L,P=Ht.maxLength,A=Ht.minLength)=>{const J=R?U:L;E[w]={type:R?P:A,message:J,ref:a,...C(R?P:A,J)}};if(s?!Array.isArray(_)||!_.length:l&&(!M&&(Y||ct(_))||Ct(_)&&!_||N&&!pd(o).isValid||k&&!hd(o).isValid)){const{value:R,message:U}=hi(l)?{value:!!l,message:l}:An(l);if(R&&(E[w]={type:Ht.required,message:U,ref:g,...C(Ht.required,U)},!r))return T(U),E}if(!Y&&(!ct(d)||!ct(p))){let R,U;const L=An(p),P=An(d);if(!ct(_)&&!isNaN(_)){const A=a.valueAsNumber||_&&+_;ct(L.value)||(R=A>L.value),ct(P.value)||(U=A<P.value)}else{const A=a.valueAsDate||new Date(_),J=b=>new Date(new Date().toDateString()+" "+b),O=a.type=="time",q=a.type=="week";Bt(L.value)&&_&&(R=O?J(_)>J(L.value):q?_>L.value:A>new Date(L.value)),Bt(P.value)&&_&&(U=O?J(_)<J(P.value):q?_<P.value:A<new Date(P.value))}if((R||U)&&(B(!!R,L.message,P.message,Ht.max,Ht.min),!r))return T(E[w].message),E}if((u||f)&&!Y&&(Bt(_)||s&&Array.isArray(_))){const R=An(u),U=An(f),L=!ct(R.value)&&_.length>+R.value,P=!ct(U.value)&&_.length<+U.value;if((L||P)&&(B(L,R.message,U.message),!r))return T(E[w].message),E}if(h&&!Y&&Bt(_)){const{value:R,message:U}=An(h);if(Ci(R)&&!_.match(R)&&(E[w]={type:Ht.pattern,message:U,ref:a,...C(Ht.pattern,U)},!r))return T(U),E}if(m){if(Zt(m)){const R=await m(_,n),U=qo(R,g);if(U&&(E[w]={...U,...C(Ht.validate,U.message)},!r))return T(U.message),E}else if(We(m)){let R={};for(const U in m){if(!gt(R)&&!r)break;const L=qo(await m[U](_,n),g,U);L&&(R={...L,...C(U,L.message)},T(L.message),r&&(E[w]=R))}if(!gt(R)&&(E[w]={ref:g,...R},!r))return E}}return T(!0),E};function Tg(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 Ag(e){for(const t in e)if(e.hasOwnProperty(t)&&!qe(e[t]))return!1;return!0}function nt(e,t){const n=Array.isArray(t)?t:Ja(t)?[t]:od(t),r=n.length===1?e:Tg(e,n),i=n.length-1,s=n[i];return r&&delete r[s],i!==0&&(We(r)&>(r)||Array.isArray(r)&&Ag(r))&&nt(e,n.slice(0,-1)),e}var _s=()=>{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=[]}}},ca=e=>ct(e)||!id(e);function rn(e,t){if(ca(e)||ca(t))return e===t;if(vn(e)&&vn(t))return e.getTime()===t.getTime();const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n){const s=e[i];if(!r.includes(i))return!1;if(i!=="ref"){const a=t[i];if(vn(s)&&vn(a)||We(s)&&We(a)||Array.isArray(s)&&Array.isArray(a)?!rn(s,a):s!==a)return!1}}return!0}var md=e=>e.type==="select-multiple",Pg=e=>Wa(e)||Wr(e),js=e=>ji(e)&&e.isConnected,gd=e=>{for(const t in e)if(Zt(e[t]))return!0;return!1};function Ni(e,t={}){const n=Array.isArray(e);if(We(e)||n)for(const r in e)Array.isArray(e[r])||We(e[r])&&!gd(e[r])?(t[r]=Array.isArray(e[r])?[]:{},Ni(e[r],t[r])):ct(e[r])||(t[r]=!0);return t}function xd(e,t,n){const r=Array.isArray(e);if(We(e)||r)for(const i in e)Array.isArray(e[i])||We(e[i])&&!gd(e[i])?qe(t)||ca(n[i])?n[i]=Array.isArray(e[i])?Ni(e[i],[]):{...Ni(e[i])}:xd(e[i],ct(t)?{}:t[i],n[i]):n[i]=!rn(e[i],t[i]);return n}var ur=(e,t)=>xd(e,t,Ni(t)),yd=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>qe(e)?e:t?e===""?NaN:e&&+e:n&&Bt(e)?new Date(e):r?r(e):e;function Cs(e){const t=e.ref;return qa(t)?t.files:Wa(t)?hd(e.refs).value:md(t)?[...t.selectedOptions].map(({value:n})=>n):Wr(t)?pd(e.refs).value:yd(qe(t.value)?e.ref.value:t.value,e)}var Og=(e,t,n,r)=>{const i={};for(const s of e){const a=se(t,s);a&&Oe(i,s,a._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},cr=e=>qe(e)?e:Ci(e)?e.source:We(e)?Ci(e.value)?e.value.source:e.value:e;const Go="AsyncFunction";var Dg=e=>!!e&&!!e.validate&&!!(Zt(e.validate)&&e.validate.constructor.name===Go||We(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Go)),Rg=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Ko(e,t,n){const r=se(e,n);if(r||Ja(n))return{error:r,name:n};const i=n.split(".");for(;i.length;){const s=i.join("."),a=se(t,s),o=se(e,s);if(a&&!Array.isArray(a)&&n!==s)return{name:n};if(o&&o.type)return{name:s,error:o};i.pop()}return{name:n}}var Mg=(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,$g=(e,t)=>!ts(se(e,t)).length&&nt(e,t);const Fg={mode:Pt.onSubmit,reValidateMode:Pt.onChange,shouldFocusError:!0};function Lg(e={}){let t={...Fg,...e},n={submitCount:0,isDirty:!1,isLoading:Zt(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},i=We(t.defaultValues)||We(t.values)?mt(t.defaultValues||t.values)||{}:{},s=t.shouldUnregister?{}:mt(i),a={action:!1,mount:!1,watch:!1},o={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},l,u=0;const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},d={values:_s(),array:_s(),state:_s()},p=Bo(t.mode),h=Bo(t.reValidateMode),m=t.criteriaMode===Pt.all,w=j=>z=>{clearTimeout(u),u=setTimeout(j,z)},S=async j=>{if(!t.disabled&&(f.isValid||j)){const z=t.resolver?gt((await M()).errors):await C(r,!0);z!==n.isValid&&d.state.next({isValid:z})}},x=(j,z)=>{!t.disabled&&(f.isValidating||f.validatingFields)&&((j||Array.from(o.mount)).forEach(Z=>{Z&&(z?Oe(n.validatingFields,Z,z):nt(n.validatingFields,Z))}),d.state.next({validatingFields:n.validatingFields,isValidating:!gt(n.validatingFields)}))},_=(j,z=[],Z,re,te=!0,ee=!0)=>{if(re&&Z&&!t.disabled){if(a.action=!0,ee&&Array.isArray(se(r,j))){const fe=Z(se(r,j),re.argA,re.argB);te&&Oe(r,j,fe)}if(ee&&Array.isArray(se(n.errors,j))){const fe=Z(se(n.errors,j),re.argA,re.argB);te&&Oe(n.errors,j,fe),$g(n.errors,j)}if(f.touchedFields&&ee&&Array.isArray(se(n.touchedFields,j))){const fe=Z(se(n.touchedFields,j),re.argA,re.argB);te&&Oe(n.touchedFields,j,fe)}f.dirtyFields&&(n.dirtyFields=ur(i,s)),d.state.next({name:j,isDirty:R(j,z),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Oe(s,j,z)},g=(j,z)=>{Oe(n.errors,j,z),d.state.next({errors:n.errors})},T=j=>{n.errors=j,d.state.next({errors:n.errors,isValid:!1})},E=(j,z,Z,re)=>{const te=se(r,j);if(te){const ee=se(s,j,qe(Z)?se(i,j):Z);qe(ee)||re&&re.defaultChecked||z?Oe(s,j,z?ee:Cs(te._f)):P(j,ee),a.mount&&S()}},k=(j,z,Z,re,te)=>{let ee=!1,fe=!1;const be={name:j};if(!t.disabled){const F=!!(se(r,j)&&se(r,j)._f&&se(r,j)._f.disabled);if(!Z||re){f.isDirty&&(fe=n.isDirty,n.isDirty=be.isDirty=R(),ee=fe!==be.isDirty);const G=F||rn(se(i,j),z);fe=!!(!F&&se(n.dirtyFields,j)),G||F?nt(n.dirtyFields,j):Oe(n.dirtyFields,j,!0),be.dirtyFields=n.dirtyFields,ee=ee||f.dirtyFields&&fe!==!G}if(Z){const G=se(n.touchedFields,j);G||(Oe(n.touchedFields,j,Z),be.touchedFields=n.touchedFields,ee=ee||f.touchedFields&&G!==Z)}ee&&te&&d.state.next(be)}return ee?be:{}},N=(j,z,Z,re)=>{const te=se(n.errors,j),ee=f.isValid&&Ct(z)&&n.isValid!==z;if(t.delayError&&Z?(l=w(()=>g(j,Z)),l(t.delayError)):(clearTimeout(u),l=null,Z?Oe(n.errors,j,Z):nt(n.errors,j)),(Z?!rn(te,Z):te)||!gt(re)||ee){const fe={...re,...ee&&Ct(z)?{isValid:z}:{},errors:n.errors,name:j};n={...n,...fe},d.state.next(fe)}},M=async j=>{x(j,!0);const z=await t.resolver(s,t.context,Og(j||o.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return x(j),z},Y=async j=>{const{errors:z}=await M(j);if(j)for(const Z of j){const re=se(z,Z);re?Oe(n.errors,Z,re):nt(n.errors,Z)}else n.errors=z;return z},C=async(j,z,Z={valid:!0})=>{for(const re in j){const te=j[re];if(te){const{_f:ee,...fe}=te;if(ee){const be=o.array.has(ee.name),F=te._f&&Dg(te._f);F&&f.validatingFields&&x([re],!0);const G=await Wo(te,o.disabled,s,m,t.shouldUseNativeValidation&&!z,be);if(F&&f.validatingFields&&x([re]),G[ee.name]&&(Z.valid=!1,z))break;!z&&(se(G,ee.name)?be?zg(n.errors,G,ee.name):Oe(n.errors,ee.name,G[ee.name]):nt(n.errors,ee.name))}!gt(fe)&&await C(fe,z,Z)}}return Z.valid},B=()=>{for(const j of o.unMount){const z=se(r,j);z&&(z._f.refs?z._f.refs.every(Z=>!js(Z)):!js(z._f.ref))&&ne(j)}o.unMount=new Set},R=(j,z)=>!t.disabled&&(j&&z&&Oe(s,j,z),!rn(ce(),i)),U=(j,z,Z)=>fd(j,o,{...a.mount?s:qe(z)?i:Bt(j)?{[j]:z}:z},Z,z),L=j=>ts(se(a.mount?s:i,j,t.shouldUnregister?se(i,j,[]):[])),P=(j,z,Z={})=>{const re=se(r,j);let te=z;if(re){const ee=re._f;ee&&(!ee.disabled&&Oe(s,j,yd(z,ee)),te=ji(ee.ref)&&ct(z)?"":z,md(ee.ref)?[...ee.ref.options].forEach(fe=>fe.selected=te.includes(fe.value)):ee.refs?Wr(ee.ref)?ee.refs.length>1?ee.refs.forEach(fe=>(!fe.defaultChecked||!fe.disabled)&&(fe.checked=Array.isArray(te)?!!te.find(be=>be===fe.value):te===fe.value)):ee.refs[0]&&(ee.refs[0].checked=!!te):ee.refs.forEach(fe=>fe.checked=fe.value===te):qa(ee.ref)?ee.ref.value="":(ee.ref.value=te,ee.ref.type||d.values.next({name:j,values:{...s}})))}(Z.shouldDirty||Z.shouldTouch)&&k(j,te,Z.shouldTouch,Z.shouldDirty,!0),Z.shouldValidate&&b(j)},A=(j,z,Z)=>{for(const re in z){const te=z[re],ee=`${j}.${re}`,fe=se(r,ee);(o.array.has(j)||We(te)||fe&&!fe._f)&&!vn(te)?A(ee,te,Z):P(ee,te,Z)}},J=(j,z,Z={})=>{const re=se(r,j),te=o.array.has(j),ee=mt(z);Oe(s,j,ee),te?(d.array.next({name:j,values:{...s}}),(f.isDirty||f.dirtyFields)&&Z.shouldDirty&&d.state.next({name:j,dirtyFields:ur(i,s),isDirty:R(j,ee)})):re&&!re._f&&!ct(ee)?A(j,ee,Z):P(j,ee,Z),Vo(j,o)&&d.state.next({...n}),d.values.next({name:a.mount?j:void 0,values:{...s}})},O=async j=>{a.mount=!0;const z=j.target;let Z=z.name,re=!0;const te=se(r,Z),ee=()=>z.type?Cs(te._f):sd(j),fe=be=>{re=Number.isNaN(be)||vn(be)&&isNaN(be.getTime())||rn(be,se(s,Z,be))};if(te){let be,F;const G=ee(),pe=j.type===_i.BLUR||j.type===_i.FOCUS_OUT,ke=!Rg(te._f)&&!t.resolver&&!se(n.errors,Z)&&!te._f.deps||Mg(pe,se(n.touchedFields,Z),n.isSubmitted,h,p),D=Vo(Z,o,pe);Oe(s,Z,G),pe?(te._f.onBlur&&te._f.onBlur(j),l&&l(0)):te._f.onChange&&te._f.onChange(j);const he=k(Z,G,pe,!1),Ne=!gt(he)||D;if(!pe&&d.values.next({name:Z,type:j.type,values:{...s}}),ke)return f.isValid&&(t.mode==="onBlur"&&pe?S():pe||S()),Ne&&d.state.next({name:Z,...D?{}:he});if(!pe&&D&&d.state.next({...n}),t.resolver){const{errors:Me}=await M([Z]);if(fe(G),re){const tt=Ko(n.errors,r,Z),Ke=Ko(Me,r,tt.name||Z);be=Ke.error,Z=Ke.name,F=gt(Me)}}else x([Z],!0),be=(await Wo(te,o.disabled,s,m,t.shouldUseNativeValidation))[Z],x([Z]),fe(G),re&&(be?F=!1:f.isValid&&(F=await C(r,!0)));re&&(te._f.deps&&b(te._f.deps),N(Z,F,be,he))}},q=(j,z)=>{if(se(n.errors,z)&&j.focus)return j.focus(),1},b=async(j,z={})=>{let Z,re;const te=Cr(j);if(t.resolver){const ee=await Y(qe(j)?j:te);Z=gt(ee),re=j?!te.some(fe=>se(ee,fe)):Z}else j?(re=(await Promise.all(te.map(async ee=>{const fe=se(r,ee);return await C(fe&&fe._f?{[ee]:fe}:fe)}))).every(Boolean),!(!re&&!n.isValid)&&S()):re=Z=await C(r);return d.state.next({...!Bt(j)||f.isValid&&Z!==n.isValid?{}:{name:j},...t.resolver||!j?{isValid:Z}:{},errors:n.errors}),z.shouldFocus&&!re&&Nr(r,q,j?te:o.mount),re},ce=j=>{const z={...a.mount?s:i};return qe(j)?z:Bt(j)?se(z,j):j.map(Z=>se(z,Z))},oe=(j,z)=>({invalid:!!se((z||n).errors,j),isDirty:!!se((z||n).dirtyFields,j),error:se((z||n).errors,j),isValidating:!!se(n.validatingFields,j),isTouched:!!se((z||n).touchedFields,j)}),v=j=>{j&&Cr(j).forEach(z=>nt(n.errors,z)),d.state.next({errors:j?n.errors:{}})},X=(j,z,Z)=>{const re=(se(r,j,{_f:{}})._f||{}).ref,te=se(n.errors,j)||{},{ref:ee,message:fe,type:be,...F}=te;Oe(n.errors,j,{...F,...z,ref:re}),d.state.next({name:j,errors:n.errors,isValid:!1}),Z&&Z.shouldFocus&&re&&re.focus&&re.focus()},ae=(j,z)=>Zt(j)?d.values.subscribe({next:Z=>j(U(void 0,z),Z)}):U(j,z,!0),ne=(j,z={})=>{for(const Z of j?Cr(j):o.mount)o.mount.delete(Z),o.array.delete(Z),z.keepValue||(nt(r,Z),nt(s,Z)),!z.keepError&&nt(n.errors,Z),!z.keepDirty&&nt(n.dirtyFields,Z),!z.keepTouched&&nt(n.touchedFields,Z),!z.keepIsValidating&&nt(n.validatingFields,Z),!t.shouldUnregister&&!z.keepDefaultValue&&nt(i,Z);d.values.next({values:{...s}}),d.state.next({...n,...z.keepDirty?{isDirty:R()}:{}}),!z.keepIsValid&&S()},I=({disabled:j,name:z,field:Z,fields:re})=>{(Ct(j)&&a.mount||j||o.disabled.has(z))&&(j?o.disabled.add(z):o.disabled.delete(z),k(z,Cs(Z?Z._f:se(re,z)._f),!1,!1,!0))},$=(j,z={})=>{let Z=se(r,j);const re=Ct(z.disabled)||Ct(t.disabled);return Oe(r,j,{...Z||{},_f:{...Z&&Z._f?Z._f:{ref:{name:j}},name:j,mount:!0,...z}}),o.mount.add(j),Z?I({field:Z,disabled:Ct(z.disabled)?z.disabled:t.disabled,name:j}):E(j,!0,z.value),{...re?{disabled:z.disabled||t.disabled}:{},...t.progressive?{required:!!z.required,min:cr(z.min),max:cr(z.max),minLength:cr(z.minLength),maxLength:cr(z.maxLength),pattern:cr(z.pattern)}:{},name:j,onChange:O,onBlur:O,ref:te=>{if(te){$(j,z),Z=se(r,j);const ee=qe(te.value)&&te.querySelectorAll&&te.querySelectorAll("input,select,textarea")[0]||te,fe=Pg(ee),be=Z._f.refs||[];if(fe?be.find(F=>F===ee):ee===Z._f.ref)return;Oe(r,j,{_f:{...Z._f,...fe?{refs:[...be.filter(js),ee,...Array.isArray(se(i,j))?[{}]:[]],ref:{type:ee.type,name:j}}:{ref:ee}}}),E(j,!1,void 0,ee)}else Z=se(r,j,{}),Z._f&&(Z._f.mount=!1),(t.shouldUnregister||z.shouldUnregister)&&!(ad(o.array,j)&&a.action)&&o.unMount.add(j)}}},W=()=>t.shouldFocusError&&Nr(r,q,o.mount),le=j=>{Ct(j)&&(d.state.next({disabled:j}),Nr(r,(z,Z)=>{const re=se(r,Z);re&&(z.disabled=re._f.disabled||j,Array.isArray(re._f.refs)&&re._f.refs.forEach(te=>{te.disabled=re._f.disabled||j}))},0,!1))},K=(j,z)=>async Z=>{let re;Z&&(Z.preventDefault&&Z.preventDefault(),Z.persist&&Z.persist());let te=mt(s);if(o.disabled.size)for(const ee of o.disabled)Oe(te,ee,void 0);if(d.state.next({isSubmitting:!0}),t.resolver){const{errors:ee,values:fe}=await M();n.errors=ee,te=fe}else await C(r);if(nt(n.errors,"root"),gt(n.errors)){d.state.next({errors:{}});try{await j(te,Z)}catch(ee){re=ee}}else z&&await z({...n.errors},Z),W(),setTimeout(W);if(d.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:gt(n.errors)&&!re,submitCount:n.submitCount+1,errors:n.errors}),re)throw re},ve=(j,z={})=>{se(r,j)&&(qe(z.defaultValue)?J(j,mt(se(i,j))):(J(j,z.defaultValue),Oe(i,j,mt(z.defaultValue))),z.keepTouched||nt(n.touchedFields,j),z.keepDirty||(nt(n.dirtyFields,j),n.isDirty=z.defaultValue?R(j,mt(se(i,j))):R()),z.keepError||(nt(n.errors,j),f.isValid&&S()),d.state.next({...n}))},de=(j,z={})=>{const Z=j?mt(j):i,re=mt(Z),te=gt(j),ee=te?i:re;if(z.keepDefaultValues||(i=Z),!z.keepValues){if(z.keepDirtyValues){const fe=new Set([...o.mount,...Object.keys(ur(i,s))]);for(const be of Array.from(fe))se(n.dirtyFields,be)?Oe(ee,be,se(s,be)):J(be,se(ee,be))}else{if(Ua&&qe(j))for(const fe of o.mount){const be=se(r,fe);if(be&&be._f){const F=Array.isArray(be._f.refs)?be._f.refs[0]:be._f.ref;if(ji(F)){const G=F.closest("form");if(G){G.reset();break}}}}r={}}s=t.shouldUnregister?z.keepDefaultValues?mt(i):{}:mt(ee),d.array.next({values:{...ee}}),d.values.next({values:{...ee}})}o={mount:z.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},a.mount=!f.isValid||!!z.keepIsValid||!!z.keepDirtyValues,a.watch=!!t.shouldUnregister,d.state.next({submitCount:z.keepSubmitCount?n.submitCount:0,isDirty:te?!1:z.keepDirty?n.isDirty:!!(z.keepDefaultValues&&!rn(j,i)),isSubmitted:z.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:te?{}:z.keepDirtyValues?z.keepDefaultValues&&s?ur(i,s):n.dirtyFields:z.keepDefaultValues&&j?ur(i,j):z.keepDirty?n.dirtyFields:{},touchedFields:z.keepTouched?n.touchedFields:{},errors:z.keepErrors?n.errors:{},isSubmitSuccessful:z.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},xe=(j,z)=>de(Zt(j)?j(s):j,z);return{control:{register:$,unregister:ne,getFieldState:oe,handleSubmit:K,setError:X,_executeSchema:M,_getWatch:U,_getDirty:R,_updateValid:S,_removeUnmounted:B,_updateFieldArray:_,_updateDisabledField:I,_getFieldArray:L,_reset:de,_resetDefaultValues:()=>Zt(t.defaultValues)&&t.defaultValues().then(j=>{xe(j,t.resetOptions),d.state.next({isLoading:!1})}),_updateFormState:j=>{n={...n,...j}},_disableForm:le,_subjects:d,_proxyFormState:f,_setErrors:T,get _fields(){return r},get _formValues(){return s},get _state(){return a},set _state(j){a=j},get _defaultValues(){return i},get _names(){return o},set _names(j){o=j},get _formState(){return n},set _formState(j){n=j},get _options(){return t},set _options(j){t={...t,...j}}},trigger:b,register:$,handleSubmit:K,watch:ae,setValue:J,getValues:ce,reset:xe,resetField:ve,clearErrors:v,unregister:ne,setError:X,setFocus:(j,z={})=>{const Z=se(r,j),re=Z&&Z._f;if(re){const te=re.refs?re.refs[0]:re.ref;te.focus&&(te.focus(),z.shouldSelect&&Zt(te.select)&&te.select())}},getFieldState:oe}}function Zg(e={}){const t=Ee.useRef(void 0),n=Ee.useRef(void 0),[r,i]=Ee.useState({isDirty:!1,isValidating:!1,isLoading:Zt(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Zt(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...Lg(e),formState:r});const s=t.current.control;return s._options=e,Ha({subject:s._subjects.state,next:a=>{cd(a,s._proxyFormState,s._updateFormState,!0)&&i({...s._formState})}}),Ee.useEffect(()=>s._disableForm(e.disabled),[s,e.disabled]),Ee.useEffect(()=>{if(s._proxyFormState.isDirty){const a=s._getDirty();a!==r.isDirty&&s._subjects.state.next({isDirty:a})}},[s,r.isDirty]),Ee.useEffect(()=>{e.values&&!rn(e.values,n.current)?(s._reset(e.values,s._options.resetOptions),n.current=e.values,i(a=>({...a}))):s._resetDefaultValues()},[e.values,s]),Ee.useEffect(()=>{e.errors&&s._setErrors(e.errors)},[e.errors,s]),Ee.useEffect(()=>{s._state.mount||(s._updateValid(),s._state.mount=!0),s._state.watch&&(s._state.watch=!1,s._subjects.state.next({...s._formState})),s._removeUnmounted()}),Ee.useEffect(()=>{e.shouldUnregister&&s._subjects.values.next({values:s._getWatch()})},[e.shouldUnregister,s]),t.current.formState=ud(r,s),t.current}function Bg(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 Dt=pc,Yo=hc,Vg=mc,Xo=Ba,bd=y.forwardRef(({className:e,...t},n)=>c.jsx(Xi,{ref:n,className:H("fixed inset-0 z-50 bg-black/80",e),...t}));bd.displayName=Xi.displayName;const Et=y.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Vg,{children:[c.jsx(bd,{}),c.jsxs(Gi,{ref:r,className:H("bg-background fixed top-[50%] left-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border p-6 shadow-lg sm:rounded-lg",e),...n,children:[t,c.jsxs(Ba,{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:[c.jsx(jn,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Et.displayName=Gi.displayName;const Gt=({className:e,...t})=>c.jsx("div",{className:H("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Gt.displayName="DialogHeader";const Yn=({className:e,...t})=>c.jsx("div",{className:H("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Yn.displayName="DialogFooter";const Kt=y.forwardRef(({className:e,...t},n)=>c.jsx(Ki,{ref:n,className:H("text-lg leading-none font-semibold tracking-tight",e),...t}));Kt.displayName=Ki.displayName;const Cn=y.forwardRef(({className:e,...t},n)=>c.jsx(Yi,{ref:n,className:H("text-muted-foreground text-sm",e),...t}));Cn.displayName=Yi.displayName;const Ug=qr("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ga=y.forwardRef(({className:e,...t},n)=>c.jsx(gc,{ref:n,className:H(Ug(),e),...t}));Ga.displayName=gc.displayName;const Jg=_g,vd=y.createContext({}),Qo=({...e})=>c.jsx(vd.Provider,{value:{name:e.name},children:c.jsx(Eg,{...e})}),rs=()=>{const e=y.useContext(vd),t=y.useContext(wd),{getFieldState:n,formState:r}=ns(),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}},wd=y.createContext({}),da=y.forwardRef(({className:e,...t},n)=>{const r=y.useId();return c.jsx(wd.Provider,{value:{id:r},children:c.jsx("div",{ref:n,className:H("space-y-2",e),...t})})});da.displayName="FormItem";const fa=y.forwardRef(({className:e,...t},n)=>{const{error:r,formItemId:i}=rs();return c.jsx(Ga,{ref:n,className:H(r&&"text-destructive",e),htmlFor:i,...t})});fa.displayName="FormLabel";const pa=y.forwardRef(({...e},t)=>{const{error:n,formItemId:r,formDescriptionId:i,formMessageId:s}=rs();return c.jsx(rr,{ref:t,id:r,"aria-describedby":n?`${i} ${s}`:`${i}`,"aria-invalid":!!n,...e})});pa.displayName="FormControl";const kd=y.forwardRef(({className:e,...t},n)=>{const{formDescriptionId:r}=rs();return c.jsx("p",{ref:n,id:r,className:H("text-muted-foreground text-[0.8rem]",e),...t})});kd.displayName="FormDescription";const ha=y.forwardRef(({className:e,children:t,...n},r)=>{const{error:i,formMessageId:s}=rs(),a=i?String(i==null?void 0:i.message):t;return a?c.jsx("p",{ref:r,id:s,className:H("text-destructive text-[0.8rem] font-medium",e),...n,children:a}):null});ha.displayName="FormMessage";const is=y.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:H("border-input file:text-foreground placeholder:text-muted-foreground focus-visible:ring-ring flex h-9 w-full rounded-md border bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:ring-1 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));is.displayName="Input";const Ka=xm,Hg=_m,Ya=ym,ss=y.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(xc,{ref:r,className:H("border-input ring-offset-background placeholder:text-muted-foreground focus:ring-ring flex h-9 w-full items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm shadow-sm focus:ring-1 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 [&>span]:truncate cursor-pointer",e),...n,children:[t,c.jsx(bm,{asChild:!0,children:c.jsx(an,{className:"h-4 w-4 shrink-0 opacity-50"})})]}));ss.displayName=xc.displayName;const Sd=y.forwardRef(({className:e,...t},n)=>c.jsx(vc,{ref:n,className:H("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(Lm,{className:"h-4 w-4"})}));Sd.displayName=vc.displayName;const _d=y.forwardRef(({className:e,...t},n)=>c.jsx(wc,{ref:n,className:H("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(an,{className:"h-4 w-4"})}));_d.displayName=wc.displayName;const as=y.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>c.jsx(vm,{children:c.jsxs(yc,{ref:i,className:H("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[c.jsx(Sd,{}),c.jsx(wm,{className:H("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(_d,{})]})}));as.displayName=yc.displayName;const jd=y.forwardRef(({className:e,...t},n)=>c.jsx(kc,{ref:n,className:H("px-2 py-1.5 text-sm font-semibold",e),...t}));jd.displayName=kc.displayName;const Ar=y.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(bc,{ref:r,className:H("focus:bg-accent focus:text-accent-foreground relative flex w-full cursor-pointer items-center rounded-sm py-1.5 pr-8 pl-2 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(km,{children:c.jsx(ln,{className:"h-4 w-4"})})}),c.jsx(Sm,{children:t})]}));Ar.displayName=bc.displayName;const qg=y.forwardRef(({className:e,...t},n)=>c.jsx(Sc,{ref:n,className:H("bg-muted -mx-1 my-1 h-px",e),...t}));qg.displayName=Sc.displayName;function Xa(){const e=new Date,t=n=>String(n).padStart(2,"0");return`Chat ${t(e.getMonth()+1)}/${t(e.getDate())} ${t(e.getHours())}:${t(e.getMinutes())}`}const Cd=()=>({chatOpen:!1,scope:"global",model:"opus",contextAttachments:[],threads:{},activeThreadId:{}}),Wg=(e=Cd())=>mg()(gg(xg((t,n)=>({...e,toggleChat:()=>t(r=>({chatOpen:!r.chatOpen})),openChat:()=>t({chatOpen:!0}),closeChat:()=>t({chatOpen:!1}),addContext:r=>t(i=>({contextAttachments:[...i.contextAttachments,r]})),removeContext:r=>t(i=>({contextAttachments:i.contextAttachments.filter((s,a)=>a!==r)})),clearContext:()=>t({contextAttachments:[]}),setScope:r=>t({scope:r}),setModel:r=>t({model:r}),createThread:r=>{const i=crypto.randomUUID(),s=Date.now(),a={id:i,documentName:r,title:Xa(),messages:[],createdAt:s,updatedAt:s};return t(o=>({threads:{...o.threads,[i]:a},activeThreadId:{...o.activeThreadId,[r]:i}})),i},deleteThread:r=>{const i=n(),s=i.threads[r];if(!s)return;const a=Object.fromEntries(Object.entries(i.threads).filter(([u])=>u!==r)),o=s.documentName,l={...i.activeThreadId};if(l[o]===r){const u=Object.values(a).filter(f=>f.documentName===o);u.length>0?(u.sort((f,d)=>d.updatedAt-f.updatedAt),l[o]=u[0].id):delete l[o]}t({threads:a,activeThreadId:l})},switchThread:r=>{const s=n().threads[r];s&&t(a=>({activeThreadId:{...a.activeThreadId,[s.documentName]:r}}))},updateThreadMessages:(r,i)=>{t(s=>{const a=s.threads[r];return a?{threads:{...s.threads,[r]:{...a,messages:i,updatedAt:Date.now()}}}:s})},updateThreadTitle:(r,i)=>{t(s=>{const a=s.threads[r];return a?{threads:{...s.threads,[r]:{...a,title:i}}}:s})},deleteThreadsForDocument:r=>{t(i=>{const s={...i.threads},a={...i.activeThreadId};for(const[o,l]of Object.entries(s))l.documentName===r&&delete s[o];return delete a[r],{threads:s,activeThreadId:a}})},renameThreadsForDocument:(r,i)=>{t(s=>{const a={...s.threads},o={...s.activeThreadId};for(const[l,u]of Object.entries(a))u.documentName===r&&(a[l]={...u,documentName:i});return r in o&&(o[i]=o[r],delete o[r]),{threads:a,activeThreadId:o}})},clearChat:()=>{t(r=>({contextAttachments:[]}))}}),{name:"chat-storage",version:1,storage:yg(()=>ug),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}}))),Nd=y.createContext(void 0),Gg=({children:e})=>{const t=y.useRef(null);return t.current||(t.current=Wg(Cd())),c.jsx(Nd.Provider,{value:t.current,children:e})},Te=e=>{const t=y.useContext(Nd);if(!t)throw new Error("useChatStore must be used within ChatStoreProvider");return bg(t,e)};function Kg(e,t,n){return t.filter(r=>r.name!==n).every(r=>r.name!==e)}function Yg(e,t,n){const r={},i=[];e!=="delete"&&(r.name=ei.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=ei.Optional(ei.String({description:"Template selection"})));const s=ei.Object(r,{additionalProperties:!1,required:i.length>0?i:void 0});return{schema:s,validate:a=>{const o=[];if(!um(s,a))for(const u of cm(s,a))o.push({path:u.path.replace(/^\//,""),message:u.message});const l=a;if(e!=="delete"&&l.name){const u=l.name.trim();u?(l.name=u,t(u)||o.push({path:"name",message:"Document with this name already exists"})):o.push({path:"name",message:"Name can't be empty"})}return e==="create"&&(n!=null&&n.length)&&l.template&&(n.some(u=>u.name===l.template)||o.push({path:"template",message:"You must select a valid template"})),{success:o.length===0,data:o.length===0?l:void 0,errors:o}}}}function Xg(e,t,n){return e==="create"?{name:"",template:t}:e==="update"?{name:n}:{}}const Qg=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"}}),dr="__empty__";function ex({mode:e,shouldReset:t,postSubmit:n,selectedName:r,discoveredDocuments:i,discoveredThemes:s,isTheme:a}){const[o,l]=y.useState(!1),[u,f]=y.useState(null),d=Qg(a),{documents:p,openTabs:h,createDocument:m,renameDocument:w,deleteDocument:S,openDocument:x,closeDocument:_}=Ae(O=>O),{updateTheme:g,removeTheme:T}=la(O=>O),E=Te(O=>O.renameThreadsForDocument),k=Te(O=>O.deleteThreadsForDocument),N=y.useMemo(()=>a?s||[]:i||[],[a,i,s]),M=y.useMemo(()=>{const O={current:[],downstream:[]};return N.forEach(q=>{O[q.location]&&O[q.location].push(q)}),O},[N]),Y=y.useMemo(()=>N.map(O=>({name:O.name,type:"application/json",text:"",mtime:new Date,ctime:new Date,atime:new Date})),[N]),C=y.useMemo(()=>Yg(e,O=>Kg(O,p,r),Y),[e,p,r,Y]),B=C.schema,R=y.useMemo(()=>{const O=new Map;return N.forEach(q=>O.set(q.path,q)),O},[N]),U=dr,L=Zg({resolver:Bg(C.validate),defaultValues:Xg(e,void 0,r)}),[P,A]=y.useState(U);y.useEffect(()=>{if(P&&P!==dr&&e==="create"){const O=R.get(P);O&&fetch(`/api/discovery/${a?"themes":"documents"}/${encodeURIComponent(O.name)}/content`).then(q=>{if(!q.ok)throw new Error(`Failed to fetch content: ${q.statusText}`);return q.text()}).then(q=>{try{const b=JSON.parse(q);f(JSON.stringify(b,null,2))}catch(b){console.error("Invalid JSON content received:",b),f(null)}}).catch(q=>{console.error("Failed to fetch content:",q),f(null)})}},[P,e,R,a]),y.useEffect(()=>{t&&(L.reset(),f(null),A(U))},[L,t]);const J=L.handleSubmit(async({name:O,template:q})=>{l(!0);try{if(await new Promise(b=>setTimeout(b,200)),e==="create"){const b=P?R.get(P):N.find($=>$.name===q);let ce,oe=O;if(a){const $=oe.replace(/\.(json|theme)$/i,"").toLowerCase().replace(/\s+/g,"-");ce=u||JSON.stringify(kt==="docx"?{name:$,colors:{primary:"#2563EB",secondary:"#64748B",accent:"#F8FAFC",background:"#FFFFFF",text:"#334155"},fonts:{heading:{family:"Calibri",size:28},body:{family:"Calibri",size:11}},page:{size:"A4"}}:{name:$,colors:{primary:"#2563EB",secondary:"#64748B",accent:"#F8FAFC",background:"#FFFFFF",text:"#334155"},fonts:{heading:"Calibri",body:"Calibri"},defaults:{fontSize:18,fontColor:"#334155"}},null,2);const le=`.${kt}.theme.json`;oe.endsWith(le)||(oe=oe.replace(/\.(pptx|docx)\.theme\.json$/i,"").replace(/\.theme\.json$/i,"").replace(/\.json$/i,""),oe+=le)}else{const $=b;ce=u||JSON.stringify(kt==="docx"?{name:"docx",props:{theme:($==null?void 0:$.theme)||"default",metadata:{title:($==null?void 0:$.title)||oe.replace(/\.(json|js)$/i,"")}},children:[{name:"section",props:{},children:[{name:"paragraph",props:{text:"Start writing your document content here..."}}]}]}:{name:"pptx",props:{title:($==null?void 0:$.title)||oe.replace(/\.(json|js)$/i,""),theme:($==null?void 0:$.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 W=kt==="docx"?".docx.json":".pptx.json";!oe.endsWith(W)&&!oe.endsWith(".json")&&(oe+=W)}const v=oe.match(/(\.(pptx|docx)(\.theme)?\.json|\.json)$/i),X=v?v[0]:"",ae=oe.slice(0,oe.length-X.length);let ne=oe,I=1;for(;p.some($=>$.name===ne);)I++,ne=`${ae} (${I})${X}`;oe=ne,m(oe,ce),x(oe),a&&g(oe,ce)}else if(e==="update"){const b=r,ce=O,oe=h.includes(b);oe&&_(b),w(b,ce),E(b,ce),oe&&x(ce)}else if(e==="delete"){const b=r;_(b),S(b),k(b),a&&T(b)}n()}finally{l(!1)}});return c.jsx(Jg,{...L,children:c.jsxs("form",{onSubmit:J,children:[c.jsxs(Gt,{children:[c.jsx(Kt,{children:d[e].title}),c.jsx(Cn,{children:d[e].description})]}),c.jsxs("div",{className:"flex flex-col gap-4 py-4",children:[B.properties&&"name"in B.properties&&c.jsx(Qo,{control:L.control,name:"name",render:({field:O})=>c.jsxs(da,{children:[c.jsx(fa,{children:"Name"}),c.jsx(pa,{children:c.jsx(is,{placeholder:"Enter a name or select a template below",autoComplete:"off",...O})}),c.jsx(ha,{})]})}),e==="create"&&c.jsx(Qo,{control:L.control,name:"template",render:({field:O})=>c.jsxs(da,{children:[c.jsx(fa,{children:a?"Base Theme":"Base Document"}),c.jsxs(Ka,{onValueChange:q=>{if(q===dr)O.onChange(void 0),L.setValue("name",""),A(dr),f(null);else{const b=R.get(q);b&&(O.onChange(b.name),L.setValue("name",b.name),A(q))}},defaultValue:U,children:[c.jsx(pa,{children:c.jsx(ss,{children:c.jsx(Ya,{placeholder:`Select a discovered ${a?"theme":"document"}`})})}),c.jsxs(as,{className:"max-h-[300px]",children:[c.jsxs(Ar,{value:dr,children:["Empty ",a?"theme":"document"]}),Object.entries(M).map(([q,b])=>b.length===0?null:c.jsxs(Hg,{children:[c.jsx(jd,{children:q==="current"?"📁 Current Directory":"📦 Project"}),b.map(ce=>{let oe=ce.name;if(ce.title)oe=`${ce.name} - ${ce.title}`;else if(ce.description){const v=ce.description.length>40?ce.description.substring(0,40)+"...":ce.description;oe=`${ce.name} - ${v}`}return c.jsx(Ar,{value:ce.path,className:"pl-6",children:oe},ce.path)})]},q))]})]}),c.jsxs(kd,{children:["Start empty or select a discovered"," ",a?"theme":"document"," as a starting point"]}),c.jsx(ha,{})]})})]}),c.jsx(Yn,{children:c.jsx(_e,{type:"submit",variant:d[e].buttonVariant,disabled:o,children:o?c.jsxs(c.Fragment,{children:[c.jsx(nn,{size:"sm",className:"mr-2"}),e==="create"?"Creating...":e==="update"?"Saving...":"Deleting..."]}):d[e].button})})]})})}const Ei=Ee.memo(ex),tx=jm,nx=Cm,rx=y.forwardRef(({className:e,inset:t,children:n,...r},i)=>c.jsxs(Nc,{ref:i,className:H("focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-pointer items-center rounded-sm px-2 py-1.5 text-sm outline-none select-none",t&&"pl-8",e),...r,children:[n,c.jsx(Qi,{className:"ml-auto h-4 w-4"})]}));rx.displayName=Nc.displayName;const ix=y.forwardRef(({className:e,...t},n)=>c.jsx(Ec,{ref:n,className:H("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-lg",e),...t}));ix.displayName=Ec.displayName;const Ed=y.forwardRef(({className:e,...t},n)=>c.jsx(Nm,{children:c.jsx(_c,{ref:n,className:H("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-md",e),...t})}));Ed.displayName=_c.displayName;const yr=y.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(jc,{ref:r,className:H("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm px-2 py-1.5 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));yr.displayName=jc.displayName;const sx=y.forwardRef(({className:e,children:t,checked:n,...r},i)=>c.jsxs(Ic,{ref:i,className:H("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(zc,{children:c.jsx(ln,{className:"h-4 w-4"})})}),t]}));sx.displayName=Ic.displayName;const ax=y.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Tc,{ref:r,className:H("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(zc,{children:c.jsx(Wc,{className:"h-4 w-4 fill-current"})})}),t]}));ax.displayName=Tc.displayName;const ox=y.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Ac,{ref:r,className:H("text-foreground px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));ox.displayName=Ac.displayName;const ma=y.forwardRef(({className:e,...t},n)=>c.jsx(Cc,{ref:n,className:H("bg-border -mx-1 my-1 h-px",e),...t}));ma.displayName=Cc.displayName;const mi=({className:e,...t})=>c.jsx("span",{className:H("text-muted-foreground ml-auto text-xs tracking-widest",e),...t});mi.displayName="ContextMenuShortcut";const Id=y.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},i)=>c.jsx(Pc,{ref:i,decorative:n,orientation:t,className:H("bg-border shrink-0",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Id.displayName=Pc.displayName;const zd=pc,lx=hc,ux=mc,Td=y.forwardRef(({className:e,...t},n)=>c.jsx(Xi,{className:H("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80",e),...t,ref:n}));Td.displayName=Xi.displayName;const cx=qr("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),Qa=y.forwardRef(({side:e="right",className:t,children:n,...r},i)=>c.jsxs(ux,{children:[c.jsx(Td,{}),c.jsxs(Gi,{ref:i,className:H(cx({side:e}),t),...r,children:[c.jsxs(Ba,{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:[c.jsx(jn,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]}),n]})]}));Qa.displayName=Gi.displayName;const dx=y.forwardRef(({className:e,...t},n)=>c.jsx(Ki,{ref:n,className:H("text-foreground text-lg font-semibold",e),...t}));dx.displayName=Ki.displayName;const fx=y.forwardRef(({className:e,...t},n)=>c.jsx(Yi,{ref:n,className:H("text-muted-foreground text-sm",e),...t}));fx.displayName=Yi.displayName;function Er({className:e,...t}){return c.jsx("div",{className:H("bg-primary/10 animate-pulse rounded-md",e),...t})}const Ns=768,Es=1200;function Ad(e){return typeof window<"u"?window.innerWidth<e:!1}function Pd(){const[e,t]=y.useState(()=>Ad(Ns));return y.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Ns-1}px)`),r=()=>{t(window.innerWidth<Ns)};return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}function px(){const[e,t]=y.useState(()=>Ad(Es));return y.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Es-1}px)`),r=()=>{t(window.innerWidth<Es)};return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}const hx="sidebar_state",mx=60*60*24*7,gx="16rem",xx="18rem",yx="3rem",bx="b",Od=y.createContext(null);function os(){const e=y.useContext(Od);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const Dd=y.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:s,...a},o)=>{const l=Pd(),[u,f]=y.useState(!1),[d,p]=y.useState(e),h=t??d,m=y.useCallback(_=>{const g=typeof _=="function"?_(h):_;n?n(g):p(g),document.cookie=`${hx}=${g}; path=/; max-age=${mx}`},[n,h]),w=y.useCallback(()=>l?f(_=>!_):m(_=>!_),[l,m,f]);y.useEffect(()=>{const _=T=>{var N;const E=T;if(!E)return!1;const k=(N=E.tagName)==null?void 0:N.toLowerCase();return k==="input"||k==="textarea"||k==="select"||E.isContentEditable?!0:!!(E.closest&&E.closest(".monaco-editor"))},g=T=>{const E=T.metaKey||T.ctrlKey,k=T.key.toLowerCase();if(E&&k===bx){T.preventDefault(),w();return}E&&k==="s"&&!_(T.target)&&(T.preventDefault(),w())};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[w]);const S=h?"expanded":"collapsed",x=y.useMemo(()=>({state:S,open:h,setOpen:m,isMobile:l,openMobile:u,setOpenMobile:f,toggleSidebar:w}),[S,h,m,l,u,f,w]);return c.jsx(Od.Provider,{value:x,children:c.jsx(dm,{delayDuration:0,children:c.jsx("div",{style:{"--sidebar-width":gx,"--sidebar-width-icon":yx,...i},className:H("group/sidebar-wrapper has-[[data-variant=inset]]:bg-sidebar flex min-h-svh w-full",r),ref:o,...a,children:s})})})});Dd.displayName="SidebarProvider";const Rd=y.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:i,...s},a)=>{const{isMobile:o,state:l,openMobile:u,setOpenMobile:f}=os();return n==="none"?c.jsx("div",{className:H("bg-sidebar text-sidebar-foreground flex h-full w-[--sidebar-width] flex-col",r),ref:a,...s,children:i}):o?c.jsx(zd,{open:u,onOpenChange:f,...s,children:c.jsx(Qa,{"data-sidebar":"sidebar","data-mobile":"true",className:"bg-sidebar text-sidebar-foreground w-[--sidebar-width] p-0 [&>button]:hidden",style:{"--sidebar-width":xx},side:e,children:c.jsx("div",{className:"flex h-full w-full flex-col",children:i})})}):c.jsxs("div",{ref:a,className:"group peer text-sidebar-foreground hidden md:block","data-state":l,"data-collapsible":l==="collapsed"?n:"","data-variant":t,"data-side":e,children:[c.jsx("div",{className:H("relative h-svh w-[--sidebar-width] bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),c.jsx("div",{className:H("fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] duration-200 ease-linear md:flex",e==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",t==="floating"||t==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...s,children:c.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})})]})});Rd.displayName="Sidebar";const vx=y.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:i}=os();return c.jsxs(_e,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:H("h-7 w-7",e),onClick:s=>{t==null||t(s),i()},...n,children:[c.jsx(Zm,{}),c.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});vx.displayName="SidebarTrigger";const wx=y.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=os();return c.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:H("hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:hover:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})});wx.displayName="SidebarRail";const kx=y.forwardRef(({className:e,...t},n)=>c.jsx("main",{ref:n,className:H("bg-background relative flex min-h-svh flex-1 flex-col","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2",e),...t}));kx.displayName="SidebarInset";const Sx=y.forwardRef(({className:e,...t},n)=>c.jsx(is,{ref:n,"data-sidebar":"input",className:H("bg-background focus-visible:ring-sidebar-ring h-8 w-full shadow-none focus-visible:ring-2",e),...t}));Sx.displayName="SidebarInput";const Md=y.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"header",className:H("flex flex-col gap-2 p-2",e),...t}));Md.displayName="SidebarHeader";const $d=y.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"footer",className:H("flex flex-col gap-2 p-2",e),...t}));$d.displayName="SidebarFooter";const Fd=y.forwardRef(({className:e,...t},n)=>c.jsx(Id,{ref:n,"data-sidebar":"separator",className:H("bg-sidebar-border mx-2 w-auto",e),...t}));Fd.displayName="SidebarSeparator";const Ld=y.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"content",className:H("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Ld.displayName="SidebarContent";const gi=y.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"group",className:H("relative flex w-full min-w-0 flex-col p-2",e),...t}));gi.displayName="SidebarGroup";const xi=y.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?rr:"div";return c.jsx(i,{ref:r,"data-sidebar":"group-label",className:H("text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium transition-[margin,opa] duration-200 ease-linear outline-none focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",e),...n})});xi.displayName="SidebarGroupLabel";const _x=y.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?rr:"button";return c.jsx(i,{ref:r,"data-sidebar":"group-action",className:H("text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 transition-transform outline-none focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0 cursor-pointer","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",e),...n})});_x.displayName="SidebarGroupAction";const br=y.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"group-content",className:H("w-full text-sm",e),...t}));br.displayName="SidebarGroupContent";const ga=y.forwardRef(({className:e,...t},n)=>c.jsx("ul",{ref:n,"data-sidebar":"menu",className:H("flex w-full min-w-0 flex-col gap-1",e),...t}));ga.displayName="SidebarMenu";const Zd=y.forwardRef(({className:e,...t},n)=>c.jsx("li",{ref:n,"data-sidebar":"menu-item",className:H("group/menu-item relative",e),...t}));Zd.displayName="SidebarMenuItem";const jx=qr("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 cursor-pointer",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),Bd=y.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:i,className:s,...a},o)=>{const l=e?rr:"button",{isMobile:u,state:f}=os(),d=c.jsx(l,{ref:o,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:H(jx({variant:n,size:r}),s),...a});return i?(typeof i=="string"&&(i={children:i}),c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:d}),c.jsx(et,{side:"right",align:"center",hidden:f!=="collapsed"||u,...i})]})):d});Bd.displayName="SidebarMenuButton";const Cx=y.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},i)=>{const s=t?rr:"button";return c.jsx(s,{ref:i,"data-sidebar":"menu-action",className:H("text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground peer-hover/menu-button:text-sidebar-accent-foreground absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 transition-transform outline-none focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0 cursor-pointer","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",n&&"peer-data-[active=true]/menu-button:text-sidebar-accent-foreground group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 md:opacity-0",e),...r})});Cx.displayName="SidebarMenuAction";const Nx=y.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:H("text-sidebar-foreground pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums select-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",e),...t}));Nx.displayName="SidebarMenuBadge";const Ex=y.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{const i=y.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return c.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:H("flex h-8 items-center gap-2 rounded-md px-2",e),...n,children:[t&&c.jsx(Er,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),c.jsx(Er,{className:"h-4 max-w-[--skeleton-width] flex-1","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":i}})]})});Ex.displayName="SidebarMenuSkeleton";const Ix=y.forwardRef(({className:e,...t},n)=>c.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:H("border-sidebar-border mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",e),...t}));Ix.displayName="SidebarMenuSub";const zx=y.forwardRef(({...e},t)=>c.jsx("li",{ref:t,...e}));zx.displayName="SidebarMenuSubItem";const Tx=y.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...i},s)=>{const a=e?rr:"a";return c.jsx(a,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:H("text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 outline-none focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 cursor-pointer","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",t==="sm"&&"text-xs",t==="md"&&"text-sm","group-data-[collapsible=icon]:hidden",r),...i})});Tx.displayName="SidebarMenuSubButton";function yi(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 Ax=typeof window<"u"?navigator.userAgent.toUpperCase().indexOf("MAC")>=0:!1;function Px({document:e,indicator:t,compact:n=!1}){const r=y.useRef(null),[i,s]=y.useState(!1),[a,o]=y.useState(!1),[l,u]=y.useState(!1),{openDocument:f,documentTypes:d,activeTab:p}=Ae(P=>P),{name:h,text:m,isGenerating:w}=yn(P=>P),x=(d[e.name]||"application/json+report")==="application/json+theme",_=p===e.name,[g,T]=y.useState(h),[E,k]=y.useState(m),N=100,M=0;y.useEffect(()=>{const P=setTimeout(()=>{h&&m?(T(h),k(m)):w||(T(""),k(""))},w?N:M);return()=>clearTimeout(P)},[h,m,w]);const Y=g===e.name,C=P=>{var J;const A=new Set;try{const O=JSON.parse(P);(J=O.props)!=null&&J.theme&&A.add(O.props.theme),O.children&&Array.isArray(O.children)&&O.children.forEach(q=>{var b;q.name==="docx"&&((b=q.props)!=null&&b.theme)&&A.add(q.props.theme)})}catch{}return A},B=y.useMemo(()=>{if(!x||!E)return!1;try{const P=JSON.parse(e.text),A=ua(P);if(A)return C(E).has(A)}catch{}return!1},[x,E,e.text,e.name,g]),R=y.useCallback(()=>{o(!1)},[]),U=y.useCallback(()=>{u(!1)},[]),L=c.jsxs(Bd,{variant:"default",size:"default",ref:r,className:H("text-sidebar-foreground focus:bg-accent focus:text-accent-foreground w-full",n?"justify-center px-1":"justify-start gap-2",i&&"bg-accent text-accent-foreground",_&&(n?"bg-green-50 text-green-700 dark:bg-green-900/20 dark:text-green-300":"bg-green-50 border-l-2 border-green-500 text-green-700 dark:bg-green-900/20 dark:border-green-400 dark:text-green-300"),Y&&!_&&(n?"bg-blue-50 text-blue-700 dark:bg-blue-900/20 dark:text-blue-300":"bg-blue-50 border-l-2 border-blue-500 text-blue-700 dark:bg-blue-900/20 dark:border-blue-400 dark:text-blue-300"),B&&!_&&!Y&&(n?"bg-purple-50 text-purple-700 dark:bg-purple-900/20 dark:text-purple-300":"bg-purple-50 border-l-2 border-purple-500 text-purple-700 dark:bg-purple-900/20 dark:border-purple-400 dark:text-purple-300")),title:e.name,onClick:()=>{f(e.name)},onKeyDown:P=>{var A;(P.ctrlKey||P.metaKey)&&P.key==="Enter"?(f(e.name),P.preventDefault()):P.key==="Enter"?(o(!0),P.preventDefault()):P.key==="Backspace"||P.key==="Delete"?(u(!0),P.preventDefault()):P.key==="Escape"&&((A=r.current)==null||A.blur(),P.preventDefault())},children:[_?c.jsx($o,{className:H("size-4","text-green-600 dark:text-green-400")}):Y?c.jsx($o,{className:H("size-4","text-blue-600 dark:text-blue-400")}):x?c.jsx(sa,{className:"size-4 text-purple-600 dark:text-purple-400"}):c.jsx(Gc,{className:"size-4 text-blue-600 dark:text-blue-400"}),!n&&c.jsx("span",{className:H("truncate flex-1",x&&!_&&!Y&&!B&&"text-purple-700 dark:text-purple-300",(_||Y||B)&&"font-medium"),children:e.name})]});return c.jsxs(Zd,{children:[c.jsxs(tx,{onOpenChange:s,children:[c.jsx(nx,{children:n?c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:L}),c.jsx(et,{side:"right",children:c.jsxs("div",{className:"text-xs",children:[e.name,x?c.jsx("div",{className:"opacity-70",children:"Theme"}):c.jsx("div",{className:"opacity-70",children:"Document"})]})})]}):L}),c.jsxs(Ed,{children:[c.jsxs(yr,{onClick:()=>f(e.name),children:["Open",c.jsx(mi,{children:Ax?"⌘⏎":"⌃⏎"})]}),c.jsx(ma,{}),c.jsx(yr,{disabled:!e,onClick:()=>{e&&yi(e.name,new Blob([e.text],{type:e.type}))},children:"Download..."}),c.jsx(ma,{}),c.jsxs(yr,{onClick:()=>o(!0),children:["Rename...",c.jsx(mi,{children:"⏎"})]}),c.jsxs(yr,{onClick:()=>u(!0),children:["Delete",c.jsx(mi,{children:"⌫"})]})]})]}),c.jsx(Dt,{open:a,onOpenChange:o,children:c.jsx(Et,{className:"sm:max-w-[425px]",onCloseAutoFocus:P=>{var A;P.preventDefault(),(A=r.current)==null||A.focus()},children:c.jsx(Ei,{mode:"update",shouldReset:!a,postSubmit:R,selectedName:e.name})})}),c.jsx(Dt,{open:l,onOpenChange:u,children:c.jsx(Et,{className:"sm:max-w-[425px]",onCloseAutoFocus:P=>{var A;P.preventDefault(),(A=r.current)==null||A.focus()},children:c.jsx(Ei,{mode:"delete",shouldReset:!l,postSubmit:U,selectedName:e.name})})})]})}const el=Ee.memo(Px);async function Ox(e,t){const n=JSON.stringify({name:e,props:t,children:[]},null,2);await navigator.clipboard.writeText(n)}const Dx=qr("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function kn({className:e,variant:t,...n}){return c.jsx("div",{className:H(Dx({variant:t}),e),...n})}const Pr=y.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Oc,{ref:r,className:H("relative overflow-hidden",e),...n,children:[c.jsx(Em,{className:"h-full w-full rounded-[inherit]",children:t}),c.jsx(Vd,{}),c.jsx(Im,{})]}));Pr.displayName=Oc.displayName;const Vd=y.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(Dc,{ref:r,orientation:t,className:H("flex touch-none transition-colors select-none",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:c.jsx(zm,{className:"bg-border relative flex-1 rounded-full"})}));Vd.displayName=Dc.displayName;function eo({className:e,...t}){return c.jsx(Tm,{"data-slot":"switch",className:H("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 cursor-pointer",e),...t,children:c.jsx(Am,{"data-slot":"switch-thumb",className:H("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}const Rx=qr("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),Ii=y.forwardRef(({className:e,variant:t,...n},r)=>c.jsx("div",{ref:r,role:"alert",className:H(Rx({variant:t}),e),...n}));Ii.displayName="Alert";const Mx=y.forwardRef(({className:e,...t},n)=>c.jsx("h5",{ref:n,className:H("mb-1 font-medium leading-none tracking-tight",e),...t}));Mx.displayName="AlertTitle";const zi=y.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:H("text-sm [&_p]:leading-relaxed",e),...t}));zi.displayName="AlertDescription";const Ti=y.memo(({keyName:e,value:t,depth:n=0,isLast:r=!1})=>{const[i,s]=y.useState(n<2),a=t!==null&&typeof t=="object",o=Array.isArray(t),l=()=>s(!i),u=()=>t===null?c.jsx("span",{className:"text-orange-500",children:"null"}):t===void 0?c.jsx("span",{className:"text-gray-500",children:"undefined"}):typeof t=="boolean"?c.jsx("span",{className:"text-blue-500",children:String(t)}):typeof t=="number"?c.jsx("span",{className:"text-green-500",children:t}):typeof t=="string"?t.startsWith("http")?c.jsxs("span",{className:"text-purple-500",children:['"',t,'"']}):t.startsWith("#/")?c.jsxs("span",{className:"text-cyan-500",children:['"',t,'"']}):c.jsxs("span",{className:"text-amber-600",children:['"',t,'"']}):null,f=a?Object.keys(t).length:0;return c.jsxs("div",{className:H("text-sm",n>0&&"ml-4"),children:[c.jsxs("div",{className:"flex items-start hover:bg-muted/30 rounded px-1 py-0.5",children:[a&&c.jsx("button",{onClick:l,className:"mr-1 hover:bg-muted rounded p-0.5","aria-label":i?"Collapse":"Expand",children:i?c.jsx(an,{className:"h-3 w-3"}):c.jsx(Qi,{className:"h-3 w-3"})}),!a&&c.jsx("span",{className:"w-4"}),e&&c.jsxs(c.Fragment,{children:[c.jsxs("span",{className:"text-blue-600 dark:text-blue-400",children:['"',e,'"']}),c.jsx("span",{className:"mx-1",children:":"})]}),a?c.jsxs("span",{className:"text-muted-foreground",children:[o?"[":"{",!i&&c.jsxs("span",{className:"mx-1 text-xs",children:[f," ",o?"items":"properties"]}),!i&&(o?"]":"}")]}):u(),!a&&!r&&c.jsx("span",{className:"text-muted-foreground",children:","})]}),a&&i&&c.jsxs("div",{className:"ml-4",children:[o?t.map((d,p)=>c.jsx(Ti,{keyName:String(p),value:d,depth:n+1,isLast:p===t.length-1},p)):Object.entries(t).map(([d,p],h,m)=>c.jsx(Ti,{keyName:d,value:p,depth:n+1,isLast:h===m.length-1},d)),c.jsx("div",{className:"ml-4",children:c.jsxs("span",{className:"text-muted-foreground",children:[o?"]":"}",!r&&","]})})]})]})});Ti.displayName="JsonNode";const Ai=y.memo(({schema:e,loading:t=!1,error:n,className:r})=>t?c.jsxs("div",{className:H("space-y-4",r),children:[c.jsx(Er,{className:"h-8 w-64"}),c.jsx(Er,{className:"h-4 w-full"}),c.jsx(Er,{className:"h-64 w-full"})]}):n?c.jsx(Ii,{variant:"destructive",className:r,children:c.jsx(zi,{children:n})}):e?c.jsx(Pr,{className:H("h-full w-full rounded-md border bg-muted/10 p-4",r),children:c.jsx("div",{className:"font-mono text-xs",children:c.jsx(Ti,{value:e})})}):c.jsx(Ii,{className:r,children:c.jsx(zi,{children:"No schema available"})}));Ai.displayName="SchemaViewer";function $x({plugins:e,initialFocusedPlugin:t}){var g,T;const n=Ot(E=>E.togglePlugin),r=Ot(E=>E.isPluginSelected),i=Ot(E=>E.selectedPlugins),s=Ot(E=>E.isApplyingPlugins),[a,o]=y.useState(null),[l,u]=y.useState(null),[f,d]=y.useState("properties");y.useEffect(()=>{if(t){const E=e.find(k=>k.name===t);if(E){o(E);return}}e.length>0&&!a&&o(e[0])},[t,e]);const p=y.useMemo(()=>{const E={current:[],downstream:[],upstream:[]};return e.forEach(k=>{E[k.location]&&E[k.location].push(k)}),E},[e]),h=async(E,k)=>{a&&(await Ox(a.name,E.props),u(k),setTimeout(()=>u(null),2e3))},m=E=>{switch(E){case"current":return"Current Directory";case"downstream":return"Project";case"upstream":return"Parent Directories";default:return E}},w=E=>{switch(E){case"current":return c.jsx(Hm,{className:"size-3"});case"downstream":return c.jsx(Jm,{className:"size-3"});case"upstream":return c.jsx(Gc,{className:"size-3"});default:return null}},S=((g=a==null?void 0:a.schema)==null?void 0:g.properties)&&Object.keys(a.schema.properties).length>0,x=(T=a==null?void 0:a.schema)==null?void 0:T.jsonSchema,_=(a==null?void 0:a.examples)&&a.examples.length>0;return c.jsxs(c.Fragment,{children:[c.jsxs(Gt,{children:[c.jsxs(Kt,{className:"flex items-center gap-2",children:[c.jsx(Kc,{className:"size-5 text-amber-600 dark:text-amber-400"}),"Plugins",c.jsxs(kn,{variant:"secondary",className:"font-normal",children:[i.size," active"]})]}),c.jsxs(Cn,{children:[e.length," plugin",e.length!==1?"s":""," discovered in your project"]})]}),c.jsxs("div",{className:"mt-3 flex gap-0 h-[600px] border rounded-lg overflow-hidden",children:[c.jsx("div",{className:"w-[240px] flex-none border-r bg-muted/30",children:c.jsx(Pr,{className:"h-full",children:c.jsx("div",{className:"p-2 space-y-3",children:Object.entries(p).map(([E,k])=>k.length===0?null:c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:[w(E),m(E)]}),c.jsx("div",{className:"space-y-0.5",children:k.map(N=>{const M=r(N.name),Y=(a==null?void 0:a.name)===N.name;return c.jsxs("button",{onClick:()=>o(N),className:H("w-full text-left px-2 py-1.5 rounded-md transition-colors cursor-pointer","flex items-center gap-2",Y?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"),children:[c.jsx("div",{className:H("size-1.5 rounded-full flex-none transition-colors",M?"bg-amber-500 dark:bg-amber-400":"bg-muted-foreground/30")}),c.jsx("span",{className:"text-sm font-medium truncate flex-1",children:N.name})]},N.name)})})]},E))})})}),a?c.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[c.jsxs("div",{className:"flex-none px-5 py-4 border-b bg-background",children:[c.jsxs("div",{className:"flex items-start justify-between gap-3",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2.5",children:[c.jsx("h3",{className:"text-base font-semibold truncate",children:a.name}),a.version&&c.jsxs(kn,{variant:"outline",className:"font-mono text-[11px] flex-none",children:["v",a.version]})]}),a.description&&c.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:a.description})]}),c.jsxs("div",{className:"flex items-center gap-2 flex-none pt-0.5",children:[c.jsx("span",{className:"text-xs text-muted-foreground",children:r(a.name)?"On":"Off"}),c.jsx(eo,{checked:r(a.name),onCheckedChange:()=>n(a),disabled:s,"aria-label":`Toggle ${a.name}`})]})]}),c.jsxs("div",{className:"flex items-center gap-1.5 mt-2 text-xs text-muted-foreground",children:[w(a.location),c.jsx("span",{children:m(a.location)}),c.jsx("span",{className:"text-muted-foreground/60 mx-1",children:"/"}),c.jsx("span",{className:"font-mono truncate",children:a.relativePath})]})]}),c.jsxs("div",{className:"flex-none px-5 pt-3 pb-0 flex gap-1 border-b bg-background",children:[S&&c.jsx("button",{onClick:()=>d("properties"),className:H("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",f==="properties"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(Fo,{className:"size-3.5"}),"Properties"]})}),x&&c.jsx("button",{onClick:()=>d("schema"),className:H("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",f==="schema"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(Bm,{className:"size-3.5"}),"Schema"]})}),_&&c.jsx("button",{onClick:()=>d("examples"),className:H("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",f==="examples"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(Vm,{className:"size-3.5"}),"Examples",c.jsx(kn,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-4",children:a.examples.length})]})})]}),c.jsx(Pr,{className:"flex-1",children:c.jsxs("div",{className:"p-5",children:[f==="properties"&&S&&c.jsx("div",{className:"space-y-1",children:Object.entries(a.schema.properties).map(([E,k])=>c.jsx(Fx,{name:E,prop:k},E))}),f==="schema"&&x&&c.jsx(Ai,{schema:a.schema.jsonSchema,loading:!1,className:"h-[420px]"}),f==="examples"&&_&&a.examples.map((E,k)=>c.jsxs("div",{className:H(k>0&&"mt-4 pt-4 border-t"),children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[E.title&&c.jsx("span",{className:"font-medium text-sm truncate",children:E.title}),!E.title&&c.jsxs("span",{className:"text-sm text-muted-foreground",children:["Example ",k+1]})]}),c.jsx(_e,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs flex-none",onClick:()=>h(E,k),children:l===k?c.jsxs(c.Fragment,{children:[c.jsx(Um,{className:"size-3 mr-1 text-green-600"}),"Copied"]}):c.jsxs(c.Fragment,{children:[c.jsx(es,{className:"size-3 mr-1"}),"Copy"]})})]}),E.description&&c.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:E.description}),c.jsx("pre",{className:"p-3 bg-muted rounded-md overflow-x-auto text-xs font-mono leading-relaxed",children:JSON.stringify(E.props,null,2)})]},k)),!S&&!x&&!_&&c.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[c.jsx(Fo,{className:"size-10 mx-auto mb-3 opacity-20"}),c.jsx("p",{className:"text-sm",children:"No schema or examples available for this plugin"})]})]})})]}):c.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:c.jsx("p",{className:"text-sm",children:"Select a plugin to view details"})})]})]})}function Fx({name:e,prop:t}){var a;const[n,r]=y.useState(!1),i=t.description||t.enum||t.default!==void 0||t.items||t.properties,s=t.type||(t.enum?"enum":t.oneOf?"oneOf":"—");return c.jsxs("div",{className:"rounded-md border",children:[c.jsxs("button",{onClick:()=>i&&r(!n),className:H("w-full text-left flex items-center gap-2 px-3 py-2 text-sm",i&&"cursor-pointer hover:bg-muted/50"),children:[i?n?c.jsx(an,{className:"size-3 text-muted-foreground flex-none"}):c.jsx(Qi,{className:"size-3 text-muted-foreground flex-none"}):c.jsx("span",{className:"size-3 flex-none"}),c.jsx("span",{className:"font-mono font-medium text-xs",children:e}),c.jsx(kn,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 flex-none",children:s}),t.optional===!1&&c.jsx("span",{className:"text-[10px] text-red-500 font-medium flex-none",children:"required"}),c.jsx("span",{className:"flex-1"}),t.default!==void 0&&c.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground flex-none",children:["= ",JSON.stringify(t.default)]})]}),n&&i&&c.jsxs("div",{className:"px-3 pb-2 pt-0 ml-5 text-xs space-y-1 text-muted-foreground",children:[t.description&&c.jsx("p",{children:t.description}),t.enum&&c.jsxs("p",{children:[c.jsx("span",{className:"font-medium text-foreground",children:"Values: "}),t.enum.map((o,l)=>c.jsxs("span",{children:[l>0&&", ",c.jsx("code",{className:"bg-muted px-1 rounded",children:JSON.stringify(o)})]},l))]}),((a=t.items)==null?void 0:a.type)&&c.jsxs("p",{children:[c.jsx("span",{className:"font-medium text-foreground",children:"Items: "}),t.items.type]})]})]})}const Is=Pm,zs=Om,Ts=Dm,to=Rm,no=Mm,Lx=y.forwardRef(({className:e,inset:t,children:n,...r},i)=>c.jsxs(Lc,{ref:i,className:H("focus:bg-accent data-[state=open]:bg-accent flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none select-none [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...r,children:[n,c.jsx(Qi,{className:"ml-auto"})]}));Lx.displayName=Lc.displayName;const Zx=y.forwardRef(({className:e,...t},n)=>c.jsx(Zc,{ref:n,className:H("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-lg",e),...t}));Zx.displayName=Zc.displayName;const ls=y.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx($m,{children:c.jsx(Rc,{ref:r,sideOffset:t,className:H("bg-popover text-popover-foreground z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));ls.displayName=Rc.displayName;const qt=y.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Mc,{ref:r,className:H("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm transition-colors outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",t&&"pl-8",e),...n}));qt.displayName=Mc.displayName;const Bx=y.forwardRef(({className:e,children:t,checked:n,...r},i)=>c.jsxs(Bc,{ref:i,className:H("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm py-1.5 pr-2 pl-8 text-sm transition-colors outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Vc,{children:c.jsx(ln,{className:"h-4 w-4"})})}),t]}));Bx.displayName=Bc.displayName;const Vx=y.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Uc,{ref:r,className:H("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm py-1.5 pr-2 pl-8 text-sm transition-colors outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Vc,{children:c.jsx(Wc,{className:"h-2 w-2 fill-current"})})}),t]}));Vx.displayName=Uc.displayName;const Ud=y.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Fc,{ref:r,className:H("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Ud.displayName=Fc.displayName;const Or=y.forwardRef(({className:e,...t},n)=>c.jsx($c,{ref:n,className:H("bg-muted -mx-1 my-1 h-px",e),...t}));Or.displayName=$c.displayName;function Ux(){const{theme:e,setTheme:t}=dc(),n=e==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e,r=y.useCallback(()=>{t(n==="dark"?"light":"dark")},[n,t]);return c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:c.jsxs(_e,{variant:"ghost",size:"icon",onClick:r,children:[c.jsx(qm,{className:"hidden dark:block"}),c.jsx(Wm,{className:"block dark:hidden"}),c.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),c.jsx(et,{children:c.jsx("p",{children:"Toggle theme"})})]})}const Jd=Fm,ro=y.forwardRef(({className:e,...t},n)=>c.jsx(Jc,{ref:n,className:H("bg-muted text-muted-foreground inline-flex h-9 items-center justify-center rounded-lg p-1",e),...t}));ro.displayName=Jc.displayName;const Dr=y.forwardRef(({className:e,...t},n)=>c.jsx(Hc,{ref:n,className:H("ring-offset-background focus-visible:ring-ring data-[state=active]:bg-background data-[state=active]:text-foreground inline-flex cursor-pointer items-center justify-center rounded-md px-3 py-1 text-sm font-medium whitespace-nowrap transition-all focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow",e),...t}));Dr.displayName=Hc.displayName;const Rr=y.forwardRef(({className:e,...t},n)=>c.jsx(qc,{ref:n,className:H("ring-offset-background focus-visible:ring-ring mt-2 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",e),...t}));Rr.displayName=qc.displayName;async function Jx(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 Hx(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 qx(e){const t=Hx(e);return Jx(t)}const Hd=({open:e,onOpenChange:t,defaultTab:n="document"})=>{const[r,i]=y.useState(n),[s,a]=y.useState(null),[o,l]=y.useState(null),[u,f]=y.useState(!1),[d,p]=y.useState(!1),[h,m]=y.useState(null),[w,S]=y.useState(null),[x,_]=y.useState(!1),{toast:g}=Wi(),T=Ot(U=>U.selectedPlugins),E=Array.from(T);y.useEffect(()=>{n&&i(n)},[n]);const k=y.useCallback(async()=>{f(!0),m(null);try{const U=await Ss.fetchDocumentSchema(E);a(U)}catch(U){const L=U instanceof Error?U.message:"Failed to load document schema";m(L),g({variant:"destructive",title:"Error loading schema",description:L})}finally{f(!1)}},[E,g]),N=y.useCallback(async()=>{if(!o){p(!0),S(null);try{const U=await Ss.fetchThemeSchema();l(U)}catch(U){const L=U instanceof Error?U.message:"Failed to load theme schema";S(L),g({variant:"destructive",title:"Error loading schema",description:L})}finally{p(!1)}}},[o,g]),[M,Y]=y.useState([]);y.useEffect(()=>{e||(a(null),m(null))},[e]),y.useEffect(()=>{if(!e)return;const U=E.length!==M.length||E.some((L,P)=>L!==M[P]);r==="document"?(!s||U)&&(U&&(Ss.clearPluginSchemaCache(),Y([...E])),u||k()):r==="theme"&&!o&&!d&&N()},[r,e,s,o,u,d,E,M,k,N]);const C=E.length,B=r==="document"?s:o,R=async()=>{if(B)try{await qx(B)&&(_(!0),g({title:"Schema copied",description:"The JSON schema has been copied to your clipboard"}),setTimeout(()=>_(!1),2e3))}catch(U){console.error("Copy failed:",U)}};return c.jsx(Dt,{open:e,onOpenChange:t,children:c.jsxs(Et,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[c.jsx(Gt,{children:c.jsx(Kt,{children:"Schema Viewer"})}),c.jsxs(Jd,{value:r,onValueChange:U=>i(U),className:"flex-1 overflow-hidden flex flex-col",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(ro,{children:[c.jsxs(Dr,{value:"document",className:"flex items-center gap-1",children:["Document",C>0&&c.jsxs(kn,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:["+",C]})]}),c.jsx(Dr,{value:"theme",children:"Theme"})]}),c.jsx("div",{className:"ml-auto",children:c.jsx(_e,{variant:"ghost",size:"icon",onClick:R,disabled:x||!B,"aria-label":"Copy schema",children:x?c.jsx(ln,{className:"h-4 w-4"}):c.jsx(es,{className:"h-4 w-4"})})})]}),c.jsxs("div",{className:"flex-1 overflow-auto mt-4",children:[c.jsx(Rr,{value:"document",className:"h-full",children:c.jsx(Ai,{schema:s,loading:u,error:h||void 0})}),c.jsx(Rr,{value:"theme",className:"h-full",children:c.jsx(Ai,{schema:o,loading:d,error:w||void 0})})]})]})]})})};function Wx({discoveryData:e,onToggleSidebar:t,isCollapsed:n=!1,isAnimating:r=!1}){const{documents:i,documentTypes:s,createDocument:a,openDocument:o}=Ae(vg(I=>({documents:I.documents,documentTypes:I.documentTypes,createDocument:I.createDocument,openDocument:I.openDocument}))),l=la(I=>I.updateTheme),u=la(I=>I.removeTheme),f=y.useContext(rd),[d,p]=y.useState(!1),[h,m]=y.useState(!1),[w,S]=y.useState(!1),[x,_]=y.useState(null),g=Ot(I=>I.togglePlugin),T=Ot(I=>I.isPluginSelected),E=Ot(I=>I.selectedPlugins),k=Ot(I=>I.isApplyingPlugins),[N,M]=y.useState(!1),[Y,C]=y.useState(new Set(["current-docs","current-themes"])),{toast:B}=Wi(),R=i.filter(I=>s[I.name]!=="application/json+theme"),U=i.filter(I=>s[I.name]==="application/json+theme"),L=y.useMemo(()=>{if(!e)return{current:[],downstream:[]};const I={current:[],downstream:[]};return e.documents.forEach($=>{I[$.location]&&I[$.location].push($)}),I},[e]),P=y.useMemo(()=>{if(!e)return{current:[],downstream:[]};const I={current:[],downstream:[]};return e.themes.forEach($=>{I[$.location]&&I[$.location].push($)}),I},[e]),A=y.useMemo(()=>{const I=new Set;return R.forEach($=>{try{const W=JSON.parse($.text);W.children&&Array.isArray(W.children)&&W.children.forEach(le=>{var K;le.name==="docx"&&((K=le.props)!=null&&K.theme)&&I.add(le.props.theme)})}catch{}}),I},[R]),J=y.useCallback(()=>{p(!1)},[]),O=y.useCallback(()=>{m(!1)},[]),q=y.useRef(new Map);y.useEffect(()=>{const I=q.current,$=new Map;U.forEach(W=>{$.set(W.name,W.text),I.get(W.name)!==W.text&&l(W.name,W.text)}),I.forEach((W,le)=>{$.has(le)||u(le)}),q.current=$},[U,l,u]);const b=y.useRef(!1);y.useEffect(()=>{if(b.current||!f)return;b.current=!0;const I=new Set(U.map(W=>W.name));Object.keys(f.getState().customThemes).forEach(W=>{I.has(W)||u(W)})},[U,u,f]);const ce=I=>{C($=>{const W=new Set($);return W.has(I)?W.delete(I):W.add(I),W})},oe=Ae(I=>I.activeTab),v=oe&&s[oe]==="application/json+theme"?"theme":"document",{resolvedTheme:X}=dc(),ae=X==="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",ne=y.useCallback(async(I,$)=>{if(i.some(W=>W.name===I)){o(I);return}try{const W=await fetch(`/api/discovery/${$?"themes":"documents"}/${encodeURIComponent(I)}/content`);if(!W.ok)throw new Error(W.statusText);const le=await W.text(),K=JSON.parse(le);a(I,JSON.stringify(K,null,2)),o(I),B({title:`Added ${$?"theme":"document"}: ${I}`})}catch{B({title:"Failed to load",description:`Could not load ${I}`,variant:"destructive"})}},[i,a,o,B]);return c.jsxs(c.Fragment,{children:[c.jsxs(Rd,{collapsible:"none",style:{"--sidebar-width":n?"3rem":"16rem"},children:[c.jsx(Md,{children:c.jsx("div",{className:H("flex items-center transition-opacity duration-150 ease-out",r?"opacity-0":"opacity-100",n?"justify-center":"justify-between"),children:n?c.jsx(_e,{variant:"ghost",size:"icon","aria-label":"Expand sidebar","aria-expanded":!1,onClick:t,children:c.jsx(Yc,{className:"h-4 w-4"})}):c.jsxs(c.Fragment,{children:[c.jsx("a",{href:"/",className:"flex items-center pl-2",children:c.jsx("img",{src:ae,alt:"WiseAir logo",className:"h-5 w-auto max-w-[120px] shrink-0"})}),c.jsx("div",{className:"flex items-center gap-1",children:c.jsx(_e,{variant:"ghost",size:"icon","aria-label":"Collapse sidebar","aria-expanded":!0,onClick:t,children:c.jsx(Gm,{className:"h-4 w-4"})})})]})})}),c.jsxs(Ld,{className:H("h-full transition-opacity duration-150 ease-out",r?"opacity-0":"opacity-100"),children:[c.jsxs(gi,{children:[c.jsxs(xi,{className:H("flex items-center",n?"justify-center":"justify-between"),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[!n&&c.jsx(Lo,{className:"size-3"}),!n&&c.jsx("span",{children:"Active Documents"})]}),c.jsxs(Dt,{open:d,onOpenChange:p,children:[c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:c.jsx(Yo,{asChild:!0,children:c.jsx(_e,{className:H("p-0 flex-shrink-0",n?"mx-auto h-8 w-8 rounded border border-dashed border-sidebar-foreground/20 hover:border-sidebar-foreground/40":"h-6 w-6"),variant:"ghost",size:"icon",children:c.jsx(Si,{className:n?"size-3.5":"size-4"})})})}),c.jsx(et,{side:n?"right":"bottom",children:c.jsx("span",{className:"text-xs",children:"New Document"})})]}),c.jsx(Et,{className:"sm:max-w-[525px]",children:c.jsx(Ei,{mode:"create",shouldReset:!d,postSubmit:J,discoveredDocuments:(e==null?void 0:e.documents)||[]})})]})]}),n?c.jsx(br,{children:c.jsx("div",{className:"flex flex-col items-center gap-0.5 px-0.5",children:R.map(I=>{const $=oe===I.name;return c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:c.jsxs("button",{onClick:()=>o(I.name),"aria-label":I.name,className:H("relative w-8 h-8 rounded flex items-center justify-center text-[11px] font-bold transition-colors cursor-pointer",$?"bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:[$&&c.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-0.5 rounded-full bg-green-500 dark:bg-green-400"}),I.name.replace(/\.[^.]+$/,"").slice(0,2).toUpperCase()]})}),c.jsx(et,{side:"right",children:c.jsx("span",{className:"text-xs",children:I.name})})]},I.name)})})}):c.jsx(br,{children:c.jsx(ga,{children:R.length>0?R.map((I,$)=>c.jsx(el,{document:I,compact:n},`doc-${$}`)):c.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No active documents. Click + to create one."})})})]}),c.jsx(Fd,{}),c.jsxs(gi,{children:[c.jsxs(xi,{className:H("flex items-center",n?"justify-center":"justify-between"),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[!n&&c.jsx(sa,{className:"size-3 text-purple-600 dark:text-purple-400"}),!n&&c.jsx("span",{children:"Active Themes"})]}),c.jsxs(Dt,{open:h,onOpenChange:m,children:[c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:c.jsx(Yo,{asChild:!0,children:c.jsx(_e,{className:H("p-0 flex-shrink-0",n?"mx-auto h-8 w-8 rounded border border-dashed border-sidebar-foreground/20 hover:border-sidebar-foreground/40":"h-6 w-6"),variant:"ghost",size:"icon",children:c.jsx(Si,{className:n?"size-3.5":"size-4"})})})}),c.jsx(et,{side:n?"right":"bottom",children:c.jsx("span",{className:"text-xs",children:"New Theme"})})]}),c.jsx(Et,{className:"sm:max-w-[525px]",children:c.jsx(Ei,{mode:"create",shouldReset:!h,postSubmit:O,discoveredThemes:(e==null?void 0:e.themes)||[],isTheme:!0})})]})]}),n?c.jsx(br,{children:c.jsx("div",{className:"flex flex-col items-center gap-0.5 px-0.5",children:U.map(I=>{const $=oe===I.name;let W=null;try{const K=JSON.parse(I.text);W=ua(K)}catch{}const le=W?A.has(W):!1;return c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:c.jsxs("button",{onClick:()=>o(I.name),"aria-label":I.name,className:H("relative w-8 h-8 rounded flex items-center justify-center text-[11px] font-bold transition-colors cursor-pointer",$?"bg-purple-100 text-purple-700 dark:bg-purple-900/40 dark:text-purple-300":le?"bg-purple-50 text-purple-600 dark:bg-purple-900/20 dark:text-purple-400":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:[$&&c.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-0.5 rounded-full bg-purple-500 dark:bg-purple-400"}),(W||I.name).charAt(0).toUpperCase()]})}),c.jsx(et,{side:"right",children:c.jsxs("div",{className:"text-xs",children:[I.name,le&&c.jsx("div",{className:"opacity-70",children:"In use"})]})})]},I.name)})})}):c.jsx(br,{children:c.jsx(ga,{children:U.length>0?U.map((I,$)=>{let W=null;try{const K=JSON.parse(I.text);W=ua(K)}catch{}const le=W?A.has(W):!1;return c.jsx(el,{document:I,compact:n,indicator:le?"in-use":void 0},`theme-${$}`)}):c.jsxs("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:["No active themes."," ",e&&e.themes.length>0?"Click + to add one.":"No themes discovered in project."]})})})]}),!n&&e&&(e.documents.length>0||e.themes.length>0)&&c.jsxs(gi,{className:"mt-2 border-t pt-4",children:[c.jsxs(xi,{className:"flex items-center mb-2 gap-2",children:[c.jsx(Km,{className:"size-3"}),c.jsx("span",{children:"Discovered Resources"})]}),c.jsxs(c.Fragment,{children:[Object.entries(L).map(([I,$])=>{if($.length===0)return null;const W=`${I}-docs`,le=Y.has(W);return c.jsxs(Is,{open:le,children:[c.jsxs(zs,{className:"flex items-center gap-1 px-3 py-1 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors cursor-pointer w-full",onClick:()=>ce(W),children:[c.jsx(an,{className:H("size-3 transition-transform",!le&&"-rotate-90")}),c.jsx(Lo,{className:"size-3"}),I==="current"?"Current Directory":"Project"," ","Documents (",$.length,")"]}),c.jsx(Ts,{children:c.jsx("div",{className:"pl-4 space-y-0.5",children:$.map((K,ve)=>{const de=i.some(xe=>xe.name===K.name);return c.jsxs("button",{onClick:()=>ne(K.name,!1),className:H("w-full text-left py-1 px-2 rounded text-sm transition-colors","border-l-2 border-blue-400/60 dark:border-blue-500/40","hover:bg-accent hover:text-accent-foreground",de&&"opacity-50"),children:[c.jsx("div",{className:"font-medium truncate",children:K.name}),K.title&&c.jsx("div",{className:"text-xs text-muted-foreground truncate",children:K.title})]},ve)})})})]},W)}),Object.entries(P).map(([I,$])=>{if($.length===0)return null;const W=`${I}-themes`,le=Y.has(W);return c.jsxs(Is,{open:le,children:[c.jsxs(zs,{className:"flex items-center gap-1 px-3 py-1 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors cursor-pointer w-full",onClick:()=>ce(W),children:[c.jsx(an,{className:H("size-3 transition-transform",!le&&"-rotate-90")}),c.jsx(sa,{className:"size-3"}),I==="current"?"Current Directory":"Project"," ","Themes (",$.length,")"]}),c.jsx(Ts,{children:c.jsx("div",{className:"pl-4 space-y-0.5",children:$.map((K,ve)=>{const de=i.some(xe=>xe.name===K.name);return c.jsxs("button",{onClick:()=>ne(K.name,!0),className:H("w-full text-left py-1 px-2 rounded text-sm transition-colors","border-l-2 border-purple-400/60 dark:border-purple-500/40","hover:bg-accent hover:text-accent-foreground",de&&"opacity-50"),children:[c.jsx("div",{className:"font-medium truncate",children:K.name}),K.description&&c.jsx("div",{className:"text-xs text-muted-foreground truncate",children:K.description})]},ve)})})})]},W)}),e&&e.plugins.length>0&&c.jsxs(Is,{open:Y.has("plugins"),children:[c.jsxs(zs,{className:"flex items-center gap-1 px-3 py-1 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors cursor-pointer w-full",onClick:()=>ce("plugins"),children:[c.jsx(an,{className:H("size-3 transition-transform",!Y.has("plugins")&&"-rotate-90")}),c.jsx(Kc,{className:"size-3 text-amber-600 dark:text-amber-400"}),"Plugins (",E.size,"/",e.plugins.length,")"]}),c.jsx(Ts,{children:c.jsx("div",{className:"pl-4 space-y-0.5",children:e.plugins.map((I,$)=>{const W=T(I.name);return c.jsxs("div",{className:H("py-1 px-2 text-sm border-l-2 flex items-center gap-2 group transition-colors",W?"border-amber-500 dark:border-amber-400 text-foreground":"border-amber-400/30 dark:border-amber-500/20 text-muted-foreground"),children:[c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"font-medium truncate",children:I.name}),I.description&&c.jsx("div",{className:"text-xs opacity-70 truncate",children:I.description})]}),c.jsx("button",{className:"flex-none size-5 flex items-center justify-center rounded-sm opacity-0 group-hover:opacity-100 hover:bg-accent transition-all cursor-pointer",title:`View details for ${I.name}`,onClick:le=>{le.stopPropagation(),_(I.name),S(!0)},children:c.jsx(Xc,{className:"size-3 text-muted-foreground"})}),c.jsx(eo,{checked:W,onCheckedChange:()=>g(I),disabled:k,className:"flex-none scale-[0.8]","aria-label":`Toggle ${I.name} plugin`})]},$)})})})]})]})]})]}),c.jsx($d,{children:c.jsx("div",{className:H("flex w-full items-center transition-opacity duration-150 ease-out",r?"opacity-0":"opacity-100",n?"justify-center":"justify-end pr-2"),children:c.jsx(Ux,{})})}),c.jsx(Dt,{open:w,onOpenChange:I=>{S(I),I||_(null)},children:c.jsx(Et,{className:"sm:max-w-5xl max-h-[85vh] overflow-hidden",children:c.jsx($x,{plugins:(e==null?void 0:e.plugins)||[],initialFocusedPlugin:x})})})]}),c.jsx(Hd,{open:N,onOpenChange:M,defaultTab:v==="theme"?"theme":"document"})]})}const tl=y.memo(Wx),Gx=y.lazy(()=>fc(()=>import("./editor-QOUTSCme.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(e=>({default:e.Editor})));function nl(){return c.jsx(y.Suspense,{fallback:c.jsx("div",{className:"flex items-center justify-center h-full",children:c.jsxs("div",{className:"text-center",children:[c.jsx(nn,{className:"w-8 h-8 mx-auto mb-2"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading editor..."})]})}),children:c.jsx(Gx,{})})}const Kx=y.lazy(()=>fc(()=>import("./preview-CtIrY86t.js"),__vite__mapDeps([12,1,3,4,5,6,7,8,9,10,11])).then(e=>({default:e.Preview})));function rl(){return c.jsx(y.Suspense,{fallback:c.jsx("div",{className:"flex items-center justify-center h-full",children:c.jsxs("div",{className:"text-center",children:[c.jsx(nn,{className:"w-8 h-8 mx-auto mb-2"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading preview..."})]})}),children:c.jsx(Kx,{})})}const{createElement:Xn,createContext:Yx,forwardRef:qd,useCallback:pt,useContext:Wd,useEffect:Sn,useImperativeHandle:Gd,useLayoutEffect:Xx,useMemo:Qx,useRef:xt,useState:qn}=cc,il=cc[`useId${Math.random()}`.slice(0,5)],ey=Xx,us=Yx(null);us.displayName="PanelGroupContext";const _n=ey,ty=typeof il=="function"?il:()=>null;let ny=0;function io(e=null){const t=ty(),n=xt(e||t||null);return n.current===null&&(n.current=""+ny++),e??n.current}function Kd({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:i,forwardedRef:s,id:a,maxSize:o,minSize:l,onCollapse:u,onExpand:f,onResize:d,order:p,style:h,tagName:m="div",...w}){const S=Wd(us);if(S===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:x,expandPanel:_,getPanelSize:g,getPanelStyle:T,groupId:E,isPanelCollapsed:k,reevaluatePanelConstraints:N,registerPanel:M,resizePanel:Y,unregisterPanel:C}=S,B=io(a),R=xt({callbacks:{onCollapse:u,onExpand:f,onResize:d},constraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:o,minSize:l},id:B,idIsFromProps:a!==void 0,order:p});xt({didLogMissingDefaultSizeWarning:!1}),_n(()=>{const{callbacks:L,constraints:P}=R.current,A={...P};R.current.id=B,R.current.idIsFromProps=a!==void 0,R.current.order=p,L.onCollapse=u,L.onExpand=f,L.onResize=d,P.collapsedSize=n,P.collapsible=r,P.defaultSize=i,P.maxSize=o,P.minSize=l,(A.collapsedSize!==P.collapsedSize||A.collapsible!==P.collapsible||A.maxSize!==P.maxSize||A.minSize!==P.minSize)&&N(R.current,A)}),_n(()=>{const L=R.current;return M(L),()=>{C(L)}},[p,B,M,C]),Gd(s,()=>({collapse:()=>{x(R.current)},expand:L=>{_(R.current,L)},getId(){return B},getSize(){return g(R.current)},isCollapsed(){return k(R.current)},isExpanded(){return!k(R.current)},resize:L=>{Y(R.current,L)}}),[x,_,g,k,B,Y]);const U=T(R.current,i);return Xn(m,{...w,children:e,className:t,id:a,style:{...U,...h},"data-panel":"","data-panel-collapsible":r||void 0,"data-panel-group-id":E,"data-panel-id":B,"data-panel-size":parseFloat(""+U.flexGrow).toFixed(1)})}const Yd=qd((e,t)=>Xn(Kd,{...e,forwardedRef:t}));Kd.displayName="Panel";Yd.displayName="forwardRef(Panel)";let xa=null,wn=null;function ry(e,t){if(t){const n=(t&nf)!==0,r=(t&rf)!==0,i=(t&sf)!==0,s=(t&af)!==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 iy(){wn!==null&&(document.head.removeChild(wn),xa=null,wn=null)}function As(e,t){const n=ry(e,t);xa!==n&&(xa=n,wn===null&&(wn=document.createElement("style"),document.head.appendChild(wn)),wn.innerHTML=`*{cursor: ${n}!important;}`)}function Xd(e){return e.type==="keydown"}function Qd(e){return e.type.startsWith("pointer")}function ef(e){return e.type.startsWith("mouse")}function cs(e){if(Qd(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(ef(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function sy(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function ay(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 oy(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:ol(e),b:ol(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;Se(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:al(sl(n.a)),b:al(sl(n.b))};if(i.a===i.b){const s=r.childNodes,a={a:n.a.at(-1),b:n.b.at(-1)};let o=s.length;for(;o--;){const l=s[o];if(l===a.a)return 1;if(l===a.b)return-1}}return Math.sign(i.a-i.b)}const ly=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function uy(e){var t;const n=getComputedStyle((t=tf(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function cy(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||uy(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"||ly.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function sl(e){let t=e.length;for(;t--;){const n=e[t];if(Se(n,"Missing node"),cy(n))return n}return null}function al(e){return e&&Number(getComputedStyle(e).zIndex)||0}function ol(e){const t=[];for(;e;)t.push(e),e=tf(e);return t}function tf(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const nf=1,rf=2,sf=4,af=8,dy=sy()==="coarse";let Rt=[],Wn=!1,sn=new Map,ds=new Map;const Mr=new Set;function fy(e,t,n,r,i){var s;const{ownerDocument:a}=t,o={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:i},l=(s=sn.get(a))!==null&&s!==void 0?s:0;return sn.set(a,l+1),Mr.add(o),Pi(),function(){var f;ds.delete(e),Mr.delete(o);const d=(f=sn.get(a))!==null&&f!==void 0?f:1;if(sn.set(a,d-1),Pi(),d===1&&sn.delete(a),Rt.includes(o)){const p=Rt.indexOf(o);p>=0&&Rt.splice(p,1),ao(),i("up",!0,null)}}}function ll(e){const{target:t}=e,{x:n,y:r}=cs(e);Wn=!0,so({target:t,x:n,y:r}),Pi(),Rt.length>0&&(Oi("down",e),e.preventDefault(),e.stopPropagation())}function fr(e){const{x:t,y:n}=cs(e);if(Wn&&e.buttons===0&&(Wn=!1,Oi("up",e)),!Wn){const{target:r}=e;so({target:r,x:t,y:n})}Oi("move",e),ao(),Rt.length>0&&e.preventDefault()}function Pn(e){const{target:t}=e,{x:n,y:r}=cs(e);ds.clear(),Wn=!1,Rt.length>0&&e.preventDefault(),Oi("up",e),so({target:t,x:n,y:r}),ao(),Pi()}function so({target:e,x:t,y:n}){Rt.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),Mr.forEach(i=>{const{element:s,hitAreaMargins:a}=i,o=s.getBoundingClientRect(),{bottom:l,left:u,right:f,top:d}=o,p=dy?a.coarse:a.fine;if(t>=u-p&&t<=f+p&&n>=d-p&&n<=l+p){if(r!==null&&document.contains(r)&&s!==r&&!s.contains(r)&&!r.contains(s)&&oy(r,s)>0){let m=r,w=!1;for(;m&&!m.contains(s);){if(ay(m.getBoundingClientRect(),o)){w=!0;break}m=m.parentElement}if(w)return}Rt.push(i)}})}function Ps(e,t){ds.set(e,t)}function ao(){let e=!1,t=!1;Rt.forEach(r=>{const{direction:i}=r;i==="horizontal"?e=!0:t=!0});let n=0;ds.forEach(r=>{n|=r}),e&&t?As("intersection",n):e?As("horizontal",n):t?As("vertical",n):iy()}function Pi(){sn.forEach((e,t)=>{const{body:n}=t;n.removeEventListener("contextmenu",Pn),n.removeEventListener("pointerdown",ll),n.removeEventListener("pointerleave",fr),n.removeEventListener("pointermove",fr)}),window.removeEventListener("pointerup",Pn),window.removeEventListener("pointercancel",Pn),Mr.size>0&&(Wn?(Rt.length>0&&sn.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("contextmenu",Pn),n.addEventListener("pointerleave",fr),n.addEventListener("pointermove",fr))}),window.addEventListener("pointerup",Pn),window.addEventListener("pointercancel",Pn)):sn.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("pointerdown",ll,{capture:!0}),n.addEventListener("pointermove",fr))}))}function Oi(e,t){Mr.forEach(n=>{const{setResizeHandlerState:r}=n,i=Rt.includes(n);r(e,i,t)})}function py(){const[e,t]=qn(0);return pt(()=>t(n=>n+1),[])}function Se(e,t){if(!e)throw console.error(t),Error(t)}const oo=10;function Nn(e,t,n=oo){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Wt(e,t,n=oo){return Nn(e,t,n)===0}function wt(e,t,n){return Nn(e,t,n)===0}function hy(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(!wt(i,s,n))return!1}return!0}function Un({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];Se(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:s,maxSize:a=100,minSize:o=0}=r;if(Nn(n,o)<0)if(s){const l=(i+o)/2;Nn(n,l)<0?n=i:n=o}else n=o;return n=Math.min(a,n),n=parseFloat(n.toFixed(oo)),n}function vr({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(wt(e,0))return t;const a=[...t],[o,l]=r;Se(o!=null,"Invalid first pivot index"),Se(l!=null,"Invalid second pivot index");let u=0;if(s==="keyboard"){{const d=e<0?l:o,p=n[d];Se(p,`Panel constraints not found for index ${d}`);const{collapsedSize:h=0,collapsible:m,minSize:w=0}=p;if(m){const S=t[d];if(Se(S!=null,`Previous layout not found for panel index ${d}`),wt(S,h)){const x=w-S;Nn(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const d=e<0?o:l,p=n[d];Se(p,`No panel constraints found for index ${d}`);const{collapsedSize:h=0,collapsible:m,minSize:w=0}=p;if(m){const S=t[d];if(Se(S!=null,`Previous layout not found for panel index ${d}`),wt(S,w)){const x=S-h;Nn(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}}{const d=e<0?1:-1;let p=e<0?l:o,h=0;for(;;){const w=t[p];Se(w!=null,`Previous layout not found for panel index ${p}`);const x=Un({panelConstraints:n,panelIndex:p,size:100})-w;if(h+=x,p+=d,p<0||p>=n.length)break}const m=Math.min(Math.abs(e),Math.abs(h));e=e<0?0-m:m}{let p=e<0?o:l;for(;p>=0&&p<n.length;){const h=Math.abs(e)-Math.abs(u),m=t[p];Se(m!=null,`Previous layout not found for panel index ${p}`);const w=m-h,S=Un({panelConstraints:n,panelIndex:p,size:w});if(!wt(m,S)&&(u+=m-S,a[p]=S,u.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?p--:p++}}if(hy(i,a))return i;{const d=e<0?l:o,p=t[d];Se(p!=null,`Previous layout not found for panel index ${d}`);const h=p+u,m=Un({panelConstraints:n,panelIndex:d,size:h});if(a[d]=m,!wt(m,h)){let w=h-m,x=e<0?l:o;for(;x>=0&&x<n.length;){const _=a[x];Se(_!=null,`Previous layout not found for panel index ${x}`);const g=_+w,T=Un({panelConstraints:n,panelIndex:x,size:g});if(wt(_,T)||(w-=T-_,a[x]=T),wt(w,0))break;e>0?x--:x++}}}const f=a.reduce((d,p)=>p+d,0);return wt(f,100)?a:i}function my({layout:e,panelsArray:t,pivotIndices:n}){let r=0,i=100,s=0,a=0;const o=n[0];Se(o!=null,"No pivot index found"),t.forEach((d,p)=>{const{constraints:h}=d,{maxSize:m=100,minSize:w=0}=h;p===o?(r=w,i=m):(s+=w,a+=m)});const l=Math.min(i,100-s),u=Math.max(r,100-a),f=e[o];return{valueMax:l,valueMin:u,valueNow:f}}function $r(e,t=document){return Array.from(t.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${e}"]`))}function of(e,t,n=document){const i=$r(e,n).findIndex(s=>s.getAttribute("data-panel-resize-handle-id")===t);return i??null}function lf(e,t,n){const r=of(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function uf(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 fs(e,t=document){const n=t.querySelector(`[data-panel-resize-handle-id="${e}"]`);return n||null}function gy(e,t,n,r=document){var i,s,a,o;const l=fs(t,r),u=$r(e,r),f=l?u.indexOf(l):-1,d=(i=(s=n[f])===null||s===void 0?void 0:s.id)!==null&&i!==void 0?i:null,p=(a=(o=n[f+1])===null||o===void 0?void 0:o.id)!==null&&a!==void 0?a:null;return[d,p]}function xy({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:i,panelGroupElement:s,setLayout:a}){xt({didWarnAboutMissingResizeHandle:!1}),_n(()=>{if(!s)return;const o=$r(n,s);for(let l=0;l<i.length-1;l++){const{valueMax:u,valueMin:f,valueNow:d}=my({layout:r,panelsArray:i,pivotIndices:[l,l+1]}),p=o[l];if(p!=null){const h=i[l];Se(h,`No panel data found for index "${l}"`),p.setAttribute("aria-controls",h.id),p.setAttribute("aria-valuemax",""+Math.round(u)),p.setAttribute("aria-valuemin",""+Math.round(f)),p.setAttribute("aria-valuenow",d!=null?""+Math.round(d):"")}}return()=>{o.forEach((l,u)=>{l.removeAttribute("aria-controls"),l.removeAttribute("aria-valuemax"),l.removeAttribute("aria-valuemin"),l.removeAttribute("aria-valuenow")})}},[n,r,i,s]),Sn(()=>{if(!s)return;const o=t.current;Se(o,"Eager values not found");const{panelDataArray:l}=o,u=uf(n,s);Se(u!=null,`No group found for id "${n}"`);const f=$r(n,s);Se(f,`No resize handles found for group id "${n}"`);const d=f.map(p=>{const h=p.getAttribute("data-panel-resize-handle-id");Se(h,"Resize handle element has no handle id attribute");const[m,w]=gy(n,h,l,s);if(m==null||w==null)return()=>{};const S=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const _=l.findIndex(g=>g.id===m);if(_>=0){const g=l[_];Se(g,`No panel data found for index ${_}`);const T=r[_],{collapsedSize:E=0,collapsible:k,minSize:N=0}=g.constraints;if(T!=null&&k){const M=vr({delta:wt(T,E)?N-E:E-T,initialLayout:r,panelConstraints:l.map(Y=>Y.constraints),pivotIndices:lf(n,h,s),prevLayout:r,trigger:"keyboard"});r!==M&&a(M)}}break}}};return p.addEventListener("keydown",S),()=>{p.removeEventListener("keydown",S)}});return()=>{d.forEach(p=>p())}},[s,e,t,n,r,i,a])}function ul(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function cf(e,t){const n=e==="horizontal",{x:r,y:i}=cs(t);return n?r:i}function yy(e,t,n,r,i){const s=n==="horizontal",a=fs(t,i);Se(a,`No resize handle element found for id "${t}"`);const o=a.getAttribute("data-panel-group-id");Se(o,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=r;const u=cf(n,e),f=uf(o,i);Se(f,`No group element found for id "${o}"`);const d=f.getBoundingClientRect(),p=s?d.width:d.height;return(u-l)/p*100}function by(e,t,n,r,i,s){if(Xd(e)){const a=n==="horizontal";let o=0;e.shiftKey?o=100:i!=null?o=i:o=10;let l=0;switch(e.key){case"ArrowDown":l=a?0:o;break;case"ArrowLeft":l=a?-o:0;break;case"ArrowRight":l=a?o:0;break;case"ArrowUp":l=a?0:-o;break;case"End":l=100;break;case"Home":l=-100;break}return l}else return r==null?0:yy(e,t,n,r,s)}function vy({panelDataArray:e}){const t=Array(e.length),n=e.map(s=>s.constraints);let r=0,i=100;for(let s=0;s<e.length;s++){const a=n[s];Se(a,`Panel constraints not found for index ${s}`);const{defaultSize:o}=a;o!=null&&(r++,t[s]=o,i-=o)}for(let s=0;s<e.length;s++){const a=n[s];Se(a,`Panel constraints not found for index ${s}`);const{defaultSize:o}=a;if(o!=null)continue;const l=e.length-r,u=i/l;r++,t[s]=u,i-=u}return t}function On(e,t,n){t.forEach((r,i)=>{const s=e[i];Se(s,`Panel data not found for index ${i}`);const{callbacks:a,constraints:o,id:l}=s,{collapsedSize:u=0,collapsible:f}=o,d=n[l];if(d==null||r!==d){n[l]=r;const{onCollapse:p,onExpand:h,onResize:m}=a;m&&m(r,d),f&&(p||h)&&(h&&(d==null||Wt(d,u))&&!Wt(r,u)&&h(),p&&(d==null||!Wt(d,u))&&Wt(r,u)&&p())}})}function ri(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 wy({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:i,precision:s=3}){const a=n[i];let o;return a==null?o=e!=null?e.toPrecision(s):"1":r.length===1?o="1":o=a.toPrecision(s),{flexBasis:0,flexGrow:o,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function ky(e,t=10){let n=null;return(...i)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...i)},t)}}function cl(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function df(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 pf(e,t){try{const n=df(e),r=t.getItem(n);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function Sy(e,t,n){var r,i;const s=(r=pf(e,n))!==null&&r!==void 0?r:{},a=ff(t);return(i=s[a])!==null&&i!==void 0?i:null}function _y(e,t,n,r,i){var s;const a=df(e),o=ff(t),l=(s=pf(e,i))!==null&&s!==void 0?s:{};l[o]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{i.setItem(a,JSON.stringify(l))}catch(u){console.error(u)}}function dl({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((s,a)=>s+a,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(s=>`${s}%`).join(", ")}`);if(!wt(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const a=n[s];Se(a!=null,`No layout data found for index ${s}`);const o=100/r*a;n[s]=o}let i=0;for(let s=0;s<t.length;s++){const a=n[s];Se(a!=null,`No layout data found for index ${s}`);const o=Un({panelConstraints:t,panelIndex:s,size:a});a!=o&&(i+=a-o,n[s]=o)}if(!wt(i,0))for(let s=0;s<t.length;s++){const a=n[s];Se(a!=null,`No layout data found for index ${s}`);const o=a+i,l=Un({panelConstraints:t,panelIndex:s,size:o});if(a!==l&&(i-=l-a,n[s]=l,wt(i,0)))break}return n}const jy=100,wr={getItem:e=>(cl(wr),wr.getItem(e)),setItem:(e,t)=>{cl(wr),wr.setItem(e,t)}},fl={};function hf({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:i,id:s=null,onLayout:a=null,keyboardResizeBy:o=null,storage:l=wr,style:u,tagName:f="div",...d}){const p=io(s),h=xt(null),[m,w]=qn(null),[S,x]=qn([]),_=py(),g=xt({}),T=xt(new Map),E=xt(0),k=xt({autoSaveId:e,direction:r,dragState:m,id:p,keyboardResizeBy:o,onLayout:a,storage:l}),N=xt({layout:S,panelDataArray:[],panelDataArrayChanged:!1});xt({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),Gd(i,()=>({getId:()=>k.current.id,getLayout:()=>{const{layout:v}=N.current;return v},setLayout:v=>{const{onLayout:X}=k.current,{layout:ae,panelDataArray:ne}=N.current,I=dl({layout:v,panelConstraints:ne.map($=>$.constraints)});ul(ae,I)||(x(I),N.current.layout=I,X&&X(I),On(ne,I,g.current))}}),[]),_n(()=>{k.current.autoSaveId=e,k.current.direction=r,k.current.dragState=m,k.current.id=p,k.current.onLayout=a,k.current.storage=l}),xy({committedValuesRef:k,eagerValuesRef:N,groupId:p,layout:S,panelDataArray:N.current.panelDataArray,setLayout:x,panelGroupElement:h.current}),Sn(()=>{const{panelDataArray:v}=N.current;if(e){if(S.length===0||S.length!==v.length)return;let X=fl[e];X==null&&(X=ky(_y,jy),fl[e]=X);const ae=[...v],ne=new Map(T.current);X(e,ae,ne,S,l)}},[e,S,l]),Sn(()=>{});const M=pt(v=>{const{onLayout:X}=k.current,{layout:ae,panelDataArray:ne}=N.current;if(v.constraints.collapsible){const I=ne.map(K=>K.constraints),{collapsedSize:$=0,panelSize:W,pivotIndices:le}=hn(ne,v,ae);if(Se(W!=null,`Panel size not found for panel "${v.id}"`),!Wt(W,$)){T.current.set(v.id,W);const ve=Ln(ne,v)===ne.length-1?W-$:$-W,de=vr({delta:ve,initialLayout:ae,panelConstraints:I,pivotIndices:le,prevLayout:ae,trigger:"imperative-api"});ri(ae,de)||(x(de),N.current.layout=de,X&&X(de),On(ne,de,g.current))}}},[]),Y=pt((v,X)=>{const{onLayout:ae}=k.current,{layout:ne,panelDataArray:I}=N.current;if(v.constraints.collapsible){const $=I.map(xe=>xe.constraints),{collapsedSize:W=0,panelSize:le=0,minSize:K=0,pivotIndices:ve}=hn(I,v,ne),de=X??K;if(Wt(le,W)){const xe=T.current.get(v.id),Ue=xe!=null&&xe>=de?xe:de,Ge=Ln(I,v)===I.length-1?le-Ue:Ue-le,j=vr({delta:Ge,initialLayout:ne,panelConstraints:$,pivotIndices:ve,prevLayout:ne,trigger:"imperative-api"});ri(ne,j)||(x(j),N.current.layout=j,ae&&ae(j),On(I,j,g.current))}}},[]),C=pt(v=>{const{layout:X,panelDataArray:ae}=N.current,{panelSize:ne}=hn(ae,v,X);return Se(ne!=null,`Panel size not found for panel "${v.id}"`),ne},[]),B=pt((v,X)=>{const{panelDataArray:ae}=N.current,ne=Ln(ae,v);return wy({defaultSize:X,dragState:m,layout:S,panelData:ae,panelIndex:ne})},[m,S]),R=pt(v=>{const{layout:X,panelDataArray:ae}=N.current,{collapsedSize:ne=0,collapsible:I,panelSize:$}=hn(ae,v,X);return Se($!=null,`Panel size not found for panel "${v.id}"`),I===!0&&Wt($,ne)},[]),U=pt(v=>{const{layout:X,panelDataArray:ae}=N.current,{collapsedSize:ne=0,collapsible:I,panelSize:$}=hn(ae,v,X);return Se($!=null,`Panel size not found for panel "${v.id}"`),!I||Nn($,ne)>0},[]),L=pt(v=>{const{panelDataArray:X}=N.current;X.push(v),X.sort((ae,ne)=>{const I=ae.order,$=ne.order;return I==null&&$==null?0:I==null?-1:$==null?1:I-$}),N.current.panelDataArrayChanged=!0,_()},[_]);_n(()=>{if(N.current.panelDataArrayChanged){N.current.panelDataArrayChanged=!1;const{autoSaveId:v,onLayout:X,storage:ae}=k.current,{layout:ne,panelDataArray:I}=N.current;let $=null;if(v){const le=Sy(v,I,ae);le&&(T.current=new Map(Object.entries(le.expandToSizes)),$=le.layout)}$==null&&($=vy({panelDataArray:I}));const W=dl({layout:$,panelConstraints:I.map(le=>le.constraints)});ul(ne,W)||(x(W),N.current.layout=W,X&&X(W),On(I,W,g.current))}}),_n(()=>{const v=N.current;return()=>{v.layout=[]}},[]);const P=pt(v=>{let X=!1;const ae=h.current;return ae&&window.getComputedStyle(ae,null).getPropertyValue("direction")==="rtl"&&(X=!0),function(I){I.preventDefault();const $=h.current;if(!$)return()=>null;const{direction:W,dragState:le,id:K,keyboardResizeBy:ve,onLayout:de}=k.current,{layout:xe,panelDataArray:Ue}=N.current,{initialLayout:rt}=le??{},Ge=lf(K,v,$);let j=by(I,v,W,le,ve,$);const z=W==="horizontal";z&&X&&(j=-j);const Z=Ue.map(ee=>ee.constraints),re=vr({delta:j,initialLayout:rt??xe,panelConstraints:Z,pivotIndices:Ge,prevLayout:xe,trigger:Xd(I)?"keyboard":"mouse-or-touch"}),te=!ri(xe,re);(Qd(I)||ef(I))&&E.current!=j&&(E.current=j,!te&&j!==0?z?Ps(v,j<0?nf:rf):Ps(v,j<0?sf:af):Ps(v,0)),te&&(x(re),N.current.layout=re,de&&de(re),On(Ue,re,g.current))}},[]),A=pt((v,X)=>{const{onLayout:ae}=k.current,{layout:ne,panelDataArray:I}=N.current,$=I.map(xe=>xe.constraints),{panelSize:W,pivotIndices:le}=hn(I,v,ne);Se(W!=null,`Panel size not found for panel "${v.id}"`);const ve=Ln(I,v)===I.length-1?W-X:X-W,de=vr({delta:ve,initialLayout:ne,panelConstraints:$,pivotIndices:le,prevLayout:ne,trigger:"imperative-api"});ri(ne,de)||(x(de),N.current.layout=de,ae&&ae(de),On(I,de,g.current))},[]),J=pt((v,X)=>{const{layout:ae,panelDataArray:ne}=N.current,{collapsedSize:I=0,collapsible:$}=X,{collapsedSize:W=0,collapsible:le,maxSize:K=100,minSize:ve=0}=v.constraints,{panelSize:de}=hn(ne,v,ae);de!=null&&($&&le&&Wt(de,I)?Wt(I,W)||A(v,W):de<ve?A(v,ve):de>K&&A(v,K))},[A]),O=pt((v,X)=>{const{direction:ae}=k.current,{layout:ne}=N.current;if(!h.current)return;const I=fs(v,h.current);Se(I,`Drag handle element not found for id "${v}"`);const $=cf(ae,X);w({dragHandleId:v,dragHandleRect:I.getBoundingClientRect(),initialCursorPosition:$,initialLayout:ne})},[]),q=pt(()=>{w(null)},[]),b=pt(v=>{const{panelDataArray:X}=N.current,ae=Ln(X,v);ae>=0&&(X.splice(ae,1),delete g.current[v.id],N.current.panelDataArrayChanged=!0,_())},[_]),ce=Qx(()=>({collapsePanel:M,direction:r,dragState:m,expandPanel:Y,getPanelSize:C,getPanelStyle:B,groupId:p,isPanelCollapsed:R,isPanelExpanded:U,reevaluatePanelConstraints:J,registerPanel:L,registerResizeHandle:P,resizePanel:A,startDragging:O,stopDragging:q,unregisterPanel:b,panelGroupElement:h.current}),[M,m,r,Y,C,B,p,R,U,J,L,P,A,O,q,b]),oe={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return Xn(us.Provider,{value:ce},Xn(f,{...d,children:t,className:n,id:s,ref:h,style:{...oe,...u},"data-panel-group":"","data-panel-group-direction":r,"data-panel-group-id":p}))}const mf=qd((e,t)=>Xn(hf,{...e,forwardedRef:t}));hf.displayName="PanelGroup";mf.displayName="forwardRef(PanelGroup)";function Ln(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function hn(e,t,n){const r=Ln(e,t),s=r===e.length-1?[r-1,r]:[r,r+1],a=n[r];return{...t.constraints,panelSize:a,pivotIndices:s}}function Cy({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){Sn(()=>{if(e||n==null||r==null)return;const i=fs(t,r);if(i==null)return;const s=a=>{if(!a.defaultPrevented)switch(a.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{a.preventDefault(),n(a);break}case"F6":{a.preventDefault();const o=i.getAttribute("data-panel-group-id");Se(o,`No group element found for id "${o}"`);const l=$r(o,r),u=of(o,t,r);Se(u!==null,`No resize element found for id "${t}"`);const f=a.shiftKey?u>0?u-1:l.length-1:u+1<l.length?u+1:0;l[f].focus();break}}};return i.addEventListener("keydown",s),()=>{i.removeEventListener("keydown",s)}},[r,e,t,n])}function gf({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:i,onBlur:s,onDragging:a,onFocus:o,style:l={},tabIndex:u=0,tagName:f="div",...d}){var p,h;const m=xt(null),w=xt({onDragging:a});Sn(()=>{w.current.onDragging=a});const S=Wd(us);if(S===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:x,groupId:_,registerResizeHandle:g,startDragging:T,stopDragging:E,panelGroupElement:k}=S,N=io(i),[M,Y]=qn("inactive"),[C,B]=qn(!1),[R,U]=qn(null),L=xt({state:M});_n(()=>{L.current.state=M}),Sn(()=>{if(n)U(null);else{const O=g(N);U(()=>O)}},[n,N,g]);const P=(p=r==null?void 0:r.coarse)!==null&&p!==void 0?p:15,A=(h=r==null?void 0:r.fine)!==null&&h!==void 0?h:5;return Sn(()=>{if(n||R==null)return;const O=m.current;return Se(O,"Element ref not attached"),fy(N,O,x,{coarse:P,fine:A},(b,ce,oe)=>{if(ce)switch(b){case"down":{Y("drag"),Se(oe,'Expected event to be defined for "down" action'),T(N,oe);const{onDragging:v}=w.current;v&&v(!0);break}case"move":{const{state:v}=L.current;v!=="drag"&&Y("hover"),Se(oe,'Expected event to be defined for "move" action'),R(oe);break}case"up":{Y("hover"),E();const{onDragging:v}=w.current;v&&v(!1);break}}else Y("inactive")})},[P,x,n,A,g,N,R,T,E]),Cy({disabled:n,handleId:N,resizeHandler:R,panelGroupElement:k}),Xn(f,{...d,children:e,className:t,id:i,onBlur:()=>{B(!1),s==null||s()},onFocus:()=>{B(!0),o==null||o()},ref:m,role:"separator",style:{...{touchAction:"none",userSelect:"none"},...l},tabIndex:u,"data-panel-group-direction":x,"data-panel-group-id":_,"data-resize-handle":"","data-resize-handle-active":M==="drag"?"pointer":C?"keyboard":void 0,"data-resize-handle-state":M,"data-panel-resize-handle-enabled":!n,"data-panel-resize-handle-id":N})}gf.displayName="PanelResizeHandle";const Ny=({className:e,...t})=>c.jsx(mf,{className:H("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),Os=Yd,pl=({withHandle:e,className:t,...n})=>c.jsx(gf,{className:H("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-none data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...n,children:e&&c.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-sm border",children:c.jsx(Ym,{className:"h-2.5 w-2.5"})})});function Ey({children:e,className:t}){return c.jsx("kbd",{className:H("inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1 rounded border border-border bg-background text-[11px] font-mono font-medium text-muted-foreground shadow-[0_1px_0_0] shadow-border/50 leading-none select-none",t),children:e})}function Iy({children:e,className:t}){return c.jsx("span",{className:H("inline-flex items-center gap-0.5",t),children:e})}const ii=typeof navigator<"u"&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);function ya({shortcut:e,className:t}){const r=e.split("+").map(i=>i.trim().toLowerCase()).map(i=>{switch(i){case"mod":return ii?"⌘":"Ctrl";case"shift":return ii?"⇧":"Shift";case"alt":return ii?"⌥":"Alt";case"ctrl":return ii?"⌃":"Ctrl";case"enter":return"↵";default:return i.toUpperCase()}});return c.jsx(Iy,{className:t,children:r.map((i,s)=>c.jsx(Ey,{children:i},s))})}class zy{constructor(t){Mo(this,"client");this.client=wg.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 Ty=new zy;function Ay(){const e=y.useRef(null),t=y.useCallback(async(r,i,s,a,o)=>{e.current&&e.current.abort();const l=new AbortController;e.current=l;try{a==null||a("parsing","Validating JSON structure...");let u;try{u=JSON.parse(i)}catch(k){throw new Error(`Invalid JSON: ${k instanceof Error?k.message:"Unknown parse error"}`)}a==null||a("building",`Building ${ti.toLowerCase()} structure...`);const f={jsonDefinition:u,options:o||{}};f.customThemes=s??{},a==null||a("rendering",`Generating ${kt.toUpperCase()} content...`);const d={"Content-Type":"application/json"};o!=null&&o.bypassCache&&(d["X-Bypass-Cache"]="true");const p=await fetch(fm.generate,{method:"POST",headers:d,body:JSON.stringify(f),signal:l.signal}),h=await p.json();if(!p.ok||!h.success){const k=h.error||h.message||`API request failed with status: ${p.status}`;throw new Error(k)}const{data:m,cache:w,warnings:S}=h,x=w.status==="HIT"?"HIT":w.status==="MISS"?"MISS":"UNKNOWN",_=x==="HIT"?`Served from cache (Hit rate: ${w.hitRate})`:`Generated fresh ${ti.toLowerCase()}`;a==null||a("finalizing",_);const g=globalThis.atob(m.document),T=new Uint8Array(g.length);for(let k=0;k<g.length;k++)T[k]=g.charCodeAt(k);const E=new Blob([T],{type:m.contentType});if(E.size===0)throw new Error(`Received empty ${ti.toLowerCase()} from API`);return{name:r,text:i,blob:E,filename:m.filename,fileId:m.fileId,cacheStatus:x,cacheHitRate:w.hitRate,warnings:S}}catch(u){throw u instanceof Error&&u.name==="AbortError"?new Error(`${ti} generation was cancelled`):u}finally{e.current===l&&(e.current=null)}},[]),n=y.useCallback(()=>{e.current&&(e.current.abort(),e.current=null)},[]);return{generatePresentation:t,generateDocument:t,cancelGeneration:n}}function Py(e){if(!e||e.length===0)return null;const t=[{name:"heading",props:{level:1,text:"Document Generation Warnings"}},{name:"paragraph",props:{text:`${e.length} warning(s) were generated during document processing.`,spacing:{after:240}}}],n=new Map;for(const r of e){const i=n.get(r.component)||[];i.push(r),n.set(r.component,i)}for(const[r,i]of n.entries()){t.push({name:"heading",props:{level:2,text:`Component: ${r}`}});const s=[];for(const a of i){let o=a.message;if(a.context&&Object.keys(a.context).length>0){const l=Object.entries(a.context).map(([u,f])=>`${u}: ${JSON.stringify(f)}`).join(", ");o+=` (${l})`}s.push(o)}t.push({name:"list",props:{items:s,spacing:{after:120}}})}return{name:"docx",props:{metadata:{title:"Generation Warnings"},theme:"minimal"},children:t}}function Oy({open:e,onClose:t,nonSafeFonts:n,onChoose:r}){const[i,s]=Ee.useState("custom");Ee.useEffect(()=>{e&&s("custom")},[e]);const a=n.length===1?n[0]:n.slice(0,3).join(", ")+(n.length>3?` +${n.length-3} more`:""),o=[{value:"custom",title:"Keep custom fonts",desc:"Recipients with the font installed see the authored typeface. Others get a generic fallback."},{value:"substitute",title:"Convert to safe fonts",desc:"Rewrite non-safe families to Calibri / Georgia / Consolas so every recipient sees the same glyphs."}];return c.jsx(Dt,{open:e,onOpenChange:l=>!l&&t(),children:c.jsxs(Et,{className:"max-w-md",children:[c.jsxs(Gt,{children:[c.jsx(Kt,{children:"Non-safe fonts in this document"}),c.jsxs(Cn,{children:[a," ",n.length===1?"is":"are"," not in the built-in safe list. Choose how to export."]})]}),c.jsx("div",{className:"grid gap-2 py-2",children:o.map(l=>{const u=i===l.value;return c.jsxs("button",{type:"button",onClick:()=>s(l.value),className:`text-left rounded-md border px-3 py-2 transition-colors ${u?"border-primary bg-primary/5":"border-border hover:bg-muted/40"}`,children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:`h-3.5 w-3.5 rounded-full border flex items-center justify-center ${u?"border-primary":"border-muted-foreground/50"}`,children:u&&c.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary"})}),c.jsx("span",{className:"text-sm font-medium",children:l.title})]}),c.jsx("p",{className:"mt-1 text-xs text-muted-foreground pl-6",children:l.desc})]},l.value)})}),c.jsxs(Yn,{children:[c.jsx(_e,{variant:"outline",size:"sm",onClick:t,children:"Cancel"}),c.jsx(_e,{size:"sm",onClick:()=>{r(i),t()},children:"Download"})]})]})})}const hl=kt==="docx"?["docxjs","LibreOffice"]:["LibreOffice"],Ds={docxjs:["⚡","(Fast) works in the browser — lower fidelity"],LibreOffice:["🖨️","(High fidelity) converts to PDF locally with LibreOffice"]};function Dy({name:e,blob:t,displayReloadButton:n,iframeRef:r,autoReload:i,onToggleAutoReload:s,onManualRender:a,isGenerating:o,isRendering:l,onShowCacheMetrics:u,onShowSchemas:f,onShowFonts:d,documentText:p,warnings:h,renderingLibrary:m,setRenderingLibrary:w,onToggleChat:S,chatOpen:x,onTogglePreview:_,previewOpen:g}){const T=m!=="docxjs",[E,k]=y.useState(!1),[N,M]=y.useState(!1),[Y,C]=y.useState(!1),[B,R]=y.useState(!1),[U,L]=y.useState(!1),[P,A]=y.useState(!1),{toast:J}=Wi(),{generateDocument:O}=Ay(),q=y.useContext(rd),b=y.useCallback(()=>{const K={},{customThemes:ve}=q.getState();return Object.values(ve).forEach(de=>{de.valid&&de.parsed&&(K[de.name]=de.parsed)}),K},[q]),ce=Ee.useMemo(()=>{if(!p)return[];try{const K=JSON.parse(p);return[...(kt==="pptx"?pm:hm)(K)].filter(de=>!mm(de))}catch{return[]}},[p]),[oe,v]=y.useState(!1),X=y.useCallback(async()=>{if(t){k(!0);try{await new Promise(K=>setTimeout(K,100)),yi(`${e}${lr}`,t)}finally{setTimeout(()=>k(!1),500)}}},[t,e]),ae=y.useCallback(async()=>{if(t){if(ce.length===0){await X();return}v(!0)}},[t,ce.length,X]),ne=y.useCallback(async K=>{var ve;if(p){k(!0);try{const de=await O(e,p,b(),void 0,{bypassCache:!0,fonts:{mode:K}});if(de.blob.size===0)J({title:"Export failed",description:"The server returned an empty document.",variant:"destructive"});else{yi(`${e}${lr}`,de.blob);const xe=(ve=de.warnings)==null?void 0:ve.find(Ue=>{var rt,Ge;return((rt=Ue.context)==null?void 0:rt.code)==="FONT_MODE_SUBSTITUTED"||((Ge=Ue.context)==null?void 0:Ge.code)==="FONT_MODE_CUSTOM"});xe&&J({title:K==="substitute"?"Fonts substituted":"Non-safe fonts kept",description:xe.message})}}catch(de){J({title:"Export failed",description:de instanceof Error?de.message:String(de),variant:"destructive"})}finally{setTimeout(()=>k(!1),500)}}},[p,e,O,J,b]),I=y.useCallback(async()=>{if(!(!h||h.length===0)){M(!0);try{const K=Py(h);if(!K){J({title:"No warnings",description:"There are no warnings to download.",variant:"destructive"});return}const ve=await O("warnings",JSON.stringify(K,null,2),{});ve&&typeof ve=="object"&&"blob"in ve&&ve.blob&&(yi(`${e}-warnings${lr}`,ve.blob),J({title:"Warnings downloaded",description:`Downloaded warnings document with ${h.length} warning(s).`}))}catch(K){console.error("Failed to generate warnings document:",K),J({title:"Download failed",description:K instanceof Error?K.message:"Failed to generate warnings document",variant:"destructive"})}finally{setTimeout(()=>M(!1),500)}}},[h,e,O,J]),$=y.useCallback(async()=>{const K=r==null?void 0:r.current;if(K!=null&&K.src){C(!0);try{await new Promise(de=>{let xe=null,Ue=!1;const rt=()=>{xe&&(clearTimeout(xe),xe=null),K.removeEventListener("load",j),K.removeEventListener("error",z)},Ge=()=>{Ue||(Ue=!0,rt(),de())},j=()=>Ge(),z=()=>Ge();K.addEventListener("load",j),K.addEventListener("error",z),xe=setTimeout(()=>{console.warn("Iframe reload timed out after 5 seconds"),Ge()},5e3);const Z=K.src,re=Z.includes("?")?"&":"?",te=Date.now();K.src=`${Z}${re}_reload=${te}`})}catch(ve){console.error("Iframe reload failed:",ve)}finally{C(!1)}}},[r]),W=y.useCallback(async()=>{R(!0);try{await Ty.delete(`/${kt}/cache`),window.dispatchEvent(new CustomEvent("cache:cleared")),J({title:"Cache Cleared",description:"All caches (document and component) have been successfully cleared.",variant:"default"})}catch(K){console.error("Failed to clear cache:",K),J({title:"Cache Clear Failed",description:"Failed to clear caches. Please try again.",variant:"destructive"})}finally{R(!1)}},[J]),le=y.useCallback(async()=>{if(!p){J({title:"No document available",description:"Please select a document to copy standard components",variant:"destructive"});return}A(!0);try{const K=await fetch(`/api/${kt}/standard-components`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonDefinition:p})});if(!K.ok){let xe=`Request failed with status ${K.status}`;try{const Ue=await K.json();Ue.message&&(xe=Ue.message)}catch{}J({title:"Failed to get standard components",description:xe,variant:"destructive"});return}const ve=await K.json(),de=JSON.stringify(ve.data,null,2);await navigator.clipboard.writeText(de),J({title:"Copied to clipboard",description:"Standard modules JSON has been copied"})}catch(K){console.error("Error copying standard components:",K),J({title:"Error",description:K instanceof Error?K.message:"Failed to copy standard components",variant:"destructive"})}finally{A(!1)}},[p,J]);return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"bg-sidebar flex flex-row flex-nowrap items-center justify-between gap-x-2 px-3 py-1.5",children:[c.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[c.jsx("p",{className:"text-foreground text-sm font-semibold tracking-tight truncate flex-1 min-w-0",children:e}),c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:c.jsx("button",{type:"button","aria-label":"Preview disclaimer",className:"cursor-help inline-flex items-center justify-center h-6 w-6 rounded hover:bg-muted/60 shrink-0",children:c.jsx(Xc,{className:"h-3.5 w-3.5 text-muted-foreground"})})}),c.jsx(et,{className:"max-w-sm",children:c.jsxs("p",{className:"text-sm",children:["Preview uses"," ",kt==="docx"?"docx-preview":"LibreOffice PDF conversion",". Download the ",lr," to verify fidelity."]})})]})]}),c.jsxs("div",{className:"flex flex-row items-center gap-x-1 shrink-0",children:[(!i||T)&&c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:c.jsxs(_e,{variant:"default",size:"sm",className:"gap-1.5 h-7 px-2.5",onClick:a,"aria-label":"Render preview",disabled:o||l||g===!1,children:[l?c.jsx(nn,{size:"sm"}):c.jsx(Xm,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Run"})]})}),c.jsx(et,{children:c.jsx("p",{children:g===!1?"Open preview to run":l?"Rendering preview...":"Render preview"})})]}),kt==="docx"&&c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:c.jsxs("div",{className:"flex items-center gap-1.5 cursor-help ml-2 mr-1",children:[c.jsx(Ga,{className:"text-xs text-muted-foreground hidden sm:inline",children:"Auto"}),c.jsx(eo,{checked:i,onCheckedChange:s,disabled:T})]})}),c.jsx(et,{children:c.jsx("p",{children:T?"Auto-reload is not available for Office, Docs, and LibreOffice renderers":`${i?"Disable":"Enable"} automatic preview reload on content changes`})})]}),n&&i&&c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:c.jsx(_e,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:$,disabled:Y||o||l,children:Y?c.jsx(nn,{size:"sm"}):c.jsx(Qm,{className:"h-3.5 w-3.5"})})}),c.jsx(et,{children:c.jsx("p",{children:Y?"Reloading...":"Reload"})})]}),c.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:c.jsxs(_e,{variant:"outline",size:"sm",className:"gap-1.5 h-7 px-2.5",disabled:!t||E||o,onClick:ae,children:[E?c.jsx(nn,{size:"sm"}):c.jsx(eg,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Download"})]})}),c.jsx(et,{children:c.jsxs("p",{children:["Download ",lr]})})]}),h&&h.length>0&&c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:c.jsx(_e,{variant:"outline",size:"icon",className:"h-7 w-7 bg-amber-50 dark:bg-amber-950 text-amber-600 dark:text-amber-400 border-amber-200 dark:border-amber-800 hover:bg-amber-100 dark:hover:bg-amber-900",disabled:N||o,onClick:I,children:N?c.jsx(nn,{size:"sm"}):c.jsx(Qc,{className:"h-3.5 w-3.5"})})}),c.jsx(et,{children:c.jsxs("p",{children:["Download warnings (",h.length,")"]})})]}),m&&w&&c.jsxs(Ka,{value:m,onValueChange:w,children:[c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:c.jsx(ss,{className:"w-[140px] h-7 text-xs hidden lg:flex",children:c.jsx(Ya,{placeholder:"Renderer"})})}),c.jsx(et,{children:c.jsx("p",{children:"Select the rendering library"})})]}),c.jsx(as,{className:"text-sidebar-foreground",children:hl.map(K=>c.jsxs(Ar,{value:K,children:[c.jsxs(Xe,{children:[c.jsx(Qe,{tabIndex:-1,children:Ds[K][0]}),c.jsx(et,{children:Ds[K][1]})]})," ",K]},K))})]}),c.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),c.jsxs(to,{children:[c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:c.jsx(no,{asChild:!0,children:c.jsx(_e,{variant:"ghost",size:"icon",className:"h-7 w-7",children:c.jsx(tg,{className:"h-3.5 w-3.5"})})})}),c.jsx(et,{children:c.jsx("p",{children:"More actions"})})]}),c.jsxs(ls,{align:"end",className:"w-52",children:[f&&c.jsxs(qt,{onClick:f,children:[c.jsx(ng,{className:"h-4 w-4 mr-2"}),"View JSON Schemas"]}),d&&c.jsxs(qt,{onClick:d,children:[c.jsx(rg,{className:"h-4 w-4 mr-2"}),"Browse fonts"]}),u&&c.jsxs(qt,{onClick:u,children:[c.jsx(ig,{className:"h-4 w-4 mr-2"}),"View cache metrics"]}),c.jsxs(qt,{onClick:le,disabled:!p||P,children:[c.jsx(ed,{className:"h-4 w-4 mr-2"}),P?"Copying...":"Copy standard components"]}),c.jsx(Or,{}),c.jsxs(qt,{onClick:()=>L(!0),disabled:B,className:"text-destructive focus:text-destructive",children:[c.jsx(Va,{className:"h-4 w-4 mr-2"}),B?"Clearing...":"Clear all caches"]}),m&&w&&c.jsxs(c.Fragment,{children:[c.jsx(Or,{className:"lg:hidden"}),hl.map(K=>c.jsxs(qt,{className:"lg:hidden",onClick:()=>w(K),children:[c.jsx("span",{className:"mr-2",children:m===K?"●":"○"}),Ds[K][0]," ",K]},K))]})]})]}),_&&c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:c.jsx(_e,{variant:g?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:_,children:g?c.jsx(td,{className:"h-3.5 w-3.5"}):c.jsx(sg,{className:"h-3.5 w-3.5"})})}),c.jsx(et,{children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[g?"Hide":"Show"," Preview"," ",c.jsx(ya,{shortcut:"mod+shift+p"})]})})]}),S&&c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:c.jsx(_e,{variant:x?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:S,children:c.jsx(nd,{className:"h-3.5 w-3.5"})})}),c.jsx(et,{children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[x?"Close":"Open"," AI Chat"," ",c.jsx(ya,{shortcut:"mod+shift+j"})]})})]})]})]}),c.jsx(Oy,{open:oe,onClose:()=>v(!1),nonSafeFonts:ce,onChoose:ne}),c.jsx(Dt,{open:U,onOpenChange:L,children:c.jsxs(Et,{className:"max-w-sm",children:[c.jsxs(Gt,{children:[c.jsx(Kt,{children:"Clear all caches?"}),c.jsx(Cn,{children:"This will clear document and component caches. Next generation will be uncached."})]}),c.jsxs(Yn,{children:[c.jsx(_e,{variant:"outline",size:"sm",onClick:()=>L(!1),children:"Cancel"}),c.jsx(_e,{variant:"destructive",size:"sm",disabled:B,onClick:async()=>{await W(),L(!1)},children:B?c.jsx(nn,{size:"sm"}):"Clear"})]})]})})]})}const Ry=Ee.memo(Dy);function My(e,t,n){if(t.length===0)return n;const r=ml(e,t[0]);let i=r;for(let s=0;s<t.length-1;s++){const a=t[s],o=t[s+1],l=i[a],u=ml(l,o);i[a]=u,i=u}return i[t[t.length-1]]=n,r}function ml(e,t){return typeof t=="number"?Array.isArray(e)?[...e]:[]:e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{}}const $y={safe:[],google:[]};function Fy(e,t){var f;const n=`gf-${e.replace(/\s+/g,"-")}`,r=document.getElementById(n),i=new Set(t&&t.length>0?t:[400,700]),s=new Set(((f=r==null?void 0:r.dataset.weights)==null?void 0:f.split(",").map(Number).filter(d=>!Number.isNaN(d)))??[]),a=new Set([...s,...i]);if(r&&a.size===s.size)return;const o=[...a].sort((d,p)=>d-p).join(";"),l=`https://fonts.googleapis.com/css2?family=${encodeURIComponent(e)}:wght@${o}&display=swap`,u=r??document.createElement("link");r||(u.id=n,u.rel="stylesheet",document.head.appendChild(u)),u.href=l,u.dataset.weights=[...a].sort((d,p)=>d-p).join(",")}function Ly(){const e=Ae(i=>i.activeTab),t=Ae(i=>i.documents),n=Ae(i=>i.documentTypes),r=Ae(i=>i.saveDocument);return y.useCallback(i=>{if(!e)return{ok:!1,error:"No active file"};if(n[e]!=="application/json+theme")return{ok:!1,error:"Fonts are registered on themes, not documents. Open a .theme.json file and try again."};const s=t.find(l=>l.name===e);if(!s)return{ok:!1,error:"Active theme not found"};let a;try{a=JSON.parse(s.text)}catch(l){return{ok:!1,error:`Active theme is not valid JSON: ${l.message}`}}const o=i(a);return r(e,JSON.stringify(o,null,2)),{ok:!0,name:e}},[e,t,n,r])}function Zy(){const e=Ae(r=>r.activeTab),t=Ae(r=>r.documents),n=Ae(r=>r.saveDocument);return y.useCallback((r,i)=>{if(!e)return{ok:!1,error:"No active file"};const s=t.find(l=>l.name===e);if(!s)return{ok:!1,error:"Active document not found"};let a;try{a=JSON.parse(s.text)}catch(l){return{ok:!1,error:`Active document is not valid JSON: ${l.message}`}}const o=My(a,r,i);return n(e,JSON.stringify(o,null,2)),{ok:!0,name:e}},[e,t,n])}function By(e,t,n){(!e.fonts||typeof e.fonts!="object")&&(e.fonts={});const r=e.fonts[t];r&&typeof r=="object"?e.fonts[t]={...r,family:n}:e.fonts[t]=n}function gl(e){return e.map((t,n)=>typeof t=="number"?`[${t}]`:n===0?t:`.${t}`).join("")}const Vy=({open:e,onOpenChange:t})=>{const n=pi(A=>A.open),r=pi(A=>A.contextual),i=pi(A=>A.close),s=e??n,a=r,o=y.useCallback(A=>{t&&t(A),A||i()},[t,i]),[l,u]=y.useState($y),[f,d]=y.useState(!1),[p,h]=y.useState(""),[m,w]=y.useState("safe"),[S,x]=y.useState(null),[_,g]=y.useState(null),{toast:T}=Wi(),E=Ly(),k=Zy(),N=Ae(A=>A.activeTab),M=Ae(A=>A.documentTypes),Y=N&&M[N]==="application/json+theme",C=!!a||Y;y.useEffect(()=>{s&&(l.safe.length>0||l.google.length>0||(d(!0),fetch("/api/fonts/catalog").then(A=>A.json()).then(A=>u(A)).catch(A=>{T({variant:"destructive",title:"Font catalog unavailable",description:A.message})}).finally(()=>d(!1))))},[s,l,T]),y.useEffect(()=>{if(!(m!=="google"||l.google.length===0))for(const A of l.google)Fy(A.family,A.weights)},[m,l]);const B=y.useMemo(()=>l.safe.filter(A=>A.toLowerCase().includes(p.toLowerCase())),[l.safe,p]),R=y.useMemo(()=>l.google.filter(A=>A.family.toLowerCase().includes(p.toLowerCase())),[l.google,p]),U=y.useCallback(async A=>{try{await navigator.clipboard.writeText(A),g(A),setTimeout(()=>g(null),1500)}catch{T({variant:"destructive",title:"Copy failed",description:"Your browser blocked clipboard write."})}},[T]),L=y.useCallback(async(A,J,O)=>{x(A);try{const q=E(b=>(By(b,O,A),b));if(!q.ok){T({variant:"destructive",title:"Could not insert font",description:q.error});return}T({title:"Font inserted",description:`${A} set as ${O} font in "${q.name}".`})}finally{x(null)}},[E,T]),P=y.useCallback(async A=>{if(a){x(A);try{const J=k(a.jsonPath,A);if(!J.ok){T({variant:"destructive",title:"Could not insert font",description:J.error});return}T({title:"Font inserted",description:`${A} set at ${gl(a.jsonPath)}.`}),o(!1)}finally{x(null)}}},[a,k,T,o]);return c.jsx(Dt,{open:s,onOpenChange:o,children:c.jsxs(Et,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[c.jsx(Gt,{children:c.jsx(Kt,{children:a?`Font for ${gl(a.jsonPath)}`:"Fonts"})}),!a&&!Y&&c.jsx(Ii,{children:c.jsxs(zi,{children:["Fonts are registered on themes. Open a ",c.jsx("code",{children:".theme.json"})," ","file to apply a font — the buttons below are disabled until you do."]})}),c.jsxs(Jd,{value:m,onValueChange:A=>w(A),className:"flex-1 overflow-hidden flex flex-col",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(ro,{children:[c.jsxs(Dr,{value:"safe",children:["Safe",c.jsx(kn,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:l.safe.length})]}),c.jsxs(Dr,{value:"google",children:["Google",c.jsx(kn,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:l.google.length})]})]}),c.jsx(is,{type:"search",placeholder:"Search fonts...",value:p,onChange:A=>h(A.target.value),className:"ml-auto max-w-xs"})]}),c.jsxs("div",{className:"flex-1 overflow-auto mt-4 pr-2",children:[c.jsx(Rr,{value:"safe",className:"m-0",children:f&&B.length===0?c.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[c.jsx(aa,{className:"animate-spin mr-2"})," Loading catalog..."]}):c.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:B.map(A=>c.jsx(xl,{family:A,meta:c.jsx("span",{className:"text-xs",children:"Installed with Office"}),previewStyle:{fontFamily:`"${A}", sans-serif`},onCopy:()=>U(A),copied:_===A,contextual:!!a,onUseThis:()=>P(A),onInsertHeading:()=>L(A,"safe","heading"),onInsertBody:()=>L(A,"safe","body"),applying:S===A,disabled:!C},A))})}),c.jsx(Rr,{value:"google",className:"m-0",children:f&&R.length===0?c.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[c.jsx(aa,{className:"animate-spin mr-2"})," Loading catalog..."]}):c.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:R.map(A=>c.jsx(xl,{family:A.family,meta:c.jsxs("span",{className:"text-xs",children:[A.category," · ",A.weights.length," weights"]}),previewStyle:{fontFamily:`"${A.family}", sans-serif`},onCopy:()=>U(A.family),copied:_===A.family,contextual:!!a,onUseThis:()=>P(A.family),onInsertHeading:()=>L(A.family,"google","heading"),onInsertBody:()=>L(A.family,"google","body"),applying:S===A.family,disabled:!C,extraAction:c.jsx(Jy,{family:A.family,weights:A.weights,hasItalic:A.hasItalic})},A.family))})})]})]})]})})},Uy="The quick brown fox jumps over the lazy dog",Jy=({family:e,weights:t,hasItalic:n})=>{const r=y.useMemo(()=>[...t].sort((i,s)=>i-s),[t]);return c.jsxs(to,{children:[c.jsx(no,{asChild:!0,children:c.jsx(_e,{size:"sm",variant:"ghost","aria-label":"Show variants",children:"Variants"})}),c.jsxs(ls,{align:"end",className:"min-w-[260px]",children:[c.jsxs(Ud,{className:"text-xs text-muted-foreground",children:[r.length," weight",r.length===1?"":"s",n?" · italic available":""]}),c.jsx(Or,{}),r.map(i=>{const s=gm[i]??String(i);return c.jsxs("div",{className:"flex flex-col gap-0.5 px-2 py-1.5",children:[c.jsx("span",{className:"truncate",style:{fontFamily:`"${e}", sans-serif`,fontWeight:i},children:s}),c.jsxs("span",{className:"text-xs text-muted-foreground font-mono",children:["fontWeight: ",i]})]},i)})]})]})},xl=({family:e,meta:t,previewStyle:n,onCopy:r,copied:i,contextual:s,onUseThis:a,onInsertHeading:o,onInsertBody:l,applying:u,disabled:f,extraAction:d})=>c.jsxs("div",{className:"border rounded-md p-3 flex flex-col gap-2 bg-card",children:[c.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[c.jsx("div",{className:"font-medium truncate",children:e}),c.jsx("div",{className:"text-muted-foreground",children:t})]}),c.jsx("div",{className:"text-lg truncate",style:n,"aria-hidden":!0,children:Uy}),c.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s?c.jsx(_e,{size:"sm",onClick:a,disabled:u||f,"aria-label":`Use ${e} at the target path`,children:"Use this font"}):c.jsxs(c.Fragment,{children:[c.jsx(_e,{size:"sm",variant:"secondary",onClick:o,disabled:u||f,"aria-label":`Set ${e} as heading font`,children:"Set heading"}),c.jsx(_e,{size:"sm",variant:"secondary",onClick:l,disabled:u||f,"aria-label":`Set ${e} as body font`,children:"Set body"})]}),d,c.jsx(_e,{size:"sm",variant:"ghost",className:"ml-auto",onClick:r,"aria-label":`Copy ${e}`,children:i?c.jsx(ln,{className:"h-4 w-4"}):c.jsx(es,{className:"h-4 w-4"})})]})]});function yl({previewOpen:e,onTogglePreview:t}){const n=yn(M=>M.name||""),r=yn(M=>M.blob),i=yn(M=>M.isGenerating),s=yn(M=>M.text),a=yn(M=>M.warnings),o=yn(M=>M.isRendering),l=ni(M=>M.autoReload),u=ni(M=>M.renderingLibrary),f=ni(M=>M.setSettings),d=ni(M=>M.useGlobalPreviewHeader??!0),p=Ae(M=>M.activeTab),h=Ae(M=>M.documentTypes),m=p&&h[p]==="application/json+theme"?"theme":"document",w=Te(M=>M.chatOpen),S=Te(M=>M.toggleChat),[x,_]=Ee.useState(!1),g=pi(M=>M.openFor);if(!d)return null;const T=y.useCallback(()=>f({saveDocumentDebounceWait:2e3,autoReload:!l}),[l,f]),E=y.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:manualRender"))},[]),k=y.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:showCacheMetrics"))},[]),N=(n==null?void 0:n.trim())||"Preview";return c.jsxs("div",{className:"sticky top-0 z-20",children:[c.jsx(Ry,{name:N,blob:r,displayReloadButton:!1,autoReload:l,onToggleAutoReload:T,onManualRender:E,isGenerating:i,isRendering:!!o,onShowCacheMetrics:k,onShowSchemas:()=>_(!0),onShowFonts:()=>g(),documentText:s,warnings:a,renderingLibrary:u,setRenderingLibrary:M=>f({renderingLibrary:M}),onToggleChat:S,chatOpen:w,onTogglePreview:t,previewOpen:e}),c.jsx(Hd,{open:x,onOpenChange:_,defaultTab:m==="theme"?"theme":"document"}),c.jsx(Vy,{})]})}function Hy(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const qy=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Wy=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Gy={};function bl(e,t){return(Gy.jsx?Wy:qy).test(e)}const Ky=/[ \t\n\f\r]/g;function Yy(e){return typeof e=="object"?e.type==="text"?vl(e.value):!1:vl(e)}function vl(e){return e.replace(Ky,"")===""}class Gr{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Gr.prototype.normal={};Gr.prototype.property={};Gr.prototype.space=void 0;function xf(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Gr(n,r,t)}function ba(e){return e.toLowerCase()}class yt{constructor(t,n){this.attribute=n,this.property=t}}yt.prototype.attribute="";yt.prototype.booleanish=!1;yt.prototype.boolean=!1;yt.prototype.commaOrSpaceSeparated=!1;yt.prototype.commaSeparated=!1;yt.prototype.defined=!1;yt.prototype.mustUseProperty=!1;yt.prototype.number=!1;yt.prototype.overloadedBoolean=!1;yt.prototype.property="";yt.prototype.spaceSeparated=!1;yt.prototype.space=void 0;let Xy=0;const we=zn(),Ye=zn(),va=zn(),Q=zn(),$e=zn(),Gn=zn(),vt=zn();function zn(){return 2**++Xy}const wa=Object.freeze(Object.defineProperty({__proto__:null,boolean:we,booleanish:Ye,commaOrSpaceSeparated:vt,commaSeparated:Gn,number:Q,overloadedBoolean:va,spaceSeparated:$e},Symbol.toStringTag,{value:"Module"})),Rs=Object.keys(wa);class lo extends yt{constructor(t,n,r,i){let s=-1;if(super(t,n),wl(this,"space",i),typeof r=="number")for(;++s<Rs.length;){const a=Rs[s];wl(this,Rs[s],(r&wa[a])===wa[a])}}}lo.prototype.defined=!0;function wl(e,t,n){n&&(e[t]=n)}function ir(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new lo(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[ba(r)]=r,n[ba(s.attribute)]=r}return new Gr(t,n,e.space)}const yf=ir({properties:{ariaActiveDescendant:null,ariaAtomic:Ye,ariaAutoComplete:null,ariaBusy:Ye,ariaChecked:Ye,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:$e,ariaCurrent:null,ariaDescribedBy:$e,ariaDetails:null,ariaDisabled:Ye,ariaDropEffect:$e,ariaErrorMessage:null,ariaExpanded:Ye,ariaFlowTo:$e,ariaGrabbed:Ye,ariaHasPopup:null,ariaHidden:Ye,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:$e,ariaLevel:Q,ariaLive:null,ariaModal:Ye,ariaMultiLine:Ye,ariaMultiSelectable:Ye,ariaOrientation:null,ariaOwns:$e,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:Ye,ariaReadOnly:Ye,ariaRelevant:null,ariaRequired:Ye,ariaRoleDescription:$e,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:Ye,ariaSetSize:Q,ariaSort:null,ariaValueMax:Q,ariaValueMin:Q,ariaValueNow:Q,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function bf(e,t){return t in e?e[t]:t}function vf(e,t){return bf(e,t.toLowerCase())}const Qy=ir({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Gn,acceptCharset:$e,accessKey:$e,action:null,allow:null,allowFullScreen:we,allowPaymentRequest:we,allowUserMedia:we,alt:null,as:null,async:we,autoCapitalize:null,autoComplete:$e,autoFocus:we,autoPlay:we,blocking:$e,capture:null,charSet:null,checked:we,cite:null,className:$e,cols:Q,colSpan:null,content:null,contentEditable:Ye,controls:we,controlsList:$e,coords:Q|Gn,crossOrigin:null,data:null,dateTime:null,decoding:null,default:we,defer:we,dir:null,dirName:null,disabled:we,download:va,draggable:Ye,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:we,formTarget:null,headers:$e,height:Q,hidden:va,high:Q,href:null,hrefLang:null,htmlFor:$e,httpEquiv:$e,id:null,imageSizes:null,imageSrcSet:null,inert:we,inputMode:null,integrity:null,is:null,isMap:we,itemId:null,itemProp:$e,itemRef:$e,itemScope:we,itemType:$e,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:we,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,multiple:we,muted:we,name:null,nonce:null,noModule:we,noValidate:we,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:we,optimum:Q,pattern:null,ping:$e,placeholder:null,playsInline:we,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:we,referrerPolicy:null,rel:$e,required:we,reversed:we,rows:Q,rowSpan:Q,sandbox:$e,scope:null,scoped:we,seamless:we,selected:we,shadowRootClonable:we,shadowRootDelegatesFocus:we,shadowRootMode:null,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:Ye,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Q,step:null,style:null,tabIndex:Q,target:null,title:null,translate:null,type:null,typeMustMatch:we,useMap:null,value:Ye,width:Q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:$e,axis:null,background:null,bgColor:null,border:Q,borderColor:null,bottomMargin:Q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:we,declare:we,event:null,face:null,frame:null,frameBorder:null,hSpace:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:we,noHref:we,noShade:we,noWrap:we,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:Ye,standby:null,summary:null,text:null,topMargin:Q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Q,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:we,disableRemotePlayback:we,prefix:null,property:null,results:Q,security:null,unselectable:null},space:"html",transform:vf}),eb=ir({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:vt,accentHeight:Q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Q,amplitude:Q,arabicForm:null,ascent:Q,attributeName:null,attributeType:null,azimuth:Q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Q,by:null,calcMode:null,capHeight:Q,className:$e,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:Q,diffuseConstant:Q,direction:null,display:null,dur:null,divisor:Q,dominantBaseline:null,download:we,dx:null,dy:null,edgeMode:null,editable:null,elevation:Q,enableBackground:null,end:null,event:null,exponent:Q,externalResourcesRequired:null,fill:null,fillOpacity:Q,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:Gn,g2:Gn,glyphName:Gn,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Q,horizOriginX:Q,horizOriginY:Q,id:null,ideographic:Q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Q,k:Q,k1:Q,k2:Q,k3:Q,k4:Q,kernelMatrix:vt,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Q,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:Q,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:Q,overlineThickness:Q,paintOrder:null,panose1:null,path:null,pathLength:Q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:$e,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:vt,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:vt,rev:vt,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:vt,requiredFeatures:vt,requiredFonts:vt,requiredFormats:vt,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:Q,specularExponent:Q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Q,strikethroughThickness:Q,string:null,stroke:null,strokeDashArray:vt,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Q,strokeOpacity:Q,strokeWidth:null,style:null,surfaceScale:Q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:vt,tabIndex:Q,tableValues:null,target:null,targetX:Q,targetY:Q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:vt,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Q,underlineThickness:Q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Q,values:null,vAlphabetic:Q,vMathematical:Q,vectorEffect:null,vHanging:Q,vIdeographic:Q,version:null,vertAdvY:Q,vertOriginX:Q,vertOriginY:Q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:bf}),wf=ir({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()}}),kf=ir({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:vf}),Sf=ir({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),tb={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"},nb=/[A-Z]/g,kl=/-[a-z]/g,rb=/^data[-\w.:]+$/i;function ib(e,t){const n=ba(t);let r=t,i=yt;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&rb.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(kl,ab);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!kl.test(s)){let a=s.replace(nb,sb);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=lo}return new i(r,t)}function sb(e){return"-"+e.toLowerCase()}function ab(e){return e.charAt(1).toUpperCase()}const ob=xf([yf,Qy,wf,kf,Sf],"html"),uo=xf([yf,eb,wf,kf,Sf],"svg");function lb(e){return e.join(" ").trim()}var Dn={},Ms,Sl;function ub(){if(Sl)return Ms;Sl=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,o=/^\s+|\s+$/g,l=`
|
|
3
|
+
`,u="/",f="*",d="",p="comment",h="declaration";function m(S,x){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];x=x||{};var _=1,g=1;function T(L){var P=L.match(t);P&&(_+=P.length);var A=L.lastIndexOf(l);g=~A?L.length-A:g+L.length}function E(){var L={line:_,column:g};return function(P){return P.position=new k(L),Y(),P}}function k(L){this.start=L,this.end={line:_,column:g},this.source=x.source}k.prototype.content=S;function N(L){var P=new Error(x.source+":"+_+":"+g+": "+L);if(P.reason=L,P.filename=x.source,P.line=_,P.column=g,P.source=S,!x.silent)throw P}function M(L){var P=L.exec(S);if(P){var A=P[0];return T(A),S=S.slice(A.length),P}}function Y(){M(n)}function C(L){var P;for(L=L||[];P=B();)P!==!1&&L.push(P);return L}function B(){var L=E();if(!(u!=S.charAt(0)||f!=S.charAt(1))){for(var P=2;d!=S.charAt(P)&&(f!=S.charAt(P)||u!=S.charAt(P+1));)++P;if(P+=2,d===S.charAt(P-1))return N("End of comment missing");var A=S.slice(2,P-2);return g+=2,T(A),S=S.slice(P),g+=2,L({type:p,comment:A})}}function R(){var L=E(),P=M(r);if(P){if(B(),!M(i))return N("property missing ':'");var A=M(s),J=L({type:h,property:w(P[0].replace(e,d)),value:A?w(A[0].replace(e,d)):d});return M(a),J}}function U(){var L=[];C(L);for(var P;P=R();)P!==!1&&(L.push(P),C(L));return L}return Y(),U()}function w(S){return S?S.replace(o,d):d}return Ms=m,Ms}var _l;function cb(){if(_l)return Dn;_l=1;var e=Dn&&Dn.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Dn,"__esModule",{value:!0}),Dn.default=n;const t=e(ub());function n(r,i){let s=null;if(!r||typeof r!="string")return s;const a=(0,t.default)(r),o=typeof i=="function";return a.forEach(l=>{if(l.type!=="declaration")return;const{property:u,value:f}=l;o?i(u,f,l):f&&(s=s||{},s[u]=f)}),s}return Dn}var pr={},jl;function db(){if(jl)return pr;jl=1,Object.defineProperty(pr,"__esModule",{value:!0}),pr.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(u){return!u||n.test(u)||e.test(u)},a=function(u,f){return f.toUpperCase()},o=function(u,f){return"".concat(f,"-")},l=function(u,f){return f===void 0&&(f={}),s(u)?u:(u=u.toLowerCase(),f.reactCompat?u=u.replace(i,o):u=u.replace(r,o),u.replace(t,a))};return pr.camelCase=l,pr}var hr,Cl;function fb(){if(Cl)return hr;Cl=1;var e=hr&&hr.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(cb()),n=db();function r(i,s){var a={};return!i||typeof i!="string"||(0,t.default)(i,function(o,l){o&&l&&(a[(0,n.camelCase)(o,s)]=l)}),a}return r.default=r,hr=r,hr}var pb=fb();const hb=Za(pb),_f=jf("end"),co=jf("start");function jf(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 mb(e){const t=co(e),n=_f(e);if(t&&n)return{start:t,end:n}}function Ir(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Nl(e.position):"start"in e||"end"in e?Nl(e):"line"in e||"column"in e?ka(e):""}function ka(e){return El(e&&e.line)+":"+El(e&&e.column)}function Nl(e){return ka(e&&e.start)+"-"+ka(e&&e.end)}function El(e){return e&&typeof e=="number"?e:1}class at extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},a=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(a=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const o=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=o?o.line:void 0,this.name=Ir(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=a&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}at.prototype.file="";at.prototype.name="";at.prototype.reason="";at.prototype.message="";at.prototype.stack="";at.prototype.column=void 0;at.prototype.line=void 0;at.prototype.ancestors=void 0;at.prototype.cause=void 0;at.prototype.fatal=void 0;at.prototype.place=void 0;at.prototype.ruleId=void 0;at.prototype.source=void 0;const fo={}.hasOwnProperty,gb=new Map,xb=/[A-Z]/g,yb=new Set(["table","tbody","thead","tfoot","tr"]),bb=new Set(["td","th"]),Cf="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function vb(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=Eb(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=Nb(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?uo:ob,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=Nf(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function Nf(e,t,n){if(t.type==="element")return wb(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return kb(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return _b(e,t,n);if(t.type==="mdxjsEsm")return Sb(e,t);if(t.type==="root")return jb(e,t,n);if(t.type==="text")return Cb(e,t)}function wb(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=uo,e.schema=i),e.ancestors.push(t);const s=If(e,t.tagName,!1),a=Ib(e,t);let o=ho(e,t);return yb.has(t.tagName)&&(o=o.filter(function(l){return typeof l=="string"?!Yy(l):!0})),Ef(e,a,s,t),po(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function kb(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)}Fr(e,t.position)}function Sb(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Fr(e,t.position)}function _b(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=uo,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:If(e,t.name,!0),a=zb(e,t),o=ho(e,t);return Ef(e,a,s,t),po(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function jb(e,t,n){const r={};return po(r,ho(e,t)),e.create(t,e.Fragment,r,n)}function Cb(e,t){return t.value}function Ef(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function po(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Nb(e,t,n){return r;function r(i,s,a,o){const u=Array.isArray(a.children)?n:t;return o?u(s,a,o):u(s,a)}}function Eb(e,t){return n;function n(r,i,s,a){const o=Array.isArray(s.children),l=co(r);return t(i,s,a,o,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function Ib(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&fo.call(t.properties,i)){const s=Tb(e,i,t.properties[i]);if(s){const[a,o]=s;e.tableCellAlignToStyle&&a==="align"&&typeof o=="string"&&bb.has(t.tagName)?r=o:n[a]=o}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function zb(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const a=s.expression;a.type;const o=a.properties[0];o.type,Object.assign(n,e.evaluater.evaluateExpression(o.argument))}else Fr(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const o=r.value.data.estree.body[0];o.type,s=e.evaluater.evaluateExpression(o.expression)}else Fr(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function ho(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:gb;for(;++r<t.children.length;){const s=t.children[r];let a;if(e.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const u=i.get(l)||0;a=l+"-"+u,i.set(l,u+1)}}const o=Nf(e,s,a);o!==void 0&&n.push(o)}return n}function Tb(e,t,n){const r=ib(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Hy(n):lb(n)),r.property==="style"){let i=typeof n=="object"?n:Ab(e,String(n));return e.stylePropertyNameCase==="css"&&(i=Pb(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?tb[r.property]||r.property:r.attribute,n]}}function Ab(e,t){try{return hb(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new at("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=Cf+"#cannot-parse-style-attribute",i}}function If(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,a;for(;++s<i.length;){const o=bl(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};a=a?{type:"MemberExpression",object:a,property:o,computed:!!(s&&o.type==="Literal"),optional:!1}:o}r=a}else r=bl(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return fo.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);Fr(e)}function Fr(e,t){const n=new at("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=Cf+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Pb(e){const t={};let n;for(n in e)fo.call(e,n)&&(t[Ob(n)]=e[n]);return t}function Ob(e){let t=e.replace(xb,Db);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Db(e){return"-"+e.toLowerCase()}const $s={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"]},Rb={};function mo(e,t){const n=Rb,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return zf(e,r,i)}function zf(e,t,n){if(Mb(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Il(e.children,t,n)}return Array.isArray(e)?Il(e,t,n):""}function Il(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=zf(e[i],t,n);return r.join("")}function Mb(e){return!!(e&&typeof e=="object")}const zl=document.createElement("i");function go(e){const t="&"+e+";";zl.innerHTML=t;const n=zl.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function St(e,t,n,r){const i=e.length;let s=0,a;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);s<r.length;)a=r.slice(s,s+1e4),a.unshift(t,0),e.splice(...a),s+=1e4,t+=1e4}function Nt(e,t){return e.length>0?(St(e,e.length,0,t),e):t}const Tl={}.hasOwnProperty;function Tf(e){const t={};let n=-1;for(;++n<e.length;)$b(t,e[n]);return t}function $b(e,t){let n;for(n in t){const i=(Tl.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let a;if(s)for(a in s){Tl.call(i,a)||(i[a]=[]);const o=s[a];Fb(i[a],Array.isArray(o)?o:o?[o]:[])}}}function Fb(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);St(e,0,0,r)}function Af(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Mt(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const dt=dn(/[A-Za-z]/),st=dn(/[\dA-Za-z]/),Lb=dn(/[#-'*+\--9=?A-Z^-~]/);function Di(e){return e!==null&&(e<32||e===127)}const Sa=dn(/\d/),Zb=dn(/[\dA-Fa-f]/),Bb=dn(/[!-/:-@[-`{-~]/);function me(e){return e!==null&&e<-2}function Re(e){return e!==null&&(e<0||e===32)}function Ce(e){return e===-2||e===-1||e===32}const ps=dn(new RegExp("\\p{P}|\\p{S}","u")),En=dn(/\s/);function dn(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function sr(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let a="";if(s===37&&st(e.charCodeAt(n+1))&&st(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(a=String.fromCharCode(s));else if(s>55295&&s<57344){const o=e.charCodeAt(n+1);s<56320&&o>56319&&o<57344?(a=String.fromCharCode(s,o),i=1):a="�"}else a=String.fromCharCode(s);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function ze(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return a;function a(l){return Ce(l)?(e.enter(n),o(l)):t(l)}function o(l){return Ce(l)&&s++<i?(e.consume(l),o):(e.exit(n),t(l))}}const Vb={tokenize:Ub};function Ub(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),ze(e,t,"linePrefix")}function i(o){return e.enter("paragraph"),s(o)}function s(o){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,a(o)}function a(o){if(o===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(o);return}return me(o)?(e.consume(o),e.exit("chunkText"),s):(e.consume(o),a)}}const Jb={tokenize:Hb},Al={tokenize:qb};function Hb(e){const t=this,n=[];let r=0,i,s,a;return o;function o(g){if(r<n.length){const T=n[r];return t.containerState=T[1],e.attempt(T[0].continuation,l,u)(g)}return u(g)}function l(g){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&_();const T=t.events.length;let E=T,k;for(;E--;)if(t.events[E][0]==="exit"&&t.events[E][1].type==="chunkFlow"){k=t.events[E][1].end;break}x(r);let N=T;for(;N<t.events.length;)t.events[N][1].end={...k},N++;return St(t.events,E+1,0,t.events.slice(T)),t.events.length=N,u(g)}return o(g)}function u(g){if(r===n.length){if(!i)return p(g);if(i.currentConstruct&&i.currentConstruct.concrete)return m(g);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Al,f,d)(g)}function f(g){return i&&_(),x(r),p(g)}function d(g){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,m(g)}function p(g){return t.containerState={},e.attempt(Al,h,m)(g)}function h(g){return r++,n.push([t.currentConstruct,t.containerState]),p(g)}function m(g){if(g===null){i&&_(),x(0),e.consume(g);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),w(g)}function w(g){if(g===null){S(e.exit("chunkFlow"),!0),x(0),e.consume(g);return}return me(g)?(e.consume(g),S(e.exit("chunkFlow")),r=0,t.interrupt=void 0,o):(e.consume(g),w)}function S(g,T){const E=t.sliceStream(g);if(T&&E.push(null),g.previous=s,s&&(s.next=g),s=g,i.defineSkip(g.start),i.write(E),t.parser.lazy[g.start.line]){let k=i.events.length;for(;k--;)if(i.events[k][1].start.offset<a&&(!i.events[k][1].end||i.events[k][1].end.offset>a))return;const N=t.events.length;let M=N,Y,C;for(;M--;)if(t.events[M][0]==="exit"&&t.events[M][1].type==="chunkFlow"){if(Y){C=t.events[M][1].end;break}Y=!0}for(x(r),k=N;k<t.events.length;)t.events[k][1].end={...C},k++;St(t.events,M+1,0,t.events.slice(N)),t.events.length=k}}function x(g){let T=n.length;for(;T-- >g;){const E=n[T];t.containerState=E[1],E[0].exit.call(t,e)}n.length=g}function _(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function qb(e,t,n){return ze(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Qn(e){if(e===null||Re(e)||En(e))return 1;if(ps(e))return 2}function hs(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 _a={name:"attention",resolveAll:Wb,tokenize:Gb};function Wb(e,t){let n=-1,r,i,s,a,o,l,u,f;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const d={...e[r][1].end},p={...e[n][1].start};Pl(d,-l),Pl(p,l),a={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},o={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},s={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...a.start},end:{...o.end}},e[r][1].end={...a.start},e[n][1].start={...o.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=Nt(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Nt(u,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",s,t]]),u=Nt(u,hs(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Nt(u,[["exit",s,t],["enter",o,t],["exit",o,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,u=Nt(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):f=0,St(e,r-1,n-r+3,u),n=r+u.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function Gb(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Qn(r);let s;return a;function a(l){return s=l,e.enter("attentionSequence"),o(l)}function o(l){if(l===s)return e.consume(l),o;const u=e.exit("attentionSequence"),f=Qn(l),d=!f||f===2&&i||n.includes(l),p=!i||i===2&&f||n.includes(r);return u._open=!!(s===42?d:d&&(i||!p)),u._close=!!(s===42?p:p&&(f||!d)),t(l)}}function Pl(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Kb={name:"autolink",tokenize:Yb};function Yb(e,t,n){let r=0;return i;function i(h){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(h){return dt(h)?(e.consume(h),a):h===64?n(h):u(h)}function a(h){return h===43||h===45||h===46||st(h)?(r=1,o(h)):u(h)}function o(h){return h===58?(e.consume(h),r=0,l):(h===43||h===45||h===46||st(h))&&r++<32?(e.consume(h),o):(r=0,u(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||Di(h)?n(h):(e.consume(h),l)}function u(h){return h===64?(e.consume(h),f):Lb(h)?(e.consume(h),u):n(h)}function f(h){return st(h)?d(h):n(h)}function d(h){return h===46?(e.consume(h),r=0,f):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):p(h)}function p(h){if((h===45||st(h))&&r++<63){const m=h===45?p:d;return e.consume(h),m}return n(h)}}const Kr={partial:!0,tokenize:Xb};function Xb(e,t,n){return r;function r(s){return Ce(s)?ze(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||me(s)?t(s):n(s)}}const Pf={continuation:{tokenize:ev},exit:tv,name:"blockQuote",tokenize:Qb};function Qb(e,t,n){const r=this;return i;function i(a){if(a===62){const o=r.containerState;return o.open||(e.enter("blockQuote",{_container:!0}),o.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),s}return n(a)}function s(a){return Ce(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function ev(e,t,n){const r=this;return i;function i(a){return Ce(a)?ze(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):s(a)}function s(a){return e.attempt(Pf,t,n)(a)}}function tv(e){e.exit("blockQuote")}const Of={name:"characterEscape",tokenize:nv};function nv(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 Bb(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const Df={name:"characterReference",tokenize:rv};function rv(e,t,n){const r=this;let i=0,s,a;return o;function o(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),l}function l(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),s=31,a=st,f(d))}function u(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,a=Zb,f):(e.enter("characterReferenceValue"),s=7,a=Sa,f(d))}function f(d){if(d===59&&i){const p=e.exit("characterReferenceValue");return a===st&&!go(r.sliceSerialize(p))?n(d):(e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(d)&&i++<s?(e.consume(d),f):n(d)}}const Ol={partial:!0,tokenize:sv},Dl={concrete:!0,name:"codeFenced",tokenize:iv};function iv(e,t,n){const r=this,i={partial:!0,tokenize:E};let s=0,a=0,o;return l;function l(k){return u(k)}function u(k){const N=r.events[r.events.length-1];return s=N&&N[1].type==="linePrefix"?N[2].sliceSerialize(N[1],!0).length:0,o=k,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),f(k)}function f(k){return k===o?(a++,e.consume(k),f):a<3?n(k):(e.exit("codeFencedFenceSequence"),Ce(k)?ze(e,d,"whitespace")(k):d(k))}function d(k){return k===null||me(k)?(e.exit("codeFencedFence"),r.interrupt?t(k):e.check(Ol,w,T)(k)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(k))}function p(k){return k===null||me(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(k)):Ce(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ze(e,h,"whitespace")(k)):k===96&&k===o?n(k):(e.consume(k),p)}function h(k){return k===null||me(k)?d(k):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(k))}function m(k){return k===null||me(k)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(k)):k===96&&k===o?n(k):(e.consume(k),m)}function w(k){return e.attempt(i,T,S)(k)}function S(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),x}function x(k){return s>0&&Ce(k)?ze(e,_,"linePrefix",s+1)(k):_(k)}function _(k){return k===null||me(k)?e.check(Ol,w,T)(k):(e.enter("codeFlowValue"),g(k))}function g(k){return k===null||me(k)?(e.exit("codeFlowValue"),_(k)):(e.consume(k),g)}function T(k){return e.exit("codeFenced"),t(k)}function E(k,N,M){let Y=0;return C;function C(P){return k.enter("lineEnding"),k.consume(P),k.exit("lineEnding"),B}function B(P){return k.enter("codeFencedFence"),Ce(P)?ze(k,R,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):R(P)}function R(P){return P===o?(k.enter("codeFencedFenceSequence"),U(P)):M(P)}function U(P){return P===o?(Y++,k.consume(P),U):Y>=a?(k.exit("codeFencedFenceSequence"),Ce(P)?ze(k,L,"whitespace")(P):L(P)):M(P)}function L(P){return P===null||me(P)?(k.exit("codeFencedFence"),N(P)):M(P)}}}function sv(e,t,n){const r=this;return i;function i(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const Fs={name:"codeIndented",tokenize:ov},av={partial:!0,tokenize:lv};function ov(e,t,n){const r=this;return i;function i(u){return e.enter("codeIndented"),ze(e,s,"linePrefix",5)(u)}function s(u){const f=r.events[r.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?a(u):n(u)}function a(u){return u===null?l(u):me(u)?e.attempt(av,a,l)(u):(e.enter("codeFlowValue"),o(u))}function o(u){return u===null||me(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),o)}function l(u){return e.exit("codeIndented"),t(u)}}function lv(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):me(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):ze(e,s,"linePrefix",5)(a)}function s(a){const o=r.events[r.events.length-1];return o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):me(a)?i(a):n(a)}}const uv={name:"codeText",previous:dv,resolve:cv,tokenize:fv};function cv(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 dv(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function fv(e,t,n){let r=0,i,s;return a;function a(d){return e.enter("codeText"),e.enter("codeTextSequence"),o(d)}function o(d){return d===96?(e.consume(d),r++,o):(e.exit("codeTextSequence"),l(d))}function l(d){return d===null?n(d):d===32?(e.enter("space"),e.consume(d),e.exit("space"),l):d===96?(s=e.enter("codeTextSequence"),i=0,f(d)):me(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),l):(e.enter("codeTextData"),u(d))}function u(d){return d===null||d===32||d===96||me(d)?(e.exit("codeTextData"),l(d)):(e.consume(d),u)}function f(d){return d===96?(e.consume(d),i++,f):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(d)):(s.type="codeTextData",u(d))}}class pv{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&mr(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),mr(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),mr(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);mr(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);mr(this.left,n.reverse())}}}function mr(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Rf(e){const t={};let n=-1,r,i,s,a,o,l,u;const f=new pv(e);for(;++n<f.length;){for(;n in t;)n=t[n];if(r=f.get(n),n&&r[1].type==="chunkFlow"&&f.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,hv(f,n)),n=t[n],u=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(a=f.get(s),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(i&&(f.get(i)[1].type="lineEndingBlank"),a[1].type="lineEnding",i=s);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;i&&(r[1].end={...f.get(i)[1].start},o=f.slice(i,n),o.unshift(r),f.splice(i,n-i+1,o))}}return St(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!u}function hv(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const o=a.events,l=[],u={};let f,d,p=-1,h=n,m=0,w=0;const S=[w];for(;h;){for(;e.get(++i)[1]!==h;);s.push(i),h._tokenizer||(f=r.sliceStream(h),h.next||f.push(null),d&&a.defineSkip(h.start),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(f),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),d=h,h=h.next}for(h=n;++p<o.length;)o[p][0]==="exit"&&o[p-1][0]==="enter"&&o[p][1].type===o[p-1][1].type&&o[p][1].start.line!==o[p][1].end.line&&(w=p+1,S.push(w),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(a.events=[],h?(h._tokenizer=void 0,h.previous=void 0):S.pop(),p=S.length;p--;){const x=o.slice(S[p],S[p+1]),_=s.pop();l.push([_,_+x.length-1]),e.splice(_,2,x)}for(l.reverse(),p=-1;++p<l.length;)u[m+l[p][0]]=m+l[p][1],m+=l[p][1]-l[p][0]-1;return u}const mv={resolve:xv,tokenize:yv},gv={partial:!0,tokenize:bv};function xv(e){return Rf(e),e}function yv(e,t){let n;return r;function r(o){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(o)}function i(o){return o===null?s(o):me(o)?e.check(gv,a,s)(o):(e.consume(o),i)}function s(o){return e.exit("chunkContent"),e.exit("content"),t(o)}function a(o){return e.consume(o),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function bv(e,t,n){const r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),ze(e,s,"linePrefix")}function s(a){if(a===null||me(a))return n(a);const o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function Mf(e,t,n,r,i,s,a,o,l){const u=l||Number.POSITIVE_INFINITY;let f=0;return d;function d(x){return x===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(x),e.exit(s),p):x===null||x===32||x===41||Di(x)?n(x):(e.enter(r),e.enter(a),e.enter(o),e.enter("chunkString",{contentType:"string"}),w(x))}function p(x){return x===62?(e.enter(s),e.consume(x),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),h(x))}function h(x){return x===62?(e.exit("chunkString"),e.exit(o),p(x)):x===null||x===60||me(x)?n(x):(e.consume(x),x===92?m:h)}function m(x){return x===60||x===62||x===92?(e.consume(x),h):h(x)}function w(x){return!f&&(x===null||x===41||Re(x))?(e.exit("chunkString"),e.exit(o),e.exit(a),e.exit(r),t(x)):f<u&&x===40?(e.consume(x),f++,w):x===41?(e.consume(x),f--,w):x===null||x===32||x===40||Di(x)?n(x):(e.consume(x),x===92?S:w)}function S(x){return x===40||x===41||x===92?(e.consume(x),w):w(x)}}function $f(e,t,n,r,i,s){const a=this;let o=0,l;return u;function u(h){return e.enter(r),e.enter(i),e.consume(h),e.exit(i),e.enter(s),f}function f(h){return o>999||h===null||h===91||h===93&&!l||h===94&&!o&&"_hiddenFootnoteSupport"in a.parser.constructs?n(h):h===93?(e.exit(s),e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):me(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),f):(e.enter("chunkString",{contentType:"string"}),d(h))}function d(h){return h===null||h===91||h===93||me(h)||o++>999?(e.exit("chunkString"),f(h)):(e.consume(h),l||(l=!Ce(h)),h===92?p:d)}function p(h){return h===91||h===92||h===93?(e.consume(h),o++,d):d(h)}}function Ff(e,t,n,r,i,s){let a;return o;function o(p){return p===34||p===39||p===40?(e.enter(r),e.enter(i),e.consume(p),e.exit(i),a=p===40?41:p,l):n(p)}function l(p){return p===a?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(s),u(p))}function u(p){return p===a?(e.exit(s),l(a)):p===null?n(p):me(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),ze(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===a||p===null||me(p)?(e.exit("chunkString"),u(p)):(e.consume(p),p===92?d:f)}function d(p){return p===a||p===92?(e.consume(p),f):f(p)}}function zr(e,t){let n;return r;function r(i){return me(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Ce(i)?ze(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const vv={name:"definition",tokenize:kv},wv={partial:!0,tokenize:Sv};function kv(e,t,n){const r=this;let i;return s;function s(h){return e.enter("definition"),a(h)}function a(h){return $f.call(r,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function o(h){return i=Mt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),l):n(h)}function l(h){return Re(h)?zr(e,u)(h):u(h)}function u(h){return Mf(e,f,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function f(h){return e.attempt(wv,d,d)(h)}function d(h){return Ce(h)?ze(e,p,"whitespace")(h):p(h)}function p(h){return h===null||me(h)?(e.exit("definition"),r.parser.defined.push(i),t(h)):n(h)}}function Sv(e,t,n){return r;function r(o){return Re(o)?zr(e,i)(o):n(o)}function i(o){return Ff(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function s(o){return Ce(o)?ze(e,a,"whitespace")(o):a(o)}function a(o){return o===null||me(o)?t(o):n(o)}}const _v={name:"hardBreakEscape",tokenize:jv};function jv(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return me(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const Cv={name:"headingAtx",resolve:Nv,tokenize:Ev};function Nv(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"},St(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function Ev(e,t,n){let r=0;return i;function i(f){return e.enter("atxHeading"),s(f)}function s(f){return e.enter("atxHeadingSequence"),a(f)}function a(f){return f===35&&r++<6?(e.consume(f),a):f===null||Re(f)?(e.exit("atxHeadingSequence"),o(f)):n(f)}function o(f){return f===35?(e.enter("atxHeadingSequence"),l(f)):f===null||me(f)?(e.exit("atxHeading"),t(f)):Ce(f)?ze(e,o,"whitespace")(f):(e.enter("atxHeadingText"),u(f))}function l(f){return f===35?(e.consume(f),l):(e.exit("atxHeadingSequence"),o(f))}function u(f){return f===null||f===35||Re(f)?(e.exit("atxHeadingText"),o(f)):(e.consume(f),u)}}const Iv=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Rl=["pre","script","style","textarea"],zv={concrete:!0,name:"htmlFlow",resolveTo:Pv,tokenize:Ov},Tv={partial:!0,tokenize:Rv},Av={partial:!0,tokenize:Dv};function Pv(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 Ov(e,t,n){const r=this;let i,s,a,o,l;return u;function u(v){return f(v)}function f(v){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(v),d}function d(v){return v===33?(e.consume(v),p):v===47?(e.consume(v),s=!0,w):v===63?(e.consume(v),i=3,r.interrupt?t:b):dt(v)?(e.consume(v),a=String.fromCharCode(v),S):n(v)}function p(v){return v===45?(e.consume(v),i=2,h):v===91?(e.consume(v),i=5,o=0,m):dt(v)?(e.consume(v),i=4,r.interrupt?t:b):n(v)}function h(v){return v===45?(e.consume(v),r.interrupt?t:b):n(v)}function m(v){const X="CDATA[";return v===X.charCodeAt(o++)?(e.consume(v),o===X.length?r.interrupt?t:R:m):n(v)}function w(v){return dt(v)?(e.consume(v),a=String.fromCharCode(v),S):n(v)}function S(v){if(v===null||v===47||v===62||Re(v)){const X=v===47,ae=a.toLowerCase();return!X&&!s&&Rl.includes(ae)?(i=1,r.interrupt?t(v):R(v)):Iv.includes(a.toLowerCase())?(i=6,X?(e.consume(v),x):r.interrupt?t(v):R(v)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(v):s?_(v):g(v))}return v===45||st(v)?(e.consume(v),a+=String.fromCharCode(v),S):n(v)}function x(v){return v===62?(e.consume(v),r.interrupt?t:R):n(v)}function _(v){return Ce(v)?(e.consume(v),_):C(v)}function g(v){return v===47?(e.consume(v),C):v===58||v===95||dt(v)?(e.consume(v),T):Ce(v)?(e.consume(v),g):C(v)}function T(v){return v===45||v===46||v===58||v===95||st(v)?(e.consume(v),T):E(v)}function E(v){return v===61?(e.consume(v),k):Ce(v)?(e.consume(v),E):g(v)}function k(v){return v===null||v===60||v===61||v===62||v===96?n(v):v===34||v===39?(e.consume(v),l=v,N):Ce(v)?(e.consume(v),k):M(v)}function N(v){return v===l?(e.consume(v),l=null,Y):v===null||me(v)?n(v):(e.consume(v),N)}function M(v){return v===null||v===34||v===39||v===47||v===60||v===61||v===62||v===96||Re(v)?E(v):(e.consume(v),M)}function Y(v){return v===47||v===62||Ce(v)?g(v):n(v)}function C(v){return v===62?(e.consume(v),B):n(v)}function B(v){return v===null||me(v)?R(v):Ce(v)?(e.consume(v),B):n(v)}function R(v){return v===45&&i===2?(e.consume(v),A):v===60&&i===1?(e.consume(v),J):v===62&&i===4?(e.consume(v),ce):v===63&&i===3?(e.consume(v),b):v===93&&i===5?(e.consume(v),q):me(v)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Tv,oe,U)(v)):v===null||me(v)?(e.exit("htmlFlowData"),U(v)):(e.consume(v),R)}function U(v){return e.check(Av,L,oe)(v)}function L(v){return e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),P}function P(v){return v===null||me(v)?U(v):(e.enter("htmlFlowData"),R(v))}function A(v){return v===45?(e.consume(v),b):R(v)}function J(v){return v===47?(e.consume(v),a="",O):R(v)}function O(v){if(v===62){const X=a.toLowerCase();return Rl.includes(X)?(e.consume(v),ce):R(v)}return dt(v)&&a.length<8?(e.consume(v),a+=String.fromCharCode(v),O):R(v)}function q(v){return v===93?(e.consume(v),b):R(v)}function b(v){return v===62?(e.consume(v),ce):v===45&&i===2?(e.consume(v),b):R(v)}function ce(v){return v===null||me(v)?(e.exit("htmlFlowData"),oe(v)):(e.consume(v),ce)}function oe(v){return e.exit("htmlFlow"),t(v)}}function Dv(e,t,n){const r=this;return i;function i(a){return me(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):n(a)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function Rv(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Kr,t,n)}}const Mv={name:"htmlText",tokenize:$v};function $v(e,t,n){const r=this;let i,s,a;return o;function o(b){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(b),l}function l(b){return b===33?(e.consume(b),u):b===47?(e.consume(b),E):b===63?(e.consume(b),g):dt(b)?(e.consume(b),M):n(b)}function u(b){return b===45?(e.consume(b),f):b===91?(e.consume(b),s=0,m):dt(b)?(e.consume(b),_):n(b)}function f(b){return b===45?(e.consume(b),h):n(b)}function d(b){return b===null?n(b):b===45?(e.consume(b),p):me(b)?(a=d,J(b)):(e.consume(b),d)}function p(b){return b===45?(e.consume(b),h):d(b)}function h(b){return b===62?A(b):b===45?p(b):d(b)}function m(b){const ce="CDATA[";return b===ce.charCodeAt(s++)?(e.consume(b),s===ce.length?w:m):n(b)}function w(b){return b===null?n(b):b===93?(e.consume(b),S):me(b)?(a=w,J(b)):(e.consume(b),w)}function S(b){return b===93?(e.consume(b),x):w(b)}function x(b){return b===62?A(b):b===93?(e.consume(b),x):w(b)}function _(b){return b===null||b===62?A(b):me(b)?(a=_,J(b)):(e.consume(b),_)}function g(b){return b===null?n(b):b===63?(e.consume(b),T):me(b)?(a=g,J(b)):(e.consume(b),g)}function T(b){return b===62?A(b):g(b)}function E(b){return dt(b)?(e.consume(b),k):n(b)}function k(b){return b===45||st(b)?(e.consume(b),k):N(b)}function N(b){return me(b)?(a=N,J(b)):Ce(b)?(e.consume(b),N):A(b)}function M(b){return b===45||st(b)?(e.consume(b),M):b===47||b===62||Re(b)?Y(b):n(b)}function Y(b){return b===47?(e.consume(b),A):b===58||b===95||dt(b)?(e.consume(b),C):me(b)?(a=Y,J(b)):Ce(b)?(e.consume(b),Y):A(b)}function C(b){return b===45||b===46||b===58||b===95||st(b)?(e.consume(b),C):B(b)}function B(b){return b===61?(e.consume(b),R):me(b)?(a=B,J(b)):Ce(b)?(e.consume(b),B):Y(b)}function R(b){return b===null||b===60||b===61||b===62||b===96?n(b):b===34||b===39?(e.consume(b),i=b,U):me(b)?(a=R,J(b)):Ce(b)?(e.consume(b),R):(e.consume(b),L)}function U(b){return b===i?(e.consume(b),i=void 0,P):b===null?n(b):me(b)?(a=U,J(b)):(e.consume(b),U)}function L(b){return b===null||b===34||b===39||b===60||b===61||b===96?n(b):b===47||b===62||Re(b)?Y(b):(e.consume(b),L)}function P(b){return b===47||b===62||Re(b)?Y(b):n(b)}function A(b){return b===62?(e.consume(b),e.exit("htmlTextData"),e.exit("htmlText"),t):n(b)}function J(b){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),O}function O(b){return Ce(b)?ze(e,q,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(b):q(b)}function q(b){return e.enter("htmlTextData"),a(b)}}const xo={name:"labelEnd",resolveAll:Bv,resolveTo:Vv,tokenize:Uv},Fv={tokenize:Jv},Lv={tokenize:Hv},Zv={tokenize:qv};function Bv(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&&St(e,0,e.length,n),e}function Vv(e,t){let n=e.length,r=0,i,s,a,o;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(a=n);const l={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[s][1].start},end:{...e[a][1].end}},f={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[a-2][1].start}};return o=[["enter",l,t],["enter",u,t]],o=Nt(o,e.slice(s+1,s+r+3)),o=Nt(o,[["enter",f,t]]),o=Nt(o,hs(t.parser.constructs.insideSpan.null,e.slice(s+r+4,a-3),t)),o=Nt(o,[["exit",f,t],e[a-2],e[a-1],["exit",u,t]]),o=Nt(o,e.slice(a+1)),o=Nt(o,[["exit",l,t]]),St(e,s,e.length,o),e}function Uv(e,t,n){const r=this;let i=r.events.length,s,a;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return o;function o(p){return s?s._inactive?d(p):(a=r.parser.defined.includes(Mt(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),l):n(p)}function l(p){return p===40?e.attempt(Fv,f,a?f:d)(p):p===91?e.attempt(Lv,f,a?u:d)(p):a?f(p):d(p)}function u(p){return e.attempt(Zv,f,d)(p)}function f(p){return t(p)}function d(p){return s._balanced=!0,n(p)}}function Jv(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),i}function i(d){return Re(d)?zr(e,s)(d):s(d)}function s(d){return d===41?f(d):Mf(e,a,o,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function a(d){return Re(d)?zr(e,l)(d):f(d)}function o(d){return n(d)}function l(d){return d===34||d===39||d===40?Ff(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):f(d)}function u(d){return Re(d)?zr(e,f)(d):f(d)}function f(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}function Hv(e,t,n){const r=this;return i;function i(o){return $f.call(r,e,s,a,"reference","referenceMarker","referenceString")(o)}function s(o){return r.parser.defined.includes(Mt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(o):n(o)}function a(o){return n(o)}}function qv(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 Wv={name:"labelStartImage",resolveAll:xo.resolveAll,tokenize:Gv};function Gv(e,t,n){const r=this;return i;function i(o){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(o),e.exit("labelImageMarker"),s}function s(o){return o===91?(e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelImage"),a):n(o)}function a(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const Kv={name:"labelStartLink",resolveAll:xo.resolveAll,tokenize:Yv};function Yv(e,t,n){const r=this;return i;function i(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),s}function s(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const Ls={name:"lineEnding",tokenize:Xv};function Xv(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),ze(e,t,"linePrefix")}}const bi={name:"thematicBreak",tokenize:Qv};function Qv(e,t,n){let r=0,i;return s;function s(u){return e.enter("thematicBreak"),a(u)}function a(u){return i=u,o(u)}function o(u){return u===i?(e.enter("thematicBreakSequence"),l(u)):r>=3&&(u===null||me(u))?(e.exit("thematicBreak"),t(u)):n(u)}function l(u){return u===i?(e.consume(u),r++,l):(e.exit("thematicBreakSequence"),Ce(u)?ze(e,o,"whitespace")(u):o(u))}}const ht={continuation:{tokenize:rw},exit:sw,name:"list",tokenize:nw},ew={partial:!0,tokenize:aw},tw={partial:!0,tokenize:iw};function nw(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return o;function o(h){const m=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:Sa(h)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),h===42||h===45?e.check(bi,n,u)(h):u(h);if(!r.interrupt||h===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(h)}return n(h)}function l(h){return Sa(h)&&++a<10?(e.consume(h),l):(!r.interrupt||a<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(e.exit("listItemValue"),u(h)):n(h)}function u(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,e.check(Kr,r.interrupt?n:f,e.attempt(ew,p,d))}function f(h){return r.containerState.initialBlankLine=!0,s++,p(h)}function d(h){return Ce(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 rw(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Kr,i,s);function i(o){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,ze(e,t,"listItemIndent",r.containerState.size+1)(o)}function s(o){return r.containerState.furtherBlankLines||!Ce(o)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(o)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(tw,t,a)(o))}function a(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,ze(e,e.attempt(ht,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}function iw(e,t,n){const r=this;return ze(e,i,"listItemIndent",r.containerState.size+1);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(s):n(s)}}function sw(e){e.exit(this.containerState.type)}function aw(e,t,n){const r=this;return ze(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const a=r.events[r.events.length-1];return!Ce(s)&&a&&a[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const Ml={name:"setextUnderline",resolveTo:ow,tokenize:lw};function ow(e,t){let n=e.length,r,i,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",a,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function lw(e,t,n){const r=this;let i;return s;function s(u){let f=r.events.length,d;for(;f--;)if(r.events[f][1].type!=="lineEnding"&&r.events[f][1].type!=="linePrefix"&&r.events[f][1].type!=="content"){d=r.events[f][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),i=u,a(u)):n(u)}function a(u){return e.enter("setextHeadingLineSequence"),o(u)}function o(u){return u===i?(e.consume(u),o):(e.exit("setextHeadingLineSequence"),Ce(u)?ze(e,l,"lineSuffix")(u):l(u))}function l(u){return u===null||me(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const uw={tokenize:cw};function cw(e){const t=this,n=e.attempt(Kr,r,e.attempt(this.parser.constructs.flowInitial,i,ze(e,e.attempt(this.parser.constructs.flow,i,e.attempt(mv,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 dw={resolveAll:Zf()},fw=Lf("string"),pw=Lf("text");function Lf(e){return{resolveAll:Zf(e==="text"?hw:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,a,o);return a;function a(f){return u(f)?s(f):o(f)}function o(f){if(f===null){n.consume(f);return}return n.enter("data"),n.consume(f),l}function l(f){return u(f)?(n.exit("data"),s(f)):(n.consume(f),l)}function u(f){if(f===null)return!0;const d=i[f];let p=-1;if(d)for(;++p<d.length;){const h=d[p];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function Zf(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 hw(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,a=-1,o=0,l;for(;s--;){const u=i[s];if(typeof u=="string"){for(a=u.length;u.charCodeAt(a-1)===32;)o++,a--;if(a)break;a=-1}else if(u===-2)l=!0,o++;else if(u!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(o=0),o){const u={type:n===e.length||l||o<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?a:r.start._bufferIndex+a,_index:r.start._index+s,line:r.end.line,column:r.end.column-o,offset:r.end.offset-o},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const mw={42:ht,43:ht,45:ht,48:ht,49:ht,50:ht,51:ht,52:ht,53:ht,54:ht,55:ht,56:ht,57:ht,62:Pf},gw={91:vv},xw={[-2]:Fs,[-1]:Fs,32:Fs},yw={35:Cv,42:bi,45:[Ml,bi],60:zv,61:Ml,95:bi,96:Dl,126:Dl},bw={38:Df,92:Of},vw={[-5]:Ls,[-4]:Ls,[-3]:Ls,33:Wv,38:Df,42:_a,60:[Kb,Mv],91:Kv,92:[_v,Of],93:xo,95:_a,96:uv},ww={null:[_a,dw]},kw={null:[42,95]},Sw={null:[]},_w=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:kw,contentInitial:gw,disable:Sw,document:mw,flow:yw,flowInitial:xw,insideSpan:ww,string:bw,text:vw},Symbol.toStringTag,{value:"Module"}));function jw(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let a=[],o=[];const l={attempt:N(E),check:N(k),consume:_,enter:g,exit:T,interrupt:N(k,{interrupt:!0})},u={code:null,containerState:{},defineSkip:w,events:[],now:m,parser:e,previous:null,sliceSerialize:p,sliceStream:h,write:d};let f=t.tokenize.call(u,l);return t.resolveAll&&s.push(t),u;function d(B){return a=Nt(a,B),S(),a[a.length-1]!==null?[]:(M(t,0),u.events=hs(s,u.events,u),u.events)}function p(B,R){return Nw(h(B),R)}function h(B){return Cw(a,B)}function m(){const{_bufferIndex:B,_index:R,line:U,column:L,offset:P}=r;return{_bufferIndex:B,_index:R,line:U,column:L,offset:P}}function w(B){i[B.line]=B.column,C()}function S(){let B;for(;r._index<a.length;){const R=a[r._index];if(typeof R=="string")for(B=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===B&&r._bufferIndex<R.length;)x(R.charCodeAt(r._bufferIndex));else x(R)}}function x(B){f=f(B)}function _(B){me(B)?(r.line++,r.column=1,r.offset+=B===-3?2:1,C()):B!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=B}function g(B,R){const U=R||{};return U.type=B,U.start=m(),u.events.push(["enter",U,u]),o.push(U),U}function T(B){const R=o.pop();return R.end=m(),u.events.push(["exit",R,u]),R}function E(B,R){M(B,R.from)}function k(B,R){R.restore()}function N(B,R){return U;function U(L,P,A){let J,O,q,b;return Array.isArray(L)?oe(L):"tokenize"in L?oe([L]):ce(L);function ce(ne){return I;function I($){const W=$!==null&&ne[$],le=$!==null&&ne.null,K=[...Array.isArray(W)?W:W?[W]:[],...Array.isArray(le)?le:le?[le]:[]];return oe(K)($)}}function oe(ne){return J=ne,O=0,ne.length===0?A:v(ne[O])}function v(ne){return I;function I($){return b=Y(),q=ne,ne.partial||(u.currentConstruct=ne),ne.name&&u.parser.constructs.disable.null.includes(ne.name)?ae():ne.tokenize.call(R?Object.assign(Object.create(u),R):u,l,X,ae)($)}}function X(ne){return B(q,b),P}function ae(ne){return b.restore(),++O<J.length?v(J[O]):A}}}function M(B,R){B.resolveAll&&!s.includes(B)&&s.push(B),B.resolve&&St(u.events,R,u.events.length-R,B.resolve(u.events.slice(R),u)),B.resolveTo&&(u.events=B.resolveTo(u.events,u))}function Y(){const B=m(),R=u.previous,U=u.currentConstruct,L=u.events.length,P=Array.from(o);return{from:L,restore:A};function A(){r=B,u.previous=R,u.currentConstruct=U,u.events.length=L,o=P,C()}}function C(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Cw(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let a;if(n===i)a=[e[n].slice(r,s)];else{if(a=e.slice(n,i),r>-1){const o=a[0];typeof o=="string"?a[0]=o.slice(r):a.shift()}s>0&&a.push(e[i].slice(0,s))}return a}function Nw(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let a;if(typeof s=="string")a=s;else switch(s){case-5:{a="\r";break}case-4:{a=`
|
|
4
|
+
`;break}case-3:{a=`\r
|
|
5
|
+
`;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&i)continue;a=" ";break}default:a=String.fromCharCode(s)}i=s===-2,r.push(a)}return r.join("")}function Ew(e){const r={constructs:Tf([_w,...(e||{}).extensions||[]]),content:i(Vb),defined:[],document:i(Jb),flow:i(uw),lazy:{},string:i(fw),text:i(pw)};return r;function i(s){return a;function a(o){return jw(r,s,o)}}}function Iw(e){for(;!Rf(e););return e}const $l=/[\0\t\n\r]/g;function zw(){let e=1,t="",n=!0,r;return i;function i(s,a,o){const l=[];let u,f,d,p,h;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(a||void 0).decode(s)),d=0,t="",n&&(s.charCodeAt(0)===65279&&d++,n=void 0);d<s.length;){if($l.lastIndex=d,u=$l.exec(s),p=u&&u.index!==void 0?u.index:s.length,h=s.charCodeAt(p),!u){t=s.slice(d);break}if(h===10&&d===p&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),d<p&&(l.push(s.slice(d,p)),e+=p-d),h){case 0:{l.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,l.push(-2);e++<f;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}d=p+1}return o&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const Tw=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Aw(e){return e.replace(Tw,Pw)}function Pw(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return Af(n.slice(s?2:1),s?16:10)}return go(n)||e}const Bf={}.hasOwnProperty;function Ow(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),Dw(n)(Iw(Ew(n).document().write(zw()(e,t,!0))))}function Dw(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(z),autolinkProtocol:Y,autolinkEmail:Y,atxHeading:s(Ue),blockQuote:s(le),characterEscape:Y,characterReference:Y,codeFenced:s(K),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:s(K,a),codeText:s(ve,a),codeTextData:Y,data:Y,codeFlowValue:Y,definition:s(de),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:s(xe),hardBreakEscape:s(rt),hardBreakTrailing:s(rt),htmlFlow:s(Ge,a),htmlFlowData:Y,htmlText:s(Ge,a),htmlTextData:Y,image:s(j),label:a,link:s(z),listItem:s(re),listItemValue:p,listOrdered:s(Z,d),listUnordered:s(Z),paragraph:s(te),reference:v,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:s(Ue),strong:s(ee),thematicBreak:s(be)},exit:{atxHeading:l(),atxHeadingSequence:E,autolink:l(),autolinkEmail:W,autolinkProtocol:$,blockQuote:l(),characterEscapeValue:C,characterReferenceMarkerHexadecimal:ae,characterReferenceMarkerNumeric:ae,characterReferenceValue:ne,characterReference:I,codeFenced:l(S),codeFencedFence:w,codeFencedFenceInfo:h,codeFencedFenceMeta:m,codeFlowValue:C,codeIndented:l(x),codeText:l(P),codeTextData:C,data:C,definition:l(),definitionDestinationString:T,definitionLabelString:_,definitionTitleString:g,emphasis:l(),hardBreakEscape:l(R),hardBreakTrailing:l(R),htmlFlow:l(U),htmlFlowData:C,htmlText:l(L),htmlTextData:C,image:l(J),label:q,labelText:O,lineEnding:B,link:l(A),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:X,resourceDestinationString:b,resourceTitleString:ce,resource:oe,setextHeading:l(M),setextHeadingLineSequence:N,setextHeadingText:k,strong:l(),thematicBreak:l()}};Vf(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(F){let G={type:"root",children:[]};const pe={stack:[G],tokenStack:[],config:t,enter:o,exit:u,buffer:a,resume:f,data:n},ke=[];let D=-1;for(;++D<F.length;)if(F[D][1].type==="listOrdered"||F[D][1].type==="listUnordered")if(F[D][0]==="enter")ke.push(D);else{const he=ke.pop();D=i(F,he,D)}for(D=-1;++D<F.length;){const he=t[F[D][0]];Bf.call(he,F[D][1].type)&&he[F[D][1].type].call(Object.assign({sliceSerialize:F[D][2].sliceSerialize},pe),F[D][1])}if(pe.tokenStack.length>0){const he=pe.tokenStack[pe.tokenStack.length-1];(he[1]||Fl).call(pe,void 0,he[0])}for(G.position={start:Qt(F.length>0?F[0][1].start:{line:1,column:1,offset:0}),end:Qt(F.length>0?F[F.length-2][1].end:{line:1,column:1,offset:0})},D=-1;++D<t.transforms.length;)G=t.transforms[D](G)||G;return G}function i(F,G,pe){let ke=G-1,D=-1,he=!1,Ne,Me,tt,Ke;for(;++ke<=pe;){const it=F[ke];switch(it[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{it[0]==="enter"?D++:D--,Ke=void 0;break}case"lineEndingBlank":{it[0]==="enter"&&(Ne&&!Ke&&!D&&!tt&&(tt=ke),Ke=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Ke=void 0}if(!D&&it[0]==="enter"&&it[1].type==="listItemPrefix"||D===-1&&it[0]==="exit"&&(it[1].type==="listUnordered"||it[1].type==="listOrdered")){if(Ne){let Xt=ke;for(Me=void 0;Xt--;){const Jt=F[Xt];if(Jt[1].type==="lineEnding"||Jt[1].type==="lineEndingBlank"){if(Jt[0]==="exit")continue;Me&&(F[Me][1].type="lineEndingBlank",he=!0),Jt[1].type="lineEnding",Me=Xt}else if(!(Jt[1].type==="linePrefix"||Jt[1].type==="blockQuotePrefix"||Jt[1].type==="blockQuotePrefixWhitespace"||Jt[1].type==="blockQuoteMarker"||Jt[1].type==="listItemIndent"))break}tt&&(!Me||tt<Me)&&(Ne._spread=!0),Ne.end=Object.assign({},Me?F[Me][1].start:it[1].end),F.splice(Me||ke,0,["exit",Ne,it[2]]),ke++,pe++}if(it[1].type==="listItemPrefix"){const Xt={type:"listItem",_spread:!1,start:Object.assign({},it[1].start),end:void 0};Ne=Xt,F.splice(ke,0,["enter",Xt,it[2]]),ke++,pe++,tt=void 0,Ke=!0}}}return F[G][1]._spread=he,pe}function s(F,G){return pe;function pe(ke){o.call(this,F(ke),ke),G&&G.call(this,ke)}}function a(){this.stack.push({type:"fragment",children:[]})}function o(F,G,pe){this.stack[this.stack.length-1].children.push(F),this.stack.push(F),this.tokenStack.push([G,pe||void 0]),F.position={start:Qt(G.start),end:void 0}}function l(F){return G;function G(pe){F&&F.call(this,pe),u.call(this,pe)}}function u(F,G){const pe=this.stack.pop(),ke=this.tokenStack.pop();if(ke)ke[0].type!==F.type&&(G?G.call(this,F,ke[0]):(ke[1]||Fl).call(this,F,ke[0]));else throw new Error("Cannot close `"+F.type+"` ("+Ir({start:F.start,end:F.end})+"): it’s not open");pe.position.end=Qt(F.end)}function f(){return mo(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function p(F){if(this.data.expectingFirstListItemValue){const G=this.stack[this.stack.length-2];G.start=Number.parseInt(this.sliceSerialize(F),10),this.data.expectingFirstListItemValue=void 0}}function h(){const F=this.resume(),G=this.stack[this.stack.length-1];G.lang=F}function m(){const F=this.resume(),G=this.stack[this.stack.length-1];G.meta=F}function w(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const F=this.resume(),G=this.stack[this.stack.length-1];G.value=F.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function x(){const F=this.resume(),G=this.stack[this.stack.length-1];G.value=F.replace(/(\r?\n|\r)$/g,"")}function _(F){const G=this.resume(),pe=this.stack[this.stack.length-1];pe.label=G,pe.identifier=Mt(this.sliceSerialize(F)).toLowerCase()}function g(){const F=this.resume(),G=this.stack[this.stack.length-1];G.title=F}function T(){const F=this.resume(),G=this.stack[this.stack.length-1];G.url=F}function E(F){const G=this.stack[this.stack.length-1];if(!G.depth){const pe=this.sliceSerialize(F).length;G.depth=pe}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function N(F){const G=this.stack[this.stack.length-1];G.depth=this.sliceSerialize(F).codePointAt(0)===61?1:2}function M(){this.data.setextHeadingSlurpLineEnding=void 0}function Y(F){const pe=this.stack[this.stack.length-1].children;let ke=pe[pe.length-1];(!ke||ke.type!=="text")&&(ke=fe(),ke.position={start:Qt(F.start),end:void 0},pe.push(ke)),this.stack.push(ke)}function C(F){const G=this.stack.pop();G.value+=this.sliceSerialize(F),G.position.end=Qt(F.end)}function B(F){const G=this.stack[this.stack.length-1];if(this.data.atHardBreak){const pe=G.children[G.children.length-1];pe.position.end=Qt(F.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(G.type)&&(Y.call(this,F),C.call(this,F))}function R(){this.data.atHardBreak=!0}function U(){const F=this.resume(),G=this.stack[this.stack.length-1];G.value=F}function L(){const F=this.resume(),G=this.stack[this.stack.length-1];G.value=F}function P(){const F=this.resume(),G=this.stack[this.stack.length-1];G.value=F}function A(){const F=this.stack[this.stack.length-1];if(this.data.inReference){const G=this.data.referenceType||"shortcut";F.type+="Reference",F.referenceType=G,delete F.url,delete F.title}else delete F.identifier,delete F.label;this.data.referenceType=void 0}function J(){const F=this.stack[this.stack.length-1];if(this.data.inReference){const G=this.data.referenceType||"shortcut";F.type+="Reference",F.referenceType=G,delete F.url,delete F.title}else delete F.identifier,delete F.label;this.data.referenceType=void 0}function O(F){const G=this.sliceSerialize(F),pe=this.stack[this.stack.length-2];pe.label=Aw(G),pe.identifier=Mt(G).toLowerCase()}function q(){const F=this.stack[this.stack.length-1],G=this.resume(),pe=this.stack[this.stack.length-1];if(this.data.inReference=!0,pe.type==="link"){const ke=F.children;pe.children=ke}else pe.alt=G}function b(){const F=this.resume(),G=this.stack[this.stack.length-1];G.url=F}function ce(){const F=this.resume(),G=this.stack[this.stack.length-1];G.title=F}function oe(){this.data.inReference=void 0}function v(){this.data.referenceType="collapsed"}function X(F){const G=this.resume(),pe=this.stack[this.stack.length-1];pe.label=G,pe.identifier=Mt(this.sliceSerialize(F)).toLowerCase(),this.data.referenceType="full"}function ae(F){this.data.characterReferenceType=F.type}function ne(F){const G=this.sliceSerialize(F),pe=this.data.characterReferenceType;let ke;pe?(ke=Af(G,pe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ke=go(G);const D=this.stack[this.stack.length-1];D.value+=ke}function I(F){const G=this.stack.pop();G.position.end=Qt(F.end)}function $(F){C.call(this,F);const G=this.stack[this.stack.length-1];G.url=this.sliceSerialize(F)}function W(F){C.call(this,F);const G=this.stack[this.stack.length-1];G.url="mailto:"+this.sliceSerialize(F)}function le(){return{type:"blockquote",children:[]}}function K(){return{type:"code",lang:null,meta:null,value:""}}function ve(){return{type:"inlineCode",value:""}}function de(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function xe(){return{type:"emphasis",children:[]}}function Ue(){return{type:"heading",depth:0,children:[]}}function rt(){return{type:"break"}}function Ge(){return{type:"html",value:""}}function j(){return{type:"image",title:null,url:"",alt:null}}function z(){return{type:"link",title:null,url:"",children:[]}}function Z(F){return{type:"list",ordered:F.type==="listOrdered",start:null,spread:F._spread,children:[]}}function re(F){return{type:"listItem",spread:F._spread,checked:null,children:[]}}function te(){return{type:"paragraph",children:[]}}function ee(){return{type:"strong",children:[]}}function fe(){return{type:"text",value:""}}function be(){return{type:"thematicBreak"}}}function Qt(e){return{line:e.line,column:e.column,offset:e.offset}}function Vf(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Vf(e,r):Rw(e,r)}}function Rw(e,t){let n;for(n in t)if(Bf.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function Fl(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Ir({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Ir({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Ir({start:t.start,end:t.end})+") is still open")}function Mw(e){const t=this;t.parser=n;function n(r){return Ow(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function $w(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 Fw(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
6
|
+
`}]}function Lw(e,t){const n=t.value?t.value+`
|
|
7
|
+
`:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let s={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(s.data={meta:t.meta}),e.patch(t,s),s=e.applyData(t,s),s={type:"element",tagName:"pre",properties:{},children:[s]},e.patch(t,s),s}function Zw(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Bw(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Vw(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=sr(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let a,o=e.footnoteCounts.get(r);o===void 0?(o=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=s+1,o+=1,e.footnoteCounts.set(r,o);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(o>1?"-"+o:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,l);const u={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,u),e.applyData(t,u)}function Uw(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 Jw(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Uf(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),s=i[0];s&&s.type==="text"?s.value="["+s.value:i.unshift({type:"text",value:"["});const a=i[i.length-1];return a&&a.type==="text"?a.value+=r:i.push({type:"text",value:r}),i}function Hw(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Uf(e,t);const i={src:sr(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 qw(e,t){const n={src:sr(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 Ww(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 Gw(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Uf(e,t);const i={href:sr(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 Kw(e,t){const n={href:sr(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 Yw(e,t,n){const r=e.all(t),i=n?Xw(n):Jf(t),s={},a=[];if(typeof t.checked=="boolean"){const f=r[0];let d;f&&f.type==="element"&&f.tagName==="p"?d=f:(d={type:"element",tagName:"p",properties:{},children:[]},r.unshift(d)),d.children.length>0&&d.children.unshift({type:"text",value:" "}),d.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let o=-1;for(;++o<r.length;){const f=r[o];(i||o!==0||f.type!=="element"||f.tagName!=="p")&&a.push({type:"text",value:`
|
|
8
|
+
`}),f.type==="element"&&f.tagName==="p"&&!i?a.push(...f.children):a.push(f)}const l=r[r.length-1];l&&(i||l.type!=="element"||l.tagName!=="p")&&a.push({type:"text",value:`
|
|
9
|
+
`});const u={type:"element",tagName:"li",properties:s,children:a};return e.patch(t,u),e.applyData(t,u)}function Xw(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=Jf(n[r])}return t}function Jf(e){const t=e.spread;return t??e.children.length>1}function Qw(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const a=r[i];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const s={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,s),e.applyData(t,s)}function e0(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function t0(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function n0(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function r0(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const a={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],a),i.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},o=co(t.children[1]),l=_f(t.children[t.children.length-1]);o&&l&&(a.position={start:o,end:l}),i.push(a)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,s),e.applyData(t,s)}function i0(e,t,n){const r=n?n.children:void 0,s=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,o=a?a.length:t.children.length;let l=-1;const u=[];for(;++l<o;){const d=t.children[l],p={},h=a?a[l]:void 0;h&&(p.align=h);let m={type:"element",tagName:s,properties:p,children:[]};d&&(m.children=e.all(d),e.patch(d,m),m=e.applyData(d,m)),u.push(m)}const f={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,f),e.applyData(t,f)}function s0(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const Ll=9,Zl=32;function a0(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const s=[];for(;r;)s.push(Bl(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return s.push(Bl(t.slice(i),i>0,!1)),s.join("")}function Bl(e,t,n){let r=0,i=e.length;if(t){let s=e.codePointAt(r);for(;s===Ll||s===Zl;)r++,s=e.codePointAt(r)}if(n){let s=e.codePointAt(i-1);for(;s===Ll||s===Zl;)i--,s=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function o0(e,t){const n={type:"text",value:a0(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function l0(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const u0={blockquote:$w,break:Fw,code:Lw,delete:Zw,emphasis:Bw,footnoteReference:Vw,heading:Uw,html:Jw,imageReference:Hw,image:qw,inlineCode:Ww,linkReference:Gw,link:Kw,listItem:Yw,list:Qw,paragraph:e0,root:t0,strong:n0,table:r0,tableCell:s0,tableRow:i0,text:o0,thematicBreak:l0,toml:si,yaml:si,definition:si,footnoteDefinition:si};function si(){}const Hf=-1,ms=0,Tr=1,Ri=2,yo=3,bo=4,vo=5,wo=6,qf=7,Wf=8,Vl=typeof self=="object"?self:globalThis,c0=(e,t)=>{const n=(i,s)=>(e.set(s,i),i),r=i=>{if(e.has(i))return e.get(i);const[s,a]=t[i];switch(s){case ms:case Hf:return n(a,i);case Tr:{const o=n([],i);for(const l of a)o.push(r(l));return o}case Ri:{const o=n({},i);for(const[l,u]of a)o[r(l)]=r(u);return o}case yo:return n(new Date(a),i);case bo:{const{source:o,flags:l}=a;return n(new RegExp(o,l),i)}case vo:{const o=n(new Map,i);for(const[l,u]of a)o.set(r(l),r(u));return o}case wo:{const o=n(new Set,i);for(const l of a)o.add(r(l));return o}case qf:{const{name:o,message:l}=a;return n(new Vl[o](l),i)}case Wf:return n(BigInt(a),i);case"BigInt":return n(Object(BigInt(a)),i);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:o}=new Uint8Array(a);return n(new DataView(o),a)}}return n(new Vl[s](a),i)};return r},Ul=e=>c0(new Map,e)(0),Rn="",{toString:d0}={},{keys:f0}=Object,gr=e=>{const t=typeof e;if(t!=="object"||!e)return[ms,t];const n=d0.call(e).slice(8,-1);switch(n){case"Array":return[Tr,Rn];case"Object":return[Ri,Rn];case"Date":return[yo,Rn];case"RegExp":return[bo,Rn];case"Map":return[vo,Rn];case"Set":return[wo,Rn];case"DataView":return[Tr,n]}return n.includes("Array")?[Tr,n]:n.includes("Error")?[qf,n]:[Ri,n]},ai=([e,t])=>e===ms&&(t==="function"||t==="symbol"),p0=(e,t,n,r)=>{const i=(a,o)=>{const l=r.push(a)-1;return n.set(o,l),l},s=a=>{if(n.has(a))return n.get(a);let[o,l]=gr(a);switch(o){case ms:{let f=a;switch(l){case"bigint":o=Wf,f=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+l);f=null;break;case"undefined":return i([Hf],a)}return i([o,f],a)}case Tr:{if(l){let p=a;return l==="DataView"?p=new Uint8Array(a.buffer):l==="ArrayBuffer"&&(p=new Uint8Array(a)),i([l,[...p]],a)}const f=[],d=i([o,f],a);for(const p of a)f.push(s(p));return d}case Ri:{if(l)switch(l){case"BigInt":return i([l,a.toString()],a);case"Boolean":case"Number":case"String":return i([l,a.valueOf()],a)}if(t&&"toJSON"in a)return s(a.toJSON());const f=[],d=i([o,f],a);for(const p of f0(a))(e||!ai(gr(a[p])))&&f.push([s(p),s(a[p])]);return d}case yo:return i([o,a.toISOString()],a);case bo:{const{source:f,flags:d}=a;return i([o,{source:f,flags:d}],a)}case vo:{const f=[],d=i([o,f],a);for(const[p,h]of a)(e||!(ai(gr(p))||ai(gr(h))))&&f.push([s(p),s(h)]);return d}case wo:{const f=[],d=i([o,f],a);for(const p of a)(e||!ai(gr(p)))&&f.push(s(p));return d}}const{message:u}=a;return i([o,{name:l,message:u}],a)};return s},Jl=(e,{json:t,lossy:n}={})=>{const r=[];return p0(!(t||n),!!t,new Map,r)(e),r},Mi=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Ul(Jl(e,t)):structuredClone(e):(e,t)=>Ul(Jl(e,t));function h0(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 m0(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function g0(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||h0,r=e.options.footnoteBackLabel||m0,i=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},o=[];let l=-1;for(;++l<e.footnoteOrder.length;){const u=e.footnoteById.get(e.footnoteOrder[l]);if(!u)continue;const f=e.all(u),d=String(u.identifier).toUpperCase(),p=sr(d.toLowerCase());let h=0;const m=[],w=e.footnoteCounts.get(d);for(;w!==void 0&&++h<=w;){m.length>0&&m.push({type:"text",value:" "});let _=typeof n=="string"?n:n(l,h);typeof _=="string"&&(_={type:"text",value:_}),m.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+p+(h>1?"-"+h:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(l,h),className:["data-footnote-backref"]},children:Array.isArray(_)?_:[_]})}const S=f[f.length-1];if(S&&S.type==="element"&&S.tagName==="p"){const _=S.children[S.children.length-1];_&&_.type==="text"?_.value+=" ":S.children.push({type:"text",value:" "}),S.children.push(...m)}else f.push(...m);const x={type:"element",tagName:"li",properties:{id:t+"fn-"+p},children:e.wrap(f,!0)};e.patch(u,x),o.push(x)}if(o.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...Mi(a),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
|
|
10
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(o,!0)},{type:"text",value:`
|
|
11
|
+
`}]}}const gs=function(e){if(e==null)return v0;if(typeof e=="function")return xs(e);if(typeof e=="object")return Array.isArray(e)?x0(e):y0(e);if(typeof e=="string")return b0(e);throw new Error("Expected function, string, or object as test")};function x0(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=gs(e[n]);return xs(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function y0(e){const t=e;return xs(n);function n(r){const i=r;let s;for(s in e)if(i[s]!==t[s])return!1;return!0}}function b0(e){return xs(t);function t(n){return n&&n.type===e}}function xs(e){return t;function t(n,r,i){return!!(w0(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function v0(){return!0}function w0(e){return e!==null&&typeof e=="object"&&"type"in e}const Gf=[],k0=!0,ja=!1,S0="skip";function Kf(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const s=gs(i),a=r?-1:1;o(e,void 0,[])();function o(l,u,f){const d=l&&typeof l=="object"?l:{};if(typeof d.type=="string"){const h=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(l.type+(h?"<"+h+">":""))+")"})}return p;function p(){let h=Gf,m,w,S;if((!t||s(l,u,f[f.length-1]||void 0))&&(h=_0(n(l,f)),h[0]===ja))return h;if("children"in l&&l.children){const x=l;if(x.children&&h[0]!==S0)for(w=(r?x.children.length:-1)+a,S=f.concat(x);w>-1&&w<x.children.length;){const _=x.children[w];if(m=o(_,w,S)(),m[0]===ja)return m;w=typeof m[1]=="number"?m[1]:w+a}}return h}}}function _0(e){return Array.isArray(e)?e:typeof e=="number"?[k0,e]:e==null?Gf:[e]}function ko(e,t,n,r){let i,s,a;typeof t=="function"&&typeof n!="function"?(s=void 0,a=t,i=n):(s=t,a=n,i=r),Kf(e,s,o,i);function o(l,u){const f=u[u.length-1],d=f?f.children.indexOf(l):void 0;return a(l,d,f)}}const Ca={}.hasOwnProperty,j0={};function C0(e,t){const n=t||j0,r=new Map,i=new Map,s=new Map,a={...u0,...n.handlers},o={all:u,applyData:E0,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:a,one:l,options:n,patch:N0,wrap:z0};return ko(e,function(f){if(f.type==="definition"||f.type==="footnoteDefinition"){const d=f.type==="definition"?r:i,p=String(f.identifier).toUpperCase();d.has(p)||d.set(p,f)}}),o;function l(f,d){const p=f.type,h=o.handlers[p];if(Ca.call(o.handlers,p)&&h)return h(o,f,d);if(o.options.passThrough&&o.options.passThrough.includes(p)){if("children"in f){const{children:w,...S}=f,x=Mi(S);return x.children=o.all(f),x}return Mi(f)}return(o.options.unknownHandler||I0)(o,f,d)}function u(f){const d=[];if("children"in f){const p=f.children;let h=-1;for(;++h<p.length;){const m=o.one(p[h],f);if(m){if(h&&p[h-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=Hl(m.value)),!Array.isArray(m)&&m.type==="element")){const w=m.children[0];w&&w.type==="text"&&(w.value=Hl(w.value))}Array.isArray(m)?d.push(...m):d.push(m)}}}return d}}function N0(e,t){e.position&&(t.position=mb(e))}function E0(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,s=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&s&&Object.assign(n.properties,Mi(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function I0(e,t){const n=t.data||{},r="value"in t&&!(Ca.call(n,"hProperties")||Ca.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 z0(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
|
|
12
|
+
`});++r<e.length;)r&&n.push({type:"text",value:`
|
|
13
|
+
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
|
|
14
|
+
`}),n}function Hl(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function ql(e,t){const n=C0(e,t),r=n.one(e,void 0),i=g0(n),s=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&s.children.push({type:"text",value:`
|
|
15
|
+
`},i),s}function T0(e,t){return e&&"run"in e?async function(n,r){const i=ql(n,{file:r,...t});await e.run(i,r)}:function(n,r){return ql(n,{file:r,...e||t})}}function Wl(e){if(e)throw e}var Zs,Gl;function A0(){if(Gl)return Zs;Gl=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(u){return typeof Array.isArray=="function"?Array.isArray(u):t.call(u)==="[object Array]"},s=function(u){if(!u||t.call(u)!=="[object Object]")return!1;var f=e.call(u,"constructor"),d=u.constructor&&u.constructor.prototype&&e.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!f&&!d)return!1;var p;for(p in u);return typeof p>"u"||e.call(u,p)},a=function(u,f){n&&f.name==="__proto__"?n(u,f.name,{enumerable:!0,configurable:!0,value:f.newValue,writable:!0}):u[f.name]=f.newValue},o=function(u,f){if(f==="__proto__")if(e.call(u,f)){if(r)return r(u,f).value}else return;return u[f]};return Zs=function l(){var u,f,d,p,h,m,w=arguments[0],S=1,x=arguments.length,_=!1;for(typeof w=="boolean"&&(_=w,w=arguments[1]||{},S=2),(w==null||typeof w!="object"&&typeof w!="function")&&(w={});S<x;++S)if(u=arguments[S],u!=null)for(f in u)d=o(w,f),p=o(u,f),w!==p&&(_&&p&&(s(p)||(h=i(p)))?(h?(h=!1,m=d&&i(d)?d:[]):m=d&&s(d)?d:{},a(w,{name:f,newValue:l(_,m,p)})):typeof p<"u"&&a(w,{name:f,newValue:p}));return w},Zs}var P0=A0();const Bs=Za(P0);function Na(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 O0(){const e=[],t={run:n,use:r};return t;function n(...i){let s=-1;const a=i.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);o(null,...i);function o(l,...u){const f=e[++s];let d=-1;if(l){a(l);return}for(;++d<i.length;)(u[d]===null||u[d]===void 0)&&(u[d]=i[d]);i=u,f?D0(f,o)(...u):a(null,...u)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function D0(e,t){let n;return r;function r(...a){const o=e.length>a.length;let l;o&&a.push(i);try{l=e.apply(this,a)}catch(u){const f=u;if(o&&n)throw f;return i(f)}o||(l&&l.then&&typeof l.then=="function"?l.then(s,i):l instanceof Error?i(l):s(l))}function i(a,...o){n||(n=!0,t(a,...o))}function s(a){i(null,a)}}const Ft={basename:R0,dirname:M0,extname:$0,join:F0,sep:"/"};function R0(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Yr(e);let n=0,r=-1,i=e.length,s;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else r<0&&(s=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let a=-1,o=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else a<0&&(s=!0,a=i+1),o>-1&&(e.codePointAt(i)===t.codePointAt(o--)?o<0&&(r=i):(o=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function M0(e){if(Yr(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 $0(e){Yr(e);let t=e.length,n=-1,r=0,i=-1,s=0,a;for(;t--;){const o=e.codePointAt(t);if(o===47){if(a){r=t+1;break}continue}n<0&&(a=!0,n=t+1),o===46?i<0?i=t:s!==1&&(s=1):i>-1&&(s=-1)}return i<0||n<0||s===0||s===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function F0(...e){let t=-1,n;for(;++t<e.length;)Yr(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":L0(n)}function L0(e){Yr(e);const t=e.codePointAt(0)===47;let n=Z0(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function Z0(e,t){let n="",r=0,i=-1,s=0,a=-1,o,l;for(;++a<=e.length;){if(a<e.length)o=e.codePointAt(a);else{if(o===47)break;o=47}if(o===47){if(!(i===a-1||s===1))if(i!==a-1&&s===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(l=n.lastIndexOf("/"),l!==n.length-1){l<0?(n="",r=0):(n=n.slice(0,l),r=n.length-1-n.lastIndexOf("/")),i=a,s=0;continue}}else if(n.length>0){n="",r=0,i=a,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,a):n=e.slice(i+1,a),r=a-i-1;i=a,s=0}else o===46&&s>-1?s++:s=-1}return n}function Yr(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const B0={cwd:V0};function V0(){return"/"}function Ea(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function U0(e){if(typeof e=="string")e=new URL(e);else if(!Ea(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 J0(e)}function J0(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 Vs=["history","path","basename","stem","extname","dirname"];class Yf{constructor(t){let n;t?Ea(t)?n={path:t}:typeof t=="string"||H0(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":B0.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Vs.length;){const s=Vs[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)Vs.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Ft.basename(this.path):void 0}set basename(t){Js(t,"basename"),Us(t,"basename"),this.path=Ft.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Ft.dirname(this.path):void 0}set dirname(t){Kl(this.basename,"dirname"),this.path=Ft.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Ft.extname(this.path):void 0}set extname(t){if(Us(t,"extname"),Kl(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Ft.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Ea(t)&&(t=U0(t)),Js(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Ft.basename(this.path,this.extname):void 0}set stem(t){Js(t,"stem"),Us(t,"stem"),this.path=Ft.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const i=this.message(t,n,r);throw i.fatal=!0,i}info(t,n,r){const i=this.message(t,n,r);return i.fatal=void 0,i}message(t,n,r){const i=new at(t,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Us(e,t){if(e&&e.includes(Ft.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Ft.sep+"`")}function Js(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Kl(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function H0(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const q0=function(e){const r=this.constructor.prototype,i=r[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s},W0={}.hasOwnProperty;class So extends q0{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=O0()}copy(){const t=new So;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Bs(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Ws("data",this.frozen),this.namespace[t]=n,this):W0.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Ws("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=oi(t),r=this.parser||this.Parser;return Hs("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Hs("process",this.parser||this.Parser),qs("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,a){const o=oi(t),l=r.parse(o);r.run(l,o,function(f,d,p){if(f||!d||!p)return u(f);const h=d,m=r.stringify(h,p);Y0(m)?p.value=m:p.result=m,u(f,p)});function u(f,d){f||!d?a(f):s?s(d):n(void 0,d)}}}processSync(t){let n=!1,r;return this.freeze(),Hs("processSync",this.parser||this.Parser),qs("processSync",this.compiler||this.Compiler),this.process(t,i),Xl("processSync","process",n),r;function i(s,a){n=!0,Wl(s),r=a}}run(t,n,r){Yl(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?s(void 0,r):new Promise(s);function s(a,o){const l=oi(n);i.run(t,l,u);function u(f,d,p){const h=d||t;f?o(f):a?a(h):r(void 0,h,p)}}}runSync(t,n){let r=!1,i;return this.run(t,n,s),Xl("runSync","run",r),i;function s(a,o){Wl(a),i=o,r=!0}}stringify(t,n){this.freeze();const r=oi(n),i=this.compiler||this.Compiler;return qs("stringify",i),Yl(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(Ws("use",this.frozen),t!=null)if(typeof t=="function")l(t,n);else if(typeof t=="object")Array.isArray(t)?o(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(u){if(typeof u=="function")l(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[f,...d]=u;l(f,d)}else a(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function a(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(u.plugins),u.settings&&(i.settings=Bs(!0,i.settings,u.settings))}function o(u){let f=-1;if(u!=null)if(Array.isArray(u))for(;++f<u.length;){const d=u[f];s(d)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function l(u,f){let d=-1,p=-1;for(;++d<r.length;)if(r[d][0]===u){p=d;break}if(p===-1)r.push([u,...f]);else if(f.length>0){let[h,...m]=f;const w=r[p][1];Na(w)&&Na(h)&&(h=Bs(!0,w,h)),r[p]=[u,h,...m]}}}}const G0=new So().freeze();function Hs(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function qs(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Ws(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Yl(e){if(!Na(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Xl(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function oi(e){return K0(e)?e:new Yf(e)}function K0(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function Y0(e){return typeof e=="string"||X0(e)}function X0(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Q0="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Ql=[],eu={allowDangerousHtml:!0},ek=/^(https?|ircs?|mailto|xmpp)$/i,tk=[{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 nk(e){const t=rk(e),n=ik(e);return sk(t.runSync(t.parse(n),n),e)}function rk(e){const t=e.rehypePlugins||Ql,n=e.remarkPlugins||Ql,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...eu}:eu;return G0().use(Mw).use(n).use(T0,r).use(t)}function ik(e){const t=e.children||"",n=new Yf;return typeof t=="string"&&(n.value=t),n}function sk(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,s=t.disallowedElements,a=t.skipHtml,o=t.unwrapDisallowed,l=t.urlTransform||ak;for(const f of tk)Object.hasOwn(t,f.from)&&(""+f.from+(f.to?"use `"+f.to+"` instead":"remove it")+Q0+f.id,void 0);return ko(e,u),vb(e,{Fragment:c.Fragment,components:i,ignoreInvalidStyle:!0,jsx:c.jsx,jsxs:c.jsxs,passKeys:!0,passNode:!0});function u(f,d,p){if(f.type==="raw"&&p&&typeof d=="number")return a?p.children.splice(d,1):p.children[d]={type:"text",value:f.value},d;if(f.type==="element"){let h;for(h in $s)if(Object.hasOwn($s,h)&&Object.hasOwn(f.properties,h)){const m=f.properties[h],w=$s[h];(w===null||w.includes(f.tagName))&&(f.properties[h]=l(String(m||""),h,f))}}if(f.type==="element"){let h=n?!n.includes(f.tagName):s?s.includes(f.tagName):!1;if(!h&&r&&typeof d=="number"&&(h=!r(f,d,p)),h&&p&&typeof d=="number")return o&&f.children?p.children.splice(d,1,...f.children):p.children.splice(d,1),d}}}function ak(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||ek.test(e.slice(0,t))?e:""}function tu(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function ok(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function lk(e,t,n){const i=gs((n||{}).ignore||[]),s=uk(t);let a=-1;for(;++a<s.length;)Kf(e,"text",o);function o(u,f){let d=-1,p;for(;++d<f.length;){const h=f[d],m=p?p.children:void 0;if(i(h,m?m.indexOf(h):void 0,p))return;p=h}if(p)return l(u,f)}function l(u,f){const d=f[f.length-1],p=s[a][0],h=s[a][1];let m=0;const S=d.children.indexOf(u);let x=!1,_=[];p.lastIndex=0;let g=p.exec(u.value);for(;g;){const T=g.index,E={index:g.index,input:g.input,stack:[...f,u]};let k=h(...g,E);if(typeof k=="string"&&(k=k.length>0?{type:"text",value:k}:void 0),k===!1?p.lastIndex=T+1:(m!==T&&_.push({type:"text",value:u.value.slice(m,T)}),Array.isArray(k)?_.push(...k):k&&_.push(k),m=T+g[0].length,x=!0),!p.global)break;g=p.exec(u.value)}return x?(m<u.value.length&&_.push({type:"text",value:u.value.slice(m)}),d.children.splice(S,1,..._)):_=[u],S+_.length}}function uk(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([ck(i[0]),dk(i[1])])}return t}function ck(e){return typeof e=="string"?new RegExp(ok(e),"g"):e}function dk(e){return typeof e=="function"?e:function(){return e}}const Gs="phrasing",Ks=["autolink","link","image","label"];function fk(){return{transforms:[bk],enter:{literalAutolink:hk,literalAutolinkEmail:Ys,literalAutolinkHttp:Ys,literalAutolinkWww:Ys},exit:{literalAutolink:yk,literalAutolinkEmail:xk,literalAutolinkHttp:mk,literalAutolinkWww:gk}}}function pk(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Gs,notInConstruct:Ks},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Gs,notInConstruct:Ks},{character:":",before:"[ps]",after:"\\/",inConstruct:Gs,notInConstruct:Ks}]}}function hk(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Ys(e){this.config.enter.autolinkProtocol.call(this,e)}function mk(e){this.config.exit.autolinkProtocol.call(this,e)}function gk(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 xk(e){this.config.exit.autolinkEmail.call(this,e)}function yk(e){this.exit(e)}function bk(e){lk(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,vk],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),wk]],{ignore:["link","linkReference"]})}function vk(e,t,n,r,i){let s="";if(!Xf(i)||(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!kk(n)))return!1;const a=Sk(n+r);if(!a[0])return!1;const o={type:"link",title:null,url:s+t+a[0],children:[{type:"text",value:t+a[0]}]};return a[1]?[o,{type:"text",value:a[1]}]:o}function wk(e,t,n,r){return!Xf(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function kk(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 Sk(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const i=tu(e,"(");let s=tu(e,")");for(;r!==-1&&i>s;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),s++;return[e,n]}function Xf(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||En(n)||ps(n))&&(!t||n!==47)}Qf.peek=Ak;function _k(){this.buffer()}function jk(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Ck(){this.buffer()}function Nk(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Ek(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Mt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Ik(e){this.exit(e)}function zk(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Mt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Tk(e){this.exit(e)}function Ak(){return"["}function Qf(e,t,n,r){const i=n.createTracker(r);let s=i.move("[^");const a=n.enter("footnoteReference"),o=n.enter("reference");return s+=i.move(n.safe(n.associationId(e),{after:"]",before:s})),o(),a(),s+=i.move("]"),s}function Pk(){return{enter:{gfmFootnoteCallString:_k,gfmFootnoteCall:jk,gfmFootnoteDefinitionLabelString:Ck,gfmFootnoteDefinition:Nk},exit:{gfmFootnoteCallString:Ek,gfmFootnoteCall:Ik,gfmFootnoteDefinitionLabelString:zk,gfmFootnoteDefinition:Tk}}}function Ok(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Qf},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,s,a){const o=s.createTracker(a);let l=o.move("[^");const u=s.enter("footnoteDefinition"),f=s.enter("label");return l+=o.move(s.safe(s.associationId(r),{before:l,after:"]"})),f(),l+=o.move("]:"),r.children&&r.children.length>0&&(o.shift(4),l+=o.move((t?`
|
|
16
|
+
`:" ")+s.indentLines(s.containerFlow(r,o.current()),t?ep:Dk))),u(),l}}function Dk(e,t,n){return t===0?e:ep(e,t,n)}function ep(e,t,n){return(n?"":" ")+e}const Rk=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];tp.peek=Zk;function Mk(){return{canContainEols:["delete"],enter:{strikethrough:Fk},exit:{strikethrough:Lk}}}function $k(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Rk}],handlers:{delete:tp}}}function Fk(e){this.enter({type:"delete",children:[]},e)}function Lk(e){this.exit(e)}function tp(e,t,n,r){const i=n.createTracker(r),s=n.enter("strikethrough");let a=i.move("~~");return a+=n.containerPhrasing(e,{...i.current(),before:a,after:"~"}),a+=i.move("~~"),s(),a}function Zk(){return"~"}function Bk(e){return e.length}function Vk(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||Bk,s=[],a=[],o=[],l=[];let u=0,f=-1;for(;++f<e.length;){const w=[],S=[];let x=-1;for(e[f].length>u&&(u=e[f].length);++x<e[f].length;){const _=Uk(e[f][x]);if(n.alignDelimiters!==!1){const g=i(_);S[x]=g,(l[x]===void 0||g>l[x])&&(l[x]=g)}w.push(_)}a[f]=w,o[f]=S}let d=-1;if(typeof r=="object"&&"length"in r)for(;++d<u;)s[d]=nu(r[d]);else{const w=nu(r);for(;++d<u;)s[d]=w}d=-1;const p=[],h=[];for(;++d<u;){const w=s[d];let S="",x="";w===99?(S=":",x=":"):w===108?S=":":w===114&&(x=":");let _=n.alignDelimiters===!1?1:Math.max(1,l[d]-S.length-x.length);const g=S+"-".repeat(_)+x;n.alignDelimiters!==!1&&(_=S.length+_+x.length,_>l[d]&&(l[d]=_),h[d]=_),p[d]=g}a.splice(1,0,p),o.splice(1,0,h),f=-1;const m=[];for(;++f<a.length;){const w=a[f],S=o[f];d=-1;const x=[];for(;++d<u;){const _=w[d]||"";let g="",T="";if(n.alignDelimiters!==!1){const E=l[d]-(S[d]||0),k=s[d];k===114?g=" ".repeat(E):k===99?E%2?(g=" ".repeat(E/2+.5),T=" ".repeat(E/2-.5)):(g=" ".repeat(E/2),T=g):T=" ".repeat(E)}n.delimiterStart!==!1&&!d&&x.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&_==="")&&(n.delimiterStart!==!1||d)&&x.push(" "),n.alignDelimiters!==!1&&x.push(g),x.push(_),n.alignDelimiters!==!1&&x.push(T),n.padding!==!1&&x.push(" "),(n.delimiterEnd!==!1||d!==u-1)&&x.push("|")}m.push(n.delimiterEnd===!1?x.join("").replace(/ +$/,""):x.join(""))}return m.join(`
|
|
17
|
+
`)}function Uk(e){return e==null?"":String(e)}function nu(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function Jk(e,t,n,r){const i=n.enter("blockquote"),s=n.createTracker(r);s.move("> "),s.shift(2);const a=n.indentLines(n.containerFlow(e,s.current()),Hk);return i(),a}function Hk(e,t,n){return">"+(n?"":" ")+e}function qk(e,t){return ru(e,t.inConstruct,!0)&&!ru(e,t.notInConstruct,!1)}function ru(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function iu(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
18
|
+
`&&qk(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
19
|
+
`}function Wk(e,t){const n=String(e);let r=n.indexOf(t),i=r,s=0,a=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++s>a&&(a=s):s=1,i=r+t.length,r=n.indexOf(t,i);return a}function Gk(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 Kk(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 Yk(e,t,n,r){const i=Kk(n),s=e.value||"",a=i==="`"?"GraveAccent":"Tilde";if(Gk(e,n)){const d=n.enter("codeIndented"),p=n.indentLines(s,Xk);return d(),p}const o=n.createTracker(r),l=i.repeat(Math.max(Wk(s,i)+1,3)),u=n.enter("codeFenced");let f=o.move(l);if(e.lang){const d=n.enter(`codeFencedLang${a}`);f+=o.move(n.safe(e.lang,{before:f,after:" ",encode:["`"],...o.current()})),d()}if(e.lang&&e.meta){const d=n.enter(`codeFencedMeta${a}`);f+=o.move(" "),f+=o.move(n.safe(e.meta,{before:f,after:`
|
|
20
|
+
`,encode:["`"],...o.current()})),d()}return f+=o.move(`
|
|
21
|
+
`),s&&(f+=o.move(s+`
|
|
22
|
+
`)),f+=o.move(l),u(),f}function Xk(e,t,n){return(n?"":" ")+e}function _o(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function Qk(e,t,n,r){const i=_o(n),s=i==='"'?"Quote":"Apostrophe",a=n.enter("definition");let o=n.enter("label");const l=n.createTracker(r);let u=l.move("[");return u+=l.move(n.safe(n.associationId(e),{before:u,after:"]",...l.current()})),u+=l.move("]: "),o(),!e.url||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),u+=l.move("<"),u+=l.move(n.safe(e.url,{before:u,after:">",...l.current()})),u+=l.move(">")):(o=n.enter("destinationRaw"),u+=l.move(n.safe(e.url,{before:u,after:e.title?" ":`
|
|
23
|
+
`,...l.current()}))),o(),e.title&&(o=n.enter(`title${s}`),u+=l.move(" "+i),u+=l.move(n.safe(e.title,{before:u,after:i,...l.current()})),u+=l.move(i),o()),a(),u}function eS(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 Lr(e){return"&#x"+e.toString(16).toUpperCase()+";"}function $i(e,t,n){const r=Qn(e),i=Qn(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}}np.peek=tS;function np(e,t,n,r){const i=eS(n),s=n.enter("emphasis"),a=n.createTracker(r),o=a.move(i);let l=a.move(n.containerPhrasing(e,{after:i,before:o,...a.current()}));const u=l.charCodeAt(0),f=$i(r.before.charCodeAt(r.before.length-1),u,i);f.inside&&(l=Lr(u)+l.slice(1));const d=l.charCodeAt(l.length-1),p=$i(r.after.charCodeAt(0),d,i);p.inside&&(l=l.slice(0,-1)+Lr(d));const h=a.move(i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:f.outside},o+l+h}function tS(e,t,n){return n.options.emphasis||"*"}function nS(e,t){let n=!1;return ko(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,ja}),!!((!e.depth||e.depth<3)&&mo(e)&&(t.options.setext||n))}function rS(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(nS(e,n)){const f=n.enter("headingSetext"),d=n.enter("phrasing"),p=n.containerPhrasing(e,{...s.current(),before:`
|
|
24
|
+
`,after:`
|
|
25
|
+
`});return d(),f(),p+`
|
|
26
|
+
`+(i===1?"=":"-").repeat(p.length-(Math.max(p.lastIndexOf("\r"),p.lastIndexOf(`
|
|
27
|
+
`))+1))}const a="#".repeat(i),o=n.enter("headingAtx"),l=n.enter("phrasing");s.move(a+" ");let u=n.containerPhrasing(e,{before:"# ",after:`
|
|
28
|
+
`,...s.current()});return/^[\t ]/.test(u)&&(u=Lr(u.charCodeAt(0))+u.slice(1)),u=u?a+" "+u:a,n.options.closeAtx&&(u+=" "+a),l(),o(),u}rp.peek=iS;function rp(e){return e.value||""}function iS(){return"<"}ip.peek=sS;function ip(e,t,n,r){const i=_o(n),s=i==='"'?"Quote":"Apostrophe",a=n.enter("image");let o=n.enter("label");const l=n.createTracker(r);let u=l.move("![");return u+=l.move(n.safe(e.alt,{before:u,after:"]",...l.current()})),u+=l.move("]("),o(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),u+=l.move("<"),u+=l.move(n.safe(e.url,{before:u,after:">",...l.current()})),u+=l.move(">")):(o=n.enter("destinationRaw"),u+=l.move(n.safe(e.url,{before:u,after:e.title?" ":")",...l.current()}))),o(),e.title&&(o=n.enter(`title${s}`),u+=l.move(" "+i),u+=l.move(n.safe(e.title,{before:u,after:i,...l.current()})),u+=l.move(i),o()),u+=l.move(")"),a(),u}function sS(){return"!"}sp.peek=aS;function sp(e,t,n,r){const i=e.referenceType,s=n.enter("imageReference");let a=n.enter("label");const o=n.createTracker(r);let l=o.move("![");const u=n.safe(e.alt,{before:l,after:"]",...o.current()});l+=o.move(u+"]["),a();const f=n.stack;n.stack=[],a=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return a(),n.stack=f,s(),i==="full"||!u||u!==d?l+=o.move(d+"]"):i==="shortcut"?l=l.slice(0,-1):l+=o.move("]"),l}function aS(){return"!"}ap.peek=oS;function ap(e,t,n){let r=e.value||"",i="`",s=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const a=n.unsafe[s],o=n.compilePattern(a);let l;if(a.atBreak)for(;l=o.exec(r);){let u=l.index;r.charCodeAt(u)===10&&r.charCodeAt(u-1)===13&&u--,r=r.slice(0,u)+" "+r.slice(l.index+1)}}return i+r+i}function oS(){return"`"}function op(e,t){const n=mo(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}lp.peek=lS;function lp(e,t,n,r){const i=_o(n),s=i==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let o,l;if(op(e,n)){const f=n.stack;n.stack=[],o=n.enter("autolink");let d=a.move("<");return d+=a.move(n.containerPhrasing(e,{before:d,after:">",...a.current()})),d+=a.move(">"),o(),n.stack=f,d}o=n.enter("link"),l=n.enter("label");let u=a.move("[");return u+=a.move(n.containerPhrasing(e,{before:u,after:"](",...a.current()})),u+=a.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),u+=a.move("<"),u+=a.move(n.safe(e.url,{before:u,after:">",...a.current()})),u+=a.move(">")):(l=n.enter("destinationRaw"),u+=a.move(n.safe(e.url,{before:u,after:e.title?" ":")",...a.current()}))),l(),e.title&&(l=n.enter(`title${s}`),u+=a.move(" "+i),u+=a.move(n.safe(e.title,{before:u,after:i,...a.current()})),u+=a.move(i),l()),u+=a.move(")"),o(),u}function lS(e,t,n){return op(e,n)?"<":"["}up.peek=uS;function up(e,t,n,r){const i=e.referenceType,s=n.enter("linkReference");let a=n.enter("label");const o=n.createTracker(r);let l=o.move("[");const u=n.containerPhrasing(e,{before:l,after:"]",...o.current()});l+=o.move(u+"]["),a();const f=n.stack;n.stack=[],a=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return a(),n.stack=f,s(),i==="full"||!u||u!==d?l+=o.move(d+"]"):i==="shortcut"?l=l.slice(0,-1):l+=o.move("]"),l}function uS(){return"["}function jo(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function cS(e){const t=jo(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function dS(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 cp(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 fS(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let a=e.ordered?dS(n):jo(n);const o=e.ordered?a==="."?")":".":cS(n);let l=t&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!e.ordered){const f=e.children?e.children[0]:void 0;if((a==="*"||a==="-")&&f&&(!f.children||!f.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(l=!0),cp(n)===a&&f){let d=-1;for(;++d<e.children.length;){const p=e.children[d];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(a=o),n.bulletCurrent=a;const u=n.containerFlow(e,r);return n.bulletLastUsed=a,n.bulletCurrent=s,i(),u}function pS(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 hS(e,t,n,r){const i=pS(n);let s=n.bulletCurrent||jo(n);t&&t.type==="list"&&t.ordered&&(s=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+s);let a=s.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(a=Math.ceil(a/4)*4);const o=n.createTracker(r);o.move(s+" ".repeat(a-s.length)),o.shift(a);const l=n.enter("listItem"),u=n.indentLines(n.containerFlow(e,o.current()),f);return l(),u;function f(d,p,h){return p?(h?"":" ".repeat(a))+d:(h?s:s+" ".repeat(a-s.length))+d}}function mS(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),a=n.containerPhrasing(e,r);return s(),i(),a}const gS=gs(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function xS(e,t,n,r){return(e.children.some(function(a){return gS(a)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function yS(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}dp.peek=bS;function dp(e,t,n,r){const i=yS(n),s=n.enter("strong"),a=n.createTracker(r),o=a.move(i+i);let l=a.move(n.containerPhrasing(e,{after:i,before:o,...a.current()}));const u=l.charCodeAt(0),f=$i(r.before.charCodeAt(r.before.length-1),u,i);f.inside&&(l=Lr(u)+l.slice(1));const d=l.charCodeAt(l.length-1),p=$i(r.after.charCodeAt(0),d,i);p.inside&&(l=l.slice(0,-1)+Lr(d));const h=a.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:f.outside},o+l+h}function bS(e,t,n){return n.options.strong||"*"}function vS(e,t,n,r){return n.safe(e.value,r)}function wS(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 kS(e,t,n){const r=(cp(n)+(n.options.ruleSpaces?" ":"")).repeat(wS(n));return n.options.ruleSpaces?r.slice(0,-1):r}const fp={blockquote:Jk,break:iu,code:Yk,definition:Qk,emphasis:np,hardBreak:iu,heading:rS,html:rp,image:ip,imageReference:sp,inlineCode:ap,link:lp,linkReference:up,list:fS,listItem:hS,paragraph:mS,root:xS,strong:dp,text:vS,thematicBreak:kS};function SS(){return{enter:{table:_S,tableData:su,tableHeader:su,tableRow:CS},exit:{codeText:NS,table:jS,tableData:Xs,tableHeader:Xs,tableRow:Xs}}}function _S(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 jS(e){this.exit(e),this.data.inTable=void 0}function CS(e){this.enter({type:"tableRow",children:[]},e)}function Xs(e){this.exit(e)}function su(e){this.enter({type:"tableCell",children:[]},e)}function NS(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,ES));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function ES(e,t){return t==="|"?t:e}function IS(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
29
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:p,table:a,tableCell:l,tableRow:o}};function a(h,m,w,S){return u(f(h,w,S),h.align)}function o(h,m,w,S){const x=d(h,w,S),_=u([x]);return _.slice(0,_.indexOf(`
|
|
30
|
+
`))}function l(h,m,w,S){const x=w.enter("tableCell"),_=w.enter("phrasing"),g=w.containerPhrasing(h,{...S,before:s,after:s});return _(),x(),g}function u(h,m){return Vk(h,{align:m,alignDelimiters:r,padding:n,stringLength:i})}function f(h,m,w){const S=h.children;let x=-1;const _=[],g=m.enter("table");for(;++x<S.length;)_[x]=d(S[x],m,w);return g(),_}function d(h,m,w){const S=h.children;let x=-1;const _=[],g=m.enter("tableRow");for(;++x<S.length;)_[x]=l(S[x],h,m,w);return g(),_}function p(h,m,w){let S=fp.inlineCode(h,m,w);return w.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function zS(){return{exit:{taskListCheckValueChecked:au,taskListCheckValueUnchecked:au,paragraph:AS}}}function TS(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:PS}}}function au(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function AS(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,a;for(;++s<i.length;){const o=i[s];if(o.type==="paragraph"){a=o;break}}a===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function PS(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",a="["+(e.checked?"x":" ")+"] ",o=n.createTracker(r);s&&o.move(a);let l=fp.listItem(e,t,n,{...r,...o.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),l;function u(f){return f+a}}function OS(){return[fk(),Pk(),Mk(),SS(),zS()]}function DS(e){return{extensions:[pk(),Ok(e),$k(),IS(e),TS()]}}const RS={tokenize:BS,partial:!0},pp={tokenize:VS,partial:!0},hp={tokenize:US,partial:!0},mp={tokenize:JS,partial:!0},MS={tokenize:HS,partial:!0},gp={name:"wwwAutolink",tokenize:LS,previous:yp},xp={name:"protocolAutolink",tokenize:ZS,previous:bp},Yt={name:"emailAutolink",tokenize:FS,previous:vp},Ut={};function $S(){return{text:Ut}}let mn=48;for(;mn<123;)Ut[mn]=Yt,mn++,mn===58?mn=65:mn===91&&(mn=97);Ut[43]=Yt;Ut[45]=Yt;Ut[46]=Yt;Ut[95]=Yt;Ut[72]=[Yt,xp];Ut[104]=[Yt,xp];Ut[87]=[Yt,gp];Ut[119]=[Yt,gp];function FS(e,t,n){const r=this;let i,s;return a;function a(d){return!Ia(d)||!vp.call(r,r.previous)||Co(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),o(d))}function o(d){return Ia(d)?(e.consume(d),o):d===64?(e.consume(d),l):n(d)}function l(d){return d===46?e.check(MS,f,u)(d):d===45||d===95||st(d)?(s=!0,e.consume(d),l):f(d)}function u(d){return e.consume(d),i=!0,l}function f(d){return s&&i&&dt(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function LS(e,t,n){const r=this;return i;function i(a){return a!==87&&a!==119||!yp.call(r,r.previous)||Co(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(RS,e.attempt(pp,e.attempt(hp,s),n),n)(a))}function s(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function ZS(e,t,n){const r=this;let i="",s=!1;return a;function a(d){return(d===72||d===104)&&bp.call(r,r.previous)&&!Co(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),e.consume(d),o):n(d)}function o(d){if(dt(d)&&i.length<5)return i+=String.fromCodePoint(d),e.consume(d),o;if(d===58){const p=i.toLowerCase();if(p==="http"||p==="https")return e.consume(d),l}return n(d)}function l(d){return d===47?(e.consume(d),s?u:(s=!0,l)):n(d)}function u(d){return d===null||Di(d)||Re(d)||En(d)||ps(d)?n(d):e.attempt(pp,e.attempt(hp,f),n)(d)}function f(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function BS(e,t,n){let r=0;return i;function i(a){return(a===87||a===119)&&r<3?(r++,e.consume(a),i):a===46&&r===3?(e.consume(a),s):n(a)}function s(a){return a===null?n(a):t(a)}}function VS(e,t,n){let r,i,s;return a;function a(u){return u===46||u===95?e.check(mp,l,o)(u):u===null||Re(u)||En(u)||u!==45&&ps(u)?l(u):(s=!0,e.consume(u),a)}function o(u){return u===95?r=!0:(i=r,r=void 0),e.consume(u),a}function l(u){return i||r||!s?n(u):t(u)}}function US(e,t){let n=0,r=0;return i;function i(a){return a===40?(n++,e.consume(a),i):a===41&&r<n?s(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?e.check(mp,t,s)(a):a===null||Re(a)||En(a)?t(a):(e.consume(a),i)}function s(a){return a===41&&r++,e.consume(a),i}}function JS(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),s):o===93?(e.consume(o),i):o===60||o===null||Re(o)||En(o)?t(o):n(o)}function i(o){return o===null||o===40||o===91||Re(o)||En(o)?t(o):r(o)}function s(o){return dt(o)?a(o):n(o)}function a(o){return o===59?(e.consume(o),r):dt(o)?(e.consume(o),a):n(o)}}function HS(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return st(s)?n(s):t(s)}}function yp(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Re(e)}function bp(e){return!dt(e)}function vp(e){return!(e===47||Ia(e))}function Ia(e){return e===43||e===45||e===46||e===95||st(e)}function Co(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 qS={tokenize:t1,partial:!0};function WS(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:XS,continuation:{tokenize:QS},exit:e1}},text:{91:{name:"gfmFootnoteCall",tokenize:YS},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:GS,resolveTo:KS}}}}function GS(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){a=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return o;function o(l){if(!a||!a._balanced)return n(l);const u=Mt(r.sliceSerialize({start:a.end,end:r.now()}));return u.codePointAt(0)!==94||!s.includes(u.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function KS(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},o=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",a,t],["exit",a,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...o),e}function YS(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,a;return o;function o(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(d){if(s>999||d===93&&!a||d===null||d===91||Re(d))return n(d);if(d===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return i.includes(Mt(r.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return Re(d)||(a=!0),s++,e.consume(d),d===92?f:u}function f(d){return d===91||d===92||d===93?(e.consume(d),s++,u):u(d)}}function XS(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,a=0,o;return l;function l(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",f):n(m)}function f(m){if(a>999||m===93&&!o||m===null||m===91||Re(m))return n(m);if(m===93){e.exit("chunkString");const w=e.exit("gfmFootnoteDefinitionLabelString");return s=Mt(r.sliceSerialize(w)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return Re(m)||(o=!0),a++,e.consume(m),m===92?d:f}function d(m){return m===91||m===92||m===93?(e.consume(m),a++,f):f(m)}function p(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),i.includes(s)||i.push(s),ze(e,h,"gfmFootnoteDefinitionWhitespace")):n(m)}function h(m){return t(m)}}function QS(e,t,n){return e.check(Kr,t,e.attempt(qS,t,n))}function e1(e){e.exit("gfmFootnoteDefinition")}function t1(e,t,n){const r=this;return ze(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?t(s):n(s)}}function n1(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(a,o){let l=-1;for(;++l<a.length;)if(a[l][0]==="enter"&&a[l][1].type==="strikethroughSequenceTemporary"&&a[l][1]._close){let u=l;for(;u--;)if(a[u][0]==="exit"&&a[u][1].type==="strikethroughSequenceTemporary"&&a[u][1]._open&&a[l][1].end.offset-a[l][1].start.offset===a[u][1].end.offset-a[u][1].start.offset){a[l][1].type="strikethroughSequence",a[u][1].type="strikethroughSequence";const f={type:"strikethrough",start:Object.assign({},a[u][1].start),end:Object.assign({},a[l][1].end)},d={type:"strikethroughText",start:Object.assign({},a[u][1].end),end:Object.assign({},a[l][1].start)},p=[["enter",f,o],["enter",a[u][1],o],["exit",a[u][1],o],["enter",d,o]],h=o.parser.constructs.insideSpan.null;h&&St(p,p.length,0,hs(h,a.slice(u+1,l),o)),St(p,p.length,0,[["exit",d,o],["enter",a[l][1],o],["exit",a[l][1],o],["exit",f,o]]),St(a,u-1,l-u+3,p),l=u+p.length-2;break}}for(l=-1;++l<a.length;)a[l][1].type==="strikethroughSequenceTemporary"&&(a[l][1].type="data");return a}function s(a,o,l){const u=this.previous,f=this.events;let d=0;return p;function p(m){return u===126&&f[f.length-1][1].type!=="characterEscape"?l(m):(a.enter("strikethroughSequenceTemporary"),h(m))}function h(m){const w=Qn(u);if(m===126)return d>1?l(m):(a.consume(m),d++,h);if(d<2&&!n)return l(m);const S=a.exit("strikethroughSequenceTemporary"),x=Qn(m);return S._open=!x||x===2&&!!w,S._close=!w||w===2&&!!x,o(m)}}}class r1{constructor(){this.map=[]}add(t,n,r){i1(this,t,n,r)}consume(t){if(this.map.sort(function(s,a){return s[0]-a[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0}}function i1(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 s1(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 a1(){return{flow:{null:{name:"table",tokenize:o1,resolveAll:l1}}}}function o1(e,t,n){const r=this;let i=0,s=0,a;return o;function o(C){let B=r.events.length-1;for(;B>-1;){const L=r.events[B][1].type;if(L==="lineEnding"||L==="linePrefix")B--;else break}const R=B>-1?r.events[B][1].type:null,U=R==="tableHead"||R==="tableRow"?k:l;return U===k&&r.parser.lazy[r.now().line]?n(C):U(C)}function l(C){return e.enter("tableHead"),e.enter("tableRow"),u(C)}function u(C){return C===124||(a=!0,s+=1),f(C)}function f(C){return C===null?n(C):me(C)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),h):n(C):Ce(C)?ze(e,f,"whitespace")(C):(s+=1,a&&(a=!1,i+=1),C===124?(e.enter("tableCellDivider"),e.consume(C),e.exit("tableCellDivider"),a=!0,f):(e.enter("data"),d(C)))}function d(C){return C===null||C===124||Re(C)?(e.exit("data"),f(C)):(e.consume(C),C===92?p:d)}function p(C){return C===92||C===124?(e.consume(C),d):d(C)}function h(C){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(C):(e.enter("tableDelimiterRow"),a=!1,Ce(C)?ze(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):m(C))}function m(C){return C===45||C===58?S(C):C===124?(a=!0,e.enter("tableCellDivider"),e.consume(C),e.exit("tableCellDivider"),w):E(C)}function w(C){return Ce(C)?ze(e,S,"whitespace")(C):S(C)}function S(C){return C===58?(s+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(C),e.exit("tableDelimiterMarker"),x):C===45?(s+=1,x(C)):C===null||me(C)?T(C):E(C)}function x(C){return C===45?(e.enter("tableDelimiterFiller"),_(C)):E(C)}function _(C){return C===45?(e.consume(C),_):C===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(C),e.exit("tableDelimiterMarker"),g):(e.exit("tableDelimiterFiller"),g(C))}function g(C){return Ce(C)?ze(e,T,"whitespace")(C):T(C)}function T(C){return C===124?m(C):C===null||me(C)?!a||i!==s?E(C):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(C)):E(C)}function E(C){return n(C)}function k(C){return e.enter("tableRow"),N(C)}function N(C){return C===124?(e.enter("tableCellDivider"),e.consume(C),e.exit("tableCellDivider"),N):C===null||me(C)?(e.exit("tableRow"),t(C)):Ce(C)?ze(e,N,"whitespace")(C):(e.enter("data"),M(C))}function M(C){return C===null||C===124||Re(C)?(e.exit("data"),N(C)):(e.consume(C),C===92?Y:M)}function Y(C){return C===92||C===124?(e.consume(C),M):M(C)}}function l1(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],a=[0,0,0,0],o=!1,l=0,u,f,d;const p=new r1;for(;++n<e.length;){const h=e[n],m=h[1];h[0]==="enter"?m.type==="tableHead"?(o=!1,l!==0&&(ou(p,t,l,u,f),f=void 0,l=0),u={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(n,0,[["enter",u,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,d=void 0,s=[0,0,0,0],a=[0,n+1,0,0],o&&(o=!1,f={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(n,0,[["enter",f,t]])),i=m.type==="tableDelimiterRow"?2:f?3:1):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,a[2]===0&&(s[1]!==0&&(a[0]=a[1],d=li(p,t,s,i,void 0,d),s=[0,0,0,0]),a[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(a[0]=a[1],d=li(p,t,s,i,void 0,d)),s=a,a=[s[1],n,0,0])):m.type==="tableHead"?(o=!0,l=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(l=n,s[1]!==0?(a[0]=a[1],d=li(p,t,s,i,n,d)):a[1]!==0&&(d=li(p,t,a,i,n,d)),i=0):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(a[3]=n)}for(l!==0&&ou(p,t,l,u,f),p.consume(t.events),n=-1;++n<t.events.length;){const h=t.events[n];h[0]==="enter"&&h[1].type==="table"&&(h[1]._align=s1(t.events,n))}return e}function li(e,t,n,r,i,s){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",o="tableContent";n[0]!==0&&(s.end=Object.assign({},Zn(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=Zn(t.events,n[1]);if(s={type:a,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const u=Zn(t.events,n[2]),f=Zn(t.events,n[3]),d={type:o,start:Object.assign({},u),end:Object.assign({},f)};if(e.add(n[2],0,[["enter",d,t]]),r!==2){const p=t.events[n[2]],h=t.events[n[3]];if(p[1].end=Object.assign({},h[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,w=n[3]-n[2]-1;e.add(m,w,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return i!==void 0&&(s.end=Object.assign({},Zn(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function ou(e,t,n,r,i){const s=[],a=Zn(t.events,n);i&&(i.end=Object.assign({},a),s.push(["exit",i,t])),r.end=Object.assign({},a),s.push(["exit",r,t]),e.add(n+1,0,s)}function Zn(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const u1={name:"tasklistCheck",tokenize:d1};function c1(){return{text:{91:u1}}}function d1(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 Re(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),a):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),a):n(l)}function a(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),o):n(l)}function o(l){return me(l)?t(l):Ce(l)?e.check({tokenize:f1},t,n)(l):n(l)}}function f1(e,t,n){return ze(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function p1(e){return Tf([$S(),WS(),n1(e),a1(),c1()])}const h1={};function m1(e){const t=this,n=e||h1,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(p1(n)),s.push(OS()),a.push(DS(n))}var wp="vercel.ai.error",g1=Symbol.for(wp),lu,uu,Vt=class kp extends(uu=Error,lu=g1,uu){constructor({name:t,message:n,cause:r}){super(n),this[lu]=!0,this.name=t,this.cause=r}static isInstance(t){return kp.hasMarker(t,wp)}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 Sp(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var _p="AI_InvalidArgumentError",jp=`vercel.ai.error.${_p}`,x1=Symbol.for(jp),cu,du,y1=class extends(du=Vt,cu=x1,du){constructor({message:e,cause:t,argument:n}){super({name:_p,message:e,cause:t}),this[cu]=!0,this.argument=n}static isInstance(e){return Vt.hasMarker(e,jp)}},Cp="AI_JSONParseError",Np=`vercel.ai.error.${Cp}`,b1=Symbol.for(Np),fu,pu,hu=class extends(pu=Vt,fu=b1,pu){constructor({text:e,cause:t}){super({name:Cp,message:`JSON parsing failed: Text: ${e}.
|
|
31
|
+
Error message: ${Sp(t)}`,cause:t}),this[fu]=!0,this.text=e}static isInstance(e){return Vt.hasMarker(e,Np)}},Ep="AI_TypeValidationError",Ip=`vercel.ai.error.${Ep}`,v1=Symbol.for(Ip),mu,gu,er=class za extends(gu=Vt,mu=v1,gu){constructor({value:t,cause:n,context:r}){let i="Type validation failed";if(r!=null&&r.field&&(i+=` for ${r.field}`),r!=null&&r.entityName||r!=null&&r.entityId){i+=" (";const s=[];r.entityName&&s.push(r.entityName),r.entityId&&s.push(`id: "${r.entityId}"`),i+=s.join(", "),i+=")"}super({name:Ep,message:`${i}: Value: ${JSON.stringify(t)}.
|
|
32
|
+
Error message: ${Sp(n)}`,cause:n}),this[mu]=!0,this.value=t,this.context=r}static isInstance(t){return Vt.hasMarker(t,Ip)}static wrap({value:t,cause:n,context:r}){var i,s,a;return za.isInstance(n)&&n.value===t&&((i=n.context)==null?void 0:i.field)===(r==null?void 0:r.field)&&((s=n.context)==null?void 0:s.entityName)===(r==null?void 0:r.entityName)&&((a=n.context)==null?void 0:a.entityId)===(r==null?void 0:r.entityId)?n:new za({value:t,cause:n,context:r})}};function V(e,t,n){function r(o,l){if(o._zod||Object.defineProperty(o,"_zod",{value:{def:l,constr:a,traits:new Set},enumerable:!1}),o._zod.traits.has(e))return;o._zod.traits.add(e),t(o,l);const u=a.prototype,f=Object.keys(u);for(let d=0;d<f.length;d++){const p=f[d];p in o||(o[p]=u[p].bind(o))}}const i=(n==null?void 0:n.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:e});function a(o){var l;const u=n!=null&&n.Parent?new s:this;r(u,o),(l=u._zod).deferred??(l.deferred=[]);for(const f of u._zod.deferred)f();return u}return Object.defineProperty(a,"init",{value:r}),Object.defineProperty(a,Symbol.hasInstance,{value:o=>{var l,u;return n!=null&&n.Parent&&o instanceof n.Parent?!0:(u=(l=o==null?void 0:o._zod)==null?void 0:l.traits)==null?void 0:u.has(e)}}),Object.defineProperty(a,"name",{value:e}),a}class Kn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class zp extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Tp={};function un(e){return Tp}function Ap(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 Ta(e,t){return typeof t=="bigint"?t.toString():t}function ys(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function No(e){return e==null}function Eo(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function w1(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let i=(r.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(r)){const l=r.match(/\d?e-(\d?)/);l!=null&&l[1]&&(i=Number.parseInt(l[1]))}const s=n>i?n:i,a=Number.parseInt(e.toFixed(s).replace(".","")),o=Number.parseInt(t.toFixed(s).replace(".",""));return a%o/10**s}const xu=Symbol("evaluating");function Ie(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==xu)return r===void 0&&(r=xu,r=n()),r},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Tn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function fn(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function yu(e){return JSON.stringify(e)}function k1(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Pp="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Zr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const S1=ys(()=>{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 tr(e){if(Zr(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Zr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Op(e){return tr(e)?{...e}:Array.isArray(e)?[...e]:e}const _1=new Set(["string","number","symbol"]);function nr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function pn(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 ue(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 j1(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const C1={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 N1(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=fn(e._zod.def,{get shape(){const a={};for(const o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(a[o]=n.shape[o])}return Tn(this,"shape",a),a},checks:[]});return pn(e,s)}function E1(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=fn(e._zod.def,{get shape(){const a={...e._zod.def.shape};for(const o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&delete a[o]}return Tn(this,"shape",a),a},checks:[]});return pn(e,s)}function I1(e,t){if(!tr(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const s=e._zod.def.shape;for(const a in t)if(Object.getOwnPropertyDescriptor(s,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=fn(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return Tn(this,"shape",s),s}});return pn(e,i)}function z1(e,t){if(!tr(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=fn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Tn(this,"shape",r),r}});return pn(e,n)}function T1(e,t){const n=fn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Tn(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return pn(e,n)}function A1(e,t,n){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const a=fn(t._zod.def,{get shape(){const o=t._zod.def.shape,l={...o};if(n)for(const u in n){if(!(u in o))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(l[u]=e?new e({type:"optional",innerType:o[u]}):o[u])}else for(const u in o)l[u]=e?new e({type:"optional",innerType:o[u]}):o[u];return Tn(this,"shape",l),l},checks:[]});return pn(t,a)}function P1(e,t,n){const r=fn(t._zod.def,{get shape(){const i=t._zod.def.shape,s={...i};if(n)for(const a in n){if(!(a in s))throw new Error(`Unrecognized key: "${a}"`);n[a]&&(s[a]=new e({type:"nonoptional",innerType:i[a]}))}else for(const a in i)s[a]=new e({type:"nonoptional",innerType:i[a]});return Tn(this,"shape",s),s}});return pn(t,r)}function Jn(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 Hn(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function ui(e){return typeof e=="string"?e:e==null?void 0:e.message}function cn(e,t,n){var i,s,a,o,l,u;const r={...e,path:e.path??[]};if(!e.message){const f=ui((a=(s=(i=e.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:a.call(s,e))??ui((o=t==null?void 0:t.error)==null?void 0:o.call(t,e))??ui((l=n.customError)==null?void 0:l.call(n,e))??ui((u=n.localeError)==null?void 0:u.call(n,e))??"Invalid input";r.message=f}return delete r.inst,delete r.continue,t!=null&&t.reportInput||delete r.input,r}function Io(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Br(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const Dp=(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,Ta,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Rp=V("$ZodError",Dp),Mp=V("$ZodError",Dp,{Parent:Error});function O1(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 D1(e,t=n=>n.message){const n={_errors:[]},r=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>r({issues:a}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)n._errors.push(t(s));else{let a=n,o=0;for(;o<s.path.length;){const l=s.path[o];o===s.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(t(s))):a[l]=a[l]||{_errors:[]},a=a[l],o++}}};return r(e),n}const zo=e=>(t,n,r,i)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},a=t._zod.run({value:n,issues:[]},s);if(a instanceof Promise)throw new Kn;if(a.issues.length){const o=new((i==null?void 0:i.Err)??e)(a.issues.map(l=>cn(l,s,un())));throw Pp(o,i==null?void 0:i.callee),o}return a.value},To=e=>async(t,n,r,i)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let a=t._zod.run({value:n,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){const o=new((i==null?void 0:i.Err)??e)(a.issues.map(l=>cn(l,s,un())));throw Pp(o,i==null?void 0:i.callee),o}return a.value},bs=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 Kn;return s.issues.length?{success:!1,error:new(e??Rp)(s.issues.map(a=>cn(a,i,un())))}:{success:!0,data:s.value}},R1=bs(Mp),vs=e=>async(t,n,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(a=>cn(a,i,un())))}:{success:!0,data:s.value}},M1=vs(Mp),$1=e=>(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return zo(e)(t,n,i)},F1=e=>(t,n,r)=>zo(e)(t,n,r),L1=e=>async(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return To(e)(t,n,i)},Z1=e=>async(t,n,r)=>To(e)(t,n,r),B1=e=>(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return bs(e)(t,n,i)},V1=e=>(t,n,r)=>bs(e)(t,n,r),U1=e=>async(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return vs(e)(t,n,i)},J1=e=>async(t,n,r)=>vs(e)(t,n,r),H1=/^[cC][^\s-]{8,}$/,q1=/^[0-9a-z]+$/,W1=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,G1=/^[0-9a-vA-V]{20}$/,K1=/^[A-Za-z0-9]{27}$/,Y1=/^[a-zA-Z0-9_-]{21}$/,X1=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Q1=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,bu=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,e_=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,t_="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function n_(){return new RegExp(t_,"u")}const r_=/^(?:(?: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])$/,i_=/^(([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}|:))$/,s_=/^((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])$/,a_=/^(([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])$/,o_=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,$p=/^[A-Za-z0-9_-]*$/,l_=/^\+[1-9]\d{6,14}$/,Fp="(?:(?:\\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])))",u_=new RegExp(`^${Fp}$`);function Lp(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 c_(e){return new RegExp(`^${Lp(e)}$`)}function d_(e){const t=Lp({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(`^${Fp}T(?:${r})$`)}const f_=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}$`)},p_=/^-?\d+$/,Zp=/^-?\d+(?:\.\d+)?$/,h_=/^(?:true|false)$/i,m_=/^null$/i,g_=/^[^A-Z]*$/,x_=/^[^a-z]*$/,bt=V("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Bp={number:"number",bigint:"bigint",object:"date"},Vp=V("$ZodCheckLessThan",(e,t)=>{bt.init(e,t);const n=Bp[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})}}),Up=V("$ZodCheckGreaterThan",(e,t)=>{bt.init(e,t);const n=Bp[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})}}),y_=V("$ZodCheckMultipleOf",(e,t)=>{bt.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):w1(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})}}),b_=V("$ZodCheckNumberFormat",(e,t)=>{var a;bt.init(e,t),t.format=t.format||"float64";const n=(a=t.format)==null?void 0:a.includes("int"),r=n?"int":"number",[i,s]=C1[t.format];e._zod.onattach.push(o=>{const l=o._zod.bag;l.format=t.format,l.minimum=i,l.maximum=s,n&&(l.pattern=p_)}),e._zod.check=o=>{const l=o.value;if(n){if(!Number.isInteger(l)){o.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:l,inst:e});return}if(!Number.isSafeInteger(l)){l>0?o.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}l<i&&o.issues.push({origin:"number",input:l,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),l>s&&o.issues.push({origin:"number",input:l,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),v_=V("$ZodCheckMaxLength",(e,t)=>{var n;bt.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!No(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const i=r.value;if(i.length<=t.maximum)return;const a=Io(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),w_=V("$ZodCheckMinLength",(e,t)=>{var n;bt.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!No(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const i=r.value;if(i.length>=t.minimum)return;const a=Io(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),k_=V("$ZodCheckLengthEquals",(e,t)=>{var n;bt.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!No(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=r=>{const i=r.value,s=i.length;if(s===t.length)return;const a=Io(i),o=s>t.length;r.issues.push({origin:a,...o?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),ws=V("$ZodCheckStringFormat",(e,t)=>{var n,r;bt.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=()=>{})}),S_=V("$ZodCheckRegex",(e,t)=>{ws.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})}}),__=V("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=g_),ws.init(e,t)}),j_=V("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=x_),ws.init(e,t)}),C_=V("$ZodCheckIncludes",(e,t)=>{bt.init(e,t);const n=nr(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})}}),N_=V("$ZodCheckStartsWith",(e,t)=>{bt.init(e,t);const n=new RegExp(`^${nr(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})}}),E_=V("$ZodCheckEndsWith",(e,t)=>{bt.init(e,t);const n=new RegExp(`.*${nr(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})}}),I_=V("$ZodCheckOverwrite",(e,t)=>{bt.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class z_{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
33
|
+
`).filter(a=>a),i=Math.min(...r.map(a=>a.length-a.trimStart().length)),s=r.map(a=>a.slice(i)).map(a=>" ".repeat(this.indent*2)+a);for(const a of s)this.content.push(a)}compile(){const t=Function,n=this==null?void 0:this.args,i=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new t(...n,i.join(`
|
|
34
|
+
`))}}const T_={major:4,minor:3,patch:6},Be=V("$ZodType",(e,t)=>{var i;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=T_;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const s of r)for(const a of s._zod.onattach)a(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),(i=e._zod.deferred)==null||i.push(()=>{e._zod.run=e._zod.parse});else{const s=(o,l,u)=>{let f=Jn(o),d;for(const p of l){if(p._zod.def.when){if(!p._zod.def.when(o))continue}else if(f)continue;const h=o.issues.length,m=p._zod.check(o);if(m instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Kn;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await m,o.issues.length!==h&&(f||(f=Jn(o,h)))});else{if(o.issues.length===h)continue;f||(f=Jn(o,h))}}return d?d.then(()=>o):o},a=(o,l,u)=>{if(Jn(o))return o.aborted=!0,o;const f=s(l,r,u);if(f instanceof Promise){if(u.async===!1)throw new Kn;return f.then(d=>e._zod.parse(d,u))}return e._zod.parse(f,u)};e._zod.run=(o,l)=>{if(l.skipChecks)return e._zod.parse(o,l);if(l.direction==="backward"){const f=e._zod.parse({value:o.value,issues:[]},{...l,skipChecks:!0});return f instanceof Promise?f.then(d=>a(d,o,l)):a(f,o,l)}const u=e._zod.parse(o,l);if(u instanceof Promise){if(l.async===!1)throw new Kn;return u.then(f=>s(f,r,l))}return s(u,r,l)}}Ie(e,"~standard",()=>({validate:s=>{var a;try{const o=R1(e,s);return o.success?{value:o.data}:{issues:(a=o.error)==null?void 0:a.issues}}catch{return M1(e,s).then(l=>{var u;return l.success?{value:l.data}:{issues:(u=l.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),Ao=V("$ZodString",(e,t)=>{var n;Be.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??f_(e._zod.bag),e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),Je=V("$ZodStringFormat",(e,t)=>{ws.init(e,t),Ao.init(e,t)}),A_=V("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Q1),Je.init(e,t)}),P_=V("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=bu(r))}else t.pattern??(t.pattern=bu());Je.init(e,t)}),O_=V("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=e_),Je.init(e,t)}),D_=V("$ZodURL",(e,t)=>{Je.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),R_=V("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=n_()),Je.init(e,t)}),M_=V("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Y1),Je.init(e,t)}),$_=V("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=H1),Je.init(e,t)}),F_=V("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=q1),Je.init(e,t)}),L_=V("$ZodULID",(e,t)=>{t.pattern??(t.pattern=W1),Je.init(e,t)}),Z_=V("$ZodXID",(e,t)=>{t.pattern??(t.pattern=G1),Je.init(e,t)}),B_=V("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=K1),Je.init(e,t)}),V_=V("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=d_(t)),Je.init(e,t)}),U_=V("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=u_),Je.init(e,t)}),J_=V("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=c_(t)),Je.init(e,t)}),H_=V("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=X1),Je.init(e,t)}),q_=V("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=r_),Je.init(e,t),e._zod.bag.format="ipv4"}),W_=V("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=i_),Je.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),G_=V("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=s_),Je.init(e,t)}),K_=V("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=a_),Je.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[i,s]=r;if(!s)throw new Error;const a=Number(s);if(`${a}`!==s)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${i}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Jp(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Y_=V("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=o_),Je.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Jp(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function X_(e){if(!$p.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Jp(n)}const Q_=V("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=$p),Je.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{X_(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),ej=V("$ZodE164",(e,t)=>{t.pattern??(t.pattern=l_),Je.init(e,t)});function tj(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 nj=V("$ZodJWT",(e,t)=>{Je.init(e,t),e._zod.check=n=>{tj(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Hp=V("$ZodNumber",(e,t)=>{Be.init(e,t),e._zod.pattern=e._zod.bag.pattern??Zp,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}}),rj=V("$ZodNumberFormat",(e,t)=>{b_.init(e,t),Hp.init(e,t)}),ij=V("$ZodBoolean",(e,t)=>{Be.init(e,t),e._zod.pattern=h_,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}}),sj=V("$ZodNull",(e,t)=>{Be.init(e,t),e._zod.pattern=m_,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}}),aj=V("$ZodUnknown",(e,t)=>{Be.init(e,t),e._zod.parse=n=>n}),oj=V("$ZodNever",(e,t)=>{Be.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(...Hn(n,e.issues)),t.value[n]=e.value}const lj=V("$ZodArray",(e,t)=>{Be.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);const s=[];for(let a=0;a<i.length;a++){const o=i[a],l=t.element._zod.run({value:o,issues:[]},r);l instanceof Promise?s.push(l.then(u=>vu(u,n,a))):vu(l,n,a)}return s.length?Promise.all(s).then(()=>n):n}});function Fi(e,t,n,r,i){if(e.issues.length){if(i&&!(n in r))return;t.issues.push(...Hn(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function qp(e){var r,i,s,a;const t=Object.keys(e.shape);for(const o of t)if(!((a=(s=(i=(r=e.shape)==null?void 0:r[o])==null?void 0:i._zod)==null?void 0:s.traits)!=null&&a.has("$ZodType")))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);const n=j1(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Wp(e,t,n,r,i,s){const a=[],o=i.keySet,l=i.catchall._zod,u=l.def.type,f=l.optout==="optional";for(const d in t){if(o.has(d))continue;if(u==="never"){a.push(d);continue}const p=l.run({value:t[d],issues:[]},r);p instanceof Promise?e.push(p.then(h=>Fi(h,n,d,t,f))):Fi(p,n,d,t,f)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const uj=V("$ZodObject",(e,t)=>{Be.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const o=t.shape;Object.defineProperty(t,"shape",{get:()=>{const l={...o};return Object.defineProperty(t,"shape",{value:l}),l}})}const r=ys(()=>qp(t));Ie(e._zod,"propValues",()=>{const o=t.shape,l={};for(const u in o){const f=o[u]._zod;if(f.values){l[u]??(l[u]=new Set);for(const d of f.values)l[u].add(d)}}return l});const i=Zr,s=t.catchall;let a;e._zod.parse=(o,l)=>{a??(a=r.value);const u=o.value;if(!i(u))return o.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),o;o.value={};const f=[],d=a.shape;for(const p of a.keys){const h=d[p],m=h._zod.optout==="optional",w=h._zod.run({value:u[p],issues:[]},l);w instanceof Promise?f.push(w.then(S=>Fi(S,o,p,u,m))):Fi(w,o,p,u,m)}return s?Wp(f,u,o,l,r.value,e):f.length?Promise.all(f).then(()=>o):o}}),cj=V("$ZodObjectJIT",(e,t)=>{uj.init(e,t);const n=e._zod.parse,r=ys(()=>qp(t)),i=p=>{var g;const h=new z_(["shape","payload","ctx"]),m=r.value,w=T=>{const E=yu(T);return`shape[${E}]._zod.run({ value: input[${E}], issues: [] }, ctx)`};h.write("const input = payload.value;");const S=Object.create(null);let x=0;for(const T of m.keys)S[T]=`key_${x++}`;h.write("const newResult = {};");for(const T of m.keys){const E=S[T],k=yu(T),N=p[T],M=((g=N==null?void 0:N._zod)==null?void 0:g.optout)==="optional";h.write(`const ${E} = ${w(T)};`),M?h.write(`
|
|
35
|
+
if (${E}.issues.length) {
|
|
36
|
+
if (${k} in input) {
|
|
37
|
+
payload.issues = payload.issues.concat(${E}.issues.map(iss => ({
|
|
38
|
+
...iss,
|
|
39
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
40
|
+
})));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (${E}.value === undefined) {
|
|
45
|
+
if (${k} in input) {
|
|
46
|
+
newResult[${k}] = undefined;
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
newResult[${k}] = ${E}.value;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
`):h.write(`
|
|
53
|
+
if (${E}.issues.length) {
|
|
54
|
+
payload.issues = payload.issues.concat(${E}.issues.map(iss => ({
|
|
55
|
+
...iss,
|
|
56
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
57
|
+
})));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (${E}.value === undefined) {
|
|
61
|
+
if (${k} in input) {
|
|
62
|
+
newResult[${k}] = undefined;
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
newResult[${k}] = ${E}.value;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
`)}h.write("payload.value = newResult;"),h.write("return payload;");const _=h.compile();return(T,E)=>_(p,T,E)};let s;const a=Zr,o=!Tp.jitless,u=o&&S1.value,f=t.catchall;let d;e._zod.parse=(p,h)=>{d??(d=r.value);const m=p.value;return a(m)?o&&u&&(h==null?void 0:h.async)===!1&&h.jitless!==!0?(s||(s=i(t.shape)),p=s(p,h),f?Wp([],m,p,h,d,e):p):n(p,h):(p.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),p)}});function wu(e,t,n,r){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const i=e.filter(s=>!Jn(s));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(a=>cn(a,r,un())))}),t)}const Gp=V("$ZodUnion",(e,t)=>{Be.init(e,t),Ie(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),Ie(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),Ie(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),Ie(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){const i=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${i.map(s=>Eo(s.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,s)=>{if(n)return r(i,s);let a=!1;const o=[];for(const l of t.options){const u=l._zod.run({value:i.value,issues:[]},s);if(u instanceof Promise)o.push(u),a=!0;else{if(u.issues.length===0)return u;o.push(u)}}return a?Promise.all(o).then(l=>wu(l,i,e,s)):wu(o,i,e,s)}}),dj=V("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Gp.init(e,t);const n=e._zod.parse;Ie(e._zod,"propValues",()=>{const i={};for(const s of t.options){const a=s._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[o,l]of Object.entries(a)){i[o]||(i[o]=new Set);for(const u of l)i[o].add(u)}}return i});const r=ys(()=>{var a;const i=t.options,s=new Map;for(const o of i){const l=(a=o._zod.propValues)==null?void 0:a[t.discriminator];if(!l||l.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const u of l){if(s.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);s.set(u,o)}}return s});e._zod.parse=(i,s)=>{const a=i.value;if(!Zr(a))return i.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),i;const o=r.value.get(a==null?void 0:a[t.discriminator]);return o?o._zod.run(i,s):t.unionFallback?n(i,s):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),i)}}),fj=V("$ZodIntersection",(e,t)=>{Be.init(e,t),e._zod.parse=(n,r)=>{const i=n.value,s=t.left._zod.run({value:i,issues:[]},r),a=t.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||a instanceof Promise?Promise.all([s,a]).then(([l,u])=>ku(n,l,u)):ku(n,s,a)}});function Aa(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(tr(e)&&tr(t)){const n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),i={...e,...t};for(const s of r){const a=Aa(e[s],t[s]);if(!a.valid)return{valid:!1,mergeErrorPath:[s,...a.mergeErrorPath]};i[s]=a.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const i=e[r],s=t[r],a=Aa(i,s);if(!a.valid)return{valid:!1,mergeErrorPath:[r,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function ku(e,t,n){const r=new Map;let i;for(const o of t.issues)if(o.code==="unrecognized_keys"){i??(i=o);for(const l of o.keys)r.has(l)||r.set(l,{}),r.get(l).l=!0}else e.issues.push(o);for(const o of n.issues)if(o.code==="unrecognized_keys")for(const l of o.keys)r.has(l)||r.set(l,{}),r.get(l).r=!0;else e.issues.push(o);const s=[...r].filter(([,o])=>o.l&&o.r).map(([o])=>o);if(s.length&&i&&e.issues.push({...i,keys:s}),Jn(e))return e;const a=Aa(t.value,n.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}const pj=V("$ZodRecord",(e,t)=>{Be.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!tr(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;const s=[],a=t.keyType._zod.values;if(a){n.value={};const o=new Set;for(const u of a)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){o.add(typeof u=="number"?u.toString():u);const f=t.valueType._zod.run({value:i[u],issues:[]},r);f instanceof Promise?s.push(f.then(d=>{d.issues.length&&n.issues.push(...Hn(u,d.issues)),n.value[u]=d.value})):(f.issues.length&&n.issues.push(...Hn(u,f.issues)),n.value[u]=f.value)}let l;for(const u in i)o.has(u)||(l=l??[],l.push(u));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:l})}else{n.value={};for(const o of Reflect.ownKeys(i)){if(o==="__proto__")continue;let l=t.keyType._zod.run({value:o,issues:[]},r);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof o=="string"&&Zp.test(o)&&l.issues.length){const d=t.keyType._zod.run({value:Number(o),issues:[]},r);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(l=d)}if(l.issues.length){t.mode==="loose"?n.value[o]=i[o]:n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(d=>cn(d,r,un())),input:o,path:[o],inst:e});continue}const f=t.valueType._zod.run({value:i[o],issues:[]},r);f instanceof Promise?s.push(f.then(d=>{d.issues.length&&n.issues.push(...Hn(o,d.issues)),n.value[l.value]=d.value})):(f.issues.length&&n.issues.push(...Hn(o,f.issues)),n.value[l.value]=f.value)}}return s.length?Promise.all(s).then(()=>n):n}}),hj=V("$ZodEnum",(e,t)=>{Be.init(e,t);const n=Ap(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(i=>_1.has(typeof i)).map(i=>typeof i=="string"?nr(i):i.toString()).join("|")})$`),e._zod.parse=(i,s)=>{const a=i.value;return r.has(a)||i.issues.push({code:"invalid_value",values:n,input:a,inst:e}),i}}),mj=V("$ZodLiteral",(e,t)=>{if(Be.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"?nr(r):r?nr(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}}),gj=V("$ZodTransform",(e,t)=>{Be.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new zp(e.constructor.name);const i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(a=>(n.value=a,n));if(i instanceof Promise)throw new Kn;return n.value=i,n}});function Su(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Kp=V("$ZodOptional",(e,t)=>{Be.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Ie(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ie(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Eo(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>Su(s,n.value)):Su(i,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),xj=V("$ZodExactOptional",(e,t)=>{Kp.init(e,t),Ie(e._zod,"values",()=>t.innerType._zod.values),Ie(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),yj=V("$ZodNullable",(e,t)=>{Be.init(e,t),Ie(e._zod,"optin",()=>t.innerType._zod.optin),Ie(e._zod,"optout",()=>t.innerType._zod.optout),Ie(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Eo(n.source)}|null)$`):void 0}),Ie(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),bj=V("$ZodDefault",(e,t)=>{Be.init(e,t),e._zod.optin="optional",Ie(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>_u(s,t)):_u(i,t)}});function _u(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const vj=V("$ZodPrefault",(e,t)=>{Be.init(e,t),e._zod.optin="optional",Ie(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),wj=V("$ZodNonOptional",(e,t)=>{Be.init(e,t),Ie(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>ju(s,e)):ju(i,e)}});function ju(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const kj=V("$ZodCatch",(e,t)=>{Be.init(e,t),Ie(e._zod,"optin",()=>t.innerType._zod.optin),Ie(e._zod,"optout",()=>t.innerType._zod.optout),Ie(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(a=>cn(a,r,un()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(s=>cn(s,r,un()))},input:n.value}),n.issues=[]),n)}}),Sj=V("$ZodPipe",(e,t)=>{Be.init(e,t),Ie(e._zod,"values",()=>t.in._zod.values),Ie(e._zod,"optin",()=>t.in._zod.optin),Ie(e._zod,"optout",()=>t.out._zod.optout),Ie(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(n,r);return s instanceof Promise?s.then(a=>ci(a,t.in,r)):ci(s,t.in,r)}const i=t.in._zod.run(n,r);return i instanceof Promise?i.then(s=>ci(s,t.out,r)):ci(i,t.out,r)}});function ci(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const _j=V("$ZodReadonly",(e,t)=>{Be.init(e,t),Ie(e._zod,"propValues",()=>t.innerType._zod.propValues),Ie(e._zod,"values",()=>t.innerType._zod.values),Ie(e._zod,"optin",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),Ie(e._zod,"optout",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optout}),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(Cu):Cu(i)}});function Cu(e){return e.value=Object.freeze(e.value),e}const jj=V("$ZodLazy",(e,t)=>{Be.init(e,t),Ie(e._zod,"innerType",()=>t.getter()),Ie(e._zod,"pattern",()=>{var n,r;return(r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.pattern}),Ie(e._zod,"propValues",()=>{var n,r;return(r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.propValues}),Ie(e._zod,"optin",()=>{var n,r;return((r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.optin)??void 0}),Ie(e._zod,"optout",()=>{var n,r;return((r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.optout)??void 0}),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),Cj=V("$ZodCustom",(e,t)=>{bt.init(e,t),Be.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=>Nu(s,n,r,e));Nu(i,n,r,e)}});function Nu(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(Br(i))}}var Eu;class Nj{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 Ej(){return new Nj}(Eu=globalThis).__zod_globalRegistry??(Eu.__zod_globalRegistry=Ej());const kr=globalThis.__zod_globalRegistry;function Ij(e,t){return new e({type:"string",...ue(t)})}function zj(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ue(t)})}function Iu(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ue(t)})}function Tj(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ue(t)})}function Aj(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ue(t)})}function Pj(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ue(t)})}function Oj(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ue(t)})}function Dj(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ue(t)})}function Rj(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ue(t)})}function Mj(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ue(t)})}function $j(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ue(t)})}function Fj(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ue(t)})}function Lj(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ue(t)})}function Zj(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ue(t)})}function Bj(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ue(t)})}function Vj(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ue(t)})}function Uj(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ue(t)})}function Jj(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ue(t)})}function Hj(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ue(t)})}function qj(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ue(t)})}function Wj(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ue(t)})}function Gj(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ue(t)})}function Kj(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ue(t)})}function Yj(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ue(t)})}function Xj(e,t){return new e({type:"string",format:"date",check:"string_format",...ue(t)})}function Qj(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ue(t)})}function eC(e,t){return new e({type:"string",format:"duration",check:"string_format",...ue(t)})}function tC(e,t){return new e({type:"number",checks:[],...ue(t)})}function nC(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ue(t)})}function rC(e,t){return new e({type:"boolean",...ue(t)})}function iC(e,t){return new e({type:"null",...ue(t)})}function sC(e){return new e({type:"unknown"})}function aC(e,t){return new e({type:"never",...ue(t)})}function zu(e,t){return new Vp({check:"less_than",...ue(t),value:e,inclusive:!1})}function Qs(e,t){return new Vp({check:"less_than",...ue(t),value:e,inclusive:!0})}function Tu(e,t){return new Up({check:"greater_than",...ue(t),value:e,inclusive:!1})}function ea(e,t){return new Up({check:"greater_than",...ue(t),value:e,inclusive:!0})}function Au(e,t){return new y_({check:"multiple_of",...ue(t),value:e})}function Yp(e,t){return new v_({check:"max_length",...ue(t),maximum:e})}function Li(e,t){return new w_({check:"min_length",...ue(t),minimum:e})}function Xp(e,t){return new k_({check:"length_equals",...ue(t),length:e})}function oC(e,t){return new S_({check:"string_format",format:"regex",...ue(t),pattern:e})}function lC(e){return new __({check:"string_format",format:"lowercase",...ue(e)})}function uC(e){return new j_({check:"string_format",format:"uppercase",...ue(e)})}function cC(e,t){return new C_({check:"string_format",format:"includes",...ue(t),includes:e})}function dC(e,t){return new N_({check:"string_format",format:"starts_with",...ue(t),prefix:e})}function fC(e,t){return new E_({check:"string_format",format:"ends_with",...ue(t),suffix:e})}function ar(e){return new I_({check:"overwrite",tx:e})}function pC(e){return ar(t=>t.normalize(e))}function hC(){return ar(e=>e.trim())}function mC(){return ar(e=>e.toLowerCase())}function gC(){return ar(e=>e.toUpperCase())}function xC(){return ar(e=>k1(e))}function yC(e,t,n){return new e({type:"array",element:t,...ue(n)})}function bC(e,t,n){const r=ue(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function vC(e,t,n){return new e({type:"custom",check:"custom",fn:t,...ue(n)})}function wC(e){const t=kC(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(Br(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(Br(i))}},e(n.value,n)));return t}function kC(e,t){const n=new bt({check:"custom",...ue(t)});return n._zod.check=e,n}function Zi(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)??kr,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 Fe(e,t,n={path:[],schemaPath:[]}){var f,d;var r;const i=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a);const o=(d=(f=e._zod).toJSONSchema)==null?void 0:d.call(f);if(o)a.schema=o;else{const p={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,p);else{const m=a.schema,w=t.processors[i.type];if(!w)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);w(e,t,m,p)}const h=e._zod.parent;h&&(a.ref||(a.ref=h),Fe(h,t,p),t.seen.get(h).isParent=!0)}const l=t.metadataRegistry.get(e);return l&&Object.assign(a.schema,l),t.io==="input"&<(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&a.schema._prefault&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function Bi(e,t){var a,o,l,u;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const f of e.seen.entries()){const d=(a=e.metadataRegistry.get(f[0]))==null?void 0:a.id;if(d){const p=r.get(d);if(p&&p!==f[0])throw new Error(`Duplicate schema id "${d}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(d,f[0])}}const i=f=>{var w;const d=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const S=(w=e.external.registry.get(f[0]))==null?void 0:w.id,x=e.external.uri??(g=>g);if(S)return{ref:x(S)};const _=f[1].defId??f[1].schema.id??`schema${e.counter++}`;return f[1].defId=_,{defId:_,ref:`${x("__shared")}#/${d}/${_}`}}if(f[1]===n)return{ref:"#"};const h=`#/${d}/`,m=f[1].schema.id??`__schema${e.counter++}`;return{defId:m,ref:h+m}},s=f=>{if(f[1].schema.$ref)return;const d=f[1],{ref:p,defId:h}=i(f);d.def={...d.schema},h&&(d.defId=h);const m=d.schema;for(const w in m)delete m[w];m.$ref=p};if(e.cycles==="throw")for(const f of e.seen.entries()){const d=f[1];if(d.cycle)throw new Error(`Cycle detected: #/${(o=d.cycle)==null?void 0:o.join("/")}/<root>
|
|
69
|
+
|
|
70
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const f of e.seen.entries()){const d=f[1];if(t===f[0]){s(f);continue}if(e.external){const h=(l=e.external.registry.get(f[0]))==null?void 0:l.id;if(t!==f[0]&&h){s(f);continue}}if((u=e.metadataRegistry.get(f[0]))==null?void 0:u.id){s(f);continue}if(d.cycle){s(f);continue}if(d.count>1&&e.reused==="ref"){s(f);continue}}}function Vi(e,t){var a,o,l;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=u=>{const f=e.seen.get(u);if(f.ref===null)return;const d=f.def??f.schema,p={...d},h=f.ref;if(f.ref=null,h){r(h);const w=e.seen.get(h),S=w.schema;if(S.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(d.allOf=d.allOf??[],d.allOf.push(S)):Object.assign(d,S),Object.assign(d,p),u._zod.parent===h)for(const _ in d)_==="$ref"||_==="allOf"||_ in p||delete d[_];if(S.$ref&&w.def)for(const _ in d)_==="$ref"||_==="allOf"||_ in w.def&&JSON.stringify(d[_])===JSON.stringify(w.def[_])&&delete d[_]}const m=u._zod.parent;if(m&&m!==h){r(m);const w=e.seen.get(m);if(w!=null&&w.schema.$ref&&(d.$ref=w.schema.$ref,w.def))for(const S in d)S==="$ref"||S==="allOf"||S in w.def&&JSON.stringify(d[S])===JSON.stringify(w.def[S])&&delete d[S]}e.override({zodSchema:u,jsonSchema:d,path:f.path??[]})};for(const u of[...e.seen.entries()].reverse())r(u[0]);const i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":e.target,(a=e.external)!=null&&a.uri){const u=(o=e.external.registry.get(t))==null?void 0:o.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(u)}Object.assign(i,n.def??n.schema);const s=((l=e.external)==null?void 0:l.defs)??{};for(const u of e.seen.entries()){const f=u[1];f.def&&f.defId&&(s[f.defId]=f.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const u=JSON.parse(JSON.stringify(i));return Object.defineProperty(u,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ui(t,"input",e.processors),output:Ui(t,"output",e.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function lt(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return lt(r.element,n);if(r.type==="set")return lt(r.valueType,n);if(r.type==="lazy")return lt(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return lt(r.innerType,n);if(r.type==="intersection")return lt(r.left,n)||lt(r.right,n);if(r.type==="record"||r.type==="map")return lt(r.keyType,n)||lt(r.valueType,n);if(r.type==="pipe")return lt(r.in,n)||lt(r.out,n);if(r.type==="object"){for(const i in r.shape)if(lt(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(lt(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(lt(i,n))return!0;return!!(r.rest&<(r.rest,n))}return!1}const SC=(e,t={})=>n=>{const r=Zi({...n,processors:t});return Fe(e,r),Bi(r,e),Vi(r,e)},Ui=(e,t,n={})=>r=>{const{libraryOptions:i,target:s}=r??{},a=Zi({...i??{},target:s,io:t,processors:n});return Fe(e,a),Bi(a,e),Vi(a,e)},_C={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Qp=(e,t,n,r)=>{const i=n;i.type="string";const{minimum:s,maximum:a,format:o,patterns:l,contentEncoding:u}=e._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof a=="number"&&(i.maxLength=a),o&&(i.format=_C[o]??o,i.format===""&&delete i.format,o==="time"&&delete i.format),u&&(i.contentEncoding=u),l&&l.size>0){const f=[...l];f.length===1?i.pattern=f[0].source:f.length>1&&(i.allOf=[...f.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},eh=(e,t,n,r)=>{const i=n,{minimum:s,maximum:a,format:o,multipleOf:l,exclusiveMaximum:u,exclusiveMinimum:f}=e._zod.bag;typeof o=="string"&&o.includes("int")?i.type="integer":i.type="number",typeof f=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=f,i.exclusiveMinimum=!0):i.exclusiveMinimum=f),typeof s=="number"&&(i.minimum=s,typeof f=="number"&&t.target!=="draft-04"&&(f>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u),typeof a=="number"&&(i.maximum=a,typeof u=="number"&&t.target!=="draft-04"&&(u<=a?delete i.maximum:delete i.exclusiveMaximum)),typeof l=="number"&&(i.multipleOf=l)},th=(e,t,n,r)=>{n.type="boolean"},jC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},CC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},nh=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},NC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},EC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},rh=(e,t,n,r)=>{n.not={}},IC=(e,t,n,r)=>{},ih=(e,t,n,r)=>{},zC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},sh=(e,t,n,r)=>{const i=e._zod.def,s=Ap(i.entries);s.every(a=>typeof a=="number")&&(n.type="number"),s.every(a=>typeof a=="string")&&(n.type="string"),n.enum=s},ah=(e,t,n,r)=>{const i=e._zod.def,s=[];for(const a of i.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(a))}else s.push(a);if(s.length!==0)if(s.length===1){const a=s[0];n.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[a]:n.const=a}else s.every(a=>typeof a=="number")&&(n.type="number"),s.every(a=>typeof a=="string")&&(n.type="string"),s.every(a=>typeof a=="boolean")&&(n.type="boolean"),s.every(a=>a===null)&&(n.type="null"),n.enum=s},TC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},AC=(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},PC=(e,t,n,r)=>{const i=n,s={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:o,mime:l}=e._zod.bag;a!==void 0&&(s.minLength=a),o!==void 0&&(s.maxLength=o),l?l.length===1?(s.contentMediaType=l[0],Object.assign(i,s)):(Object.assign(i,s),i.anyOf=l.map(u=>({contentMediaType:u}))):Object.assign(i,s)},OC=(e,t,n,r)=>{n.type="boolean"},oh=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},DC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},lh=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},RC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},MC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},uh=(e,t,n,r)=>{const i=n,s=e._zod.def,{minimum:a,maximum:o}=e._zod.bag;typeof a=="number"&&(i.minItems=a),typeof o=="number"&&(i.maxItems=o),i.type="array",i.items=Fe(s.element,t,{...r,path:[...r.path,"items"]})},ch=(e,t,n,r)=>{var u;const i=n,s=e._zod.def;i.type="object",i.properties={};const a=s.shape;for(const f in a)i.properties[f]=Fe(a[f],t,{...r,path:[...r.path,"properties",f]});const o=new Set(Object.keys(a)),l=new Set([...o].filter(f=>{const d=s.shape[f]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));l.size>0&&(i.required=Array.from(l)),((u=s.catchall)==null?void 0:u._zod.def.type)==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=Fe(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},dh=(e,t,n,r)=>{const i=e._zod.def,s=i.inclusive===!1,a=i.options.map((o,l)=>Fe(o,t,{...r,path:[...r.path,s?"oneOf":"anyOf",l]}));s?n.oneOf=a:n.anyOf=a},fh=(e,t,n,r)=>{const i=e._zod.def,s=Fe(i.left,t,{...r,path:[...r.path,"allOf",0]}),a=Fe(i.right,t,{...r,path:[...r.path,"allOf",1]}),o=u=>"allOf"in u&&Object.keys(u).length===1,l=[...o(s)?s.allOf:[s],...o(a)?a.allOf:[a]];n.allOf=l},$C=(e,t,n,r)=>{const i=n,s=e._zod.def;i.type="array";const a=t.target==="draft-2020-12"?"prefixItems":"items",o=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",l=s.items.map((p,h)=>Fe(p,t,{...r,path:[...r.path,a,h]})),u=s.rest?Fe(s.rest,t,{...r,path:[...r.path,o,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null;t.target==="draft-2020-12"?(i.prefixItems=l,u&&(i.items=u)):t.target==="openapi-3.0"?(i.items={anyOf:l},u&&i.items.anyOf.push(u),i.minItems=l.length,u||(i.maxItems=l.length)):(i.items=l,u&&(i.additionalItems=u));const{minimum:f,maximum:d}=e._zod.bag;typeof f=="number"&&(i.minItems=f),typeof d=="number"&&(i.maxItems=d)},ph=(e,t,n,r)=>{const i=n,s=e._zod.def;i.type="object";const a=s.keyType,o=a._zod.bag,l=o==null?void 0:o.patterns;if(s.mode==="loose"&&l&&l.size>0){const f=Fe(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const d of l)i.patternProperties[d.source]=f}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=Fe(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=Fe(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const u=a._zod.values;if(u){const f=[...u].filter(d=>typeof d=="string"||typeof d=="number");f.length>0&&(i.required=f)}},hh=(e,t,n,r)=>{const i=e._zod.def,s=Fe(i.innerType,t,r),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=i.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},mh=(e,t,n,r)=>{const i=e._zod.def;Fe(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},gh=(e,t,n,r)=>{const i=e._zod.def;Fe(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},xh=(e,t,n,r)=>{const i=e._zod.def;Fe(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)))},yh=(e,t,n,r)=>{const i=e._zod.def;Fe(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType;let a;try{a=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=a},bh=(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;Fe(s,t,r);const a=t.seen.get(e);a.ref=s},vh=(e,t,n,r)=>{const i=e._zod.def;Fe(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,n.readOnly=!0},FC=(e,t,n,r)=>{const i=e._zod.def;Fe(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},Po=(e,t,n,r)=>{const i=e._zod.def;Fe(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},wh=(e,t,n,r)=>{const i=e._zod.innerType;Fe(i,t,r);const s=t.seen.get(e);s.ref=i},Pu={string:Qp,number:eh,boolean:th,bigint:jC,symbol:CC,null:nh,undefined:NC,void:EC,never:rh,any:IC,unknown:ih,date:zC,enum:sh,literal:ah,nan:TC,template_literal:AC,file:PC,success:OC,custom:oh,function:DC,transform:lh,map:RC,set:MC,array:uh,object:ch,union:dh,intersection:fh,tuple:$C,record:ph,nullable:hh,nonoptional:mh,default:gh,prefault:xh,catch:yh,pipe:bh,readonly:vh,promise:FC,optional:Po,lazy:wh};function LC(e,t){if("_idmap"in e){const r=e,i=Zi({...t,processors:Pu}),s={};for(const l of r._idmap.entries()){const[u,f]=l;Fe(f,i)}const a={},o={registry:r,uri:t==null?void 0:t.uri,defs:s};i.external=o;for(const l of r._idmap.entries()){const[u,f]=l;Bi(i,f),a[u]=Vi(i,f)}if(Object.keys(s).length>0){const l=i.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[l]:s}}return{schemas:a}}const n=Zi({...t,processors:Pu});return Fe(e,n),Bi(n,e),Vi(n,e)}const ZC=V("ZodISODateTime",(e,t)=>{V_.init(e,t),He.init(e,t)});function BC(e){return Yj(ZC,e)}const VC=V("ZodISODate",(e,t)=>{U_.init(e,t),He.init(e,t)});function UC(e){return Xj(VC,e)}const JC=V("ZodISOTime",(e,t)=>{J_.init(e,t),He.init(e,t)});function HC(e){return Qj(JC,e)}const qC=V("ZodISODuration",(e,t)=>{H_.init(e,t),He.init(e,t)});function WC(e){return eC(qC,e)}const GC=(e,t)=>{Rp.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>D1(e,n)},flatten:{value:n=>O1(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Ta,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Ta,2)}},isEmpty:{get(){return e.issues.length===0}}})},It=V("ZodError",GC,{Parent:Error}),KC=zo(It),YC=To(It),XC=bs(It),kh=vs(It),QC=$1(It),eN=F1(It),tN=L1(It),nN=Z1(It),rN=B1(It),iN=V1(It),sN=U1(It),aN=J1(It),Ve=V("ZodType",(e,t)=>(Be.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Ui(e,"input"),output:Ui(e,"output")}}),e.toJSONSchema=SC(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(fn(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)=>pn(e,n,r),e.brand=()=>e,e.register=(n,r)=>(n.add(e,r),e),e.parse=(n,r)=>KC(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>XC(e,n,r),e.parseAsync=async(n,r)=>YC(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>kh(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>QC(e,n,r),e.decode=(n,r)=>eN(e,n,r),e.encodeAsync=async(n,r)=>tN(e,n,r),e.decodeAsync=async(n,r)=>nN(e,n,r),e.safeEncode=(n,r)=>rN(e,n,r),e.safeDecode=(n,r)=>iN(e,n,r),e.safeEncodeAsync=async(n,r)=>sN(e,n,r),e.safeDecodeAsync=async(n,r)=>aN(e,n,r),e.refine=(n,r)=>e.check(nE(n,r)),e.superRefine=n=>e.check(rE(n)),e.overwrite=n=>e.check(ar(n)),e.optional=()=>Ru(e),e.exactOptional=()=>BN(e),e.nullable=()=>Mu(e),e.nullish=()=>Ru(Mu(e)),e.nonoptional=n=>WN(e,n),e.array=()=>or(e),e.or=n=>ft([e,n]),e.and=n=>RN(e,n),e.transform=n=>$u(e,LN(n)),e.default=n=>JN(e,n),e.prefault=n=>qN(e,n),e.catch=n=>KN(e,n),e.pipe=n=>$u(e,n),e.readonly=()=>QN(e),e.describe=n=>{const r=e.clone();return kr.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){var n;return(n=kr.get(e))==null?void 0:n.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return kr.get(e);const r=e.clone();return kr.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),Sh=V("_ZodString",(e,t)=>{Ao.init(e,t),Ve.init(e,t),e._zod.processJSONSchema=(r,i,s)=>Qp(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(oC(...r)),e.includes=(...r)=>e.check(cC(...r)),e.startsWith=(...r)=>e.check(dC(...r)),e.endsWith=(...r)=>e.check(fC(...r)),e.min=(...r)=>e.check(Li(...r)),e.max=(...r)=>e.check(Yp(...r)),e.length=(...r)=>e.check(Xp(...r)),e.nonempty=(...r)=>e.check(Li(1,...r)),e.lowercase=r=>e.check(lC(r)),e.uppercase=r=>e.check(uC(r)),e.trim=()=>e.check(hC()),e.normalize=(...r)=>e.check(pC(...r)),e.toLowerCase=()=>e.check(mC()),e.toUpperCase=()=>e.check(gC()),e.slugify=()=>e.check(xC())}),oN=V("ZodString",(e,t)=>{Ao.init(e,t),Sh.init(e,t),e.email=n=>e.check(zj(lN,n)),e.url=n=>e.check(Dj(uN,n)),e.jwt=n=>e.check(Kj(_N,n)),e.emoji=n=>e.check(Rj(cN,n)),e.guid=n=>e.check(Iu(Ou,n)),e.uuid=n=>e.check(Tj(di,n)),e.uuidv4=n=>e.check(Aj(di,n)),e.uuidv6=n=>e.check(Pj(di,n)),e.uuidv7=n=>e.check(Oj(di,n)),e.nanoid=n=>e.check(Mj(dN,n)),e.guid=n=>e.check(Iu(Ou,n)),e.cuid=n=>e.check($j(fN,n)),e.cuid2=n=>e.check(Fj(pN,n)),e.ulid=n=>e.check(Lj(hN,n)),e.base64=n=>e.check(qj(wN,n)),e.base64url=n=>e.check(Wj(kN,n)),e.xid=n=>e.check(Zj(mN,n)),e.ksuid=n=>e.check(Bj(gN,n)),e.ipv4=n=>e.check(Vj(xN,n)),e.ipv6=n=>e.check(Uj(yN,n)),e.cidrv4=n=>e.check(Jj(bN,n)),e.cidrv6=n=>e.check(Hj(vN,n)),e.e164=n=>e.check(Gj(SN,n)),e.datetime=n=>e.check(BC(n)),e.date=n=>e.check(UC(n)),e.time=n=>e.check(HC(n)),e.duration=n=>e.check(WC(n))});function ie(e){return Ij(oN,e)}const He=V("ZodStringFormat",(e,t)=>{Je.init(e,t),Sh.init(e,t)}),lN=V("ZodEmail",(e,t)=>{O_.init(e,t),He.init(e,t)}),Ou=V("ZodGUID",(e,t)=>{A_.init(e,t),He.init(e,t)}),di=V("ZodUUID",(e,t)=>{P_.init(e,t),He.init(e,t)}),uN=V("ZodURL",(e,t)=>{D_.init(e,t),He.init(e,t)}),cN=V("ZodEmoji",(e,t)=>{R_.init(e,t),He.init(e,t)}),dN=V("ZodNanoID",(e,t)=>{M_.init(e,t),He.init(e,t)}),fN=V("ZodCUID",(e,t)=>{$_.init(e,t),He.init(e,t)}),pN=V("ZodCUID2",(e,t)=>{F_.init(e,t),He.init(e,t)}),hN=V("ZodULID",(e,t)=>{L_.init(e,t),He.init(e,t)}),mN=V("ZodXID",(e,t)=>{Z_.init(e,t),He.init(e,t)}),gN=V("ZodKSUID",(e,t)=>{B_.init(e,t),He.init(e,t)}),xN=V("ZodIPv4",(e,t)=>{q_.init(e,t),He.init(e,t)}),yN=V("ZodIPv6",(e,t)=>{W_.init(e,t),He.init(e,t)}),bN=V("ZodCIDRv4",(e,t)=>{G_.init(e,t),He.init(e,t)}),vN=V("ZodCIDRv6",(e,t)=>{K_.init(e,t),He.init(e,t)}),wN=V("ZodBase64",(e,t)=>{Y_.init(e,t),He.init(e,t)}),kN=V("ZodBase64URL",(e,t)=>{Q_.init(e,t),He.init(e,t)}),SN=V("ZodE164",(e,t)=>{ej.init(e,t),He.init(e,t)}),_N=V("ZodJWT",(e,t)=>{nj.init(e,t),He.init(e,t)}),_h=V("ZodNumber",(e,t)=>{Hp.init(e,t),Ve.init(e,t),e._zod.processJSONSchema=(r,i,s)=>eh(e,r,i),e.gt=(r,i)=>e.check(Tu(r,i)),e.gte=(r,i)=>e.check(ea(r,i)),e.min=(r,i)=>e.check(ea(r,i)),e.lt=(r,i)=>e.check(zu(r,i)),e.lte=(r,i)=>e.check(Qs(r,i)),e.max=(r,i)=>e.check(Qs(r,i)),e.int=r=>e.check(Du(r)),e.safe=r=>e.check(Du(r)),e.positive=r=>e.check(Tu(0,r)),e.nonnegative=r=>e.check(ea(0,r)),e.negative=r=>e.check(zu(0,r)),e.nonpositive=r=>e.check(Qs(0,r)),e.multipleOf=(r,i)=>e.check(Au(r,i)),e.step=(r,i)=>e.check(Au(r,i)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function jN(e){return tC(_h,e)}const CN=V("ZodNumberFormat",(e,t)=>{rj.init(e,t),_h.init(e,t)});function Du(e){return nC(CN,e)}const NN=V("ZodBoolean",(e,t)=>{ij.init(e,t),Ve.init(e,t),e._zod.processJSONSchema=(n,r,i)=>th(e,n,r)});function ut(e){return rC(NN,e)}const EN=V("ZodNull",(e,t)=>{sj.init(e,t),Ve.init(e,t),e._zod.processJSONSchema=(n,r,i)=>nh(e,n,r)});function IN(e){return iC(EN,e)}const zN=V("ZodUnknown",(e,t)=>{aj.init(e,t),Ve.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ih()});function Lt(){return sC(zN)}const TN=V("ZodNever",(e,t)=>{oj.init(e,t),Ve.init(e,t),e._zod.processJSONSchema=(n,r,i)=>rh(e,n,r)});function jh(e){return aC(TN,e)}const AN=V("ZodArray",(e,t)=>{lj.init(e,t),Ve.init(e,t),e._zod.processJSONSchema=(n,r,i)=>uh(e,n,r,i),e.element=t.element,e.min=(n,r)=>e.check(Li(n,r)),e.nonempty=n=>e.check(Li(1,n)),e.max=(n,r)=>e.check(Yp(n,r)),e.length=(n,r)=>e.check(Xp(n,r)),e.unwrap=()=>e.element});function or(e,t){return yC(AN,e,t)}const Ch=V("ZodObject",(e,t)=>{cj.init(e,t),Ve.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ch(e,n,r,i),Ie(e,"shape",()=>t.shape),e.keyof=()=>Eh(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Lt()}),e.loose=()=>e.clone({...e._zod.def,catchall:Lt()}),e.strict=()=>e.clone({...e._zod.def,catchall:jh()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>I1(e,n),e.safeExtend=n=>z1(e,n),e.merge=n=>T1(e,n),e.pick=n=>N1(e,n),e.omit=n=>E1(e,n),e.partial=(...n)=>A1(Ih,e,n[0]),e.required=(...n)=>P1(zh,e,n[0])});function De(e,t){const n={type:"object",shape:e??{},...ue(t)};return new Ch(n)}function Le(e,t){return new Ch({type:"object",shape:e,catchall:jh(),...ue(t)})}const Nh=V("ZodUnion",(e,t)=>{Gp.init(e,t),Ve.init(e,t),e._zod.processJSONSchema=(n,r,i)=>dh(e,n,r,i),e.options=t.options});function ft(e,t){return new Nh({type:"union",options:e,...ue(t)})}const PN=V("ZodDiscriminatedUnion",(e,t)=>{Nh.init(e,t),dj.init(e,t)});function ON(e,t,n){return new PN({type:"union",options:t,discriminator:e,...ue(n)})}const DN=V("ZodIntersection",(e,t)=>{fj.init(e,t),Ve.init(e,t),e._zod.processJSONSchema=(n,r,i)=>fh(e,n,r,i)});function RN(e,t){return new DN({type:"intersection",left:e,right:t})}const MN=V("ZodRecord",(e,t)=>{pj.init(e,t),Ve.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ph(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function Vr(e,t,n){return new MN({type:"record",keyType:e,valueType:t,...ue(n)})}const Pa=V("ZodEnum",(e,t)=>{hj.init(e,t),Ve.init(e,t),e._zod.processJSONSchema=(r,i,s)=>sh(e,r,i),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,i)=>{const s={};for(const a of r)if(n.has(a))s[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Pa({...t,checks:[],...ue(i),entries:s})},e.exclude=(r,i)=>{const s={...t.entries};for(const a of r)if(n.has(a))delete s[a];else throw new Error(`Key ${a} not found in enum`);return new Pa({...t,checks:[],...ue(i),entries:s})}});function Eh(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Pa({type:"enum",entries:n,...ue(t)})}const $N=V("ZodLiteral",(e,t)=>{mj.init(e,t),Ve.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ah(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 ge(e,t){return new $N({type:"literal",values:Array.isArray(e)?e:[e],...ue(t)})}const FN=V("ZodTransform",(e,t)=>{gj.init(e,t),Ve.init(e,t),e._zod.processJSONSchema=(n,r,i)=>lh(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new zp(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(Br(s,n.value,t));else{const a=s;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=n.value),a.inst??(a.inst=e),n.issues.push(Br(a))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(s=>(n.value=s,n)):(n.value=i,n)}});function LN(e){return new FN({type:"transform",transform:e})}const Ih=V("ZodOptional",(e,t)=>{Kp.init(e,t),Ve.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Po(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Ru(e){return new Ih({type:"optional",innerType:e})}const ZN=V("ZodExactOptional",(e,t)=>{xj.init(e,t),Ve.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Po(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function BN(e){return new ZN({type:"optional",innerType:e})}const VN=V("ZodNullable",(e,t)=>{yj.init(e,t),Ve.init(e,t),e._zod.processJSONSchema=(n,r,i)=>hh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Mu(e){return new VN({type:"nullable",innerType:e})}const UN=V("ZodDefault",(e,t)=>{bj.init(e,t),Ve.init(e,t),e._zod.processJSONSchema=(n,r,i)=>gh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function JN(e,t){return new UN({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Op(t)}})}const HN=V("ZodPrefault",(e,t)=>{vj.init(e,t),Ve.init(e,t),e._zod.processJSONSchema=(n,r,i)=>xh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function qN(e,t){return new HN({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Op(t)}})}const zh=V("ZodNonOptional",(e,t)=>{wj.init(e,t),Ve.init(e,t),e._zod.processJSONSchema=(n,r,i)=>mh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function WN(e,t){return new zh({type:"nonoptional",innerType:e,...ue(t)})}const GN=V("ZodCatch",(e,t)=>{kj.init(e,t),Ve.init(e,t),e._zod.processJSONSchema=(n,r,i)=>yh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function KN(e,t){return new GN({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const YN=V("ZodPipe",(e,t)=>{Sj.init(e,t),Ve.init(e,t),e._zod.processJSONSchema=(n,r,i)=>bh(e,n,r,i),e.in=t.in,e.out=t.out});function $u(e,t){return new YN({type:"pipe",in:e,out:t})}const XN=V("ZodReadonly",(e,t)=>{_j.init(e,t),Ve.init(e,t),e._zod.processJSONSchema=(n,r,i)=>vh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function QN(e){return new XN({type:"readonly",innerType:e})}const eE=V("ZodLazy",(e,t)=>{jj.init(e,t),Ve.init(e,t),e._zod.processJSONSchema=(n,r,i)=>wh(e,n,r,i),e.unwrap=()=>e._zod.def.getter()});function tE(e){return new eE({type:"lazy",getter:e})}const Oo=V("ZodCustom",(e,t)=>{Cj.init(e,t),Ve.init(e,t),e._zod.processJSONSchema=(n,r,i)=>oh(e,n)});function Th(e,t){return bC(Oo,e??(()=>!0),t)}function nE(e,t={}){return vC(Oo,e,t)}function rE(e){return wC(e)}function Ji(e,t={}){const n=new Oo({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...ue(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 Ur;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function n(i){throw new Error}e.assertNever=n,e.arrayToEnum=i=>{const s={};for(const a of i)s[a]=a;return s},e.getValidEnumValues=i=>{const s=e.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),a={};for(const o of s)a[o]=i[o];return e.objectValues(a)},e.objectValues=i=>e.objectKeys(i).map(function(s){return i[s]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},e.find=(i,s)=>{for(const a of i)if(s(a))return a},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}e.joinValues=r,e.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Ur||(Ur={}));var Fu;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(Fu||(Fu={}));Ur.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);Ur.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 Hi extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(s){return s.message},r={_errors:[]},i=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let o=r,l=0;for(;l<a.path.length;){const u=a.path[l];l===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(n(a))):o[u]=o[u]||{_errors:[]},o=o[u],l++}}};return i(this),r}static assert(t){if(!(t instanceof Hi))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ur.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()}}Hi.create=e=>new Hi(e);var Lu;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Lu||(Lu={}));var ye;(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"})(ye||(ye={}));class Zu extends Error{constructor(t,n){super(t),this.name="ParseError",this.type=n.type,this.field=n.field,this.value=n.value,this.line=n.line}}function ta(e){}function iE(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=ta,onError:n=ta,onRetry:r=ta,onComment:i}=e;let s="",a=!0,o,l="",u="";function f(w){const S=a?w.replace(/^\xEF\xBB\xBF/,""):w,[x,_]=sE(`${s}${S}`);for(const g of x)d(g);s=_,a=!1}function d(w){if(w===""){h();return}if(w.startsWith(":")){i&&i(w.slice(w.startsWith(": ")?2:1));return}const S=w.indexOf(":");if(S!==-1){const x=w.slice(0,S),_=w[S+1]===" "?2:1,g=w.slice(S+_);p(x,g,w);return}p(w,"",w)}function p(w,S,x){switch(w){case"event":u=S;break;case"data":l=`${l}${S}
|
|
71
|
+
`;break;case"id":o=S.includes("\0")?void 0:S;break;case"retry":/^\d+$/.test(S)?r(parseInt(S,10)):n(new Zu(`Invalid \`retry\` value: "${S}"`,{type:"invalid-retry",value:S,line:x}));break;default:n(new Zu(`Unknown field "${w.length>20?`${w.slice(0,20)}…`:w}"`,{type:"unknown-field",field:w,value:S,line:x}));break}}function h(){l.length>0&&t({id:o,event:u||void 0,data:l.endsWith(`
|
|
72
|
+
`)?l.slice(0,-1):l}),o=void 0,l="",u=""}function m(w={}){s&&w.consume&&d(s),a=!0,o=void 0,l="",u="",s=""}return{feed:f,reset:m}}function sE(e){const t=[];let n="",r=0;for(;r<e.length;){const i=e.indexOf("\r",r),s=e.indexOf(`
|
|
73
|
+
`,r);let a=-1;if(i!==-1&&s!==-1?a=Math.min(i,s):i!==-1?i===e.length-1?a=-1:a=i:s!==-1&&(a=s),a===-1){n=e.slice(r);break}else{const o=e.slice(r,a);t.push(o),r=a+1,e[r-1]==="\r"&&e[r]===`
|
|
74
|
+
`&&r++}}return[t,n]}class aE extends TransformStream{constructor({onError:t,onRetry:n,onComment:r}={}){let i;super({start(s){i=iE({onEvent:a=>{s.enqueue(a)},onError(a){t==="terminate"?s.error(a):typeof t=="function"&&t(a)},onRetry:n,onComment:r})},transform(s){i.feed(s)}})}}var Xr=({prefix:e,size:t=16,alphabet:n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:r="-"}={})=>{const i=()=>{const s=n.length,a=new Array(t);for(let o=0;o<t;o++)a[o]=n[Math.random()*s|0];return a.join("")};if(e==null)return i;if(n.includes(r))throw new y1({argument:"separator",message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`},oE=Xr();function Mn(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 lE=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,uE=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function Bu(e){const t=JSON.parse(e);return t===null||typeof t!="object"||lE.test(e)===!1&&uE.test(e)===!1?t:cE(t)}function cE(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 dE(e){const{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return Bu(e)}try{return Bu(e)}finally{Error.stackTraceLimit=t}}function Do(e){if(e.type==="object"||Array.isArray(e.type)&&e.type.includes("object")){e.additionalProperties=!1;const{properties:n}=e;if(n!=null)for(const r of Object.keys(n))n[r]=gn(n[r])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(gn):gn(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(gn)),e.allOf!=null&&(e.allOf=e.allOf.map(gn)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(gn));const{definitions:t}=e;if(t!=null)for(const n of Object.keys(t))t[n]=gn(t[n]);return e}function gn(e){return typeof e=="boolean"?e:Do(e)}var fE=Symbol("Let zodToJsonSchema decide on which parser to use"),Vu={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},pE=e=>typeof e=="string"?{...Vu,name:e}:{...Vu,...e};function _t(){return{}}function hE(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)!==ye.ZodAny&&(s.items=Pe(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&(s.minItems=e.minLength.value),e.maxLength&&(s.maxItems=e.maxLength.value),e.exactLength&&(s.minItems=e.exactLength.value,s.maxItems=e.exactLength.value),s}function mE(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 gE(){return{type:"boolean"}}function Ah(e,t){return Pe(e.type._def,t)}var xE=(e,t)=>Pe(e.innerType._def,t);function Ph(e,t,n){const r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((i,s)=>Ph(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 yE(e)}}var yE=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 bE(e,t){return{...Pe(e.innerType._def,t),default:e.defaultValue()}}function vE(e,t){return t.effectStrategy==="input"?Pe(e.schema._def,t):_t()}function wE(e){return{type:"string",enum:Array.from(e.values)}}var kE=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function SE(e,t){const n=[Pe(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),Pe(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(i=>!!i),r=[];return n.forEach(i=>{if(kE(i))r.push(...i.allOf);else{let s=i;if("additionalProperties"in i&&i.additionalProperties===!1){const{additionalProperties:a,...o}=i;s=o}r.push(s)}}),r.length?{allOf:r}:void 0}function _E(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 na=void 0,zt={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:()=>(na===void 0&&(na=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),na),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 Oh(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":Tt(n,"email",r.message,t);break;case"format:idn-email":Tt(n,"idn-email",r.message,t);break;case"pattern:zod":ot(n,zt.email,r.message,t);break}break;case"url":Tt(n,"uri",r.message,t);break;case"uuid":Tt(n,"uuid",r.message,t);break;case"regex":ot(n,r.regex,r.message,t);break;case"cuid":ot(n,zt.cuid,r.message,t);break;case"cuid2":ot(n,zt.cuid2,r.message,t);break;case"startsWith":ot(n,RegExp(`^${ra(r.value,t)}`),r.message,t);break;case"endsWith":ot(n,RegExp(`${ra(r.value,t)}$`),r.message,t);break;case"datetime":Tt(n,"date-time",r.message,t);break;case"date":Tt(n,"date",r.message,t);break;case"time":Tt(n,"time",r.message,t);break;case"duration":Tt(n,"duration",r.message,t);break;case"length":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value,n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value;break;case"includes":{ot(n,RegExp(ra(r.value,t)),r.message,t);break}case"ip":{r.version!=="v6"&&Tt(n,"ipv4",r.message,t),r.version!=="v4"&&Tt(n,"ipv6",r.message,t);break}case"base64url":ot(n,zt.base64url,r.message,t);break;case"jwt":ot(n,zt.jwt,r.message,t);break;case"cidr":{r.version!=="v6"&&ot(n,zt.ipv4Cidr,r.message,t),r.version!=="v4"&&ot(n,zt.ipv6Cidr,r.message,t);break}case"emoji":ot(n,zt.emoji(),r.message,t);break;case"ulid":{ot(n,zt.ulid,r.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{Tt(n,"binary",r.message,t);break}case"contentEncoding:base64":{n.contentEncoding="base64";break}case"pattern:zod":{ot(n,zt.base64,r.message,t);break}}break}case"nanoid":ot(n,zt.nanoid,r.message,t)}return n}function ra(e,t){return t.patternStrategy==="escape"?CE(e):e}var jE=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function CE(e){let t="";for(let n=0;n<e.length;n++)jE.has(e[n])||(t+="\\"),t+=e[n];return t}function Tt(e,t,n,r){var i;e.format||(i=e.anyOf)!=null&&i.some(s=>s.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):e.format=t}function ot(e,t,n,r){var i;e.pattern||(i=e.allOf)!=null&&i.some(s=>s.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:Uu(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=Uu(t,r)}function Uu(e,t){var n;if(!t.applyRegexFlags||!e.flags)return e.source;const r={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},i=r.i?e.source.toLowerCase():e.source;let s="",a=!1,o=!1,l=!1;for(let u=0;u<i.length;u++){if(a){s+=i[u],a=!1;continue}if(r.i){if(o){if(i[u].match(/[a-z]/)){l?(s+=i[u],s+=`${i[u-2]}-${i[u]}`.toUpperCase(),l=!1):i[u+1]==="-"&&((n=i[u+2])!=null&&n.match(/[a-z]/))?(s+=i[u],l=!0):s+=`${i[u]}${i[u].toUpperCase()}`;continue}}else if(i[u].match(/[a-z]/)){s+=`[${i[u]}${i[u].toUpperCase()}]`;continue}}if(r.m){if(i[u]==="^"){s+=`(^|(?<=[\r
|
|
75
|
+
]))`;continue}else if(i[u]==="$"){s+=`($|(?=[\r
|
|
76
|
+
]))`;continue}}if(r.s&&i[u]==="."){s+=o?`${i[u]}\r
|
|
77
|
+
`:`[${i[u]}\r
|
|
78
|
+
]`;continue}s+=i[u],i[u]==="\\"?a=!0:o&&i[u]==="]"?o=!1:!o&&i[u]==="["&&(o=!0)}try{new RegExp(s)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return s}function Dh(e,t){var n,r,i,s,a,o;const l={type:"object",additionalProperties:(n=Pe(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?n:t.allowedAdditionalProperties};if(((r=e.keyType)==null?void 0:r._def.typeName)===ye.ZodString&&((i=e.keyType._def.checks)!=null&&i.length)){const{type:u,...f}=Oh(e.keyType._def,t);return{...l,propertyNames:f}}else{if(((s=e.keyType)==null?void 0:s._def.typeName)===ye.ZodEnum)return{...l,propertyNames:{enum:e.keyType._def.values}};if(((a=e.keyType)==null?void 0:a._def.typeName)===ye.ZodBranded&&e.keyType._def.type._def.typeName===ye.ZodString&&((o=e.keyType._def.type._def.checks)!=null&&o.length)){const{type:u,...f}=Ah(e.keyType._def,t);return{...l,propertyNames:f}}}return l}function NE(e,t){if(t.mapStrategy==="record")return Dh(e,t);const n=Pe(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||_t(),r=Pe(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||_t();return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}function EE(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 IE(){return{not:_t()}}function zE(){return{type:"null"}}var Oa={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function TE(e,t){const n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(r=>r._def.typeName in Oa&&(!r._def.checks||!r._def.checks.length))){const r=n.reduce((i,s)=>{const a=Oa[s._def.typeName];return a&&!i.includes(a)?[...i,a]:i},[]);return{type:r.length>1?r:r[0]}}else if(n.every(r=>r._def.typeName==="ZodLiteral"&&!r.description)){const r=n.reduce((i,s)=>{const a=typeof s._def.value;switch(a){case"string":case"number":case"boolean":return[...i,a];case"bigint":return[...i,"integer"];case"object":if(s._def.value===null)return[...i,"null"];case"symbol":case"undefined":case"function":default:return i}},[]);if(r.length===n.length){const i=r.filter((s,a,o)=>o.indexOf(s)===a);return{type:i.length>1?i:i[0],enum:n.reduce((s,a)=>s.includes(a._def.value)?s:[...s,a._def.value],[])}}}else if(n.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((r,i)=>[...r,...i._def.values.filter(s=>!r.includes(s))],[])};return AE(e,t)}var AE=(e,t)=>{const n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((r,i)=>Pe(r._def,{...t,currentPath:[...t.currentPath,"anyOf",`${i}`]})).filter(r=>!!r&&(!t.strictUnions||typeof r=="object"&&Object.keys(r).length>0));return n.length?{anyOf:n}:void 0};function PE(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[Oa[e.innerType._def.typeName],"null"]};const n=Pe(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function OE(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 DE(e,t){const n={type:"object",properties:{}},r=[],i=e.shape();for(const a in i){let o=i[a];if(o===void 0||o._def===void 0)continue;const l=ME(o),u=Pe(o._def,{...t,currentPath:[...t.currentPath,"properties",a],propertyPath:[...t.currentPath,"properties",a]});u!==void 0&&(n.properties[a]=u,l||r.push(a))}r.length&&(n.required=r);const s=RE(e,t);return s!==void 0&&(n.additionalProperties=s),n}function RE(e,t){if(e.catchall._def.typeName!=="ZodNever")return Pe(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function ME(e){try{return e.isOptional()}catch{return!0}}var $E=(e,t)=>{var n;if(t.currentPath.toString()===((n=t.propertyPath)==null?void 0:n.toString()))return Pe(e.innerType._def,t);const r=Pe(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:_t()},r]}:_t()},FE=(e,t)=>{if(t.pipeStrategy==="input")return Pe(e.in._def,t);if(t.pipeStrategy==="output")return Pe(e.out._def,t);const n=Pe(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),r=Pe(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,r].filter(i=>i!==void 0)}};function LE(e,t){return Pe(e.type._def,t)}function ZE(e,t){const r={type:"array",uniqueItems:!0,items:Pe(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&(r.minItems=e.minSize.value),e.maxSize&&(r.maxItems=e.maxSize.value),r}function BE(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,r)=>Pe(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:Pe(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,r)=>Pe(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[])}}function VE(){return{not:_t()}}function UE(){return _t()}var JE=(e,t)=>Pe(e.innerType._def,t),HE=(e,t,n)=>{switch(t){case ye.ZodString:return Oh(e,n);case ye.ZodNumber:return OE(e);case ye.ZodObject:return DE(e,n);case ye.ZodBigInt:return mE(e);case ye.ZodBoolean:return gE();case ye.ZodDate:return Ph(e,n);case ye.ZodUndefined:return VE();case ye.ZodNull:return zE();case ye.ZodArray:return hE(e,n);case ye.ZodUnion:case ye.ZodDiscriminatedUnion:return TE(e,n);case ye.ZodIntersection:return SE(e,n);case ye.ZodTuple:return BE(e,n);case ye.ZodRecord:return Dh(e,n);case ye.ZodLiteral:return _E(e);case ye.ZodEnum:return wE(e);case ye.ZodNativeEnum:return EE(e);case ye.ZodNullable:return PE(e,n);case ye.ZodOptional:return $E(e,n);case ye.ZodMap:return NE(e,n);case ye.ZodSet:return ZE(e,n);case ye.ZodLazy:return()=>e.getter()._def;case ye.ZodPromise:return LE(e,n);case ye.ZodNaN:case ye.ZodNever:return IE();case ye.ZodEffects:return vE(e,n);case ye.ZodAny:return _t();case ye.ZodUnknown:return UE();case ye.ZodDefault:return bE(e,n);case ye.ZodBranded:return Ah(e,n);case ye.ZodReadonly:return JE(e,n);case ye.ZodCatch:return xE(e,n);case ye.ZodPipeline:return FE(e,n);case ye.ZodFunction:case ye.ZodVoid:case ye.ZodSymbol:return;default:return(r=>{})()}},qE=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join("/")};function Pe(e,t,n=!1){var r;const i=t.seen.get(e);if(t.override){const l=(r=t.override)==null?void 0:r.call(t,e,t,i,n);if(l!==fE)return l}if(i&&!n){const l=WE(i,t);if(l!==void 0)return l}const s={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,s);const a=HE(e,e.typeName,t),o=typeof a=="function"?Pe(a(),t):a;if(o&&GE(e,t,o),t.postProcess){const l=t.postProcess(o,e,t);return s.jsonSchema=o,l}return s.jsonSchema=o,o}var WE=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:qE(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`),_t()):t.$refStrategy==="seen"?_t():void 0}},GE=(e,t,n)=>(e.description&&(n.description=e.description),n),KE=e=>{const t=pE(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}]))}},YE=(e,t)=>{var n;const r=KE(t);let i=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((u,[f,d])=>{var p;return{...u,[f]:(p=Pe(d._def,{...r,currentPath:[...r.basePath,r.definitionPath,f]},!0))!=null?p:_t()}},{}):void 0;const s=typeof t=="string"?t:(t==null?void 0:t.nameStrategy)==="title"||t==null?void 0:t.name,a=(n=Pe(e._def,s===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1))!=null?n:_t(),o=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;o!==void 0&&(a.title=o);const l=s===void 0?i?{...a,[r.definitionPath]:i}:a:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,s].join("/"),[r.definitionPath]:{...i,[s]:a}};return l.$schema="http://json-schema.org/draft-07/schema#",l},Da=Symbol.for("vercel.ai.schema");function XE(e){let t;return()=>(t==null&&(t=e()),t)}function ks(e,{validate:t}={}){return{[Da]:!0,_type:void 0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function QE(e){return typeof e=="object"&&e!==null&&Da in e&&e[Da]===!0&&"jsonSchema"in e&&"validate"in e}function Ro(e){return e==null?ks({properties:{},additionalProperties:!1}):QE(e)?e:"~standard"in e?e["~standard"].vendor==="zod"?Rh(e):eI(e):e()}function eI(e){return ks(()=>Do(e["~standard"].jsonSchema.input({target:"draft-07"})),{validate:async t=>{const n=await e["~standard"].validate(t);return"value"in n?{success:!0,value:n.value}:{success:!1,error:new er({value:t,cause:n.issues})}}})}function tI(e,t){var n;const r=(n=void 0)!=null?n:!1;return ks(()=>YE(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 nI(e,t){var n;const r=(n=void 0)!=null?n:!1;return ks(()=>Do(LC(e,{target:"draft-7",io:"input",reused:r?"ref":"inline"})),{validate:async i=>{const s=await kh(e,i);return s.success?{success:!0,value:s.data}:{success:!1,error:s.error}}})}function rI(e){return"_zod"in e}function Rh(e,t){return rI(e)?nI(e):tI(e)}async function Ju({value:e,schema:t,context:n}){const r=await Jr({value:e,schema:t,context:n});if(!r.success)throw er.wrap({value:e,cause:r.error,context:n});return r.value}async function Jr({value:e,schema:t,context:n}){const r=Ro(t);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};const i=await r.validate(e);return i.success?{success:!0,value:i.value,rawValue:e}:{success:!1,error:er.wrap({value:e,cause:i.error,context:n}),rawValue:e}}catch(i){return{success:!1,error:er.wrap({value:e,cause:i,context:n}),rawValue:e}}}async function In({text:e,schema:t}){try{const n=dE(e);return t==null?{success:!0,value:n,rawValue:n}:await Jr({value:n,schema:t})}catch(n){return{success:!1,error:hu.isInstance(n)?n:new hu({text:e,cause:n}),rawValue:void 0}}}function iI({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new aE).pipeThrough(new TransformStream({async transform({data:n},r){n!=="[DONE]"&&r.enqueue(await In({text:n,schema:t}))}}))}async function tn(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}var sI=Object.defineProperty,aI=(e,t)=>{for(var n in t)sI(e,n,{get:t[n],enumerable:!0})},Mh="AI_NoObjectGeneratedError",$h=`vercel.ai.error.${Mh}`,oI=Symbol.for($h),Fh,on=class extends Vt{constructor({message:e="No object generated.",cause:t,text:n,response:r,usage:i,finishReason:s}){super({name:Mh,message:e,cause:t}),this[Fh]=!0,this.text=n,this.response=r,this.usage=i,this.finishReason=s}static isInstance(e){return Vt.hasMarker(e,$h)}};Fh=oI;var Lh="AI_UIMessageStreamError",Zh=`vercel.ai.error.${Lh}`,lI=Symbol.for(Zh),Bh,$n=class extends Vt{constructor({chunkType:e,chunkId:t,message:n}){super({name:Lh,message:n}),this[Bh]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return Vt.hasMarker(e,Zh)}};Bh=lI;var Vh=ft([ie(),Ji(Uint8Array),Ji(ArrayBuffer),Th(e=>{var t,n;return(n=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?n:!1},{message:"Must be a Buffer"})]),Hr=tE(()=>ft([IN(),ie(),jN(),ut(),Vr(ie(),Hr.optional()),or(Hr)])),je=Vr(ie(),Vr(ie(),Hr.optional())),Uh=De({type:ge("text"),text:ie(),providerOptions:je.optional()}),uI=De({type:ge("image"),image:ft([Vh,Ji(URL)]),mediaType:ie().optional(),providerOptions:je.optional()}),Jh=De({type:ge("file"),data:ft([Vh,Ji(URL)]),filename:ie().optional(),mediaType:ie(),providerOptions:je.optional()}),cI=De({type:ge("reasoning"),text:ie(),providerOptions:je.optional()}),dI=De({type:ge("tool-call"),toolCallId:ie(),toolName:ie(),input:Lt(),providerOptions:je.optional(),providerExecuted:ut().optional()}),fI=ON("type",[De({type:ge("text"),value:ie(),providerOptions:je.optional()}),De({type:ge("json"),value:Hr,providerOptions:je.optional()}),De({type:ge("execution-denied"),reason:ie().optional(),providerOptions:je.optional()}),De({type:ge("error-text"),value:ie(),providerOptions:je.optional()}),De({type:ge("error-json"),value:Hr,providerOptions:je.optional()}),De({type:ge("content"),value:or(ft([De({type:ge("text"),text:ie(),providerOptions:je.optional()}),De({type:ge("media"),data:ie(),mediaType:ie()}),De({type:ge("file-data"),data:ie(),mediaType:ie(),filename:ie().optional(),providerOptions:je.optional()}),De({type:ge("file-url"),url:ie(),providerOptions:je.optional()}),De({type:ge("file-id"),fileId:ft([ie(),Vr(ie(),ie())]),providerOptions:je.optional()}),De({type:ge("image-data"),data:ie(),mediaType:ie(),providerOptions:je.optional()}),De({type:ge("image-url"),url:ie(),providerOptions:je.optional()}),De({type:ge("image-file-id"),fileId:ft([ie(),Vr(ie(),ie())]),providerOptions:je.optional()}),De({type:ge("custom"),providerOptions:je.optional()})]))})]),Hh=De({type:ge("tool-result"),toolCallId:ie(),toolName:ie(),output:fI,providerOptions:je.optional()}),pI=De({type:ge("tool-approval-request"),approvalId:ie(),toolCallId:ie()}),hI=De({type:ge("tool-approval-response"),approvalId:ie(),approved:ut(),reason:ie().optional()}),mI=De({role:ge("system"),content:ie(),providerOptions:je.optional()}),gI=De({role:ge("user"),content:ft([ie(),or(ft([Uh,uI,Jh]))]),providerOptions:je.optional()}),xI=De({role:ge("assistant"),content:ft([ie(),or(ft([Uh,Jh,cI,dI,Hh,pI]))]),providerOptions:je.optional()}),yI=De({role:ge("tool"),content:or(ft([Hh,hI])),providerOptions:je.optional()});ft([mI,gI,xI,yI]);function qh(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;const n={...e};for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)){const i=t[r];if(i===void 0)continue;const s=r in e?e[r]:void 0,a=i!==null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),o=s!=null&&typeof s=="object"&&!Array.isArray(s)&&!(s instanceof Date)&&!(s instanceof RegExp);a&&o?n[r]=qh(s,i):n[r]=i}return n}var bI={};aI(bI,{array:()=>SI,choice:()=>_I,json:()=>jI,object:()=>kI,text:()=>wI});function vI(e){const t=["ROOT"];let n=-1,r=null;function i(l,u,f){switch(l){case'"':{n=u,t.pop(),t.push(f),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=u,r=u,t.pop(),t.push(f),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(f),t.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=u,t.pop(),t.push(f),t.push("INSIDE_NUMBER");break}case"{":{n=u,t.pop(),t.push(f),t.push("INSIDE_OBJECT_START");break}case"[":{n=u,t.pop(),t.push(f),t.push("INSIDE_ARRAY_START");break}}}function s(l,u){switch(l){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{n=u,t.pop();break}}}function a(l,u){switch(l){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=u,t.pop();break}}}for(let l=0;l<e.length;l++){const u=e[l];switch(t[t.length-1]){case"ROOT":i(u,l,"FINISH");break;case"INSIDE_OBJECT_START":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{n=l,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(u){case":":{t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{i(u,l,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{s(u,l);break}case"INSIDE_STRING":{switch(u){case'"':{t.pop(),n=l;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:n=l}break}case"INSIDE_ARRAY_START":{switch(u){case"]":{n=l,t.pop();break}default:{n=l,i(u,l,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(u){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=l,t.pop();break}default:{n=l;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{i(u,l,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),n=l;break}case"INSIDE_NUMBER":{switch(u){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=l;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&s(u,l);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&s(u,l);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const d=e.substring(r,l+1);!"false".startsWith(d)&&!"true".startsWith(d)&&!"null".startsWith(d)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?s(u,l):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l)):n=l;break}}}let o=e.slice(0,n+1);for(let l=t.length-1;l>=0;l--)switch(t[l]){case"INSIDE_STRING":{o+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{o+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{o+="]";break}case"INSIDE_LITERAL":{const f=e.substring(r,e.length);"true".startsWith(f)?o+="true".slice(f.length):"false".startsWith(f)?o+="false".slice(f.length):"null".startsWith(f)&&(o+="null".slice(f.length))}}return o}async function Qr(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await In({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await In({text:vI(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var wI=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),kI=({schema:e,name:t,description:n})=>{const r=Ro(e);return{name:"object",responseFormat:tn(r.jsonSchema).then(i=>({type:"json",schema:i,...t!=null&&{name:t},...n!=null&&{description:n}})),async parseCompleteOutput({text:i},s){const a=await In({text:i});if(!a.success)throw new on({message:"No object generated: could not parse the response.",cause:a.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});const o=await Jr({value:a.value,schema:r});if(!o.success)throw new on({message:"No object generated: response did not match schema.",cause:o.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});return o.value},async parsePartialOutput({text:i}){const s=await Qr(i);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:s.value}}},createElementStreamTransform(){}}},SI=({element:e,name:t,description:n})=>{const r=Ro(e);return{name:"array",responseFormat:tn(r.jsonSchema).then(i=>{const{$schema:s,...a}=i;return{type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:a}},required:["elements"],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}}),async parseCompleteOutput({text:i},s){const a=await In({text:i});if(!a.success)throw new on({message:"No object generated: could not parse the response.",cause:a.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});const o=a.value;if(o==null||typeof o!="object"||!("elements"in o)||!Array.isArray(o.elements))throw new on({message:"No object generated: response did not match schema.",cause:new er({value:o,cause:"response must be an object with an elements array"}),text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});for(const l of o.elements){const u=await Jr({value:l,schema:r});if(!u.success)throw new on({message:"No object generated: response did not match schema.",cause:u.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason})}return o.elements},async parsePartialOutput({text:i}){const s=await Qr(i);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const a=s.value;if(a==null||typeof a!="object"||!("elements"in a)||!Array.isArray(a.elements))return;const o=s.state==="repaired-parse"&&a.elements.length>0?a.elements.slice(0,-1):a.elements,l=[];for(const u of o){const f=await Jr({value:u,schema:r});f.success&&l.push(f.value)}return{partial:l}}}},createElementStreamTransform(){let i=0;return new TransformStream({transform({partialOutput:s},a){if(s!=null)for(;i<s.length;i++)a.enqueue(s[i])}})}}},_I=({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 In({text:r});if(!s.success)throw new on({message:"No object generated: could not parse the response.",cause:s.error,text:r,response:i.response,usage:i.usage,finishReason:i.finishReason});const a=s.value;if(a==null||typeof a!="object"||!("result"in a)||typeof a.result!="string"||!e.includes(a.result))throw new on({message:"No object generated: response did not match schema.",cause:new er({value:a,cause:"response must be an object that contains a choice value."}),text:r,response:i.response,usage:i.usage,finishReason:i.finishReason});return a.result},async parsePartialOutput({text:r}){const i=await Qr(r);switch(i.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const s=i.value;if(s==null||typeof s!="object"||!("result"in s)||typeof s.result!="string")return;const a=e.filter(o=>o.startsWith(s.result));return i.state==="successful-parse"?a.includes(s.result)?{partial:s.result}:void 0:a.length===1?{partial:a[0]}:void 0}}},createElementStreamTransform(){}}),jI=({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 In({text:n});if(!i.success)throw new on({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 Qr(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(){}});Xr({prefix:"aitxt",size:24});(class extends TransformStream{constructor(){super({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}
|
|
79
|
+
|
|
80
|
+
`)},flush(e){e.enqueue(`data: [DONE]
|
|
81
|
+
|
|
82
|
+
`)}})}});var CI=XE(()=>Rh(ft([Le({type:ge("text-start"),id:ie(),providerMetadata:je.optional()}),Le({type:ge("text-delta"),id:ie(),delta:ie(),providerMetadata:je.optional()}),Le({type:ge("text-end"),id:ie(),providerMetadata:je.optional()}),Le({type:ge("error"),errorText:ie()}),Le({type:ge("tool-input-start"),toolCallId:ie(),toolName:ie(),providerExecuted:ut().optional(),providerMetadata:je.optional(),dynamic:ut().optional(),title:ie().optional()}),Le({type:ge("tool-input-delta"),toolCallId:ie(),inputTextDelta:ie()}),Le({type:ge("tool-input-available"),toolCallId:ie(),toolName:ie(),input:Lt(),providerExecuted:ut().optional(),providerMetadata:je.optional(),dynamic:ut().optional(),title:ie().optional()}),Le({type:ge("tool-input-error"),toolCallId:ie(),toolName:ie(),input:Lt(),providerExecuted:ut().optional(),providerMetadata:je.optional(),dynamic:ut().optional(),errorText:ie(),title:ie().optional()}),Le({type:ge("tool-approval-request"),approvalId:ie(),toolCallId:ie()}),Le({type:ge("tool-output-available"),toolCallId:ie(),output:Lt(),providerExecuted:ut().optional(),providerMetadata:je.optional(),dynamic:ut().optional(),preliminary:ut().optional()}),Le({type:ge("tool-output-error"),toolCallId:ie(),errorText:ie(),providerExecuted:ut().optional(),providerMetadata:je.optional(),dynamic:ut().optional()}),Le({type:ge("tool-output-denied"),toolCallId:ie()}),Le({type:ge("reasoning-start"),id:ie(),providerMetadata:je.optional()}),Le({type:ge("reasoning-delta"),id:ie(),delta:ie(),providerMetadata:je.optional()}),Le({type:ge("reasoning-end"),id:ie(),providerMetadata:je.optional()}),Le({type:ge("source-url"),sourceId:ie(),url:ie(),title:ie().optional(),providerMetadata:je.optional()}),Le({type:ge("source-document"),sourceId:ie(),mediaType:ie(),title:ie(),filename:ie().optional(),providerMetadata:je.optional()}),Le({type:ge("file"),url:ie(),mediaType:ie(),providerMetadata:je.optional()}),Le({type:Th(e=>typeof e=="string"&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:ie().optional(),data:Lt(),transient:ut().optional()}),Le({type:ge("start-step")}),Le({type:ge("finish-step")}),Le({type:ge("start"),messageId:ie().optional(),messageMetadata:Lt().optional()}),Le({type:ge("finish"),finishReason:Eh(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:Lt().optional()}),Le({type:ge("abort"),reason:ie().optional()}),Le({type:ge("message-metadata"),messageMetadata:Lt()})])));function NI(e){return e.type.startsWith("data-")}function Ra(e){return e.type.startsWith("tool-")}function EI(e){return e.type==="dynamic-tool"}function qi(e){return Ra(e)||EI(e)}function Hu(e){return e.type.split("-").slice(1).join("-")}function II({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 zI({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:r,onError:i,onToolCall:s,onData:a}){return e.pipeThrough(new TransformStream({async transform(o,l){await r(async({state:u,write:f})=>{var d,p,h,m;function w(g){const E=u.message.parts.filter(qi).find(k=>k.toolCallId===g);if(E==null)throw new $n({chunkType:"tool-invocation",chunkId:g,message:`No tool invocation found for tool call ID "${g}".`});return E}function S(g){var T;const E=u.message.parts.find(M=>Ra(M)&&M.toolCallId===g.toolCallId),k=g,N=E;if(E!=null){E.state=g.state,N.input=k.input,N.output=k.output,N.errorText=k.errorText,N.rawInput=k.rawInput,N.preliminary=k.preliminary,g.title!==void 0&&(N.title=g.title),N.providerExecuted=(T=k.providerExecuted)!=null?T:E.providerExecuted;const M=k.providerMetadata;if(M!=null)if(g.state==="output-available"||g.state==="output-error"){const Y=E;Y.resultProviderMetadata=M}else E.callProviderMetadata=M}else u.message.parts.push({type:`tool-${g.toolName}`,toolCallId:g.toolCallId,state:g.state,title:g.title,input:k.input,output:k.output,rawInput:k.rawInput,errorText:k.errorText,providerExecuted:k.providerExecuted,preliminary:k.preliminary,...k.providerMetadata!=null&&(g.state==="output-available"||g.state==="output-error")?{resultProviderMetadata:k.providerMetadata}:{},...k.providerMetadata!=null&&!(g.state==="output-available"||g.state==="output-error")?{callProviderMetadata:k.providerMetadata}:{}})}function x(g){var T,E;const k=u.message.parts.find(Y=>Y.type==="dynamic-tool"&&Y.toolCallId===g.toolCallId),N=g,M=k;if(k!=null){k.state=g.state,M.toolName=g.toolName,M.input=N.input,M.output=N.output,M.errorText=N.errorText,M.rawInput=(T=N.rawInput)!=null?T:M.rawInput,M.preliminary=N.preliminary,g.title!==void 0&&(M.title=g.title),M.providerExecuted=(E=N.providerExecuted)!=null?E:k.providerExecuted;const Y=N.providerMetadata;if(Y!=null)if(g.state==="output-available"||g.state==="output-error"){const C=k;C.resultProviderMetadata=Y}else k.callProviderMetadata=Y}else u.message.parts.push({type:"dynamic-tool",toolName:g.toolName,toolCallId:g.toolCallId,state:g.state,input:N.input,output:N.output,errorText:N.errorText,preliminary:N.preliminary,providerExecuted:N.providerExecuted,title:g.title,...N.providerMetadata!=null&&(g.state==="output-available"||g.state==="output-error")?{resultProviderMetadata:N.providerMetadata}:{},...N.providerMetadata!=null&&!(g.state==="output-available"||g.state==="output-error")?{callProviderMetadata:N.providerMetadata}:{}})}async function _(g){if(g!=null){const T=u.message.metadata!=null?qh(u.message.metadata,g):g;t!=null&&await Ju({value:T,schema:t,context:{field:"message.metadata",entityId:u.message.id}}),u.message.metadata=T}}switch(o.type){case"text-start":{const g={type:"text",text:"",providerMetadata:o.providerMetadata,state:"streaming"};u.activeTextParts[o.id]=g,u.message.parts.push(g),f();break}case"text-delta":{const g=u.activeTextParts[o.id];if(g==null)throw new $n({chunkType:"text-delta",chunkId:o.id,message:`Received text-delta for missing text part with ID "${o.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});g.text+=o.delta,g.providerMetadata=(d=o.providerMetadata)!=null?d:g.providerMetadata,f();break}case"text-end":{const g=u.activeTextParts[o.id];if(g==null)throw new $n({chunkType:"text-end",chunkId:o.id,message:`Received text-end for missing text part with ID "${o.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});g.state="done",g.providerMetadata=(p=o.providerMetadata)!=null?p:g.providerMetadata,delete u.activeTextParts[o.id],f();break}case"reasoning-start":{const g={type:"reasoning",text:"",providerMetadata:o.providerMetadata,state:"streaming"};u.activeReasoningParts[o.id]=g,u.message.parts.push(g),f();break}case"reasoning-delta":{const g=u.activeReasoningParts[o.id];if(g==null)throw new $n({chunkType:"reasoning-delta",chunkId:o.id,message:`Received reasoning-delta for missing reasoning part with ID "${o.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});g.text+=o.delta,g.providerMetadata=(h=o.providerMetadata)!=null?h:g.providerMetadata,f();break}case"reasoning-end":{const g=u.activeReasoningParts[o.id];if(g==null)throw new $n({chunkType:"reasoning-end",chunkId:o.id,message:`Received reasoning-end for missing reasoning part with ID "${o.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});g.providerMetadata=(m=o.providerMetadata)!=null?m:g.providerMetadata,g.state="done",delete u.activeReasoningParts[o.id],f();break}case"file":{u.message.parts.push({type:"file",mediaType:o.mediaType,url:o.url,...o.providerMetadata!=null?{providerMetadata:o.providerMetadata}:{}}),f();break}case"source-url":{u.message.parts.push({type:"source-url",sourceId:o.sourceId,url:o.url,title:o.title,providerMetadata:o.providerMetadata}),f();break}case"source-document":{u.message.parts.push({type:"source-document",sourceId:o.sourceId,mediaType:o.mediaType,title:o.title,filename:o.filename,providerMetadata:o.providerMetadata}),f();break}case"tool-input-start":{const g=u.message.parts.filter(Ra);u.partialToolCalls[o.toolCallId]={text:"",toolName:o.toolName,index:g.length,dynamic:o.dynamic,title:o.title},o.dynamic?x({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-streaming",input:void 0,providerExecuted:o.providerExecuted,title:o.title,providerMetadata:o.providerMetadata}):S({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-streaming",input:void 0,providerExecuted:o.providerExecuted,title:o.title,providerMetadata:o.providerMetadata}),f();break}case"tool-input-delta":{const g=u.partialToolCalls[o.toolCallId];if(g==null)throw new $n({chunkType:"tool-input-delta",chunkId:o.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${o.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});g.text+=o.inputTextDelta;const{value:T}=await Qr(g.text);g.dynamic?x({toolCallId:o.toolCallId,toolName:g.toolName,state:"input-streaming",input:T,title:g.title}):S({toolCallId:o.toolCallId,toolName:g.toolName,state:"input-streaming",input:T,title:g.title}),f();break}case"tool-input-available":{o.dynamic?x({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-available",input:o.input,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:o.title}):S({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-available",input:o.input,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:o.title}),f(),s&&!o.providerExecuted&&await s({toolCall:o});break}case"tool-input-error":{const g=u.message.parts.filter(qi).find(E=>E.toolCallId===o.toolCallId);(g!=null?g.type==="dynamic-tool":!!o.dynamic)?x({toolCallId:o.toolCallId,toolName:o.toolName,state:"output-error",input:o.input,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata}):S({toolCallId:o.toolCallId,toolName:o.toolName,state:"output-error",input:void 0,rawInput:o.input,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata}),f();break}case"tool-approval-request":{const g=w(o.toolCallId);g.state="approval-requested",g.approval={id:o.approvalId},f();break}case"tool-output-denied":{const g=w(o.toolCallId);g.state="output-denied",f();break}case"tool-output-available":{const g=w(o.toolCallId);g.type==="dynamic-tool"?x({toolCallId:o.toolCallId,toolName:g.toolName,state:"output-available",input:g.input,output:o.output,preliminary:o.preliminary,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:g.title}):S({toolCallId:o.toolCallId,toolName:Hu(g),state:"output-available",input:g.input,output:o.output,providerExecuted:o.providerExecuted,preliminary:o.preliminary,providerMetadata:o.providerMetadata,title:g.title}),f();break}case"tool-output-error":{const g=w(o.toolCallId);g.type==="dynamic-tool"?x({toolCallId:o.toolCallId,toolName:g.toolName,state:"output-error",input:g.input,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:g.title}):S({toolCallId:o.toolCallId,toolName:Hu(g),state:"output-error",input:g.input,rawInput:g.rawInput,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:g.title}),f();break}case"start-step":{u.message.parts.push({type:"step-start"});break}case"finish-step":{u.activeTextParts={},u.activeReasoningParts={};break}case"start":{o.messageId!=null&&(u.message.id=o.messageId),await _(o.messageMetadata),(o.messageId!=null||o.messageMetadata!=null)&&f();break}case"finish":{o.finishReason!=null&&(u.finishReason=o.finishReason),await _(o.messageMetadata),o.messageMetadata!=null&&f();break}case"message-metadata":{await _(o.messageMetadata),o.messageMetadata!=null&&f();break}case"error":{i==null||i(new Error(o.errorText));break}default:if(NI(o)){if((n==null?void 0:n[o.type])!=null){const E=u.message.parts.findIndex(N=>"id"in N&&"data"in N&&N.id===o.id&&N.type===o.type),k=E>=0?E:u.message.parts.length;await Ju({value:o.data,schema:n[o.type],context:{field:`message.parts[${k}].data`,entityName:o.type,entityId:o.id}})}const g=o;if(g.transient){a==null||a(g);break}const T=g.id!=null?u.message.parts.find(E=>g.type===E.type&&g.id===E.id):void 0;T!=null?T.data=g.data:u.message.parts.push(g),a==null||a(g),f()}}l.enqueue(o)})}}))}async function TI({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()}}Xr({prefix:"aitxt",size:24});Xr({prefix:"aiobj",size:24});var AI=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()})}};Xr({prefix:"aiobj",size:24});async function PI(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw new Error("FileList is not supported in the current environment");return Promise.all(Array.from(e).map(async t=>{const{name:n,type:r}=t,i=await new Promise((s,a)=>{const o=new FileReader;o.onload=l=>{var u;s((u=l.target)==null?void 0:u.result)},o.onerror=l=>a(l),o.readAsDataURL(t)});return{type:"file",mediaType:r,filename:n,url:i}}))}var OI=class{constructor({api:e="/api/chat",credentials:t,headers:n,body:r,fetch:i,prepareSendMessagesRequest:s,prepareReconnectToStreamRequest:a}){this.api=e,this.credentials=t,this.headers=n,this.body=r,this.fetch=i,this.prepareSendMessagesRequest=s,this.prepareReconnectToStreamRequest=a}async sendMessages({abortSignal:e,...t}){var n,r,i,s,a;const o=await tn(this.body),l=await tn(this.headers),u=await tn(this.credentials),f={...Mn(l),...Mn(t.headers)},d=await((n=this.prepareSendMessagesRequest)==null?void 0:n.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...o,...t.body},headers:f,credentials:u,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId})),p=(r=d==null?void 0:d.api)!=null?r:this.api,h=(d==null?void 0:d.headers)!==void 0?Mn(d.headers):f,m=(d==null?void 0:d.body)!==void 0?d.body:{...o,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId},w=(i=d==null?void 0:d.credentials)!=null?i:u,x=await((s=this.fetch)!=null?s:globalThis.fetch)(p,{method:"POST",headers:{"Content-Type":"application/json",...h},body:JSON.stringify(m),credentials:w,signal:e});if(!x.ok)throw new Error((a=await x.text())!=null?a:"Failed to fetch the chat response.");if(!x.body)throw new Error("The response body is empty.");return this.processResponseStream(x.body)}async reconnectToStream(e){var t,n,r,i,s;const a=await tn(this.body),o=await tn(this.headers),l=await tn(this.credentials),u={...Mn(o),...Mn(e.headers)},f=await((t=this.prepareReconnectToStreamRequest)==null?void 0:t.call(this,{api:this.api,id:e.chatId,body:{...a,...e.body},headers:u,credentials:l,requestMetadata:e.metadata})),d=(n=f==null?void 0:f.api)!=null?n:`${this.api}/${e.chatId}/stream`,p=(f==null?void 0:f.headers)!==void 0?Mn(f.headers):u,h=(r=f==null?void 0:f.credentials)!=null?r:l,w=await((i=this.fetch)!=null?i:globalThis.fetch)(d,{method:"GET",headers:p,credentials:h});if(w.status===204)return null;if(!w.ok)throw new Error((s=await w.text())!=null?s:"Failed to fetch the chat response.");if(!w.body)throw new Error("The response body is empty.");return this.processResponseStream(w.body)}},Wh=class extends OI{constructor(e={}){super(e)}processResponseStream(e){return iI({stream:e,schema:CI}).pipeThrough(new TransformStream({async transform(t,n){if(!t.success)throw t.error;n.enqueue(t.value)}}))}},DI=class{constructor({generateId:e=oE,id:t=e(),transport:n=new Wh,messageMetadataSchema:r,dataPartSchemas:i,state:s,onError:a,onToolCall:o,onFinish:l,onData:u,sendAutomaticallyWhen:f}){this.activeResponse=void 0,this.jobExecutor=new AI,this.sendMessage=async(d,p)=>{var h,m,w,S;if(d==null){await this.makeRequest({trigger:"submit-message",messageId:(h=this.lastMessage)==null?void 0:h.id,...p});return}let x;if("text"in d||"files"in d?x={parts:[...Array.isArray(d.files)?d.files:await PI(d.files),..."text"in d&&d.text!=null?[{type:"text",text:d.text}]:[]]}:x=d,d.messageId!=null){const _=this.state.messages.findIndex(g=>g.id===d.messageId);if(_===-1)throw new Error(`message with id ${d.messageId} not found`);if(this.state.messages[_].role!=="user")throw new Error(`message with id ${d.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,_+1),this.state.replaceMessage(_,{...x,id:d.messageId,role:(m=x.role)!=null?m:"user",metadata:d.metadata})}else this.state.pushMessage({...x,id:(w=x.id)!=null?w:this.generateId(),role:(S=x.role)!=null?S:"user",metadata:d.metadata});await this.makeRequest({trigger:"submit-message",messageId:d.messageId,...p})},this.regenerate=async({messageId:d,...p}={})=>{const h=d==null?this.state.messages.length-1:this.state.messages.findIndex(m=>m.id===d);if(h===-1)throw new Error(`message ${d} not found`);this.state.messages=this.state.messages.slice(0,this.messages[h].role==="assistant"?h:h+1),await this.makeRequest({trigger:"regenerate-message",messageId:d,...p})},this.resumeStream=async(d={})=>{await this.makeRequest({trigger:"resume-stream",...d})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:d,approved:p,reason:h,options:m})=>this.jobExecutor.run(async()=>{const w=this.state.messages,S=w[w.length-1],x=_=>qi(_)&&_.state==="approval-requested"&&_.approval.id===d?{..._,state:"approval-responded",approval:{id:d,approved:p,reason:h}}:_;this.state.replaceMessage(w.length-1,{...S,parts:S.parts.map(x)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(x)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(_=>{var g;_&&this.makeRequest({trigger:"submit-message",messageId:(g=this.lastMessage)==null?void 0:g.id,...m})})}),this.addToolOutput=async({state:d="output-available",toolCallId:p,output:h,errorText:m,options:w})=>this.jobExecutor.run(async()=>{const S=this.state.messages,x=S[S.length-1],_=g=>qi(g)&&g.toolCallId===p?{...g,state:d,output:h,errorText:m}:g;this.state.replaceMessage(S.length-1,{...x,parts:x.parts.map(_)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(_)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(g=>{var T;g&&this.makeRequest({trigger:"submit-message",messageId:(T=this.lastMessage)==null?void 0:T.id,...w})})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var d;this.status!=="streaming"&&this.status!=="submitted"||(d=this.activeResponse)!=null&&d.abortController&&this.activeResponse.abortController.abort()},this.id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=r,this.dataPartSchemas=i,this.state=s,this.onError=a,this.onToolCall=o,this.onFinish=l,this.onData=u,this.sendAutomaticallyWhen=f}get status(){return this.state.status}setStatus({status:e,error:t}){this.status!==e&&(this.state.status=e,this.state.error=t)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(e){this.state.messages=e}async shouldSendAutomatically(){if(!this.sendAutomaticallyWhen)return!1;const e=this.sendAutomaticallyWhen({messages:this.state.messages});return e&&typeof e=="object"&&"then"in e?await e:e}async makeRequest({trigger:e,metadata:t,headers:n,body:r,messageId:i}){var s,a,o;let l;if(e==="resume-stream")try{const h=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:n,body:r});if(h==null)return;l=h}catch(h){this.onError&&h instanceof Error&&this.onError(h),this.setStatus({status:"error",error:h});return}this.setStatus({status:"submitted",error:void 0});const u=this.lastMessage;let f=!1,d=!1,p=!1;try{const h={state:II({lastMessage:this.state.snapshot(u),messageId:this.generateId()}),abortController:new AbortController};h.abortController.signal.addEventListener("abort",()=>{f=!0}),this.activeResponse=h;let m;e==="resume-stream"?m=l:m=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:h.abortController.signal,metadata:t,headers:n,body:r,trigger:e,messageId:i});const w=S=>this.jobExecutor.run(()=>S({state:h.state,write:()=>{var x;this.setStatus({status:"streaming"}),h.state.message.id===((x=this.lastMessage)==null?void 0:x.id)?this.state.replaceMessage(this.state.messages.length-1,h.state.message):this.state.pushMessage(h.state.message)}}));await TI({stream:zI({stream:m,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:w,onError:S=>{throw S}}),onError:S=>{throw S}}),this.setStatus({status:"ready"})}catch(h){if(f||h.name==="AbortError")return f=!0,this.setStatus({status:"ready"}),null;p=!0,h instanceof TypeError&&(h.message.toLowerCase().includes("fetch")||h.message.toLowerCase().includes("network"))&&(d=!0),this.onError&&h instanceof Error&&this.onError(h),this.setStatus({status:"error",error:h})}finally{try{(a=this.onFinish)==null||a.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:f,isDisconnect:d,isError:p,finishReason:(s=this.activeResponse)==null?void 0:s.state.finishReason})}catch(h){console.error(h)}this.activeResponse=void 0}!p&&await this.shouldSendAutomatically()&&await this.makeRequest({trigger:"submit-message",messageId:(o=this.lastMessage)==null?void 0:o.id,metadata:t,headers:n,body:r})}},ia,qu;function RI(){if(qu)return ia;qu=1;function e(t,n){if(typeof t!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof t}\`.`);let r,i=0;return function(...a){clearTimeout(r);const o=Date.now(),l=o-i,u=n-l;u<=0?(i=o,t.apply(this,a)):r=setTimeout(()=>{i=Date.now(),t.apply(this,a)},u)}}return ia=e,ia}var MI=RI();const $I=Za(MI);var Gh=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Ze=(e,t,n)=>(Gh(e,t,"read from private field"),n?n.call(e):t.get(e)),$t=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},en=(e,t,n,r)=>(Gh(e,t,"write to private field"),t.set(e,n),n);function FI(e,t){return t!=null?$I(e,t):e}var jt,vi,wi,Sr,_r,jr,Bn,Ma,$a,LI=class{constructor(e=[]){$t(this,jt,void 0),$t(this,vi,"ready"),$t(this,wi,void 0),$t(this,Sr,new Set),$t(this,_r,new Set),$t(this,jr,new Set),this.pushMessage=t=>{en(this,jt,Ze(this,jt).concat(t)),Ze(this,Bn).call(this)},this.popMessage=()=>{en(this,jt,Ze(this,jt).slice(0,-1)),Ze(this,Bn).call(this)},this.replaceMessage=(t,n)=>{en(this,jt,[...Ze(this,jt).slice(0,t),this.snapshot(n),...Ze(this,jt).slice(t+1)]),Ze(this,Bn).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,n)=>{const r=n?FI(t,n):t;return Ze(this,Sr).add(r),()=>{Ze(this,Sr).delete(r)}},this["~registerStatusCallback"]=t=>(Ze(this,_r).add(t),()=>{Ze(this,_r).delete(t)}),this["~registerErrorCallback"]=t=>(Ze(this,jr).add(t),()=>{Ze(this,jr).delete(t)}),$t(this,Bn,()=>{Ze(this,Sr).forEach(t=>t())}),$t(this,Ma,()=>{Ze(this,_r).forEach(t=>t())}),$t(this,$a,()=>{Ze(this,jr).forEach(t=>t())}),en(this,jt,e)}get status(){return Ze(this,vi)}set status(e){en(this,vi,e),Ze(this,Ma).call(this)}get error(){return Ze(this,wi)}set error(e){en(this,wi,e),Ze(this,$a).call(this)}get messages(){return Ze(this,jt)}set messages(e){en(this,jt,[...e]),Ze(this,Bn).call(this)}};jt=new WeakMap;vi=new WeakMap;wi=new WeakMap;Sr=new WeakMap;_r=new WeakMap;jr=new WeakMap;Bn=new WeakMap;Ma=new WeakMap;$a=new WeakMap;var Vn,Wu=class extends DI{constructor({messages:e,...t}){const n=new LI(e);super({...t,state:n}),$t(this,Vn,void 0),this["~registerMessagesCallback"]=(r,i)=>Ze(this,Vn)["~registerMessagesCallback"](r,i),this["~registerStatusCallback"]=r=>Ze(this,Vn)["~registerStatusCallback"](r),this["~registerErrorCallback"]=r=>Ze(this,Vn)["~registerErrorCallback"](r),en(this,Vn,n)}};Vn=new WeakMap;function ZI({experimental_throttle:e,resume:t=!1,...n}={}){const r=y.useRef("chat"in n?{}:{onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});"chat"in n||(r.current={onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});const i={...n,onToolCall:p=>{var h,m;return(m=(h=r.current).onToolCall)==null?void 0:m.call(h,p)},onData:p=>{var h,m;return(m=(h=r.current).onData)==null?void 0:m.call(h,p)},onFinish:p=>{var h,m;return(m=(h=r.current).onFinish)==null?void 0:m.call(h,p)},onError:p=>{var h,m;return(m=(h=r.current).onError)==null?void 0:m.call(h,p)},sendAutomaticallyWhen:p=>{var h,m,w;return(w=(m=(h=r.current).sendAutomaticallyWhen)==null?void 0:m.call(h,p))!=null?w:!1}},s=y.useRef("chat"in n?n.chat:new Wu(i));("chat"in n&&n.chat!==s.current||"id"in n&&s.current.id!==n.id)&&(s.current="chat"in n?n.chat:new Wu(i));const o=y.useCallback(p=>s.current["~registerMessagesCallback"](p,e),[e,s.current.id]),l=y.useSyncExternalStore(o,()=>s.current.messages,()=>s.current.messages),u=y.useSyncExternalStore(s.current["~registerStatusCallback"],()=>s.current.status,()=>s.current.status),f=y.useSyncExternalStore(s.current["~registerErrorCallback"],()=>s.current.error,()=>s.current.error),d=y.useCallback(p=>{typeof p=="function"&&(p=p(s.current.messages)),s.current.messages=p},[s]);return y.useEffect(()=>{t&&s.current.resumeStream()},[t,s]),{id:s.current.id,messages:l,setMessages:d,sendMessage:s.current.sendMessage,regenerate:s.current.regenerate,clearError:s.current.clearError,stop:s.current.stop,error:f,resumeStream:s.current.resumeStream,status:u,addToolResult:s.current.addToolOutput,addToolOutput:s.current.addToolOutput,addToolApprovalResponse:s.current.addToolApprovalResponse}}function Kh(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 Yh(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 Xh(e,t,n){if(!(n!=null&&n.selectedText)){const i=BI(e,t);if(i)return i}if(n!=null&&n.selectedText){const i=n.selectedText,s=e.indexOf(i);if(s!==-1){const o=e.indexOf(i,s+1);let l;if(o===-1)l=s;else if(n.startLine&&n.startLine>0){const d=WI(e,n.startLine);l=GI(e,i,d)}else l=s;const u=e.slice(0,l),f=e.slice(l+i.length);return{original:e,modified:u+t+f}}if(n.startLine&&n.endLine){const o=HI(e,t,n.startLine,n.endLine);if(o)return o}const a=Gu(e,t);return a||{original:e,modified:t}}const r=Gu(e,t);return r||{original:e,modified:t}}function BI(e,t){let n;try{n=JSON.parse(t)}catch{return null}if(!n||typeof n!="object"||Array.isArray(n))return null;const r=n.name;if(typeof r!="string"||!r)return null;let i;try{i=JSON.parse(e)}catch{return null}const s=e.match(/\n(\s+)"/),a=s?s[1].length:2;if(!Fa(i,r,n))return null;const o=JSON.stringify(i,null,a);return{original:e,modified:o}}function Fa(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(Fa(i,t,n))return!0}return!1}if(e&&typeof e=="object"){for(const r of Object.values(e))if(Fa(r,t,n))return!0}return!1}function Gu(e,t){try{const s=JSON.parse(t);if(s&&typeof s=="object"&&!Array.isArray(s))try{const a=JSON.parse(e);if(a&&typeof a=="object"&&!Array.isArray(a)){const o=Object.keys(s).sort().join(","),l=Object.keys(a).sort().join(",");if(o===l)return null}}catch{}}catch{}const n=VI(t);if(n.length===0)return null;let r=e,i=!1;for(const s of n){const a=UI(r,t,s);a&&(r=a,i=!0)}return i?{original:e,modified:r}:null}function VI(e){const t=[],n=e.split(`
|
|
83
|
+
`),r=n.find(s=>s.trim().length>0);if(!r)return t;const i=r.search(/\S/);for(const s of n){const a=s.search(/\S/);if(a<0||a!==i)continue;const o=s.match(/^\s*"([^"]+)"\s*:/);o&&t.push(o[1])}return[...new Set(t)]}function UI(e,t,n){const r=`"${n}"`,i=Ku(e,r);if(i.length===0)return null;const s=Ku(t,r);if(s.length===0)return null;const a=s[0],o=t.slice(a.start,a.end);let l=0;if(i.length>1){let f=-1;for(let d=0;d<i.length;d++){const p=e.slice(i[d].start,i[d].end),h=qI(p,o);h>f&&(f=h,l=d)}}const u=i[l];return e.slice(0,u.start)+o+e.slice(u.end)}function Ku(e,t){const n=[];let r=0;for(;;){const i=e.indexOf(t,r);if(i===-1)break;let s=i-1;for(;s>=0&&(e[s]===" "||e[s]===" ");)s--;const a=s<0?"":e[s];if(a!==""&&a!=="{"&&a!==","&&a!==`
|
|
84
|
+
`&&a!=="\r"){r=i+1;continue}const o=e.indexOf(":",i+t.length);if(o===-1){r=i+1;continue}const l=o+1,u=JI(e,l);if(u===-1){r=i+1;continue}n.push({start:i,end:u}),r=u}return n}function JI(e,t){for(;t<e.length&&/\s/.test(e[t]);)t++;if(t>=e.length)return-1;const n=e[t];if(n==='"'){let i=t+1;for(;i<e.length;){if(e[i]==="\\"){i+=2;continue}if(e[i]==='"')return i+1;i++}return-1}if(n==="["||n==="{"){const i=n,s=n==="["?"]":"}";let a=1,o=t+1,l=!1;for(;o<e.length&&a>0;){if(e[o]==="\\"&&l){o+=2;continue}e[o]==='"'&&(l=!l),l||(e[o]===i?a++:e[o]===s&&a--),o++}return a===0?o:-1}let r=t;for(;r<e.length&&/[^\s,\]}]/.test(e[r]);)r++;return r>t?r:-1}function HI(e,t,n,r){const i=e.split(`
|
|
85
|
+
`);if(n<1||r<n||n>i.length)return null;const s=i.slice(0,n-1).join(`
|
|
86
|
+
`),a=i.slice(r).join(`
|
|
87
|
+
`),o=s+(s?`
|
|
88
|
+
`:"")+t+(a?`
|
|
89
|
+
`:"")+a;return{original:e,modified:o}}function qI(e,t){if(e===t)return 1;if(!e.length||!t.length)return 0;const n=3,r=new Set;for(let a=0;a<=e.length-n;a++)r.add(e.slice(a,a+n));let i=0;for(let a=0;a<=t.length-n;a++)r.has(t.slice(a,a+n))&&i++;const s=Math.max(e.length-n+1,t.length-n+1);return s>0?i/s:0}function WI(e,t){let n=0;const r=e.split(`
|
|
90
|
+
`);for(let i=0;i<Math.min(t-1,r.length);i++)n+=r[i].length+1;return n}function GI(e,t,n){let r=-1,i=1/0,s=e.indexOf(t);for(;s!==-1;){const a=Math.abs(s-n);a<i&&(i=a,r=s),s=e.indexOf(t,s+1)}return r}function KI(e){const t=e[e.length-1][1];try{return JSON.parse(t),t}catch{}if(e.length>1){const n=e.map(r=>r[1]).join(`
|
|
91
|
+
`);try{return JSON.parse(n),n}catch{}}return null}function YI(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=Kh(r.props.templates||[],i.templates);else return null;return{original:e,modified:JSON.stringify(r,null,2)}}catch{return null}}function XI(){const e=Te(J=>J.threads),t=Te(J=>J.activeThreadId),n=Te(J=>J.updateThreadMessages),r=Te(J=>J.updateThreadTitle),i=Te(J=>J.clearContext),s=Te(J=>J.contextAttachments),a=Te(J=>J.scope),o=Te(J=>J.model),l=Ae(J=>J.activeTab),u=Ae(J=>J.documents),f=Ae(J=>J.documentTypes),d=Ae(J=>J.setPendingDiff),p=Ae(J=>J.createDocument),h=Ae(J=>J.openDocument),m=y.useRef(e);m.current=e;const w=y.useRef(l);w.current=l;const S=y.useRef(u);S.current=u;const x=y.useRef(f);x.current=f;const _=y.useRef(t);_.current=t;const g=l?t[l]:void 0,T=y.useRef(g);T.current=g;const E=y.useRef([]),k=y.useRef([]),N=y.useRef({}),M=y.useRef({}),[,Y]=y.useState(0),C=y.useCallback(()=>Y(J=>J+1),[]),B=y.useRef(null);B.current||(B.current=new Wh({api:"/api/ai/chat"}));const R=y.useCallback(()=>{const J=S.current.find(O=>O.name===w.current);return J?{name:J.name,text:J.text}:void 0},[]),U=y.useCallback(J=>N.current[J]||[],[]),L=ZI({transport:B.current,onError:()=>{E.current.shift(),k.current.shift(),i()},onFinish:({messages:J})=>{var X,ae;const O=T.current;if(O){n(O,J);const ne=m.current[O];if(ne&&ne.title.startsWith("Chat ")){const I=J.find($=>$.role==="user");if(I){const $=((X=I.parts)==null?void 0:X.filter(W=>W.type==="text").map(W=>W.text).join(""))||"";if($){const W=$.length>50?$.slice(0,50)+"...":$;r(O,W)}}}}const q=E.current.shift()||[],b=k.current.shift()||"global",ce=J.filter(ne=>ne.role==="user"),oe=ce[ce.length-1];oe!=null&&oe.id&&(N.current[oe.id]=q,M.current[oe.id]=b);const v=J.filter(ne=>ne.role==="assistant").pop();if(v){const I=[...(((ae=v.parts)==null?void 0:ae.filter($=>$.type==="text").map($=>$.text).join(""))||"").matchAll(/```(?:json|jsonc)\s*\n([\s\S]*?)```/g)];if(I.length>0){const $=KI(I);if($){const W=I[I.length-1][1],le=w.current;if(le){const K=S.current.find(Ge=>Ge.name===le),ve=(K==null?void 0:K.text)||"",de=q[0],xe=YI(ve,$,b);!xe&&b!=="global"&&console.warn(`[chat] scopedMerge failed for scope="${b}", falling back to text merge`);const{original:Ue,modified:rt}=xe??Xh(ve,$,de);d(le,Ue,rt,Yh(W.replace(/\n$/,"")))}else{const K=`ai-generated-${Date.now()}`;p(K,$),h(K)}}}}i()}});y.useEffect(()=>{const J=L.messages.filter(O=>O.role==="user");for(let O=J.length-1;O>=0;O--){const q=J[O].id;if(q in N.current)break;E.current.length>0&&(N.current[q]=E.current[0],M.current[q]=k.current[0]||"global",C());break}},[L.messages,C]);const P=y.useCallback((J,O)=>{E.current.push([...s]),k.current.push(a),i();const q={text:J};O!=null&&O.length&&(q.files=O),L.sendMessage(q,{body:{format:kt,context:s,activeDocument:R(),documentType:w.current&&x.current[w.current]||"application/json+report",scope:a,model:o}})},[L.sendMessage,s,R,i,a,o]),A=y.useCallback(J=>M.current[J],[]);return{messages:L.messages,sendMessage:P,status:L.status,error:L.error,setMessages:L.setMessages,stop:L.stop,getMessageContext:U,getMessageScope:A}}const Qh=y.createContext(null);function QI({children:e}){const t=XI();return c.jsx(Qh.Provider,{value:t,children:e})}function ez(){const e=y.useContext(Qh);if(!e)throw new Error("useChatSessionContext must be used within ChatSessionProvider");return e}function tz(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 nz(e,t=50){const n=e.replace(/[\n\r]+/g," ").replace(/\s+/g," ").trim();return n.length>t?n.slice(0,t)+"…":n}function em({context:e,onRemove:t,variant:n="default"}){var u;const r=tz(e),i=((u=e.documentName)==null?void 0:u.replace(/\.json$/,""))??"",s=i?`${i} › ${r}`:r,a=nz(e.selectedText),o=n==="sent",l=c.jsxs("div",{className:`group flex items-center gap-1.5 rounded-md border pl-2 ${t?"pr-1":"pr-2"} py-1 text-xs max-w-[280px] transition-colors ${o?"border-primary-foreground/20 bg-primary-foreground/10 hover:bg-primary-foreground/20":"border-primary/20 bg-primary/5 hover:bg-primary/10"}`,children:[c.jsx(ag,{className:`h-3 w-3 shrink-0 ${o?"text-primary-foreground/60":"text-primary/60"}`}),c.jsx("span",{className:"truncate font-medium",children:s}),t&&c.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:c.jsx(jn,{className:"h-3 w-3"})})]});return c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:l}),c.jsxs(et,{side:"top",className:"max-w-xs",children:[c.jsx("p",{className:"text-xs font-medium mb-0.5",children:s}),c.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:a}),e.jsonPath&&c.jsx("p",{className:"text-[10px] text-muted-foreground/60 mt-1",children:e.jsonPath})]})]})}class Fn extends Error{constructor(t,n){super(`${t} at position ${n}`),this.position=n}}const tm=32,rz=10,nm=9,rm=13,iz=160,sz=6158,az=8192,oz=8203,lz=8239,uz=8287,cz=12288,dz=65279;function fz(e){return/^[0-9A-Fa-f]$/.test(e)}function xn(e){return e>="0"&&e<="9"}function pz(e){return e>=" "}function fi(e){return`,:[]/{}()
|
|
92
|
+
+`.includes(e)}function Yu(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"}function Xu(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"||e>="0"&&e<="9"}const Qu=/^(http|https|ftp|mailto|file|data|irc):\/\/$/,ec=/^[A-Za-z0-9-._~:/?#@!$&'()*+;=]$/;function tc(e){return`,[]/{}
|
|
93
|
+
+`.includes(e)}function nc(e){return ki(e)||hz.test(e)}const hz=/^[[{\w-]$/;function mz(e){return e===`
|
|
94
|
+
`||e==="\r"||e===" "||e==="\b"||e==="\f"}function bn(e,t){const n=e.charCodeAt(t);return n===tm||n===rz||n===nm||n===rm}function gz(e,t){const n=e.charCodeAt(t);return n===tm||n===nm||n===rm}function xz(e,t){const n=e.charCodeAt(t);return n===iz||n===sz||n>=az&&n<=oz||n===lz||n===uz||n===cz||n===dz}function ki(e){return im(e)||La(e)}function im(e){return e==='"'||e==="“"||e==="”"}function rc(e){return e==='"'}function La(e){return e==="'"||e==="‘"||e==="’"||e==="`"||e==="´"}function ic(e){return e==="'"}function xr(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 At(e,t){let n=e.length;if(!bn(e,n-1))return e+t;for(;bn(e,n-1);)n--;return e.substring(0,n)+t+e.substring(n)}function yz(e,t,n){return e.substring(0,t)+e.substring(t+n)}function bz(e){return/[,\n][ \t\r]*$/.test(e)}const vz={"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"},wz={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
|
|
95
|
+
`,r:"\r",t:" "};function sc(e){let t=0,n="";u(["```","[```","{```"]),s()||L(),u(["```","```]","```}"]);const i=d(",");for(i&&a(),nc(e[t])&&bz(n)?(i||(n=At(n,",")),x()):i&&(n=xr(n,","));e[t]==="}"||e[t]==="]";)t++,a();if(t>=e.length)return n;U();function s(){a();const O=w()||S()||_()||T()||E()||N(!1)||M();return a(),O}function a(){let O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;const q=t;let b=o(O);do b=l(),b&&(b=o(O));while(b);return t>q}function o(O){const q=O?bn:gz;let b="";for(;;)if(q(e,t))b+=e[t],t++;else if(xz(e,t))b+=" ",t++;else break;return b.length>0?(n+=b,!0):!1}function l(){if(e[t]==="/"&&e[t+1]==="*"){for(;t<e.length&&!kz(e,t);)t++;return t+=2,!0}if(e[t]==="/"&&e[t+1]==="/"){for(;t<e.length&&e[t]!==`
|
|
96
|
+
`;)t++;return!0}return!1}function u(O){if(f(O)){if(Yu(e[t]))for(;t<e.length&&Xu(e[t]);)t++;return a(),!0}return!1}function f(O){o(!0);for(const q of O){const b=t+q.length;if(e.slice(t,b)===q)return t=b,!0}return!1}function d(O){return e[t]===O?(n+=e[t],t++,!0):!1}function p(O){return e[t]===O?(t++,!0):!1}function h(){return p("\\")}function m(){return a(),e[t]==="."&&e[t+1]==="."&&e[t+2]==="."?(t+=3,a(),p(","),!0):!1}function w(){if(e[t]==="{"){n+="{",t++,a(),p(",")&&a();let O=!0;for(;t<e.length&&e[t]!=="}";){let q;if(O?(q=!0,O=!1):(q=d(","),q||(n=At(n,",")),a()),m(),!(_()||N(!0))){e[t]==="}"||e[t]==="{"||e[t]==="]"||e[t]==="["||e[t]===void 0?n=xr(n,","):P();break}a();const ce=d(":"),oe=t>=e.length;ce||(nc(e[t])||oe?n=At(n,":"):A()),s()||(ce||oe?n+="null":A())}return e[t]==="}"?(n+="}",t++):n=At(n,"}"),!0}return!1}function S(){if(e[t]==="["){n+="[",t++,a(),p(",")&&a();let O=!0;for(;t<e.length&&e[t]!=="]";)if(O?O=!1:d(",")||(n=At(n,",")),m(),!s()){n=xr(n,",");break}return e[t]==="]"?(n+="]",t++):n=At(n,"]"),!0}return!1}function x(){let O=!0,q=!0;for(;q;)O?O=!1:d(",")||(n=At(n,",")),q=s();q||(n=xr(n,",")),n=`[
|
|
97
|
+
${n}
|
|
98
|
+
]`}function _(){let O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:-1,b=e[t]==="\\";if(b&&(t++,b=!0),ki(e[t])){const ce=rc(e[t])?rc:ic(e[t])?ic:La(e[t])?La:im,oe=t,v=n.length;let X='"';for(t++;;){if(t>=e.length){const ae=Y(t-1);return!O&&fi(e.charAt(ae))?(t=oe,n=n.substring(0,v),_(!0)):(X=At(X,'"'),n+=X,!0)}if(t===q)return X=At(X,'"'),n+=X,!0;if(ce(e[t])){const ae=t,ne=X.length;if(X+='"',t++,n+=X,a(!1),O||t>=e.length||fi(e[t])||ki(e[t])||xn(e[t]))return g(),!0;const I=Y(ae-1),$=e.charAt(I);if($===",")return t=oe,n=n.substring(0,v),_(!1,I);if(fi($))return t=oe,n=n.substring(0,v),_(!0);n=n.substring(0,v),t=ae+1,X=`${X.substring(0,ne)}\\${X.substring(ne)}`}else if(O&&tc(e[t])){if(e[t-1]===":"&&Qu.test(e.substring(oe+1,t+2)))for(;t<e.length&&ec.test(e[t]);)X+=e[t],t++;return X=At(X,'"'),n+=X,g(),!0}else if(e[t]==="\\"){const ae=e.charAt(t+1);if(wz[ae]!==void 0)X+=e.slice(t,t+2),t+=2;else if(ae==="u"){let I=2;for(;I<6&&fz(e[t+I]);)I++;I===6?(X+=e.slice(t,t+6),t+=6):t+I>=e.length?t=e.length:J()}else X+=ae,t+=2}else{const ae=e.charAt(t);ae==='"'&&e[t-1]!=="\\"?(X+=`\\${ae}`,t++):mz(ae)?(X+=vz[ae],t++):(pz(ae)||R(ae),X+=ae,t++)}b&&h()}}return!1}function g(){let O=!1;for(a();e[t]==="+";){O=!0,t++,a(),n=xr(n,'"',!0);const q=n.length;_()?n=yz(n,q,1):n=At(n,'"')}return O}function T(){const O=t;if(e[t]==="-"){if(t++,C())return B(O),!0;if(!xn(e[t]))return t=O,!1}for(;xn(e[t]);)t++;if(e[t]==="."){if(t++,C())return B(O),!0;if(!xn(e[t]))return t=O,!1;for(;xn(e[t]);)t++}if(e[t]==="e"||e[t]==="E"){if(t++,(e[t]==="-"||e[t]==="+")&&t++,C())return B(O),!0;if(!xn(e[t]))return t=O,!1;for(;xn(e[t]);)t++}if(!C())return t=O,!1;if(t>O){const q=e.slice(O,t),b=/^0\d/.test(q);return n+=b?`"${q}"`:q,!0}return!1}function E(){return k("true","true")||k("false","false")||k("null","null")||k("True","true")||k("False","false")||k("None","null")}function k(O,q){return e.slice(t,t+O.length)===O?(n+=q,t+=O.length,!0):!1}function N(O){const q=t;if(Yu(e[t])){for(;t<e.length&&Xu(e[t]);)t++;let b=t;for(;bn(e,b);)b++;if(e[b]==="(")return t=b+1,s(),e[t]===")"&&(t++,e[t]===";"&&t++),!0}for(;t<e.length&&!tc(e[t])&&!ki(e[t])&&(!O||e[t]!==":");)t++;if(e[t-1]===":"&&Qu.test(e.substring(q,t+2)))for(;t<e.length&&ec.test(e[t]);)t++;if(t>q){for(;bn(e,t-1)&&t>0;)t--;const b=e.slice(q,t);return n+=b==="undefined"?"null":JSON.stringify(b),e[t]==='"'&&t++,!0}}function M(){if(e[t]==="/"){const O=t;for(t++;t<e.length&&(e[t]!=="/"||e[t-1]==="\\");)t++;return t++,n+=JSON.stringify(e.substring(O,t)),!0}}function Y(O){let q=O;for(;q>0&&bn(e,q);)q--;return q}function C(){return t>=e.length||fi(e[t])||bn(e,t)}function B(O){n+=`${e.slice(O,t)}0`}function R(O){throw new Fn(`Invalid character ${JSON.stringify(O)}`,t)}function U(){throw new Fn(`Unexpected character ${JSON.stringify(e[t])}`,t)}function L(){throw new Fn("Unexpected end of json string",e.length)}function P(){throw new Fn("Object key expected",t)}function A(){throw new Fn("Colon expected",t)}function J(){const O=e.slice(t,t+6);throw new Fn(`Invalid unicode character "${O}"`,t)}}function kz(e,t){return e[t]==="*"&&e[t+1]==="/"}function Sz({json:e,context:t,scope:n}){const[r,i]=y.useState(!1),[s,a]=y.useState(null),o=y.useMemo(()=>{try{return JSON.parse(e),e}catch{}try{return sc(e)}catch{}const x=`{${e}}`;try{return JSON.parse(x),x}catch{}try{return sc(x)}catch{return null}},[e]),l=y.useMemo(()=>Yh(o||e),[o,e]),u=Ae(x=>x.activeTab),f=Ae(x=>x.documents),d=Ae(x=>(x.acceptedApplyIds||[]).includes(l)),p=Ae(x=>x.setPendingDiff),h=Ae(x=>x.createDocument),m=Ae(x=>x.openDocument),w=y.useCallback(()=>{if(o){a(null);try{if(u){const x=f.find(k=>k.name===u),_=(x==null?void 0:x.text)||"";if(n==="templates")try{const k=JSON.parse(_),N=JSON.parse(o);if(Array.isArray(N.templates)){k.props||(k.props={}),k.props.templates=Kh(k.props.templates||[],N.templates);const M=JSON.stringify(k,null,2);p(u,_,M,l);return}}catch{}const g=t==null?void 0:t[0],{original:T,modified:E}=Xh(_,o,g);p(u,T,E,l)}else{const x=`ai-generated-${Date.now()}`;h(x,o),m(x)}}catch(x){a(x instanceof Error?x.message:"Merge failed")}}},[o,u,f,p,h,m,t,n,l]),S=y.useCallback(async()=>{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),1500)},[e]);return c.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2 border-t",children:[c.jsxs("div",{className:"flex gap-1.5",children:[c.jsx(_e,{variant:"secondary",size:"sm",onClick:w,disabled:d||!o,children:d?"Applied":o?"Apply to Editor":"Invalid JSON"}),c.jsx(_e,{variant:"ghost",size:"sm",onClick:S,children:r?c.jsx(ln,{className:"h-3.5 w-3.5"}):c.jsx(es,{className:"h-3.5 w-3.5"})})]}),s&&c.jsx("p",{className:"text-xs text-destructive m-0",children:s})]})}function _z({threads:e,activeThread:t,disabled:n,onSwitch:r,onCreate:i,onDelete:s,onRename:a}){const[o,l]=y.useState(null),[u,f]=y.useState(""),[d,p]=y.useState(null),h=y.useRef(null),m=(t==null?void 0:t.title)||"New Chat",w=m.length>24?m.slice(0,24)+"...":m;y.useEffect(()=>{o&&requestAnimationFrame(()=>{var N;return(N=h.current)==null?void 0:N.focus()})},[o]);const S=y.useCallback((N,M)=>{M.stopPropagation(),M.preventDefault(),l(N.id),f(N.title),p(null)},[]),x=y.useCallback(()=>{o&&u.trim()&&a(o,u.trim()),l(null),f("")},[o,u,a]),_=y.useCallback(()=>{l(null),f("")},[]),g=y.useCallback(N=>{N.stopPropagation(),N.key==="Enter"?(N.preventDefault(),x()):N.key==="Escape"&&(N.preventDefault(),_())},[x,_]),T=y.useCallback((N,M)=>{M.stopPropagation(),M.preventDefault(),p(N),l(null)},[]),E=y.useCallback(N=>{N.stopPropagation(),N.preventDefault(),d&&(s(d),p(null))},[d,s]),k=y.useCallback(N=>{N.stopPropagation(),N.preventDefault(),p(null)},[]);return c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsxs(to,{onOpenChange:N=>{N||(l(null),p(null))},children:[c.jsx(no,{asChild:!0,disabled:n,children:c.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:[c.jsx("div",{className:"h-2 w-2 rounded-full bg-primary/70 shrink-0"}),c.jsx("span",{className:"truncate",children:w}),c.jsx(an,{className:"h-3 w-3 shrink-0 opacity-60"})]})}),c.jsxs(ls,{align:"start",className:"w-64",children:[e.map(N=>{const M=o===N.id;return d===N.id?c.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 text-sm",children:[c.jsx("span",{className:"text-red-400 text-xs flex-1 truncate",children:"Delete this thread?"}),c.jsx("button",{className:"shrink-0 text-red-400 hover:text-red-300 transition-colors cursor-pointer",onClick:E,children:c.jsx(ln,{className:"h-3.5 w-3.5"})}),c.jsx("button",{className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onClick:k,children:c.jsx(jn,{className:"h-3.5 w-3.5"})})]},N.id):M?c.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1",onClick:C=>C.stopPropagation(),onPointerDown:C=>C.stopPropagation(),children:[c.jsx("input",{ref:h,type:"text",value:u,onChange:C=>f(C.target.value),onKeyDown:g,onBlur:x,className:"flex-1 min-w-0 text-sm rounded border border-border bg-background px-1.5 py-0.5 outline-none focus:ring-1 focus:ring-primary/40"}),c.jsx("button",{className:"shrink-0 text-primary hover:text-primary/80 transition-colors cursor-pointer",onMouseDown:C=>{C.preventDefault(),x()},children:c.jsx(ln,{className:"h-3.5 w-3.5"})}),c.jsx("button",{className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onMouseDown:C=>{C.preventDefault(),_()},children:c.jsx(jn,{className:"h-3.5 w-3.5"})})]},N.id):c.jsxs(qt,{onSelect:()=>r(N.id),className:`group ${N.id===(t==null?void 0:t.id)?"bg-accent":""}`,children:[c.jsx("span",{className:"truncate flex-1",children:N.title.length>30?N.title.slice(0,30)+"...":N.title}),c.jsxs("div",{className:"ml-auto shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[c.jsx("button",{className:"text-muted-foreground hover:text-foreground transition-colors p-0.5 cursor-pointer",onClick:C=>S(N,C),children:c.jsx(og,{className:"h-3 w-3"})}),e.length>1&&c.jsx("button",{className:"text-muted-foreground hover:text-destructive transition-colors p-0.5 cursor-pointer",onClick:C=>T(N.id,C),children:c.jsx(Va,{className:"h-3 w-3"})})]})]},N.id)}),c.jsx(Or,{}),c.jsxs(qt,{onSelect:N=>{N.preventDefault();const M=i();M&&(l(M),f(Xa()),p(null))},children:[c.jsx(Si,{className:"h-3.5 w-3.5 mr-1.5"}),"New Chat"]})]})]}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-foreground",onClick:()=>i(),disabled:n,title:"New chat thread",children:c.jsx(Si,{className:"h-3.5 w-3.5"})})]})}const sm=new Set(["image/png","image/jpeg","image/gif","image/webp","application/pdf","text/plain","text/markdown","text/csv","text/html"]),jz=Array.from(sm).join(","),Cz=20*1024*1024,ac=10;function Nz(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t({type:"file",mediaType:e.type,filename:e.name,url:r.result}),r.onerror=n,r.readAsDataURL(e)})}function oc(e){return Array.from(e).filter(t=>sm.has(t.type)&&t.size<=Cz)}function am(e){return e.startsWith("image/")}function lc(){var G,pe,ke;const e=Te(D=>D.contextAttachments),t=Te(D=>D.addContext),n=Te(D=>D.removeContext),r=Te(D=>D.scope),i=Te(D=>D.setScope),s=Te(D=>D.model),a=Te(D=>D.setModel),o=Te(D=>D.openChat),l=Te(D=>D.closeChat),u=Te(D=>D.threads),f=Te(D=>D.activeThreadId),d=Te(D=>D.createThread),p=Te(D=>D.deleteThread),h=Te(D=>D.switchThread),m=Te(D=>D.updateThreadMessages),w=Te(D=>D.updateThreadTitle),S=Te(D=>D.deleteThreadsForDocument),x=Ae(D=>D.activeTab),_=Ae(D=>D.documents),{messages:g,sendMessage:T,status:E,error:k,setMessages:N,stop:M,getMessageContext:Y,getMessageScope:C}=ez(),[B,R]=y.useState(""),[U,L]=y.useState([]),[P,A]=y.useState(!1),[J,O]=y.useState(!1),q=y.useRef(null),b=y.useRef(null),ce=y.useRef(null),oe=y.useCallback(async D=>{const he=oc(D);if(he.length===0)return;const Ne=await Promise.all(he.map(Nz));L(Me=>{const tt=[...Me,...Ne];return tt.length>ac?tt.slice(0,ac):tt})},[]),v=y.useCallback(D=>{L(he=>he.filter((Ne,Me)=>Me!==D))},[]),X=y.useCallback(D=>{var Ne;const he=(Ne=D.clipboardData)==null?void 0:Ne.files;if(he&&he.length>0){const Me=oc(he);Me.length>0&&(D.preventDefault(),oe(Me))}},[oe]),ae=y.useCallback(D=>{var Ne;D.preventDefault(),O(!1);const he=(Ne=D.dataTransfer)==null?void 0:Ne.files;he&&he.length>0&&oe(Array.from(he))},[oe]),ne=y.useCallback(D=>{D.preventDefault(),O(!0)},[]),I=y.useCallback(()=>O(!1),[]),$=x?f[x]:void 0,W=$?u[$]:void 0,le=y.useMemo(()=>x?Object.values(u).filter(D=>D.documentName===x).sort((D,he)=>he.updatedAt-D.updatedAt):[],[u,x]);y.useEffect(()=>{x&&le.length===0&&d(x)},[x,le.length,d]);const K=y.useRef(u);K.current=u,y.useEffect(()=>{const D=new Set(_.map(Ne=>Ne.name)),he=new Set;for(const Ne of Object.values(K.current))!D.has(Ne.documentName)&&Ne.documentName!=="__migrated__"&&he.add(Ne.documentName);for(const Ne of he)S(Ne)},[_,S]);const ve=y.useRef(null);y.useEffect(()=>{ve.current!==$&&(ve.current=$,N((W==null?void 0:W.messages)??[]))},[$,W,N]),y.useEffect(()=>{var D;(D=q.current)==null||D.scrollIntoView({behavior:"smooth"})},[g,E]),y.useEffect(()=>{const D=he=>{var tt;const{documentName:Ne,selection:Me}=he.detail;t({...Me,documentName:Ne}),o(),(tt=b.current)==null||tt.focus()};return window.addEventListener("monaco-selection-to-ai",D),()=>window.removeEventListener("monaco-selection-to-ai",D)},[t,o]);const de=E==="streaming",xe=E==="submitted"||de,Ue=y.useCallback(D=>{D.preventDefault(),!(!B.trim()&&U.length===0||xe)&&(T(B,U.length>0?U:void 0),R(""),L([]))},[B,U,xe,T]),rt=y.useCallback(D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),Ue(D))},[Ue]),Ge=y.useCallback(()=>{g.length!==0&&A(!0)},[g.length]),j=y.useCallback(()=>{A(!1),N([]),$&&(m($,[]),w($,Xa()))},[N,$,m,w]),[z,Z]=y.useState(null),re=y.useCallback(D=>{Z(D)},[]),te=y.useCallback(()=>{var tt,Ke;if(!z)return;const D=g.findIndex(it=>it.id===z);if(D===-1){Z(null);return}const he=g[D],Ne=new Set([D]);he.role==="user"&&((tt=g[D+1])==null?void 0:tt.role)==="assistant"?Ne.add(D+1):he.role==="assistant"&&D>0&&((Ke=g[D-1])==null?void 0:Ke.role)==="user"&&Ne.add(D-1);const Me=g.filter((it,Xt)=>!Ne.has(Xt));N(Me),$&&m($,Me),Z(null)},[z,g,N,$,m]),ee=y.useCallback(D=>{if(!xe){if(le.length<=1){Ge();return}p(D)}},[xe,le.length,Ge,p]),fe=y.useCallback(()=>{if(!(!x||xe))return d(x)},[x,xe,d]),be=y.useCallback(D=>{xe||D===$||h(D)},[xe,$,h]),F=y.useCallback((D,he)=>{w(D,he)},[w]);return c.jsxs("div",{className:"flex flex-col h-full border-l bg-surface-chat",children:[c.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border/60 bg-surface-chat",children:[c.jsx(_z,{threads:le,activeThread:W,disabled:xe,onSwitch:be,onCreate:fe,onDelete:ee,onRename:F}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(_e,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:Ge,disabled:xe||g.length===0,children:"Clear"}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:l,title:"Close chat",children:c.jsx(jn,{className:"h-3.5 w-3.5"})})]})]}),c.jsx(Pr,{className:"flex-1 min-h-0 [&_[data-radix-scroll-area-viewport]>div]:!block",children:c.jsxs("div",{className:"p-3 space-y-4 min-w-0",children:[g.length===0&&c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-4",children:[c.jsx("div",{className:"rounded-xl bg-primary/10 p-3 mb-4",children:c.jsx(Zo,{className:"h-5 w-5 text-primary"})}),c.jsx("p",{className:"text-sm font-medium text-foreground/80 mb-1",children:"JSON Assistant"}),c.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."}),c.jsxs("div",{className:"flex items-center gap-1.5 rounded-md bg-muted/50 px-2.5 py-1.5",children:[c.jsx(ya,{shortcut:"mod+k"}),c.jsx("span",{className:"text-xs text-muted-foreground",children:"to send a selection"})]})]}),g.map((D,he)=>{let Ne;if(D.role==="user"){const Ke=Y(D.id);Ke&&Ke.length>0&&(Ne=Ke)}else if(D.role==="assistant"){for(let Ke=he-1;Ke>=0;Ke--)if(g[Ke].role==="user"){Ne=Y(g[Ke].id);break}}const Me=de&&he===g.length-1&&D.role==="assistant",tt=D.role==="user"?C(D.id):void 0;return c.jsx(Ez,{msg:D,isStreaming:Me,context:Ne,scope:tt,onDelete:xe?void 0:re},D.id)}),xe&&((G=g[g.length-1])==null?void 0:G.role)!=="assistant"&&c.jsx("div",{className:"flex justify-start",children:c.jsx("div",{className:"rounded-lg px-3 py-2 bg-muted/60 border border-border/40",children:c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(aa,{className:"h-3.5 w-3.5 animate-spin text-primary"}),c.jsx("span",{children:"Thinking..."})]})})}),k&&!xe&&c.jsx("div",{className:"flex justify-start",children:c.jsx("div",{className:"rounded-lg px-3 py-2 bg-destructive/10 border border-destructive/30 text-destructive text-sm max-w-[90%]",children:k.message||"Something went wrong"})}),c.jsx("div",{ref:q})]})}),c.jsxs("div",{className:`border-t border-border/60 p-2.5 space-y-2 bg-surface-chat transition-colors ${J?"ring-2 ring-primary/40 bg-primary/5":""}`,onDrop:ae,onDragOver:ne,onDragLeave:I,children:[e.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.map((D,he)=>c.jsx(em,{context:D,onRemove:()=>n(he)},he))}),c.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[c.jsx(Tz,{model:s,setModel:a}),kt==="pptx"&&x&&c.jsx(Pz,{scope:r,setScope:i,docSize:((ke=(pe=_.find(D=>D.name===x))==null?void 0:pe.text)==null?void 0:ke.length)??0})]}),U.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1.5",children:U.map((D,he)=>c.jsxs("div",{className:"relative group",children:[am(D.mediaType)?c.jsx("img",{src:D.url,alt:D.filename||"attachment",className:"h-14 w-14 rounded-md object-cover border border-border/60"}):c.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:[c.jsx(oa,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),c.jsx("span",{className:"text-xs truncate text-muted-foreground",children:D.filename||"file"})]}),c.jsx("button",{type:"button",onClick:()=>v(he),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:c.jsx(jn,{className:"h-3 w-3"})})]},he))}),c.jsxs("form",{onSubmit:Ue,className:"flex items-end gap-2",children:[c.jsx("input",{ref:ce,type:"file",accept:jz,multiple:!0,className:"hidden",onChange:D=>{D.target.files&&oe(Array.from(D.target.files)),D.target.value=""}}),c.jsx(_e,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 h-9 w-9 rounded-lg text-muted-foreground hover:text-foreground",onClick:()=>{var D;return(D=ce.current)==null?void 0:D.click()},title:"Attach file",children:c.jsx(oa,{className:"h-4 w-4"})}),c.jsx("textarea",{ref:b,value:B,onChange:D=>{R(D.target.value);const he=D.target;he.style.height="auto",he.style.height=`${Math.min(he.scrollHeight,128)}px`},onKeyDown:rt,onPaste:X,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}),xe?c.jsx(_e,{type:"button",size:"icon",variant:"destructive",className:"shrink-0 h-9 w-9 rounded-lg",onClick:M,title:"Stop generating",children:c.jsx(lg,{className:"h-4 w-4"})}):c.jsx(_e,{type:"submit",size:"icon",disabled:!B.trim()&&U.length===0,className:"shrink-0 h-9 w-9 rounded-lg",children:c.jsx(Zo,{className:"h-4 w-4"})})]})]}),c.jsx(Dt,{open:P,onOpenChange:A,children:c.jsxs(Et,{className:"max-w-sm",children:[c.jsxs(Gt,{children:[c.jsx(Kt,{children:"Clear thread"}),c.jsx(Cn,{children:"This will delete all messages in this thread. This action cannot be undone."})]}),c.jsxs(Yn,{children:[c.jsx(Xo,{asChild:!0,children:c.jsx(_e,{variant:"ghost",size:"sm",children:"Cancel"})}),c.jsx(_e,{variant:"destructive",size:"sm",onClick:j,children:"Clear"})]})]})}),c.jsx(Dt,{open:z!==null,onOpenChange:D=>{D||Z(null)},children:c.jsxs(Et,{className:"max-w-sm",children:[c.jsxs(Gt,{children:[c.jsx(Kt,{children:"Delete message"}),c.jsx(Cn,{children:"This will delete the message and its paired response. This action cannot be undone."})]}),c.jsxs(Yn,{children:[c.jsx(Xo,{asChild:!0,children:c.jsx(_e,{variant:"ghost",size:"sm",children:"Cancel"})}),c.jsx(_e,{variant:"destructive",size:"sm",onClick:te,children:"Delete"})]})]})})]})}const Ez=y.memo(function({msg:t,isStreaming:n,context:r,scope:i,onDelete:s}){var l,u;const a=((l=t.parts)==null?void 0:l.filter(f=>f.type==="text").map(f=>f.text).join(""))||"",o=((u=t.parts)==null?void 0:u.filter(f=>f.type==="file"))||[];return c.jsx("div",{className:`group/msg flex ${t.role==="user"?"justify-end":"justify-start"}`,children:c.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"?c.jsxs("div",{children:[o.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1 mb-1.5",children:o.map((f,d)=>am(f.mediaType)?c.jsx("img",{src:f.url,alt:f.filename||"image",className:"h-20 max-w-[160px] rounded object-cover"},d):c.jsxs("div",{className:"flex items-center gap-1.5 rounded bg-primary-foreground/20 px-2 py-1",children:[c.jsx(oa,{className:"h-3 w-3 shrink-0"}),c.jsx("span",{className:"text-xs truncate max-w-[120px]",children:f.filename||"file"})]},d))}),r&&r.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1 mb-1.5",children:r.map((f,d)=>c.jsx(em,{context:f,variant:"sent"},d))}),a&&c.jsx("div",{className:"whitespace-pre-wrap text-sm break-words",children:a}),i&&i!=="global"&&c.jsx("span",{className:"text-[10px] text-primary-foreground/60 mt-0.5 block text-right",children:i})]}):c.jsx(Iz,{text:a,isStreaming:n,context:r,scope:i}),s&&!n&&c.jsx("div",{className:"opacity-0 group-hover/msg:opacity-100 transition-opacity mt-1",children:c.jsx("button",{type:"button",onClick:()=>s(t.id),className:`p-0.5 rounded cursor-pointer ${t.role==="user"?"text-primary-foreground/50 hover:text-primary-foreground/80":"text-muted-foreground hover:text-destructive"}`,children:c.jsx(Va,{className:"h-3 w-3"})})})]})})},(e,t)=>e.msg.id===t.msg.id&&e.isStreaming===t.isStreaming&&e.scope===t.scope&&e.onDelete===t.onDelete&&e.context===t.context);function Iz({text:e,isStreaming:t,context:n,scope:r}){return t?c.jsx("div",{className:"text-sm prose prose-sm dark:prose-invert break-words [&_pre]:overflow-x-auto [&_p]:my-1",children:c.jsx("pre",{className:"whitespace-pre-wrap font-sans text-sm m-0 p-0 bg-transparent border-none",children:e})}):c.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:c.jsx(nk,{remarkPlugins:[m1],components:{pre:({children:i})=>c.jsx(c.Fragment,{children:i}),code:({className:i,children:s})=>{const a=i==null?void 0:i.startsWith("language-"),o=(i==null?void 0:i.replace("language-",""))||"",l=String(s).replace(/\n$/,"");if(!a)return c.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs font-mono",children:s});const u=o==="json"||o==="jsonc";return c.jsxs("div",{className:"my-2 rounded-lg border bg-card",children:[c.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-muted/60 border-b text-xs text-muted-foreground",children:[c.jsx("span",{className:"font-mono",children:o||"code"}),!u&&c.jsx(Oz,{text:l})]}),c.jsx("pre",{className:"p-3 text-xs font-mono overflow-x-auto max-h-80 overflow-y-auto m-0",children:c.jsx("code",{children:l})}),u&&c.jsx(Sz,{json:l,context:n,scope:r})]})}},children:e})})}const zz=[{value:"opus",label:"Opus"},{value:"sonnet",label:"Sonnet"},{value:"haiku",label:"Haiku"}];function Tz({model:e,setModel:t}){return c.jsxs(Ka,{value:e,onValueChange:n=>t(n),children:[c.jsx(ss,{className:"h-6 w-auto gap-1 border-none bg-muted/40 px-2 py-0 text-[10px] shadow-none focus:ring-0",children:c.jsx(Ya,{})}),c.jsx(as,{children:zz.map(n=>c.jsx(Ar,{value:n.value,className:"text-xs",children:n.label},n.value))})]})}const uc={global:"AI sees and edits the entire document",slides:"AI sees and edits only slides — templates stay unchanged",templates:"AI sees and edits only template layouts — slides stay unchanged"},Az=1e5;function Pz({scope:e,setScope:t,docSize:n}){return c.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Scope"}),c.jsx("div",{className:"flex items-center bg-muted/40 rounded-md p-0.5 gap-px",children:Object.keys(uc).map(r=>c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:c.jsx("button",{type:"button",onClick:()=>t(r),className:`px-2 py-0.5 rounded text-[10px] cursor-pointer transition-colors ${e===r?"bg-background text-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:r})}),c.jsx(et,{side:"top",className:"text-xs max-w-[200px]",children:uc[r]})]},r))})]}),e==="global"&&n>Az&&c.jsxs("div",{className:"text-[10px] text-amber-500 flex items-center gap-1",children:[c.jsx(Qc,{className:"h-3 w-3 shrink-0"}),c.jsxs("span",{children:["Large doc — switch to"," ",c.jsx("button",{type:"button",onClick:()=>t("slides"),className:"underline cursor-pointer hover:text-amber-400",children:"slides"})," ","or"," ",c.jsx("button",{type:"button",onClick:()=>t("templates"),className:"underline cursor-pointer hover:text-amber-400",children:"templates"})]})]})]})}function Oz({text:e}){const[t,n]=y.useState(!1),r=y.useCallback(async()=>{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)},[e]);return c.jsx("button",{onClick:r,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:t?"Copied!":"Copy"})}function Dz({discoveryData:e}){const t=Pd(),n=px(),r=Te(C=>C.chatOpen),i=Te(C=>C.toggleChat),[s,a]=y.useState(()=>{try{const C=localStorage.getItem("dev-env.sidebar-open");return n?!1:C?C==="true":!0}catch{return!n}}),[o,l]=y.useState(()=>{try{const C=localStorage.getItem("dev-env.preview-open");return C?C==="true":!0}catch{return!0}}),[u,f]=y.useState("editor"),[d,p]=y.useState(!1),h=150,[m,w]=y.useState(!s),[S,x]=y.useState(!1);y.useEffect(()=>{try{localStorage.setItem("dev-env.sidebar-open",String(s))}catch{}},[s]),y.useEffect(()=>{try{localStorage.setItem("dev-env.preview-open",String(o))}catch{}},[o]);const _=y.useRef(n);y.useEffect(()=>{n&&!_.current&&s&&(x(!0),a(!1),setTimeout(()=>{w(!0),x(!1)},h)),!n&&_.current&&!s&&(x(!0),a(!0),setTimeout(()=>{w(!1),x(!1)},h)),_.current=n},[n,s]);const g=y.useCallback(()=>{if(t){p(C=>!C);return}x(!0),a(C=>!C),setTimeout(()=>{w(C=>!C),x(!1)},h)},[t]),T=y.useCallback(()=>l(C=>!C),[]),E=y.useRef(i),k=y.useRef(g),N=y.useRef(T);y.useEffect(()=>{E.current=i}),y.useEffect(()=>{k.current=g}),y.useEffect(()=>{N.current=T}),y.useEffect(()=>{const C=B=>{(B.metaKey||B.ctrlKey)&&(B.code==="KeyB"&&!B.shiftKey&&(B.preventDefault(),k.current()),B.code==="KeyJ"&&B.shiftKey&&(B.preventDefault(),B.stopPropagation(),E.current()),B.code==="KeyP"&&B.shiftKey&&(B.preventDefault(),N.current()))};return window.addEventListener("keydown",C,!0),()=>window.removeEventListener("keydown",C,!0)},[]);const M=QI,Y=[{key:"editor",icon:ed,label:"Editor"},{key:"preview",icon:td,label:"Preview"},{key:"chat",icon:nd,label:"Chat"}];return t?c.jsx(M,{children:c.jsxs("div",{className:"flex flex-col h-full w-full overflow-hidden",children:[c.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b bg-sidebar shrink-0",children:[c.jsxs(zd,{open:d,onOpenChange:p,children:[c.jsx(lx,{asChild:!0,children:c.jsx(_e,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:c.jsx(Yc,{className:"h-4 w-4"})})}),c.jsx(Qa,{side:"left",className:"p-0 w-72",children:c.jsx(tl,{discoveryData:e,onToggleSidebar:()=>p(!1),isCollapsed:!1})})]}),c.jsx("div",{className:"flex gap-0.5 flex-1 min-w-0",children:Y.map(({key:C,icon:B,label:R})=>c.jsxs(_e,{variant:u===C?"default":"ghost",size:"sm",className:"h-7 gap-1.5 text-xs flex-1",onClick:()=>f(C),children:[c.jsx(B,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"hidden xs:inline",children:R})]},C))})]}),u!=="chat"&&c.jsx(yl,{previewOpen:o,onTogglePreview:T}),c.jsxs("div",{className:"flex-1 min-h-0",children:[u==="editor"&&c.jsx("div",{className:"h-full bg-surface-editor",children:c.jsx(nl,{})}),u==="preview"&&c.jsx("div",{className:"h-full bg-surface-preview",children:c.jsx(rl,{})}),u==="chat"&&c.jsx(lc,{})]})]})}):c.jsx(M,{children:c.jsxs("div",{className:"flex h-full w-full overflow-hidden",children:[c.jsx("div",{className:H("shrink-0 overflow-hidden border-r bg-sidebar","transition-[width] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)]",s?"w-64":"w-12"),children:c.jsx(tl,{discoveryData:e,onToggleSidebar:g,isCollapsed:m,isAnimating:S})}),c.jsxs("div",{className:"flex-1 min-w-0 flex flex-col h-full",children:[c.jsx(yl,{previewOpen:o,onTogglePreview:T}),c.jsxs(Ny,{direction:"horizontal",autoSaveId:"layout-main",className:"flex-1 min-h-0",children:[c.jsx(Os,{defaultSize:o?50:100,minSize:20,id:"editor",order:1,children:c.jsx("div",{className:"h-full bg-surface-editor",children:c.jsx(nl,{})})}),o&&c.jsxs(c.Fragment,{children:[c.jsx(pl,{withHandle:!0}),c.jsx(Os,{defaultSize:50,minSize:20,id:"preview",order:2,children:c.jsx("div",{className:"h-full bg-surface-preview",children:c.jsx(rl,{})})})]}),r&&c.jsxs(c.Fragment,{children:[c.jsx(pl,{withHandle:!0}),c.jsx(Os,{defaultSize:30,minSize:25,maxSize:50,id:"chat",order:3,children:c.jsx(lc,{})})]})]})]})]})})}function Rz(){const[e,t]=y.useState(null),[n,r]=y.useState(!0),[i,s]=y.useState(null),a=y.useCallback(async()=>{r(!0),s(null);try{const o=await fetch("/api/discovery/all");if(!o.ok)throw new Error(`Discovery failed: ${o.statusText}`);const l=await o.json();if(!l.success)throw new Error(l.error||"Discovery failed");t(l.data)}catch(o){console.error("Discovery error:",o),s(o instanceof Error?o.message:"Failed to fetch discovered items"),t({plugins:[],documents:[],themes:[]})}finally{r(!1)}},[]);return y.useEffect(()=>{a()},[a]),{data:e,loading:n,error:i,refetch:a}}function Mz(){const[e,t]=y.useState(!1),[n,r]=y.useState(null),[i,s]=y.useState(0);return{loadPlugins:y.useCallback(async()=>{t(!0),r(null);try{const o=await fetch("/api/discovery/load-plugins",{method:"POST"});if(!o.ok)throw new Error(`Failed to load plugins: ${o.statusText}`);const l=await o.json();if(!l.success)throw new Error(l.error||"Failed to load plugins");return s(l.data.loaded),!0}catch(o){return console.error("Plugin loading error:",o),r(o instanceof Error?o.message:"Failed to load plugins"),!1}finally{t(!1)}},[]),loading:e,error:n,loadedCount:i}}function $z(){const{data:e,loading:t,error:n}=Rz(),{loadPlugins:r}=Mz(),i=Ot(s=>s.applyPluginsWithValidation);return y.useEffect(()=>{e&&e.plugins.length>0&&r().then(s=>{if(s){console.log("Plugins loaded successfully");const a=Ot.getState().selectedPlugins;a.size>0&&(console.log("Auto-applying persisted plugin selections:",Array.from(a)),i())}})},[e,r,i]),t?c.jsx("div",{className:"flex items-center justify-center h-screen",children:c.jsxs("div",{className:"text-center",children:[c.jsx("div",{className:"text-lg font-medium",children:"Discovering project resources..."}),c.jsx("div",{className:"text-sm text-muted-foreground mt-2",children:"Searching for documents, themes, and plugins"})]})}):n?c.jsx("div",{className:"flex items-center justify-center h-screen",children:c.jsxs("div",{className:"text-center",children:[c.jsx("div",{className:"text-lg font-medium text-destructive",children:"Discovery failed"}),c.jsx("div",{className:"text-sm text-muted-foreground mt-2",children:n}),c.jsx("div",{className:"text-xs text-muted-foreground mt-4",children:"The playground will work with limited functionality."})]})}):c.jsx(cg,{children:c.jsx(dg,{children:c.jsx(fg,{children:c.jsx(pg,{children:c.jsx(hg,{children:c.jsx(Gg,{children:c.jsx(Dd,{children:c.jsx("section",{className:"flex h-screen w-full flex-col",children:c.jsx("div",{className:"grow overflow-hidden",children:c.jsx(Dz,{discoveryData:e})})})})})})})})})})}const Wz=Object.freeze(Object.defineProperty({__proto__:null,HomePage:$z},Symbol.toStringTag,{value:"Module"}));export{kn as B,Dt as D,Wz as H,Ry as P,Er as S,Rr as T,Jd as a,Id as b,Et as c,Gt as d,Kt as e,Ay as u};
|
|
99
|
+
//# sourceMappingURL=HomePage-CtePCdPD.js.map
|