@json-to-office/jto 0.3.0 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -1
- package/dist/client/assets/HomePage-9ryiIVJl.js +99 -0
- package/dist/client/assets/HomePage-9ryiIVJl.js.map +1 -0
- package/dist/client/assets/JsonEditorPage-BO0AtnI3.js +3 -0
- package/dist/client/assets/{JsonEditorPage-DKor0I6f.js.map → JsonEditorPage-BO0AtnI3.js.map} +1 -1
- package/dist/client/assets/MonacoPluginProvider-BE7Xjhup.js +3 -0
- package/dist/client/assets/{MonacoPluginProvider-BGYshg9R.js.map → MonacoPluginProvider-BE7Xjhup.js.map} +1 -1
- package/dist/client/assets/NotFoundPage-SV9cseZ6.js +2 -0
- package/dist/client/assets/{NotFoundPage-ILCklaD-.js.map → NotFoundPage-SV9cseZ6.js.map} +1 -1
- package/dist/client/assets/button-DghEEchK.js +2 -0
- package/dist/client/assets/{button-BzUKH2aN.js.map → button-DghEEchK.js.map} +1 -1
- package/dist/client/assets/{docx-preview-DkKCgwb-.js → docx-preview-DQa8jhzH.js} +3 -3
- package/dist/client/assets/{docx-preview-DkKCgwb-.js.map → docx-preview-DQa8jhzH.js.map} +1 -1
- package/dist/client/assets/{editor-BS2qlF-X.js → editor-BxyYhgT1.js} +2 -2
- package/dist/client/assets/{editor-BS2qlF-X.js.map → editor-BxyYhgT1.js.map} +1 -1
- package/dist/client/assets/{editor-monaco-json-DKrX3IiN.js → editor-monaco-json-PlUCgtCX.js} +3 -3
- package/dist/client/assets/{editor-monaco-json-DKrX3IiN.js.map → editor-monaco-json-PlUCgtCX.js.map} +1 -1
- package/dist/client/assets/index-DSzthtfQ.js +3 -0
- package/dist/client/assets/{index-D_aKAAFg.js.map → index-DSzthtfQ.js.map} +1 -1
- package/dist/client/assets/{monaco-editor-B-NlkJ5A.js → monaco-editor-BcgxPCqT.js} +3 -3
- package/dist/client/assets/{monaco-editor-B-NlkJ5A.js.map → monaco-editor-BcgxPCqT.js.map} +1 -1
- package/dist/client/assets/preview-BBQhSmsm.js +3 -0
- package/dist/client/assets/{preview-AJZwEEO9.js.map → preview-BBQhSmsm.js.map} +1 -1
- package/dist/client/assets/query-vendor-Df8-oete.js +7 -0
- package/dist/client/assets/query-vendor-Df8-oete.js.map +1 -0
- package/dist/client/assets/radix-ui-BZ5iKMtq.js +51 -0
- package/dist/client/assets/radix-ui-BZ5iKMtq.js.map +1 -0
- package/dist/client/assets/react-vendor-CTFDOf2G.js +61 -0
- package/dist/client/assets/react-vendor-CTFDOf2G.js.map +1 -0
- package/dist/client/assets/{state-vendor-Az8redj0.js → state-vendor-BDrPu9qj.js} +2 -2
- package/dist/client/assets/{state-vendor-Az8redj0.js.map → state-vendor-BDrPu9qj.js.map} +1 -1
- package/dist/client/assets/{ui-vendor-ChWVh3T-.js → ui-vendor-Dyg3GRT-.js} +2 -2
- package/dist/client/assets/{ui-vendor-ChWVh3T-.js.map → ui-vendor-Dyg3GRT-.js.map} +1 -1
- package/dist/client/index.html +6 -6
- package/dist/prompts/instructions-docx.md +46 -0
- package/dist/prompts/instructions-edit-document-docx.md +54 -0
- package/dist/prompts/instructions-edit-document-pptx-slides.md +40 -0
- package/dist/prompts/instructions-edit-document-pptx-templates.md +48 -0
- package/dist/prompts/instructions-edit-document-pptx.md +49 -0
- package/dist/prompts/instructions-edit-document.md +28 -0
- package/dist/prompts/instructions-edit-pptx.md +31 -0
- package/dist/prompts/instructions-edit.md +24 -0
- package/dist/prompts/instructions-generate-docx.md +10 -0
- package/dist/prompts/instructions-generate-pptx.md +24 -0
- package/dist/prompts/instructions-generate.md +21 -0
- package/dist/prompts/pptx-core.md +180 -0
- package/dist/prompts/pptx-design.md +209 -0
- package/dist/prompts/system-theme.md +28 -0
- package/dist/prompts/system.md +30 -0
- package/package.json +17 -17
- package/dist/client/assets/HomePage-muPAe_M2.js +0 -99
- package/dist/client/assets/HomePage-muPAe_M2.js.map +0 -1
- package/dist/client/assets/JsonEditorPage-DKor0I6f.js +0 -3
- package/dist/client/assets/MonacoPluginProvider-BGYshg9R.js +0 -3
- package/dist/client/assets/NotFoundPage-ILCklaD-.js +0 -2
- package/dist/client/assets/button-BzUKH2aN.js +0 -2
- package/dist/client/assets/index-D_aKAAFg.js +0 -3
- package/dist/client/assets/preview-AJZwEEO9.js +0 -3
- package/dist/client/assets/query-vendor-CT0SoqJh.js +0 -15
- package/dist/client/assets/query-vendor-CT0SoqJh.js.map +0 -1
- package/dist/client/assets/radix-ui-DkKm4m5M.js +0 -2
- package/dist/client/assets/radix-ui-DkKm4m5M.js.map +0 -1
- package/dist/client/assets/react-vendor-B_QXlk-T.js +0 -102
- package/dist/client/assets/react-vendor-B_QXlk-T.js.map +0 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-BxyYhgT1.js","assets/react-vendor-CTFDOf2G.js","assets/editor-monaco-json-PlUCgtCX.js","assets/index-DSzthtfQ.js","assets/query-vendor-Df8-oete.js","assets/radix-ui-BZ5iKMtq.js","assets/ui-vendor-Dyg3GRT-.js","assets/monaco-editor-BcgxPCqT.js","assets/index-Cph82KFG.css","assets/MonacoPluginProvider-BE7Xjhup.js","assets/state-vendor-BDrPu9qj.js","assets/button-DghEEchK.js","assets/preview-BBQhSmsm.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var rm=Object.defineProperty;var im=(e,t,n)=>t in e?rm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Po=(e,t,n)=>im(e,typeof t!="symbol"?t+"":t,n);import{c as Ee,r as v,j as c,R as oc,g as Ra}from"./react-vendor-CTFDOf2G.js";import{B as Ie}from"./button-DghEEchK.js";import{c as V,T as Yr,C as sm,E as am,F as Nt,S as Qt,a as om,b as Xe,d as Qe,e as et,u as lc,f as Ma,s as hs,_ as uc,g as Xr,A as lm,h as Qr}from"./index-DSzthtfQ.js";import{b as cc,c as $a,d as dc,e as fc,f as Vi,g as Ui,D as Ji,O as Hi,h as pc,S as tr,i as um,V as cm,j as hc,I as dm,k as fm,l as mc,m as pm,n as gc,o as hm,p as mm,G as gm,q as xc,r as yc,L as bc,s as vc,t as xm,u as ym,v as bm,w as wc,x as kc,y as Sc,z as _c,A as jc,B as Cc,E as Nc,F as Ec,H as Ic,J as zc,K as Tc,M as vm,N as wm,Q as Ac,U as km,W as Sm,X as _m,Y as jm,Z as Cm,_ as Nm,$ as Em,a0 as Im,a1 as zm,a2 as Pc,a3 as Oc,a4 as Dc,a5 as Rc,a6 as Mc,a7 as $c,a8 as Fc,a9 as Lc,aa as Zc,ab as Tm,ac as Bc,ad as Vc,ae as Uc}from"./radix-ui-BZ5iKMtq.js";import{X as kn,a as Ur,C as rn,b as Sn,d as Am,e as qi,f as Jc,P as Pm,g as Oo,h as mr,F as Hc,S as qc,B as Do,i as Om,j as Dm,k as Rm,l as Fa,m as Mm,M as $m,n as Fm,o as Lm,p as Wc,q as Zm,r as ms,s as bi,t as Ro,I as Gc,G as Bm,u as Vm,R as Um,v as Jm,T as Kc,E as Hm,w as qm,x as Wm,y as Yc,z as La,A as Xc,D as Gm,H as Qc,J as Km,K as Ym,L as Mo,N as Xm,O as Ys,Q as Qm}from"./ui-vendor-Dyg3GRT-.js";import{i as eg,u as Ge,a as Xs,b as mn,g as Qs,c as Pt,T as tg,d as ei,S as ng,O as rg,e as ig,M as sg,D as ag}from"./MonacoPluginProvider-BE7Xjhup.js";import{c as og,d as lg,p as ug,a as cg,u as dg,b as fg}from"./state-vendor-BDrPu9qj.js";import{b as pg}from"./query-vendor-Df8-oete.js";var Jr=e=>e.type==="checkbox",yn=e=>e instanceof Date,lt=e=>e==null;const ed=e=>typeof e=="object";var He=e=>!lt(e)&&!Array.isArray(e)&&ed(e)&&!yn(e),td=e=>He(e)&&e.target?Jr(e.target)?e.target.checked:e.target.value:e,hg=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,nd=(e,t)=>e.has(hg(t)),mg=e=>{const t=e.constructor&&e.constructor.prototype;return He(t)&&t.hasOwnProperty("isPrototypeOf")},Za=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function pt(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(!(Za&&(e instanceof Blob||r))&&(n||He(e)))if(t=n?[]:{},!n&&!mg(e))t=e;else for(const i in e)e.hasOwnProperty(i)&&(t[i]=pt(e[i]));else return e;return t}var Wi=e=>Array.isArray(e)?e.filter(Boolean):[],Je=e=>e===void 0,se=(e,t,n)=>{if(!t||!He(e))return n;const r=Wi(t.split(/[,[\].]+?/)).reduce((i,s)=>lt(i)?i:i[s],e);return Je(r)||r===e?Je(e[t])?n:e[t]:r},jt=e=>typeof e=="boolean",Ba=e=>/^\w*$/.test(e),rd=e=>Wi(e.replace(/["|']|\]/g,"").split(/\.|\[/)),Pe=(e,t,n)=>{let r=-1;const i=Ba(t)?[t]:rd(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=He(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 vi={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},At={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Jt={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},id=Ee.createContext(null),Gi=()=>Ee.useContext(id),gg=e=>{const{children:t,...n}=e;return Ee.createElement(id.Provider,{value:n},t)};var sd=(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]!==At.all&&(t._proxyFormState[a]=!r||At.all),n&&(n[a]=!0),e[a]}});return i},ht=e=>He(e)&&!Object.keys(e).length,ad=(e,t,n,r)=>{n(e);const{name:i,...s}=e;return ht(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(a=>t[a]===(!r||At.all))},_r=e=>Array.isArray(e)?e:[e],od=(e,t,n)=>!e||!t||e===t||_r(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r)));function Va(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 xg(e){const t=Gi(),{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,Va({disabled:r,next:d=>l.current&&od(f.current,d.name,s)&&ad(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(()=>sd(a,n,u.current,!1),[a,n])}var Lt=e=>typeof e=="string",ld=(e,t,n,r,i)=>Lt(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 yg(e){const t=Gi(),{control:n=t.control,name:r,defaultValue:i,disabled:s,exact:a}=e||{},o=Ee.useRef(r);o.current=r,Va({disabled:s,subject:n._subjects.values,next:f=>{od(o.current,f.name,a)&&u(pt(ld(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 bg(e){const t=Gi(),{name:n,disabled:r,control:i=t.control,shouldUnregister:s}=e,a=nd(i._names.array,n),o=yg({control:i,name:n,defaultValue:se(i._formValues,n,se(i._defaultValues,n,e.defaultValue)),exact:!0}),l=xg({control:i,name:n,exact:!0}),u=Ee.useRef(i.register(n,{...e.rules,value:o,...jt(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,...jt(r)||l.disabled?{disabled:l.disabled||r}:{},onChange:h=>u.current.onChange({target:{value:td(h),name:n},type:vi.CHANGE}),onBlur:()=>u.current.onBlur({target:{value:se(i._formValues,n),name:n},type:vi.BLUR}),ref:h=>{const p=se(i._fields,n);p&&h&&(p._f.ref={focus:()=>h.focus(),select:()=>h.select(),setCustomValidity:m=>h.setCustomValidity(m),reportValidity:()=>h.reportValidity()})}}),[n,i._formValues,r,l.disabled,o,i._fields]);return Ee.useEffect(()=>{const h=i._options.shouldUnregister||s,p=(m,w)=>{const S=se(i._fields,m);S&&S._f&&(S._f.mount=w)};if(p(n,!0),h){const m=pt(se(i._options.defaultValues,n));Pe(i._defaultValues,n,m),Je(se(i._formValues,n))&&Pe(i._formValues,n,m)}return!a&&i.register(n),()=>{(a?h&&!i._state.action:h)?i.unregister(n):p(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 vg=e=>e.render(bg(e));var wg=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},$o=e=>({isOnSubmit:!e||e===At.onSubmit,isOnBlur:e===At.onBlur,isOnChange:e===At.onChange,isOnAll:e===At.all,isOnTouch:e===At.onTouched}),Fo=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const jr=(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(jr(o,t))break}else if(He(o)&&jr(o,t))break}}};var kg=(e,t,n)=>{const r=_r(se(e,n));return Pe(r,"root",t[n]),Pe(e,n,r),e},Ua=e=>e.type==="file",Ft=e=>typeof e=="function",wi=e=>{if(!Za)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},di=e=>Lt(e),Ja=e=>e.type==="radio",ki=e=>e instanceof RegExp;const Lo={value:!1,isValid:!1},Zo={value:!0,isValid:!0};var ud=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&&!Je(e[0].attributes.value)?Je(e[0].value)||e[0].value===""?Zo:{value:e[0].value,isValid:!0}:Zo:Lo}return Lo};const Bo={isValid:!1,value:null};var cd=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,Bo):Bo;function Vo(e,t,n="validate"){if(di(e)||Array.isArray(e)&&e.every(di)||jt(e)&&!e)return{type:n,message:di(e)?e:"",ref:t}}var Tn=e=>He(e)&&!ki(e)?e:{value:e,message:""},Uo=async(e,t,n,r,i,s)=>{const{ref:a,refs:o,required:l,maxLength:u,minLength:f,min:d,max:h,pattern:p,validate:m,name:w,valueAsNumber:S,mount:x}=e._f,_=se(n,w);if(!x||t.has(w))return{};const y=o?o[0]:a,P=R=>{i&&y.reportValidity&&(y.setCustomValidity(jt(R)?"":R||""),y.reportValidity())},N={},k=Ja(a),j=Jr(a),$=k||j,W=(S||Ua(a))&&Je(a.value)&&Je(_)||wi(a)&&a.value===""||_===""||Array.isArray(_)&&!_.length,E=wg.bind(null,w,r,N),U=(R,B,L,T=Jt.maxLength,H=Jt.minLength)=>{const Y=R?B:L;N[w]={type:R?T:H,message:Y,ref:a,...E(R?T:H,Y)}};if(s?!Array.isArray(_)||!_.length:l&&(!$&&(W||lt(_))||jt(_)&&!_||j&&!ud(o).isValid||k&&!cd(o).isValid)){const{value:R,message:B}=di(l)?{value:!!l,message:l}:Tn(l);if(R&&(N[w]={type:Jt.required,message:B,ref:y,...E(Jt.required,B)},!r))return P(B),N}if(!W&&(!lt(d)||!lt(h))){let R,B;const L=Tn(h),T=Tn(d);if(!lt(_)&&!isNaN(_)){const H=a.valueAsNumber||_&&+_;lt(L.value)||(R=H>L.value),lt(T.value)||(B=H<T.value)}else{const H=a.valueAsDate||new Date(_),Y=b=>new Date(new Date().toDateString()+" "+b),O=a.type=="time",G=a.type=="week";Lt(L.value)&&_&&(R=O?Y(_)>Y(L.value):G?_>L.value:H>new Date(L.value)),Lt(T.value)&&_&&(B=O?Y(_)<Y(T.value):G?_<T.value:H<new Date(T.value))}if((R||B)&&(U(!!R,L.message,T.message,Jt.max,Jt.min),!r))return P(N[w].message),N}if((u||f)&&!W&&(Lt(_)||s&&Array.isArray(_))){const R=Tn(u),B=Tn(f),L=!lt(R.value)&&_.length>+R.value,T=!lt(B.value)&&_.length<+B.value;if((L||T)&&(U(L,R.message,B.message),!r))return P(N[w].message),N}if(p&&!W&&Lt(_)){const{value:R,message:B}=Tn(p);if(ki(R)&&!_.match(R)&&(N[w]={type:Jt.pattern,message:B,ref:a,...E(Jt.pattern,B)},!r))return P(B),N}if(m){if(Ft(m)){const R=await m(_,n),B=Vo(R,y);if(B&&(N[w]={...B,...E(Jt.validate,B.message)},!r))return P(B.message),N}else if(He(m)){let R={};for(const B in m){if(!ht(R)&&!r)break;const L=Vo(await m[B](_,n),y,B);L&&(R={...L,...E(B,L.message)},P(L.message),r&&(N[w]=R))}if(!ht(R)&&(N[w]={ref:y,...R},!r))return N}}return P(!0),N};function Sg(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=Je(e)?r++:e[t[r++]];return e}function _g(e){for(const t in e)if(e.hasOwnProperty(t)&&!Je(e[t]))return!1;return!0}function Ye(e,t){const n=Array.isArray(t)?t:Ba(t)?[t]:rd(t),r=n.length===1?e:Sg(e,n),i=n.length-1,s=n[i];return r&&delete r[s],i!==0&&(He(r)&&ht(r)||Array.isArray(r)&&_g(r))&&Ye(e,n.slice(0,-1)),e}var gs=()=>{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=[]}}},ea=e=>lt(e)||!ed(e);function en(e,t){if(ea(e)||ea(t))return e===t;if(yn(e)&&yn(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(yn(s)&&yn(a)||He(s)&&He(a)||Array.isArray(s)&&Array.isArray(a)?!en(s,a):s!==a)return!1}}return!0}var dd=e=>e.type==="select-multiple",jg=e=>Ja(e)||Jr(e),xs=e=>wi(e)&&e.isConnected,fd=e=>{for(const t in e)if(Ft(e[t]))return!0;return!1};function Si(e,t={}){const n=Array.isArray(e);if(He(e)||n)for(const r in e)Array.isArray(e[r])||He(e[r])&&!fd(e[r])?(t[r]=Array.isArray(e[r])?[]:{},Si(e[r],t[r])):lt(e[r])||(t[r]=!0);return t}function pd(e,t,n){const r=Array.isArray(e);if(He(e)||r)for(const i in e)Array.isArray(e[i])||He(e[i])&&!fd(e[i])?Je(t)||ea(n[i])?n[i]=Array.isArray(e[i])?Si(e[i],[]):{...Si(e[i])}:pd(e[i],lt(t)?{}:t[i],n[i]):n[i]=!en(e[i],t[i]);return n}var ar=(e,t)=>pd(e,t,Si(t)),hd=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>Je(e)?e:t?e===""?NaN:e&&+e:n&&Lt(e)?new Date(e):r?r(e):e;function ys(e){const t=e.ref;return Ua(t)?t.files:Ja(t)?cd(e.refs).value:dd(t)?[...t.selectedOptions].map(({value:n})=>n):Jr(t)?ud(e.refs).value:hd(Je(t.value)?e.ref.value:t.value,e)}var Cg=(e,t,n,r)=>{const i={};for(const s of e){const a=se(t,s);a&&Pe(i,s,a._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},or=e=>Je(e)?e:ki(e)?e.source:He(e)?ki(e.value)?e.value.source:e.value:e;const Jo="AsyncFunction";var Ng=e=>!!e&&!!e.validate&&!!(Ft(e.validate)&&e.validate.constructor.name===Jo||He(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Jo)),Eg=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Ho(e,t,n){const r=se(e,n);if(r||Ba(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 Ig=(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,zg=(e,t)=>!Wi(se(e,t)).length&&Ye(e,t);const Tg={mode:At.onSubmit,reValidateMode:At.onChange,shouldFocusError:!0};function Ag(e={}){let t={...Tg,...e},n={submitCount:0,isDirty:!1,isLoading:Ft(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},i=He(t.defaultValues)||He(t.values)?pt(t.defaultValues||t.values)||{}:{},s=t.shouldUnregister?{}:pt(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:gs(),array:gs(),state:gs()},h=$o(t.mode),p=$o(t.reValidateMode),m=t.criteriaMode===At.all,w=C=>z=>{clearTimeout(u),u=setTimeout(C,z)},S=async C=>{if(!t.disabled&&(f.isValid||C)){const z=t.resolver?ht((await $()).errors):await E(r,!0);z!==n.isValid&&d.state.next({isValid:z})}},x=(C,z)=>{!t.disabled&&(f.isValidating||f.validatingFields)&&((C||Array.from(o.mount)).forEach(F=>{F&&(z?Pe(n.validatingFields,F,z):Ye(n.validatingFields,F))}),d.state.next({validatingFields:n.validatingFields,isValidating:!ht(n.validatingFields)}))},_=(C,z=[],F,ne,te=!0,ee=!0)=>{if(ne&&F&&!t.disabled){if(a.action=!0,ee&&Array.isArray(se(r,C))){const ce=F(se(r,C),ne.argA,ne.argB);te&&Pe(r,C,ce)}if(ee&&Array.isArray(se(n.errors,C))){const ce=F(se(n.errors,C),ne.argA,ne.argB);te&&Pe(n.errors,C,ce),zg(n.errors,C)}if(f.touchedFields&&ee&&Array.isArray(se(n.touchedFields,C))){const ce=F(se(n.touchedFields,C),ne.argA,ne.argB);te&&Pe(n.touchedFields,C,ce)}f.dirtyFields&&(n.dirtyFields=ar(i,s)),d.state.next({name:C,isDirty:R(C,z),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Pe(s,C,z)},y=(C,z)=>{Pe(n.errors,C,z),d.state.next({errors:n.errors})},P=C=>{n.errors=C,d.state.next({errors:n.errors,isValid:!1})},N=(C,z,F,ne)=>{const te=se(r,C);if(te){const ee=se(s,C,Je(F)?se(i,C):F);Je(ee)||ne&&ne.defaultChecked||z?Pe(s,C,z?ee:ys(te._f)):T(C,ee),a.mount&&S()}},k=(C,z,F,ne,te)=>{let ee=!1,ce=!1;const xe={name:C};if(!t.disabled){const M=!!(se(r,C)&&se(r,C)._f&&se(r,C)._f.disabled);if(!F||ne){f.isDirty&&(ce=n.isDirty,n.isDirty=xe.isDirty=R(),ee=ce!==xe.isDirty);const q=M||en(se(i,C),z);ce=!!(!M&&se(n.dirtyFields,C)),q||M?Ye(n.dirtyFields,C):Pe(n.dirtyFields,C,!0),xe.dirtyFields=n.dirtyFields,ee=ee||f.dirtyFields&&ce!==!q}if(F){const q=se(n.touchedFields,C);q||(Pe(n.touchedFields,C,F),xe.touchedFields=n.touchedFields,ee=ee||f.touchedFields&&q!==F)}ee&&te&&d.state.next(xe)}return ee?xe:{}},j=(C,z,F,ne)=>{const te=se(n.errors,C),ee=f.isValid&&jt(z)&&n.isValid!==z;if(t.delayError&&F?(l=w(()=>y(C,F)),l(t.delayError)):(clearTimeout(u),l=null,F?Pe(n.errors,C,F):Ye(n.errors,C)),(F?!en(te,F):te)||!ht(ne)||ee){const ce={...ne,...ee&&jt(z)?{isValid:z}:{},errors:n.errors,name:C};n={...n,...ce},d.state.next(ce)}},$=async C=>{x(C,!0);const z=await t.resolver(s,t.context,Cg(C||o.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return x(C),z},W=async C=>{const{errors:z}=await $(C);if(C)for(const F of C){const ne=se(z,F);ne?Pe(n.errors,F,ne):Ye(n.errors,F)}else n.errors=z;return z},E=async(C,z,F={valid:!0})=>{for(const ne in C){const te=C[ne];if(te){const{_f:ee,...ce}=te;if(ee){const xe=o.array.has(ee.name),M=te._f&&Ng(te._f);M&&f.validatingFields&&x([ne],!0);const q=await Uo(te,o.disabled,s,m,t.shouldUseNativeValidation&&!z,xe);if(M&&f.validatingFields&&x([ne]),q[ee.name]&&(F.valid=!1,z))break;!z&&(se(q,ee.name)?xe?kg(n.errors,q,ee.name):Pe(n.errors,ee.name,q[ee.name]):Ye(n.errors,ee.name))}!ht(ce)&&await E(ce,z,F)}}return F.valid},U=()=>{for(const C of o.unMount){const z=se(r,C);z&&(z._f.refs?z._f.refs.every(F=>!xs(F)):!xs(z._f.ref))&&Q(C)}o.unMount=new Set},R=(C,z)=>!t.disabled&&(C&&z&&Pe(s,C,z),!en(ue(),i)),B=(C,z,F)=>ld(C,o,{...a.mount?s:Je(z)?i:Lt(C)?{[C]:z}:z},F,z),L=C=>Wi(se(a.mount?s:i,C,t.shouldUnregister?se(i,C,[]):[])),T=(C,z,F={})=>{const ne=se(r,C);let te=z;if(ne){const ee=ne._f;ee&&(!ee.disabled&&Pe(s,C,hd(z,ee)),te=wi(ee.ref)&<(z)?"":z,dd(ee.ref)?[...ee.ref.options].forEach(ce=>ce.selected=te.includes(ce.value)):ee.refs?Jr(ee.ref)?ee.refs.length>1?ee.refs.forEach(ce=>(!ce.defaultChecked||!ce.disabled)&&(ce.checked=Array.isArray(te)?!!te.find(xe=>xe===ce.value):te===ce.value)):ee.refs[0]&&(ee.refs[0].checked=!!te):ee.refs.forEach(ce=>ce.checked=ce.value===te):Ua(ee.ref)?ee.ref.value="":(ee.ref.value=te,ee.ref.type||d.values.next({name:C,values:{...s}})))}(F.shouldDirty||F.shouldTouch)&&k(C,te,F.shouldTouch,F.shouldDirty,!0),F.shouldValidate&&b(C)},H=(C,z,F)=>{for(const ne in z){const te=z[ne],ee=`${C}.${ne}`,ce=se(r,ee);(o.array.has(C)||He(te)||ce&&!ce._f)&&!yn(te)?H(ee,te,F):T(ee,te,F)}},Y=(C,z,F={})=>{const ne=se(r,C),te=o.array.has(C),ee=pt(z);Pe(s,C,ee),te?(d.array.next({name:C,values:{...s}}),(f.isDirty||f.dirtyFields)&&F.shouldDirty&&d.state.next({name:C,dirtyFields:ar(i,s),isDirty:R(C,ee)})):ne&&!ne._f&&!lt(ee)?H(C,ee,F):T(C,ee,F),Fo(C,o)&&d.state.next({...n}),d.values.next({name:a.mount?C:void 0,values:{...s}})},O=async C=>{a.mount=!0;const z=C.target;let F=z.name,ne=!0;const te=se(r,F),ee=()=>z.type?ys(te._f):td(C),ce=xe=>{ne=Number.isNaN(xe)||yn(xe)&&isNaN(xe.getTime())||en(xe,se(s,F,xe))};if(te){let xe,M;const q=ee(),de=C.type===vi.BLUR||C.type===vi.FOCUS_OUT,ve=!Eg(te._f)&&!t.resolver&&!se(n.errors,F)&&!te._f.deps||Ig(de,se(n.touchedFields,F),n.isSubmitted,p,h),A=Fo(F,o,de);Pe(s,F,q),de?(te._f.onBlur&&te._f.onBlur(C),l&&l(0)):te._f.onChange&&te._f.onChange(C);const fe=k(F,q,de,!1),_e=!ht(fe)||A;if(!de&&d.values.next({name:F,type:C.type,values:{...s}}),ve)return f.isValid&&(t.mode==="onBlur"&&de?S():de||S()),_e&&d.state.next({name:F,...A?{}:fe});if(!de&&A&&d.state.next({...n}),t.resolver){const{errors:Re}=await $([F]);if(ce(q),ne){const Ke=Ho(n.errors,r,F),qe=Ho(Re,r,Ke.name||F);xe=qe.error,F=qe.name,M=ht(Re)}}else x([F],!0),xe=(await Uo(te,o.disabled,s,m,t.shouldUseNativeValidation))[F],x([F]),ce(q),ne&&(xe?M=!1:f.isValid&&(M=await E(r,!0)));ne&&(te._f.deps&&b(te._f.deps),j(F,M,xe,fe))}},G=(C,z)=>{if(se(n.errors,z)&&C.focus)return C.focus(),1},b=async(C,z={})=>{let F,ne;const te=_r(C);if(t.resolver){const ee=await W(Je(C)?C:te);F=ht(ee),ne=C?!te.some(ce=>se(ee,ce)):F}else C?(ne=(await Promise.all(te.map(async ee=>{const ce=se(r,ee);return await E(ce&&ce._f?{[ee]:ce}:ce)}))).every(Boolean),!(!ne&&!n.isValid)&&S()):ne=F=await E(r);return d.state.next({...!Lt(C)||f.isValid&&F!==n.isValid?{}:{name:C},...t.resolver||!C?{isValid:F}:{},errors:n.errors}),z.shouldFocus&&!ne&&jr(r,G,C?te:o.mount),ne},ue=C=>{const z={...a.mount?s:i};return Je(C)?z:Lt(C)?se(z,C):C.map(F=>se(z,F))},ae=(C,z)=>({invalid:!!se((z||n).errors,C),isDirty:!!se((z||n).dirtyFields,C),error:se((z||n).errors,C),isValidating:!!se(n.validatingFields,C),isTouched:!!se((z||n).touchedFields,C)}),g=C=>{C&&_r(C).forEach(z=>Ye(n.errors,z)),d.state.next({errors:C?n.errors:{}})},K=(C,z,F)=>{const ne=(se(r,C,{_f:{}})._f||{}).ref,te=se(n.errors,C)||{},{ref:ee,message:ce,type:xe,...M}=te;Pe(n.errors,C,{...M,...z,ref:ne}),d.state.next({name:C,errors:n.errors,isValid:!1}),F&&F.shouldFocus&&ne&&ne.focus&&ne.focus()},ie=(C,z)=>Ft(C)?d.values.subscribe({next:F=>C(B(void 0,z),F)}):B(C,z,!0),Q=(C,z={})=>{for(const F of C?_r(C):o.mount)o.mount.delete(F),o.array.delete(F),z.keepValue||(Ye(r,F),Ye(s,F)),!z.keepError&&Ye(n.errors,F),!z.keepDirty&&Ye(n.dirtyFields,F),!z.keepTouched&&Ye(n.touchedFields,F),!z.keepIsValidating&&Ye(n.validatingFields,F),!t.shouldUnregister&&!z.keepDefaultValue&&Ye(i,F);d.values.next({values:{...s}}),d.state.next({...n,...z.keepDirty?{isDirty:R()}:{}}),!z.keepIsValid&&S()},I=({disabled:C,name:z,field:F,fields:ne})=>{(jt(C)&&a.mount||C||o.disabled.has(z))&&(C?o.disabled.add(z):o.disabled.delete(z),k(z,ys(F?F._f:se(ne,z)._f),!1,!1,!0))},D=(C,z={})=>{let F=se(r,C);const ne=jt(z.disabled)||jt(t.disabled);return Pe(r,C,{...F||{},_f:{...F&&F._f?F._f:{ref:{name:C}},name:C,mount:!0,...z}}),o.mount.add(C),F?I({field:F,disabled:jt(z.disabled)?z.disabled:t.disabled,name:C}):N(C,!0,z.value),{...ne?{disabled:z.disabled||t.disabled}:{},...t.progressive?{required:!!z.required,min:or(z.min),max:or(z.max),minLength:or(z.minLength),maxLength:or(z.maxLength),pattern:or(z.pattern)}:{},name:C,onChange:O,onBlur:O,ref:te=>{if(te){D(C,z),F=se(r,C);const ee=Je(te.value)&&te.querySelectorAll&&te.querySelectorAll("input,select,textarea")[0]||te,ce=jg(ee),xe=F._f.refs||[];if(ce?xe.find(M=>M===ee):ee===F._f.ref)return;Pe(r,C,{_f:{...F._f,...ce?{refs:[...xe.filter(xs),ee,...Array.isArray(se(i,C))?[{}]:[]],ref:{type:ee.type,name:C}}:{ref:ee}}}),N(C,!1,void 0,ee)}else F=se(r,C,{}),F._f&&(F._f.mount=!1),(t.shouldUnregister||z.shouldUnregister)&&!(nd(o.array,C)&&a.action)&&o.unMount.add(C)}}},J=()=>t.shouldFocusError&&jr(r,G,o.mount),oe=C=>{jt(C)&&(d.state.next({disabled:C}),jr(r,(z,F)=>{const ne=se(r,F);ne&&(z.disabled=ne._f.disabled||C,Array.isArray(ne._f.refs)&&ne._f.refs.forEach(te=>{te.disabled=ne._f.disabled||C}))},0,!1))},pe=(C,z)=>async F=>{let ne;F&&(F.preventDefault&&F.preventDefault(),F.persist&&F.persist());let te=pt(s);if(o.disabled.size)for(const ee of o.disabled)Pe(te,ee,void 0);if(d.state.next({isSubmitting:!0}),t.resolver){const{errors:ee,values:ce}=await $();n.errors=ee,te=ce}else await E(r);if(Ye(n.errors,"root"),ht(n.errors)){d.state.next({errors:{}});try{await C(te,F)}catch(ee){ne=ee}}else z&&await z({...n.errors},F),J(),setTimeout(J);if(d.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ht(n.errors)&&!ne,submitCount:n.submitCount+1,errors:n.errors}),ne)throw ne},Ae=(C,z={})=>{se(r,C)&&(Je(z.defaultValue)?Y(C,pt(se(i,C))):(Y(C,z.defaultValue),Pe(i,C,pt(z.defaultValue))),z.keepTouched||Ye(n.touchedFields,C),z.keepDirty||(Ye(n.dirtyFields,C),n.isDirty=z.defaultValue?R(C,pt(se(i,C))):R()),z.keepError||(Ye(n.errors,C),f.isValid&&S()),d.state.next({...n}))},ke=(C,z={})=>{const F=C?pt(C):i,ne=pt(F),te=ht(C),ee=te?i:ne;if(z.keepDefaultValues||(i=F),!z.keepValues){if(z.keepDirtyValues){const ce=new Set([...o.mount,...Object.keys(ar(i,s))]);for(const xe of Array.from(ce))se(n.dirtyFields,xe)?Pe(ee,xe,se(s,xe)):Y(xe,se(ee,xe))}else{if(Za&&Je(C))for(const ce of o.mount){const xe=se(r,ce);if(xe&&xe._f){const M=Array.isArray(xe._f.refs)?xe._f.refs[0]:xe._f.ref;if(wi(M)){const q=M.closest("form");if(q){q.reset();break}}}}r={}}s=t.shouldUnregister?z.keepDefaultValues?pt(i):{}:pt(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&&!en(C,i)),isSubmitted:z.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:te?{}:z.keepDirtyValues?z.keepDefaultValues&&s?ar(i,s):n.dirtyFields:z.keepDefaultValues&&C?ar(i,C):z.keepDirty?n.dirtyFields:{},touchedFields:z.keepTouched?n.touchedFields:{},errors:z.keepErrors?n.errors:{},isSubmitSuccessful:z.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},be=(C,z)=>ke(Ft(C)?C(s):C,z);return{control:{register:D,unregister:Q,getFieldState:ae,handleSubmit:pe,setError:K,_executeSchema:$,_getWatch:B,_getDirty:R,_updateValid:S,_removeUnmounted:U,_updateFieldArray:_,_updateDisabledField:I,_getFieldArray:L,_reset:ke,_resetDefaultValues:()=>Ft(t.defaultValues)&&t.defaultValues().then(C=>{be(C,t.resetOptions),d.state.next({isLoading:!1})}),_updateFormState:C=>{n={...n,...C}},_disableForm:oe,_subjects:d,_proxyFormState:f,_setErrors:P,get _fields(){return r},get _formValues(){return s},get _state(){return a},set _state(C){a=C},get _defaultValues(){return i},get _names(){return o},set _names(C){o=C},get _formState(){return n},set _formState(C){n=C},get _options(){return t},set _options(C){t={...t,...C}}},trigger:b,register:D,handleSubmit:pe,watch:ie,setValue:Y,getValues:ue,reset:be,resetField:Ae,clearErrors:g,unregister:Q,setError:K,setFocus:(C,z={})=>{const F=se(r,C),ne=F&&F._f;if(ne){const te=ne.refs?ne.refs[0]:ne.ref;te.focus&&(te.focus(),z.shouldSelect&&Ft(te.select)&&te.select())}},getFieldState:ae}}function Pg(e={}){const t=Ee.useRef(void 0),n=Ee.useRef(void 0),[r,i]=Ee.useState({isDirty:!1,isValidating:!1,isLoading:Ft(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Ft(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...Ag(e),formState:r});const s=t.current.control;return s._options=e,Va({subject:s._subjects.state,next:a=>{ad(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&&!en(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=sd(r,s),t.current}function Og(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 qt=cc,qo=dc,Dg=fc,Wo=$a,md=v.forwardRef(({className:e,...t},n)=>c.jsx(Hi,{ref:n,className:V("fixed inset-0 z-50 bg-black/80",e),...t}));md.displayName=Hi.displayName;const Zt=v.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Dg,{children:[c.jsx(md,{}),c.jsxs(Vi,{ref:r,className:V("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($a,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground 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(kn,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Zt.displayName=Vi.displayName;const _n=({className:e,...t})=>c.jsx("div",{className:V("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});_n.displayName="DialogHeader";const Tr=({className:e,...t})=>c.jsx("div",{className:V("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Tr.displayName="DialogFooter";const jn=v.forwardRef(({className:e,...t},n)=>c.jsx(Ui,{ref:n,className:V("text-lg leading-none font-semibold tracking-tight",e),...t}));jn.displayName=Ui.displayName;const Gn=v.forwardRef(({className:e,...t},n)=>c.jsx(Ji,{ref:n,className:V("text-muted-foreground text-sm",e),...t}));Gn.displayName=Ji.displayName;const Rg=Ur("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ha=v.forwardRef(({className:e,...t},n)=>c.jsx(pc,{ref:n,className:V(Rg(),e),...t}));Ha.displayName=pc.displayName;const Mg=gg,gd=v.createContext({}),Go=({...e})=>c.jsx(gd.Provider,{value:{name:e.name},children:c.jsx(vg,{...e})}),Ki=()=>{const e=v.useContext(gd),t=v.useContext(xd),{getFieldState:n,formState:r}=Gi(),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}},xd=v.createContext({}),ta=v.forwardRef(({className:e,...t},n)=>{const r=v.useId();return c.jsx(xd.Provider,{value:{id:r},children:c.jsx("div",{ref:n,className:V("space-y-2",e),...t})})});ta.displayName="FormItem";const na=v.forwardRef(({className:e,...t},n)=>{const{error:r,formItemId:i}=Ki();return c.jsx(Ha,{ref:n,className:V(r&&"text-destructive",e),htmlFor:i,...t})});na.displayName="FormLabel";const ra=v.forwardRef(({...e},t)=>{const{error:n,formItemId:r,formDescriptionId:i,formMessageId:s}=Ki();return c.jsx(tr,{ref:t,id:r,"aria-describedby":n?`${i} ${s}`:`${i}`,"aria-invalid":!!n,...e})});ra.displayName="FormControl";const yd=v.forwardRef(({className:e,...t},n)=>{const{formDescriptionId:r}=Ki();return c.jsx("p",{ref:n,id:r,className:V("text-muted-foreground text-[0.8rem]",e),...t})});yd.displayName="FormDescription";const ia=v.forwardRef(({className:e,children:t,...n},r)=>{const{error:i,formMessageId:s}=Ki(),a=i?String(i==null?void 0:i.message):t;return a?c.jsx("p",{ref:r,id:s,className:V("text-destructive text-[0.8rem] font-medium",e),...n,children:a}):null});ia.displayName="FormMessage";const qa=v.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:V("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}));qa.displayName="Input";const Wa=um,$g=gm,Ga=cm,Yi=v.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(hc,{ref:r,className:V("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(dm,{asChild:!0,children:c.jsx(rn,{className:"h-4 w-4 shrink-0 opacity-50"})})]}));Yi.displayName=hc.displayName;const bd=v.forwardRef(({className:e,...t},n)=>c.jsx(xc,{ref:n,className:V("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(Am,{className:"h-4 w-4"})}));bd.displayName=xc.displayName;const vd=v.forwardRef(({className:e,...t},n)=>c.jsx(yc,{ref:n,className:V("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(rn,{className:"h-4 w-4"})}));vd.displayName=yc.displayName;const Xi=v.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>c.jsx(fm,{children:c.jsxs(mc,{ref:i,className:V("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(bd,{}),c.jsx(pm,{className:V("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(vd,{})]})}));Xi.displayName=mc.displayName;const wd=v.forwardRef(({className:e,...t},n)=>c.jsx(bc,{ref:n,className:V("px-2 py-1.5 text-sm font-semibold",e),...t}));wd.displayName=bc.displayName;const Ar=v.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(gc,{ref:r,className:V("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(hm,{children:c.jsx(Sn,{className:"h-4 w-4"})})}),c.jsx(mm,{children:t})]}));Ar.displayName=gc.displayName;const Fg=v.forwardRef(({className:e,...t},n)=>c.jsx(vc,{ref:n,className:V("bg-muted -mx-1 my-1 h-px",e),...t}));Fg.displayName=vc.displayName;function Ka(){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 kd=()=>({chatOpen:!1,scope:"global",model:"opus",contextAttachments:[],threads:{},activeThreadId:{}}),Lg=(e=kd())=>og()(lg(ug((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:Ka(),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:cg(()=>eg),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}}))),Sd=v.createContext(void 0),Zg=({children:e})=>{const t=v.useRef(null);return t.current||(t.current=Lg(kd())),c.jsx(Sd.Provider,{value:t.current,children:e})},ze=e=>{const t=v.useContext(Sd);if(!t)throw new Error("useChatStore must be used within ChatStoreProvider");return dg(t,e)};function Bg(e,t,n){return t.filter(r=>r.name!==n).every(r=>r.name!==e)}function Vg(e,t,n){const r={},i=[];e!=="delete"&&(r.name=Yr.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=Yr.Optional(Yr.String({description:"Template selection"})));const s=Yr.Object(r,{additionalProperties:!1,required:i.length>0?i:void 0});return{schema:s,validate:a=>{const o=[];if(!sm(s,a))for(const u of am(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 Ug(e,t,n){return e==="create"?{name:"",template:t}:e==="update"?{name:n}:{}}const Jg=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"}}),lr="__empty__";function Hg({mode:e,shouldReset:t,postSubmit:n,selectedName:r,discoveredDocuments:i,discoveredThemes:s,isTheme:a}){const[o,l]=v.useState(!1),[u,f]=v.useState(null),d=Jg(a),{documents:h,openTabs:p,createDocument:m,renameDocument:w,deleteDocument:S,openDocument:x,closeDocument:_}=Ge(O=>O),{updateTheme:y,removeTheme:P}=Xs(O=>O),N=ze(O=>O.renameThreadsForDocument),k=ze(O=>O.deleteThreadsForDocument),j=v.useMemo(()=>a?s||[]:i||[],[a,i,s]),$=v.useMemo(()=>{const O={current:[],downstream:[]};return j.forEach(G=>{O[G.location]&&O[G.location].push(G)}),O},[j]),W=v.useMemo(()=>j.map(O=>({name:O.name,type:"application/json",text:"",mtime:new Date,ctime:new Date,atime:new Date})),[j]),E=v.useMemo(()=>Vg(e,O=>Bg(O,h,r),W),[e,h,r,W]),U=E.schema,R=v.useMemo(()=>{const O=new Map;return j.forEach(G=>O.set(G.path,G)),O},[j]),B=lr,L=Pg({resolver:Og(E.validate),defaultValues:Ug(e,void 0,r)}),[T,H]=v.useState(B);v.useEffect(()=>{if(T&&T!==lr&&e==="create"){const O=R.get(T);O&&fetch(`/api/discovery/${a?"themes":"documents"}/${encodeURIComponent(O.name)}/content`).then(G=>{if(!G.ok)throw new Error(`Failed to fetch content: ${G.statusText}`);return G.text()}).then(G=>{try{const b=JSON.parse(G);f(JSON.stringify(b,null,2))}catch(b){console.error("Invalid JSON content received:",b),f(null)}}).catch(G=>{console.error("Failed to fetch content:",G),f(null)})}},[T,e,R,a]),v.useEffect(()=>{t&&(L.reset(),f(null),H(B))},[L,t]);const Y=L.handleSubmit(async({name:O,template:G})=>{l(!0);try{if(await new Promise(b=>setTimeout(b,200)),e==="create"){const b=T?R.get(T):j.find(D=>D.name===G);let ue,ae=O;if(a){const D=ae.replace(/\.(json|theme)$/i,"").toLowerCase().replace(/\s+/g,"-");ue=u||JSON.stringify(Nt==="docx"?{name:D,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:D,colors:{primary:"#2563EB",secondary:"#64748B",accent:"#F8FAFC",background:"#FFFFFF",text:"#334155"},fonts:{heading:"Calibri",body:"Calibri"},defaults:{fontSize:18,fontColor:"#334155"}},null,2);const oe=`.${Nt}.theme.json`;ae.endsWith(oe)||(ae=ae.replace(/\.(pptx|docx)\.theme\.json$/i,"").replace(/\.theme\.json$/i,"").replace(/\.json$/i,""),ae+=oe)}else{const D=b;ue=u||JSON.stringify(Nt==="docx"?{name:"docx",props:{theme:(D==null?void 0:D.theme)||"default",metadata:{title:(D==null?void 0:D.title)||ae.replace(/\.(json|js)$/i,"")}},children:[{name:"section",props:{},children:[{name:"paragraph",props:{text:"Start writing your document content here..."}}]}]}:{name:"pptx",props:{title:(D==null?void 0:D.title)||ae.replace(/\.(json|js)$/i,""),theme:(D==null?void 0:D.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 J=Nt==="docx"?".docx.json":".pptx.json";!ae.endsWith(J)&&!ae.endsWith(".json")&&(ae+=J)}const g=ae.match(/(\.(pptx|docx)(\.theme)?\.json|\.json)$/i),K=g?g[0]:"",ie=ae.slice(0,ae.length-K.length);let Q=ae,I=1;for(;h.some(D=>D.name===Q);)I++,Q=`${ie} (${I})${K}`;ae=Q,m(ae,ue),x(ae),a&&y(ae,ue)}else if(e==="update"){const b=r,ue=O,ae=p.includes(b);ae&&_(b),w(b,ue),N(b,ue),ae&&x(ue)}else if(e==="delete"){const b=r;_(b),S(b),k(b),a&&P(b)}n()}finally{l(!1)}});return c.jsx(Mg,{...L,children:c.jsxs("form",{onSubmit:Y,children:[c.jsxs(_n,{children:[c.jsx(jn,{children:d[e].title}),c.jsx(Gn,{children:d[e].description})]}),c.jsxs("div",{className:"flex flex-col gap-4 py-4",children:[U.properties&&"name"in U.properties&&c.jsx(Go,{control:L.control,name:"name",render:({field:O})=>c.jsxs(ta,{children:[c.jsx(na,{children:"Name"}),c.jsx(ra,{children:c.jsx(qa,{placeholder:"Enter a name or select a template below",autoComplete:"off",...O})}),c.jsx(ia,{})]})}),e==="create"&&c.jsx(Go,{control:L.control,name:"template",render:({field:O})=>c.jsxs(ta,{children:[c.jsx(na,{children:a?"Base Theme":"Base Document"}),c.jsxs(Wa,{onValueChange:G=>{if(G===lr)O.onChange(void 0),L.setValue("name",""),H(lr),f(null);else{const b=R.get(G);b&&(O.onChange(b.name),L.setValue("name",b.name),H(G))}},defaultValue:B,children:[c.jsx(ra,{children:c.jsx(Yi,{children:c.jsx(Ga,{placeholder:`Select a discovered ${a?"theme":"document"}`})})}),c.jsxs(Xi,{className:"max-h-[300px]",children:[c.jsxs(Ar,{value:lr,children:["Empty ",a?"theme":"document"]}),Object.entries($).map(([G,b])=>b.length===0?null:c.jsxs($g,{children:[c.jsx(wd,{children:G==="current"?"📁 Current Directory":"📦 Project"}),b.map(ue=>{let ae=ue.name;if(ue.title)ae=`${ue.name} - ${ue.title}`;else if(ue.description){const g=ue.description.length>40?ue.description.substring(0,40)+"...":ue.description;ae=`${ue.name} - ${g}`}return c.jsx(Ar,{value:ue.path,className:"pl-6",children:ae},ue.path)})]},G))]})]}),c.jsxs(yd,{children:["Start empty or select a discovered"," ",a?"theme":"document"," as a starting point"]}),c.jsx(ia,{})]})})]}),c.jsx(Tr,{children:c.jsx(Ie,{type:"submit",variant:d[e].buttonVariant,disabled:o,children:o?c.jsxs(c.Fragment,{children:[c.jsx(Qt,{size:"sm",className:"mr-2"}),e==="create"?"Creating...":e==="update"?"Saving...":"Deleting..."]}):d[e].button})})]})})}const _i=Ee.memo(Hg),qg=xm,Wg=ym,Gg=v.forwardRef(({className:e,inset:t,children:n,...r},i)=>c.jsxs(_c,{ref:i,className:V("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"})]}));Gg.displayName=_c.displayName;const Kg=v.forwardRef(({className:e,...t},n)=>c.jsx(jc,{ref:n,className:V("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}));Kg.displayName=jc.displayName;const _d=v.forwardRef(({className:e,...t},n)=>c.jsx(bm,{children:c.jsx(wc,{ref:n,className:V("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})}));_d.displayName=wc.displayName;const gr=v.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(kc,{ref:r,className:V("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}));gr.displayName=kc.displayName;const Yg=v.forwardRef(({className:e,children:t,checked:n,...r},i)=>c.jsxs(Cc,{ref:i,className:V("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(Nc,{children:c.jsx(Sn,{className:"h-4 w-4"})})}),t]}));Yg.displayName=Cc.displayName;const Xg=v.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Ec,{ref:r,className:V("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(Nc,{children:c.jsx(Jc,{className:"h-4 w-4 fill-current"})})}),t]}));Xg.displayName=Ec.displayName;const Qg=v.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Ic,{ref:r,className:V("text-foreground px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Qg.displayName=Ic.displayName;const sa=v.forwardRef(({className:e,...t},n)=>c.jsx(Sc,{ref:n,className:V("bg-border -mx-1 my-1 h-px",e),...t}));sa.displayName=Sc.displayName;const fi=({className:e,...t})=>c.jsx("span",{className:V("text-muted-foreground ml-auto text-xs tracking-widest",e),...t});fi.displayName="ContextMenuShortcut";const jd=v.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},i)=>c.jsx(zc,{ref:i,decorative:n,orientation:t,className:V("bg-border shrink-0",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));jd.displayName=zc.displayName;const Cd=cc,ex=dc,tx=fc,Nd=v.forwardRef(({className:e,...t},n)=>c.jsx(Hi,{className:V("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}));Nd.displayName=Hi.displayName;const nx=Ur("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"}}),Ya=v.forwardRef(({side:e="right",className:t,children:n,...r},i)=>c.jsxs(tx,{children:[c.jsx(Nd,{}),c.jsxs(Vi,{ref:i,className:V(nx({side:e}),t),...r,children:[c.jsxs($a,{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(kn,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]}),n]})]}));Ya.displayName=Vi.displayName;const rx=v.forwardRef(({className:e,...t},n)=>c.jsx(Ui,{ref:n,className:V("text-foreground text-lg font-semibold",e),...t}));rx.displayName=Ui.displayName;const ix=v.forwardRef(({className:e,...t},n)=>c.jsx(Ji,{ref:n,className:V("text-muted-foreground text-sm",e),...t}));ix.displayName=Ji.displayName;function Cr({className:e,...t}){return c.jsx("div",{className:V("bg-primary/10 animate-pulse rounded-md",e),...t})}const bs=768,vs=1200;function Ed(){const[e,t]=v.useState(void 0);return v.useEffect(()=>{const n=window.matchMedia(`(max-width: ${bs-1}px)`),r=()=>{t(window.innerWidth<bs)};return n.addEventListener("change",r),t(window.innerWidth<bs),()=>n.removeEventListener("change",r)},[]),!!e}function sx(){const[e,t]=v.useState(void 0);return v.useEffect(()=>{const n=window.matchMedia(`(max-width: ${vs-1}px)`),r=()=>{t(window.innerWidth<vs)};return n.addEventListener("change",r),t(window.innerWidth<vs),()=>n.removeEventListener("change",r)},[]),!!e}const ax="sidebar_state",ox=60*60*24*7,lx="16rem",ux="18rem",cx="3rem",dx="b",Id=v.createContext(null);function Qi(){const e=v.useContext(Id);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const zd=v.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:s,...a},o)=>{const l=Ed(),[u,f]=v.useState(!1),[d,h]=v.useState(e),p=t??d,m=v.useCallback(_=>{const y=typeof _=="function"?_(p):_;n?n(y):h(y),document.cookie=`${ax}=${y}; path=/; max-age=${ox}`},[n,p]),w=v.useCallback(()=>l?f(_=>!_):m(_=>!_),[l,m,f]);v.useEffect(()=>{const _=P=>{var j;const N=P;if(!N)return!1;const k=(j=N.tagName)==null?void 0:j.toLowerCase();return k==="input"||k==="textarea"||k==="select"||N.isContentEditable?!0:!!(N.closest&&N.closest(".monaco-editor"))},y=P=>{const N=P.metaKey||P.ctrlKey,k=P.key.toLowerCase();if(N&&k===dx){P.preventDefault(),w();return}N&&k==="s"&&!_(P.target)&&(P.preventDefault(),w())};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[w]);const S=p?"expanded":"collapsed",x=v.useMemo(()=>({state:S,open:p,setOpen:m,isMobile:l,openMobile:u,setOpenMobile:f,toggleSidebar:w}),[S,p,m,l,u,f,w]);return c.jsx(Id.Provider,{value:x,children:c.jsx(om,{delayDuration:0,children:c.jsx("div",{style:{"--sidebar-width":lx,"--sidebar-width-icon":cx,...i},className:V("group/sidebar-wrapper has-[[data-variant=inset]]:bg-sidebar flex min-h-svh w-full",r),ref:o,...a,children:s})})})});zd.displayName="SidebarProvider";const Td=v.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}=Qi();return n==="none"?c.jsx("div",{className:V("bg-sidebar text-sidebar-foreground flex h-full w-[--sidebar-width] flex-col",r),ref:a,...s,children:i}):o?c.jsx(Cd,{open:u,onOpenChange:f,...s,children:c.jsx(Ya,{"data-sidebar":"sidebar","data-mobile":"true",className:"bg-sidebar text-sidebar-foreground w-[--sidebar-width] p-0 [&>button]:hidden",style:{"--sidebar-width":ux},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:V("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:V("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})})]})});Td.displayName="Sidebar";const fx=v.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:i}=Qi();return c.jsxs(Ie,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:V("h-7 w-7",e),onClick:s=>{t==null||t(s),i()},...n,children:[c.jsx(Pm,{}),c.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});fx.displayName="SidebarTrigger";const px=v.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=Qi();return c.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:V("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})});px.displayName="SidebarRail";const hx=v.forwardRef(({className:e,...t},n)=>c.jsx("main",{ref:n,className:V("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}));hx.displayName="SidebarInset";const mx=v.forwardRef(({className:e,...t},n)=>c.jsx(qa,{ref:n,"data-sidebar":"input",className:V("bg-background focus-visible:ring-sidebar-ring h-8 w-full shadow-none focus-visible:ring-2",e),...t}));mx.displayName="SidebarInput";const Ad=v.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"header",className:V("flex flex-col gap-2 p-2",e),...t}));Ad.displayName="SidebarHeader";const Pd=v.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"footer",className:V("flex flex-col gap-2 p-2",e),...t}));Pd.displayName="SidebarFooter";const Od=v.forwardRef(({className:e,...t},n)=>c.jsx(jd,{ref:n,"data-sidebar":"separator",className:V("bg-sidebar-border mx-2 w-auto",e),...t}));Od.displayName="SidebarSeparator";const Dd=v.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"content",className:V("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Dd.displayName="SidebarContent";const pi=v.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"group",className:V("relative flex w-full min-w-0 flex-col p-2",e),...t}));pi.displayName="SidebarGroup";const hi=v.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?tr:"div";return c.jsx(i,{ref:r,"data-sidebar":"group-label",className:V("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})});hi.displayName="SidebarGroupLabel";const gx=v.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?tr:"button";return c.jsx(i,{ref:r,"data-sidebar":"group-action",className:V("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})});gx.displayName="SidebarGroupAction";const xr=v.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"group-content",className:V("w-full text-sm",e),...t}));xr.displayName="SidebarGroupContent";const aa=v.forwardRef(({className:e,...t},n)=>c.jsx("ul",{ref:n,"data-sidebar":"menu",className:V("flex w-full min-w-0 flex-col gap-1",e),...t}));aa.displayName="SidebarMenu";const Rd=v.forwardRef(({className:e,...t},n)=>c.jsx("li",{ref:n,"data-sidebar":"menu-item",className:V("group/menu-item relative",e),...t}));Rd.displayName="SidebarMenuItem";const xx=Ur("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"}}),Md=v.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:i,className:s,...a},o)=>{const l=e?tr:"button",{isMobile:u,state:f}=Qi(),d=c.jsx(l,{ref:o,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:V(xx({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});Md.displayName="SidebarMenuButton";const yx=v.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},i)=>{const s=t?tr:"button";return c.jsx(s,{ref:i,"data-sidebar":"menu-action",className:V("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})});yx.displayName="SidebarMenuAction";const bx=v.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:V("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}));bx.displayName="SidebarMenuBadge";const vx=v.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{const i=v.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return c.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:V("flex h-8 items-center gap-2 rounded-md px-2",e),...n,children:[t&&c.jsx(Cr,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),c.jsx(Cr,{className:"h-4 max-w-[--skeleton-width] flex-1","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":i}})]})});vx.displayName="SidebarMenuSkeleton";const wx=v.forwardRef(({className:e,...t},n)=>c.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:V("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}));wx.displayName="SidebarMenuSub";const kx=v.forwardRef(({...e},t)=>c.jsx("li",{ref:t,...e}));kx.displayName="SidebarMenuSubItem";const Sx=v.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...i},s)=>{const a=e?tr:"a";return c.jsx(a,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:V("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})});Sx.displayName="SidebarMenuSubButton";function oa(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 _x=typeof window<"u"?navigator.userAgent.toUpperCase().indexOf("MAC")>=0:!1;function jx({document:e,indicator:t,compact:n=!1}){const r=v.useRef(null),[i,s]=v.useState(!1),[a,o]=v.useState(!1),[l,u]=v.useState(!1),{openDocument:f,documentTypes:d,activeTab:h}=Ge(T=>T),{name:p,text:m,isGenerating:w}=mn(T=>T),x=(d[e.name]||"application/json+report")==="application/json+theme",_=h===e.name,[y,P]=v.useState(p),[N,k]=v.useState(m),j=100,$=0;v.useEffect(()=>{const T=setTimeout(()=>{p&&m?(P(p),k(m)):w||(P(""),k(""))},w?j:$);return()=>clearTimeout(T)},[p,m,w]);const W=y===e.name,E=T=>{var Y;const H=new Set;try{const O=JSON.parse(T);(Y=O.props)!=null&&Y.theme&&H.add(O.props.theme),O.children&&Array.isArray(O.children)&&O.children.forEach(G=>{var b;G.name==="docx"&&((b=G.props)!=null&&b.theme)&&H.add(G.props.theme)})}catch{}return H},U=v.useMemo(()=>{if(!x||!N)return!1;try{const T=JSON.parse(e.text),H=Qs(T);if(H)return E(N).has(H)}catch{}return!1},[x,N,e.text,e.name,y]),R=v.useCallback(()=>{o(!1)},[]),B=v.useCallback(()=>{u(!1)},[]),L=c.jsxs(Md,{variant:"default",size:"default",ref:r,className:V("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"),W&&!_&&(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"),U&&!_&&!W&&(n?"bg-purple-50 text-purple-700 dark:bg-purple-900/20 dark:text-purple-300":"bg-purple-50 border-l-2 border-purple-500 text-purple-700 dark:bg-purple-900/20 dark:border-purple-400 dark:text-purple-300")),title:e.name,onClick:()=>{f(e.name)},onKeyDown:T=>{var H;(T.ctrlKey||T.metaKey)&&T.key==="Enter"?(f(e.name),T.preventDefault()):T.key==="Enter"?(o(!0),T.preventDefault()):T.key==="Backspace"||T.key==="Delete"?(u(!0),T.preventDefault()):T.key==="Escape"&&((H=r.current)==null||H.blur(),T.preventDefault())},children:[_?c.jsx(Oo,{className:V("size-4","text-green-600 dark:text-green-400")}):W?c.jsx(Oo,{className:V("size-4","text-blue-600 dark:text-blue-400")}):x?c.jsx(mr,{className:"size-4 text-purple-600 dark:text-purple-400"}):c.jsx(Hc,{className:"size-4 text-blue-600 dark:text-blue-400"}),!n&&c.jsx("span",{className:V("truncate flex-1",x&&!_&&!W&&!U&&"text-purple-700 dark:text-purple-300",(_||W||U)&&"font-medium"),children:e.name})]});return c.jsxs(Rd,{children:[c.jsxs(qg,{onOpenChange:s,children:[c.jsx(Wg,{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(_d,{children:[c.jsxs(gr,{onClick:()=>f(e.name),children:["Open",c.jsx(fi,{children:_x?"⌘⏎":"⌃⏎"})]}),c.jsx(sa,{}),c.jsx(gr,{disabled:!e,onClick:()=>{e&&oa(e.name,new Blob([e.text],{type:e.type}))},children:"Download..."}),c.jsx(sa,{}),c.jsxs(gr,{onClick:()=>o(!0),children:["Rename...",c.jsx(fi,{children:"⏎"})]}),c.jsxs(gr,{onClick:()=>u(!0),children:["Delete",c.jsx(fi,{children:"⌫"})]})]})]}),c.jsx(qt,{open:a,onOpenChange:o,children:c.jsx(Zt,{className:"sm:max-w-[425px]",onCloseAutoFocus:T=>{var H;T.preventDefault(),(H=r.current)==null||H.focus()},children:c.jsx(_i,{mode:"update",shouldReset:!a,postSubmit:R,selectedName:e.name})})}),c.jsx(qt,{open:l,onOpenChange:u,children:c.jsx(Zt,{className:"sm:max-w-[425px]",onCloseAutoFocus:T=>{var H;T.preventDefault(),(H=r.current)==null||H.focus()},children:c.jsx(_i,{mode:"delete",shouldReset:!l,postSubmit:B,selectedName:e.name})})})]})}const Ko=Ee.memo(jx);async function Cx(e,t){const n=JSON.stringify({name:e,props:t,children:[]},null,2);await navigator.clipboard.writeText(n)}const Nx=Ur("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 Nr({className:e,variant:t,...n}){return c.jsx("div",{className:V(Nx({variant:t}),e),...n})}const Pr=v.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Tc,{ref:r,className:V("relative overflow-hidden",e),...n,children:[c.jsx(vm,{className:"h-full w-full rounded-[inherit]",children:t}),c.jsx($d,{}),c.jsx(wm,{})]}));Pr.displayName=Tc.displayName;const $d=v.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(Ac,{ref:r,orientation:t,className:V("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(km,{className:"bg-border relative flex-1 rounded-full"})}));$d.displayName=Ac.displayName;function Xa({className:e,...t}){return c.jsx(Sm,{"data-slot":"switch",className:V("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(_m,{"data-slot":"switch-thumb",className:V("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 Ex=Ur("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"}}),la=v.forwardRef(({className:e,variant:t,...n},r)=>c.jsx("div",{ref:r,role:"alert",className:V(Ex({variant:t}),e),...n}));la.displayName="Alert";const Ix=v.forwardRef(({className:e,...t},n)=>c.jsx("h5",{ref:n,className:V("mb-1 font-medium leading-none tracking-tight",e),...t}));Ix.displayName="AlertTitle";const ua=v.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:V("text-sm [&_p]:leading-relaxed",e),...t}));ua.displayName="AlertDescription";const ji=v.memo(({keyName:e,value:t,depth:n=0,isLast:r=!1})=>{const[i,s]=v.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:V("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(rn,{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,h)=>c.jsx(ji,{keyName:String(h),value:d,depth:n+1,isLast:h===t.length-1},h)):Object.entries(t).map(([d,h],p,m)=>c.jsx(ji,{keyName:d,value:h,depth:n+1,isLast:p===m.length-1},d)),c.jsx("div",{className:"ml-4",children:c.jsxs("span",{className:"text-muted-foreground",children:[o?"]":"}",!r&&","]})})]})]})});ji.displayName="JsonNode";const Ci=v.memo(({schema:e,loading:t=!1,error:n,className:r})=>t?c.jsxs("div",{className:V("space-y-4",r),children:[c.jsx(Cr,{className:"h-8 w-64"}),c.jsx(Cr,{className:"h-4 w-full"}),c.jsx(Cr,{className:"h-64 w-full"})]}):n?c.jsx(la,{variant:"destructive",className:r,children:c.jsx(ua,{children:n})}):e?c.jsx(Pr,{className:V("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(ji,{value:e})})}):c.jsx(la,{className:r,children:c.jsx(ua,{children:"No schema available"})}));Ci.displayName="SchemaViewer";function zx({plugins:e,initialFocusedPlugin:t}){var y,P;const n=Pt(N=>N.togglePlugin),r=Pt(N=>N.isPluginSelected),i=Pt(N=>N.selectedPlugins),s=Pt(N=>N.isApplyingPlugins),[a,o]=v.useState(null),[l,u]=v.useState(null),[f,d]=v.useState("properties");v.useEffect(()=>{if(t){const N=e.find(k=>k.name===t);if(N){o(N);return}}e.length>0&&!a&&o(e[0])},[t,e]);const h=v.useMemo(()=>{const N={current:[],downstream:[],upstream:[]};return e.forEach(k=>{N[k.location]&&N[k.location].push(k)}),N},[e]),p=async(N,k)=>{a&&(await Cx(a.name,N.props),u(k),setTimeout(()=>u(null),2e3))},m=N=>{switch(N){case"current":return"Current Directory";case"downstream":return"Project";case"upstream":return"Parent Directories";default:return N}},w=N=>{switch(N){case"current":return c.jsx($m,{className:"size-3"});case"downstream":return c.jsx(Mm,{className:"size-3"});case"upstream":return c.jsx(Hc,{className:"size-3"});default:return null}},S=((y=a==null?void 0:a.schema)==null?void 0:y.properties)&&Object.keys(a.schema.properties).length>0,x=(P=a==null?void 0:a.schema)==null?void 0:P.jsonSchema,_=(a==null?void 0:a.examples)&&a.examples.length>0;return c.jsxs(c.Fragment,{children:[c.jsxs(_n,{children:[c.jsxs(jn,{className:"flex items-center gap-2",children:[c.jsx(qc,{className:"size-5 text-amber-600 dark:text-amber-400"}),"Plugins",c.jsxs(Nr,{variant:"secondary",className:"font-normal",children:[i.size," active"]})]}),c.jsxs(Gn,{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(h).map(([N,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(N),m(N)]}),c.jsx("div",{className:"space-y-0.5",children:k.map(j=>{const $=r(j.name),W=(a==null?void 0:a.name)===j.name;return c.jsxs("button",{onClick:()=>o(j),className:V("w-full text-left px-2 py-1.5 rounded-md transition-colors cursor-pointer","flex items-center gap-2",W?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"),children:[c.jsx("div",{className:V("size-1.5 rounded-full flex-none transition-colors",$?"bg-amber-500 dark:bg-amber-400":"bg-muted-foreground/30")}),c.jsx("span",{className:"text-sm font-medium truncate flex-1",children:j.name})]},j.name)})})]},N))})})}),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(Nr,{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(Xa,{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:V("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(Do,{className:"size-3.5"}),"Properties"]})}),x&&c.jsx("button",{onClick:()=>d("schema"),className:V("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(Om,{className:"size-3.5"}),"Schema"]})}),_&&c.jsx("button",{onClick:()=>d("examples"),className:V("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(Dm,{className:"size-3.5"}),"Examples",c.jsx(Nr,{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(([N,k])=>c.jsx(Tx,{name:N,prop:k},N))}),f==="schema"&&x&&c.jsx(Ci,{schema:a.schema.jsonSchema,loading:!1,className:"h-[420px]"}),f==="examples"&&_&&a.examples.map((N,k)=>c.jsxs("div",{className:V(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:[N.title&&c.jsx("span",{className:"font-medium text-sm truncate",children:N.title}),!N.title&&c.jsxs("span",{className:"text-sm text-muted-foreground",children:["Example ",k+1]})]}),c.jsx(Ie,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs flex-none",onClick:()=>p(N,k),children:l===k?c.jsxs(c.Fragment,{children:[c.jsx(Rm,{className:"size-3 mr-1 text-green-600"}),"Copied"]}):c.jsxs(c.Fragment,{children:[c.jsx(Fa,{className:"size-3 mr-1"}),"Copy"]})})]}),N.description&&c.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:N.description}),c.jsx("pre",{className:"p-3 bg-muted rounded-md overflow-x-auto text-xs font-mono leading-relaxed",children:JSON.stringify(N.props,null,2)})]},k)),!S&&!x&&!_&&c.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[c.jsx(Do,{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 Tx({name:e,prop:t}){var a;const[n,r]=v.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:V("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(rn,{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(Nr,{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 ws=jm,ks=Cm,Ss=Nm,Fd=Em,Ld=Im,Ax=v.forwardRef(({className:e,inset:t,children:n,...r},i)=>c.jsxs(Rc,{ref:i,className:V("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"})]}));Ax.displayName=Rc.displayName;const Px=v.forwardRef(({className:e,...t},n)=>c.jsx(Mc,{ref:n,className:V("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}));Px.displayName=Mc.displayName;const Qa=v.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(zm,{children:c.jsx(Pc,{ref:r,sideOffset:t,className:V("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})}));Qa.displayName=Pc.displayName;const tn=v.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Oc,{ref:r,className:V("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}));tn.displayName=Oc.displayName;const Ox=v.forwardRef(({className:e,children:t,checked:n,...r},i)=>c.jsxs($c,{ref:i,className:V("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(Fc,{children:c.jsx(Sn,{className:"h-4 w-4"})})}),t]}));Ox.displayName=$c.displayName;const Dx=v.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Lc,{ref:r,className:V("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(Fc,{children:c.jsx(Jc,{className:"h-2 w-2 fill-current"})})}),t]}));Dx.displayName=Lc.displayName;const Rx=v.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Zc,{ref:r,className:V("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Rx.displayName=Zc.displayName;const Ni=v.forwardRef(({className:e,...t},n)=>c.jsx(Dc,{ref:n,className:V("bg-muted -mx-1 my-1 h-px",e),...t}));Ni.displayName=Dc.displayName;function Mx(){const{theme:e,setTheme:t}=lc(),n=e==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e,r=v.useCallback(()=>{t(n==="dark"?"light":"dark")},[n,t]);return c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:c.jsxs(Ie,{variant:"ghost",size:"icon",onClick:r,children:[c.jsx(Fm,{className:"hidden dark:block"}),c.jsx(Lm,{className:"block dark:hidden"}),c.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),c.jsx(et,{children:c.jsx("p",{children:"Toggle theme"})})]})}const $x=Tm,Zd=v.forwardRef(({className:e,...t},n)=>c.jsx(Bc,{ref:n,className:V("bg-muted text-muted-foreground inline-flex h-9 items-center justify-center rounded-lg p-1",e),...t}));Zd.displayName=Bc.displayName;const ca=v.forwardRef(({className:e,...t},n)=>c.jsx(Vc,{ref:n,className:V("ring-offset-background focus-visible:ring-ring data-[state=active]:bg-background data-[state=active]:text-foreground inline-flex 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}));ca.displayName=Vc.displayName;const da=v.forwardRef(({className:e,...t},n)=>c.jsx(Uc,{ref:n,className:V("ring-offset-background focus-visible:ring-ring mt-2 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",e),...t}));da.displayName=Uc.displayName;async function Fx(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 Lx(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 Zx(e){const t=Lx(e);return Fx(t)}const Bd=({open:e,onOpenChange:t,defaultTab:n="document"})=>{const[r,i]=v.useState(n),[s,a]=v.useState(null),[o,l]=v.useState(null),[u,f]=v.useState(!1),[d,h]=v.useState(!1),[p,m]=v.useState(null),[w,S]=v.useState(null),[x,_]=v.useState(!1),{toast:y}=Ma(),P=Pt(B=>B.selectedPlugins),N=Array.from(P);v.useEffect(()=>{n&&i(n)},[n]);const k=v.useCallback(async()=>{f(!0),m(null);try{const B=await hs.fetchDocumentSchema(N);a(B)}catch(B){const L=B instanceof Error?B.message:"Failed to load document schema";m(L),y({variant:"destructive",title:"Error loading schema",description:L})}finally{f(!1)}},[N,y]),j=v.useCallback(async()=>{if(!o){h(!0),S(null);try{const B=await hs.fetchThemeSchema();l(B)}catch(B){const L=B instanceof Error?B.message:"Failed to load theme schema";S(L),y({variant:"destructive",title:"Error loading schema",description:L})}finally{h(!1)}}},[o,y]),[$,W]=v.useState([]);v.useEffect(()=>{e||(a(null),m(null))},[e]),v.useEffect(()=>{if(!e)return;const B=N.length!==$.length||N.some((L,T)=>L!==$[T]);r==="document"?(!s||B)&&(B&&(hs.clearPluginSchemaCache(),W([...N])),u||k()):r==="theme"&&!o&&!d&&j()},[r,e,s,o,u,d,N,$,k,j]);const E=N.length,U=r==="document"?s:o,R=async()=>{if(U)try{await Zx(U)&&(_(!0),y({title:"Schema copied",description:"The JSON schema has been copied to your clipboard"}),setTimeout(()=>_(!1),2e3))}catch(B){console.error("Copy failed:",B)}};return c.jsx(qt,{open:e,onOpenChange:t,children:c.jsxs(Zt,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[c.jsx(_n,{children:c.jsx(jn,{children:"Schema Viewer"})}),c.jsxs($x,{value:r,onValueChange:B=>i(B),className:"flex-1 overflow-hidden flex flex-col",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Zd,{children:[c.jsxs(ca,{value:"document",className:"flex items-center gap-1",children:["Document",E>0&&c.jsxs(Nr,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:["+",E]})]}),c.jsx(ca,{value:"theme",children:"Theme"})]}),c.jsx("div",{className:"ml-auto",children:c.jsx(Ie,{variant:"ghost",size:"icon",onClick:R,disabled:x||!U,"aria-label":"Copy schema",children:x?c.jsx(Sn,{className:"h-4 w-4"}):c.jsx(Fa,{className:"h-4 w-4"})})})]}),c.jsxs("div",{className:"flex-1 overflow-auto mt-4",children:[c.jsx(da,{value:"document",className:"h-full",children:c.jsx(Ci,{schema:s,loading:u,error:p||void 0})}),c.jsx(da,{value:"theme",className:"h-full",children:c.jsx(Ci,{schema:o,loading:d,error:w||void 0})})]})]})]})})};function Bx({discoveryData:e,onToggleSidebar:t,isCollapsed:n=!1,isAnimating:r=!1}){const{documents:i,documentTypes:s,createDocument:a,openDocument:o}=Ge(fg(I=>({documents:I.documents,documentTypes:I.documentTypes,createDocument:I.createDocument,openDocument:I.openDocument}))),l=Xs(I=>I.updateTheme),u=Xs(I=>I.removeTheme),f=v.useContext(tg),[d,h]=v.useState(!1),[p,m]=v.useState(!1),[w,S]=v.useState(!1),[x,_]=v.useState(null),y=Pt(I=>I.togglePlugin),P=Pt(I=>I.isPluginSelected),N=Pt(I=>I.selectedPlugins),k=Pt(I=>I.isApplyingPlugins),[j,$]=v.useState(!1),[W,E]=v.useState(new Set(["current-docs","current-themes"])),{toast:U}=Ma(),R=i.filter(I=>s[I.name]!=="application/json+theme"),B=i.filter(I=>s[I.name]==="application/json+theme"),L=v.useMemo(()=>{if(!e)return{current:[],downstream:[]};const I={current:[],downstream:[]};return e.documents.forEach(D=>{I[D.location]&&I[D.location].push(D)}),I},[e]),T=v.useMemo(()=>{if(!e)return{current:[],downstream:[]};const I={current:[],downstream:[]};return e.themes.forEach(D=>{I[D.location]&&I[D.location].push(D)}),I},[e]),H=v.useMemo(()=>{const I=new Set;return R.forEach(D=>{try{const J=JSON.parse(D.text);J.children&&Array.isArray(J.children)&&J.children.forEach(oe=>{var pe;oe.name==="docx"&&((pe=oe.props)!=null&&pe.theme)&&I.add(oe.props.theme)})}catch{}}),I},[R]),Y=v.useCallback(()=>{h(!1)},[]),O=v.useCallback(()=>{m(!1)},[]),G=v.useRef(new Map);v.useEffect(()=>{const I=G.current,D=new Map;B.forEach(J=>{D.set(J.name,J.text),I.get(J.name)!==J.text&&l(J.name,J.text)}),I.forEach((J,oe)=>{D.has(oe)||u(oe)}),G.current=D},[B,l,u]);const b=v.useRef(!1);v.useEffect(()=>{if(b.current||!f)return;b.current=!0;const I=new Set(B.map(J=>J.name));Object.keys(f.getState().customThemes).forEach(J=>{I.has(J)||u(J)})},[B,u,f]);const ue=I=>{E(D=>{const J=new Set(D);return J.has(I)?J.delete(I):J.add(I),J})},ae=Ge(I=>I.activeTab),g=ae&&s[ae]==="application/json+theme"?"theme":"document",{resolvedTheme:K}=lc(),ie=K==="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",Q=v.useCallback(async(I,D)=>{if(i.some(J=>J.name===I)){o(I);return}try{const J=await fetch(`/api/discovery/${D?"themes":"documents"}/${encodeURIComponent(I)}/content`);if(!J.ok)throw new Error(J.statusText);const oe=await J.text(),pe=JSON.parse(oe);a(I,JSON.stringify(pe,null,2)),o(I),U({title:`Added ${D?"theme":"document"}: ${I}`})}catch{U({title:"Failed to load",description:`Could not load ${I}`,variant:"destructive"})}},[i,a,o,U]);return c.jsxs(c.Fragment,{children:[c.jsxs(Td,{collapsible:"none",style:{"--sidebar-width":n?"2.5rem":"16rem"},children:[c.jsx(Ad,{children:c.jsx("div",{className:V("flex items-center transition-opacity duration-[120ms] ease-in-out",r?"opacity-0":"opacity-100",n?"justify-center":"justify-between"),children:n?c.jsx(Ie,{variant:"ghost",size:"icon",title:"Expand sidebar",onClick:t,children:c.jsx(Wc,{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:ie,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(Ie,{variant:"ghost",size:"icon",title:"Collapse sidebar",onClick:t,children:c.jsx(Zm,{className:"h-4 w-4"})})})]})})}),c.jsxs(Dd,{className:V("h-full transition-opacity duration-[120ms] ease-in-out",r?"opacity-0":"opacity-100"),children:[c.jsxs(pi,{children:[c.jsxs(hi,{className:V("flex items-center",n?"justify-center":"justify-between"),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[!n&&c.jsx(ms,{className:"size-3"}),!n&&c.jsx("span",{children:"Active Documents"})]}),c.jsxs(qt,{open:d,onOpenChange:h,children:[c.jsx(qo,{asChild:!0,children:c.jsx("div",{className:V("flex",n?"w-full justify-center":""),children:c.jsx(Ie,{className:V("h-6 w-6 p-0 flex-shrink-0",n&&"mx-auto"),variant:"ghost",size:"icon",title:"New Document",children:n?c.jsx(ms,{className:"size-4"}):c.jsx(bi,{className:"size-4"})})})}),c.jsx(Zt,{className:"sm:max-w-[525px]",children:c.jsx(_i,{mode:"create",shouldReset:!d,postSubmit:Y,discoveredDocuments:(e==null?void 0:e.documents)||[]})})]})]}),n?c.jsx(xr,{children:c.jsx("div",{className:"flex flex-col items-center gap-0.5 px-0.5",children:R.map(I=>{const D=ae===I.name;return c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:c.jsxs("button",{onClick:()=>o(I.name),className:V("relative w-7 h-7 rounded flex items-center justify-center text-[10px] font-bold transition-colors",D?"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:[D&&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.charAt(0).toUpperCase()]})}),c.jsx(et,{side:"right",children:c.jsx("span",{className:"text-xs",children:I.name})})]},I.name)})})}):c.jsx(xr,{children:c.jsx(aa,{children:R.length>0?R.map((I,D)=>c.jsx(Ko,{document:I,compact:n},`doc-${D}`)):c.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No active documents. Click + to create one."})})})]}),c.jsx(Od,{}),c.jsxs(pi,{children:[c.jsxs(hi,{className:V("flex items-center",n?"justify-center":"justify-between"),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[!n&&c.jsx(mr,{className:"size-3 text-purple-600 dark:text-purple-400"}),!n&&c.jsx("span",{children:"Active Themes"})]}),c.jsxs(qt,{open:p,onOpenChange:m,children:[c.jsx(qo,{asChild:!0,children:c.jsx("div",{className:V("flex",n?"w-full justify-center":""),children:c.jsx(Ie,{className:V("h-6 w-6 p-0 flex-shrink-0",n&&"mx-auto"),variant:"ghost",size:"icon",title:"New Theme",children:n?c.jsx(mr,{className:"size-4"}):c.jsx(bi,{className:"size-4"})})})}),c.jsx(Zt,{className:"sm:max-w-[525px]",children:c.jsx(_i,{mode:"create",shouldReset:!p,postSubmit:O,discoveredThemes:(e==null?void 0:e.themes)||[],isTheme:!0})})]})]}),n?c.jsx(xr,{children:c.jsx("div",{className:"flex flex-col items-center gap-0.5 px-0.5",children:B.map(I=>{const D=ae===I.name;let J=null;try{const pe=JSON.parse(I.text);J=Qs(pe)}catch{}const oe=J?H.has(J):!1;return c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:c.jsxs("button",{onClick:()=>o(I.name),className:V("relative w-7 h-7 rounded flex items-center justify-center text-[10px] font-bold transition-colors",D?"bg-purple-100 text-purple-700 dark:bg-purple-900/40 dark:text-purple-300":oe?"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:[D&&c.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-0.5 rounded-full bg-purple-500 dark:bg-purple-400"}),c.jsx(mr,{className:"size-3"})]})}),c.jsx(et,{side:"right",children:c.jsxs("div",{className:"text-xs",children:[I.name,oe&&c.jsx("div",{className:"opacity-70",children:"In use"})]})})]},I.name)})})}):c.jsx(xr,{children:c.jsx(aa,{children:B.length>0?B.map((I,D)=>{let J=null;try{const pe=JSON.parse(I.text);J=Qs(pe)}catch{}const oe=J?H.has(J):!1;return c.jsx(Ko,{document:I,compact:n,indicator:oe?"in-use":void 0},`theme-${D}`)}):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."]})})})]}),e&&(e.documents.length>0||e.themes.length>0)&&c.jsxs(pi,{className:"mt-2 border-t pt-4",children:[c.jsx(hi,{className:V("flex items-center mb-2",n?"justify-center":"gap-2"),children:n?c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:c.jsx(Ro,{className:"size-3"})}),c.jsx(et,{side:"right",children:c.jsx("span",{className:"text-xs",children:"Expand sidebar to show discovered resources"})})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ro,{className:"size-3"}),c.jsx("span",{children:"Discovered Resources"})]})}),!n&&c.jsxs(c.Fragment,{children:[Object.entries(L).map(([I,D])=>{if(D.length===0)return null;const J=`${I}-docs`,oe=W.has(J);return c.jsxs(ws,{open:oe,children:[c.jsxs(ks,{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:()=>ue(J),children:[c.jsx(rn,{className:V("size-3 transition-transform",!oe&&"-rotate-90")}),c.jsx(ms,{className:"size-3"}),I==="current"?"Current Directory":"Project"," ","Documents (",D.length,")"]}),c.jsx(Ss,{children:c.jsx("div",{className:"pl-4 space-y-0.5",children:D.map((pe,Ae)=>{const ke=i.some(be=>be.name===pe.name);return c.jsxs("button",{onClick:()=>Q(pe.name,!1),className:V("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",ke&&"opacity-50"),children:[c.jsx("div",{className:"font-medium truncate",children:pe.name}),pe.title&&c.jsx("div",{className:"text-xs text-muted-foreground truncate",children:pe.title})]},Ae)})})})]},J)}),Object.entries(T).map(([I,D])=>{if(D.length===0)return null;const J=`${I}-themes`,oe=W.has(J);return c.jsxs(ws,{open:oe,children:[c.jsxs(ks,{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:()=>ue(J),children:[c.jsx(rn,{className:V("size-3 transition-transform",!oe&&"-rotate-90")}),c.jsx(mr,{className:"size-3"}),I==="current"?"Current Directory":"Project"," ","Themes (",D.length,")"]}),c.jsx(Ss,{children:c.jsx("div",{className:"pl-4 space-y-0.5",children:D.map((pe,Ae)=>{const ke=i.some(be=>be.name===pe.name);return c.jsxs("button",{onClick:()=>Q(pe.name,!0),className:V("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",ke&&"opacity-50"),children:[c.jsx("div",{className:"font-medium truncate",children:pe.name}),pe.description&&c.jsx("div",{className:"text-xs text-muted-foreground truncate",children:pe.description})]},Ae)})})})]},J)}),e&&e.plugins.length>0&&c.jsxs(ws,{open:W.has("plugins"),children:[c.jsxs(ks,{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:()=>ue("plugins"),children:[c.jsx(rn,{className:V("size-3 transition-transform",!W.has("plugins")&&"-rotate-90")}),c.jsx(qc,{className:"size-3 text-amber-600 dark:text-amber-400"}),"Plugins (",N.size,"/",e.plugins.length,")"]}),c.jsx(Ss,{children:c.jsx("div",{className:"pl-4 space-y-0.5",children:e.plugins.map((I,D)=>{const J=P(I.name);return c.jsxs("div",{className:V("py-1 px-2 text-sm border-l-2 flex items-center gap-2 group transition-colors",J?"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:oe=>{oe.stopPropagation(),_(I.name),S(!0)},children:c.jsx(Gc,{className:"size-3 text-muted-foreground"})}),c.jsx(Xa,{checked:J,onCheckedChange:()=>y(I),disabled:k,className:"flex-none scale-[0.8]","aria-label":`Toggle ${I.name} plugin`})]},D)})})})]})]})]})]}),c.jsx(Pd,{children:c.jsx("div",{className:V("flex w-full items-center transition-opacity duration-[120ms] ease-in-out",r?"opacity-0":"opacity-100",n?"justify-center":"justify-end pr-2"),children:c.jsx(Mx,{})})}),c.jsx(qt,{open:w,onOpenChange:I=>{S(I),I||_(null)},children:c.jsx(Zt,{className:"sm:max-w-5xl max-h-[85vh] overflow-hidden",children:c.jsx(zx,{plugins:(e==null?void 0:e.plugins)||[],initialFocusedPlugin:x})})})]}),c.jsx(Bd,{open:j,onOpenChange:$,defaultTab:g==="theme"?"theme":"document"})]})}const Yo=v.memo(Bx),Vx=v.lazy(()=>uc(()=>import("./editor-BxyYhgT1.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(e=>({default:e.Editor})));function Xo(){return c.jsx(v.Suspense,{fallback:c.jsx("div",{className:"flex items-center justify-center h-full",children:c.jsxs("div",{className:"text-center",children:[c.jsx(Qt,{className:"w-8 h-8 mx-auto mb-2"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading editor..."})]})}),children:c.jsx(Vx,{})})}const Ux=v.lazy(()=>uc(()=>import("./preview-BBQhSmsm.js"),__vite__mapDeps([12,1,3,4,5,6,7,8,9,10,11])).then(e=>({default:e.Preview})));function Qo(){return c.jsx(v.Suspense,{fallback:c.jsx("div",{className:"flex items-center justify-center h-full",children:c.jsxs("div",{className:"text-center",children:[c.jsx(Qt,{className:"w-8 h-8 mx-auto mb-2"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading preview..."})]})}),children:c.jsx(Ux,{})})}const{createElement:Kn,createContext:Jx,forwardRef:Vd,useCallback:dt,useContext:Ud,useEffect:vn,useImperativeHandle:Jd,useLayoutEffect:Hx,useMemo:qx,useRef:mt,useState:Jn}=oc,el=oc[`useId${Math.random()}`.slice(0,5)],Wx=Hx,es=Jx(null);es.displayName="PanelGroupContext";const wn=Wx,Gx=typeof el=="function"?el:()=>null;let Kx=0;function eo(e=null){const t=Gx(),n=mt(e||t||null);return n.current===null&&(n.current=""+Kx++),e??n.current}function Hd({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:h,style:p,tagName:m="div",...w}){const S=Ud(es);if(S===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:x,expandPanel:_,getPanelSize:y,getPanelStyle:P,groupId:N,isPanelCollapsed:k,reevaluatePanelConstraints:j,registerPanel:$,resizePanel:W,unregisterPanel:E}=S,U=eo(a),R=mt({callbacks:{onCollapse:u,onExpand:f,onResize:d},constraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:o,minSize:l},id:U,idIsFromProps:a!==void 0,order:h});mt({didLogMissingDefaultSizeWarning:!1}),wn(()=>{const{callbacks:L,constraints:T}=R.current,H={...T};R.current.id=U,R.current.idIsFromProps=a!==void 0,R.current.order=h,L.onCollapse=u,L.onExpand=f,L.onResize=d,T.collapsedSize=n,T.collapsible=r,T.defaultSize=i,T.maxSize=o,T.minSize=l,(H.collapsedSize!==T.collapsedSize||H.collapsible!==T.collapsible||H.maxSize!==T.maxSize||H.minSize!==T.minSize)&&j(R.current,H)}),wn(()=>{const L=R.current;return $(L),()=>{E(L)}},[h,U,$,E]),Jd(s,()=>({collapse:()=>{x(R.current)},expand:L=>{_(R.current,L)},getId(){return U},getSize(){return y(R.current)},isCollapsed(){return k(R.current)},isExpanded(){return!k(R.current)},resize:L=>{W(R.current,L)}}),[x,_,y,k,U,W]);const B=P(R.current,i);return Kn(m,{...w,children:e,className:t,id:a,style:{...B,...p},"data-panel":"","data-panel-collapsible":r||void 0,"data-panel-group-id":N,"data-panel-id":U,"data-panel-size":parseFloat(""+B.flexGrow).toFixed(1)})}const qd=Vd((e,t)=>Kn(Hd,{...e,forwardedRef:t}));Hd.displayName="Panel";qd.displayName="forwardRef(Panel)";let fa=null,bn=null;function Yx(e,t){if(t){const n=(t&Xd)!==0,r=(t&Qd)!==0,i=(t&ef)!==0,s=(t&tf)!==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 Xx(){bn!==null&&(document.head.removeChild(bn),fa=null,bn=null)}function _s(e,t){const n=Yx(e,t);fa!==n&&(fa=n,bn===null&&(bn=document.createElement("style"),document.head.appendChild(bn)),bn.innerHTML=`*{cursor: ${n}!important;}`)}function Wd(e){return e.type==="keydown"}function Gd(e){return e.type.startsWith("pointer")}function Kd(e){return e.type.startsWith("mouse")}function ts(e){if(Gd(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Kd(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function Qx(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function ey(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 ty(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:rl(e),b:rl(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;we(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:nl(tl(n.a)),b:nl(tl(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 ny=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function ry(e){var t;const n=getComputedStyle((t=Yd(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function iy(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||ry(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"||ny.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function tl(e){let t=e.length;for(;t--;){const n=e[t];if(we(n,"Missing node"),iy(n))return n}return null}function nl(e){return e&&Number(getComputedStyle(e).zIndex)||0}function rl(e){const t=[];for(;e;)t.push(e),e=Yd(e);return t}function Yd(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const Xd=1,Qd=2,ef=4,tf=8,sy=Qx()==="coarse";let Ot=[],Hn=!1,nn=new Map,ns=new Map;const Or=new Set;function ay(e,t,n,r,i){var s;const{ownerDocument:a}=t,o={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:i},l=(s=nn.get(a))!==null&&s!==void 0?s:0;return nn.set(a,l+1),Or.add(o),Ei(),function(){var f;ns.delete(e),Or.delete(o);const d=(f=nn.get(a))!==null&&f!==void 0?f:1;if(nn.set(a,d-1),Ei(),d===1&&nn.delete(a),Ot.includes(o)){const h=Ot.indexOf(o);h>=0&&Ot.splice(h,1),no(),i("up",!0,null)}}}function il(e){const{target:t}=e,{x:n,y:r}=ts(e);Hn=!0,to({target:t,x:n,y:r}),Ei(),Ot.length>0&&(Ii("down",e),e.preventDefault(),e.stopPropagation())}function ur(e){const{x:t,y:n}=ts(e);if(Hn&&e.buttons===0&&(Hn=!1,Ii("up",e)),!Hn){const{target:r}=e;to({target:r,x:t,y:n})}Ii("move",e),no(),Ot.length>0&&e.preventDefault()}function An(e){const{target:t}=e,{x:n,y:r}=ts(e);ns.clear(),Hn=!1,Ot.length>0&&e.preventDefault(),Ii("up",e),to({target:t,x:n,y:r}),no(),Ei()}function to({target:e,x:t,y:n}){Ot.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),Or.forEach(i=>{const{element:s,hitAreaMargins:a}=i,o=s.getBoundingClientRect(),{bottom:l,left:u,right:f,top:d}=o,h=sy?a.coarse:a.fine;if(t>=u-h&&t<=f+h&&n>=d-h&&n<=l+h){if(r!==null&&document.contains(r)&&s!==r&&!s.contains(r)&&!r.contains(s)&&ty(r,s)>0){let m=r,w=!1;for(;m&&!m.contains(s);){if(ey(m.getBoundingClientRect(),o)){w=!0;break}m=m.parentElement}if(w)return}Ot.push(i)}})}function js(e,t){ns.set(e,t)}function no(){let e=!1,t=!1;Ot.forEach(r=>{const{direction:i}=r;i==="horizontal"?e=!0:t=!0});let n=0;ns.forEach(r=>{n|=r}),e&&t?_s("intersection",n):e?_s("horizontal",n):t?_s("vertical",n):Xx()}function Ei(){nn.forEach((e,t)=>{const{body:n}=t;n.removeEventListener("contextmenu",An),n.removeEventListener("pointerdown",il),n.removeEventListener("pointerleave",ur),n.removeEventListener("pointermove",ur)}),window.removeEventListener("pointerup",An),window.removeEventListener("pointercancel",An),Or.size>0&&(Hn?(Ot.length>0&&nn.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("contextmenu",An),n.addEventListener("pointerleave",ur),n.addEventListener("pointermove",ur))}),window.addEventListener("pointerup",An),window.addEventListener("pointercancel",An)):nn.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("pointerdown",il,{capture:!0}),n.addEventListener("pointermove",ur))}))}function Ii(e,t){Or.forEach(n=>{const{setResizeHandlerState:r}=n,i=Ot.includes(n);r(e,i,t)})}function oy(){const[e,t]=Jn(0);return dt(()=>t(n=>n+1),[])}function we(e,t){if(!e)throw console.error(t),Error(t)}const ro=10;function Cn(e,t,n=ro){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Ht(e,t,n=ro){return Cn(e,t,n)===0}function vt(e,t,n){return Cn(e,t,n)===0}function ly(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(!vt(i,s,n))return!1}return!0}function Bn({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];we(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:s,maxSize:a=100,minSize:o=0}=r;if(Cn(n,o)<0)if(s){const l=(i+o)/2;Cn(n,l)<0?n=i:n=o}else n=o;return n=Math.min(a,n),n=parseFloat(n.toFixed(ro)),n}function yr({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(vt(e,0))return t;const a=[...t],[o,l]=r;we(o!=null,"Invalid first pivot index"),we(l!=null,"Invalid second pivot index");let u=0;if(s==="keyboard"){{const d=e<0?l:o,h=n[d];we(h,`Panel constraints not found for index ${d}`);const{collapsedSize:p=0,collapsible:m,minSize:w=0}=h;if(m){const S=t[d];if(we(S!=null,`Previous layout not found for panel index ${d}`),vt(S,p)){const x=w-S;Cn(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const d=e<0?o:l,h=n[d];we(h,`No panel constraints found for index ${d}`);const{collapsedSize:p=0,collapsible:m,minSize:w=0}=h;if(m){const S=t[d];if(we(S!=null,`Previous layout not found for panel index ${d}`),vt(S,w)){const x=S-p;Cn(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}}{const d=e<0?1:-1;let h=e<0?l:o,p=0;for(;;){const w=t[h];we(w!=null,`Previous layout not found for panel index ${h}`);const x=Bn({panelConstraints:n,panelIndex:h,size:100})-w;if(p+=x,h+=d,h<0||h>=n.length)break}const m=Math.min(Math.abs(e),Math.abs(p));e=e<0?0-m:m}{let h=e<0?o:l;for(;h>=0&&h<n.length;){const p=Math.abs(e)-Math.abs(u),m=t[h];we(m!=null,`Previous layout not found for panel index ${h}`);const w=m-p,S=Bn({panelConstraints:n,panelIndex:h,size:w});if(!vt(m,S)&&(u+=m-S,a[h]=S,u.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?h--:h++}}if(ly(i,a))return i;{const d=e<0?l:o,h=t[d];we(h!=null,`Previous layout not found for panel index ${d}`);const p=h+u,m=Bn({panelConstraints:n,panelIndex:d,size:p});if(a[d]=m,!vt(m,p)){let w=p-m,x=e<0?l:o;for(;x>=0&&x<n.length;){const _=a[x];we(_!=null,`Previous layout not found for panel index ${x}`);const y=_+w,P=Bn({panelConstraints:n,panelIndex:x,size:y});if(vt(_,P)||(w-=P-_,a[x]=P),vt(w,0))break;e>0?x--:x++}}}const f=a.reduce((d,h)=>h+d,0);return vt(f,100)?a:i}function uy({layout:e,panelsArray:t,pivotIndices:n}){let r=0,i=100,s=0,a=0;const o=n[0];we(o!=null,"No pivot index found"),t.forEach((d,h)=>{const{constraints:p}=d,{maxSize:m=100,minSize:w=0}=p;h===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 Dr(e,t=document){return Array.from(t.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${e}"]`))}function nf(e,t,n=document){const i=Dr(e,n).findIndex(s=>s.getAttribute("data-panel-resize-handle-id")===t);return i??null}function rf(e,t,n){const r=nf(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function sf(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 rs(e,t=document){const n=t.querySelector(`[data-panel-resize-handle-id="${e}"]`);return n||null}function cy(e,t,n,r=document){var i,s,a,o;const l=rs(t,r),u=Dr(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,h=(a=(o=n[f+1])===null||o===void 0?void 0:o.id)!==null&&a!==void 0?a:null;return[d,h]}function dy({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:i,panelGroupElement:s,setLayout:a}){mt({didWarnAboutMissingResizeHandle:!1}),wn(()=>{if(!s)return;const o=Dr(n,s);for(let l=0;l<i.length-1;l++){const{valueMax:u,valueMin:f,valueNow:d}=uy({layout:r,panelsArray:i,pivotIndices:[l,l+1]}),h=o[l];if(h!=null){const p=i[l];we(p,`No panel data found for index "${l}"`),h.setAttribute("aria-controls",p.id),h.setAttribute("aria-valuemax",""+Math.round(u)),h.setAttribute("aria-valuemin",""+Math.round(f)),h.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]),vn(()=>{if(!s)return;const o=t.current;we(o,"Eager values not found");const{panelDataArray:l}=o,u=sf(n,s);we(u!=null,`No group found for id "${n}"`);const f=Dr(n,s);we(f,`No resize handles found for group id "${n}"`);const d=f.map(h=>{const p=h.getAttribute("data-panel-resize-handle-id");we(p,"Resize handle element has no handle id attribute");const[m,w]=cy(n,p,l,s);if(m==null||w==null)return()=>{};const S=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const _=l.findIndex(y=>y.id===m);if(_>=0){const y=l[_];we(y,`No panel data found for index ${_}`);const P=r[_],{collapsedSize:N=0,collapsible:k,minSize:j=0}=y.constraints;if(P!=null&&k){const $=yr({delta:vt(P,N)?j-N:N-P,initialLayout:r,panelConstraints:l.map(W=>W.constraints),pivotIndices:rf(n,p,s),prevLayout:r,trigger:"keyboard"});r!==$&&a($)}}break}}};return h.addEventListener("keydown",S),()=>{h.removeEventListener("keydown",S)}});return()=>{d.forEach(h=>h())}},[s,e,t,n,r,i,a])}function sl(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 af(e,t){const n=e==="horizontal",{x:r,y:i}=ts(t);return n?r:i}function fy(e,t,n,r,i){const s=n==="horizontal",a=rs(t,i);we(a,`No resize handle element found for id "${t}"`);const o=a.getAttribute("data-panel-group-id");we(o,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=r;const u=af(n,e),f=sf(o,i);we(f,`No group element found for id "${o}"`);const d=f.getBoundingClientRect(),h=s?d.width:d.height;return(u-l)/h*100}function py(e,t,n,r,i,s){if(Wd(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:fy(e,t,n,r,s)}function hy({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];we(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];we(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 Pn(e,t,n){t.forEach((r,i)=>{const s=e[i];we(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:h,onExpand:p,onResize:m}=a;m&&m(r,d),f&&(h||p)&&(p&&(d==null||Ht(d,u))&&!Ht(r,u)&&p(),h&&(d==null||!Ht(d,u))&&Ht(r,u)&&h())}})}function ti(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 my({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 gy(e,t=10){let n=null;return(...i)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...i)},t)}}function al(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 of(e){return`react-resizable-panels:${e}`}function lf(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 uf(e,t){try{const n=of(e),r=t.getItem(n);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function xy(e,t,n){var r,i;const s=(r=uf(e,n))!==null&&r!==void 0?r:{},a=lf(t);return(i=s[a])!==null&&i!==void 0?i:null}function yy(e,t,n,r,i){var s;const a=of(e),o=lf(t),l=(s=uf(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 ol({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(!vt(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const a=n[s];we(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];we(a!=null,`No layout data found for index ${s}`);const o=Bn({panelConstraints:t,panelIndex:s,size:a});a!=o&&(i+=a-o,n[s]=o)}if(!vt(i,0))for(let s=0;s<t.length;s++){const a=n[s];we(a!=null,`No layout data found for index ${s}`);const o=a+i,l=Bn({panelConstraints:t,panelIndex:s,size:o});if(a!==l&&(i-=l-a,n[s]=l,vt(i,0)))break}return n}const by=100,br={getItem:e=>(al(br),br.getItem(e)),setItem:(e,t)=>{al(br),br.setItem(e,t)}},ll={};function cf({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:i,id:s=null,onLayout:a=null,keyboardResizeBy:o=null,storage:l=br,style:u,tagName:f="div",...d}){const h=eo(s),p=mt(null),[m,w]=Jn(null),[S,x]=Jn([]),_=oy(),y=mt({}),P=mt(new Map),N=mt(0),k=mt({autoSaveId:e,direction:r,dragState:m,id:h,keyboardResizeBy:o,onLayout:a,storage:l}),j=mt({layout:S,panelDataArray:[],panelDataArrayChanged:!1});mt({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),Jd(i,()=>({getId:()=>k.current.id,getLayout:()=>{const{layout:g}=j.current;return g},setLayout:g=>{const{onLayout:K}=k.current,{layout:ie,panelDataArray:Q}=j.current,I=ol({layout:g,panelConstraints:Q.map(D=>D.constraints)});sl(ie,I)||(x(I),j.current.layout=I,K&&K(I),Pn(Q,I,y.current))}}),[]),wn(()=>{k.current.autoSaveId=e,k.current.direction=r,k.current.dragState=m,k.current.id=h,k.current.onLayout=a,k.current.storage=l}),dy({committedValuesRef:k,eagerValuesRef:j,groupId:h,layout:S,panelDataArray:j.current.panelDataArray,setLayout:x,panelGroupElement:p.current}),vn(()=>{const{panelDataArray:g}=j.current;if(e){if(S.length===0||S.length!==g.length)return;let K=ll[e];K==null&&(K=gy(yy,by),ll[e]=K);const ie=[...g],Q=new Map(P.current);K(e,ie,Q,S,l)}},[e,S,l]),vn(()=>{});const $=dt(g=>{const{onLayout:K}=k.current,{layout:ie,panelDataArray:Q}=j.current;if(g.constraints.collapsible){const I=Q.map(pe=>pe.constraints),{collapsedSize:D=0,panelSize:J,pivotIndices:oe}=dn(Q,g,ie);if(we(J!=null,`Panel size not found for panel "${g.id}"`),!Ht(J,D)){P.current.set(g.id,J);const Ae=$n(Q,g)===Q.length-1?J-D:D-J,ke=yr({delta:Ae,initialLayout:ie,panelConstraints:I,pivotIndices:oe,prevLayout:ie,trigger:"imperative-api"});ti(ie,ke)||(x(ke),j.current.layout=ke,K&&K(ke),Pn(Q,ke,y.current))}}},[]),W=dt((g,K)=>{const{onLayout:ie}=k.current,{layout:Q,panelDataArray:I}=j.current;if(g.constraints.collapsible){const D=I.map(be=>be.constraints),{collapsedSize:J=0,panelSize:oe=0,minSize:pe=0,pivotIndices:Ae}=dn(I,g,Q),ke=K??pe;if(Ht(oe,J)){const be=P.current.get(g.id),it=be!=null&&be>=ke?be:ke,yt=$n(I,g)===I.length-1?oe-it:it-oe,C=yr({delta:yt,initialLayout:Q,panelConstraints:D,pivotIndices:Ae,prevLayout:Q,trigger:"imperative-api"});ti(Q,C)||(x(C),j.current.layout=C,ie&&ie(C),Pn(I,C,y.current))}}},[]),E=dt(g=>{const{layout:K,panelDataArray:ie}=j.current,{panelSize:Q}=dn(ie,g,K);return we(Q!=null,`Panel size not found for panel "${g.id}"`),Q},[]),U=dt((g,K)=>{const{panelDataArray:ie}=j.current,Q=$n(ie,g);return my({defaultSize:K,dragState:m,layout:S,panelData:ie,panelIndex:Q})},[m,S]),R=dt(g=>{const{layout:K,panelDataArray:ie}=j.current,{collapsedSize:Q=0,collapsible:I,panelSize:D}=dn(ie,g,K);return we(D!=null,`Panel size not found for panel "${g.id}"`),I===!0&&Ht(D,Q)},[]),B=dt(g=>{const{layout:K,panelDataArray:ie}=j.current,{collapsedSize:Q=0,collapsible:I,panelSize:D}=dn(ie,g,K);return we(D!=null,`Panel size not found for panel "${g.id}"`),!I||Cn(D,Q)>0},[]),L=dt(g=>{const{panelDataArray:K}=j.current;K.push(g),K.sort((ie,Q)=>{const I=ie.order,D=Q.order;return I==null&&D==null?0:I==null?-1:D==null?1:I-D}),j.current.panelDataArrayChanged=!0,_()},[_]);wn(()=>{if(j.current.panelDataArrayChanged){j.current.panelDataArrayChanged=!1;const{autoSaveId:g,onLayout:K,storage:ie}=k.current,{layout:Q,panelDataArray:I}=j.current;let D=null;if(g){const oe=xy(g,I,ie);oe&&(P.current=new Map(Object.entries(oe.expandToSizes)),D=oe.layout)}D==null&&(D=hy({panelDataArray:I}));const J=ol({layout:D,panelConstraints:I.map(oe=>oe.constraints)});sl(Q,J)||(x(J),j.current.layout=J,K&&K(J),Pn(I,J,y.current))}}),wn(()=>{const g=j.current;return()=>{g.layout=[]}},[]);const T=dt(g=>{let K=!1;const ie=p.current;return ie&&window.getComputedStyle(ie,null).getPropertyValue("direction")==="rtl"&&(K=!0),function(I){I.preventDefault();const D=p.current;if(!D)return()=>null;const{direction:J,dragState:oe,id:pe,keyboardResizeBy:Ae,onLayout:ke}=k.current,{layout:be,panelDataArray:it}=j.current,{initialLayout:St}=oe??{},yt=rf(pe,g,D);let C=py(I,g,J,oe,Ae,D);const z=J==="horizontal";z&&K&&(C=-C);const F=it.map(ee=>ee.constraints),ne=yr({delta:C,initialLayout:St??be,panelConstraints:F,pivotIndices:yt,prevLayout:be,trigger:Wd(I)?"keyboard":"mouse-or-touch"}),te=!ti(be,ne);(Gd(I)||Kd(I))&&N.current!=C&&(N.current=C,!te&&C!==0?z?js(g,C<0?Xd:Qd):js(g,C<0?ef:tf):js(g,0)),te&&(x(ne),j.current.layout=ne,ke&&ke(ne),Pn(it,ne,y.current))}},[]),H=dt((g,K)=>{const{onLayout:ie}=k.current,{layout:Q,panelDataArray:I}=j.current,D=I.map(be=>be.constraints),{panelSize:J,pivotIndices:oe}=dn(I,g,Q);we(J!=null,`Panel size not found for panel "${g.id}"`);const Ae=$n(I,g)===I.length-1?J-K:K-J,ke=yr({delta:Ae,initialLayout:Q,panelConstraints:D,pivotIndices:oe,prevLayout:Q,trigger:"imperative-api"});ti(Q,ke)||(x(ke),j.current.layout=ke,ie&&ie(ke),Pn(I,ke,y.current))},[]),Y=dt((g,K)=>{const{layout:ie,panelDataArray:Q}=j.current,{collapsedSize:I=0,collapsible:D}=K,{collapsedSize:J=0,collapsible:oe,maxSize:pe=100,minSize:Ae=0}=g.constraints,{panelSize:ke}=dn(Q,g,ie);ke!=null&&(D&&oe&&Ht(ke,I)?Ht(I,J)||H(g,J):ke<Ae?H(g,Ae):ke>pe&&H(g,pe))},[H]),O=dt((g,K)=>{const{direction:ie}=k.current,{layout:Q}=j.current;if(!p.current)return;const I=rs(g,p.current);we(I,`Drag handle element not found for id "${g}"`);const D=af(ie,K);w({dragHandleId:g,dragHandleRect:I.getBoundingClientRect(),initialCursorPosition:D,initialLayout:Q})},[]),G=dt(()=>{w(null)},[]),b=dt(g=>{const{panelDataArray:K}=j.current,ie=$n(K,g);ie>=0&&(K.splice(ie,1),delete y.current[g.id],j.current.panelDataArrayChanged=!0,_())},[_]),ue=qx(()=>({collapsePanel:$,direction:r,dragState:m,expandPanel:W,getPanelSize:E,getPanelStyle:U,groupId:h,isPanelCollapsed:R,isPanelExpanded:B,reevaluatePanelConstraints:Y,registerPanel:L,registerResizeHandle:T,resizePanel:H,startDragging:O,stopDragging:G,unregisterPanel:b,panelGroupElement:p.current}),[$,m,r,W,E,U,h,R,B,Y,L,T,H,O,G,b]),ae={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return Kn(es.Provider,{value:ue},Kn(f,{...d,children:t,className:n,id:s,ref:p,style:{...ae,...u},"data-panel-group":"","data-panel-group-direction":r,"data-panel-group-id":h}))}const df=Vd((e,t)=>Kn(cf,{...e,forwardedRef:t}));cf.displayName="PanelGroup";df.displayName="forwardRef(PanelGroup)";function $n(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function dn(e,t,n){const r=$n(e,t),s=r===e.length-1?[r-1,r]:[r,r+1],a=n[r];return{...t.constraints,panelSize:a,pivotIndices:s}}function vy({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){vn(()=>{if(e||n==null||r==null)return;const i=rs(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");we(o,`No group element found for id "${o}"`);const l=Dr(o,r),u=nf(o,t,r);we(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 ff({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 h,p;const m=mt(null),w=mt({onDragging:a});vn(()=>{w.current.onDragging=a});const S=Ud(es);if(S===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:x,groupId:_,registerResizeHandle:y,startDragging:P,stopDragging:N,panelGroupElement:k}=S,j=eo(i),[$,W]=Jn("inactive"),[E,U]=Jn(!1),[R,B]=Jn(null),L=mt({state:$});wn(()=>{L.current.state=$}),vn(()=>{if(n)B(null);else{const O=y(j);B(()=>O)}},[n,j,y]);const T=(h=r==null?void 0:r.coarse)!==null&&h!==void 0?h:15,H=(p=r==null?void 0:r.fine)!==null&&p!==void 0?p:5;return vn(()=>{if(n||R==null)return;const O=m.current;return we(O,"Element ref not attached"),ay(j,O,x,{coarse:T,fine:H},(b,ue,ae)=>{if(ue)switch(b){case"down":{W("drag"),we(ae,'Expected event to be defined for "down" action'),P(j,ae);const{onDragging:g}=w.current;g&&g(!0);break}case"move":{const{state:g}=L.current;g!=="drag"&&W("hover"),we(ae,'Expected event to be defined for "move" action'),R(ae);break}case"up":{W("hover"),N();const{onDragging:g}=w.current;g&&g(!1);break}}else W("inactive")})},[T,x,n,H,y,j,R,P,N]),vy({disabled:n,handleId:j,resizeHandler:R,panelGroupElement:k}),Kn(f,{...d,children:e,className:t,id:i,onBlur:()=>{U(!1),s==null||s()},onFocus:()=>{U(!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":$==="drag"?"pointer":E?"keyboard":void 0,"data-resize-handle-state":$,"data-panel-resize-handle-enabled":!n,"data-panel-resize-handle-id":j})}ff.displayName="PanelResizeHandle";const wy=({className:e,...t})=>c.jsx(df,{className:V("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),Cs=qd,ul=({withHandle:e,className:t,...n})=>c.jsx(ff,{className:V("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(Bm,{className:"h-2.5 w-2.5"})})});function ky({children:e,className:t}){return c.jsx("kbd",{className:V("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 Sy({children:e,className:t}){return c.jsx("span",{className:V("inline-flex items-center gap-0.5",t),children:e})}const ni=typeof navigator<"u"&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);function pa({shortcut:e,className:t}){const r=e.split("+").map(i=>i.trim().toLowerCase()).map(i=>{switch(i){case"mod":return ni?"⌘":"Ctrl";case"shift":return ni?"⇧":"Shift";case"alt":return ni?"⌥":"Alt";case"ctrl":return ni?"⌃":"Ctrl";case"enter":return"↵";default:return i.toUpperCase()}});return c.jsx(Sy,{className:t,children:r.map((i,s)=>c.jsx(ky,{children:i},s))})}class _y{constructor(t){Po(this,"client");this.client=pg.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 jy=new _y;function Cy(){const e=v.useRef(null),t=v.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 ${Xr.toLowerCase()} structure...`);const f={jsonDefinition:u,options:o||{}};f.customThemes=s??{},a==null||a("rendering",`Generating ${Nt.toUpperCase()} content...`);const d={"Content-Type":"application/json"};o!=null&&o.bypassCache&&(d["X-Bypass-Cache"]="true");const h=await fetch(lm.generate,{method:"POST",headers:d,body:JSON.stringify(f),signal:l.signal}),p=await h.json();if(!h.ok||!p.success){const k=p.error||p.message||`API request failed with status: ${h.status}`;throw new Error(k)}const{data:m,cache:w,warnings:S}=p,x=w.status==="HIT"?"HIT":w.status==="MISS"?"MISS":"UNKNOWN",_=x==="HIT"?`Served from cache (Hit rate: ${w.hitRate})`:`Generated fresh ${Xr.toLowerCase()}`;a==null||a("finalizing",_);const y=globalThis.atob(m.document),P=new Uint8Array(y.length);for(let k=0;k<y.length;k++)P[k]=y.charCodeAt(k);const N=new Blob([P],{type:m.contentType});if(N.size===0)throw new Error(`Received empty ${Xr.toLowerCase()} from API`);return{name:r,text:i,blob:N,filename:m.filename,fileId:m.fileId,cacheStatus:x,cacheHitRate:w.hitRate,warnings:S}}catch(u){throw u instanceof Error&&u.name==="AbortError"?new Error(`${Xr} generation was cancelled`):u}finally{e.current===l&&(e.current=null)}},[]),n=v.useCallback(()=>{e.current&&(e.current.abort(),e.current=null)},[]);return{generatePresentation:t,cancelGeneration:n}}function Ny(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}}const cl=Nt==="docx"?["docxjs","LibreOffice"]:["LibreOffice"],Ns={docxjs:["⚡","(Recommended) works in the browser"],LibreOffice:["🖨️","(High fidelity) converts to PDF locally with LibreOffice"]};function Ey({name:e,blob:t,displayReloadButton:n,iframeRef:r,autoReload:i,onToggleAutoReload:s,onManualRender:a,isGenerating:o,isRendering:l,onShowCacheMetrics:u,onShowSchemas:f,documentText:d,warnings:h,renderingLibrary:p,setRenderingLibrary:m,onToggleChat:w,chatOpen:S,onTogglePreview:x,previewOpen:_}){const y=p!=="docxjs",[P,N]=v.useState(!1),[k,j]=v.useState(!1),[$,W]=v.useState(!1),[E,U]=v.useState(!1),[R,B]=v.useState(!1),[L,T]=v.useState(!1),{toast:H}=Ma(),{generatePresentation:Y}=Cy(),O=v.useCallback(async()=>{if(t){N(!0);try{await new Promise(g=>setTimeout(g,100)),oa(`${e}${Qr}`,t)}finally{setTimeout(()=>N(!1),500)}}},[t,e]),G=v.useCallback(async()=>{if(!(!h||h.length===0)){j(!0);try{const g=Ny(h);if(!g){H({title:"No warnings",description:"There are no warnings to download.",variant:"destructive"});return}const K=await Y("warnings",JSON.stringify(g,null,2),{});K&&typeof K=="object"&&"blob"in K&&K.blob&&(oa(`${e}-warnings${Qr}`,K.blob),H({title:"Warnings downloaded",description:`Downloaded warnings document with ${h.length} warning(s).`}))}catch(g){console.error("Failed to generate warnings document:",g),H({title:"Download failed",description:g instanceof Error?g.message:"Failed to generate warnings document",variant:"destructive"})}finally{setTimeout(()=>j(!1),500)}}},[h,e,Y,H]),b=v.useCallback(async()=>{const g=r==null?void 0:r.current;if(g!=null&&g.src){W(!0);try{await new Promise(ie=>{let Q=null,I=!1;const D=()=>{Q&&(clearTimeout(Q),Q=null),g.removeEventListener("load",oe),g.removeEventListener("error",pe)},J=()=>{I||(I=!0,D(),ie())},oe=()=>J(),pe=()=>J();g.addEventListener("load",oe),g.addEventListener("error",pe),Q=setTimeout(()=>{console.warn("Iframe reload timed out after 5 seconds"),J()},5e3);const Ae=g.src,ke=Ae.includes("?")?"&":"?",be=Date.now();g.src=`${Ae}${ke}_reload=${be}`})}catch(K){console.error("Iframe reload failed:",K)}finally{W(!1)}}},[r]),ue=v.useCallback(async()=>{U(!0);try{await jy.delete(`/${Nt}/cache`),window.dispatchEvent(new CustomEvent("cache:cleared")),H({title:"Cache Cleared",description:"All caches (document and component) have been successfully cleared.",variant:"default"})}catch(g){console.error("Failed to clear cache:",g),H({title:"Cache Clear Failed",description:"Failed to clear caches. Please try again.",variant:"destructive"})}finally{U(!1)}},[H]),ae=v.useCallback(async()=>{if(!d){H({title:"No document available",description:"Please select a document to copy standard components",variant:"destructive"});return}T(!0);try{const g=await fetch(`/api/${Nt}/standard-components`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonDefinition:d})});if(!g.ok){let Q=`Request failed with status ${g.status}`;try{const I=await g.json();I.message&&(Q=I.message)}catch{}H({title:"Failed to get standard components",description:Q,variant:"destructive"});return}const K=await g.json(),ie=JSON.stringify(K.data,null,2);await navigator.clipboard.writeText(ie),H({title:"Copied to clipboard",description:"Standard modules JSON has been copied"})}catch(g){console.error("Error copying standard components:",g),H({title:"Error",description:g instanceof Error?g.message:"Failed to copy standard components",variant:"destructive"})}finally{T(!1)}},[d,H]);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(Gc,{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 ",Nt==="docx"?"docx-preview":"LibreOffice PDF conversion",". Download the ",Qr," to verify fidelity."]})})]})]}),c.jsxs("div",{className:"flex flex-row items-center gap-x-1 shrink-0",children:[(!i||y)&&c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:c.jsxs(Ie,{variant:"default",size:"sm",className:"gap-1.5 h-7 px-2.5",onClick:a,"aria-label":"Render preview",disabled:o||l||_===!1,children:[l?c.jsx(Qt,{size:"sm"}):c.jsx(Vm,{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:_===!1?"Open preview to run":l?"Rendering preview...":"Render preview"})})]}),Nt==="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(Ha,{className:"text-xs text-muted-foreground hidden sm:inline",children:"Auto"}),c.jsx(Xa,{checked:i,onCheckedChange:s,disabled:y})]})}),c.jsx(et,{children:c.jsx("p",{children:y?"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(Ie,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:b,disabled:$||o||l,children:$?c.jsx(Qt,{size:"sm"}):c.jsx(Um,{className:"h-3.5 w-3.5"})})}),c.jsx(et,{children:c.jsx("p",{children:$?"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(Ie,{variant:"outline",size:"sm",className:"gap-1.5 h-7 px-2.5",disabled:!t||P||o,onClick:O,children:[P?c.jsx(Qt,{size:"sm"}):c.jsx(Jm,{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 ",Qr]})})]}),h&&h.length>0&&c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:c.jsx(Ie,{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:k||o,onClick:G,children:k?c.jsx(Qt,{size:"sm"}):c.jsx(Kc,{className:"h-3.5 w-3.5"})})}),c.jsx(et,{children:c.jsxs("p",{children:["Download warnings (",h.length,")"]})})]}),p&&m&&c.jsxs(Wa,{value:p,onValueChange:m,children:[c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:c.jsx(Yi,{className:"w-[140px] h-7 text-xs hidden lg:flex",children:c.jsx(Ga,{placeholder:"Renderer"})})}),c.jsx(et,{children:c.jsx("p",{children:"Select the rendering library"})})]}),c.jsx(Xi,{className:"text-sidebar-foreground",children:cl.map(g=>c.jsxs(Ar,{value:g,children:[c.jsxs(Xe,{children:[c.jsx(Qe,{tabIndex:-1,children:Ns[g][0]}),c.jsx(et,{children:Ns[g][1]})]})," ",g]},g))})]}),c.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),c.jsxs(Fd,{children:[c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:c.jsx(Ld,{asChild:!0,children:c.jsx(Ie,{variant:"ghost",size:"icon",className:"h-7 w-7",children:c.jsx(Hm,{className:"h-3.5 w-3.5"})})})}),c.jsx(et,{children:c.jsx("p",{children:"More actions"})})]}),c.jsxs(Qa,{align:"end",className:"w-52",children:[f&&c.jsxs(tn,{onClick:f,children:[c.jsx(qm,{className:"h-4 w-4 mr-2"}),"View JSON Schemas"]}),u&&c.jsxs(tn,{onClick:u,children:[c.jsx(Wm,{className:"h-4 w-4 mr-2"}),"View cache metrics"]}),c.jsxs(tn,{onClick:ae,disabled:!d||L,children:[c.jsx(Yc,{className:"h-4 w-4 mr-2"}),L?"Copying...":"Copy standard components"]}),c.jsx(Ni,{}),c.jsxs(tn,{onClick:()=>B(!0),disabled:E,className:"text-destructive focus:text-destructive",children:[c.jsx(La,{className:"h-4 w-4 mr-2"}),E?"Clearing...":"Clear all caches"]}),p&&m&&c.jsxs(c.Fragment,{children:[c.jsx(Ni,{className:"lg:hidden"}),cl.map(g=>c.jsxs(tn,{className:"lg:hidden",onClick:()=>m(g),children:[c.jsx("span",{className:"mr-2",children:p===g?"●":"○"}),Ns[g][0]," ",g]},g))]})]})]}),x&&c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:c.jsx(Ie,{variant:_?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:x,children:_?c.jsx(Xc,{className:"h-3.5 w-3.5"}):c.jsx(Gm,{className:"h-3.5 w-3.5"})})}),c.jsx(et,{children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[_?"Hide":"Show"," Preview ",c.jsx(pa,{shortcut:"mod+shift+p"})]})})]}),w&&c.jsxs(Xe,{children:[c.jsx(Qe,{asChild:!0,children:c.jsx(Ie,{variant:S?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:w,children:c.jsx(Qc,{className:"h-3.5 w-3.5"})})}),c.jsx(et,{children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[S?"Close":"Open"," AI Chat ",c.jsx(pa,{shortcut:"mod+shift+j"})]})})]})]})]}),c.jsx(qt,{open:R,onOpenChange:B,children:c.jsxs(Zt,{className:"max-w-sm",children:[c.jsxs(_n,{children:[c.jsx(jn,{children:"Clear all caches?"}),c.jsx(Gn,{children:"This will clear document and component caches. Next generation will be uncached."})]}),c.jsxs(Tr,{children:[c.jsx(Ie,{variant:"outline",size:"sm",onClick:()=>B(!1),children:"Cancel"}),c.jsx(Ie,{variant:"destructive",size:"sm",disabled:E,onClick:async()=>{await ue(),B(!1)},children:E?c.jsx(Qt,{size:"sm"}):"Clear"})]})]})})]})}const Iy=Ee.memo(Ey);function dl({previewOpen:e,onTogglePreview:t}){const n=mn(j=>j.name||""),r=mn(j=>j.blob),i=mn(j=>j.isGenerating),s=mn(j=>j.text),a=mn(j=>j.warnings),o=mn(j=>j.isRendering),l=ei(j=>j.autoReload),u=ei(j=>j.renderingLibrary),f=ei(j=>j.setSettings),d=ei(j=>j.useGlobalPreviewHeader??!0),h=Ge(j=>j.activeTab),p=Ge(j=>j.documentTypes),m=h&&p[h]==="application/json+theme"?"theme":"document",w=ze(j=>j.chatOpen),S=ze(j=>j.toggleChat),[x,_]=Ee.useState(!1);if(!d)return null;const y=v.useCallback(()=>f({saveDocumentDebounceWait:2e3,autoReload:!l}),[l,f]),P=v.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:manualRender"))},[]),N=v.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:showCacheMetrics"))},[]),k=(n==null?void 0:n.trim())||"Preview";return c.jsxs("div",{className:"sticky top-0 z-20",children:[c.jsx(Iy,{name:k,blob:r,displayReloadButton:!1,autoReload:l,onToggleAutoReload:y,onManualRender:P,isGenerating:i,isRendering:!!o,onShowCacheMetrics:N,onShowSchemas:()=>_(!0),documentText:s,warnings:a,renderingLibrary:u,setRenderingLibrary:j=>f({renderingLibrary:j}),onToggleChat:S,chatOpen:w,onTogglePreview:t,previewOpen:e}),c.jsx(Bd,{open:x,onOpenChange:_,defaultTab:m==="theme"?"theme":"document"})]})}function zy(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Ty=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ay=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Py={};function fl(e,t){return(Py.jsx?Ay:Ty).test(e)}const Oy=/[ \t\n\f\r]/g;function Dy(e){return typeof e=="object"?e.type==="text"?pl(e.value):!1:pl(e)}function pl(e){return e.replace(Oy,"")===""}class Hr{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Hr.prototype.normal={};Hr.prototype.property={};Hr.prototype.space=void 0;function pf(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Hr(n,r,t)}function ha(e){return e.toLowerCase()}class gt{constructor(t,n){this.attribute=n,this.property=t}}gt.prototype.attribute="";gt.prototype.booleanish=!1;gt.prototype.boolean=!1;gt.prototype.commaOrSpaceSeparated=!1;gt.prototype.commaSeparated=!1;gt.prototype.defined=!1;gt.prototype.mustUseProperty=!1;gt.prototype.number=!1;gt.prototype.overloadedBoolean=!1;gt.prototype.property="";gt.prototype.spaceSeparated=!1;gt.prototype.space=void 0;let Ry=0;const ye=In(),We=In(),ma=In(),X=In(),Me=In(),qn=In(),bt=In();function In(){return 2**++Ry}const ga=Object.freeze(Object.defineProperty({__proto__:null,boolean:ye,booleanish:We,commaOrSpaceSeparated:bt,commaSeparated:qn,number:X,overloadedBoolean:ma,spaceSeparated:Me},Symbol.toStringTag,{value:"Module"})),Es=Object.keys(ga);class io extends gt{constructor(t,n,r,i){let s=-1;if(super(t,n),hl(this,"space",i),typeof r=="number")for(;++s<Es.length;){const a=Es[s];hl(this,Es[s],(r&ga[a])===ga[a])}}}io.prototype.defined=!0;function hl(e,t,n){n&&(e[t]=n)}function nr(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new io(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[ha(r)]=r,n[ha(s.attribute)]=r}return new Hr(t,n,e.space)}const hf=nr({properties:{ariaActiveDescendant:null,ariaAtomic:We,ariaAutoComplete:null,ariaBusy:We,ariaChecked:We,ariaColCount:X,ariaColIndex:X,ariaColSpan:X,ariaControls:Me,ariaCurrent:null,ariaDescribedBy:Me,ariaDetails:null,ariaDisabled:We,ariaDropEffect:Me,ariaErrorMessage:null,ariaExpanded:We,ariaFlowTo:Me,ariaGrabbed:We,ariaHasPopup:null,ariaHidden:We,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Me,ariaLevel:X,ariaLive:null,ariaModal:We,ariaMultiLine:We,ariaMultiSelectable:We,ariaOrientation:null,ariaOwns:Me,ariaPlaceholder:null,ariaPosInSet:X,ariaPressed:We,ariaReadOnly:We,ariaRelevant:null,ariaRequired:We,ariaRoleDescription:Me,ariaRowCount:X,ariaRowIndex:X,ariaRowSpan:X,ariaSelected:We,ariaSetSize:X,ariaSort:null,ariaValueMax:X,ariaValueMin:X,ariaValueNow:X,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function mf(e,t){return t in e?e[t]:t}function gf(e,t){return mf(e,t.toLowerCase())}const My=nr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:qn,acceptCharset:Me,accessKey:Me,action:null,allow:null,allowFullScreen:ye,allowPaymentRequest:ye,allowUserMedia:ye,alt:null,as:null,async:ye,autoCapitalize:null,autoComplete:Me,autoFocus:ye,autoPlay:ye,blocking:Me,capture:null,charSet:null,checked:ye,cite:null,className:Me,cols:X,colSpan:null,content:null,contentEditable:We,controls:ye,controlsList:Me,coords:X|qn,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ye,defer:ye,dir:null,dirName:null,disabled:ye,download:ma,draggable:We,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ye,formTarget:null,headers:Me,height:X,hidden:ma,high:X,href:null,hrefLang:null,htmlFor:Me,httpEquiv:Me,id:null,imageSizes:null,imageSrcSet:null,inert:ye,inputMode:null,integrity:null,is:null,isMap:ye,itemId:null,itemProp:Me,itemRef:Me,itemScope:ye,itemType:Me,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ye,low:X,manifest:null,max:null,maxLength:X,media:null,method:null,min:null,minLength:X,multiple:ye,muted:ye,name:null,nonce:null,noModule:ye,noValidate:ye,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:ye,optimum:X,pattern:null,ping:Me,placeholder:null,playsInline:ye,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ye,referrerPolicy:null,rel:Me,required:ye,reversed:ye,rows:X,rowSpan:X,sandbox:Me,scope:null,scoped:ye,seamless:ye,selected:ye,shadowRootClonable:ye,shadowRootDelegatesFocus:ye,shadowRootMode:null,shape:null,size:X,sizes:null,slot:null,span:X,spellCheck:We,src:null,srcDoc:null,srcLang:null,srcSet:null,start:X,step:null,style:null,tabIndex:X,target:null,title:null,translate:null,type:null,typeMustMatch:ye,useMap:null,value:We,width:X,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Me,axis:null,background:null,bgColor:null,border:X,borderColor:null,bottomMargin:X,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ye,declare:ye,event:null,face:null,frame:null,frameBorder:null,hSpace:X,leftMargin:X,link:null,longDesc:null,lowSrc:null,marginHeight:X,marginWidth:X,noResize:ye,noHref:ye,noShade:ye,noWrap:ye,object:null,profile:null,prompt:null,rev:null,rightMargin:X,rules:null,scheme:null,scrolling:We,standby:null,summary:null,text:null,topMargin:X,valueType:null,version:null,vAlign:null,vLink:null,vSpace:X,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:ye,disableRemotePlayback:ye,prefix:null,property:null,results:X,security:null,unselectable:null},space:"html",transform:gf}),$y=nr({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:bt,accentHeight:X,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:X,amplitude:X,arabicForm:null,ascent:X,attributeName:null,attributeType:null,azimuth:X,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:X,by:null,calcMode:null,capHeight:X,className:Me,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:X,diffuseConstant:X,direction:null,display:null,dur:null,divisor:X,dominantBaseline:null,download:ye,dx:null,dy:null,edgeMode:null,editable:null,elevation:X,enableBackground:null,end:null,event:null,exponent:X,externalResourcesRequired:null,fill:null,fillOpacity:X,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:qn,g2:qn,glyphName:qn,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:X,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:X,horizOriginX:X,horizOriginY:X,id:null,ideographic:X,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:X,k:X,k1:X,k2:X,k3:X,k4:X,kernelMatrix:bt,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:X,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:X,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:X,overlineThickness:X,paintOrder:null,panose1:null,path:null,pathLength:X,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Me,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:X,pointsAtY:X,pointsAtZ:X,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:bt,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:bt,rev:bt,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:bt,requiredFeatures:bt,requiredFonts:bt,requiredFormats:bt,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:X,specularExponent:X,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:X,strikethroughThickness:X,string:null,stroke:null,strokeDashArray:bt,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:X,strokeOpacity:X,strokeWidth:null,style:null,surfaceScale:X,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:bt,tabIndex:X,tableValues:null,target:null,targetX:X,targetY:X,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:bt,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:X,underlineThickness:X,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:X,values:null,vAlphabetic:X,vMathematical:X,vectorEffect:null,vHanging:X,vIdeographic:X,version:null,vertAdvY:X,vertOriginX:X,vertOriginY:X,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:X,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:mf}),xf=nr({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),yf=nr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:gf}),bf=nr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Fy={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"},Ly=/[A-Z]/g,ml=/-[a-z]/g,Zy=/^data[-\w.:]+$/i;function By(e,t){const n=ha(t);let r=t,i=gt;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Zy.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(ml,Uy);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!ml.test(s)){let a=s.replace(Ly,Vy);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=io}return new i(r,t)}function Vy(e){return"-"+e.toLowerCase()}function Uy(e){return e.charAt(1).toUpperCase()}const Jy=pf([hf,My,xf,yf,bf],"html"),so=pf([hf,$y,xf,yf,bf],"svg");function Hy(e){return e.join(" ").trim()}var On={},Is,gl;function qy(){if(gl)return Is;gl=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="",h="comment",p="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,y=1;function P(L){var T=L.match(t);T&&(_+=T.length);var H=L.lastIndexOf(l);y=~H?L.length-H:y+L.length}function N(){var L={line:_,column:y};return function(T){return T.position=new k(L),W(),T}}function k(L){this.start=L,this.end={line:_,column:y},this.source=x.source}k.prototype.content=S;function j(L){var T=new Error(x.source+":"+_+":"+y+": "+L);if(T.reason=L,T.filename=x.source,T.line=_,T.column=y,T.source=S,!x.silent)throw T}function $(L){var T=L.exec(S);if(T){var H=T[0];return P(H),S=S.slice(H.length),T}}function W(){$(n)}function E(L){var T;for(L=L||[];T=U();)T!==!1&&L.push(T);return L}function U(){var L=N();if(!(u!=S.charAt(0)||f!=S.charAt(1))){for(var T=2;d!=S.charAt(T)&&(f!=S.charAt(T)||u!=S.charAt(T+1));)++T;if(T+=2,d===S.charAt(T-1))return j("End of comment missing");var H=S.slice(2,T-2);return y+=2,P(H),S=S.slice(T),y+=2,L({type:h,comment:H})}}function R(){var L=N(),T=$(r);if(T){if(U(),!$(i))return j("property missing ':'");var H=$(s),Y=L({type:p,property:w(T[0].replace(e,d)),value:H?w(H[0].replace(e,d)):d});return $(a),Y}}function B(){var L=[];E(L);for(var T;T=R();)T!==!1&&(L.push(T),E(L));return L}return W(),B()}function w(S){return S?S.replace(o,d):d}return Is=m,Is}var xl;function Wy(){if(xl)return On;xl=1;var e=On&&On.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(On,"__esModule",{value:!0}),On.default=n;const t=e(qy());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 On}var cr={},yl;function Gy(){if(yl)return cr;yl=1,Object.defineProperty(cr,"__esModule",{value:!0}),cr.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 cr.camelCase=l,cr}var dr,bl;function Ky(){if(bl)return dr;bl=1;var e=dr&&dr.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(Wy()),n=Gy();function r(i,s){var a={};return!i||typeof i!="string"||(0,t.default)(i,function(o,l){o&&l&&(a[(0,n.camelCase)(o,s)]=l)}),a}return r.default=r,dr=r,dr}var Yy=Ky();const Xy=Ra(Yy),vf=wf("end"),ao=wf("start");function wf(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 Qy(e){const t=ao(e),n=vf(e);if(t&&n)return{start:t,end:n}}function Er(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?vl(e.position):"start"in e||"end"in e?vl(e):"line"in e||"column"in e?xa(e):""}function xa(e){return wl(e&&e.line)+":"+wl(e&&e.column)}function vl(e){return xa(e&&e.start)+"-"+xa(e&&e.end)}function wl(e){return e&&typeof e=="number"?e:1}class rt 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=Er(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}}rt.prototype.file="";rt.prototype.name="";rt.prototype.reason="";rt.prototype.message="";rt.prototype.stack="";rt.prototype.column=void 0;rt.prototype.line=void 0;rt.prototype.ancestors=void 0;rt.prototype.cause=void 0;rt.prototype.fatal=void 0;rt.prototype.place=void 0;rt.prototype.ruleId=void 0;rt.prototype.source=void 0;const oo={}.hasOwnProperty,eb=new Map,tb=/[A-Z]/g,nb=new Set(["table","tbody","thead","tfoot","tr"]),rb=new Set(["td","th"]),kf="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function ib(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=fb(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=db(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"?so:Jy,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=Sf(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function Sf(e,t,n){if(t.type==="element")return sb(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return ab(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return lb(e,t,n);if(t.type==="mdxjsEsm")return ob(e,t);if(t.type==="root")return ub(e,t,n);if(t.type==="text")return cb(e,t)}function sb(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=so,e.schema=i),e.ancestors.push(t);const s=jf(e,t.tagName,!1),a=pb(e,t);let o=uo(e,t);return nb.has(t.tagName)&&(o=o.filter(function(l){return typeof l=="string"?!Dy(l):!0})),_f(e,a,s,t),lo(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function ab(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)}Rr(e,t.position)}function ob(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Rr(e,t.position)}function lb(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=so,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:jf(e,t.name,!0),a=hb(e,t),o=uo(e,t);return _f(e,a,s,t),lo(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function ub(e,t,n){const r={};return lo(r,uo(e,t)),e.create(t,e.Fragment,r,n)}function cb(e,t){return t.value}function _f(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function lo(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function db(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 fb(e,t){return n;function n(r,i,s,a){const o=Array.isArray(s.children),l=ao(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 pb(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&oo.call(t.properties,i)){const s=mb(e,i,t.properties[i]);if(s){const[a,o]=s;e.tableCellAlignToStyle&&a==="align"&&typeof o=="string"&&rb.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 hb(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 Rr(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 Rr(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function uo(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:eb;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=Sf(e,s,a);o!==void 0&&n.push(o)}return n}function mb(e,t,n){const r=By(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?zy(n):Hy(n)),r.property==="style"){let i=typeof n=="object"?n:gb(e,String(n));return e.stylePropertyNameCase==="css"&&(i=xb(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?Fy[r.property]||r.property:r.attribute,n]}}function gb(e,t){try{return Xy(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new rt("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=kf+"#cannot-parse-style-attribute",i}}function jf(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=fl(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=fl(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return oo.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);Rr(e)}function Rr(e,t){const n=new rt("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=kf+"#cannot-handle-mdx-estrees-without-createevaluater",n}function xb(e){const t={};let n;for(n in e)oo.call(e,n)&&(t[yb(n)]=e[n]);return t}function yb(e){let t=e.replace(tb,bb);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function bb(e){return"-"+e.toLowerCase()}const zs={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},vb={};function co(e,t){const n=vb,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Cf(e,r,i)}function Cf(e,t,n){if(wb(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 kl(e.children,t,n)}return Array.isArray(e)?kl(e,t,n):""}function kl(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=Cf(e[i],t,n);return r.join("")}function wb(e){return!!(e&&typeof e=="object")}const Sl=document.createElement("i");function fo(e){const t="&"+e+";";Sl.innerHTML=t;const n=Sl.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function wt(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 Ct(e,t){return e.length>0?(wt(e,e.length,0,t),e):t}const _l={}.hasOwnProperty;function Nf(e){const t={};let n=-1;for(;++n<e.length;)kb(t,e[n]);return t}function kb(e,t){let n;for(n in t){const i=(_l.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let a;if(s)for(a in s){_l.call(i,a)||(i[a]=[]);const o=s[a];Sb(i[a],Array.isArray(o)?o:o?[o]:[])}}}function Sb(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);wt(e,0,0,r)}function Ef(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 Dt(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ut=ln(/[A-Za-z]/),nt=ln(/[\dA-Za-z]/),_b=ln(/[#-'*+\--9=?A-Z^-~]/);function zi(e){return e!==null&&(e<32||e===127)}const ya=ln(/\d/),jb=ln(/[\dA-Fa-f]/),Cb=ln(/[!-/:-@[-`{-~]/);function he(e){return e!==null&&e<-2}function De(e){return e!==null&&(e<0||e===32)}function Se(e){return e===-2||e===-1||e===32}const is=ln(new RegExp("\\p{P}|\\p{S}","u")),Nn=ln(/\s/);function ln(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function rr(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let a="";if(s===37&&nt(e.charCodeAt(n+1))&&nt(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 Ne(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return a;function a(l){return Se(l)?(e.enter(n),o(l)):t(l)}function o(l){return Se(l)&&s++<i?(e.consume(l),o):(e.exit(n),t(l))}}const Nb={tokenize:Eb};function Eb(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"),Ne(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 he(o)?(e.consume(o),e.exit("chunkText"),s):(e.consume(o),a)}}const Ib={tokenize:zb},jl={tokenize:Tb};function zb(e){const t=this,n=[];let r=0,i,s,a;return o;function o(y){if(r<n.length){const P=n[r];return t.containerState=P[1],e.attempt(P[0].continuation,l,u)(y)}return u(y)}function l(y){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&_();const P=t.events.length;let N=P,k;for(;N--;)if(t.events[N][0]==="exit"&&t.events[N][1].type==="chunkFlow"){k=t.events[N][1].end;break}x(r);let j=P;for(;j<t.events.length;)t.events[j][1].end={...k},j++;return wt(t.events,N+1,0,t.events.slice(P)),t.events.length=j,u(y)}return o(y)}function u(y){if(r===n.length){if(!i)return h(y);if(i.currentConstruct&&i.currentConstruct.concrete)return m(y);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(jl,f,d)(y)}function f(y){return i&&_(),x(r),h(y)}function d(y){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,m(y)}function h(y){return t.containerState={},e.attempt(jl,p,m)(y)}function p(y){return r++,n.push([t.currentConstruct,t.containerState]),h(y)}function m(y){if(y===null){i&&_(),x(0),e.consume(y);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),w(y)}function w(y){if(y===null){S(e.exit("chunkFlow"),!0),x(0),e.consume(y);return}return he(y)?(e.consume(y),S(e.exit("chunkFlow")),r=0,t.interrupt=void 0,o):(e.consume(y),w)}function S(y,P){const N=t.sliceStream(y);if(P&&N.push(null),y.previous=s,s&&(s.next=y),s=y,i.defineSkip(y.start),i.write(N),t.parser.lazy[y.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 j=t.events.length;let $=j,W,E;for(;$--;)if(t.events[$][0]==="exit"&&t.events[$][1].type==="chunkFlow"){if(W){E=t.events[$][1].end;break}W=!0}for(x(r),k=j;k<t.events.length;)t.events[k][1].end={...E},k++;wt(t.events,$+1,0,t.events.slice(j)),t.events.length=k}}function x(y){let P=n.length;for(;P-- >y;){const N=n[P];t.containerState=N[1],N[0].exit.call(t,e)}n.length=y}function _(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Tb(e,t,n){return Ne(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Yn(e){if(e===null||De(e)||Nn(e))return 1;if(is(e))return 2}function ss(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 ba={name:"attention",resolveAll:Ab,tokenize:Pb};function Ab(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},h={...e[n][1].start};Cl(d,-l),Cl(h,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:h},s={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...a.start},end:{...o.end}},e[r][1].end={...a.start},e[n][1].start={...o.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=Ct(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Ct(u,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",s,t]]),u=Ct(u,ss(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Ct(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=Ct(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):f=0,wt(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 Pb(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Yn(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=Yn(l),d=!f||f===2&&i||n.includes(l),h=!i||i===2&&f||n.includes(r);return u._open=!!(s===42?d:d&&(i||!h)),u._close=!!(s===42?h:h&&(f||!d)),t(l)}}function Cl(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Ob={name:"autolink",tokenize:Db};function Db(e,t,n){let r=0;return i;function i(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(p){return ut(p)?(e.consume(p),a):p===64?n(p):u(p)}function a(p){return p===43||p===45||p===46||nt(p)?(r=1,o(p)):u(p)}function o(p){return p===58?(e.consume(p),r=0,l):(p===43||p===45||p===46||nt(p))&&r++<32?(e.consume(p),o):(r=0,u(p))}function l(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||zi(p)?n(p):(e.consume(p),l)}function u(p){return p===64?(e.consume(p),f):_b(p)?(e.consume(p),u):n(p)}function f(p){return nt(p)?d(p):n(p)}function d(p){return p===46?(e.consume(p),r=0,f):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):h(p)}function h(p){if((p===45||nt(p))&&r++<63){const m=p===45?h:d;return e.consume(p),m}return n(p)}}const qr={partial:!0,tokenize:Rb};function Rb(e,t,n){return r;function r(s){return Se(s)?Ne(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||he(s)?t(s):n(s)}}const If={continuation:{tokenize:$b},exit:Fb,name:"blockQuote",tokenize:Mb};function Mb(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 Se(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function $b(e,t,n){const r=this;return i;function i(a){return Se(a)?Ne(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):s(a)}function s(a){return e.attempt(If,t,n)(a)}}function Fb(e){e.exit("blockQuote")}const zf={name:"characterEscape",tokenize:Lb};function Lb(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 Cb(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const Tf={name:"characterReference",tokenize:Zb};function Zb(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=nt,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=jb,f):(e.enter("characterReferenceValue"),s=7,a=ya,f(d))}function f(d){if(d===59&&i){const h=e.exit("characterReferenceValue");return a===nt&&!fo(r.sliceSerialize(h))?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 Nl={partial:!0,tokenize:Vb},El={concrete:!0,name:"codeFenced",tokenize:Bb};function Bb(e,t,n){const r=this,i={partial:!0,tokenize:N};let s=0,a=0,o;return l;function l(k){return u(k)}function u(k){const j=r.events[r.events.length-1];return s=j&&j[1].type==="linePrefix"?j[2].sliceSerialize(j[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"),Se(k)?Ne(e,d,"whitespace")(k):d(k))}function d(k){return k===null||he(k)?(e.exit("codeFencedFence"),r.interrupt?t(k):e.check(Nl,w,P)(k)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),h(k))}function h(k){return k===null||he(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(k)):Se(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ne(e,p,"whitespace")(k)):k===96&&k===o?n(k):(e.consume(k),h)}function p(k){return k===null||he(k)?d(k):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(k))}function m(k){return k===null||he(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,P,S)(k)}function S(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),x}function x(k){return s>0&&Se(k)?Ne(e,_,"linePrefix",s+1)(k):_(k)}function _(k){return k===null||he(k)?e.check(Nl,w,P)(k):(e.enter("codeFlowValue"),y(k))}function y(k){return k===null||he(k)?(e.exit("codeFlowValue"),_(k)):(e.consume(k),y)}function P(k){return e.exit("codeFenced"),t(k)}function N(k,j,$){let W=0;return E;function E(T){return k.enter("lineEnding"),k.consume(T),k.exit("lineEnding"),U}function U(T){return k.enter("codeFencedFence"),Se(T)?Ne(k,R,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):R(T)}function R(T){return T===o?(k.enter("codeFencedFenceSequence"),B(T)):$(T)}function B(T){return T===o?(W++,k.consume(T),B):W>=a?(k.exit("codeFencedFenceSequence"),Se(T)?Ne(k,L,"whitespace")(T):L(T)):$(T)}function L(T){return T===null||he(T)?(k.exit("codeFencedFence"),j(T)):$(T)}}}function Vb(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 Ts={name:"codeIndented",tokenize:Jb},Ub={partial:!0,tokenize:Hb};function Jb(e,t,n){const r=this;return i;function i(u){return e.enter("codeIndented"),Ne(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):he(u)?e.attempt(Ub,a,l)(u):(e.enter("codeFlowValue"),o(u))}function o(u){return u===null||he(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),o)}function l(u){return e.exit("codeIndented"),t(u)}}function Hb(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):he(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):Ne(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):he(a)?i(a):n(a)}}const qb={name:"codeText",previous:Gb,resolve:Wb,tokenize:Kb};function Wb(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 Gb(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Kb(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)):he(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||he(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 Yb{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&&fr(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),fr(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),fr(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);fr(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);fr(this.left,n.reverse())}}}function fr(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 Af(e){const t={};let n=-1,r,i,s,a,o,l,u;const f=new Yb(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,Xb(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 wt(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!u}function Xb(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,h=-1,p=n,m=0,w=0;const S=[w];for(;p;){for(;e.get(++i)[1]!==p;);s.push(i),p._tokenizer||(f=r.sliceStream(p),p.next||f.push(null),d&&a.defineSkip(p.start),p._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(f),p._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++h<o.length;)o[h][0]==="exit"&&o[h-1][0]==="enter"&&o[h][1].type===o[h-1][1].type&&o[h][1].start.line!==o[h][1].end.line&&(w=h+1,S.push(w),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(a.events=[],p?(p._tokenizer=void 0,p.previous=void 0):S.pop(),h=S.length;h--;){const x=o.slice(S[h],S[h+1]),_=s.pop();l.push([_,_+x.length-1]),e.splice(_,2,x)}for(l.reverse(),h=-1;++h<l.length;)u[m+l[h][0]]=m+l[h][1],m+=l[h][1]-l[h][0]-1;return u}const Qb={resolve:tv,tokenize:nv},ev={partial:!0,tokenize:rv};function tv(e){return Af(e),e}function nv(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):he(o)?e.check(ev,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 rv(e,t,n){const r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Ne(e,s,"linePrefix")}function s(a){if(a===null||he(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 Pf(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),h):x===null||x===32||x===41||zi(x)?n(x):(e.enter(r),e.enter(a),e.enter(o),e.enter("chunkString",{contentType:"string"}),w(x))}function h(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"}),p(x))}function p(x){return x===62?(e.exit("chunkString"),e.exit(o),h(x)):x===null||x===60||he(x)?n(x):(e.consume(x),x===92?m:p)}function m(x){return x===60||x===62||x===92?(e.consume(x),p):p(x)}function w(x){return!f&&(x===null||x===41||De(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||zi(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 Of(e,t,n,r,i,s){const a=this;let o=0,l;return u;function u(p){return e.enter(r),e.enter(i),e.consume(p),e.exit(i),e.enter(s),f}function f(p){return o>999||p===null||p===91||p===93&&!l||p===94&&!o&&"_hiddenFootnoteSupport"in a.parser.constructs?n(p):p===93?(e.exit(s),e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):he(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),f):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===null||p===91||p===93||he(p)||o++>999?(e.exit("chunkString"),f(p)):(e.consume(p),l||(l=!Se(p)),p===92?h:d)}function h(p){return p===91||p===92||p===93?(e.consume(p),o++,d):d(p)}}function Df(e,t,n,r,i,s){let a;return o;function o(h){return h===34||h===39||h===40?(e.enter(r),e.enter(i),e.consume(h),e.exit(i),a=h===40?41:h,l):n(h)}function l(h){return h===a?(e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):(e.enter(s),u(h))}function u(h){return h===a?(e.exit(s),l(a)):h===null?n(h):he(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),Ne(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===a||h===null||he(h)?(e.exit("chunkString"),u(h)):(e.consume(h),h===92?d:f)}function d(h){return h===a||h===92?(e.consume(h),f):f(h)}}function Ir(e,t){let n;return r;function r(i){return he(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Se(i)?Ne(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const iv={name:"definition",tokenize:av},sv={partial:!0,tokenize:ov};function av(e,t,n){const r=this;let i;return s;function s(p){return e.enter("definition"),a(p)}function a(p){return Of.call(r,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function o(p){return i=Dt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),l):n(p)}function l(p){return De(p)?Ir(e,u)(p):u(p)}function u(p){return Pf(e,f,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function f(p){return e.attempt(sv,d,d)(p)}function d(p){return Se(p)?Ne(e,h,"whitespace")(p):h(p)}function h(p){return p===null||he(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function ov(e,t,n){return r;function r(o){return De(o)?Ir(e,i)(o):n(o)}function i(o){return Df(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function s(o){return Se(o)?Ne(e,a,"whitespace")(o):a(o)}function a(o){return o===null||he(o)?t(o):n(o)}}const lv={name:"hardBreakEscape",tokenize:uv};function uv(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return he(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const cv={name:"headingAtx",resolve:dv,tokenize:fv};function dv(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"},wt(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function fv(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||De(f)?(e.exit("atxHeadingSequence"),o(f)):n(f)}function o(f){return f===35?(e.enter("atxHeadingSequence"),l(f)):f===null||he(f)?(e.exit("atxHeading"),t(f)):Se(f)?Ne(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||De(f)?(e.exit("atxHeadingText"),o(f)):(e.consume(f),u)}}const pv=["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"],Il=["pre","script","style","textarea"],hv={concrete:!0,name:"htmlFlow",resolveTo:xv,tokenize:yv},mv={partial:!0,tokenize:vv},gv={partial:!0,tokenize:bv};function xv(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 yv(e,t,n){const r=this;let i,s,a,o,l;return u;function u(g){return f(g)}function f(g){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(g),d}function d(g){return g===33?(e.consume(g),h):g===47?(e.consume(g),s=!0,w):g===63?(e.consume(g),i=3,r.interrupt?t:b):ut(g)?(e.consume(g),a=String.fromCharCode(g),S):n(g)}function h(g){return g===45?(e.consume(g),i=2,p):g===91?(e.consume(g),i=5,o=0,m):ut(g)?(e.consume(g),i=4,r.interrupt?t:b):n(g)}function p(g){return g===45?(e.consume(g),r.interrupt?t:b):n(g)}function m(g){const K="CDATA[";return g===K.charCodeAt(o++)?(e.consume(g),o===K.length?r.interrupt?t:R:m):n(g)}function w(g){return ut(g)?(e.consume(g),a=String.fromCharCode(g),S):n(g)}function S(g){if(g===null||g===47||g===62||De(g)){const K=g===47,ie=a.toLowerCase();return!K&&!s&&Il.includes(ie)?(i=1,r.interrupt?t(g):R(g)):pv.includes(a.toLowerCase())?(i=6,K?(e.consume(g),x):r.interrupt?t(g):R(g)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(g):s?_(g):y(g))}return g===45||nt(g)?(e.consume(g),a+=String.fromCharCode(g),S):n(g)}function x(g){return g===62?(e.consume(g),r.interrupt?t:R):n(g)}function _(g){return Se(g)?(e.consume(g),_):E(g)}function y(g){return g===47?(e.consume(g),E):g===58||g===95||ut(g)?(e.consume(g),P):Se(g)?(e.consume(g),y):E(g)}function P(g){return g===45||g===46||g===58||g===95||nt(g)?(e.consume(g),P):N(g)}function N(g){return g===61?(e.consume(g),k):Se(g)?(e.consume(g),N):y(g)}function k(g){return g===null||g===60||g===61||g===62||g===96?n(g):g===34||g===39?(e.consume(g),l=g,j):Se(g)?(e.consume(g),k):$(g)}function j(g){return g===l?(e.consume(g),l=null,W):g===null||he(g)?n(g):(e.consume(g),j)}function $(g){return g===null||g===34||g===39||g===47||g===60||g===61||g===62||g===96||De(g)?N(g):(e.consume(g),$)}function W(g){return g===47||g===62||Se(g)?y(g):n(g)}function E(g){return g===62?(e.consume(g),U):n(g)}function U(g){return g===null||he(g)?R(g):Se(g)?(e.consume(g),U):n(g)}function R(g){return g===45&&i===2?(e.consume(g),H):g===60&&i===1?(e.consume(g),Y):g===62&&i===4?(e.consume(g),ue):g===63&&i===3?(e.consume(g),b):g===93&&i===5?(e.consume(g),G):he(g)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(mv,ae,B)(g)):g===null||he(g)?(e.exit("htmlFlowData"),B(g)):(e.consume(g),R)}function B(g){return e.check(gv,L,ae)(g)}function L(g){return e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),T}function T(g){return g===null||he(g)?B(g):(e.enter("htmlFlowData"),R(g))}function H(g){return g===45?(e.consume(g),b):R(g)}function Y(g){return g===47?(e.consume(g),a="",O):R(g)}function O(g){if(g===62){const K=a.toLowerCase();return Il.includes(K)?(e.consume(g),ue):R(g)}return ut(g)&&a.length<8?(e.consume(g),a+=String.fromCharCode(g),O):R(g)}function G(g){return g===93?(e.consume(g),b):R(g)}function b(g){return g===62?(e.consume(g),ue):g===45&&i===2?(e.consume(g),b):R(g)}function ue(g){return g===null||he(g)?(e.exit("htmlFlowData"),ae(g)):(e.consume(g),ue)}function ae(g){return e.exit("htmlFlow"),t(g)}}function bv(e,t,n){const r=this;return i;function i(a){return he(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 vv(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(qr,t,n)}}const wv={name:"htmlText",tokenize:kv};function kv(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),N):b===63?(e.consume(b),y):ut(b)?(e.consume(b),$):n(b)}function u(b){return b===45?(e.consume(b),f):b===91?(e.consume(b),s=0,m):ut(b)?(e.consume(b),_):n(b)}function f(b){return b===45?(e.consume(b),p):n(b)}function d(b){return b===null?n(b):b===45?(e.consume(b),h):he(b)?(a=d,Y(b)):(e.consume(b),d)}function h(b){return b===45?(e.consume(b),p):d(b)}function p(b){return b===62?H(b):b===45?h(b):d(b)}function m(b){const ue="CDATA[";return b===ue.charCodeAt(s++)?(e.consume(b),s===ue.length?w:m):n(b)}function w(b){return b===null?n(b):b===93?(e.consume(b),S):he(b)?(a=w,Y(b)):(e.consume(b),w)}function S(b){return b===93?(e.consume(b),x):w(b)}function x(b){return b===62?H(b):b===93?(e.consume(b),x):w(b)}function _(b){return b===null||b===62?H(b):he(b)?(a=_,Y(b)):(e.consume(b),_)}function y(b){return b===null?n(b):b===63?(e.consume(b),P):he(b)?(a=y,Y(b)):(e.consume(b),y)}function P(b){return b===62?H(b):y(b)}function N(b){return ut(b)?(e.consume(b),k):n(b)}function k(b){return b===45||nt(b)?(e.consume(b),k):j(b)}function j(b){return he(b)?(a=j,Y(b)):Se(b)?(e.consume(b),j):H(b)}function $(b){return b===45||nt(b)?(e.consume(b),$):b===47||b===62||De(b)?W(b):n(b)}function W(b){return b===47?(e.consume(b),H):b===58||b===95||ut(b)?(e.consume(b),E):he(b)?(a=W,Y(b)):Se(b)?(e.consume(b),W):H(b)}function E(b){return b===45||b===46||b===58||b===95||nt(b)?(e.consume(b),E):U(b)}function U(b){return b===61?(e.consume(b),R):he(b)?(a=U,Y(b)):Se(b)?(e.consume(b),U):W(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,B):he(b)?(a=R,Y(b)):Se(b)?(e.consume(b),R):(e.consume(b),L)}function B(b){return b===i?(e.consume(b),i=void 0,T):b===null?n(b):he(b)?(a=B,Y(b)):(e.consume(b),B)}function L(b){return b===null||b===34||b===39||b===60||b===61||b===96?n(b):b===47||b===62||De(b)?W(b):(e.consume(b),L)}function T(b){return b===47||b===62||De(b)?W(b):n(b)}function H(b){return b===62?(e.consume(b),e.exit("htmlTextData"),e.exit("htmlText"),t):n(b)}function Y(b){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),O}function O(b){return Se(b)?Ne(e,G,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(b):G(b)}function G(b){return e.enter("htmlTextData"),a(b)}}const po={name:"labelEnd",resolveAll:Cv,resolveTo:Nv,tokenize:Ev},Sv={tokenize:Iv},_v={tokenize:zv},jv={tokenize:Tv};function Cv(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&&wt(e,0,e.length,n),e}function Nv(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=Ct(o,e.slice(s+1,s+r+3)),o=Ct(o,[["enter",f,t]]),o=Ct(o,ss(t.parser.constructs.insideSpan.null,e.slice(s+r+4,a-3),t)),o=Ct(o,[["exit",f,t],e[a-2],e[a-1],["exit",u,t]]),o=Ct(o,e.slice(a+1)),o=Ct(o,[["exit",l,t]]),wt(e,s,e.length,o),e}function Ev(e,t,n){const r=this;let i=r.events.length,s,a;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return o;function o(h){return s?s._inactive?d(h):(a=r.parser.defined.includes(Dt(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(h),e.exit("labelMarker"),e.exit("labelEnd"),l):n(h)}function l(h){return h===40?e.attempt(Sv,f,a?f:d)(h):h===91?e.attempt(_v,f,a?u:d)(h):a?f(h):d(h)}function u(h){return e.attempt(jv,f,d)(h)}function f(h){return t(h)}function d(h){return s._balanced=!0,n(h)}}function Iv(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 De(d)?Ir(e,s)(d):s(d)}function s(d){return d===41?f(d):Pf(e,a,o,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function a(d){return De(d)?Ir(e,l)(d):f(d)}function o(d){return n(d)}function l(d){return d===34||d===39||d===40?Df(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):f(d)}function u(d){return De(d)?Ir(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 zv(e,t,n){const r=this;return i;function i(o){return Of.call(r,e,s,a,"reference","referenceMarker","referenceString")(o)}function s(o){return r.parser.defined.includes(Dt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(o):n(o)}function a(o){return n(o)}}function Tv(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 Av={name:"labelStartImage",resolveAll:po.resolveAll,tokenize:Pv};function Pv(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 Ov={name:"labelStartLink",resolveAll:po.resolveAll,tokenize:Dv};function Dv(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 As={name:"lineEnding",tokenize:Rv};function Rv(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ne(e,t,"linePrefix")}}const mi={name:"thematicBreak",tokenize:Mv};function Mv(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||he(u))?(e.exit("thematicBreak"),t(u)):n(u)}function l(u){return u===i?(e.consume(u),r++,l):(e.exit("thematicBreakSequence"),Se(u)?Ne(e,o,"whitespace")(u):o(u))}}const ft={continuation:{tokenize:Zv},exit:Vv,name:"list",tokenize:Lv},$v={partial:!0,tokenize:Uv},Fv={partial:!0,tokenize:Bv};function Lv(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return o;function o(p){const m=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:ya(p)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(mi,n,u)(p):u(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(p)}return n(p)}function l(p){return ya(p)&&++a<10?(e.consume(p),l):(!r.interrupt||a<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),u(p)):n(p)}function u(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(qr,r.interrupt?n:f,e.attempt($v,h,d))}function f(p){return r.containerState.initialBlankLine=!0,s++,h(p)}function d(p){return Se(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),h):n(p)}function h(p){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function Zv(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(qr,i,s);function i(o){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ne(e,t,"listItemIndent",r.containerState.size+1)(o)}function s(o){return r.containerState.furtherBlankLines||!Se(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(Fv,t,a)(o))}function a(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ne(e,e.attempt(ft,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}function Bv(e,t,n){const r=this;return Ne(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 Vv(e){e.exit(this.containerState.type)}function Uv(e,t,n){const r=this;return Ne(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!Se(s)&&a&&a[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const zl={name:"setextUnderline",resolveTo:Jv,tokenize:Hv};function Jv(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 Hv(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"),Se(u)?Ne(e,l,"lineSuffix")(u):l(u))}function l(u){return u===null||he(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const qv={tokenize:Wv};function Wv(e){const t=this,n=e.attempt(qr,r,e.attempt(this.parser.constructs.flowInitial,i,Ne(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Qb,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 Gv={resolveAll:Mf()},Kv=Rf("string"),Yv=Rf("text");function Rf(e){return{resolveAll:Mf(e==="text"?Xv: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 h=-1;if(d)for(;++h<d.length;){const p=d[h];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function Mf(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 Xv(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 Qv={42:ft,43:ft,45:ft,48:ft,49:ft,50:ft,51:ft,52:ft,53:ft,54:ft,55:ft,56:ft,57:ft,62:If},ew={91:iv},tw={[-2]:Ts,[-1]:Ts,32:Ts},nw={35:cv,42:mi,45:[zl,mi],60:hv,61:zl,95:mi,96:El,126:El},rw={38:Tf,92:zf},iw={[-5]:As,[-4]:As,[-3]:As,33:Av,38:Tf,42:ba,60:[Ob,wv],91:Ov,92:[lv,zf],93:po,95:ba,96:qb},sw={null:[ba,Gv]},aw={null:[42,95]},ow={null:[]},lw=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:aw,contentInitial:ew,disable:ow,document:Qv,flow:nw,flowInitial:tw,insideSpan:sw,string:rw,text:iw},Symbol.toStringTag,{value:"Module"}));function uw(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:j(N),check:j(k),consume:_,enter:y,exit:P,interrupt:j(k,{interrupt:!0})},u={code:null,containerState:{},defineSkip:w,events:[],now:m,parser:e,previous:null,sliceSerialize:h,sliceStream:p,write:d};let f=t.tokenize.call(u,l);return t.resolveAll&&s.push(t),u;function d(U){return a=Ct(a,U),S(),a[a.length-1]!==null?[]:($(t,0),u.events=ss(s,u.events,u),u.events)}function h(U,R){return dw(p(U),R)}function p(U){return cw(a,U)}function m(){const{_bufferIndex:U,_index:R,line:B,column:L,offset:T}=r;return{_bufferIndex:U,_index:R,line:B,column:L,offset:T}}function w(U){i[U.line]=U.column,E()}function S(){let U;for(;r._index<a.length;){const R=a[r._index];if(typeof R=="string")for(U=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===U&&r._bufferIndex<R.length;)x(R.charCodeAt(r._bufferIndex));else x(R)}}function x(U){f=f(U)}function _(U){he(U)?(r.line++,r.column=1,r.offset+=U===-3?2:1,E()):U!==-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=U}function y(U,R){const B=R||{};return B.type=U,B.start=m(),u.events.push(["enter",B,u]),o.push(B),B}function P(U){const R=o.pop();return R.end=m(),u.events.push(["exit",R,u]),R}function N(U,R){$(U,R.from)}function k(U,R){R.restore()}function j(U,R){return B;function B(L,T,H){let Y,O,G,b;return Array.isArray(L)?ae(L):"tokenize"in L?ae([L]):ue(L);function ue(Q){return I;function I(D){const J=D!==null&&Q[D],oe=D!==null&&Q.null,pe=[...Array.isArray(J)?J:J?[J]:[],...Array.isArray(oe)?oe:oe?[oe]:[]];return ae(pe)(D)}}function ae(Q){return Y=Q,O=0,Q.length===0?H:g(Q[O])}function g(Q){return I;function I(D){return b=W(),G=Q,Q.partial||(u.currentConstruct=Q),Q.name&&u.parser.constructs.disable.null.includes(Q.name)?ie():Q.tokenize.call(R?Object.assign(Object.create(u),R):u,l,K,ie)(D)}}function K(Q){return U(G,b),T}function ie(Q){return b.restore(),++O<Y.length?g(Y[O]):H}}}function $(U,R){U.resolveAll&&!s.includes(U)&&s.push(U),U.resolve&&wt(u.events,R,u.events.length-R,U.resolve(u.events.slice(R),u)),U.resolveTo&&(u.events=U.resolveTo(u.events,u))}function W(){const U=m(),R=u.previous,B=u.currentConstruct,L=u.events.length,T=Array.from(o);return{from:L,restore:H};function H(){r=U,u.previous=R,u.currentConstruct=B,u.events.length=L,o=T,E()}}function E(){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 dw(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 fw(e){const r={constructs:Nf([lw,...(e||{}).extensions||[]]),content:i(Nb),defined:[],document:i(Ib),flow:i(qv),lazy:{},string:i(Kv),text:i(Yv)};return r;function i(s){return a;function a(o){return uw(r,s,o)}}}function pw(e){for(;!Af(e););return e}const Tl=/[\0\t\n\r]/g;function hw(){let e=1,t="",n=!0,r;return i;function i(s,a,o){const l=[];let u,f,d,h,p;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(Tl.lastIndex=d,u=Tl.exec(s),h=u&&u.index!==void 0?u.index:s.length,p=s.charCodeAt(h),!u){t=s.slice(d);break}if(p===10&&d===h&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),d<h&&(l.push(s.slice(d,h)),e+=h-d),p){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=h+1}return o&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const mw=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function gw(e){return e.replace(mw,xw)}function xw(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return Ef(n.slice(s?2:1),s?16:10)}return fo(n)||e}const $f={}.hasOwnProperty;function yw(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),bw(n)(pw(fw(n).document().write(hw()(e,t,!0))))}function bw(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(z),autolinkProtocol:W,autolinkEmail:W,atxHeading:s(it),blockQuote:s(oe),characterEscape:W,characterReference:W,codeFenced:s(pe),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:s(pe,a),codeText:s(Ae,a),codeTextData:W,data:W,codeFlowValue:W,definition:s(ke),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:s(be),hardBreakEscape:s(St),hardBreakTrailing:s(St),htmlFlow:s(yt,a),htmlFlowData:W,htmlText:s(yt,a),htmlTextData:W,image:s(C),label:a,link:s(z),listItem:s(ne),listItemValue:h,listOrdered:s(F,d),listUnordered:s(F),paragraph:s(te),reference:g,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:s(it),strong:s(ee),thematicBreak:s(xe)},exit:{atxHeading:l(),atxHeadingSequence:N,autolink:l(),autolinkEmail:J,autolinkProtocol:D,blockQuote:l(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:ie,characterReferenceMarkerNumeric:ie,characterReferenceValue:Q,characterReference:I,codeFenced:l(S),codeFencedFence:w,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:l(x),codeText:l(T),codeTextData:E,data:E,definition:l(),definitionDestinationString:P,definitionLabelString:_,definitionTitleString:y,emphasis:l(),hardBreakEscape:l(R),hardBreakTrailing:l(R),htmlFlow:l(B),htmlFlowData:E,htmlText:l(L),htmlTextData:E,image:l(Y),label:G,labelText:O,lineEnding:U,link:l(H),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:K,resourceDestinationString:b,resourceTitleString:ue,resource:ae,setextHeading:l($),setextHeadingLineSequence:j,setextHeadingText:k,strong:l(),thematicBreak:l()}};Ff(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(M){let q={type:"root",children:[]};const de={stack:[q],tokenStack:[],config:t,enter:o,exit:u,buffer:a,resume:f,data:n},ve=[];let A=-1;for(;++A<M.length;)if(M[A][1].type==="listOrdered"||M[A][1].type==="listUnordered")if(M[A][0]==="enter")ve.push(A);else{const fe=ve.pop();A=i(M,fe,A)}for(A=-1;++A<M.length;){const fe=t[M[A][0]];$f.call(fe,M[A][1].type)&&fe[M[A][1].type].call(Object.assign({sliceSerialize:M[A][2].sliceSerialize},de),M[A][1])}if(de.tokenStack.length>0){const fe=de.tokenStack[de.tokenStack.length-1];(fe[1]||Al).call(de,void 0,fe[0])}for(q.position={start:Kt(M.length>0?M[0][1].start:{line:1,column:1,offset:0}),end:Kt(M.length>0?M[M.length-2][1].end:{line:1,column:1,offset:0})},A=-1;++A<t.transforms.length;)q=t.transforms[A](q)||q;return q}function i(M,q,de){let ve=q-1,A=-1,fe=!1,_e,Re,Ke,qe;for(;++ve<=de;){const tt=M[ve];switch(tt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{tt[0]==="enter"?A++:A--,qe=void 0;break}case"lineEndingBlank":{tt[0]==="enter"&&(_e&&!qe&&!A&&!Ke&&(Ke=ve),qe=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:qe=void 0}if(!A&&tt[0]==="enter"&&tt[1].type==="listItemPrefix"||A===-1&&tt[0]==="exit"&&(tt[1].type==="listUnordered"||tt[1].type==="listOrdered")){if(_e){let Gt=ve;for(Re=void 0;Gt--;){const Ut=M[Gt];if(Ut[1].type==="lineEnding"||Ut[1].type==="lineEndingBlank"){if(Ut[0]==="exit")continue;Re&&(M[Re][1].type="lineEndingBlank",fe=!0),Ut[1].type="lineEnding",Re=Gt}else if(!(Ut[1].type==="linePrefix"||Ut[1].type==="blockQuotePrefix"||Ut[1].type==="blockQuotePrefixWhitespace"||Ut[1].type==="blockQuoteMarker"||Ut[1].type==="listItemIndent"))break}Ke&&(!Re||Ke<Re)&&(_e._spread=!0),_e.end=Object.assign({},Re?M[Re][1].start:tt[1].end),M.splice(Re||ve,0,["exit",_e,tt[2]]),ve++,de++}if(tt[1].type==="listItemPrefix"){const Gt={type:"listItem",_spread:!1,start:Object.assign({},tt[1].start),end:void 0};_e=Gt,M.splice(ve,0,["enter",Gt,tt[2]]),ve++,de++,Ke=void 0,qe=!0}}}return M[q][1]._spread=fe,de}function s(M,q){return de;function de(ve){o.call(this,M(ve),ve),q&&q.call(this,ve)}}function a(){this.stack.push({type:"fragment",children:[]})}function o(M,q,de){this.stack[this.stack.length-1].children.push(M),this.stack.push(M),this.tokenStack.push([q,de||void 0]),M.position={start:Kt(q.start),end:void 0}}function l(M){return q;function q(de){M&&M.call(this,de),u.call(this,de)}}function u(M,q){const de=this.stack.pop(),ve=this.tokenStack.pop();if(ve)ve[0].type!==M.type&&(q?q.call(this,M,ve[0]):(ve[1]||Al).call(this,M,ve[0]));else throw new Error("Cannot close `"+M.type+"` ("+Er({start:M.start,end:M.end})+"): it’s not open");de.position.end=Kt(M.end)}function f(){return co(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function h(M){if(this.data.expectingFirstListItemValue){const q=this.stack[this.stack.length-2];q.start=Number.parseInt(this.sliceSerialize(M),10),this.data.expectingFirstListItemValue=void 0}}function p(){const M=this.resume(),q=this.stack[this.stack.length-1];q.lang=M}function m(){const M=this.resume(),q=this.stack[this.stack.length-1];q.meta=M}function w(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const M=this.resume(),q=this.stack[this.stack.length-1];q.value=M.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function x(){const M=this.resume(),q=this.stack[this.stack.length-1];q.value=M.replace(/(\r?\n|\r)$/g,"")}function _(M){const q=this.resume(),de=this.stack[this.stack.length-1];de.label=q,de.identifier=Dt(this.sliceSerialize(M)).toLowerCase()}function y(){const M=this.resume(),q=this.stack[this.stack.length-1];q.title=M}function P(){const M=this.resume(),q=this.stack[this.stack.length-1];q.url=M}function N(M){const q=this.stack[this.stack.length-1];if(!q.depth){const de=this.sliceSerialize(M).length;q.depth=de}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function j(M){const q=this.stack[this.stack.length-1];q.depth=this.sliceSerialize(M).codePointAt(0)===61?1:2}function $(){this.data.setextHeadingSlurpLineEnding=void 0}function W(M){const de=this.stack[this.stack.length-1].children;let ve=de[de.length-1];(!ve||ve.type!=="text")&&(ve=ce(),ve.position={start:Kt(M.start),end:void 0},de.push(ve)),this.stack.push(ve)}function E(M){const q=this.stack.pop();q.value+=this.sliceSerialize(M),q.position.end=Kt(M.end)}function U(M){const q=this.stack[this.stack.length-1];if(this.data.atHardBreak){const de=q.children[q.children.length-1];de.position.end=Kt(M.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(q.type)&&(W.call(this,M),E.call(this,M))}function R(){this.data.atHardBreak=!0}function B(){const M=this.resume(),q=this.stack[this.stack.length-1];q.value=M}function L(){const M=this.resume(),q=this.stack[this.stack.length-1];q.value=M}function T(){const M=this.resume(),q=this.stack[this.stack.length-1];q.value=M}function H(){const M=this.stack[this.stack.length-1];if(this.data.inReference){const q=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=q,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function Y(){const M=this.stack[this.stack.length-1];if(this.data.inReference){const q=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=q,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function O(M){const q=this.sliceSerialize(M),de=this.stack[this.stack.length-2];de.label=gw(q),de.identifier=Dt(q).toLowerCase()}function G(){const M=this.stack[this.stack.length-1],q=this.resume(),de=this.stack[this.stack.length-1];if(this.data.inReference=!0,de.type==="link"){const ve=M.children;de.children=ve}else de.alt=q}function b(){const M=this.resume(),q=this.stack[this.stack.length-1];q.url=M}function ue(){const M=this.resume(),q=this.stack[this.stack.length-1];q.title=M}function ae(){this.data.inReference=void 0}function g(){this.data.referenceType="collapsed"}function K(M){const q=this.resume(),de=this.stack[this.stack.length-1];de.label=q,de.identifier=Dt(this.sliceSerialize(M)).toLowerCase(),this.data.referenceType="full"}function ie(M){this.data.characterReferenceType=M.type}function Q(M){const q=this.sliceSerialize(M),de=this.data.characterReferenceType;let ve;de?(ve=Ef(q,de==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ve=fo(q);const A=this.stack[this.stack.length-1];A.value+=ve}function I(M){const q=this.stack.pop();q.position.end=Kt(M.end)}function D(M){E.call(this,M);const q=this.stack[this.stack.length-1];q.url=this.sliceSerialize(M)}function J(M){E.call(this,M);const q=this.stack[this.stack.length-1];q.url="mailto:"+this.sliceSerialize(M)}function oe(){return{type:"blockquote",children:[]}}function pe(){return{type:"code",lang:null,meta:null,value:""}}function Ae(){return{type:"inlineCode",value:""}}function ke(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function be(){return{type:"emphasis",children:[]}}function it(){return{type:"heading",depth:0,children:[]}}function St(){return{type:"break"}}function yt(){return{type:"html",value:""}}function C(){return{type:"image",title:null,url:"",alt:null}}function z(){return{type:"link",title:null,url:"",children:[]}}function F(M){return{type:"list",ordered:M.type==="listOrdered",start:null,spread:M._spread,children:[]}}function ne(M){return{type:"listItem",spread:M._spread,checked:null,children:[]}}function te(){return{type:"paragraph",children:[]}}function ee(){return{type:"strong",children:[]}}function ce(){return{type:"text",value:""}}function xe(){return{type:"thematicBreak"}}}function Kt(e){return{line:e.line,column:e.column,offset:e.offset}}function Ff(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Ff(e,r):vw(e,r)}}function vw(e,t){let n;for(n in t)if($f.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 Al(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Er({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Er({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Er({start:t.start,end:t.end})+") is still open")}function ww(e){const t=this;t.parser=n;function n(r){return yw(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function kw(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 Sw(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
6
|
+
`}]}function _w(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 jw(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Cw(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Nw(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=rr(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 Ew(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 Iw(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Lf(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 zw(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Lf(e,t);const i={src:rr(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 Tw(e,t){const n={src:rr(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 Aw(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 Pw(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Lf(e,t);const i={href:rr(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 Ow(e,t){const n={href:rr(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 Dw(e,t,n){const r=e.all(t),i=n?Rw(n):Zf(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 Rw(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=Zf(n[r])}return t}function Zf(e){const t=e.spread;return t??e.children.length>1}function Mw(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 $w(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Fw(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function Lw(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Zw(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=ao(t.children[1]),l=vf(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 Bw(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],h={},p=a?a[l]:void 0;p&&(h.align=p);let m={type:"element",tagName:s,properties:h,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 Vw(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const Pl=9,Ol=32;function Uw(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const s=[];for(;r;)s.push(Dl(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return s.push(Dl(t.slice(i),i>0,!1)),s.join("")}function Dl(e,t,n){let r=0,i=e.length;if(t){let s=e.codePointAt(r);for(;s===Pl||s===Ol;)r++,s=e.codePointAt(r)}if(n){let s=e.codePointAt(i-1);for(;s===Pl||s===Ol;)i--,s=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function Jw(e,t){const n={type:"text",value:Uw(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function Hw(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const qw={blockquote:kw,break:Sw,code:_w,delete:jw,emphasis:Cw,footnoteReference:Nw,heading:Ew,html:Iw,imageReference:zw,image:Tw,inlineCode:Aw,linkReference:Pw,link:Ow,listItem:Dw,list:Mw,paragraph:$w,root:Fw,strong:Lw,table:Zw,tableCell:Vw,tableRow:Bw,text:Jw,thematicBreak:Hw,toml:ri,yaml:ri,definition:ri,footnoteDefinition:ri};function ri(){}const Bf=-1,as=0,zr=1,Ti=2,ho=3,mo=4,go=5,xo=6,Vf=7,Uf=8,Rl=typeof self=="object"?self:globalThis,Ww=(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 as:case Bf:return n(a,i);case zr:{const o=n([],i);for(const l of a)o.push(r(l));return o}case Ti:{const o=n({},i);for(const[l,u]of a)o[r(l)]=r(u);return o}case ho:return n(new Date(a),i);case mo:{const{source:o,flags:l}=a;return n(new RegExp(o,l),i)}case go:{const o=n(new Map,i);for(const[l,u]of a)o.set(r(l),r(u));return o}case xo:{const o=n(new Set,i);for(const l of a)o.add(r(l));return o}case Vf:{const{name:o,message:l}=a;return n(new Rl[o](l),i)}case Uf: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 Rl[s](a),i)};return r},Ml=e=>Ww(new Map,e)(0),Dn="",{toString:Gw}={},{keys:Kw}=Object,pr=e=>{const t=typeof e;if(t!=="object"||!e)return[as,t];const n=Gw.call(e).slice(8,-1);switch(n){case"Array":return[zr,Dn];case"Object":return[Ti,Dn];case"Date":return[ho,Dn];case"RegExp":return[mo,Dn];case"Map":return[go,Dn];case"Set":return[xo,Dn];case"DataView":return[zr,n]}return n.includes("Array")?[zr,n]:n.includes("Error")?[Vf,n]:[Ti,n]},ii=([e,t])=>e===as&&(t==="function"||t==="symbol"),Yw=(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]=pr(a);switch(o){case as:{let f=a;switch(l){case"bigint":o=Uf,f=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+l);f=null;break;case"undefined":return i([Bf],a)}return i([o,f],a)}case zr:{if(l){let h=a;return l==="DataView"?h=new Uint8Array(a.buffer):l==="ArrayBuffer"&&(h=new Uint8Array(a)),i([l,[...h]],a)}const f=[],d=i([o,f],a);for(const h of a)f.push(s(h));return d}case Ti:{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 h of Kw(a))(e||!ii(pr(a[h])))&&f.push([s(h),s(a[h])]);return d}case ho:return i([o,a.toISOString()],a);case mo:{const{source:f,flags:d}=a;return i([o,{source:f,flags:d}],a)}case go:{const f=[],d=i([o,f],a);for(const[h,p]of a)(e||!(ii(pr(h))||ii(pr(p))))&&f.push([s(h),s(p)]);return d}case xo:{const f=[],d=i([o,f],a);for(const h of a)(e||!ii(pr(h)))&&f.push(s(h));return d}}const{message:u}=a;return i([o,{name:l,message:u}],a)};return s},$l=(e,{json:t,lossy:n}={})=>{const r=[];return Yw(!(t||n),!!t,new Map,r)(e),r},Ai=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Ml($l(e,t)):structuredClone(e):(e,t)=>Ml($l(e,t));function Xw(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 Qw(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function e0(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||Xw,r=e.options.footnoteBackLabel||Qw,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(),h=rr(d.toLowerCase());let p=0;const m=[],w=e.footnoteCounts.get(d);for(;w!==void 0&&++p<=w;){m.length>0&&m.push({type:"text",value:" "});let _=typeof n=="string"?n:n(l,p);typeof _=="string"&&(_={type:"text",value:_}),m.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+h+(p>1?"-"+p:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(l,p),className:["data-footnote-backref"]},children:Array.isArray(_)?_:[_]})}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-"+h},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:{...Ai(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 os=function(e){if(e==null)return i0;if(typeof e=="function")return ls(e);if(typeof e=="object")return Array.isArray(e)?t0(e):n0(e);if(typeof e=="string")return r0(e);throw new Error("Expected function, string, or object as test")};function t0(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=os(e[n]);return ls(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function n0(e){const t=e;return ls(n);function n(r){const i=r;let s;for(s in e)if(i[s]!==t[s])return!1;return!0}}function r0(e){return ls(t);function t(n){return n&&n.type===e}}function ls(e){return t;function t(n,r,i){return!!(s0(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function i0(){return!0}function s0(e){return e!==null&&typeof e=="object"&&"type"in e}const Jf=[],a0=!0,va=!1,o0="skip";function Hf(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const s=os(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 p=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(h,"name",{value:"node ("+(l.type+(p?"<"+p+">":""))+")"})}return h;function h(){let p=Jf,m,w,S;if((!t||s(l,u,f[f.length-1]||void 0))&&(p=l0(n(l,f)),p[0]===va))return p;if("children"in l&&l.children){const x=l;if(x.children&&p[0]!==o0)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]===va)return m;w=typeof m[1]=="number"?m[1]:w+a}}return p}}}function l0(e){return Array.isArray(e)?e:typeof e=="number"?[a0,e]:e==null?Jf:[e]}function yo(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),Hf(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 wa={}.hasOwnProperty,u0={};function c0(e,t){const n=t||u0,r=new Map,i=new Map,s=new Map,a={...qw,...n.handlers},o={all:u,applyData:f0,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:a,one:l,options:n,patch:d0,wrap:h0};return yo(e,function(f){if(f.type==="definition"||f.type==="footnoteDefinition"){const d=f.type==="definition"?r:i,h=String(f.identifier).toUpperCase();d.has(h)||d.set(h,f)}}),o;function l(f,d){const h=f.type,p=o.handlers[h];if(wa.call(o.handlers,h)&&p)return p(o,f,d);if(o.options.passThrough&&o.options.passThrough.includes(h)){if("children"in f){const{children:w,...S}=f,x=Ai(S);return x.children=o.all(f),x}return Ai(f)}return(o.options.unknownHandler||p0)(o,f,d)}function u(f){const d=[];if("children"in f){const h=f.children;let p=-1;for(;++p<h.length;){const m=o.one(h[p],f);if(m){if(p&&h[p-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=Fl(m.value)),!Array.isArray(m)&&m.type==="element")){const w=m.children[0];w&&w.type==="text"&&(w.value=Fl(w.value))}Array.isArray(m)?d.push(...m):d.push(m)}}}return d}}function d0(e,t){e.position&&(t.position=Qy(e))}function f0(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,Ai(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function p0(e,t){const n=t.data||{},r="value"in t&&!(wa.call(n,"hProperties")||wa.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 h0(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 Fl(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Ll(e,t){const n=c0(e,t),r=n.one(e,void 0),i=e0(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 m0(e,t){return e&&"run"in e?async function(n,r){const i=Ll(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Ll(n,{file:r,...e||t})}}function Zl(e){if(e)throw e}var Ps,Bl;function g0(){if(Bl)return Ps;Bl=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 h;for(h in u);return typeof h>"u"||e.call(u,h)},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 Ps=function l(){var u,f,d,h,p,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),h=o(u,f),w!==h&&(_&&h&&(s(h)||(p=i(h)))?(p?(p=!1,m=d&&i(d)?d:[]):m=d&&s(d)?d:{},a(w,{name:f,newValue:l(_,m,h)})):typeof h<"u"&&a(w,{name:f,newValue:h}));return w},Ps}var x0=g0();const Os=Ra(x0);function ka(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 y0(){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?b0(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 b0(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 Mt={basename:v0,dirname:w0,extname:k0,join:S0,sep:"/"};function v0(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Wr(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 w0(e){if(Wr(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 k0(e){Wr(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 S0(...e){let t=-1,n;for(;++t<e.length;)Wr(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":_0(n)}function _0(e){Wr(e);const t=e.codePointAt(0)===47;let n=j0(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function j0(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 Wr(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const C0={cwd:N0};function N0(){return"/"}function Sa(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function E0(e){if(typeof e=="string")e=new URL(e);else if(!Sa(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 I0(e)}function I0(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 Ds=["history","path","basename","stem","extname","dirname"];class qf{constructor(t){let n;t?Sa(t)?n={path:t}:typeof t=="string"||z0(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":C0.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Ds.length;){const s=Ds[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)Ds.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Mt.basename(this.path):void 0}set basename(t){Ms(t,"basename"),Rs(t,"basename"),this.path=Mt.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Mt.dirname(this.path):void 0}set dirname(t){Vl(this.basename,"dirname"),this.path=Mt.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Mt.extname(this.path):void 0}set extname(t){if(Rs(t,"extname"),Vl(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=Mt.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Sa(t)&&(t=E0(t)),Ms(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Mt.basename(this.path,this.extname):void 0}set stem(t){Ms(t,"stem"),Rs(t,"stem"),this.path=Mt.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 rt(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 Rs(e,t){if(e&&e.includes(Mt.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Mt.sep+"`")}function Ms(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Vl(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function z0(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const T0=function(e){const r=this.constructor.prototype,i=r[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s},A0={}.hasOwnProperty;class bo extends T0{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=y0()}copy(){const t=new bo;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Os(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Ls("data",this.frozen),this.namespace[t]=n,this):A0.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Ls("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=si(t),r=this.parser||this.Parser;return $s("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),$s("process",this.parser||this.Parser),Fs("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,a){const o=si(t),l=r.parse(o);r.run(l,o,function(f,d,h){if(f||!d||!h)return u(f);const p=d,m=r.stringify(p,h);D0(m)?h.value=m:h.result=m,u(f,h)});function u(f,d){f||!d?a(f):s?s(d):n(void 0,d)}}}processSync(t){let n=!1,r;return this.freeze(),$s("processSync",this.parser||this.Parser),Fs("processSync",this.compiler||this.Compiler),this.process(t,i),Jl("processSync","process",n),r;function i(s,a){n=!0,Zl(s),r=a}}run(t,n,r){Ul(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=si(n);i.run(t,l,u);function u(f,d,h){const p=d||t;f?o(f):a?a(p):r(void 0,p,h)}}}runSync(t,n){let r=!1,i;return this.run(t,n,s),Jl("runSync","run",r),i;function s(a,o){Zl(a),i=o,r=!0}}stringify(t,n){this.freeze();const r=si(n),i=this.compiler||this.Compiler;return Fs("stringify",i),Ul(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(Ls("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=Os(!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,h=-1;for(;++d<r.length;)if(r[d][0]===u){h=d;break}if(h===-1)r.push([u,...f]);else if(f.length>0){let[p,...m]=f;const w=r[h][1];ka(w)&&ka(p)&&(p=Os(!0,w,p)),r[h]=[u,p,...m]}}}}const P0=new bo().freeze();function $s(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Fs(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Ls(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 Ul(e){if(!ka(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Jl(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function si(e){return O0(e)?e:new qf(e)}function O0(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function D0(e){return typeof e=="string"||R0(e)}function R0(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const M0="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Hl=[],ql={allowDangerousHtml:!0},$0=/^(https?|ircs?|mailto|xmpp)$/i,F0=[{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 L0(e){const t=Z0(e),n=B0(e);return V0(t.runSync(t.parse(n),n),e)}function Z0(e){const t=e.rehypePlugins||Hl,n=e.remarkPlugins||Hl,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...ql}:ql;return P0().use(ww).use(n).use(m0,r).use(t)}function B0(e){const t=e.children||"",n=new qf;return typeof t=="string"&&(n.value=t),n}function V0(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,s=t.disallowedElements,a=t.skipHtml,o=t.unwrapDisallowed,l=t.urlTransform||U0;for(const f of F0)Object.hasOwn(t,f.from)&&(""+f.from+(f.to?"use `"+f.to+"` instead":"remove it")+M0+f.id,void 0);return yo(e,u),ib(e,{Fragment:c.Fragment,components:i,ignoreInvalidStyle:!0,jsx:c.jsx,jsxs:c.jsxs,passKeys:!0,passNode:!0});function u(f,d,h){if(f.type==="raw"&&h&&typeof d=="number")return a?h.children.splice(d,1):h.children[d]={type:"text",value:f.value},d;if(f.type==="element"){let p;for(p in zs)if(Object.hasOwn(zs,p)&&Object.hasOwn(f.properties,p)){const m=f.properties[p],w=zs[p];(w===null||w.includes(f.tagName))&&(f.properties[p]=l(String(m||""),p,f))}}if(f.type==="element"){let p=n?!n.includes(f.tagName):s?s.includes(f.tagName):!1;if(!p&&r&&typeof d=="number"&&(p=!r(f,d,h)),p&&h&&typeof d=="number")return o&&f.children?h.children.splice(d,1,...f.children):h.children.splice(d,1),d}}}function U0(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||$0.test(e.slice(0,t))?e:""}function Wl(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 J0(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function H0(e,t,n){const i=os((n||{}).ignore||[]),s=q0(t);let a=-1;for(;++a<s.length;)Hf(e,"text",o);function o(u,f){let d=-1,h;for(;++d<f.length;){const p=f[d],m=h?h.children:void 0;if(i(p,m?m.indexOf(p):void 0,h))return;h=p}if(h)return l(u,f)}function l(u,f){const d=f[f.length-1],h=s[a][0],p=s[a][1];let m=0;const S=d.children.indexOf(u);let x=!1,_=[];h.lastIndex=0;let y=h.exec(u.value);for(;y;){const P=y.index,N={index:y.index,input:y.input,stack:[...f,u]};let k=p(...y,N);if(typeof k=="string"&&(k=k.length>0?{type:"text",value:k}:void 0),k===!1?h.lastIndex=P+1:(m!==P&&_.push({type:"text",value:u.value.slice(m,P)}),Array.isArray(k)?_.push(...k):k&&_.push(k),m=P+y[0].length,x=!0),!h.global)break;y=h.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 q0(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([W0(i[0]),G0(i[1])])}return t}function W0(e){return typeof e=="string"?new RegExp(J0(e),"g"):e}function G0(e){return typeof e=="function"?e:function(){return e}}const Zs="phrasing",Bs=["autolink","link","image","label"];function K0(){return{transforms:[rk],enter:{literalAutolink:X0,literalAutolinkEmail:Vs,literalAutolinkHttp:Vs,literalAutolinkWww:Vs},exit:{literalAutolink:nk,literalAutolinkEmail:tk,literalAutolinkHttp:Q0,literalAutolinkWww:ek}}}function Y0(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Zs,notInConstruct:Bs},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Zs,notInConstruct:Bs},{character:":",before:"[ps]",after:"\\/",inConstruct:Zs,notInConstruct:Bs}]}}function X0(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Vs(e){this.config.enter.autolinkProtocol.call(this,e)}function Q0(e){this.config.exit.autolinkProtocol.call(this,e)}function ek(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 tk(e){this.config.exit.autolinkEmail.call(this,e)}function nk(e){this.exit(e)}function rk(e){H0(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,ik],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),sk]],{ignore:["link","linkReference"]})}function ik(e,t,n,r,i){let s="";if(!Wf(i)||(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!ak(n)))return!1;const a=ok(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 sk(e,t,n,r){return!Wf(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function ak(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 ok(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=Wl(e,"(");let s=Wl(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 Wf(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Nn(n)||is(n))&&(!t||n!==47)}Gf.peek=gk;function lk(){this.buffer()}function uk(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function ck(){this.buffer()}function dk(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function fk(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Dt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function pk(e){this.exit(e)}function hk(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Dt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function mk(e){this.exit(e)}function gk(){return"["}function Gf(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 xk(){return{enter:{gfmFootnoteCallString:lk,gfmFootnoteCall:uk,gfmFootnoteDefinitionLabelString:ck,gfmFootnoteDefinition:dk},exit:{gfmFootnoteCallString:fk,gfmFootnoteCall:pk,gfmFootnoteDefinitionLabelString:hk,gfmFootnoteDefinition:mk}}}function yk(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Gf},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?Kf:bk))),u(),l}}function bk(e,t,n){return t===0?e:Kf(e,t,n)}function Kf(e,t,n){return(n?"":" ")+e}const vk=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Yf.peek=jk;function wk(){return{canContainEols:["delete"],enter:{strikethrough:Sk},exit:{strikethrough:_k}}}function kk(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:vk}],handlers:{delete:Yf}}}function Sk(e){this.enter({type:"delete",children:[]},e)}function _k(e){this.exit(e)}function Yf(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 jk(){return"~"}function Ck(e){return e.length}function Nk(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||Ck,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 _=Ek(e[f][x]);if(n.alignDelimiters!==!1){const y=i(_);S[x]=y,(l[x]===void 0||y>l[x])&&(l[x]=y)}w.push(_)}a[f]=w,o[f]=S}let d=-1;if(typeof r=="object"&&"length"in r)for(;++d<u;)s[d]=Gl(r[d]);else{const w=Gl(r);for(;++d<u;)s[d]=w}d=-1;const h=[],p=[];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 y=S+"-".repeat(_)+x;n.alignDelimiters!==!1&&(_=S.length+_+x.length,_>l[d]&&(l[d]=_),p[d]=_),h[d]=y}a.splice(1,0,h),o.splice(1,0,p),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 y="",P="";if(n.alignDelimiters!==!1){const N=l[d]-(S[d]||0),k=s[d];k===114?y=" ".repeat(N):k===99?N%2?(y=" ".repeat(N/2+.5),P=" ".repeat(N/2-.5)):(y=" ".repeat(N/2),P=y):P=" ".repeat(N)}n.delimiterStart!==!1&&!d&&x.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&_==="")&&(n.delimiterStart!==!1||d)&&x.push(" "),n.alignDelimiters!==!1&&x.push(y),x.push(_),n.alignDelimiters!==!1&&x.push(P),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 Ek(e){return e==null?"":String(e)}function Gl(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 Ik(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()),zk);return i(),a}function zk(e,t,n){return">"+(n?"":" ")+e}function Tk(e,t){return Kl(e,t.inConstruct,!0)&&!Kl(e,t.notInConstruct,!1)}function Kl(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 Yl(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
18
|
+
`&&Tk(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
19
|
+
`}function Ak(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 Pk(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 Ok(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 Dk(e,t,n,r){const i=Ok(n),s=e.value||"",a=i==="`"?"GraveAccent":"Tilde";if(Pk(e,n)){const d=n.enter("codeIndented"),h=n.indentLines(s,Rk);return d(),h}const o=n.createTracker(r),l=i.repeat(Math.max(Ak(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 Rk(e,t,n){return(n?"":" ")+e}function vo(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 Mk(e,t,n,r){const i=vo(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 $k(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 Mr(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Pi(e,t,n){const r=Yn(e),i=Yn(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}}Xf.peek=Fk;function Xf(e,t,n,r){const i=$k(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=Pi(r.before.charCodeAt(r.before.length-1),u,i);f.inside&&(l=Mr(u)+l.slice(1));const d=l.charCodeAt(l.length-1),h=Pi(r.after.charCodeAt(0),d,i);h.inside&&(l=l.slice(0,-1)+Mr(d));const p=a.move(i);return s(),n.attentionEncodeSurroundingInfo={after:h.outside,before:f.outside},o+l+p}function Fk(e,t,n){return n.options.emphasis||"*"}function Lk(e,t){let n=!1;return yo(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,va}),!!((!e.depth||e.depth<3)&&co(e)&&(t.options.setext||n))}function Zk(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(Lk(e,n)){const f=n.enter("headingSetext"),d=n.enter("phrasing"),h=n.containerPhrasing(e,{...s.current(),before:`
|
|
24
|
+
`,after:`
|
|
25
|
+
`});return d(),f(),h+`
|
|
26
|
+
`+(i===1?"=":"-").repeat(h.length-(Math.max(h.lastIndexOf("\r"),h.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=Mr(u.charCodeAt(0))+u.slice(1)),u=u?a+" "+u:a,n.options.closeAtx&&(u+=" "+a),l(),o(),u}Qf.peek=Bk;function Qf(e){return e.value||""}function Bk(){return"<"}ep.peek=Vk;function ep(e,t,n,r){const i=vo(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 Vk(){return"!"}tp.peek=Uk;function tp(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 Uk(){return"!"}np.peek=Jk;function np(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 Jk(){return"`"}function rp(e,t){const n=co(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))}ip.peek=Hk;function ip(e,t,n,r){const i=vo(n),s=i==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let o,l;if(rp(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 Hk(e,t,n){return rp(e,n)?"<":"["}sp.peek=qk;function sp(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 qk(){return"["}function wo(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 Wk(e){const t=wo(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 Gk(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 ap(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 Kk(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let a=e.ordered?Gk(n):wo(n);const o=e.ordered?a==="."?")":".":Wk(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),ap(n)===a&&f){let d=-1;for(;++d<e.children.length;){const h=e.children[d];if(h&&h.type==="listItem"&&h.children&&h.children[0]&&h.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(a=o),n.bulletCurrent=a;const u=n.containerFlow(e,r);return n.bulletLastUsed=a,n.bulletCurrent=s,i(),u}function Yk(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 Xk(e,t,n,r){const i=Yk(n);let s=n.bulletCurrent||wo(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,h,p){return h?(p?"":" ".repeat(a))+d:(p?s:s+" ".repeat(a-s.length))+d}}function Qk(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),a=n.containerPhrasing(e,r);return s(),i(),a}const eS=os(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function tS(e,t,n,r){return(e.children.some(function(a){return eS(a)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function nS(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}op.peek=rS;function op(e,t,n,r){const i=nS(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=Pi(r.before.charCodeAt(r.before.length-1),u,i);f.inside&&(l=Mr(u)+l.slice(1));const d=l.charCodeAt(l.length-1),h=Pi(r.after.charCodeAt(0),d,i);h.inside&&(l=l.slice(0,-1)+Mr(d));const p=a.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:h.outside,before:f.outside},o+l+p}function rS(e,t,n){return n.options.strong||"*"}function iS(e,t,n,r){return n.safe(e.value,r)}function sS(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 aS(e,t,n){const r=(ap(n)+(n.options.ruleSpaces?" ":"")).repeat(sS(n));return n.options.ruleSpaces?r.slice(0,-1):r}const lp={blockquote:Ik,break:Yl,code:Dk,definition:Mk,emphasis:Xf,hardBreak:Yl,heading:Zk,html:Qf,image:ep,imageReference:tp,inlineCode:np,link:ip,linkReference:sp,list:Kk,listItem:Xk,paragraph:Qk,root:tS,strong:op,text:iS,thematicBreak:aS};function oS(){return{enter:{table:lS,tableData:Xl,tableHeader:Xl,tableRow:cS},exit:{codeText:dS,table:uS,tableData:Us,tableHeader:Us,tableRow:Us}}}function lS(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 uS(e){this.exit(e),this.data.inTable=void 0}function cS(e){this.enter({type:"tableRow",children:[]},e)}function Us(e){this.exit(e)}function Xl(e){this.enter({type:"tableCell",children:[]},e)}function dS(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,fS));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function fS(e,t){return t==="|"?t:e}function pS(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:h,table:a,tableCell:l,tableRow:o}};function a(p,m,w,S){return u(f(p,w,S),p.align)}function o(p,m,w,S){const x=d(p,w,S),_=u([x]);return _.slice(0,_.indexOf(`
|
|
30
|
+
`))}function l(p,m,w,S){const x=w.enter("tableCell"),_=w.enter("phrasing"),y=w.containerPhrasing(p,{...S,before:s,after:s});return _(),x(),y}function u(p,m){return Nk(p,{align:m,alignDelimiters:r,padding:n,stringLength:i})}function f(p,m,w){const S=p.children;let x=-1;const _=[],y=m.enter("table");for(;++x<S.length;)_[x]=d(S[x],m,w);return y(),_}function d(p,m,w){const S=p.children;let x=-1;const _=[],y=m.enter("tableRow");for(;++x<S.length;)_[x]=l(S[x],p,m,w);return y(),_}function h(p,m,w){let S=lp.inlineCode(p,m,w);return w.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function hS(){return{exit:{taskListCheckValueChecked:Ql,taskListCheckValueUnchecked:Ql,paragraph:gS}}}function mS(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:xS}}}function Ql(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function gS(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,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 xS(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=lp.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 yS(){return[K0(),xk(),wk(),oS(),hS()]}function bS(e){return{extensions:[Y0(),yk(e),kk(),pS(e),mS()]}}const vS={tokenize:CS,partial:!0},up={tokenize:NS,partial:!0},cp={tokenize:ES,partial:!0},dp={tokenize:IS,partial:!0},wS={tokenize:zS,partial:!0},fp={name:"wwwAutolink",tokenize:_S,previous:hp},pp={name:"protocolAutolink",tokenize:jS,previous:mp},Wt={name:"emailAutolink",tokenize:SS,previous:gp},Vt={};function kS(){return{text:Vt}}let fn=48;for(;fn<123;)Vt[fn]=Wt,fn++,fn===58?fn=65:fn===91&&(fn=97);Vt[43]=Wt;Vt[45]=Wt;Vt[46]=Wt;Vt[95]=Wt;Vt[72]=[Wt,pp];Vt[104]=[Wt,pp];Vt[87]=[Wt,fp];Vt[119]=[Wt,fp];function SS(e,t,n){const r=this;let i,s;return a;function a(d){return!_a(d)||!gp.call(r,r.previous)||ko(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),o(d))}function o(d){return _a(d)?(e.consume(d),o):d===64?(e.consume(d),l):n(d)}function l(d){return d===46?e.check(wS,f,u)(d):d===45||d===95||nt(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&&ut(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function _S(e,t,n){const r=this;return i;function i(a){return a!==87&&a!==119||!hp.call(r,r.previous)||ko(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(vS,e.attempt(up,e.attempt(cp,s),n),n)(a))}function s(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function jS(e,t,n){const r=this;let i="",s=!1;return a;function a(d){return(d===72||d===104)&&mp.call(r,r.previous)&&!ko(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),e.consume(d),o):n(d)}function o(d){if(ut(d)&&i.length<5)return i+=String.fromCodePoint(d),e.consume(d),o;if(d===58){const h=i.toLowerCase();if(h==="http"||h==="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||zi(d)||De(d)||Nn(d)||is(d)?n(d):e.attempt(up,e.attempt(cp,f),n)(d)}function f(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function CS(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 NS(e,t,n){let r,i,s;return a;function a(u){return u===46||u===95?e.check(dp,l,o)(u):u===null||De(u)||Nn(u)||u!==45&&is(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 ES(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(dp,t,s)(a):a===null||De(a)||Nn(a)?t(a):(e.consume(a),i)}function s(a){return a===41&&r++,e.consume(a),i}}function IS(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||De(o)||Nn(o)?t(o):n(o)}function i(o){return o===null||o===40||o===91||De(o)||Nn(o)?t(o):r(o)}function s(o){return ut(o)?a(o):n(o)}function a(o){return o===59?(e.consume(o),r):ut(o)?(e.consume(o),a):n(o)}}function zS(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return nt(s)?n(s):t(s)}}function hp(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||De(e)}function mp(e){return!ut(e)}function gp(e){return!(e===47||_a(e))}function _a(e){return e===43||e===45||e===46||e===95||nt(e)}function ko(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 TS={tokenize:FS,partial:!0};function AS(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:RS,continuation:{tokenize:MS},exit:$S}},text:{91:{name:"gfmFootnoteCall",tokenize:DS},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:PS,resolveTo:OS}}}}function PS(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=Dt(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 OS(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 DS(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||De(d))return n(d);if(d===93){e.exit("chunkString");const h=e.exit("gfmFootnoteCallString");return i.includes(Dt(r.sliceSerialize(h)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return De(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 RS(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||De(m))return n(m);if(m===93){e.exit("chunkString");const w=e.exit("gfmFootnoteDefinitionLabelString");return s=Dt(r.sliceSerialize(w)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),h}return De(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 h(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),i.includes(s)||i.push(s),Ne(e,p,"gfmFootnoteDefinitionWhitespace")):n(m)}function p(m){return t(m)}}function MS(e,t,n){return e.check(qr,t,e.attempt(TS,t,n))}function $S(e){e.exit("gfmFootnoteDefinition")}function FS(e,t,n){const r=this;return Ne(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 LS(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)},h=[["enter",f,o],["enter",a[u][1],o],["exit",a[u][1],o],["enter",d,o]],p=o.parser.constructs.insideSpan.null;p&&wt(h,h.length,0,ss(p,a.slice(u+1,l),o)),wt(h,h.length,0,[["exit",d,o],["enter",a[l][1],o],["exit",a[l][1],o],["exit",f,o]]),wt(a,u-1,l-u+3,h),l=u+h.length-2;break}}for(l=-1;++l<a.length;)a[l][1].type==="strikethroughSequenceTemporary"&&(a[l][1].type="data");return a}function s(a,o,l){const u=this.previous,f=this.events;let d=0;return h;function h(m){return u===126&&f[f.length-1][1].type!=="characterEscape"?l(m):(a.enter("strikethroughSequenceTemporary"),p(m))}function p(m){const w=Yn(u);if(m===126)return d>1?l(m):(a.consume(m),d++,p);if(d<2&&!n)return l(m);const S=a.exit("strikethroughSequenceTemporary"),x=Yn(m);return S._open=!x||x===2&&!!w,S._close=!w||w===2&&!!x,o(m)}}}class ZS{constructor(){this.map=[]}add(t,n,r){BS(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 BS(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 VS(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 US(){return{flow:{null:{name:"table",tokenize:JS,resolveAll:HS}}}}function JS(e,t,n){const r=this;let i=0,s=0,a;return o;function o(E){let U=r.events.length-1;for(;U>-1;){const L=r.events[U][1].type;if(L==="lineEnding"||L==="linePrefix")U--;else break}const R=U>-1?r.events[U][1].type:null,B=R==="tableHead"||R==="tableRow"?k:l;return B===k&&r.parser.lazy[r.now().line]?n(E):B(E)}function l(E){return e.enter("tableHead"),e.enter("tableRow"),u(E)}function u(E){return E===124||(a=!0,s+=1),f(E)}function f(E){return E===null?n(E):he(E)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),p):n(E):Se(E)?Ne(e,f,"whitespace")(E):(s+=1,a&&(a=!1,i+=1),E===124?(e.enter("tableCellDivider"),e.consume(E),e.exit("tableCellDivider"),a=!0,f):(e.enter("data"),d(E)))}function d(E){return E===null||E===124||De(E)?(e.exit("data"),f(E)):(e.consume(E),E===92?h:d)}function h(E){return E===92||E===124?(e.consume(E),d):d(E)}function p(E){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(E):(e.enter("tableDelimiterRow"),a=!1,Se(E)?Ne(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):m(E))}function m(E){return E===45||E===58?S(E):E===124?(a=!0,e.enter("tableCellDivider"),e.consume(E),e.exit("tableCellDivider"),w):N(E)}function w(E){return Se(E)?Ne(e,S,"whitespace")(E):S(E)}function S(E){return E===58?(s+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(E),e.exit("tableDelimiterMarker"),x):E===45?(s+=1,x(E)):E===null||he(E)?P(E):N(E)}function x(E){return E===45?(e.enter("tableDelimiterFiller"),_(E)):N(E)}function _(E){return E===45?(e.consume(E),_):E===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(E),e.exit("tableDelimiterMarker"),y):(e.exit("tableDelimiterFiller"),y(E))}function y(E){return Se(E)?Ne(e,P,"whitespace")(E):P(E)}function P(E){return E===124?m(E):E===null||he(E)?!a||i!==s?N(E):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(E)):N(E)}function N(E){return n(E)}function k(E){return e.enter("tableRow"),j(E)}function j(E){return E===124?(e.enter("tableCellDivider"),e.consume(E),e.exit("tableCellDivider"),j):E===null||he(E)?(e.exit("tableRow"),t(E)):Se(E)?Ne(e,j,"whitespace")(E):(e.enter("data"),$(E))}function $(E){return E===null||E===124||De(E)?(e.exit("data"),j(E)):(e.consume(E),E===92?W:$)}function W(E){return E===92||E===124?(e.consume(E),$):$(E)}}function HS(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 h=new ZS;for(;++n<e.length;){const p=e[n],m=p[1];p[0]==="enter"?m.type==="tableHead"?(o=!1,l!==0&&(eu(h,t,l,u,f),f=void 0,l=0),u={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},h.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)},h.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=ai(h,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=ai(h,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=ai(h,t,s,i,n,d)):a[1]!==0&&(d=ai(h,t,a,i,n,d)),i=0):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(a[3]=n)}for(l!==0&&eu(h,t,l,u,f),h.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=VS(t.events,n))}return e}function ai(e,t,n,r,i,s){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",o="tableContent";n[0]!==0&&(s.end=Object.assign({},Fn(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=Fn(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=Fn(t.events,n[2]),f=Fn(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 h=t.events[n[2]],p=t.events[n[3]];if(h[1].end=Object.assign({},p[1].end),h[1].type="chunkText",h[1].contentType="text",n[3]>n[2]+1){const 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({},Fn(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function eu(e,t,n,r,i){const s=[],a=Fn(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 Fn(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const qS={name:"tasklistCheck",tokenize:GS};function WS(){return{text:{91:qS}}}function GS(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 De(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 he(l)?t(l):Se(l)?e.check({tokenize:KS},t,n)(l):n(l)}}function KS(e,t,n){return Ne(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function YS(e){return Nf([kS(),AS(),LS(e),US(),WS()])}const XS={};function QS(e){const t=this,n=e||XS,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(YS(n)),s.push(yS()),a.push(bS(n))}var xp="vercel.ai.error",e_=Symbol.for(xp),tu,nu,Bt=class yp extends(nu=Error,tu=e_,nu){constructor({name:t,message:n,cause:r}){super(n),this[tu]=!0,this.name=t,this.cause=r}static isInstance(t){return yp.hasMarker(t,xp)}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 bp(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var vp="AI_InvalidArgumentError",wp=`vercel.ai.error.${vp}`,t_=Symbol.for(wp),ru,iu,n_=class extends(iu=Bt,ru=t_,iu){constructor({message:e,cause:t,argument:n}){super({name:vp,message:e,cause:t}),this[ru]=!0,this.argument=n}static isInstance(e){return Bt.hasMarker(e,wp)}},kp="AI_JSONParseError",Sp=`vercel.ai.error.${kp}`,r_=Symbol.for(Sp),su,au,ou=class extends(au=Bt,su=r_,au){constructor({text:e,cause:t}){super({name:kp,message:`JSON parsing failed: Text: ${e}.
|
|
31
|
+
Error message: ${bp(t)}`,cause:t}),this[su]=!0,this.text=e}static isInstance(e){return Bt.hasMarker(e,Sp)}},_p="AI_TypeValidationError",jp=`vercel.ai.error.${_p}`,i_=Symbol.for(jp),lu,uu,Xn=class ja extends(uu=Bt,lu=i_,uu){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:_p,message:`${i}: Value: ${JSON.stringify(t)}.
|
|
32
|
+
Error message: ${bp(n)}`,cause:n}),this[lu]=!0,this.value=t,this.context=r}static isInstance(t){return Bt.hasMarker(t,jp)}static wrap({value:t,cause:n,context:r}){var i,s,a;return ja.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 ja({value:t,cause:n,context:r})}};function Z(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 h=f[d];h in o||(o[h]=u[h].bind(o))}}const i=(n==null?void 0:n.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:e});function a(o){var l;const 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 Wn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Cp extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Np={};function an(e){return Np}function Ep(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 Ca(e,t){return typeof t=="bigint"?t.toString():t}function us(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function So(e){return e==null}function _o(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function s_(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 cu=Symbol("evaluating");function Ce(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==cu)return r===void 0&&(r=cu,r=n()),r},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function zn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function un(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function du(e){return JSON.stringify(e)}function a_(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Ip="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function $r(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const o_=us(()=>{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 Qn(e){if($r(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!($r(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function zp(e){return Qn(e)?{...e}:Array.isArray(e)?[...e]:e}const l_=new Set(["string","number","symbol"]);function er(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function cn(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 le(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 u_(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const c_={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 d_(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=un(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 zn(this,"shape",a),a},checks:[]});return cn(e,s)}function f_(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=un(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 zn(this,"shape",a),a},checks:[]});return cn(e,s)}function p_(e,t){if(!Qn(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=un(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return zn(this,"shape",s),s}});return cn(e,i)}function h_(e,t){if(!Qn(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=un(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return zn(this,"shape",r),r}});return cn(e,n)}function m_(e,t){const n=un(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return zn(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return cn(e,n)}function g_(e,t,n){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const a=un(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 zn(this,"shape",l),l},checks:[]});return cn(t,a)}function x_(e,t,n){const r=un(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 zn(this,"shape",s),s}});return cn(t,r)}function Vn(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 Un(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function oi(e){return typeof e=="string"?e:e==null?void 0:e.message}function on(e,t,n){var i,s,a,o,l,u;const r={...e,path:e.path??[]};if(!e.message){const f=oi((a=(s=(i=e.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:a.call(s,e))??oi((o=t==null?void 0:t.error)==null?void 0:o.call(t,e))??oi((l=n.customError)==null?void 0:l.call(n,e))??oi((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 jo(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Fr(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const Tp=(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,Ca,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ap=Z("$ZodError",Tp),Pp=Z("$ZodError",Tp,{Parent:Error});function y_(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 b_(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 Co=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 Wn;if(a.issues.length){const o=new((i==null?void 0:i.Err)??e)(a.issues.map(l=>on(l,s,an())));throw Ip(o,i==null?void 0:i.callee),o}return a.value},No=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=>on(l,s,an())));throw Ip(o,i==null?void 0:i.callee),o}return a.value},cs=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 Wn;return s.issues.length?{success:!1,error:new(e??Ap)(s.issues.map(a=>on(a,i,an())))}:{success:!0,data:s.value}},v_=cs(Pp),ds=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=>on(a,i,an())))}:{success:!0,data:s.value}},w_=ds(Pp),k_=e=>(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Co(e)(t,n,i)},S_=e=>(t,n,r)=>Co(e)(t,n,r),__=e=>async(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return No(e)(t,n,i)},j_=e=>async(t,n,r)=>No(e)(t,n,r),C_=e=>(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return cs(e)(t,n,i)},N_=e=>(t,n,r)=>cs(e)(t,n,r),E_=e=>async(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ds(e)(t,n,i)},I_=e=>async(t,n,r)=>ds(e)(t,n,r),z_=/^[cC][^\s-]{8,}$/,T_=/^[0-9a-z]+$/,A_=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,P_=/^[0-9a-vA-V]{20}$/,O_=/^[A-Za-z0-9]{27}$/,D_=/^[a-zA-Z0-9_-]{21}$/,R_=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,M_=/^([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})$/,fu=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)$/,$_=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,F_="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function L_(){return new RegExp(F_,"u")}const Z_=/^(?:(?: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])$/,B_=/^(([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}|:))$/,V_=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,U_=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,J_=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Op=/^[A-Za-z0-9_-]*$/,H_=/^\+[1-9]\d{6,14}$/,Dp="(?:(?:\\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])))",q_=new RegExp(`^${Dp}$`);function Rp(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 W_(e){return new RegExp(`^${Rp(e)}$`)}function G_(e){const t=Rp({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(`^${Dp}T(?:${r})$`)}const K_=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}$`)},Y_=/^-?\d+$/,Mp=/^-?\d+(?:\.\d+)?$/,X_=/^(?:true|false)$/i,Q_=/^null$/i,e1=/^[^A-Z]*$/,t1=/^[^a-z]*$/,xt=Z("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),$p={number:"number",bigint:"bigint",object:"date"},Fp=Z("$ZodCheckLessThan",(e,t)=>{xt.init(e,t);const n=$p[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})}}),Lp=Z("$ZodCheckGreaterThan",(e,t)=>{xt.init(e,t);const n=$p[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})}}),n1=Z("$ZodCheckMultipleOf",(e,t)=>{xt.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):s_(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})}}),r1=Z("$ZodCheckNumberFormat",(e,t)=>{var a;xt.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]=c_[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=Y_)}),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})}}),i1=Z("$ZodCheckMaxLength",(e,t)=>{var n;xt.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!So(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=jo(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),s1=Z("$ZodCheckMinLength",(e,t)=>{var n;xt.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!So(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=jo(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),a1=Z("$ZodCheckLengthEquals",(e,t)=>{var n;xt.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!So(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=jo(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})}}),fs=Z("$ZodCheckStringFormat",(e,t)=>{var n,r;xt.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=()=>{})}),o1=Z("$ZodCheckRegex",(e,t)=>{fs.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})}}),l1=Z("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=e1),fs.init(e,t)}),u1=Z("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=t1),fs.init(e,t)}),c1=Z("$ZodCheckIncludes",(e,t)=>{xt.init(e,t);const n=er(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})}}),d1=Z("$ZodCheckStartsWith",(e,t)=>{xt.init(e,t);const n=new RegExp(`^${er(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})}}),f1=Z("$ZodCheckEndsWith",(e,t)=>{xt.init(e,t);const n=new RegExp(`.*${er(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})}}),p1=Z("$ZodCheckOverwrite",(e,t)=>{xt.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class h1{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 m1={major:4,minor:3,patch:6},Ze=Z("$ZodType",(e,t)=>{var i;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=m1;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=Vn(o),d;for(const h of l){if(h._zod.def.when){if(!h._zod.def.when(o))continue}else if(f)continue;const p=o.issues.length,m=h._zod.check(o);if(m instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Wn;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await m,o.issues.length!==p&&(f||(f=Vn(o,p)))});else{if(o.issues.length===p)continue;f||(f=Vn(o,p))}}return d?d.then(()=>o):o},a=(o,l,u)=>{if(Vn(o))return o.aborted=!0,o;const f=s(l,r,u);if(f instanceof Promise){if(u.async===!1)throw new Wn;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 Wn;return u.then(f=>s(f,r,l))}return s(u,r,l)}}Ce(e,"~standard",()=>({validate:s=>{var a;try{const o=v_(e,s);return o.success?{value:o.data}:{issues:(a=o.error)==null?void 0:a.issues}}catch{return w_(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}))}),Eo=Z("$ZodString",(e,t)=>{var n;Ze.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??K_(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}}),Ve=Z("$ZodStringFormat",(e,t)=>{fs.init(e,t),Eo.init(e,t)}),g1=Z("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=M_),Ve.init(e,t)}),x1=Z("$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=fu(r))}else t.pattern??(t.pattern=fu());Ve.init(e,t)}),y1=Z("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=$_),Ve.init(e,t)}),b1=Z("$ZodURL",(e,t)=>{Ve.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})}}}),v1=Z("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=L_()),Ve.init(e,t)}),w1=Z("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=D_),Ve.init(e,t)}),k1=Z("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=z_),Ve.init(e,t)}),S1=Z("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=T_),Ve.init(e,t)}),_1=Z("$ZodULID",(e,t)=>{t.pattern??(t.pattern=A_),Ve.init(e,t)}),j1=Z("$ZodXID",(e,t)=>{t.pattern??(t.pattern=P_),Ve.init(e,t)}),C1=Z("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=O_),Ve.init(e,t)}),N1=Z("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=G_(t)),Ve.init(e,t)}),E1=Z("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=q_),Ve.init(e,t)}),I1=Z("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=W_(t)),Ve.init(e,t)}),z1=Z("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=R_),Ve.init(e,t)}),T1=Z("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Z_),Ve.init(e,t),e._zod.bag.format="ipv4"}),A1=Z("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=B_),Ve.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})}}}),P1=Z("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=V_),Ve.init(e,t)}),O1=Z("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=U_),Ve.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 Zp(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const D1=Z("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=J_),Ve.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Zp(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function R1(e){if(!Op.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Zp(n)}const M1=Z("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Op),Ve.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{R1(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),$1=Z("$ZodE164",(e,t)=>{t.pattern??(t.pattern=H_),Ve.init(e,t)});function F1(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 L1=Z("$ZodJWT",(e,t)=>{Ve.init(e,t),e._zod.check=n=>{F1(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Bp=Z("$ZodNumber",(e,t)=>{Ze.init(e,t),e._zod.pattern=e._zod.bag.pattern??Mp,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}}),Z1=Z("$ZodNumberFormat",(e,t)=>{r1.init(e,t),Bp.init(e,t)}),B1=Z("$ZodBoolean",(e,t)=>{Ze.init(e,t),e._zod.pattern=X_,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const i=n.value;return typeof i=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),V1=Z("$ZodNull",(e,t)=>{Ze.init(e,t),e._zod.pattern=Q_,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}}),U1=Z("$ZodUnknown",(e,t)=>{Ze.init(e,t),e._zod.parse=n=>n}),J1=Z("$ZodNever",(e,t)=>{Ze.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function pu(e,t,n){e.issues.length&&t.issues.push(...Un(n,e.issues)),t.value[n]=e.value}const H1=Z("$ZodArray",(e,t)=>{Ze.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=>pu(u,n,a))):pu(l,n,a)}return s.length?Promise.all(s).then(()=>n):n}});function Oi(e,t,n,r,i){if(e.issues.length){if(i&&!(n in r))return;t.issues.push(...Un(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Vp(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=u_(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Up(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 h=l.run({value:t[d],issues:[]},r);h instanceof Promise?e.push(h.then(p=>Oi(p,n,d,t,f))):Oi(h,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 q1=Z("$ZodObject",(e,t)=>{Ze.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=us(()=>Vp(t));Ce(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=$r,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 h of a.keys){const p=d[h],m=p._zod.optout==="optional",w=p._zod.run({value:u[h],issues:[]},l);w instanceof Promise?f.push(w.then(S=>Oi(S,o,h,u,m))):Oi(w,o,h,u,m)}return s?Up(f,u,o,l,r.value,e):f.length?Promise.all(f).then(()=>o):o}}),W1=Z("$ZodObjectJIT",(e,t)=>{q1.init(e,t);const n=e._zod.parse,r=us(()=>Vp(t)),i=h=>{var y;const p=new h1(["shape","payload","ctx"]),m=r.value,w=P=>{const N=du(P);return`shape[${N}]._zod.run({ value: input[${N}], issues: [] }, ctx)`};p.write("const input = payload.value;");const S=Object.create(null);let x=0;for(const P of m.keys)S[P]=`key_${x++}`;p.write("const newResult = {};");for(const P of m.keys){const N=S[P],k=du(P),j=h[P],$=((y=j==null?void 0:j._zod)==null?void 0:y.optout)==="optional";p.write(`const ${N} = ${w(P)};`),$?p.write(`
|
|
35
|
+
if (${N}.issues.length) {
|
|
36
|
+
if (${k} in input) {
|
|
37
|
+
payload.issues = payload.issues.concat(${N}.issues.map(iss => ({
|
|
38
|
+
...iss,
|
|
39
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
40
|
+
})));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (${N}.value === undefined) {
|
|
45
|
+
if (${k} in input) {
|
|
46
|
+
newResult[${k}] = undefined;
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
newResult[${k}] = ${N}.value;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
`):p.write(`
|
|
53
|
+
if (${N}.issues.length) {
|
|
54
|
+
payload.issues = payload.issues.concat(${N}.issues.map(iss => ({
|
|
55
|
+
...iss,
|
|
56
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
57
|
+
})));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (${N}.value === undefined) {
|
|
61
|
+
if (${k} in input) {
|
|
62
|
+
newResult[${k}] = undefined;
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
newResult[${k}] = ${N}.value;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
`)}p.write("payload.value = newResult;"),p.write("return payload;");const _=p.compile();return(P,N)=>_(h,P,N)};let s;const a=$r,o=!Np.jitless,u=o&&o_.value,f=t.catchall;let d;e._zod.parse=(h,p)=>{d??(d=r.value);const m=h.value;return a(m)?o&&u&&(p==null?void 0:p.async)===!1&&p.jitless!==!0?(s||(s=i(t.shape)),h=s(h,p),f?Up([],m,h,p,d,e):h):n(h,p):(h.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),h)}});function hu(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=>!Vn(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=>on(a,r,an())))}),t)}const Jp=Z("$ZodUnion",(e,t)=>{Ze.init(e,t),Ce(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),Ce(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),Ce(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),Ce(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=>_o(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=>hu(l,i,e,s)):hu(o,i,e,s)}}),G1=Z("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Jp.init(e,t);const n=e._zod.parse;Ce(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=us(()=>{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(!$r(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)}}),K1=Z("$ZodIntersection",(e,t)=>{Ze.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])=>mu(n,l,u)):mu(n,s,a)}});function Na(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(Qn(e)&&Qn(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=Na(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=Na(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 mu(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}),Vn(e))return e;const a=Na(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 Y1=Z("$ZodRecord",(e,t)=>{Ze.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!Qn(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(...Un(u,d.issues)),n.value[u]=d.value})):(f.issues.length&&n.issues.push(...Un(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"&&Mp.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=>on(d,r,an())),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(...Un(o,d.issues)),n.value[l.value]=d.value})):(f.issues.length&&n.issues.push(...Un(o,f.issues)),n.value[l.value]=f.value)}}return s.length?Promise.all(s).then(()=>n):n}}),X1=Z("$ZodEnum",(e,t)=>{Ze.init(e,t);const n=Ep(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(i=>l_.has(typeof i)).map(i=>typeof i=="string"?er(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}}),Q1=Z("$ZodLiteral",(e,t)=>{if(Ze.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"?er(r):r?er(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}}),ej=Z("$ZodTransform",(e,t)=>{Ze.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Cp(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 Wn;return n.value=i,n}});function gu(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Hp=Z("$ZodOptional",(e,t)=>{Ze.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Ce(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ce(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${_o(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=>gu(s,n.value)):gu(i,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),tj=Z("$ZodExactOptional",(e,t)=>{Hp.init(e,t),Ce(e._zod,"values",()=>t.innerType._zod.values),Ce(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),nj=Z("$ZodNullable",(e,t)=>{Ze.init(e,t),Ce(e._zod,"optin",()=>t.innerType._zod.optin),Ce(e._zod,"optout",()=>t.innerType._zod.optout),Ce(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${_o(n.source)}|null)$`):void 0}),Ce(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)}),rj=Z("$ZodDefault",(e,t)=>{Ze.init(e,t),e._zod.optin="optional",Ce(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=>xu(s,t)):xu(i,t)}});function xu(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const ij=Z("$ZodPrefault",(e,t)=>{Ze.init(e,t),e._zod.optin="optional",Ce(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))}),sj=Z("$ZodNonOptional",(e,t)=>{Ze.init(e,t),Ce(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=>yu(s,e)):yu(i,e)}});function yu(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 aj=Z("$ZodCatch",(e,t)=>{Ze.init(e,t),Ce(e._zod,"optin",()=>t.innerType._zod.optin),Ce(e._zod,"optout",()=>t.innerType._zod.optout),Ce(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=>on(a,r,an()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(s=>on(s,r,an()))},input:n.value}),n.issues=[]),n)}}),oj=Z("$ZodPipe",(e,t)=>{Ze.init(e,t),Ce(e._zod,"values",()=>t.in._zod.values),Ce(e._zod,"optin",()=>t.in._zod.optin),Ce(e._zod,"optout",()=>t.out._zod.optout),Ce(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=>li(a,t.in,r)):li(s,t.in,r)}const i=t.in._zod.run(n,r);return i instanceof Promise?i.then(s=>li(s,t.out,r)):li(i,t.out,r)}});function li(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const lj=Z("$ZodReadonly",(e,t)=>{Ze.init(e,t),Ce(e._zod,"propValues",()=>t.innerType._zod.propValues),Ce(e._zod,"values",()=>t.innerType._zod.values),Ce(e._zod,"optin",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),Ce(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(bu):bu(i)}});function bu(e){return e.value=Object.freeze(e.value),e}const uj=Z("$ZodLazy",(e,t)=>{Ze.init(e,t),Ce(e._zod,"innerType",()=>t.getter()),Ce(e._zod,"pattern",()=>{var n,r;return(r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.pattern}),Ce(e._zod,"propValues",()=>{var n,r;return(r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.propValues}),Ce(e._zod,"optin",()=>{var n,r;return((r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.optin)??void 0}),Ce(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=Z("$ZodCustom",(e,t)=>{xt.init(e,t),Ze.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=>vu(s,n,r,e));vu(i,n,r,e)}});function vu(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(Fr(i))}}var wu;class dj{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 fj(){return new dj}(wu=globalThis).__zod_globalRegistry??(wu.__zod_globalRegistry=fj());const vr=globalThis.__zod_globalRegistry;function pj(e,t){return new e({type:"string",...le(t)})}function hj(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...le(t)})}function ku(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...le(t)})}function mj(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...le(t)})}function gj(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...le(t)})}function xj(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...le(t)})}function yj(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...le(t)})}function bj(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...le(t)})}function vj(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...le(t)})}function wj(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...le(t)})}function kj(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...le(t)})}function Sj(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...le(t)})}function _j(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...le(t)})}function jj(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...le(t)})}function Cj(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...le(t)})}function Nj(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...le(t)})}function Ej(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...le(t)})}function Ij(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...le(t)})}function zj(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...le(t)})}function Tj(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...le(t)})}function Aj(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...le(t)})}function Pj(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...le(t)})}function Oj(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...le(t)})}function Dj(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...le(t)})}function Rj(e,t){return new e({type:"string",format:"date",check:"string_format",...le(t)})}function Mj(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...le(t)})}function $j(e,t){return new e({type:"string",format:"duration",check:"string_format",...le(t)})}function Fj(e,t){return new e({type:"number",checks:[],...le(t)})}function Lj(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...le(t)})}function Zj(e,t){return new e({type:"boolean",...le(t)})}function Bj(e,t){return new e({type:"null",...le(t)})}function Vj(e){return new e({type:"unknown"})}function Uj(e,t){return new e({type:"never",...le(t)})}function Su(e,t){return new Fp({check:"less_than",...le(t),value:e,inclusive:!1})}function Js(e,t){return new Fp({check:"less_than",...le(t),value:e,inclusive:!0})}function _u(e,t){return new Lp({check:"greater_than",...le(t),value:e,inclusive:!1})}function Hs(e,t){return new Lp({check:"greater_than",...le(t),value:e,inclusive:!0})}function ju(e,t){return new n1({check:"multiple_of",...le(t),value:e})}function qp(e,t){return new i1({check:"max_length",...le(t),maximum:e})}function Di(e,t){return new s1({check:"min_length",...le(t),minimum:e})}function Wp(e,t){return new a1({check:"length_equals",...le(t),length:e})}function Jj(e,t){return new o1({check:"string_format",format:"regex",...le(t),pattern:e})}function Hj(e){return new l1({check:"string_format",format:"lowercase",...le(e)})}function qj(e){return new u1({check:"string_format",format:"uppercase",...le(e)})}function Wj(e,t){return new c1({check:"string_format",format:"includes",...le(t),includes:e})}function Gj(e,t){return new d1({check:"string_format",format:"starts_with",...le(t),prefix:e})}function Kj(e,t){return new f1({check:"string_format",format:"ends_with",...le(t),suffix:e})}function ir(e){return new p1({check:"overwrite",tx:e})}function Yj(e){return ir(t=>t.normalize(e))}function Xj(){return ir(e=>e.trim())}function Qj(){return ir(e=>e.toLowerCase())}function eC(){return ir(e=>e.toUpperCase())}function tC(){return ir(e=>a_(e))}function nC(e,t,n){return new e({type:"array",element:t,...le(n)})}function rC(e,t,n){const r=le(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function iC(e,t,n){return new e({type:"custom",check:"custom",fn:t,...le(n)})}function sC(e){const t=aC(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(Fr(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(Fr(i))}},e(n.value,n)));return t}function aC(e,t){const n=new xt({check:"custom",...le(t)});return n._zod.check=e,n}function Ri(e){let t=(e==null?void 0:e.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:(e==null?void 0:e.metadata)??vr,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",external:(e==null?void 0:e.external)??void 0}}function $e(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 h={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,h);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,h)}const p=e._zod.parent;p&&(a.ref||(a.ref=p),$e(p,t,h),t.seen.get(p).isParent=!0)}const l=t.metadataRegistry.get(e);return l&&Object.assign(a.schema,l),t.io==="input"&&at(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 Mi(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 h=r.get(d);if(h&&h!==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??(y=>y);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 p=`#/${d}/`,m=f[1].schema.id??`__schema${e.counter++}`;return{defId:m,ref:p+m}},s=f=>{if(f[1].schema.$ref)return;const d=f[1],{ref:h,defId:p}=i(f);d.def={...d.schema},p&&(d.defId=p);const m=d.schema;for(const w in m)delete m[w];m.$ref=h};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 p=(l=e.external.registry.get(f[0]))==null?void 0:l.id;if(t!==f[0]&&p){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 $i(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,h={...d},p=f.ref;if(f.ref=null,p){r(p);const w=e.seen.get(p),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,h),u._zod.parent===p)for(const _ in d)_==="$ref"||_==="allOf"||_ in h||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!==p){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:Fi(t,"input",e.processors),output:Fi(t,"output",e.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function at(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 at(r.element,n);if(r.type==="set")return at(r.valueType,n);if(r.type==="lazy")return at(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 at(r.innerType,n);if(r.type==="intersection")return at(r.left,n)||at(r.right,n);if(r.type==="record"||r.type==="map")return at(r.keyType,n)||at(r.valueType,n);if(r.type==="pipe")return at(r.in,n)||at(r.out,n);if(r.type==="object"){for(const i in r.shape)if(at(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(at(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(at(i,n))return!0;return!!(r.rest&&at(r.rest,n))}return!1}const oC=(e,t={})=>n=>{const r=Ri({...n,processors:t});return $e(e,r),Mi(r,e),$i(r,e)},Fi=(e,t,n={})=>r=>{const{libraryOptions:i,target:s}=r??{},a=Ri({...i??{},target:s,io:t,processors:n});return $e(e,a),Mi(a,e),$i(a,e)},lC={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Gp=(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=lC[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}))])}},Kp=(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)},Yp=(e,t,n,r)=>{n.type="boolean"},uC=(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")},Xp=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},dC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},fC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},Qp=(e,t,n,r)=>{n.not={}},pC=(e,t,n,r)=>{},eh=(e,t,n,r)=>{},hC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},th=(e,t,n,r)=>{const i=e._zod.def,s=Ep(i.entries);s.every(a=>typeof a=="number")&&(n.type="number"),s.every(a=>typeof a=="string")&&(n.type="string"),n.enum=s},nh=(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},mC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},gC=(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},xC=(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)},yC=(e,t,n,r)=>{n.type="boolean"},rh=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},bC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},ih=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},vC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},wC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},sh=(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=$e(s.element,t,{...r,path:[...r.path,"items"]})},ah=(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]=$e(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=$e(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},oh=(e,t,n,r)=>{const i=e._zod.def,s=i.inclusive===!1,a=i.options.map((o,l)=>$e(o,t,{...r,path:[...r.path,s?"oneOf":"anyOf",l]}));s?n.oneOf=a:n.anyOf=a},lh=(e,t,n,r)=>{const i=e._zod.def,s=$e(i.left,t,{...r,path:[...r.path,"allOf",0]}),a=$e(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},kC=(e,t,n,r)=>{const i=n,s=e._zod.def;i.type="array";const a=t.target==="draft-2020-12"?"prefixItems":"items",o=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",l=s.items.map((h,p)=>$e(h,t,{...r,path:[...r.path,a,p]})),u=s.rest?$e(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)},uh=(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=$e(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=$e(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=$e(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)}},ch=(e,t,n,r)=>{const i=e._zod.def,s=$e(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"}]},dh=(e,t,n,r)=>{const i=e._zod.def;$e(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},fh=(e,t,n,r)=>{const i=e._zod.def;$e(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},ph=(e,t,n,r)=>{const i=e._zod.def;$e(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)))},hh=(e,t,n,r)=>{const i=e._zod.def;$e(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},mh=(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;$e(s,t,r);const a=t.seen.get(e);a.ref=s},gh=(e,t,n,r)=>{const i=e._zod.def;$e(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,n.readOnly=!0},SC=(e,t,n,r)=>{const i=e._zod.def;$e(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},Io=(e,t,n,r)=>{const i=e._zod.def;$e(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},xh=(e,t,n,r)=>{const i=e._zod.innerType;$e(i,t,r);const s=t.seen.get(e);s.ref=i},Cu={string:Gp,number:Kp,boolean:Yp,bigint:uC,symbol:cC,null:Xp,undefined:dC,void:fC,never:Qp,any:pC,unknown:eh,date:hC,enum:th,literal:nh,nan:mC,template_literal:gC,file:xC,success:yC,custom:rh,function:bC,transform:ih,map:vC,set:wC,array:sh,object:ah,union:oh,intersection:lh,tuple:kC,record:uh,nullable:ch,nonoptional:dh,default:fh,prefault:ph,catch:hh,pipe:mh,readonly:gh,promise:SC,optional:Io,lazy:xh};function _C(e,t){if("_idmap"in e){const r=e,i=Ri({...t,processors:Cu}),s={};for(const l of r._idmap.entries()){const[u,f]=l;$e(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;Mi(i,f),a[u]=$i(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=Ri({...t,processors:Cu});return $e(e,n),Mi(n,e),$i(n,e)}const jC=Z("ZodISODateTime",(e,t)=>{N1.init(e,t),Ue.init(e,t)});function CC(e){return Dj(jC,e)}const NC=Z("ZodISODate",(e,t)=>{E1.init(e,t),Ue.init(e,t)});function EC(e){return Rj(NC,e)}const IC=Z("ZodISOTime",(e,t)=>{I1.init(e,t),Ue.init(e,t)});function zC(e){return Mj(IC,e)}const TC=Z("ZodISODuration",(e,t)=>{z1.init(e,t),Ue.init(e,t)});function AC(e){return $j(TC,e)}const PC=(e,t)=>{Ap.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>b_(e,n)},flatten:{value:n=>y_(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Ca,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Ca,2)}},isEmpty:{get(){return e.issues.length===0}}})},Et=Z("ZodError",PC,{Parent:Error}),OC=Co(Et),DC=No(Et),RC=cs(Et),yh=ds(Et),MC=k_(Et),$C=S_(Et),FC=__(Et),LC=j_(Et),ZC=C_(Et),BC=N_(Et),VC=E_(Et),UC=I_(Et),Be=Z("ZodType",(e,t)=>(Ze.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Fi(e,"input"),output:Fi(e,"output")}}),e.toJSONSchema=oC(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(un(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)=>cn(e,n,r),e.brand=()=>e,e.register=(n,r)=>(n.add(e,r),e),e.parse=(n,r)=>OC(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>RC(e,n,r),e.parseAsync=async(n,r)=>DC(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>yh(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>MC(e,n,r),e.decode=(n,r)=>$C(e,n,r),e.encodeAsync=async(n,r)=>FC(e,n,r),e.decodeAsync=async(n,r)=>LC(e,n,r),e.safeEncode=(n,r)=>ZC(e,n,r),e.safeDecode=(n,r)=>BC(e,n,r),e.safeEncodeAsync=async(n,r)=>VC(e,n,r),e.safeDecodeAsync=async(n,r)=>UC(e,n,r),e.refine=(n,r)=>e.check(LN(n,r)),e.superRefine=n=>e.check(ZN(n)),e.overwrite=n=>e.check(ir(n)),e.optional=()=>Iu(e),e.exactOptional=()=>CN(e),e.nullable=()=>zu(e),e.nullish=()=>Iu(zu(e)),e.nonoptional=n=>AN(e,n),e.array=()=>sr(e),e.or=n=>ct([e,n]),e.and=n=>vN(e,n),e.transform=n=>Tu(e,_N(n)),e.default=n=>IN(e,n),e.prefault=n=>TN(e,n),e.catch=n=>ON(e,n),e.pipe=n=>Tu(e,n),e.readonly=()=>MN(e),e.describe=n=>{const r=e.clone();return vr.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){var n;return(n=vr.get(e))==null?void 0:n.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return vr.get(e);const r=e.clone();return vr.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),bh=Z("_ZodString",(e,t)=>{Eo.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,i,s)=>Gp(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(Jj(...r)),e.includes=(...r)=>e.check(Wj(...r)),e.startsWith=(...r)=>e.check(Gj(...r)),e.endsWith=(...r)=>e.check(Kj(...r)),e.min=(...r)=>e.check(Di(...r)),e.max=(...r)=>e.check(qp(...r)),e.length=(...r)=>e.check(Wp(...r)),e.nonempty=(...r)=>e.check(Di(1,...r)),e.lowercase=r=>e.check(Hj(r)),e.uppercase=r=>e.check(qj(r)),e.trim=()=>e.check(Xj()),e.normalize=(...r)=>e.check(Yj(...r)),e.toLowerCase=()=>e.check(Qj()),e.toUpperCase=()=>e.check(eC()),e.slugify=()=>e.check(tC())}),JC=Z("ZodString",(e,t)=>{Eo.init(e,t),bh.init(e,t),e.email=n=>e.check(hj(HC,n)),e.url=n=>e.check(bj(qC,n)),e.jwt=n=>e.check(Oj(lN,n)),e.emoji=n=>e.check(vj(WC,n)),e.guid=n=>e.check(ku(Nu,n)),e.uuid=n=>e.check(mj(ui,n)),e.uuidv4=n=>e.check(gj(ui,n)),e.uuidv6=n=>e.check(xj(ui,n)),e.uuidv7=n=>e.check(yj(ui,n)),e.nanoid=n=>e.check(wj(GC,n)),e.guid=n=>e.check(ku(Nu,n)),e.cuid=n=>e.check(kj(KC,n)),e.cuid2=n=>e.check(Sj(YC,n)),e.ulid=n=>e.check(_j(XC,n)),e.base64=n=>e.check(Tj(sN,n)),e.base64url=n=>e.check(Aj(aN,n)),e.xid=n=>e.check(jj(QC,n)),e.ksuid=n=>e.check(Cj(eN,n)),e.ipv4=n=>e.check(Nj(tN,n)),e.ipv6=n=>e.check(Ej(nN,n)),e.cidrv4=n=>e.check(Ij(rN,n)),e.cidrv6=n=>e.check(zj(iN,n)),e.e164=n=>e.check(Pj(oN,n)),e.datetime=n=>e.check(CC(n)),e.date=n=>e.check(EC(n)),e.time=n=>e.check(zC(n)),e.duration=n=>e.check(AC(n))});function re(e){return pj(JC,e)}const Ue=Z("ZodStringFormat",(e,t)=>{Ve.init(e,t),bh.init(e,t)}),HC=Z("ZodEmail",(e,t)=>{y1.init(e,t),Ue.init(e,t)}),Nu=Z("ZodGUID",(e,t)=>{g1.init(e,t),Ue.init(e,t)}),ui=Z("ZodUUID",(e,t)=>{x1.init(e,t),Ue.init(e,t)}),qC=Z("ZodURL",(e,t)=>{b1.init(e,t),Ue.init(e,t)}),WC=Z("ZodEmoji",(e,t)=>{v1.init(e,t),Ue.init(e,t)}),GC=Z("ZodNanoID",(e,t)=>{w1.init(e,t),Ue.init(e,t)}),KC=Z("ZodCUID",(e,t)=>{k1.init(e,t),Ue.init(e,t)}),YC=Z("ZodCUID2",(e,t)=>{S1.init(e,t),Ue.init(e,t)}),XC=Z("ZodULID",(e,t)=>{_1.init(e,t),Ue.init(e,t)}),QC=Z("ZodXID",(e,t)=>{j1.init(e,t),Ue.init(e,t)}),eN=Z("ZodKSUID",(e,t)=>{C1.init(e,t),Ue.init(e,t)}),tN=Z("ZodIPv4",(e,t)=>{T1.init(e,t),Ue.init(e,t)}),nN=Z("ZodIPv6",(e,t)=>{A1.init(e,t),Ue.init(e,t)}),rN=Z("ZodCIDRv4",(e,t)=>{P1.init(e,t),Ue.init(e,t)}),iN=Z("ZodCIDRv6",(e,t)=>{O1.init(e,t),Ue.init(e,t)}),sN=Z("ZodBase64",(e,t)=>{D1.init(e,t),Ue.init(e,t)}),aN=Z("ZodBase64URL",(e,t)=>{M1.init(e,t),Ue.init(e,t)}),oN=Z("ZodE164",(e,t)=>{$1.init(e,t),Ue.init(e,t)}),lN=Z("ZodJWT",(e,t)=>{L1.init(e,t),Ue.init(e,t)}),vh=Z("ZodNumber",(e,t)=>{Bp.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,i,s)=>Kp(e,r,i),e.gt=(r,i)=>e.check(_u(r,i)),e.gte=(r,i)=>e.check(Hs(r,i)),e.min=(r,i)=>e.check(Hs(r,i)),e.lt=(r,i)=>e.check(Su(r,i)),e.lte=(r,i)=>e.check(Js(r,i)),e.max=(r,i)=>e.check(Js(r,i)),e.int=r=>e.check(Eu(r)),e.safe=r=>e.check(Eu(r)),e.positive=r=>e.check(_u(0,r)),e.nonnegative=r=>e.check(Hs(0,r)),e.negative=r=>e.check(Su(0,r)),e.nonpositive=r=>e.check(Js(0,r)),e.multipleOf=(r,i)=>e.check(ju(r,i)),e.step=(r,i)=>e.check(ju(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 uN(e){return Fj(vh,e)}const cN=Z("ZodNumberFormat",(e,t)=>{Z1.init(e,t),vh.init(e,t)});function Eu(e){return Lj(cN,e)}const dN=Z("ZodBoolean",(e,t)=>{B1.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Yp(e,n,r)});function ot(e){return Zj(dN,e)}const fN=Z("ZodNull",(e,t)=>{V1.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Xp(e,n,r)});function pN(e){return Bj(fN,e)}const hN=Z("ZodUnknown",(e,t)=>{U1.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(n,r,i)=>eh()});function $t(){return Vj(hN)}const mN=Z("ZodNever",(e,t)=>{J1.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Qp(e,n,r)});function wh(e){return Uj(mN,e)}const gN=Z("ZodArray",(e,t)=>{H1.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(n,r,i)=>sh(e,n,r,i),e.element=t.element,e.min=(n,r)=>e.check(Di(n,r)),e.nonempty=n=>e.check(Di(1,n)),e.max=(n,r)=>e.check(qp(n,r)),e.length=(n,r)=>e.check(Wp(n,r)),e.unwrap=()=>e.element});function sr(e,t){return nC(gN,e,t)}const kh=Z("ZodObject",(e,t)=>{W1.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ah(e,n,r,i),Ce(e,"shape",()=>t.shape),e.keyof=()=>_h(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:$t()}),e.loose=()=>e.clone({...e._zod.def,catchall:$t()}),e.strict=()=>e.clone({...e._zod.def,catchall:wh()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>p_(e,n),e.safeExtend=n=>h_(e,n),e.merge=n=>m_(e,n),e.pick=n=>d_(e,n),e.omit=n=>f_(e,n),e.partial=(...n)=>g_(jh,e,n[0]),e.required=(...n)=>x_(Ch,e,n[0])});function Oe(e,t){const n={type:"object",shape:e??{},...le(t)};return new kh(n)}function Fe(e,t){return new kh({type:"object",shape:e,catchall:wh(),...le(t)})}const Sh=Z("ZodUnion",(e,t)=>{Jp.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(n,r,i)=>oh(e,n,r,i),e.options=t.options});function ct(e,t){return new Sh({type:"union",options:e,...le(t)})}const xN=Z("ZodDiscriminatedUnion",(e,t)=>{Sh.init(e,t),G1.init(e,t)});function yN(e,t,n){return new xN({type:"union",options:t,discriminator:e,...le(n)})}const bN=Z("ZodIntersection",(e,t)=>{K1.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(n,r,i)=>lh(e,n,r,i)});function vN(e,t){return new bN({type:"intersection",left:e,right:t})}const wN=Z("ZodRecord",(e,t)=>{Y1.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(n,r,i)=>uh(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function Lr(e,t,n){return new wN({type:"record",keyType:e,valueType:t,...le(n)})}const Ea=Z("ZodEnum",(e,t)=>{X1.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,i,s)=>th(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 Ea({...t,checks:[],...le(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 Ea({...t,checks:[],...le(i),entries:s})}});function _h(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Ea({type:"enum",entries:n,...le(t)})}const kN=Z("ZodLiteral",(e,t)=>{Q1.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(n,r,i)=>nh(e,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function me(e,t){return new kN({type:"literal",values:Array.isArray(e)?e:[e],...le(t)})}const SN=Z("ZodTransform",(e,t)=>{ej.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ih(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Cp(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(Fr(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(Fr(a))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(s=>(n.value=s,n)):(n.value=i,n)}});function _N(e){return new SN({type:"transform",transform:e})}const jh=Z("ZodOptional",(e,t)=>{Hp.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Io(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Iu(e){return new jh({type:"optional",innerType:e})}const jN=Z("ZodExactOptional",(e,t)=>{tj.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Io(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function CN(e){return new jN({type:"optional",innerType:e})}const NN=Z("ZodNullable",(e,t)=>{nj.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ch(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function zu(e){return new NN({type:"nullable",innerType:e})}const EN=Z("ZodDefault",(e,t)=>{rj.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(n,r,i)=>fh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function IN(e,t){return new EN({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():zp(t)}})}const zN=Z("ZodPrefault",(e,t)=>{ij.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ph(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function TN(e,t){return new zN({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():zp(t)}})}const Ch=Z("ZodNonOptional",(e,t)=>{sj.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(n,r,i)=>dh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function AN(e,t){return new Ch({type:"nonoptional",innerType:e,...le(t)})}const PN=Z("ZodCatch",(e,t)=>{aj.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(n,r,i)=>hh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ON(e,t){return new PN({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const DN=Z("ZodPipe",(e,t)=>{oj.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(n,r,i)=>mh(e,n,r,i),e.in=t.in,e.out=t.out});function Tu(e,t){return new DN({type:"pipe",in:e,out:t})}const RN=Z("ZodReadonly",(e,t)=>{lj.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(n,r,i)=>gh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function MN(e){return new RN({type:"readonly",innerType:e})}const $N=Z("ZodLazy",(e,t)=>{uj.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(n,r,i)=>xh(e,n,r,i),e.unwrap=()=>e._zod.def.getter()});function FN(e){return new $N({type:"lazy",getter:e})}const zo=Z("ZodCustom",(e,t)=>{cj.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(n,r,i)=>rh(e,n)});function Nh(e,t){return rC(zo,e??(()=>!0),t)}function LN(e,t={}){return iC(zo,e,t)}function ZN(e){return sC(e)}function Li(e,t={}){const n=new zo({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...le(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 Zr;(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})(Zr||(Zr={}));var Au;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(Au||(Au={}));Zr.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);Zr.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 Zi 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 Zi))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Zr.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()}}Zi.create=e=>new Zi(e);var Pu;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Pu||(Pu={}));var ge;(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"})(ge||(ge={}));class Ou 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 qs(e){}function BN(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=qs,onError:n=qs,onRetry:r=qs,onComment:i}=e;let s="",a=!0,o,l="",u="";function f(w){const S=a?w.replace(/^\xEF\xBB\xBF/,""):w,[x,_]=VN(`${s}${S}`);for(const y of x)d(y);s=_,a=!1}function d(w){if(w===""){p();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,y=w.slice(S+_);h(x,y,w);return}h(w,"",w)}function h(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 Ou(`Invalid \`retry\` value: "${S}"`,{type:"invalid-retry",value:S,line:x}));break;default:n(new Ou(`Unknown field "${w.length>20?`${w.slice(0,20)}…`:w}"`,{type:"unknown-field",field:w,value:S,line:x}));break}}function p(){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 VN(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 UN extends TransformStream{constructor({onError:t,onRetry:n,onComment:r}={}){let i;super({start(s){i=BN({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 Gr=({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 n_({argument:"separator",message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`},JN=Gr();function Du(e=globalThis){var t,n,r;return e.window?"runtime/browser":(t=e.navigator)!=null&&t.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:(r=(n=e.process)==null?void 0:n.versions)!=null&&r.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function gn(e){if(e==null)return{};const t={};if(e instanceof Headers)e.forEach((n,r)=>{t[r.toLowerCase()]=n});else{Array.isArray(e)||(e=Object.entries(e));for(const[n,r]of e)r!=null&&(t[n.toLowerCase()]=r)}return t}function Ru(e,...t){const n=new Headers(gn(e)),r=n.get("user-agent")||"";return n.set("user-agent",[r,...t].filter(Boolean).join(" ")),Object.fromEntries(n.entries())}var HN=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,qN=/"(?: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 Mu(e){const t=JSON.parse(e);return t===null||typeof t!="object"||HN.test(e)===!1&&qN.test(e)===!1?t:WN(t)}function WN(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 GN(e){const{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return Mu(e)}try{return Mu(e)}finally{Error.stackTraceLimit=t}}function To(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]=pn(n[r])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(pn):pn(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(pn)),e.allOf!=null&&(e.allOf=e.allOf.map(pn)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(pn));const{definitions:t}=e;if(t!=null)for(const n of Object.keys(t))t[n]=pn(t[n]);return e}function pn(e){return typeof e=="boolean"?e:To(e)}var KN=Symbol("Let zodToJsonSchema decide on which parser to use"),$u={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"},YN=e=>typeof e=="string"?{...$u,name:e}:{...$u,...e};function kt(){return{}}function XN(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)!==ge.ZodAny&&(s.items=Te(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 QN(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 eE(){return{type:"boolean"}}function Eh(e,t){return Te(e.type._def,t)}var tE=(e,t)=>Te(e.innerType._def,t);function Ih(e,t,n){const r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((i,s)=>Ih(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 nE(e)}}var nE=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 rE(e,t){return{...Te(e.innerType._def,t),default:e.defaultValue()}}function iE(e,t){return t.effectStrategy==="input"?Te(e.schema._def,t):kt()}function sE(e){return{type:"string",enum:Array.from(e.values)}}var aE=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function oE(e,t){const n=[Te(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),Te(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(i=>!!i),r=[];return n.forEach(i=>{if(aE(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 lE(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 Ws=void 0,It={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:()=>(Ws===void 0&&(Ws=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Ws),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 zh(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":zt(n,"email",r.message,t);break;case"format:idn-email":zt(n,"idn-email",r.message,t);break;case"pattern:zod":st(n,It.email,r.message,t);break}break;case"url":zt(n,"uri",r.message,t);break;case"uuid":zt(n,"uuid",r.message,t);break;case"regex":st(n,r.regex,r.message,t);break;case"cuid":st(n,It.cuid,r.message,t);break;case"cuid2":st(n,It.cuid2,r.message,t);break;case"startsWith":st(n,RegExp(`^${Gs(r.value,t)}`),r.message,t);break;case"endsWith":st(n,RegExp(`${Gs(r.value,t)}$`),r.message,t);break;case"datetime":zt(n,"date-time",r.message,t);break;case"date":zt(n,"date",r.message,t);break;case"time":zt(n,"time",r.message,t);break;case"duration":zt(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":{st(n,RegExp(Gs(r.value,t)),r.message,t);break}case"ip":{r.version!=="v6"&&zt(n,"ipv4",r.message,t),r.version!=="v4"&&zt(n,"ipv6",r.message,t);break}case"base64url":st(n,It.base64url,r.message,t);break;case"jwt":st(n,It.jwt,r.message,t);break;case"cidr":{r.version!=="v6"&&st(n,It.ipv4Cidr,r.message,t),r.version!=="v4"&&st(n,It.ipv6Cidr,r.message,t);break}case"emoji":st(n,It.emoji(),r.message,t);break;case"ulid":{st(n,It.ulid,r.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{zt(n,"binary",r.message,t);break}case"contentEncoding:base64":{n.contentEncoding="base64";break}case"pattern:zod":{st(n,It.base64,r.message,t);break}}break}case"nanoid":st(n,It.nanoid,r.message,t)}return n}function Gs(e,t){return t.patternStrategy==="escape"?cE(e):e}var uE=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function cE(e){let t="";for(let n=0;n<e.length;n++)uE.has(e[n])||(t+="\\"),t+=e[n];return t}function zt(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 st(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:Fu(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=Fu(t,r)}function Fu(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 Th(e,t){var n,r,i,s,a,o;const l={type:"object",additionalProperties:(n=Te(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?n:t.allowedAdditionalProperties};if(((r=e.keyType)==null?void 0:r._def.typeName)===ge.ZodString&&((i=e.keyType._def.checks)!=null&&i.length)){const{type:u,...f}=zh(e.keyType._def,t);return{...l,propertyNames:f}}else{if(((s=e.keyType)==null?void 0:s._def.typeName)===ge.ZodEnum)return{...l,propertyNames:{enum:e.keyType._def.values}};if(((a=e.keyType)==null?void 0:a._def.typeName)===ge.ZodBranded&&e.keyType._def.type._def.typeName===ge.ZodString&&((o=e.keyType._def.type._def.checks)!=null&&o.length)){const{type:u,...f}=Eh(e.keyType._def,t);return{...l,propertyNames:f}}}return l}function dE(e,t){if(t.mapStrategy==="record")return Th(e,t);const n=Te(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||kt(),r=Te(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||kt();return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}function fE(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 pE(){return{not:kt()}}function hE(){return{type:"null"}}var Ia={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function mE(e,t){const n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(r=>r._def.typeName in Ia&&(!r._def.checks||!r._def.checks.length))){const r=n.reduce((i,s)=>{const a=Ia[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 gE(e,t)}var gE=(e,t)=>{const n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((r,i)=>Te(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 xE(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[Ia[e.innerType._def.typeName],"null"]};const n=Te(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function yE(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 bE(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=wE(o),u=Te(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=vE(e,t);return s!==void 0&&(n.additionalProperties=s),n}function vE(e,t){if(e.catchall._def.typeName!=="ZodNever")return Te(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 wE(e){try{return e.isOptional()}catch{return!0}}var kE=(e,t)=>{var n;if(t.currentPath.toString()===((n=t.propertyPath)==null?void 0:n.toString()))return Te(e.innerType._def,t);const r=Te(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:kt()},r]}:kt()},SE=(e,t)=>{if(t.pipeStrategy==="input")return Te(e.in._def,t);if(t.pipeStrategy==="output")return Te(e.out._def,t);const n=Te(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),r=Te(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,r].filter(i=>i!==void 0)}};function _E(e,t){return Te(e.type._def,t)}function jE(e,t){const r={type:"array",uniqueItems:!0,items:Te(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 CE(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,r)=>Te(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:Te(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,r)=>Te(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[])}}function NE(){return{not:kt()}}function EE(){return kt()}var IE=(e,t)=>Te(e.innerType._def,t),zE=(e,t,n)=>{switch(t){case ge.ZodString:return zh(e,n);case ge.ZodNumber:return yE(e);case ge.ZodObject:return bE(e,n);case ge.ZodBigInt:return QN(e);case ge.ZodBoolean:return eE();case ge.ZodDate:return Ih(e,n);case ge.ZodUndefined:return NE();case ge.ZodNull:return hE();case ge.ZodArray:return XN(e,n);case ge.ZodUnion:case ge.ZodDiscriminatedUnion:return mE(e,n);case ge.ZodIntersection:return oE(e,n);case ge.ZodTuple:return CE(e,n);case ge.ZodRecord:return Th(e,n);case ge.ZodLiteral:return lE(e);case ge.ZodEnum:return sE(e);case ge.ZodNativeEnum:return fE(e);case ge.ZodNullable:return xE(e,n);case ge.ZodOptional:return kE(e,n);case ge.ZodMap:return dE(e,n);case ge.ZodSet:return jE(e,n);case ge.ZodLazy:return()=>e.getter()._def;case ge.ZodPromise:return _E(e,n);case ge.ZodNaN:case ge.ZodNever:return pE();case ge.ZodEffects:return iE(e,n);case ge.ZodAny:return kt();case ge.ZodUnknown:return EE();case ge.ZodDefault:return rE(e,n);case ge.ZodBranded:return Eh(e,n);case ge.ZodReadonly:return IE(e,n);case ge.ZodCatch:return tE(e,n);case ge.ZodPipeline:return SE(e,n);case ge.ZodFunction:case ge.ZodVoid:case ge.ZodSymbol:return;default:return(r=>{})()}},TE=(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 Te(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!==KN)return l}if(i&&!n){const l=AE(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=zE(e,e.typeName,t),o=typeof a=="function"?Te(a(),t):a;if(o&&PE(e,t,o),t.postProcess){const l=t.postProcess(o,e,t);return s.jsonSchema=o,l}return s.jsonSchema=o,o}var AE=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:TE(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`),kt()):t.$refStrategy==="seen"?kt():void 0}},PE=(e,t,n)=>(e.description&&(n.description=e.description),n),OE=e=>{const t=YN(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}]))}},DE=(e,t)=>{var n;const r=OE(t);let i=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((u,[f,d])=>{var h;return{...u,[f]:(h=Te(d._def,{...r,currentPath:[...r.basePath,r.definitionPath,f]},!0))!=null?h:kt()}},{}):void 0;const s=typeof t=="string"?t:(t==null?void 0:t.nameStrategy)==="title"||t==null?void 0:t.name,a=(n=Te(e._def,s===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1))!=null?n:kt(),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},za=Symbol.for("vercel.ai.schema");function RE(e){let t;return()=>(t==null&&(t=e()),t)}function ps(e,{validate:t}={}){return{[za]:!0,_type:void 0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function ME(e){return typeof e=="object"&&e!==null&&za in e&&e[za]===!0&&"jsonSchema"in e&&"validate"in e}function Ao(e){return e==null?ps({properties:{},additionalProperties:!1}):ME(e)?e:"~standard"in e?e["~standard"].vendor==="zod"?Ah(e):$E(e):e()}function $E(e){return ps(()=>To(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 Xn({value:t,cause:n.issues})}}})}function FE(e,t){var n;const r=(n=void 0)!=null?n:!1;return ps(()=>DE(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 LE(e,t){var n;const r=(n=void 0)!=null?n:!1;return ps(()=>To(_C(e,{target:"draft-7",io:"input",reused:r?"ref":"inline"})),{validate:async i=>{const s=await yh(e,i);return s.success?{success:!0,value:s.data}:{success:!1,error:s.error}}})}function ZE(e){return"_zod"in e}function Ah(e,t){return ZE(e)?LE(e):FE(e)}async function Lu({value:e,schema:t,context:n}){const r=await Br({value:e,schema:t,context:n});if(!r.success)throw Xn.wrap({value:e,cause:r.error,context:n});return r.value}async function Br({value:e,schema:t,context:n}){const r=Ao(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:Xn.wrap({value:e,cause:i.error,context:n}),rawValue:e}}catch(i){return{success:!1,error:Xn.wrap({value:e,cause:i,context:n}),rawValue:e}}}async function En({text:e,schema:t}){try{const n=GN(e);return t==null?{success:!0,value:n,rawValue:n}:await Br({value:n,schema:t})}catch(n){return{success:!1,error:ou.isInstance(n)?n:new ou({text:e,cause:n}),rawValue:void 0}}}function BE({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new UN).pipeThrough(new TransformStream({async transform({data:n},r){n!=="[DONE]"&&r.enqueue(await En({text:n,schema:t}))}}))}async function Xt(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}var VE=Object.defineProperty,UE=(e,t)=>{for(var n in t)VE(e,n,{get:t[n],enumerable:!0})},Ph="AI_NoObjectGeneratedError",Oh=`vercel.ai.error.${Ph}`,JE=Symbol.for(Oh),Dh,sn=class extends Bt{constructor({message:e="No object generated.",cause:t,text:n,response:r,usage:i,finishReason:s}){super({name:Ph,message:e,cause:t}),this[Dh]=!0,this.text=n,this.response=r,this.usage=i,this.finishReason=s}static isInstance(e){return Bt.hasMarker(e,Oh)}};Dh=JE;var Rh="AI_UIMessageStreamError",Mh=`vercel.ai.error.${Rh}`,HE=Symbol.for(Mh),$h,Rn=class extends Bt{constructor({chunkType:e,chunkId:t,message:n}){super({name:Rh,message:n}),this[$h]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return Bt.hasMarker(e,Mh)}};$h=HE;var Zu="6.0.116",Fh=ct([re(),Li(Uint8Array),Li(ArrayBuffer),Nh(e=>{var t,n;return(n=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?n:!1},{message:"Must be a Buffer"})]),Vr=FN(()=>ct([pN(),re(),uN(),ot(),Lr(re(),Vr.optional()),sr(Vr)])),je=Lr(re(),Lr(re(),Vr.optional())),Lh=Oe({type:me("text"),text:re(),providerOptions:je.optional()}),qE=Oe({type:me("image"),image:ct([Fh,Li(URL)]),mediaType:re().optional(),providerOptions:je.optional()}),Zh=Oe({type:me("file"),data:ct([Fh,Li(URL)]),filename:re().optional(),mediaType:re(),providerOptions:je.optional()}),WE=Oe({type:me("reasoning"),text:re(),providerOptions:je.optional()}),GE=Oe({type:me("tool-call"),toolCallId:re(),toolName:re(),input:$t(),providerOptions:je.optional(),providerExecuted:ot().optional()}),KE=yN("type",[Oe({type:me("text"),value:re(),providerOptions:je.optional()}),Oe({type:me("json"),value:Vr,providerOptions:je.optional()}),Oe({type:me("execution-denied"),reason:re().optional(),providerOptions:je.optional()}),Oe({type:me("error-text"),value:re(),providerOptions:je.optional()}),Oe({type:me("error-json"),value:Vr,providerOptions:je.optional()}),Oe({type:me("content"),value:sr(ct([Oe({type:me("text"),text:re(),providerOptions:je.optional()}),Oe({type:me("media"),data:re(),mediaType:re()}),Oe({type:me("file-data"),data:re(),mediaType:re(),filename:re().optional(),providerOptions:je.optional()}),Oe({type:me("file-url"),url:re(),providerOptions:je.optional()}),Oe({type:me("file-id"),fileId:ct([re(),Lr(re(),re())]),providerOptions:je.optional()}),Oe({type:me("image-data"),data:re(),mediaType:re(),providerOptions:je.optional()}),Oe({type:me("image-url"),url:re(),providerOptions:je.optional()}),Oe({type:me("image-file-id"),fileId:ct([re(),Lr(re(),re())]),providerOptions:je.optional()}),Oe({type:me("custom"),providerOptions:je.optional()})]))})]),Bh=Oe({type:me("tool-result"),toolCallId:re(),toolName:re(),output:KE,providerOptions:je.optional()}),YE=Oe({type:me("tool-approval-request"),approvalId:re(),toolCallId:re()}),XE=Oe({type:me("tool-approval-response"),approvalId:re(),approved:ot(),reason:re().optional()}),QE=Oe({role:me("system"),content:re(),providerOptions:je.optional()}),eI=Oe({role:me("user"),content:ct([re(),sr(ct([Lh,qE,Zh]))]),providerOptions:je.optional()}),tI=Oe({role:me("assistant"),content:ct([re(),sr(ct([Lh,Zh,WE,GE,Bh,YE]))]),providerOptions:je.optional()}),nI=Oe({role:me("tool"),content:sr(ct([Bh,XE])),providerOptions:je.optional()});ct([QE,eI,tI,nI]);function Vh(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]=Vh(s,i):n[r]=i}return n}var rI={};UE(rI,{array:()=>oI,choice:()=>lI,json:()=>uI,object:()=>aI,text:()=>sI});function iI(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 Kr(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await En({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await En({text:iI(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var sI=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),aI=({schema:e,name:t,description:n})=>{const r=Ao(e);return{name:"object",responseFormat:Xt(r.jsonSchema).then(i=>({type:"json",schema:i,...t!=null&&{name:t},...n!=null&&{description:n}})),async parseCompleteOutput({text:i},s){const a=await En({text:i});if(!a.success)throw new sn({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 Br({value:a.value,schema:r});if(!o.success)throw new sn({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 Kr(i);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:s.value}}},createElementStreamTransform(){}}},oI=({element:e,name:t,description:n})=>{const r=Ao(e);return{name:"array",responseFormat:Xt(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 En({text:i});if(!a.success)throw new sn({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 sn({message:"No object generated: response did not match schema.",cause:new Xn({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 Br({value:l,schema:r});if(!u.success)throw new sn({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 Kr(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 Br({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])}})}}},lI=({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 En({text:r});if(!s.success)throw new sn({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 sn({message:"No object generated: response did not match schema.",cause:new Xn({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 Kr(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(){}}),uI=({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 En({text:n});if(!i.success)throw new sn({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 Kr(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(){}});Gr({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=RE(()=>Ah(ct([Fe({type:me("text-start"),id:re(),providerMetadata:je.optional()}),Fe({type:me("text-delta"),id:re(),delta:re(),providerMetadata:je.optional()}),Fe({type:me("text-end"),id:re(),providerMetadata:je.optional()}),Fe({type:me("error"),errorText:re()}),Fe({type:me("tool-input-start"),toolCallId:re(),toolName:re(),providerExecuted:ot().optional(),providerMetadata:je.optional(),dynamic:ot().optional(),title:re().optional()}),Fe({type:me("tool-input-delta"),toolCallId:re(),inputTextDelta:re()}),Fe({type:me("tool-input-available"),toolCallId:re(),toolName:re(),input:$t(),providerExecuted:ot().optional(),providerMetadata:je.optional(),dynamic:ot().optional(),title:re().optional()}),Fe({type:me("tool-input-error"),toolCallId:re(),toolName:re(),input:$t(),providerExecuted:ot().optional(),providerMetadata:je.optional(),dynamic:ot().optional(),errorText:re(),title:re().optional()}),Fe({type:me("tool-approval-request"),approvalId:re(),toolCallId:re()}),Fe({type:me("tool-output-available"),toolCallId:re(),output:$t(),providerExecuted:ot().optional(),dynamic:ot().optional(),preliminary:ot().optional()}),Fe({type:me("tool-output-error"),toolCallId:re(),errorText:re(),providerExecuted:ot().optional(),dynamic:ot().optional()}),Fe({type:me("tool-output-denied"),toolCallId:re()}),Fe({type:me("reasoning-start"),id:re(),providerMetadata:je.optional()}),Fe({type:me("reasoning-delta"),id:re(),delta:re(),providerMetadata:je.optional()}),Fe({type:me("reasoning-end"),id:re(),providerMetadata:je.optional()}),Fe({type:me("source-url"),sourceId:re(),url:re(),title:re().optional(),providerMetadata:je.optional()}),Fe({type:me("source-document"),sourceId:re(),mediaType:re(),title:re(),filename:re().optional(),providerMetadata:je.optional()}),Fe({type:me("file"),url:re(),mediaType:re(),providerMetadata:je.optional()}),Fe({type:Nh(e=>typeof e=="string"&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:re().optional(),data:$t(),transient:ot().optional()}),Fe({type:me("start-step")}),Fe({type:me("finish-step")}),Fe({type:me("start"),messageId:re().optional(),messageMetadata:$t().optional()}),Fe({type:me("finish"),finishReason:_h(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:$t().optional()}),Fe({type:me("abort"),reason:re().optional()}),Fe({type:me("message-metadata"),messageMetadata:$t()})])));function dI(e){return e.type.startsWith("data-")}function Ta(e){return e.type.startsWith("tool-")}function fI(e){return e.type==="dynamic-tool"}function Bi(e){return Ta(e)||fI(e)}function Bu(e){return e.type.split("-").slice(1).join("-")}function pI({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 hI({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,h,p,m;function w(y){const N=u.message.parts.filter(Bi).find(k=>k.toolCallId===y);if(N==null)throw new Rn({chunkType:"tool-invocation",chunkId:y,message:`No tool invocation found for tool call ID "${y}".`});return N}function S(y){var P;const N=u.message.parts.find($=>Ta($)&&$.toolCallId===y.toolCallId),k=y,j=N;N!=null?(N.state=y.state,j.input=k.input,j.output=k.output,j.errorText=k.errorText,j.rawInput=k.rawInput,j.preliminary=k.preliminary,y.title!==void 0&&(j.title=y.title),j.providerExecuted=(P=k.providerExecuted)!=null?P:N.providerExecuted,k.providerMetadata!=null&&(N.callProviderMetadata=k.providerMetadata)):u.message.parts.push({type:`tool-${y.toolName}`,toolCallId:y.toolCallId,state:y.state,title:y.title,input:k.input,output:k.output,rawInput:k.rawInput,errorText:k.errorText,providerExecuted:k.providerExecuted,preliminary:k.preliminary,...k.providerMetadata!=null?{callProviderMetadata:k.providerMetadata}:{}})}function x(y){var P,N;const k=u.message.parts.find(W=>W.type==="dynamic-tool"&&W.toolCallId===y.toolCallId),j=y,$=k;k!=null?(k.state=y.state,$.toolName=y.toolName,$.input=j.input,$.output=j.output,$.errorText=j.errorText,$.rawInput=(P=j.rawInput)!=null?P:$.rawInput,$.preliminary=j.preliminary,y.title!==void 0&&($.title=y.title),$.providerExecuted=(N=j.providerExecuted)!=null?N:k.providerExecuted,j.providerMetadata!=null&&(k.callProviderMetadata=j.providerMetadata)):u.message.parts.push({type:"dynamic-tool",toolName:y.toolName,toolCallId:y.toolCallId,state:y.state,input:j.input,output:j.output,errorText:j.errorText,preliminary:j.preliminary,providerExecuted:j.providerExecuted,title:y.title,...j.providerMetadata!=null?{callProviderMetadata:j.providerMetadata}:{}})}async function _(y){if(y!=null){const P=u.message.metadata!=null?Vh(u.message.metadata,y):y;t!=null&&await Lu({value:P,schema:t,context:{field:"message.metadata",entityId:u.message.id}}),u.message.metadata=P}}switch(o.type){case"text-start":{const y={type:"text",text:"",providerMetadata:o.providerMetadata,state:"streaming"};u.activeTextParts[o.id]=y,u.message.parts.push(y),f();break}case"text-delta":{const y=u.activeTextParts[o.id];if(y==null)throw new Rn({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.`});y.text+=o.delta,y.providerMetadata=(d=o.providerMetadata)!=null?d:y.providerMetadata,f();break}case"text-end":{const y=u.activeTextParts[o.id];if(y==null)throw new Rn({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.`});y.state="done",y.providerMetadata=(h=o.providerMetadata)!=null?h:y.providerMetadata,delete u.activeTextParts[o.id],f();break}case"reasoning-start":{const y={type:"reasoning",text:"",providerMetadata:o.providerMetadata,state:"streaming"};u.activeReasoningParts[o.id]=y,u.message.parts.push(y),f();break}case"reasoning-delta":{const y=u.activeReasoningParts[o.id];if(y==null)throw new Rn({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.`});y.text+=o.delta,y.providerMetadata=(p=o.providerMetadata)!=null?p:y.providerMetadata,f();break}case"reasoning-end":{const y=u.activeReasoningParts[o.id];if(y==null)throw new Rn({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.`});y.providerMetadata=(m=o.providerMetadata)!=null?m:y.providerMetadata,y.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 y=u.message.parts.filter(Ta);u.partialToolCalls[o.toolCallId]={text:"",toolName:o.toolName,index:y.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 y=u.partialToolCalls[o.toolCallId];if(y==null)throw new Rn({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.`});y.text+=o.inputTextDelta;const{value:P}=await Kr(y.text);y.dynamic?x({toolCallId:o.toolCallId,toolName:y.toolName,state:"input-streaming",input:P,title:y.title}):S({toolCallId:o.toolCallId,toolName:y.toolName,state:"input-streaming",input:P,title:y.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 y=u.message.parts.filter(Bi).find(N=>N.toolCallId===o.toolCallId);(y!=null?y.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 y=w(o.toolCallId);y.state="approval-requested",y.approval={id:o.approvalId},f();break}case"tool-output-denied":{const y=w(o.toolCallId);y.state="output-denied",f();break}case"tool-output-available":{const y=w(o.toolCallId);y.type==="dynamic-tool"?x({toolCallId:o.toolCallId,toolName:y.toolName,state:"output-available",input:y.input,output:o.output,preliminary:o.preliminary,providerExecuted:o.providerExecuted,title:y.title}):S({toolCallId:o.toolCallId,toolName:Bu(y),state:"output-available",input:y.input,output:o.output,providerExecuted:o.providerExecuted,preliminary:o.preliminary,title:y.title}),f();break}case"tool-output-error":{const y=w(o.toolCallId);y.type==="dynamic-tool"?x({toolCallId:o.toolCallId,toolName:y.toolName,state:"output-error",input:y.input,errorText:o.errorText,providerExecuted:o.providerExecuted,title:y.title}):S({toolCallId:o.toolCallId,toolName:Bu(y),state:"output-error",input:y.input,rawInput:y.rawInput,errorText:o.errorText,providerExecuted:o.providerExecuted,title:y.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(dI(o)){if((n==null?void 0:n[o.type])!=null){const N=u.message.parts.findIndex(j=>"id"in j&&"data"in j&&j.id===o.id&&j.type===o.type),k=N>=0?N:u.message.parts.length;await Lu({value:o.data,schema:n[o.type],context:{field:`message.parts[${k}].data`,entityName:o.type,entityId:o.id}})}const y=o;if(y.transient){a==null||a(y);break}const P=y.id!=null?u.message.parts.find(N=>y.type===N.type&&y.id===N.id):void 0;P!=null?P.data=y.data:u.message.parts.push(y),a==null||a(y),f()}}l.enqueue(o)})}}))}async function mI({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()}}Gr({prefix:"aitxt",size:24});Gr({prefix:"aiobj",size:24});var gI=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()})}};Gr({prefix:"aiobj",size:24});async function xI(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 yI=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 Xt(this.body),l=await Xt(this.headers),u=await Xt(this.credentials),f={...gn(l),...gn(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})),h=(r=d==null?void 0:d.api)!=null?r:this.api,p=(d==null?void 0:d.headers)!==void 0?gn(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)(h,{method:"POST",headers:Ru({"Content-Type":"application/json",...p},`ai-sdk/${Zu}`,Du()),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 Xt(this.body),o=await Xt(this.headers),l=await Xt(this.credentials),u={...gn(o),...gn(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`,h=(f==null?void 0:f.headers)!==void 0?gn(f.headers):u,p=(r=f==null?void 0:f.credentials)!=null?r:l,w=await((i=this.fetch)!=null?i:globalThis.fetch)(d,{method:"GET",headers:Ru(h,`ai-sdk/${Zu}`,Du()),credentials:p});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)}},Uh=class extends yI{constructor(e={}){super(e)}processResponseStream(e){return BE({stream:e,schema:cI}).pipeThrough(new TransformStream({async transform(t,n){if(!t.success)throw t.error;n.enqueue(t.value)}}))}},bI=class{constructor({generateId:e=JN,id:t=e(),transport:n=new Uh,messageMetadataSchema:r,dataPartSchemas:i,state:s,onError:a,onToolCall:o,onFinish:l,onData:u,sendAutomaticallyWhen:f}){this.activeResponse=void 0,this.jobExecutor=new gI,this.sendMessage=async(d,h)=>{var p,m,w,S;if(d==null){await this.makeRequest({trigger:"submit-message",messageId:(p=this.lastMessage)==null?void 0:p.id,...h});return}let x;if("text"in d||"files"in d?x={parts:[...Array.isArray(d.files)?d.files:await xI(d.files),..."text"in d&&d.text!=null?[{type:"text",text:d.text}]:[]]}:x=d,d.messageId!=null){const _=this.state.messages.findIndex(y=>y.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,...h})},this.regenerate=async({messageId:d,...h}={})=>{const p=d==null?this.state.messages.length-1:this.state.messages.findIndex(m=>m.id===d);if(p===-1)throw new Error(`message ${d} not found`);this.state.messages=this.state.messages.slice(0,this.messages[p].role==="assistant"?p:p+1),await this.makeRequest({trigger:"regenerate-message",messageId:d,...h})},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:h,reason:p})=>this.jobExecutor.run(async()=>{const m=this.state.messages,w=m[m.length-1],S=x=>Bi(x)&&x.state==="approval-requested"&&x.approval.id===d?{...x,state:"approval-responded",approval:{id:d,approved:h,reason:p}}:x;this.state.replaceMessage(m.length-1,{...w,parts:w.parts.map(S)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(S)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(x=>{var _;x&&this.makeRequest({trigger:"submit-message",messageId:(_=this.lastMessage)==null?void 0:_.id})})}),this.addToolOutput=async({state:d="output-available",tool:h,toolCallId:p,output:m,errorText:w})=>this.jobExecutor.run(async()=>{const S=this.state.messages,x=S[S.length-1],_=y=>Bi(y)&&y.toolCallId===p?{...y,state:d,output:m,errorText:w}:y;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(y=>{var P;y&&this.makeRequest({trigger:"submit-message",messageId:(P=this.lastMessage)==null?void 0:P.id})})}),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 p=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:n,body:r});if(p==null)return;l=p}catch(p){this.onError&&p instanceof Error&&this.onError(p),this.setStatus({status:"error",error:p});return}this.setStatus({status:"submitted",error:void 0});const u=this.lastMessage;let f=!1,d=!1,h=!1;try{const p={state:pI({lastMessage:this.state.snapshot(u),messageId:this.generateId()}),abortController:new AbortController};p.abortController.signal.addEventListener("abort",()=>{f=!0}),this.activeResponse=p;let m;e==="resume-stream"?m=l:m=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:p.abortController.signal,metadata:t,headers:n,body:r,trigger:e,messageId:i});const w=S=>this.jobExecutor.run(()=>S({state:p.state,write:()=>{var x;this.setStatus({status:"streaming"}),p.state.message.id===((x=this.lastMessage)==null?void 0:x.id)?this.state.replaceMessage(this.state.messages.length-1,p.state.message):this.state.pushMessage(p.state.message)}}));await mI({stream:hI({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(p){if(f||p.name==="AbortError")return f=!0,this.setStatus({status:"ready"}),null;h=!0,p instanceof TypeError&&(p.message.toLowerCase().includes("fetch")||p.message.toLowerCase().includes("network"))&&(d=!0),this.onError&&p instanceof Error&&this.onError(p),this.setStatus({status:"error",error:p})}finally{try{(a=this.onFinish)==null||a.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:f,isDisconnect:d,isError:h,finishReason:(s=this.activeResponse)==null?void 0:s.state.finishReason})}catch(p){console.error(p)}this.activeResponse=void 0}!h&&await this.shouldSendAutomatically()&&await this.makeRequest({trigger:"submit-message",messageId:(o=this.lastMessage)==null?void 0:o.id,metadata:t,headers:n,body:r})}},Ks,Vu;function vI(){if(Vu)return Ks;Vu=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 Ks=e,Ks}var wI=vI();const kI=Ra(wI);var Jh=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Le=(e,t,n)=>(Jh(e,t,"read from private field"),n?n.call(e):t.get(e)),Rt=(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)},Yt=(e,t,n,r)=>(Jh(e,t,"write to private field"),t.set(e,n),n);function SI(e,t){return t!=null?kI(e,t):e}var _t,gi,xi,wr,kr,Sr,Ln,Aa,Pa,_I=class{constructor(e=[]){Rt(this,_t,void 0),Rt(this,gi,"ready"),Rt(this,xi,void 0),Rt(this,wr,new Set),Rt(this,kr,new Set),Rt(this,Sr,new Set),this.pushMessage=t=>{Yt(this,_t,Le(this,_t).concat(t)),Le(this,Ln).call(this)},this.popMessage=()=>{Yt(this,_t,Le(this,_t).slice(0,-1)),Le(this,Ln).call(this)},this.replaceMessage=(t,n)=>{Yt(this,_t,[...Le(this,_t).slice(0,t),this.snapshot(n),...Le(this,_t).slice(t+1)]),Le(this,Ln).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,n)=>{const r=n?SI(t,n):t;return Le(this,wr).add(r),()=>{Le(this,wr).delete(r)}},this["~registerStatusCallback"]=t=>(Le(this,kr).add(t),()=>{Le(this,kr).delete(t)}),this["~registerErrorCallback"]=t=>(Le(this,Sr).add(t),()=>{Le(this,Sr).delete(t)}),Rt(this,Ln,()=>{Le(this,wr).forEach(t=>t())}),Rt(this,Aa,()=>{Le(this,kr).forEach(t=>t())}),Rt(this,Pa,()=>{Le(this,Sr).forEach(t=>t())}),Yt(this,_t,e)}get status(){return Le(this,gi)}set status(e){Yt(this,gi,e),Le(this,Aa).call(this)}get error(){return Le(this,xi)}set error(e){Yt(this,xi,e),Le(this,Pa).call(this)}get messages(){return Le(this,_t)}set messages(e){Yt(this,_t,[...e]),Le(this,Ln).call(this)}};_t=new WeakMap;gi=new WeakMap;xi=new WeakMap;wr=new WeakMap;kr=new WeakMap;Sr=new WeakMap;Ln=new WeakMap;Aa=new WeakMap;Pa=new WeakMap;var Zn,Uu=class extends bI{constructor({messages:e,...t}){const n=new _I(e);super({...t,state:n}),Rt(this,Zn,void 0),this["~registerMessagesCallback"]=(r,i)=>Le(this,Zn)["~registerMessagesCallback"](r,i),this["~registerStatusCallback"]=r=>Le(this,Zn)["~registerStatusCallback"](r),this["~registerErrorCallback"]=r=>Le(this,Zn)["~registerErrorCallback"](r),Yt(this,Zn,n)}};Zn=new WeakMap;function jI({experimental_throttle:e,resume:t=!1,...n}={}){const r=v.useRef("chat"in n?{}:{onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});"chat"in n||(r.current={onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});const i={...n,onToolCall:h=>{var p,m;return(m=(p=r.current).onToolCall)==null?void 0:m.call(p,h)},onData:h=>{var p,m;return(m=(p=r.current).onData)==null?void 0:m.call(p,h)},onFinish:h=>{var p,m;return(m=(p=r.current).onFinish)==null?void 0:m.call(p,h)},onError:h=>{var p,m;return(m=(p=r.current).onError)==null?void 0:m.call(p,h)},sendAutomaticallyWhen:h=>{var p,m,w;return(w=(m=(p=r.current).sendAutomaticallyWhen)==null?void 0:m.call(p,h))!=null?w:!1}},s=v.useRef("chat"in n?n.chat:new Uu(i));("chat"in n&&n.chat!==s.current||"id"in n&&s.current.id!==n.id)&&(s.current="chat"in n?n.chat:new Uu(i));const o=v.useCallback(h=>s.current["~registerMessagesCallback"](h,e),[e,s.current.id]),l=v.useSyncExternalStore(o,()=>s.current.messages,()=>s.current.messages),u=v.useSyncExternalStore(s.current["~registerStatusCallback"],()=>s.current.status,()=>s.current.status),f=v.useSyncExternalStore(s.current["~registerErrorCallback"],()=>s.current.error,()=>s.current.error),d=v.useCallback(h=>{typeof h=="function"&&(h=h(s.current.messages)),s.current.messages=h},[s]);return v.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 Hh(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 qh(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 Wh(e,t,n){if(!(n!=null&&n.selectedText)){const i=CI(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=AI(e,n.startLine);l=PI(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=zI(e,t,n.startLine,n.endLine);if(o)return o}const a=Ju(e,t);return a||{original:e,modified:t}}const r=Ju(e,t);return r||{original:e,modified:t}}function CI(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(!Oa(i,r,n))return null;const o=JSON.stringify(i,null,a);return{original:e,modified:o}}function Oa(e,t,n){if(Array.isArray(e)){for(let r=0;r<e.length;r++){const i=e[r];if(i&&typeof i=="object"&&!Array.isArray(i)&&i.name===t)return e[r]=n,!0;if(Oa(i,t,n))return!0}return!1}if(e&&typeof e=="object"){for(const r of Object.values(e))if(Oa(r,t,n))return!0}return!1}function Ju(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=NI(t);if(n.length===0)return null;let r=e,i=!1;for(const s of n){const a=EI(r,t,s);a&&(r=a,i=!0)}return i?{original:e,modified:r}:null}function NI(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 EI(e,t,n){const r=`"${n}"`,i=Hu(e,r);if(i.length===0)return null;const s=Hu(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 h=e.slice(i[d].start,i[d].end),p=TI(h,o);p>f&&(f=p,l=d)}}const u=i[l];return e.slice(0,u.start)+o+e.slice(u.end)}function Hu(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=II(e,l);if(u===-1){r=i+1;continue}n.push({start:i,end:u}),r=u}return n}function II(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 zI(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 TI(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 AI(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 PI(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 OI(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 DI(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=Hh(r.props.templates||[],i.templates);else return null;return{original:e,modified:JSON.stringify(r,null,2)}}catch{return null}}function RI(){const e=ze(Y=>Y.threads),t=ze(Y=>Y.activeThreadId),n=ze(Y=>Y.updateThreadMessages),r=ze(Y=>Y.updateThreadTitle),i=ze(Y=>Y.clearContext),s=ze(Y=>Y.contextAttachments),a=ze(Y=>Y.scope),o=ze(Y=>Y.model),l=Ge(Y=>Y.activeTab),u=Ge(Y=>Y.documents),f=Ge(Y=>Y.documentTypes),d=Ge(Y=>Y.setPendingDiff),h=Ge(Y=>Y.createDocument),p=Ge(Y=>Y.openDocument),m=v.useRef(e);m.current=e;const w=v.useRef(l);w.current=l;const S=v.useRef(u);S.current=u;const x=v.useRef(f);x.current=f;const _=v.useRef(t);_.current=t;const y=l?t[l]:void 0,P=v.useRef(y);P.current=y;const N=v.useRef([]),k=v.useRef([]),j=v.useRef({}),$=v.useRef({}),[,W]=v.useState(0),E=v.useCallback(()=>W(Y=>Y+1),[]),U=v.useRef(null);U.current||(U.current=new Uh({api:"/api/ai/chat"}));const R=v.useCallback(()=>{const Y=S.current.find(O=>O.name===w.current);return Y?{name:Y.name,text:Y.text}:void 0},[]),B=v.useCallback(Y=>j.current[Y]||[],[]),L=jI({transport:U.current,onError:()=>{N.current.shift(),k.current.shift(),i()},onFinish:({messages:Y})=>{var K,ie;const O=P.current;if(O){n(O,Y);const Q=m.current[O];if(Q&&Q.title.startsWith("Chat ")){const I=Y.find(D=>D.role==="user");if(I){const D=((K=I.parts)==null?void 0:K.filter(J=>J.type==="text").map(J=>J.text).join(""))||"";if(D){const J=D.length>50?D.slice(0,50)+"...":D;r(O,J)}}}}const G=N.current.shift()||[],b=k.current.shift()||"global",ue=Y.filter(Q=>Q.role==="user"),ae=ue[ue.length-1];ae!=null&&ae.id&&(j.current[ae.id]=G,$.current[ae.id]=b);const g=Y.filter(Q=>Q.role==="assistant").pop();if(g){const I=[...(((ie=g.parts)==null?void 0:ie.filter(D=>D.type==="text").map(D=>D.text).join(""))||"").matchAll(/```(?:json|jsonc)\s*\n([\s\S]*?)```/g)];if(I.length>0){const D=OI(I);if(D){const J=I[I.length-1][1],oe=w.current;if(oe){const pe=S.current.find(yt=>yt.name===oe),Ae=(pe==null?void 0:pe.text)||"",ke=G[0],be=DI(Ae,D,b);!be&&b!=="global"&&console.warn(`[chat] scopedMerge failed for scope="${b}", falling back to text merge`);const{original:it,modified:St}=be??Wh(Ae,D,ke);d(oe,it,St,qh(J.replace(/\n$/,"")))}else{const pe=`ai-generated-${Date.now()}`;h(pe,D),p(pe)}}}}i()}});v.useEffect(()=>{const Y=L.messages.filter(O=>O.role==="user");for(let O=Y.length-1;O>=0;O--){const G=Y[O].id;if(G in j.current)break;N.current.length>0&&(j.current[G]=N.current[0],$.current[G]=k.current[0]||"global",E());break}},[L.messages,E]);const T=v.useCallback((Y,O)=>{N.current.push([...s]),k.current.push(a),i();const G={text:Y};O!=null&&O.length&&(G.files=O),L.sendMessage(G,{body:{format:Nt,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]),H=v.useCallback(Y=>$.current[Y],[]);return{messages:L.messages,sendMessage:T,status:L.status,error:L.error,setMessages:L.setMessages,stop:L.stop,getMessageContext:B,getMessageScope:H}}const Gh=v.createContext(null);function qu({children:e}){const t=RI();return c.jsx(Gh.Provider,{value:t,children:e})}function MI(){const e=v.useContext(Gh);if(!e)throw new Error("useChatSessionContext must be used within ChatSessionProvider");return e}function $I(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 FI(e,t=50){const n=e.replace(/[\n\r]+/g," ").replace(/\s+/g," ").trim();return n.length>t?n.slice(0,t)+"…":n}function Kh({context:e,onRemove:t,variant:n="default"}){var u;const r=$I(e),i=((u=e.documentName)==null?void 0:u.replace(/\.json$/,""))??"",s=i?`${i} › ${r}`:r,a=FI(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(Km,{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(kn,{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 Mn extends Error{constructor(t,n){super(`${t} at position ${n}`),this.position=n}}const Yh=32,LI=10,Xh=9,Qh=13,ZI=160,BI=6158,VI=8192,UI=8203,JI=8239,HI=8287,qI=12288,WI=65279;function GI(e){return/^[0-9A-Fa-f]$/.test(e)}function hn(e){return e>="0"&&e<="9"}function KI(e){return e>=" "}function ci(e){return`,:[]/{}()
|
|
92
|
+
+`.includes(e)}function Wu(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"}function Gu(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"||e>="0"&&e<="9"}const Ku=/^(http|https|ftp|mailto|file|data|irc):\/\/$/,Yu=/^[A-Za-z0-9-._~:/?#@!$&'()*+;=]$/;function Xu(e){return`,[]/{}
|
|
93
|
+
+`.includes(e)}function Qu(e){return yi(e)||YI.test(e)}const YI=/^[[{\w-]$/;function XI(e){return e===`
|
|
94
|
+
`||e==="\r"||e===" "||e==="\b"||e==="\f"}function xn(e,t){const n=e.charCodeAt(t);return n===Yh||n===LI||n===Xh||n===Qh}function QI(e,t){const n=e.charCodeAt(t);return n===Yh||n===Xh||n===Qh}function ez(e,t){const n=e.charCodeAt(t);return n===ZI||n===BI||n>=VI&&n<=UI||n===JI||n===HI||n===qI||n===WI}function yi(e){return em(e)||Da(e)}function em(e){return e==='"'||e==="“"||e==="”"}function ec(e){return e==='"'}function Da(e){return e==="'"||e==="‘"||e==="’"||e==="`"||e==="´"}function tc(e){return e==="'"}function hr(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 Tt(e,t){let n=e.length;if(!xn(e,n-1))return e+t;for(;xn(e,n-1);)n--;return e.substring(0,n)+t+e.substring(n)}function tz(e,t,n){return e.substring(0,t)+e.substring(t+n)}function nz(e){return/[,\n][ \t\r]*$/.test(e)}const rz={"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"},iz={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
|
|
95
|
+
`,r:"\r",t:" "};function nc(e){let t=0,n="";u(["```","[```","{```"]),s()||L(),u(["```","```]","```}"]);const i=d(",");for(i&&a(),Qu(e[t])&&nz(n)?(i||(n=Tt(n,",")),x()):i&&(n=hr(n,","));e[t]==="}"||e[t]==="]";)t++,a();if(t>=e.length)return n;B();function s(){a();const O=w()||S()||_()||P()||N()||j(!1)||$();return a(),O}function a(){let O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;const G=t;let b=o(O);do b=l(),b&&(b=o(O));while(b);return t>G}function o(O){const G=O?xn:QI;let b="";for(;;)if(G(e,t))b+=e[t],t++;else if(ez(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&&!sz(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(Wu(e[t]))for(;t<e.length&&Gu(e[t]);)t++;return a(),!0}return!1}function f(O){o(!0);for(const G of O){const b=t+G.length;if(e.slice(t,b)===G)return t=b,!0}return!1}function d(O){return e[t]===O?(n+=e[t],t++,!0):!1}function h(O){return e[t]===O?(t++,!0):!1}function p(){return h("\\")}function m(){return a(),e[t]==="."&&e[t+1]==="."&&e[t+2]==="."?(t+=3,a(),h(","),!0):!1}function w(){if(e[t]==="{"){n+="{",t++,a(),h(",")&&a();let O=!0;for(;t<e.length&&e[t]!=="}";){let G;if(O?(G=!0,O=!1):(G=d(","),G||(n=Tt(n,",")),a()),m(),!(_()||j(!0))){e[t]==="}"||e[t]==="{"||e[t]==="]"||e[t]==="["||e[t]===void 0?n=hr(n,","):T();break}a();const ue=d(":"),ae=t>=e.length;ue||(Qu(e[t])||ae?n=Tt(n,":"):H()),s()||(ue||ae?n+="null":H())}return e[t]==="}"?(n+="}",t++):n=Tt(n,"}"),!0}return!1}function S(){if(e[t]==="["){n+="[",t++,a(),h(",")&&a();let O=!0;for(;t<e.length&&e[t]!=="]";)if(O?O=!1:d(",")||(n=Tt(n,",")),m(),!s()){n=hr(n,",");break}return e[t]==="]"?(n+="]",t++):n=Tt(n,"]"),!0}return!1}function x(){let O=!0,G=!0;for(;G;)O?O=!1:d(",")||(n=Tt(n,",")),G=s();G||(n=hr(n,",")),n=`[
|
|
97
|
+
${n}
|
|
98
|
+
]`}function _(){let O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,G=arguments.length>1&&arguments[1]!==void 0?arguments[1]:-1,b=e[t]==="\\";if(b&&(t++,b=!0),yi(e[t])){const ue=ec(e[t])?ec:tc(e[t])?tc:Da(e[t])?Da:em,ae=t,g=n.length;let K='"';for(t++;;){if(t>=e.length){const ie=W(t-1);return!O&&ci(e.charAt(ie))?(t=ae,n=n.substring(0,g),_(!0)):(K=Tt(K,'"'),n+=K,!0)}if(t===G)return K=Tt(K,'"'),n+=K,!0;if(ue(e[t])){const ie=t,Q=K.length;if(K+='"',t++,n+=K,a(!1),O||t>=e.length||ci(e[t])||yi(e[t])||hn(e[t]))return y(),!0;const I=W(ie-1),D=e.charAt(I);if(D===",")return t=ae,n=n.substring(0,g),_(!1,I);if(ci(D))return t=ae,n=n.substring(0,g),_(!0);n=n.substring(0,g),t=ie+1,K=`${K.substring(0,Q)}\\${K.substring(Q)}`}else if(O&&Xu(e[t])){if(e[t-1]===":"&&Ku.test(e.substring(ae+1,t+2)))for(;t<e.length&&Yu.test(e[t]);)K+=e[t],t++;return K=Tt(K,'"'),n+=K,y(),!0}else if(e[t]==="\\"){const ie=e.charAt(t+1);if(iz[ie]!==void 0)K+=e.slice(t,t+2),t+=2;else if(ie==="u"){let I=2;for(;I<6&&GI(e[t+I]);)I++;I===6?(K+=e.slice(t,t+6),t+=6):t+I>=e.length?t=e.length:Y()}else K+=ie,t+=2}else{const ie=e.charAt(t);ie==='"'&&e[t-1]!=="\\"?(K+=`\\${ie}`,t++):XI(ie)?(K+=rz[ie],t++):(KI(ie)||R(ie),K+=ie,t++)}b&&p()}}return!1}function y(){let O=!1;for(a();e[t]==="+";){O=!0,t++,a(),n=hr(n,'"',!0);const G=n.length;_()?n=tz(n,G,1):n=Tt(n,'"')}return O}function P(){const O=t;if(e[t]==="-"){if(t++,E())return U(O),!0;if(!hn(e[t]))return t=O,!1}for(;hn(e[t]);)t++;if(e[t]==="."){if(t++,E())return U(O),!0;if(!hn(e[t]))return t=O,!1;for(;hn(e[t]);)t++}if(e[t]==="e"||e[t]==="E"){if(t++,(e[t]==="-"||e[t]==="+")&&t++,E())return U(O),!0;if(!hn(e[t]))return t=O,!1;for(;hn(e[t]);)t++}if(!E())return t=O,!1;if(t>O){const G=e.slice(O,t),b=/^0\d/.test(G);return n+=b?`"${G}"`:G,!0}return!1}function N(){return k("true","true")||k("false","false")||k("null","null")||k("True","true")||k("False","false")||k("None","null")}function k(O,G){return e.slice(t,t+O.length)===O?(n+=G,t+=O.length,!0):!1}function j(O){const G=t;if(Wu(e[t])){for(;t<e.length&&Gu(e[t]);)t++;let b=t;for(;xn(e,b);)b++;if(e[b]==="(")return t=b+1,s(),e[t]===")"&&(t++,e[t]===";"&&t++),!0}for(;t<e.length&&!Xu(e[t])&&!yi(e[t])&&(!O||e[t]!==":");)t++;if(e[t-1]===":"&&Ku.test(e.substring(G,t+2)))for(;t<e.length&&Yu.test(e[t]);)t++;if(t>G){for(;xn(e,t-1)&&t>0;)t--;const b=e.slice(G,t);return n+=b==="undefined"?"null":JSON.stringify(b),e[t]==='"'&&t++,!0}}function $(){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 W(O){let G=O;for(;G>0&&xn(e,G);)G--;return G}function E(){return t>=e.length||ci(e[t])||xn(e,t)}function U(O){n+=`${e.slice(O,t)}0`}function R(O){throw new Mn(`Invalid character ${JSON.stringify(O)}`,t)}function B(){throw new Mn(`Unexpected character ${JSON.stringify(e[t])}`,t)}function L(){throw new Mn("Unexpected end of json string",e.length)}function T(){throw new Mn("Object key expected",t)}function H(){throw new Mn("Colon expected",t)}function Y(){const O=e.slice(t,t+6);throw new Mn(`Invalid unicode character "${O}"`,t)}}function sz(e,t){return e[t]==="*"&&e[t+1]==="/"}function az({json:e,context:t,scope:n}){const[r,i]=v.useState(!1),[s,a]=v.useState(null),o=v.useMemo(()=>{try{return JSON.parse(e),e}catch{}try{return nc(e)}catch{}const x=`{${e}}`;try{return JSON.parse(x),x}catch{}try{return nc(x)}catch{return null}},[e]),l=v.useMemo(()=>qh(o||e),[o,e]),u=Ge(x=>x.activeTab),f=Ge(x=>x.documents),d=Ge(x=>(x.acceptedApplyIds||[]).includes(l)),h=Ge(x=>x.setPendingDiff),p=Ge(x=>x.createDocument),m=Ge(x=>x.openDocument),w=v.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(_),j=JSON.parse(o);if(Array.isArray(j.templates)){k.props||(k.props={}),k.props.templates=Hh(k.props.templates||[],j.templates);const $=JSON.stringify(k,null,2);h(u,_,$,l);return}}catch{}const y=t==null?void 0:t[0],{original:P,modified:N}=Wh(_,o,y);h(u,P,N,l)}else{const x=`ai-generated-${Date.now()}`;p(x,o),m(x)}}catch(x){a(x instanceof Error?x.message:"Merge failed")}}},[o,u,f,h,p,m,t,n,l]),S=v.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(Ie,{variant:"secondary",size:"sm",onClick:w,disabled:d||!o,children:d?"Applied":o?"Apply to Editor":"Invalid JSON"}),c.jsx(Ie,{variant:"ghost",size:"sm",onClick:S,children:r?c.jsx(Sn,{className:"h-3.5 w-3.5"}):c.jsx(Fa,{className:"h-3.5 w-3.5"})})]}),s&&c.jsx("p",{className:"text-xs text-destructive m-0",children:s})]})}function oz({threads:e,activeThread:t,disabled:n,onSwitch:r,onCreate:i,onDelete:s,onRename:a}){const[o,l]=v.useState(null),[u,f]=v.useState(""),[d,h]=v.useState(null),p=v.useRef(null),m=(t==null?void 0:t.title)||"New Chat",w=m.length>24?m.slice(0,24)+"...":m;v.useEffect(()=>{o&&requestAnimationFrame(()=>{var j;return(j=p.current)==null?void 0:j.focus()})},[o]);const S=v.useCallback((j,$)=>{$.stopPropagation(),$.preventDefault(),l(j.id),f(j.title),h(null)},[]),x=v.useCallback(()=>{o&&u.trim()&&a(o,u.trim()),l(null),f("")},[o,u,a]),_=v.useCallback(()=>{l(null),f("")},[]),y=v.useCallback(j=>{j.stopPropagation(),j.key==="Enter"?(j.preventDefault(),x()):j.key==="Escape"&&(j.preventDefault(),_())},[x,_]),P=v.useCallback((j,$)=>{$.stopPropagation(),$.preventDefault(),h(j),l(null)},[]),N=v.useCallback(j=>{j.stopPropagation(),j.preventDefault(),d&&(s(d),h(null))},[d,s]),k=v.useCallback(j=>{j.stopPropagation(),j.preventDefault(),h(null)},[]);return c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsxs(Fd,{onOpenChange:j=>{j||(l(null),h(null))},children:[c.jsx(Ld,{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(rn,{className:"h-3 w-3 shrink-0 opacity-60"})]})}),c.jsxs(Qa,{align:"start",className:"w-64",children:[e.map(j=>{const $=o===j.id;return d===j.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:N,children:c.jsx(Sn,{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(kn,{className:"h-3.5 w-3.5"})})]},j.id):$?c.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1",onClick:E=>E.stopPropagation(),onPointerDown:E=>E.stopPropagation(),children:[c.jsx("input",{ref:p,type:"text",value:u,onChange:E=>f(E.target.value),onKeyDown:y,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:E=>{E.preventDefault(),x()},children:c.jsx(Sn,{className:"h-3.5 w-3.5"})}),c.jsx("button",{className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onMouseDown:E=>{E.preventDefault(),_()},children:c.jsx(kn,{className:"h-3.5 w-3.5"})})]},j.id):c.jsxs(tn,{onSelect:()=>r(j.id),className:`group ${j.id===(t==null?void 0:t.id)?"bg-accent":""}`,children:[c.jsx("span",{className:"truncate flex-1",children:j.title.length>30?j.title.slice(0,30)+"...":j.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:E=>S(j,E),children:c.jsx(Ym,{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:E=>P(j.id,E),children:c.jsx(La,{className:"h-3 w-3"})})]})]},j.id)}),c.jsx(Ni,{}),c.jsxs(tn,{onSelect:j=>{j.preventDefault();const $=i();$&&(l($),f(Ka()),h(null))},children:[c.jsx(bi,{className:"h-3.5 w-3.5 mr-1.5"}),"New Chat"]})]})]}),c.jsx(Ie,{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(bi,{className:"h-3.5 w-3.5"})})]})}const tm=new Set(["image/png","image/jpeg","image/gif","image/webp","application/pdf","text/plain","text/markdown","text/csv","text/html"]),lz=Array.from(tm).join(","),uz=20*1024*1024,rc=10;function cz(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t({type:"file",mediaType:e.type,filename:e.name,url:r.result}),r.onerror=n,r.readAsDataURL(e)})}function ic(e){return Array.from(e).filter(t=>tm.has(t.type)&&t.size<=uz)}function nm(e){return e.startsWith("image/")}function sc(){var q,de,ve;const e=ze(A=>A.contextAttachments),t=ze(A=>A.addContext),n=ze(A=>A.removeContext),r=ze(A=>A.scope),i=ze(A=>A.setScope),s=ze(A=>A.model),a=ze(A=>A.setModel),o=ze(A=>A.openChat),l=ze(A=>A.closeChat),u=ze(A=>A.threads),f=ze(A=>A.activeThreadId),d=ze(A=>A.createThread),h=ze(A=>A.deleteThread),p=ze(A=>A.switchThread),m=ze(A=>A.updateThreadMessages),w=ze(A=>A.updateThreadTitle),S=ze(A=>A.deleteThreadsForDocument),x=Ge(A=>A.activeTab),_=Ge(A=>A.documents),{messages:y,sendMessage:P,status:N,error:k,setMessages:j,stop:$,getMessageContext:W,getMessageScope:E}=MI(),[U,R]=v.useState(""),[B,L]=v.useState([]),[T,H]=v.useState(!1),[Y,O]=v.useState(!1),G=v.useRef(null),b=v.useRef(null),ue=v.useRef(null),ae=v.useCallback(async A=>{const fe=ic(A);if(fe.length===0)return;const _e=await Promise.all(fe.map(cz));L(Re=>{const Ke=[...Re,..._e];return Ke.length>rc?Ke.slice(0,rc):Ke})},[]),g=v.useCallback(A=>{L(fe=>fe.filter((_e,Re)=>Re!==A))},[]),K=v.useCallback(A=>{var _e;const fe=(_e=A.clipboardData)==null?void 0:_e.files;if(fe&&fe.length>0){const Re=ic(fe);Re.length>0&&(A.preventDefault(),ae(Re))}},[ae]),ie=v.useCallback(A=>{var _e;A.preventDefault(),O(!1);const fe=(_e=A.dataTransfer)==null?void 0:_e.files;fe&&fe.length>0&&ae(Array.from(fe))},[ae]),Q=v.useCallback(A=>{A.preventDefault(),O(!0)},[]),I=v.useCallback(()=>O(!1),[]),D=x?f[x]:void 0,J=D?u[D]:void 0,oe=v.useMemo(()=>x?Object.values(u).filter(A=>A.documentName===x).sort((A,fe)=>fe.updatedAt-A.updatedAt):[],[u,x]);v.useEffect(()=>{x&&oe.length===0&&d(x)},[x,oe.length,d]);const pe=v.useRef(u);pe.current=u,v.useEffect(()=>{const A=new Set(_.map(_e=>_e.name)),fe=new Set;for(const _e of Object.values(pe.current))!A.has(_e.documentName)&&_e.documentName!=="__migrated__"&&fe.add(_e.documentName);for(const _e of fe)S(_e)},[_,S]);const Ae=v.useRef(null);v.useEffect(()=>{Ae.current!==D&&(Ae.current=D,j((J==null?void 0:J.messages)??[]))},[D,J,j]),v.useEffect(()=>{var A;(A=G.current)==null||A.scrollIntoView({behavior:"smooth"})},[y,N]),v.useEffect(()=>{const A=fe=>{var Ke;const{documentName:_e,selection:Re}=fe.detail;t({...Re,documentName:_e}),o(),(Ke=b.current)==null||Ke.focus()};return window.addEventListener("monaco-selection-to-ai",A),()=>window.removeEventListener("monaco-selection-to-ai",A)},[t,o]);const ke=N==="streaming",be=N==="submitted"||ke,it=v.useCallback(A=>{A.preventDefault(),!(!U.trim()&&B.length===0||be)&&(P(U,B.length>0?B:void 0),R(""),L([]))},[U,B,be,P]),St=v.useCallback(A=>{A.key==="Enter"&&!A.shiftKey&&(A.preventDefault(),it(A))},[it]),yt=v.useCallback(()=>{y.length!==0&&H(!0)},[y.length]),C=v.useCallback(()=>{H(!1),j([]),D&&(m(D,[]),w(D,Ka()))},[j,D,m,w]),[z,F]=v.useState(null),ne=v.useCallback(A=>{F(A)},[]),te=v.useCallback(()=>{var Ke,qe;if(!z)return;const A=y.findIndex(tt=>tt.id===z);if(A===-1){F(null);return}const fe=y[A],_e=new Set([A]);fe.role==="user"&&((Ke=y[A+1])==null?void 0:Ke.role)==="assistant"?_e.add(A+1):fe.role==="assistant"&&A>0&&((qe=y[A-1])==null?void 0:qe.role)==="user"&&_e.add(A-1);const Re=y.filter((tt,Gt)=>!_e.has(Gt));j(Re),D&&m(D,Re),F(null)},[z,y,j,D,m]),ee=v.useCallback(A=>{if(!be){if(oe.length<=1){yt();return}h(A)}},[be,oe.length,yt,h]),ce=v.useCallback(()=>{if(!(!x||be))return d(x)},[x,be,d]),xe=v.useCallback(A=>{be||A===D||p(A)},[be,D,p]),M=v.useCallback((A,fe)=>{w(A,fe)},[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(oz,{threads:oe,activeThread:J,disabled:be,onSwitch:xe,onCreate:ce,onDelete:ee,onRename:M}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(Ie,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:yt,disabled:be||y.length===0,children:"Clear"}),c.jsx(Ie,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:l,title:"Close chat",children:c.jsx(kn,{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:[y.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(Mo,{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(pa,{shortcut:"mod+k"}),c.jsx("span",{className:"text-xs text-muted-foreground",children:"to send a selection"})]})]}),y.map((A,fe)=>{let _e;if(A.role==="user"){const qe=W(A.id);qe&&qe.length>0&&(_e=qe)}else if(A.role==="assistant"){for(let qe=fe-1;qe>=0;qe--)if(y[qe].role==="user"){_e=W(y[qe].id);break}}const Re=ke&&fe===y.length-1&&A.role==="assistant",Ke=A.role==="user"?E(A.id):void 0;return c.jsx(dz,{msg:A,isStreaming:Re,context:_e,scope:Ke,onDelete:be?void 0:ne},A.id)}),be&&((q=y[y.length-1])==null?void 0:q.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(Xm,{className:"h-3.5 w-3.5 animate-spin text-primary"}),c.jsx("span",{children:"Thinking..."})]})})}),k&&!be&&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:G})]})}),c.jsxs("div",{className:`border-t border-border/60 p-2.5 space-y-2 bg-surface-chat transition-colors ${Y?"ring-2 ring-primary/40 bg-primary/5":""}`,onDrop:ie,onDragOver:Q,onDragLeave:I,children:[e.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.map((A,fe)=>c.jsx(Kh,{context:A,onRemove:()=>n(fe)},fe))}),c.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[c.jsx(hz,{model:s,setModel:a}),Nt==="pptx"&&x&&c.jsx(gz,{scope:r,setScope:i,docSize:((ve=(de=_.find(A=>A.name===x))==null?void 0:de.text)==null?void 0:ve.length)??0})]}),B.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1.5",children:B.map((A,fe)=>c.jsxs("div",{className:"relative group",children:[nm(A.mediaType)?c.jsx("img",{src:A.url,alt:A.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(Ys,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),c.jsx("span",{className:"text-xs truncate text-muted-foreground",children:A.filename||"file"})]}),c.jsx("button",{type:"button",onClick:()=>g(fe),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(kn,{className:"h-3 w-3"})})]},fe))}),c.jsxs("form",{onSubmit:it,className:"flex items-end gap-2",children:[c.jsx("input",{ref:ue,type:"file",accept:lz,multiple:!0,className:"hidden",onChange:A=>{A.target.files&&ae(Array.from(A.target.files)),A.target.value=""}}),c.jsx(Ie,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 h-9 w-9 rounded-lg text-muted-foreground hover:text-foreground",onClick:()=>{var A;return(A=ue.current)==null?void 0:A.click()},title:"Attach file",children:c.jsx(Ys,{className:"h-4 w-4"})}),c.jsx("textarea",{ref:b,value:U,onChange:A=>{R(A.target.value);const fe=A.target;fe.style.height="auto",fe.style.height=`${Math.min(fe.scrollHeight,128)}px`},onKeyDown:St,onPaste:K,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}),be?c.jsx(Ie,{type:"button",size:"icon",variant:"destructive",className:"shrink-0 h-9 w-9 rounded-lg",onClick:$,title:"Stop generating",children:c.jsx(Qm,{className:"h-4 w-4"})}):c.jsx(Ie,{type:"submit",size:"icon",disabled:!U.trim()&&B.length===0,className:"shrink-0 h-9 w-9 rounded-lg",children:c.jsx(Mo,{className:"h-4 w-4"})})]})]}),c.jsx(qt,{open:T,onOpenChange:H,children:c.jsxs(Zt,{className:"max-w-sm",children:[c.jsxs(_n,{children:[c.jsx(jn,{children:"Clear thread"}),c.jsx(Gn,{children:"This will delete all messages in this thread. This action cannot be undone."})]}),c.jsxs(Tr,{children:[c.jsx(Wo,{asChild:!0,children:c.jsx(Ie,{variant:"ghost",size:"sm",children:"Cancel"})}),c.jsx(Ie,{variant:"destructive",size:"sm",onClick:C,children:"Clear"})]})]})}),c.jsx(qt,{open:z!==null,onOpenChange:A=>{A||F(null)},children:c.jsxs(Zt,{className:"max-w-sm",children:[c.jsxs(_n,{children:[c.jsx(jn,{children:"Delete message"}),c.jsx(Gn,{children:"This will delete the message and its paired response. This action cannot be undone."})]}),c.jsxs(Tr,{children:[c.jsx(Wo,{asChild:!0,children:c.jsx(Ie,{variant:"ghost",size:"sm",children:"Cancel"})}),c.jsx(Ie,{variant:"destructive",size:"sm",onClick:te,children:"Delete"})]})]})})]})}const dz=v.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)=>nm(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(Ys,{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(Kh,{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(fz,{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(La,{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 fz({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(L0,{remarkPlugins:[QS],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(xz,{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(az,{json:l,context:n,scope:r})]})}},children:e})})}const pz=[{value:"opus",label:"Opus"},{value:"sonnet",label:"Sonnet"},{value:"haiku",label:"Haiku"}];function hz({model:e,setModel:t}){return c.jsxs(Wa,{value:e,onValueChange:n=>t(n),children:[c.jsx(Yi,{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(Ga,{})}),c.jsx(Xi,{children:pz.map(n=>c.jsx(Ar,{value:n.value,className:"text-xs",children:n.label},n.value))})]})}const ac={global:"AI sees and edits the entire document",slides:"AI sees and edits only slides — templates stay unchanged",templates:"AI sees and edits only template layouts — slides stay unchanged"},mz=1e5;function gz({scope:e,setScope:t,docSize:n}){return 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(ac).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:ac[r]})]},r))})]}),e==="global"&&n>mz&&c.jsxs("div",{className:"text-[10px] text-amber-500 flex items-center gap-1",children:[c.jsx(Kc,{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 xz({text:e}){const[t,n]=v.useState(!1),r=v.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 yz({discoveryData:e}){const t=Ed(),n=sx(),r=ze($=>$.chatOpen),i=ze($=>$.toggleChat),[s,a]=v.useState(()=>{try{const $=localStorage.getItem("dev-env.sidebar-open");return $?$==="true":!0}catch{return!0}}),[o,l]=v.useState(()=>{try{const $=localStorage.getItem("dev-env.preview-open");return $?$==="true":!0}catch{return!0}}),[u,f]=v.useState("editor"),[d,h]=v.useState(!1),p=120,[m,w]=v.useState(!s),[S,x]=v.useState(!1);v.useEffect(()=>{try{localStorage.setItem("dev-env.sidebar-open",String(s))}catch{}},[s]),v.useEffect(()=>{try{localStorage.setItem("dev-env.preview-open",String(o))}catch{}},[o]);const _=v.useRef(n);v.useEffect(()=>{n&&!_.current&&s&&(x(!0),setTimeout(()=>{a(!1),w(!0)},p)),!n&&_.current&&!s&&(x(!0),setTimeout(()=>{a(!0),w(!1)},p)),_.current=n},[n,s]);const y=v.useCallback(()=>{if(t){h($=>!$);return}x(!0),setTimeout(()=>{a($=>!$),w($=>!$)},p)},[t]),P=v.useCallback(()=>l($=>!$),[]),N=v.useRef(i),k=v.useRef(y),j=v.useRef(P);return v.useEffect(()=>{N.current=i}),v.useEffect(()=>{k.current=y}),v.useEffect(()=>{j.current=P}),v.useEffect(()=>{const $=W=>{(W.metaKey||W.ctrlKey)&&(W.code==="KeyB"&&!W.shiftKey&&(W.preventDefault(),k.current()),W.code==="KeyJ"&&W.shiftKey&&(W.preventDefault(),W.stopPropagation(),N.current()),W.code==="KeyP"&&W.shiftKey&&(W.preventDefault(),j.current()))};return window.addEventListener("keydown",$,!0),()=>window.removeEventListener("keydown",$,!0)},[]),t?c.jsx(qu,{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(Cd,{open:d,onOpenChange:h,children:[c.jsx(ex,{asChild:!0,children:c.jsx(Ie,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:c.jsx(Wc,{className:"h-4 w-4"})})}),c.jsx(Ya,{side:"left",className:"p-0 w-72",children:c.jsx(Yo,{discoveryData:e,onToggleSidebar:()=>h(!1),isCollapsed:!1})})]}),c.jsx("div",{className:"flex gap-0.5 flex-1 min-w-0",children:[{key:"editor",icon:Yc,label:"Editor"},{key:"preview",icon:Xc,label:"Preview"},{key:"chat",icon:Qc,label:"Chat"}].map(({key:$,icon:W,label:E})=>c.jsxs(Ie,{variant:u===$?"default":"ghost",size:"sm",className:"h-7 gap-1.5 text-xs flex-1",onClick:()=>f($),children:[c.jsx(W,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"hidden xs:inline",children:E})]},$))})]}),u!=="chat"&&c.jsx(dl,{previewOpen:o,onTogglePreview:P}),c.jsxs("div",{className:"flex-1 min-h-0",children:[u==="editor"&&c.jsx("div",{className:"h-full bg-surface-editor",children:c.jsx(Xo,{})}),u==="preview"&&c.jsx("div",{className:"h-full bg-surface-preview",children:c.jsx(Qo,{})}),u==="chat"&&c.jsx(sc,{})]})]})}):c.jsx(qu,{children:c.jsxs("div",{className:"flex h-full w-full overflow-hidden",children:[c.jsx("div",{className:V("shrink-0 overflow-hidden border-r bg-sidebar","transition-[width] duration-[280ms] ease-[cubic-bezier(0.22,1,0.36,1)]",s?"w-64":"w-10"),onTransitionEnd:$=>{$.propertyName==="width"&&$.target===$.currentTarget&&x(!1)},children:c.jsx(Yo,{discoveryData:e,onToggleSidebar:y,isCollapsed:m,isAnimating:S})}),c.jsxs("div",{className:"flex-1 min-w-0 flex flex-col h-full",children:[c.jsx(dl,{previewOpen:o,onTogglePreview:P}),c.jsxs(wy,{direction:"horizontal",autoSaveId:"layout-main",className:"flex-1 min-h-0",children:[c.jsx(Cs,{defaultSize:o?50:100,minSize:20,id:"editor",order:1,children:c.jsx("div",{className:"h-full bg-surface-editor",children:c.jsx(Xo,{})})}),o&&c.jsxs(c.Fragment,{children:[c.jsx(ul,{withHandle:!0}),c.jsx(Cs,{defaultSize:50,minSize:20,id:"preview",order:2,children:c.jsx("div",{className:"h-full bg-surface-preview",children:c.jsx(Qo,{})})})]}),r&&c.jsxs(c.Fragment,{children:[c.jsx(ul,{withHandle:!0}),c.jsx(Cs,{defaultSize:30,minSize:25,maxSize:50,id:"chat",order:3,children:c.jsx(sc,{})})]})]})]})]})})}function bz(){const[e,t]=v.useState(null),[n,r]=v.useState(!0),[i,s]=v.useState(null),a=v.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 v.useEffect(()=>{a()},[a]),{data:e,loading:n,error:i,refetch:a}}function vz(){const[e,t]=v.useState(!1),[n,r]=v.useState(null),[i,s]=v.useState(0);return{loadPlugins:v.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 wz(){const{data:e,loading:t,error:n}=bz(),{loadPlugins:r}=vz(),i=Pt(s=>s.applyPluginsWithValidation);return v.useEffect(()=>{e&&e.plugins.length>0&&r().then(s=>{if(s){console.log("Plugins loaded successfully");const a=Pt.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(ng,{children:c.jsx(rg,{children:c.jsx(ig,{children:c.jsx(sg,{children:c.jsx(ag,{children:c.jsx(Zg,{children:c.jsx(zd,{children:c.jsx("section",{className:"flex h-screen w-full flex-col",children:c.jsx("div",{className:"grow overflow-hidden",children:c.jsx(yz,{discoveryData:e})})})})})})})})})})}const Tz=Object.freeze(Object.defineProperty({__proto__:null,HomePage:wz},Symbol.toStringTag,{value:"Module"}));export{Nr as B,qt as D,Tz as H,Iy as P,Cr as S,da as T,$x as a,jd as b,Zt as c,_n as d,jn as e,Cy as u};
|
|
99
|
+
//# sourceMappingURL=HomePage-9ryiIVJl.js.map
|