@json-to-office/jto 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/cli.js +234 -49
  2. package/dist/cli.js.map +1 -1
  3. package/dist/client/assets/HomePage-DX_EbLqY.js +99 -0
  4. package/dist/client/assets/HomePage-DX_EbLqY.js.map +1 -0
  5. package/dist/client/assets/JsonEditorPage-C8a43kG2.js +3 -0
  6. package/dist/client/assets/JsonEditorPage-C8a43kG2.js.map +1 -0
  7. package/dist/client/assets/MonacoPluginProvider-C_k1zpkx.js +3 -0
  8. package/dist/client/assets/MonacoPluginProvider-C_k1zpkx.js.map +1 -0
  9. package/dist/client/assets/{NotFoundPage-Et1QhbQw.js → NotFoundPage-ILCklaD-.js} +2 -2
  10. package/dist/client/assets/{NotFoundPage-Et1QhbQw.js.map → NotFoundPage-ILCklaD-.js.map} +1 -1
  11. package/dist/client/assets/{button-CMkwEplC.js → button-DLt0WPRa.js} +2 -2
  12. package/dist/client/assets/{button-CMkwEplC.js.map → button-DLt0WPRa.js.map} +1 -1
  13. package/dist/client/assets/{docx-preview-CUjVWdSJ.js → docx-preview-DkKCgwb-.js} +2 -2
  14. package/dist/client/assets/{docx-preview-CUjVWdSJ.js.map → docx-preview-DkKCgwb-.js.map} +1 -1
  15. package/dist/client/assets/{editor-CtwF-qwA.js → editor-LsSIrw3S.js} +2 -2
  16. package/dist/client/assets/{editor-CtwF-qwA.js.map → editor-LsSIrw3S.js.map} +1 -1
  17. package/dist/client/assets/editor-monaco-json-CTzuM8w2.js +6 -0
  18. package/dist/client/assets/{editor-monaco-json-DHRbpQ-v.js.map → editor-monaco-json-CTzuM8w2.js.map} +1 -1
  19. package/dist/client/assets/index-Cph82KFG.css +1 -0
  20. package/dist/client/assets/index-CslfgN2g.js +3 -0
  21. package/dist/client/assets/index-CslfgN2g.js.map +1 -0
  22. package/dist/client/assets/{monaco-editor-DzeBDgmk.js → monaco-editor-B-NlkJ5A.js} +2 -2
  23. package/dist/client/assets/{monaco-editor-DzeBDgmk.js.map → monaco-editor-B-NlkJ5A.js.map} +1 -1
  24. package/dist/client/assets/preview-CeZ8u4Ec.js +3 -0
  25. package/dist/client/assets/{preview-38guLS86.js.map → preview-CeZ8u4Ec.js.map} +1 -1
  26. package/dist/client/assets/{query-vendor-UL64zsGL.js → query-vendor-CT0SoqJh.js} +2 -2
  27. package/dist/client/assets/{query-vendor-UL64zsGL.js.map → query-vendor-CT0SoqJh.js.map} +1 -1
  28. package/dist/client/assets/{radix-ui-CXavUarI.js → radix-ui-DkKm4m5M.js} +2 -2
  29. package/dist/client/assets/{radix-ui-CXavUarI.js.map → radix-ui-DkKm4m5M.js.map} +1 -1
  30. package/dist/client/assets/{react-vendor-DhdcN9D5.js → react-vendor-B_QXlk-T.js} +4 -4
  31. package/dist/client/assets/{react-vendor-DhdcN9D5.js.map → react-vendor-B_QXlk-T.js.map} +1 -1
  32. package/dist/client/assets/{state-vendor-CAMVKh-F.js → state-vendor-Az8redj0.js} +3 -3
  33. package/dist/client/assets/{state-vendor-CAMVKh-F.js.map → state-vendor-Az8redj0.js.map} +1 -1
  34. package/dist/client/assets/{ui-vendor-C6DsfOoA.js → ui-vendor-ChWVh3T-.js} +48 -43
  35. package/dist/client/assets/ui-vendor-ChWVh3T-.js.map +1 -0
  36. package/dist/client/index.html +7 -8
  37. package/dist/index.d.ts +8 -3
  38. package/dist/index.js +110 -19
  39. package/dist/index.js.map +1 -1
  40. package/package.json +6 -6
  41. package/dist/client/assets/HomePage-D9PVR0H8.js +0 -99
  42. package/dist/client/assets/HomePage-D9PVR0H8.js.map +0 -1
  43. package/dist/client/assets/JsonEditorPage-bCBt1A49.js +0 -3
  44. package/dist/client/assets/JsonEditorPage-bCBt1A49.js.map +0 -1
  45. package/dist/client/assets/editor-monaco-json-DHRbpQ-v.js +0 -6
  46. package/dist/client/assets/index-B9dV-vCI.css +0 -1
  47. package/dist/client/assets/index-CGQAncgl.js +0 -3
  48. package/dist/client/assets/index-CGQAncgl.js.map +0 -1
  49. package/dist/client/assets/preview-38guLS86.js +0 -3
  50. package/dist/client/assets/settings-store-provider-BEzje7_o.js +0 -2
  51. package/dist/client/assets/settings-store-provider-BEzje7_o.js.map +0 -1
  52. package/dist/client/assets/ui-vendor-C6DsfOoA.js.map +0 -1
@@ -0,0 +1,99 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-LsSIrw3S.js","assets/query-vendor-CT0SoqJh.js","assets/react-vendor-B_QXlk-T.js","assets/radix-ui-DkKm4m5M.js","assets/editor-monaco-json-CTzuM8w2.js","assets/index-CslfgN2g.js","assets/ui-vendor-ChWVh3T-.js","assets/monaco-editor-B-NlkJ5A.js","assets/index-Cph82KFG.css","assets/MonacoPluginProvider-C_k1zpkx.js","assets/state-vendor-Az8redj0.js","assets/button-DLt0WPRa.js","assets/preview-CeZ8u4Ec.js"])))=>i.map(i=>d[i]);
2
+ var Lp=Object.defineProperty;var Zp=(e,t,n)=>t in e?Lp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Wa=(e,t,n)=>Zp(e,typeof t!="symbol"?t+"":t,n);import{j as c,b as Vp}from"./query-vendor-CT0SoqJh.js";import{a as je,f as hu,h as na,i as mu,r as x,j as gu,k as gi,l as xi,D as yi,m as bi,n as xu,o as Bp,V as Up,p as yu,I as Jp,q as qp,s as bu,t as Hp,v as vu,w as Wp,x as Gp,G as Kp,S as wu,y as ku,L as _u,z as Su,A as Yp,E as Xp,F as Qp,H as ju,J as Nu,K as Cu,M as Eu,N as Iu,Q as Tu,U as Au,W as zu,X as Ou,Y as Pu,Z as Du,_ as eh,$ as th,a0 as Ru,a1 as nh,a2 as rh,a3 as ih,a4 as sh,a5 as ah,a6 as oh,a7 as lh,a8 as uh,a9 as ch,aa as Mu,ab as Fu,ac as $u,ad as Lu,ae as Zu,af as Vu,ag as Bu,ah as Uu,ai as Ju,aj as dh,ak as qu,al as Hu,am as Wu,an as fh,ao as ph,ap as hh,g as ra}from"./react-vendor-B_QXlk-T.js";import{B as Ne}from"./button-DLt0WPRa.js";import{c as L,T as Cr,C as mh,E as gh,F as vt,S as qt,a as xh,b as Ge,d as Ke,e as Ye,u as Gu,f as ia,s as Mi,_ as Ku,g as Er,A as yh,h as Ir}from"./index-CslfgN2g.js";import{X as dn,a as vr,C as Gt,b as fn,d as bh,e as vi,f as Yu,P as vh,g as Ga,h as Gn,F as Xu,S as Qu,B as Ka,i as wh,j as kh,k as _h,l as sa,m as Sh,M as jh,n as Nh,o as Ch,p as ec,q as Eh,r as Fi,s as Wr,t as Ya,I as tc,G as Ih,u as Th,R as Ah,v as zh,T as nc,E as Oh,w as Ph,x as Dh,y as rc,z as aa,A as ic,D as Rh,H as sc,J as Mh,K as Fh,L as Xa,N as $h,O as ys,Q as Lh}from"./ui-vendor-ChWVh3T-.js";import{S as Rn}from"./radix-ui-DkKm4m5M.js";import{i as Zh,u as qe,a as bs,b as on,g as vs,c as Nt,T as Vh,d as Tr,S as Bh,O as Uh,e as Jh,M as qh,D as Hh}from"./MonacoPluginProvider-C_k1zpkx.js";import{c as Wh,d as Gh,p as Kh,a as Yh,u as Xh,b as Qh}from"./state-vendor-Az8redj0.js";var wr=e=>e.type==="checkbox",cn=e=>e instanceof Date,at=e=>e==null;const ac=e=>typeof e=="object";var Be=e=>!at(e)&&!Array.isArray(e)&&ac(e)&&!cn(e),oc=e=>Be(e)&&e.target?wr(e.target)?e.target.checked:e.target.value:e,em=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,lc=(e,t)=>e.has(em(t)),tm=e=>{const t=e.constructor&&e.constructor.prototype;return Be(t)&&t.hasOwnProperty("isPrototypeOf")},oa=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function ct(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(!(oa&&(e instanceof Blob||r))&&(n||Be(e)))if(t=n?[]:{},!n&&!tm(e))t=e;else for(const i in e)e.hasOwnProperty(i)&&(t[i]=ct(e[i]));else return e;return t}var wi=e=>Array.isArray(e)?e.filter(Boolean):[],Ve=e=>e===void 0,te=(e,t,n)=>{if(!t||!Be(e))return n;const r=wi(t.split(/[,[\].]+?/)).reduce((i,s)=>at(i)?i:i[s],e);return Ve(r)||r===e?Ve(e[t])?n:e[t]:r},yt=e=>typeof e=="boolean",la=e=>/^\w*$/.test(e),uc=e=>wi(e.replace(/["|']|\]/g,"").split(/\.|\[/)),Te=(e,t,n)=>{let r=-1;const i=la(t)?[t]:uc(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=Be(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 Gr={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},jt={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},$t={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},cc=je.createContext(null),ki=()=>je.useContext(cc),nm=e=>{const{children:t,...n}=e;return je.createElement(cc.Provider,{value:n},t)};var dc=(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]!==jt.all&&(t._proxyFormState[a]=!r||jt.all),n&&(n[a]=!0),e[a]}});return i},dt=e=>Be(e)&&!Object.keys(e).length,fc=(e,t,n,r)=>{n(e);const{name:i,...s}=e;return dt(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(a=>t[a]===(!r||jt.all))},nr=e=>Array.isArray(e)?e:[e],pc=(e,t,n)=>!e||!t||e===t||nr(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r)));function ua(e){const t=je.useRef(e);t.current=e,je.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}function rm(e){const t=ki(),{control:n=t.control,disabled:r,name:i,exact:s}=e||{},[a,o]=je.useState(n._formState),l=je.useRef(!0),u=je.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),d=je.useRef(i);return d.current=i,ua({disabled:r,next:f=>l.current&&pc(d.current,f.name,s)&&fc(f,u.current,n._updateFormState)&&o({...n._formState,...f}),subject:n._subjects.state}),je.useEffect(()=>(l.current=!0,u.current.isValid&&n._updateValid(!0),()=>{l.current=!1}),[n]),je.useMemo(()=>dc(a,n,u.current,!1),[a,n])}var zt=e=>typeof e=="string",hc=(e,t,n,r,i)=>zt(e)?(r&&t.watch.add(e),te(n,e,i)):Array.isArray(e)?e.map(s=>(r&&t.watch.add(s),te(n,s))):(r&&(t.watchAll=!0),n);function im(e){const t=ki(),{control:n=t.control,name:r,defaultValue:i,disabled:s,exact:a}=e||{},o=je.useRef(r);o.current=r,ua({disabled:s,subject:n._subjects.values,next:d=>{pc(o.current,d.name,a)&&u(ct(hc(o.current,n._names,d.values||n._formValues,!1,i)))}});const[l,u]=je.useState(n._getWatch(r,i));return je.useEffect(()=>n._removeUnmounted()),l}function sm(e){const t=ki(),{name:n,disabled:r,control:i=t.control,shouldUnregister:s}=e,a=lc(i._names.array,n),o=im({control:i,name:n,defaultValue:te(i._formValues,n,te(i._defaultValues,n,e.defaultValue)),exact:!0}),l=rm({control:i,name:n,exact:!0}),u=je.useRef(i.register(n,{...e.rules,value:o,...yt(e.disabled)?{disabled:e.disabled}:{}})),d=je.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!te(l.errors,n)},isDirty:{enumerable:!0,get:()=>!!te(l.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!te(l.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!te(l.validatingFields,n)},error:{enumerable:!0,get:()=>te(l.errors,n)}}),[l,n]),f=je.useMemo(()=>({name:n,value:o,...yt(r)||l.disabled?{disabled:l.disabled||r}:{},onChange:h=>u.current.onChange({target:{value:oc(h),name:n},type:Gr.CHANGE}),onBlur:()=>u.current.onBlur({target:{value:te(i._formValues,n),name:n},type:Gr.BLUR}),ref:h=>{const p=te(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 je.useEffect(()=>{const h=i._options.shouldUnregister||s,p=(m,w)=>{const S=te(i._fields,m);S&&S._f&&(S._f.mount=w)};if(p(n,!0),h){const m=ct(te(i._options.defaultValues,n));Te(i._defaultValues,n,m),Ve(te(i._formValues,n))&&Te(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]),je.useEffect(()=>{i._updateDisabledField({disabled:r,fields:i._fields,name:n})},[r,n,i]),je.useMemo(()=>({field:f,formState:l,fieldState:d}),[f,l,d])}const am=e=>e.render(sm(e));var om=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},Qa=e=>({isOnSubmit:!e||e===jt.onSubmit,isOnBlur:e===jt.onBlur,isOnChange:e===jt.onChange,isOnAll:e===jt.all,isOnTouch:e===jt.onTouched}),eo=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const rr=(e,t,n,r)=>{for(const i of n||Object.keys(e)){const s=te(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(rr(o,t))break}else if(Be(o)&&rr(o,t))break}}};var lm=(e,t,n)=>{const r=nr(te(e,n));return Te(r,"root",t[n]),Te(e,n,r),e},ca=e=>e.type==="file",At=e=>typeof e=="function",Kr=e=>{if(!oa)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Lr=e=>zt(e),da=e=>e.type==="radio",Yr=e=>e instanceof RegExp;const to={value:!1,isValid:!1},no={value:!0,isValid:!0};var mc=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&&!Ve(e[0].attributes.value)?Ve(e[0].value)||e[0].value===""?no:{value:e[0].value,isValid:!0}:no:to}return to};const ro={isValid:!1,value:null};var gc=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,ro):ro;function io(e,t,n="validate"){if(Lr(e)||Array.isArray(e)&&e.every(Lr)||yt(e)&&!e)return{type:n,message:Lr(e)?e:"",ref:t}}var bn=e=>Be(e)&&!Yr(e)?e:{value:e,message:""},so=async(e,t,n,r,i,s)=>{const{ref:a,refs:o,required:l,maxLength:u,minLength:d,min:f,max:h,pattern:p,validate:m,name:w,valueAsNumber:S,mount:b}=e._f,_=te(n,w);if(!b||t.has(w))return{};const g=o?o[0]:a,D=$=>{i&&g.reportValidity&&(g.setCustomValidity(yt($)?"":$||""),g.reportValidity())},E={},k=da(a),N=wr(a),F=k||N,K=(S||ca(a))&&Ve(a.value)&&Ve(_)||Kr(a)&&a.value===""||_===""||Array.isArray(_)&&!_.length,C=om.bind(null,w,r,E),q=($,V,Z,O=$t.maxLength,Y=$t.minLength)=>{const H=$?V:Z;E[w]={type:$?O:Y,message:H,ref:a,...C($?O:Y,H)}};if(s?!Array.isArray(_)||!_.length:l&&(!F&&(K||at(_))||yt(_)&&!_||N&&!mc(o).isValid||k&&!gc(o).isValid)){const{value:$,message:V}=Lr(l)?{value:!!l,message:l}:bn(l);if($&&(E[w]={type:$t.required,message:V,ref:g,...C($t.required,V)},!r))return D(V),E}if(!K&&(!at(f)||!at(h))){let $,V;const Z=bn(h),O=bn(f);if(!at(_)&&!isNaN(_)){const Y=a.valueAsNumber||_&&+_;at(Z.value)||($=Y>Z.value),at(O.value)||(V=Y<O.value)}else{const Y=a.valueAsDate||new Date(_),H=y=>new Date(new Date().toDateString()+" "+y),z=a.type=="time",J=a.type=="week";zt(Z.value)&&_&&($=z?H(_)>H(Z.value):J?_>Z.value:Y>new Date(Z.value)),zt(O.value)&&_&&(V=z?H(_)<H(O.value):J?_<O.value:Y<new Date(O.value))}if(($||V)&&(q(!!$,Z.message,O.message,$t.max,$t.min),!r))return D(E[w].message),E}if((u||d)&&!K&&(zt(_)||s&&Array.isArray(_))){const $=bn(u),V=bn(d),Z=!at($.value)&&_.length>+$.value,O=!at(V.value)&&_.length<+V.value;if((Z||O)&&(q(Z,$.message,V.message),!r))return D(E[w].message),E}if(p&&!K&&zt(_)){const{value:$,message:V}=bn(p);if(Yr($)&&!_.match($)&&(E[w]={type:$t.pattern,message:V,ref:a,...C($t.pattern,V)},!r))return D(V),E}if(m){if(At(m)){const $=await m(_,n),V=io($,g);if(V&&(E[w]={...V,...C($t.validate,V.message)},!r))return D(V.message),E}else if(Be(m)){let $={};for(const V in m){if(!dt($)&&!r)break;const Z=io(await m[V](_,n),g,V);Z&&($={...Z,...C(V,Z.message)},D(Z.message),r&&(E[w]=$))}if(!dt($)&&(E[w]={ref:g,...$},!r))return E}}return D(!0),E};function um(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=Ve(e)?r++:e[t[r++]];return e}function cm(e){for(const t in e)if(e.hasOwnProperty(t)&&!Ve(e[t]))return!1;return!0}function We(e,t){const n=Array.isArray(t)?t:la(t)?[t]:uc(t),r=n.length===1?e:um(e,n),i=n.length-1,s=n[i];return r&&delete r[s],i!==0&&(Be(r)&&dt(r)||Array.isArray(r)&&cm(r))&&We(e,n.slice(0,-1)),e}var $i=()=>{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=[]}}},ws=e=>at(e)||!ac(e);function Ht(e,t){if(ws(e)||ws(t))return e===t;if(cn(e)&&cn(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(cn(s)&&cn(a)||Be(s)&&Be(a)||Array.isArray(s)&&Array.isArray(a)?!Ht(s,a):s!==a)return!1}}return!0}var xc=e=>e.type==="select-multiple",dm=e=>da(e)||wr(e),Li=e=>Kr(e)&&e.isConnected,yc=e=>{for(const t in e)if(At(e[t]))return!0;return!1};function Xr(e,t={}){const n=Array.isArray(e);if(Be(e)||n)for(const r in e)Array.isArray(e[r])||Be(e[r])&&!yc(e[r])?(t[r]=Array.isArray(e[r])?[]:{},Xr(e[r],t[r])):at(e[r])||(t[r]=!0);return t}function bc(e,t,n){const r=Array.isArray(e);if(Be(e)||r)for(const i in e)Array.isArray(e[i])||Be(e[i])&&!yc(e[i])?Ve(t)||ws(n[i])?n[i]=Array.isArray(e[i])?Xr(e[i],[]):{...Xr(e[i])}:bc(e[i],at(t)?{}:t[i],n[i]):n[i]=!Ht(e[i],t[i]);return n}var Zn=(e,t)=>bc(e,t,Xr(t)),vc=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>Ve(e)?e:t?e===""?NaN:e&&+e:n&&zt(e)?new Date(e):r?r(e):e;function Zi(e){const t=e.ref;return ca(t)?t.files:da(t)?gc(e.refs).value:xc(t)?[...t.selectedOptions].map(({value:n})=>n):wr(t)?mc(e.refs).value:vc(Ve(t.value)?e.ref.value:t.value,e)}var fm=(e,t,n,r)=>{const i={};for(const s of e){const a=te(t,s);a&&Te(i,s,a._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},Vn=e=>Ve(e)?e:Yr(e)?e.source:Be(e)?Yr(e.value)?e.value.source:e.value:e;const ao="AsyncFunction";var pm=e=>!!e&&!!e.validate&&!!(At(e.validate)&&e.validate.constructor.name===ao||Be(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===ao)),hm=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function oo(e,t,n){const r=te(e,n);if(r||la(n))return{error:r,name:n};const i=n.split(".");for(;i.length;){const s=i.join("."),a=te(t,s),o=te(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 mm=(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,gm=(e,t)=>!wi(te(e,t)).length&&We(e,t);const xm={mode:jt.onSubmit,reValidateMode:jt.onChange,shouldFocusError:!0};function ym(e={}){let t={...xm,...e},n={submitCount:0,isDirty:!1,isLoading:At(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},i=Be(t.defaultValues)||Be(t.values)?ct(t.defaultValues||t.values)||{}:{},s=t.shouldUnregister?{}:ct(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 d={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={values:$i(),array:$i(),state:$i()},h=Qa(t.mode),p=Qa(t.reValidateMode),m=t.criteriaMode===jt.all,w=j=>I=>{clearTimeout(u),u=setTimeout(j,I)},S=async j=>{if(!t.disabled&&(d.isValid||j)){const I=t.resolver?dt((await F()).errors):await C(r,!0);I!==n.isValid&&f.state.next({isValid:I})}},b=(j,I)=>{!t.disabled&&(d.isValidating||d.validatingFields)&&((j||Array.from(o.mount)).forEach(P=>{P&&(I?Te(n.validatingFields,P,I):We(n.validatingFields,P))}),f.state.next({validatingFields:n.validatingFields,isValidating:!dt(n.validatingFields)}))},_=(j,I=[],P,ne,X=!0,G=!0)=>{if(ne&&P&&!t.disabled){if(a.action=!0,G&&Array.isArray(te(r,j))){const ae=P(te(r,j),ne.argA,ne.argB);X&&Te(r,j,ae)}if(G&&Array.isArray(te(n.errors,j))){const ae=P(te(n.errors,j),ne.argA,ne.argB);X&&Te(n.errors,j,ae),gm(n.errors,j)}if(d.touchedFields&&G&&Array.isArray(te(n.touchedFields,j))){const ae=P(te(n.touchedFields,j),ne.argA,ne.argB);X&&Te(n.touchedFields,j,ae)}d.dirtyFields&&(n.dirtyFields=Zn(i,s)),f.state.next({name:j,isDirty:$(j,I),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Te(s,j,I)},g=(j,I)=>{Te(n.errors,j,I),f.state.next({errors:n.errors})},D=j=>{n.errors=j,f.state.next({errors:n.errors,isValid:!1})},E=(j,I,P,ne)=>{const X=te(r,j);if(X){const G=te(s,j,Ve(P)?te(i,j):P);Ve(G)||ne&&ne.defaultChecked||I?Te(s,j,I?G:Zi(X._f)):O(j,G),a.mount&&S()}},k=(j,I,P,ne,X)=>{let G=!1,ae=!1;const me={name:j};if(!t.disabled){const A=!!(te(r,j)&&te(r,j)._f&&te(r,j)._f.disabled);if(!P||ne){d.isDirty&&(ae=n.isDirty,n.isDirty=me.isDirty=$(),G=ae!==me.isDirty);const U=A||Ht(te(i,j),I);ae=!!(!A&&te(n.dirtyFields,j)),U||A?We(n.dirtyFields,j):Te(n.dirtyFields,j,!0),me.dirtyFields=n.dirtyFields,G=G||d.dirtyFields&&ae!==!U}if(P){const U=te(n.touchedFields,j);U||(Te(n.touchedFields,j,P),me.touchedFields=n.touchedFields,G=G||d.touchedFields&&U!==P)}G&&X&&f.state.next(me)}return G?me:{}},N=(j,I,P,ne)=>{const X=te(n.errors,j),G=d.isValid&&yt(I)&&n.isValid!==I;if(t.delayError&&P?(l=w(()=>g(j,P)),l(t.delayError)):(clearTimeout(u),l=null,P?Te(n.errors,j,P):We(n.errors,j)),(P?!Ht(X,P):X)||!dt(ne)||G){const ae={...ne,...G&&yt(I)?{isValid:I}:{},errors:n.errors,name:j};n={...n,...ae},f.state.next(ae)}},F=async j=>{b(j,!0);const I=await t.resolver(s,t.context,fm(j||o.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return b(j),I},K=async j=>{const{errors:I}=await F(j);if(j)for(const P of j){const ne=te(I,P);ne?Te(n.errors,P,ne):We(n.errors,P)}else n.errors=I;return I},C=async(j,I,P={valid:!0})=>{for(const ne in j){const X=j[ne];if(X){const{_f:G,...ae}=X;if(G){const me=o.array.has(G.name),A=X._f&&pm(X._f);A&&d.validatingFields&&b([ne],!0);const U=await so(X,o.disabled,s,m,t.shouldUseNativeValidation&&!I,me);if(A&&d.validatingFields&&b([ne]),U[G.name]&&(P.valid=!1,I))break;!I&&(te(U,G.name)?me?lm(n.errors,U,G.name):Te(n.errors,G.name,U[G.name]):We(n.errors,G.name))}!dt(ae)&&await C(ae,I,P)}}return P.valid},q=()=>{for(const j of o.unMount){const I=te(r,j);I&&(I._f.refs?I._f.refs.every(P=>!Li(P)):!Li(I._f.ref))&&fe(j)}o.unMount=new Set},$=(j,I)=>!t.disabled&&(j&&I&&Te(s,j,I),!Ht(ue(),i)),V=(j,I,P)=>hc(j,o,{...a.mount?s:Ve(I)?i:zt(j)?{[j]:I}:I},P,I),Z=j=>wi(te(a.mount?s:i,j,t.shouldUnregister?te(i,j,[]):[])),O=(j,I,P={})=>{const ne=te(r,j);let X=I;if(ne){const G=ne._f;G&&(!G.disabled&&Te(s,j,vc(I,G)),X=Kr(G.ref)&&at(I)?"":I,xc(G.ref)?[...G.ref.options].forEach(ae=>ae.selected=X.includes(ae.value)):G.refs?wr(G.ref)?G.refs.length>1?G.refs.forEach(ae=>(!ae.defaultChecked||!ae.disabled)&&(ae.checked=Array.isArray(X)?!!X.find(me=>me===ae.value):X===ae.value)):G.refs[0]&&(G.refs[0].checked=!!X):G.refs.forEach(ae=>ae.checked=ae.value===X):ca(G.ref)?G.ref.value="":(G.ref.value=X,G.ref.type||f.values.next({name:j,values:{...s}})))}(P.shouldDirty||P.shouldTouch)&&k(j,X,P.shouldTouch,P.shouldDirty,!0),P.shouldValidate&&y(j)},Y=(j,I,P)=>{for(const ne in I){const X=I[ne],G=`${j}.${ne}`,ae=te(r,G);(o.array.has(j)||Be(X)||ae&&!ae._f)&&!cn(X)?Y(G,X,P):O(G,X,P)}},H=(j,I,P={})=>{const ne=te(r,j),X=o.array.has(j),G=ct(I);Te(s,j,G),X?(f.array.next({name:j,values:{...s}}),(d.isDirty||d.dirtyFields)&&P.shouldDirty&&f.state.next({name:j,dirtyFields:Zn(i,s),isDirty:$(j,G)})):ne&&!ne._f&&!at(G)?Y(j,G,P):O(j,G,P),eo(j,o)&&f.state.next({...n}),f.values.next({name:a.mount?j:void 0,values:{...s}})},z=async j=>{a.mount=!0;const I=j.target;let P=I.name,ne=!0;const X=te(r,P),G=()=>I.type?Zi(X._f):oc(j),ae=me=>{ne=Number.isNaN(me)||cn(me)&&isNaN(me.getTime())||Ht(me,te(s,P,me))};if(X){let me,A;const U=G(),oe=j.type===Gr.BLUR||j.type===Gr.FOCUS_OUT,ye=!hm(X._f)&&!t.resolver&&!te(n.errors,P)&&!X._f.deps||mm(oe,te(n.touchedFields,P),n.isSubmitted,p,h),T=eo(P,o,oe);Te(s,P,U),oe?(X._f.onBlur&&X._f.onBlur(j),l&&l(0)):X._f.onChange&&X._f.onChange(j);const le=k(P,U,oe,!1),we=!dt(le)||T;if(!oe&&f.values.next({name:P,type:j.type,values:{...s}}),ye)return d.isValid&&(t.mode==="onBlur"&&oe?S():oe||S()),we&&f.state.next({name:P,...T?{}:le});if(!oe&&T&&f.state.next({...n}),t.resolver){const{errors:Oe}=await F([P]);if(ae(U),ne){const He=oo(n.errors,r,P),Ue=oo(Oe,r,He.name||P);me=Ue.error,P=Ue.name,A=dt(Oe)}}else b([P],!0),me=(await so(X,o.disabled,s,m,t.shouldUseNativeValidation))[P],b([P]),ae(U),ne&&(me?A=!1:d.isValid&&(A=await C(r,!0)));ne&&(X._f.deps&&y(X._f.deps),N(P,A,me,le))}},J=(j,I)=>{if(te(n.errors,I)&&j.focus)return j.focus(),1},y=async(j,I={})=>{let P,ne;const X=nr(j);if(t.resolver){const G=await K(Ve(j)?j:X);P=dt(G),ne=j?!X.some(ae=>te(G,ae)):P}else j?(ne=(await Promise.all(X.map(async G=>{const ae=te(r,G);return await C(ae&&ae._f?{[G]:ae}:ae)}))).every(Boolean),!(!ne&&!n.isValid)&&S()):ne=P=await C(r);return f.state.next({...!zt(j)||d.isValid&&P!==n.isValid?{}:{name:j},...t.resolver||!j?{isValid:P}:{},errors:n.errors}),I.shouldFocus&&!ne&&rr(r,J,j?X:o.mount),ne},ue=j=>{const I={...a.mount?s:i};return Ve(j)?I:zt(j)?te(I,j):j.map(P=>te(I,P))},re=(j,I)=>({invalid:!!te((I||n).errors,j),isDirty:!!te((I||n).dirtyFields,j),error:te((I||n).errors,j),isValidating:!!te(n.validatingFields,j),isTouched:!!te((I||n).touchedFields,j)}),v=j=>{j&&nr(j).forEach(I=>We(n.errors,I)),f.state.next({errors:j?n.errors:{}})},se=(j,I,P)=>{const ne=(te(r,j,{_f:{}})._f||{}).ref,X=te(n.errors,j)||{},{ref:G,message:ae,type:me,...A}=X;Te(n.errors,j,{...A,...I,ref:ne}),f.state.next({name:j,errors:n.errors,isValid:!1}),P&&P.shouldFocus&&ne&&ne.focus&&ne.focus()},be=(j,I)=>At(j)?f.values.subscribe({next:P=>j(V(void 0,I),P)}):V(j,I,!0),fe=(j,I={})=>{for(const P of j?nr(j):o.mount)o.mount.delete(P),o.array.delete(P),I.keepValue||(We(r,P),We(s,P)),!I.keepError&&We(n.errors,P),!I.keepDirty&&We(n.dirtyFields,P),!I.keepTouched&&We(n.touchedFields,P),!I.keepIsValidating&&We(n.validatingFields,P),!t.shouldUnregister&&!I.keepDefaultValue&&We(i,P);f.values.next({values:{...s}}),f.state.next({...n,...I.keepDirty?{isDirty:$()}:{}}),!I.keepIsValid&&S()},M=({disabled:j,name:I,field:P,fields:ne})=>{(yt(j)&&a.mount||j||o.disabled.has(I))&&(j?o.disabled.add(I):o.disabled.delete(I),k(I,Zi(P?P._f:te(ne,I)._f),!1,!1,!0))},B=(j,I={})=>{let P=te(r,j);const ne=yt(I.disabled)||yt(t.disabled);return Te(r,j,{...P||{},_f:{...P&&P._f?P._f:{ref:{name:j}},name:j,mount:!0,...I}}),o.mount.add(j),P?M({field:P,disabled:yt(I.disabled)?I.disabled:t.disabled,name:j}):E(j,!0,I.value),{...ne?{disabled:I.disabled||t.disabled}:{},...t.progressive?{required:!!I.required,min:Vn(I.min),max:Vn(I.max),minLength:Vn(I.minLength),maxLength:Vn(I.maxLength),pattern:Vn(I.pattern)}:{},name:j,onChange:z,onBlur:z,ref:X=>{if(X){B(j,I),P=te(r,j);const G=Ve(X.value)&&X.querySelectorAll&&X.querySelectorAll("input,select,textarea")[0]||X,ae=dm(G),me=P._f.refs||[];if(ae?me.find(A=>A===G):G===P._f.ref)return;Te(r,j,{_f:{...P._f,...ae?{refs:[...me.filter(Li),G,...Array.isArray(te(i,j))?[{}]:[]],ref:{type:G.type,name:j}}:{ref:G}}}),E(j,!1,void 0,G)}else P=te(r,j,{}),P._f&&(P._f.mount=!1),(t.shouldUnregister||I.shouldUnregister)&&!(lc(o.array,j)&&a.action)&&o.unMount.add(j)}}},ee=()=>t.shouldFocusError&&rr(r,J,o.mount),pe=j=>{yt(j)&&(f.state.next({disabled:j}),rr(r,(I,P)=>{const ne=te(r,P);ne&&(I.disabled=ne._f.disabled||j,Array.isArray(ne._f.refs)&&ne._f.refs.forEach(X=>{X.disabled=ne._f.disabled||j}))},0,!1))},ge=(j,I)=>async P=>{let ne;P&&(P.preventDefault&&P.preventDefault(),P.persist&&P.persist());let X=ct(s);if(o.disabled.size)for(const G of o.disabled)Te(X,G,void 0);if(f.state.next({isSubmitting:!0}),t.resolver){const{errors:G,values:ae}=await F();n.errors=G,X=ae}else await C(r);if(We(n.errors,"root"),dt(n.errors)){f.state.next({errors:{}});try{await j(X,P)}catch(G){ne=G}}else I&&await I({...n.errors},P),ee(),setTimeout(ee);if(f.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:dt(n.errors)&&!ne,submitCount:n.submitCount+1,errors:n.errors}),ne)throw ne},Xe=(j,I={})=>{te(r,j)&&(Ve(I.defaultValue)?H(j,ct(te(i,j))):(H(j,I.defaultValue),Te(i,j,ct(I.defaultValue))),I.keepTouched||We(n.touchedFields,j),I.keepDirty||(We(n.dirtyFields,j),n.isDirty=I.defaultValue?$(j,ct(te(i,j))):$()),I.keepError||(We(n.errors,j),d.isValid&&S()),f.state.next({...n}))},nt=(j,I={})=>{const P=j?ct(j):i,ne=ct(P),X=dt(j),G=X?i:ne;if(I.keepDefaultValues||(i=P),!I.keepValues){if(I.keepDirtyValues){const ae=new Set([...o.mount,...Object.keys(Zn(i,s))]);for(const me of Array.from(ae))te(n.dirtyFields,me)?Te(G,me,te(s,me)):H(me,te(G,me))}else{if(oa&&Ve(j))for(const ae of o.mount){const me=te(r,ae);if(me&&me._f){const A=Array.isArray(me._f.refs)?me._f.refs[0]:me._f.ref;if(Kr(A)){const U=A.closest("form");if(U){U.reset();break}}}}r={}}s=t.shouldUnregister?I.keepDefaultValues?ct(i):{}:ct(G),f.array.next({values:{...G}}),f.values.next({values:{...G}})}o={mount:I.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},a.mount=!d.isValid||!!I.keepIsValid||!!I.keepDirtyValues,a.watch=!!t.shouldUnregister,f.state.next({submitCount:I.keepSubmitCount?n.submitCount:0,isDirty:X?!1:I.keepDirty?n.isDirty:!!(I.keepDefaultValues&&!Ht(j,i)),isSubmitted:I.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:X?{}:I.keepDirtyValues?I.keepDefaultValues&&s?Zn(i,s):n.dirtyFields:I.keepDefaultValues&&j?Zn(i,j):I.keepDirty?n.dirtyFields:{},touchedFields:I.keepTouched?n.touchedFields:{},errors:I.keepErrors?n.errors:{},isSubmitSuccessful:I.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},Ie=(j,I)=>nt(At(j)?j(s):j,I);return{control:{register:B,unregister:fe,getFieldState:re,handleSubmit:ge,setError:se,_executeSchema:F,_getWatch:V,_getDirty:$,_updateValid:S,_removeUnmounted:q,_updateFieldArray:_,_updateDisabledField:M,_getFieldArray:Z,_reset:nt,_resetDefaultValues:()=>At(t.defaultValues)&&t.defaultValues().then(j=>{Ie(j,t.resetOptions),f.state.next({isLoading:!1})}),_updateFormState:j=>{n={...n,...j}},_disableForm:pe,_subjects:f,_proxyFormState:d,_setErrors:D,get _fields(){return r},get _formValues(){return s},get _state(){return a},set _state(j){a=j},get _defaultValues(){return i},get _names(){return o},set _names(j){o=j},get _formState(){return n},set _formState(j){n=j},get _options(){return t},set _options(j){t={...t,...j}}},trigger:y,register:B,handleSubmit:ge,watch:be,setValue:H,getValues:ue,reset:Ie,resetField:Xe,clearErrors:v,unregister:fe,setError:se,setFocus:(j,I={})=>{const P=te(r,j),ne=P&&P._f;if(ne){const X=ne.refs?ne.refs[0]:ne.ref;X.focus&&(X.focus(),I.shouldSelect&&At(X.select)&&X.select())}},getFieldState:re}}function bm(e={}){const t=je.useRef(void 0),n=je.useRef(void 0),[r,i]=je.useState({isDirty:!1,isValidating:!1,isLoading:At(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:At(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...ym(e),formState:r});const s=t.current.control;return s._options=e,ua({subject:s._subjects.state,next:a=>{fc(a,s._proxyFormState,s._updateFormState,!0)&&i({...s._formState})}}),je.useEffect(()=>s._disableForm(e.disabled),[s,e.disabled]),je.useEffect(()=>{if(s._proxyFormState.isDirty){const a=s._getDirty();a!==r.isDirty&&s._subjects.state.next({isDirty:a})}},[s,r.isDirty]),je.useEffect(()=>{e.values&&!Ht(e.values,n.current)?(s._reset(e.values,s._options.resetOptions),n.current=e.values,i(a=>({...a}))):s._resetDefaultValues()},[e.values,s]),je.useEffect(()=>{e.errors&&s._setErrors(e.errors)},[e.errors,s]),je.useEffect(()=>{s._state.mount||(s._updateValid(),s._state.mount=!0),s._state.watch&&(s._state.watch=!1,s._subjects.state.next({...s._formState})),s._removeUnmounted()}),je.useEffect(()=>{e.shouldUnregister&&s._subjects.values.next({values:s._getWatch()})},[e.shouldUnregister,s]),t.current.formState=dc(r,s),t.current}function vm(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 Lt=hu,lo=mu,wm=gu,uo=na,wc=x.forwardRef(({className:e,...t},n)=>c.jsx(bi,{ref:n,className:L("fixed inset-0 z-50 bg-black/80",e),...t}));wc.displayName=bi.displayName;const Ot=x.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(wm,{children:[c.jsx(wc,{}),c.jsxs(gi,{ref:r,className:L("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(na,{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(dn,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ot.displayName=gi.displayName;const pn=({className:e,...t})=>c.jsx("div",{className:L("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});pn.displayName="DialogHeader";const ur=({className:e,...t})=>c.jsx("div",{className:L("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});ur.displayName="DialogFooter";const hn=x.forwardRef(({className:e,...t},n)=>c.jsx(xi,{ref:n,className:L("text-lg leading-none font-semibold tracking-tight",e),...t}));hn.displayName=xi.displayName;const An=x.forwardRef(({className:e,...t},n)=>c.jsx(yi,{ref:n,className:L("text-muted-foreground text-sm",e),...t}));An.displayName=yi.displayName;const km=vr("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),fa=x.forwardRef(({className:e,...t},n)=>c.jsx(xu,{ref:n,className:L(km(),e),...t}));fa.displayName=xu.displayName;const _m=nm,kc=x.createContext({}),co=({...e})=>c.jsx(kc.Provider,{value:{name:e.name},children:c.jsx(am,{...e})}),_i=()=>{const e=x.useContext(kc),t=x.useContext(_c),{getFieldState:n,formState:r}=ki(),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}},_c=x.createContext({}),ks=x.forwardRef(({className:e,...t},n)=>{const r=x.useId();return c.jsx(_c.Provider,{value:{id:r},children:c.jsx("div",{ref:n,className:L("space-y-2",e),...t})})});ks.displayName="FormItem";const _s=x.forwardRef(({className:e,...t},n)=>{const{error:r,formItemId:i}=_i();return c.jsx(fa,{ref:n,className:L(r&&"text-destructive",e),htmlFor:i,...t})});_s.displayName="FormLabel";const Ss=x.forwardRef(({...e},t)=>{const{error:n,formItemId:r,formDescriptionId:i,formMessageId:s}=_i();return c.jsx(Rn,{ref:t,id:r,"aria-describedby":n?`${i} ${s}`:`${i}`,"aria-invalid":!!n,...e})});Ss.displayName="FormControl";const Sc=x.forwardRef(({className:e,...t},n)=>{const{formDescriptionId:r}=_i();return c.jsx("p",{ref:n,id:r,className:L("text-muted-foreground text-[0.8rem]",e),...t})});Sc.displayName="FormDescription";const js=x.forwardRef(({className:e,children:t,...n},r)=>{const{error:i,formMessageId:s}=_i(),a=i?String(i==null?void 0:i.message):t;return a?c.jsx("p",{ref:r,id:s,className:L("text-destructive text-[0.8rem] font-medium",e),...n,children:a}):null});js.displayName="FormMessage";const pa=x.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:L("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}));pa.displayName="Input";const ha=Bp,Sm=Kp,ma=Up,Si=x.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(yu,{ref:r,className:L("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(Jp,{asChild:!0,children:c.jsx(Gt,{className:"h-4 w-4 shrink-0 opacity-50"})})]}));Si.displayName=yu.displayName;const jc=x.forwardRef(({className:e,...t},n)=>c.jsx(wu,{ref:n,className:L("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(bh,{className:"h-4 w-4"})}));jc.displayName=wu.displayName;const Nc=x.forwardRef(({className:e,...t},n)=>c.jsx(ku,{ref:n,className:L("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(Gt,{className:"h-4 w-4"})}));Nc.displayName=ku.displayName;const ji=x.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>c.jsx(qp,{children:c.jsxs(bu,{ref:i,className:L("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(jc,{}),c.jsx(Hp,{className:L("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(Nc,{})]})}));ji.displayName=bu.displayName;const Cc=x.forwardRef(({className:e,...t},n)=>c.jsx(_u,{ref:n,className:L("px-2 py-1.5 text-sm font-semibold",e),...t}));Cc.displayName=_u.displayName;const cr=x.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(vu,{ref:r,className:L("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(Wp,{children:c.jsx(fn,{className:"h-4 w-4"})})}),c.jsx(Gp,{children:t})]}));cr.displayName=vu.displayName;const jm=x.forwardRef(({className:e,...t},n)=>c.jsx(Su,{ref:n,className:L("bg-muted -mx-1 my-1 h-px",e),...t}));jm.displayName=Su.displayName;function ga(){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 Ec=()=>({chatOpen:!1,scope:"global",model:"opus",contextAttachments:[],threads:{},activeThreadId:{}}),Nm=(e=Ec())=>Wh()(Gh(Kh((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:ga(),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(d=>d.documentName===o);u.length>0?(u.sort((d,f)=>f.updatedAt-d.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:Yh(()=>Zh),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}}))),Ic=x.createContext(void 0),Cm=({children:e})=>{const t=x.useRef(null);return t.current||(t.current=Nm(Ec())),c.jsx(Ic.Provider,{value:t.current,children:e})},Ce=e=>{const t=x.useContext(Ic);if(!t)throw new Error("useChatStore must be used within ChatStoreProvider");return Xh(t,e)};function Em(e,t,n){return t.filter(r=>r.name!==n).every(r=>r.name!==e)}function Im(e,t,n){const r={},i=[];e!=="delete"&&(r.name=Cr.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=Cr.Optional(Cr.String({description:"Template selection"})));const s=Cr.Object(r,{additionalProperties:!1,required:i.length>0?i:void 0});return{schema:s,validate:a=>{const o=[];if(!mh(s,a))for(const u of gh(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 Tm(e,t,n){return e==="create"?{name:"",template:t}:e==="update"?{name:n}:{}}const Am=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"}}),Bn="__empty__";function zm({mode:e,shouldReset:t,postSubmit:n,selectedName:r,discoveredDocuments:i,discoveredThemes:s,isTheme:a}){const[o,l]=x.useState(!1),[u,d]=x.useState(null),f=Am(a),{documents:h,openTabs:p,createDocument:m,renameDocument:w,deleteDocument:S,openDocument:b,closeDocument:_}=qe(z=>z),{updateTheme:g,removeTheme:D}=bs(z=>z),E=Ce(z=>z.renameThreadsForDocument),k=Ce(z=>z.deleteThreadsForDocument),N=x.useMemo(()=>a?s||[]:i||[],[a,i,s]),F=x.useMemo(()=>{const z={current:[],downstream:[]};return N.forEach(J=>{z[J.location]&&z[J.location].push(J)}),z},[N]),K=x.useMemo(()=>N.map(z=>({name:z.name,type:"application/json",text:"",mtime:new Date,ctime:new Date,atime:new Date})),[N]),C=x.useMemo(()=>Im(e,z=>Em(z,h,r),K),[e,h,r,K]),q=C.schema,$=x.useMemo(()=>{const z=new Map;return N.forEach(J=>z.set(J.path,J)),z},[N]),V=Bn,Z=bm({resolver:vm(C.validate),defaultValues:Tm(e,void 0,r)}),[O,Y]=x.useState(V);x.useEffect(()=>{if(O&&O!==Bn&&e==="create"){const z=$.get(O);z&&fetch(`/api/discovery/${a?"themes":"documents"}/${encodeURIComponent(z.name)}/content`).then(J=>{if(!J.ok)throw new Error(`Failed to fetch content: ${J.statusText}`);return J.text()}).then(J=>{try{const y=JSON.parse(J);d(JSON.stringify(y,null,2))}catch(y){console.error("Invalid JSON content received:",y),d(null)}}).catch(J=>{console.error("Failed to fetch content:",J),d(null)})}},[O,e,$,a]),x.useEffect(()=>{t&&(Z.reset(),d(null),Y(V))},[Z,t]);const H=Z.handleSubmit(async({name:z,template:J})=>{l(!0);try{if(await new Promise(y=>setTimeout(y,200)),e==="create"){const y=O?$.get(O):N.find(B=>B.name===J);let ue,re=z;if(a){const B=re.replace(/\.(json|theme)$/i,"").toLowerCase().replace(/\s+/g,"-");ue=u||JSON.stringify(vt==="docx"?{name:B,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:B,colors:{primary:"#2563EB",secondary:"#64748B",accent:"#F8FAFC",background:"#FFFFFF",text:"#334155"},fonts:{heading:"Calibri",body:"Calibri"},defaults:{fontSize:18,fontColor:"#334155"}},null,2);const pe=`.${vt}.theme.json`;re.endsWith(pe)||(re=re.replace(/\.(pptx|docx)\.theme\.json$/i,"").replace(/\.theme\.json$/i,"").replace(/\.json$/i,""),re+=pe)}else{const B=y;ue=u||JSON.stringify(vt==="docx"?{name:"docx",props:{theme:(B==null?void 0:B.theme)||"default",metadata:{title:(B==null?void 0:B.title)||re.replace(/\.(json|js)$/i,"")}},children:[{name:"section",props:{},children:[{name:"paragraph",props:{text:"Start writing your document content here..."}}]}]}:{name:"pptx",props:{title:(B==null?void 0:B.title)||re.replace(/\.(json|js)$/i,""),theme:(B==null?void 0:B.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 ee=vt==="docx"?".docx.json":".pptx.json";!re.endsWith(ee)&&!re.endsWith(".json")&&(re+=ee)}const v=re.match(/(\.(pptx|docx)(\.theme)?\.json|\.json)$/i),se=v?v[0]:"",be=re.slice(0,re.length-se.length);let fe=re,M=1;for(;h.some(B=>B.name===fe);)M++,fe=`${be} (${M})${se}`;re=fe,m(re,ue),b(re),a&&g(re,ue)}else if(e==="update"){const y=r,ue=z,re=p.includes(y);re&&_(y),w(y,ue),E(y,ue),re&&b(ue)}else if(e==="delete"){const y=r;_(y),S(y),k(y),a&&D(y)}n()}finally{l(!1)}});return c.jsx(_m,{...Z,children:c.jsxs("form",{onSubmit:H,children:[c.jsxs(pn,{children:[c.jsx(hn,{children:f[e].title}),c.jsx(An,{children:f[e].description})]}),c.jsxs("div",{className:"flex flex-col gap-4 py-4",children:[q.properties&&"name"in q.properties&&c.jsx(co,{control:Z.control,name:"name",render:({field:z})=>c.jsxs(ks,{children:[c.jsx(_s,{children:"Name"}),c.jsx(Ss,{children:c.jsx(pa,{placeholder:"Enter a name or select a template below",autoComplete:"off",...z})}),c.jsx(js,{})]})}),e==="create"&&c.jsx(co,{control:Z.control,name:"template",render:({field:z})=>c.jsxs(ks,{children:[c.jsx(_s,{children:a?"Base Theme":"Base Document"}),c.jsxs(ha,{onValueChange:J=>{if(J===Bn)z.onChange(void 0),Z.setValue("name",""),Y(Bn),d(null);else{const y=$.get(J);y&&(z.onChange(y.name),Z.setValue("name",y.name),Y(J))}},defaultValue:V,children:[c.jsx(Ss,{children:c.jsx(Si,{children:c.jsx(ma,{placeholder:`Select a discovered ${a?"theme":"document"}`})})}),c.jsxs(ji,{className:"max-h-[300px]",children:[c.jsxs(cr,{value:Bn,children:["Empty ",a?"theme":"document"]}),Object.entries(F).map(([J,y])=>y.length===0?null:c.jsxs(Sm,{children:[c.jsx(Cc,{children:J==="current"?"📁 Current Directory":"📦 Project"}),y.map(ue=>{let re=ue.name;if(ue.title)re=`${ue.name} - ${ue.title}`;else if(ue.description){const v=ue.description.length>40?ue.description.substring(0,40)+"...":ue.description;re=`${ue.name} - ${v}`}return c.jsx(cr,{value:ue.path,className:"pl-6",children:re},ue.path)})]},J))]})]}),c.jsxs(Sc,{children:["Start empty or select a discovered"," ",a?"theme":"document"," as a starting point"]}),c.jsx(js,{})]})})]}),c.jsx(ur,{children:c.jsx(Ne,{type:"submit",variant:f[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..."]}):f[e].button})})]})})}const Qr=je.memo(zm),Om=Yp,Pm=Xp,Dm=x.forwardRef(({className:e,inset:t,children:n,...r},i)=>c.jsxs(Eu,{ref:i,className:L("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(vi,{className:"ml-auto h-4 w-4"})]}));Dm.displayName=Eu.displayName;const Rm=x.forwardRef(({className:e,...t},n)=>c.jsx(Iu,{ref:n,className:L("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}));Rm.displayName=Iu.displayName;const Tc=x.forwardRef(({className:e,...t},n)=>c.jsx(Qp,{children:c.jsx(ju,{ref:n,className:L("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})}));Tc.displayName=ju.displayName;const Kn=x.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Nu,{ref:r,className:L("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}));Kn.displayName=Nu.displayName;const Mm=x.forwardRef(({className:e,children:t,checked:n,...r},i)=>c.jsxs(Tu,{ref:i,className:L("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(Au,{children:c.jsx(fn,{className:"h-4 w-4"})})}),t]}));Mm.displayName=Tu.displayName;const Fm=x.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(zu,{ref:r,className:L("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(Au,{children:c.jsx(Yu,{className:"h-4 w-4 fill-current"})})}),t]}));Fm.displayName=zu.displayName;const $m=x.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Ou,{ref:r,className:L("text-foreground px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));$m.displayName=Ou.displayName;const Ns=x.forwardRef(({className:e,...t},n)=>c.jsx(Cu,{ref:n,className:L("bg-border -mx-1 my-1 h-px",e),...t}));Ns.displayName=Cu.displayName;const Zr=({className:e,...t})=>c.jsx("span",{className:L("text-muted-foreground ml-auto text-xs tracking-widest",e),...t});Zr.displayName="ContextMenuShortcut";const Ac=x.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},i)=>c.jsx(Pu,{ref:i,decorative:n,orientation:t,className:L("bg-border shrink-0",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Ac.displayName=Pu.displayName;const zc=hu,Lm=mu,Zm=gu,Oc=x.forwardRef(({className:e,...t},n)=>c.jsx(bi,{className:L("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}));Oc.displayName=bi.displayName;const Vm=vr("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),xa=x.forwardRef(({side:e="right",className:t,children:n,...r},i)=>c.jsxs(Zm,{children:[c.jsx(Oc,{}),c.jsxs(gi,{ref:i,className:L(Vm({side:e}),t),...r,children:[c.jsxs(na,{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(dn,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]}),n]})]}));xa.displayName=gi.displayName;const Bm=x.forwardRef(({className:e,...t},n)=>c.jsx(xi,{ref:n,className:L("text-foreground text-lg font-semibold",e),...t}));Bm.displayName=xi.displayName;const Um=x.forwardRef(({className:e,...t},n)=>c.jsx(yi,{ref:n,className:L("text-muted-foreground text-sm",e),...t}));Um.displayName=yi.displayName;function ir({className:e,...t}){return c.jsx("div",{className:L("bg-primary/10 animate-pulse rounded-md",e),...t})}const Vi=768,Bi=1200;function Pc(){const[e,t]=x.useState(void 0);return x.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Vi-1}px)`),r=()=>{t(window.innerWidth<Vi)};return n.addEventListener("change",r),t(window.innerWidth<Vi),()=>n.removeEventListener("change",r)},[]),!!e}function Jm(){const[e,t]=x.useState(void 0);return x.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Bi-1}px)`),r=()=>{t(window.innerWidth<Bi)};return n.addEventListener("change",r),t(window.innerWidth<Bi),()=>n.removeEventListener("change",r)},[]),!!e}const qm="sidebar_state",Hm=60*60*24*7,Wm="16rem",Gm="18rem",Km="3rem",Ym="b",Dc=x.createContext(null);function Ni(){const e=x.useContext(Dc);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const Rc=x.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:s,...a},o)=>{const l=Pc(),[u,d]=x.useState(!1),[f,h]=x.useState(e),p=t??f,m=x.useCallback(_=>{const g=typeof _=="function"?_(p):_;n?n(g):h(g),document.cookie=`${qm}=${g}; path=/; max-age=${Hm}`},[n,p]),w=x.useCallback(()=>l?d(_=>!_):m(_=>!_),[l,m,d]);x.useEffect(()=>{const _=D=>{var N;const E=D;if(!E)return!1;const k=(N=E.tagName)==null?void 0:N.toLowerCase();return k==="input"||k==="textarea"||k==="select"||E.isContentEditable?!0:!!(E.closest&&E.closest(".monaco-editor"))},g=D=>{const E=D.metaKey||D.ctrlKey,k=D.key.toLowerCase();if(E&&k===Ym){D.preventDefault(),w();return}E&&k==="s"&&!_(D.target)&&(D.preventDefault(),w())};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[w]);const S=p?"expanded":"collapsed",b=x.useMemo(()=>({state:S,open:p,setOpen:m,isMobile:l,openMobile:u,setOpenMobile:d,toggleSidebar:w}),[S,p,m,l,u,d,w]);return c.jsx(Dc.Provider,{value:b,children:c.jsx(xh,{delayDuration:0,children:c.jsx("div",{style:{"--sidebar-width":Wm,"--sidebar-width-icon":Km,...i},className:L("group/sidebar-wrapper has-[[data-variant=inset]]:bg-sidebar flex min-h-svh w-full",r),ref:o,...a,children:s})})})});Rc.displayName="SidebarProvider";const Mc=x.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:i,...s},a)=>{const{isMobile:o,state:l,openMobile:u,setOpenMobile:d}=Ni();return n==="none"?c.jsx("div",{className:L("bg-sidebar text-sidebar-foreground flex h-full w-[--sidebar-width] flex-col",r),ref:a,...s,children:i}):o?c.jsx(zc,{open:u,onOpenChange:d,...s,children:c.jsx(xa,{"data-sidebar":"sidebar","data-mobile":"true",className:"bg-sidebar text-sidebar-foreground w-[--sidebar-width] p-0 [&>button]:hidden",style:{"--sidebar-width":Gm},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:L("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:L("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})})]})});Mc.displayName="Sidebar";const Xm=x.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:i}=Ni();return c.jsxs(Ne,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:L("h-7 w-7",e),onClick:s=>{t==null||t(s),i()},...n,children:[c.jsx(vh,{}),c.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Xm.displayName="SidebarTrigger";const Qm=x.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=Ni();return c.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:L("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})});Qm.displayName="SidebarRail";const eg=x.forwardRef(({className:e,...t},n)=>c.jsx("main",{ref:n,className:L("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}));eg.displayName="SidebarInset";const tg=x.forwardRef(({className:e,...t},n)=>c.jsx(pa,{ref:n,"data-sidebar":"input",className:L("bg-background focus-visible:ring-sidebar-ring h-8 w-full shadow-none focus-visible:ring-2",e),...t}));tg.displayName="SidebarInput";const Fc=x.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"header",className:L("flex flex-col gap-2 p-2",e),...t}));Fc.displayName="SidebarHeader";const $c=x.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"footer",className:L("flex flex-col gap-2 p-2",e),...t}));$c.displayName="SidebarFooter";const Lc=x.forwardRef(({className:e,...t},n)=>c.jsx(Ac,{ref:n,"data-sidebar":"separator",className:L("bg-sidebar-border mx-2 w-auto",e),...t}));Lc.displayName="SidebarSeparator";const Zc=x.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"content",className:L("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Zc.displayName="SidebarContent";const Vr=x.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"group",className:L("relative flex w-full min-w-0 flex-col p-2",e),...t}));Vr.displayName="SidebarGroup";const Br=x.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?Rn:"div";return c.jsx(i,{ref:r,"data-sidebar":"group-label",className:L("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})});Br.displayName="SidebarGroupLabel";const ng=x.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?Rn:"button";return c.jsx(i,{ref:r,"data-sidebar":"group-action",className:L("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})});ng.displayName="SidebarGroupAction";const Yn=x.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"group-content",className:L("w-full text-sm",e),...t}));Yn.displayName="SidebarGroupContent";const Cs=x.forwardRef(({className:e,...t},n)=>c.jsx("ul",{ref:n,"data-sidebar":"menu",className:L("flex w-full min-w-0 flex-col gap-1",e),...t}));Cs.displayName="SidebarMenu";const Vc=x.forwardRef(({className:e,...t},n)=>c.jsx("li",{ref:n,"data-sidebar":"menu-item",className:L("group/menu-item relative",e),...t}));Vc.displayName="SidebarMenuItem";const rg=vr("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"}}),Bc=x.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:i,className:s,...a},o)=>{const l=e?Rn:"button",{isMobile:u,state:d}=Ni(),f=c.jsx(l,{ref:o,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:L(rg({variant:n,size:r}),s),...a});return i?(typeof i=="string"&&(i={children:i}),c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:f}),c.jsx(Ye,{side:"right",align:"center",hidden:d!=="collapsed"||u,...i})]})):f});Bc.displayName="SidebarMenuButton";const ig=x.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},i)=>{const s=t?Rn:"button";return c.jsx(s,{ref:i,"data-sidebar":"menu-action",className:L("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})});ig.displayName="SidebarMenuAction";const sg=x.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:L("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}));sg.displayName="SidebarMenuBadge";const ag=x.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{const i=x.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return c.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:L("flex h-8 items-center gap-2 rounded-md px-2",e),...n,children:[t&&c.jsx(ir,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),c.jsx(ir,{className:"h-4 max-w-[--skeleton-width] flex-1","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":i}})]})});ag.displayName="SidebarMenuSkeleton";const og=x.forwardRef(({className:e,...t},n)=>c.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:L("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}));og.displayName="SidebarMenuSub";const lg=x.forwardRef(({...e},t)=>c.jsx("li",{ref:t,...e}));lg.displayName="SidebarMenuSubItem";const ug=x.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...i},s)=>{const a=e?Rn:"a";return c.jsx(a,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:L("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})});ug.displayName="SidebarMenuSubButton";function Es(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 cg=typeof window<"u"?navigator.userAgent.toUpperCase().indexOf("MAC")>=0:!1;function dg({document:e,indicator:t,compact:n=!1}){const r=x.useRef(null),[i,s]=x.useState(!1),[a,o]=x.useState(!1),[l,u]=x.useState(!1),{openDocument:d,documentTypes:f,activeTab:h}=qe(O=>O),{name:p,text:m,isGenerating:w}=on(O=>O),b=(f[e.name]||"application/json+report")==="application/json+theme",_=h===e.name,[g,D]=x.useState(p),[E,k]=x.useState(m),N=100,F=0;x.useEffect(()=>{const O=setTimeout(()=>{p&&m?(D(p),k(m)):w||(D(""),k(""))},w?N:F);return()=>clearTimeout(O)},[p,m,w]);const K=g===e.name,C=O=>{var H;const Y=new Set;try{const z=JSON.parse(O);(H=z.props)!=null&&H.theme&&Y.add(z.props.theme),z.children&&Array.isArray(z.children)&&z.children.forEach(J=>{var y;J.name==="docx"&&((y=J.props)!=null&&y.theme)&&Y.add(J.props.theme)})}catch{}return Y},q=x.useMemo(()=>{if(!b||!E)return!1;try{const O=JSON.parse(e.text),Y=vs(O);if(Y)return C(E).has(Y)}catch{}return!1},[b,E,e.text,e.name,g]),$=x.useCallback(()=>{o(!1)},[]),V=x.useCallback(()=>{u(!1)},[]),Z=c.jsxs(Bc,{variant:"default",size:"default",ref:r,className:L("text-sidebar-foreground focus:bg-accent focus:text-accent-foreground w-full",n?"justify-center px-1":"justify-start gap-2",i&&"bg-accent text-accent-foreground",_&&(n?"bg-green-50 text-green-700 dark:bg-green-900/20 dark:text-green-300":"bg-green-50 border-l-2 border-green-500 text-green-700 dark:bg-green-900/20 dark:border-green-400 dark:text-green-300"),K&&!_&&(n?"bg-blue-50 text-blue-700 dark:bg-blue-900/20 dark:text-blue-300":"bg-blue-50 border-l-2 border-blue-500 text-blue-700 dark:bg-blue-900/20 dark:border-blue-400 dark:text-blue-300"),q&&!_&&!K&&(n?"bg-purple-50 text-purple-700 dark:bg-purple-900/20 dark:text-purple-300":"bg-purple-50 border-l-2 border-purple-500 text-purple-700 dark:bg-purple-900/20 dark:border-purple-400 dark:text-purple-300")),title:e.name,onClick:()=>{d(e.name)},onKeyDown:O=>{var Y;(O.ctrlKey||O.metaKey)&&O.key==="Enter"?(d(e.name),O.preventDefault()):O.key==="Enter"?(o(!0),O.preventDefault()):O.key==="Backspace"||O.key==="Delete"?(u(!0),O.preventDefault()):O.key==="Escape"&&((Y=r.current)==null||Y.blur(),O.preventDefault())},children:[_?c.jsx(Ga,{className:L("size-4","text-green-600 dark:text-green-400")}):K?c.jsx(Ga,{className:L("size-4","text-blue-600 dark:text-blue-400")}):b?c.jsx(Gn,{className:"size-4 text-purple-600 dark:text-purple-400"}):c.jsx(Xu,{className:"size-4 text-blue-600 dark:text-blue-400"}),!n&&c.jsx("span",{className:L("truncate flex-1",b&&!_&&!K&&!q&&"text-purple-700 dark:text-purple-300",(_||K||q)&&"font-medium"),children:e.name})]});return c.jsxs(Vc,{children:[c.jsxs(Om,{onOpenChange:s,children:[c.jsx(Pm,{children:n?c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:Z}),c.jsx(Ye,{side:"right",children:c.jsxs("div",{className:"text-xs",children:[e.name,b?c.jsx("div",{className:"opacity-70",children:"Theme"}):c.jsx("div",{className:"opacity-70",children:"Document"})]})})]}):Z}),c.jsxs(Tc,{children:[c.jsxs(Kn,{onClick:()=>d(e.name),children:["Open",c.jsx(Zr,{children:cg?"⌘⏎":"⌃⏎"})]}),c.jsx(Ns,{}),c.jsx(Kn,{disabled:!e,onClick:()=>{e&&Es(e.name,new Blob([e.text],{type:e.type}))},children:"Download..."}),c.jsx(Ns,{}),c.jsxs(Kn,{onClick:()=>o(!0),children:["Rename...",c.jsx(Zr,{children:"⏎"})]}),c.jsxs(Kn,{onClick:()=>u(!0),children:["Delete",c.jsx(Zr,{children:"⌫"})]})]})]}),c.jsx(Lt,{open:a,onOpenChange:o,children:c.jsx(Ot,{className:"sm:max-w-[425px]",onCloseAutoFocus:O=>{var Y;O.preventDefault(),(Y=r.current)==null||Y.focus()},children:c.jsx(Qr,{mode:"update",shouldReset:!a,postSubmit:$,selectedName:e.name})})}),c.jsx(Lt,{open:l,onOpenChange:u,children:c.jsx(Ot,{className:"sm:max-w-[425px]",onCloseAutoFocus:O=>{var Y;O.preventDefault(),(Y=r.current)==null||Y.focus()},children:c.jsx(Qr,{mode:"delete",shouldReset:!l,postSubmit:V,selectedName:e.name})})})]})}const fo=je.memo(dg);async function fg(e,t){const n=JSON.stringify({name:e,props:t,children:[]},null,2);await navigator.clipboard.writeText(n)}const pg=vr("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 sr({className:e,variant:t,...n}){return c.jsx("div",{className:L(pg({variant:t}),e),...n})}const dr=x.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Du,{ref:r,className:L("relative overflow-hidden",e),...n,children:[c.jsx(eh,{className:"h-full w-full rounded-[inherit]",children:t}),c.jsx(Uc,{}),c.jsx(th,{})]}));dr.displayName=Du.displayName;const Uc=x.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(Ru,{ref:r,orientation:t,className:L("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(nh,{className:"bg-border relative flex-1 rounded-full"})}));Uc.displayName=Ru.displayName;function ya({className:e,...t}){return c.jsx(rh,{"data-slot":"switch",className:L("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(ih,{"data-slot":"switch-thumb",className:L("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 hg=vr("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"}}),Is=x.forwardRef(({className:e,variant:t,...n},r)=>c.jsx("div",{ref:r,role:"alert",className:L(hg({variant:t}),e),...n}));Is.displayName="Alert";const mg=x.forwardRef(({className:e,...t},n)=>c.jsx("h5",{ref:n,className:L("mb-1 font-medium leading-none tracking-tight",e),...t}));mg.displayName="AlertTitle";const Ts=x.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:L("text-sm [&_p]:leading-relaxed",e),...t}));Ts.displayName="AlertDescription";const ei=x.memo(({keyName:e,value:t,depth:n=0,isLast:r=!1})=>{const[i,s]=x.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,d=a?Object.keys(t).length:0;return c.jsxs("div",{className:L("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(Gt,{className:"h-3 w-3"}):c.jsx(vi,{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:[d," ",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((f,h)=>c.jsx(ei,{keyName:String(h),value:f,depth:n+1,isLast:h===t.length-1},h)):Object.entries(t).map(([f,h],p,m)=>c.jsx(ei,{keyName:f,value:h,depth:n+1,isLast:p===m.length-1},f)),c.jsx("div",{className:"ml-4",children:c.jsxs("span",{className:"text-muted-foreground",children:[o?"]":"}",!r&&","]})})]})]})});ei.displayName="JsonNode";const ti=x.memo(({schema:e,loading:t=!1,error:n,className:r})=>t?c.jsxs("div",{className:L("space-y-4",r),children:[c.jsx(ir,{className:"h-8 w-64"}),c.jsx(ir,{className:"h-4 w-full"}),c.jsx(ir,{className:"h-64 w-full"})]}):n?c.jsx(Is,{variant:"destructive",className:r,children:c.jsx(Ts,{children:n})}):e?c.jsx(dr,{className:L("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(ei,{value:e})})}):c.jsx(Is,{className:r,children:c.jsx(Ts,{children:"No schema available"})}));ti.displayName="SchemaViewer";function gg({plugins:e,initialFocusedPlugin:t}){var g,D;const n=Nt(E=>E.togglePlugin),r=Nt(E=>E.isPluginSelected),i=Nt(E=>E.selectedPlugins),s=Nt(E=>E.isApplyingPlugins),[a,o]=x.useState(null),[l,u]=x.useState(null),[d,f]=x.useState("properties");x.useEffect(()=>{if(t){const E=e.find(k=>k.name===t);if(E){o(E);return}}e.length>0&&!a&&o(e[0])},[t,e]);const h=x.useMemo(()=>{const E={current:[],downstream:[],upstream:[]};return e.forEach(k=>{E[k.location]&&E[k.location].push(k)}),E},[e]),p=async(E,k)=>{a&&(await fg(a.name,E.props),u(k),setTimeout(()=>u(null),2e3))},m=E=>{switch(E){case"current":return"Current Directory";case"downstream":return"Project";case"upstream":return"Parent Directories";default:return E}},w=E=>{switch(E){case"current":return c.jsx(jh,{className:"size-3"});case"downstream":return c.jsx(Sh,{className:"size-3"});case"upstream":return c.jsx(Xu,{className:"size-3"});default:return null}},S=((g=a==null?void 0:a.schema)==null?void 0:g.properties)&&Object.keys(a.schema.properties).length>0,b=(D=a==null?void 0:a.schema)==null?void 0:D.jsonSchema,_=(a==null?void 0:a.examples)&&a.examples.length>0;return c.jsxs(c.Fragment,{children:[c.jsxs(pn,{children:[c.jsxs(hn,{className:"flex items-center gap-2",children:[c.jsx(Qu,{className:"size-5 text-amber-600 dark:text-amber-400"}),"Plugins",c.jsxs(sr,{variant:"secondary",className:"font-normal",children:[i.size," active"]})]}),c.jsxs(An,{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(dr,{className:"h-full",children:c.jsx("div",{className:"p-2 space-y-3",children:Object.entries(h).map(([E,k])=>k.length===0?null:c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:[w(E),m(E)]}),c.jsx("div",{className:"space-y-0.5",children:k.map(N=>{const F=r(N.name),K=(a==null?void 0:a.name)===N.name;return c.jsxs("button",{onClick:()=>o(N),className:L("w-full text-left px-2 py-1.5 rounded-md transition-colors cursor-pointer","flex items-center gap-2",K?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"),children:[c.jsx("div",{className:L("size-1.5 rounded-full flex-none transition-colors",F?"bg-amber-500 dark:bg-amber-400":"bg-muted-foreground/30")}),c.jsx("span",{className:"text-sm font-medium truncate flex-1",children:N.name})]},N.name)})})]},E))})})}),a?c.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[c.jsxs("div",{className:"flex-none px-5 py-4 border-b bg-background",children:[c.jsxs("div",{className:"flex items-start justify-between gap-3",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2.5",children:[c.jsx("h3",{className:"text-base font-semibold truncate",children:a.name}),a.version&&c.jsxs(sr,{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(ya,{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:()=>f("properties"),className:L("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",d==="properties"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(Ka,{className:"size-3.5"}),"Properties"]})}),b&&c.jsx("button",{onClick:()=>f("schema"),className:L("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",d==="schema"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(wh,{className:"size-3.5"}),"Schema"]})}),_&&c.jsx("button",{onClick:()=>f("examples"),className:L("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",d==="examples"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(kh,{className:"size-3.5"}),"Examples",c.jsx(sr,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-4",children:a.examples.length})]})})]}),c.jsx(dr,{className:"flex-1",children:c.jsxs("div",{className:"p-5",children:[d==="properties"&&S&&c.jsx("div",{className:"space-y-1",children:Object.entries(a.schema.properties).map(([E,k])=>c.jsx(xg,{name:E,prop:k},E))}),d==="schema"&&b&&c.jsx(ti,{schema:a.schema.jsonSchema,loading:!1,className:"h-[420px]"}),d==="examples"&&_&&a.examples.map((E,k)=>c.jsxs("div",{className:L(k>0&&"mt-4 pt-4 border-t"),children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[E.title&&c.jsx("span",{className:"font-medium text-sm truncate",children:E.title}),!E.title&&c.jsxs("span",{className:"text-sm text-muted-foreground",children:["Example ",k+1]})]}),c.jsx(Ne,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs flex-none",onClick:()=>p(E,k),children:l===k?c.jsxs(c.Fragment,{children:[c.jsx(_h,{className:"size-3 mr-1 text-green-600"}),"Copied"]}):c.jsxs(c.Fragment,{children:[c.jsx(sa,{className:"size-3 mr-1"}),"Copy"]})})]}),E.description&&c.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:E.description}),c.jsx("pre",{className:"p-3 bg-muted rounded-md overflow-x-auto text-xs font-mono leading-relaxed",children:JSON.stringify(E.props,null,2)})]},k)),!S&&!b&&!_&&c.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[c.jsx(Ka,{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 xg({name:e,prop:t}){var a;const[n,r]=x.useState(!1),i=t.description||t.enum||t.default!==void 0||t.items||t.properties,s=t.type||(t.enum?"enum":t.oneOf?"oneOf":"—");return c.jsxs("div",{className:"rounded-md border",children:[c.jsxs("button",{onClick:()=>i&&r(!n),className:L("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(Gt,{className:"size-3 text-muted-foreground flex-none"}):c.jsx(vi,{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(sr,{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 Ui=sh,Ji=ah,qi=oh,Jc=lh,qc=uh,yg=x.forwardRef(({className:e,inset:t,children:n,...r},i)=>c.jsxs(Lu,{ref:i,className:L("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(vi,{className:"ml-auto"})]}));yg.displayName=Lu.displayName;const bg=x.forwardRef(({className:e,...t},n)=>c.jsx(Zu,{ref:n,className:L("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}));bg.displayName=Zu.displayName;const ba=x.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(ch,{children:c.jsx(Mu,{ref:r,sideOffset:t,className:L("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})}));ba.displayName=Mu.displayName;const Wt=x.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Fu,{ref:r,className:L("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}));Wt.displayName=Fu.displayName;const vg=x.forwardRef(({className:e,children:t,checked:n,...r},i)=>c.jsxs(Vu,{ref:i,className:L("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(Bu,{children:c.jsx(fn,{className:"h-4 w-4"})})}),t]}));vg.displayName=Vu.displayName;const wg=x.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Uu,{ref:r,className:L("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(Bu,{children:c.jsx(Yu,{className:"h-2 w-2 fill-current"})})}),t]}));wg.displayName=Uu.displayName;const kg=x.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Ju,{ref:r,className:L("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));kg.displayName=Ju.displayName;const ni=x.forwardRef(({className:e,...t},n)=>c.jsx($u,{ref:n,className:L("bg-muted -mx-1 my-1 h-px",e),...t}));ni.displayName=$u.displayName;function _g(){const{theme:e,setTheme:t}=Gu(),n=e==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e,r=x.useCallback(()=>{t(n==="dark"?"light":"dark")},[n,t]);return c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsxs(Ne,{variant:"ghost",size:"icon",onClick:r,children:[c.jsx(Nh,{className:"hidden dark:block"}),c.jsx(Ch,{className:"block dark:hidden"}),c.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),c.jsx(Ye,{children:c.jsx("p",{children:"Toggle theme"})})]})}const Sg=dh,Hc=x.forwardRef(({className:e,...t},n)=>c.jsx(qu,{ref:n,className:L("bg-muted text-muted-foreground inline-flex h-9 items-center justify-center rounded-lg p-1",e),...t}));Hc.displayName=qu.displayName;const As=x.forwardRef(({className:e,...t},n)=>c.jsx(Hu,{ref:n,className:L("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}));As.displayName=Hu.displayName;const zs=x.forwardRef(({className:e,...t},n)=>c.jsx(Wu,{ref:n,className:L("ring-offset-background focus-visible:ring-ring mt-2 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",e),...t}));zs.displayName=Wu.displayName;async function jg(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 Ng(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 Cg(e){const t=Ng(e);return jg(t)}const Wc=({open:e,onOpenChange:t,defaultTab:n="document"})=>{const[r,i]=x.useState(n),[s,a]=x.useState(null),[o,l]=x.useState(null),[u,d]=x.useState(!1),[f,h]=x.useState(!1),[p,m]=x.useState(null),[w,S]=x.useState(null),[b,_]=x.useState(!1),{toast:g}=ia(),D=Nt(V=>V.selectedPlugins),E=Array.from(D);x.useEffect(()=>{n&&i(n)},[n]);const k=x.useCallback(async()=>{d(!0),m(null);try{const V=await Mi.fetchDocumentSchema(E);a(V)}catch(V){const Z=V instanceof Error?V.message:"Failed to load document schema";m(Z),g({variant:"destructive",title:"Error loading schema",description:Z})}finally{d(!1)}},[E,g]),N=x.useCallback(async()=>{if(!o){h(!0),S(null);try{const V=await Mi.fetchThemeSchema();l(V)}catch(V){const Z=V instanceof Error?V.message:"Failed to load theme schema";S(Z),g({variant:"destructive",title:"Error loading schema",description:Z})}finally{h(!1)}}},[o,g]),[F,K]=x.useState([]);x.useEffect(()=>{e||(a(null),m(null))},[e]),x.useEffect(()=>{if(!e)return;const V=E.length!==F.length||E.some((Z,O)=>Z!==F[O]);r==="document"?(!s||V)&&(V&&(Mi.clearPluginSchemaCache(),K([...E])),u||k()):r==="theme"&&!o&&!f&&N()},[r,e,s,o,u,f,E,F,k,N]);const C=E.length,q=r==="document"?s:o,$=async()=>{if(q)try{await Cg(q)&&(_(!0),g({title:"Schema copied",description:"The JSON schema has been copied to your clipboard"}),setTimeout(()=>_(!1),2e3))}catch(V){console.error("Copy failed:",V)}};return c.jsx(Lt,{open:e,onOpenChange:t,children:c.jsxs(Ot,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[c.jsx(pn,{children:c.jsx(hn,{children:"Schema Viewer"})}),c.jsxs(Sg,{value:r,onValueChange:V=>i(V),className:"flex-1 overflow-hidden flex flex-col",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Hc,{children:[c.jsxs(As,{value:"document",className:"flex items-center gap-1",children:["Document",C>0&&c.jsxs(sr,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:["+",C]})]}),c.jsx(As,{value:"theme",children:"Theme"})]}),c.jsx("div",{className:"ml-auto",children:c.jsx(Ne,{variant:"ghost",size:"icon",onClick:$,disabled:b||!q,"aria-label":"Copy schema",children:b?c.jsx(fn,{className:"h-4 w-4"}):c.jsx(sa,{className:"h-4 w-4"})})})]}),c.jsxs("div",{className:"flex-1 overflow-auto mt-4",children:[c.jsx(zs,{value:"document",className:"h-full",children:c.jsx(ti,{schema:s,loading:u,error:p||void 0})}),c.jsx(zs,{value:"theme",className:"h-full",children:c.jsx(ti,{schema:o,loading:f,error:w||void 0})})]})]})]})})};function Eg({discoveryData:e,onToggleSidebar:t,isCollapsed:n=!1,isAnimating:r=!1}){const{documents:i,documentTypes:s,createDocument:a,openDocument:o}=qe(Qh(M=>({documents:M.documents,documentTypes:M.documentTypes,createDocument:M.createDocument,openDocument:M.openDocument}))),l=bs(M=>M.updateTheme),u=bs(M=>M.removeTheme),d=x.useContext(Vh),[f,h]=x.useState(!1),[p,m]=x.useState(!1),[w,S]=x.useState(!1),[b,_]=x.useState(null),g=Nt(M=>M.togglePlugin),D=Nt(M=>M.isPluginSelected),E=Nt(M=>M.selectedPlugins),k=Nt(M=>M.isApplyingPlugins),[N,F]=x.useState(!1),[K,C]=x.useState(new Set(["current-docs","current-themes"])),{toast:q}=ia(),$=i.filter(M=>s[M.name]!=="application/json+theme"),V=i.filter(M=>s[M.name]==="application/json+theme"),Z=x.useMemo(()=>{if(!e)return{current:[],downstream:[]};const M={current:[],downstream:[]};return e.documents.forEach(B=>{M[B.location]&&M[B.location].push(B)}),M},[e]),O=x.useMemo(()=>{if(!e)return{current:[],downstream:[]};const M={current:[],downstream:[]};return e.themes.forEach(B=>{M[B.location]&&M[B.location].push(B)}),M},[e]),Y=x.useMemo(()=>{const M=new Set;return $.forEach(B=>{try{const ee=JSON.parse(B.text);ee.children&&Array.isArray(ee.children)&&ee.children.forEach(pe=>{var ge;pe.name==="docx"&&((ge=pe.props)!=null&&ge.theme)&&M.add(pe.props.theme)})}catch{}}),M},[$]),H=x.useCallback(()=>{h(!1)},[]),z=x.useCallback(()=>{m(!1)},[]),J=x.useRef(new Map);x.useEffect(()=>{const M=J.current,B=new Map;V.forEach(ee=>{B.set(ee.name,ee.text),M.get(ee.name)!==ee.text&&l(ee.name,ee.text)}),M.forEach((ee,pe)=>{B.has(pe)||u(pe)}),J.current=B},[V,l,u]);const y=x.useRef(!1);x.useEffect(()=>{if(y.current||!d)return;y.current=!0;const M=new Set(V.map(ee=>ee.name));Object.keys(d.getState().customThemes).forEach(ee=>{M.has(ee)||u(ee)})},[V,u,d]);const ue=M=>{C(B=>{const ee=new Set(B);return ee.has(M)?ee.delete(M):ee.add(M),ee})},re=qe(M=>M.activeTab),v=re&&s[re]==="application/json+theme"?"theme":"document",{resolvedTheme:se}=Gu(),be=se==="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",fe=x.useCallback(async(M,B)=>{if(i.some(ee=>ee.name===M)){o(M);return}try{const ee=await fetch(`/api/discovery/${B?"themes":"documents"}/${encodeURIComponent(M)}/content`);if(!ee.ok)throw new Error(ee.statusText);const pe=await ee.text(),ge=JSON.parse(pe);a(M,JSON.stringify(ge,null,2)),o(M),q({title:`Added ${B?"theme":"document"}: ${M}`})}catch{q({title:"Failed to load",description:`Could not load ${M}`,variant:"destructive"})}},[i,a,o,q]);return c.jsxs(c.Fragment,{children:[c.jsxs(Mc,{collapsible:"none",style:{"--sidebar-width":n?"2.5rem":"16rem"},children:[c.jsx(Fc,{children:c.jsx("div",{className:L("flex items-center transition-opacity duration-[120ms] ease-in-out",r?"opacity-0":"opacity-100",n?"justify-center":"justify-between"),children:n?c.jsx(Ne,{variant:"ghost",size:"icon",title:"Expand sidebar",onClick:t,children:c.jsx(ec,{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:be,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(Ne,{variant:"ghost",size:"icon",title:"Collapse sidebar",onClick:t,children:c.jsx(Eh,{className:"h-4 w-4"})})})]})})}),c.jsxs(Zc,{className:L("h-full transition-opacity duration-[120ms] ease-in-out",r?"opacity-0":"opacity-100"),children:[c.jsxs(Vr,{children:[c.jsxs(Br,{className:L("flex items-center",n?"justify-center":"justify-between"),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[!n&&c.jsx(Fi,{className:"size-3"}),!n&&c.jsx("span",{children:"Active Documents"})]}),c.jsxs(Lt,{open:f,onOpenChange:h,children:[c.jsx(lo,{asChild:!0,children:c.jsx("div",{className:L("flex",n?"w-full justify-center":""),children:c.jsx(Ne,{className:L("h-6 w-6 p-0 flex-shrink-0",n&&"mx-auto"),variant:"ghost",size:"icon",title:"New Document",disabled:!e||e.documents.length===0,children:n?c.jsx(Fi,{className:"size-4"}):c.jsx(Wr,{className:"size-4"})})})}),c.jsx(Ot,{className:"sm:max-w-[525px]",children:c.jsx(Qr,{mode:"create",shouldReset:!f,postSubmit:H,discoveredDocuments:(e==null?void 0:e.documents)||[]})})]})]}),n?c.jsx(Yn,{children:c.jsx("div",{className:"flex flex-col items-center gap-0.5 px-0.5",children:$.map(M=>{const B=re===M.name;return c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsxs("button",{onClick:()=>o(M.name),className:L("relative w-7 h-7 rounded flex items-center justify-center text-[10px] font-bold transition-colors",B?"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:[B&&c.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-0.5 rounded-full bg-green-500 dark:bg-green-400"}),M.name.charAt(0).toUpperCase()]})}),c.jsx(Ye,{side:"right",children:c.jsx("span",{className:"text-xs",children:M.name})})]},M.name)})})}):c.jsx(Yn,{children:c.jsx(Cs,{children:$.length>0?$.map((M,B)=>c.jsx(fo,{document:M,compact:n},`doc-${B}`)):c.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No active documents. Click + to create one."})})})]}),c.jsx(Lc,{}),c.jsxs(Vr,{children:[c.jsxs(Br,{className:L("flex items-center",n?"justify-center":"justify-between"),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[!n&&c.jsx(Gn,{className:"size-3 text-purple-600 dark:text-purple-400"}),!n&&c.jsx("span",{children:"Active Themes"})]}),e&&e.themes.length>0&&c.jsxs(Lt,{open:p,onOpenChange:m,children:[c.jsx(lo,{asChild:!0,children:c.jsx("div",{className:L("flex",n?"w-full justify-center":""),children:c.jsx(Ne,{className:L("h-6 w-6 p-0 flex-shrink-0",n&&"mx-auto"),variant:"ghost",size:"icon",title:"New Theme",children:n?c.jsx(Gn,{className:"size-4"}):c.jsx(Wr,{className:"size-4"})})})}),c.jsx(Ot,{className:"sm:max-w-[525px]",children:c.jsx(Qr,{mode:"create",shouldReset:!p,postSubmit:z,discoveredThemes:(e==null?void 0:e.themes)||[],isTheme:!0})})]})]}),n?c.jsx(Yn,{children:c.jsx("div",{className:"flex flex-col items-center gap-0.5 px-0.5",children:V.map(M=>{const B=re===M.name;let ee=null;try{const ge=JSON.parse(M.text);ee=vs(ge)}catch{}const pe=ee?Y.has(ee):!1;return c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsxs("button",{onClick:()=>o(M.name),className:L("relative w-7 h-7 rounded flex items-center justify-center text-[10px] font-bold transition-colors",B?"bg-purple-100 text-purple-700 dark:bg-purple-900/40 dark:text-purple-300":pe?"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:[B&&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(Gn,{className:"size-3"})]})}),c.jsx(Ye,{side:"right",children:c.jsxs("div",{className:"text-xs",children:[M.name,pe&&c.jsx("div",{className:"opacity-70",children:"In use"})]})})]},M.name)})})}):c.jsx(Yn,{children:c.jsx(Cs,{children:V.length>0?V.map((M,B)=>{let ee=null;try{const ge=JSON.parse(M.text);ee=vs(ge)}catch{}const pe=ee?Y.has(ee):!1;return c.jsx(fo,{document:M,compact:n,indicator:pe?"in-use":void 0},`theme-${B}`)}):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(Vr,{className:"mt-2 border-t pt-4",children:[c.jsx(Br,{className:L("flex items-center mb-2",n?"justify-center":"gap-2"),children:n?c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(Ya,{className:"size-3"})}),c.jsx(Ye,{side:"right",children:c.jsx("span",{className:"text-xs",children:"Expand sidebar to show discovered resources"})})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ya,{className:"size-3"}),c.jsx("span",{children:"Discovered Resources"})]})}),!n&&c.jsxs(c.Fragment,{children:[Object.entries(Z).map(([M,B])=>{if(B.length===0)return null;const ee=`${M}-docs`,pe=K.has(ee);return c.jsxs(Ui,{open:pe,children:[c.jsxs(Ji,{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(ee),children:[c.jsx(Gt,{className:L("size-3 transition-transform",!pe&&"-rotate-90")}),c.jsx(Fi,{className:"size-3"}),M==="current"?"Current Directory":"Project"," ","Documents (",B.length,")"]}),c.jsx(qi,{children:c.jsx("div",{className:"pl-4 space-y-0.5",children:B.map((ge,Xe)=>{const nt=i.some(Ie=>Ie.name===ge.name);return c.jsxs("button",{onClick:()=>fe(ge.name,!1),className:L("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",nt&&"opacity-50"),children:[c.jsx("div",{className:"font-medium truncate",children:ge.name}),ge.title&&c.jsx("div",{className:"text-xs text-muted-foreground truncate",children:ge.title})]},Xe)})})})]},ee)}),Object.entries(O).map(([M,B])=>{if(B.length===0)return null;const ee=`${M}-themes`,pe=K.has(ee);return c.jsxs(Ui,{open:pe,children:[c.jsxs(Ji,{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(ee),children:[c.jsx(Gt,{className:L("size-3 transition-transform",!pe&&"-rotate-90")}),c.jsx(Gn,{className:"size-3"}),M==="current"?"Current Directory":"Project"," ","Themes (",B.length,")"]}),c.jsx(qi,{children:c.jsx("div",{className:"pl-4 space-y-0.5",children:B.map((ge,Xe)=>{const nt=i.some(Ie=>Ie.name===ge.name);return c.jsxs("button",{onClick:()=>fe(ge.name,!0),className:L("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",nt&&"opacity-50"),children:[c.jsx("div",{className:"font-medium truncate",children:ge.name}),ge.description&&c.jsx("div",{className:"text-xs text-muted-foreground truncate",children:ge.description})]},Xe)})})})]},ee)}),e&&e.plugins.length>0&&c.jsxs(Ui,{open:K.has("plugins"),children:[c.jsxs(Ji,{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(Gt,{className:L("size-3 transition-transform",!K.has("plugins")&&"-rotate-90")}),c.jsx(Qu,{className:"size-3 text-amber-600 dark:text-amber-400"}),"Plugins (",E.size,"/",e.plugins.length,")"]}),c.jsx(qi,{children:c.jsx("div",{className:"pl-4 space-y-0.5",children:e.plugins.map((M,B)=>{const ee=D(M.name);return c.jsxs("div",{className:L("py-1 px-2 text-sm border-l-2 flex items-center gap-2 group transition-colors",ee?"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:M.name}),M.description&&c.jsx("div",{className:"text-xs opacity-70 truncate",children:M.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 ${M.name}`,onClick:pe=>{pe.stopPropagation(),_(M.name),S(!0)},children:c.jsx(tc,{className:"size-3 text-muted-foreground"})}),c.jsx(ya,{checked:ee,onCheckedChange:()=>g(M),disabled:k,className:"flex-none scale-[0.8]","aria-label":`Toggle ${M.name} plugin`})]},B)})})})]})]})]})]}),c.jsx($c,{children:c.jsx("div",{className:L("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(_g,{})})}),c.jsx(Lt,{open:w,onOpenChange:M=>{S(M),M||_(null)},children:c.jsx(Ot,{className:"sm:max-w-5xl max-h-[85vh] overflow-hidden",children:c.jsx(gg,{plugins:(e==null?void 0:e.plugins)||[],initialFocusedPlugin:b})})})]}),c.jsx(Wc,{open:N,onOpenChange:F,defaultTab:v==="theme"?"theme":"document"})]})}const po=x.memo(Eg),Ig=x.lazy(()=>Ku(()=>import("./editor-LsSIrw3S.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(e=>({default:e.Editor})));function ho(){return c.jsx(x.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(Ig,{})})}const Tg=x.lazy(()=>Ku(()=>import("./preview-CeZ8u4Ec.js"),__vite__mapDeps([12,1,2,3,5,6,7,8,9,10,11])).then(e=>({default:e.Preview})));function mo(){return c.jsx(x.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(Tg,{})})}const Ag=({className:e,...t})=>c.jsx(ph,{className:L("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),Hi=fh,go=({withHandle:e,className:t,...n})=>c.jsx(hh,{className:L("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(Ih,{className:"h-2.5 w-2.5"})})});function zg({children:e,className:t}){return c.jsx("kbd",{className:L("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 Og({children:e,className:t}){return c.jsx("span",{className:L("inline-flex items-center gap-0.5",t),children:e})}const Ar=typeof navigator<"u"&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);function Os({shortcut:e,className:t}){const r=e.split("+").map(i=>i.trim().toLowerCase()).map(i=>{switch(i){case"mod":return Ar?"⌘":"Ctrl";case"shift":return Ar?"⇧":"Shift";case"alt":return Ar?"⌥":"Alt";case"ctrl":return Ar?"⌃":"Ctrl";case"enter":return"↵";default:return i.toUpperCase()}});return c.jsx(Og,{className:t,children:r.map((i,s)=>c.jsx(zg,{children:i},s))})}class Pg{constructor(t){Wa(this,"client");this.client=Vp.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 Dg=new Pg;function Rg(){const e=x.useRef(null),t=x.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 ${Er.toLowerCase()} structure...`);const d={jsonDefinition:u,options:o||{}};d.customThemes=s??{},a==null||a("rendering",`Generating ${vt.toUpperCase()} content...`);const f={"Content-Type":"application/json"};o!=null&&o.bypassCache&&(f["X-Bypass-Cache"]="true");const h=await fetch(yh.generate,{method:"POST",headers:f,body:JSON.stringify(d),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,b=w.status==="HIT"?"HIT":w.status==="MISS"?"MISS":"UNKNOWN",_=b==="HIT"?`Served from cache (Hit rate: ${w.hitRate})`:`Generated fresh ${Er.toLowerCase()}`;a==null||a("finalizing",_);const g=globalThis.atob(m.document),D=new Uint8Array(g.length);for(let k=0;k<g.length;k++)D[k]=g.charCodeAt(k);const E=new Blob([D],{type:m.contentType});if(E.size===0)throw new Error(`Received empty ${Er.toLowerCase()} from API`);return{name:r,text:i,blob:E,filename:m.filename,fileId:m.fileId,cacheStatus:b,cacheHitRate:w.hitRate,warnings:S}}catch(u){throw u instanceof Error&&u.name==="AbortError"?new Error(`${Er} generation was cancelled`):u}finally{e.current===l&&(e.current=null)}},[]),n=x.useCallback(()=>{e.current&&(e.current.abort(),e.current=null)},[]);return{generatePresentation:t,cancelGeneration:n}}function Mg(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,d])=>`${u}: ${JSON.stringify(d)}`).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 xo=vt==="docx"?["docxjs","LibreOffice"]:["LibreOffice"],Wi={docxjs:["⚡","(Recommended) works in the browser"],LibreOffice:["🖨️","(High fidelity) converts to PDF locally with LibreOffice"]};function Fg({name:e,blob:t,displayReloadButton:n,iframeRef:r,autoReload:i,onToggleAutoReload:s,onManualRender:a,isGenerating:o,isRendering:l,onShowCacheMetrics:u,onShowSchemas:d,documentText:f,warnings:h,renderingLibrary:p,setRenderingLibrary:m,onToggleChat:w,chatOpen:S,onTogglePreview:b,previewOpen:_}){const g=p!=="docxjs",[D,E]=x.useState(!1),[k,N]=x.useState(!1),[F,K]=x.useState(!1),[C,q]=x.useState(!1),[$,V]=x.useState(!1),[Z,O]=x.useState(!1),{toast:Y}=ia(),{generatePresentation:H}=Rg(),z=x.useCallback(async()=>{if(t){E(!0);try{await new Promise(v=>setTimeout(v,100)),Es(`${e}${Ir}`,t)}finally{setTimeout(()=>E(!1),500)}}},[t,e]),J=x.useCallback(async()=>{if(!(!h||h.length===0)){N(!0);try{const v=Mg(h);if(!v){Y({title:"No warnings",description:"There are no warnings to download.",variant:"destructive"});return}const se=await H("warnings",JSON.stringify(v,null,2),{});se&&typeof se=="object"&&"blob"in se&&se.blob&&(Es(`${e}-warnings${Ir}`,se.blob),Y({title:"Warnings downloaded",description:`Downloaded warnings document with ${h.length} warning(s).`}))}catch(v){console.error("Failed to generate warnings document:",v),Y({title:"Download failed",description:v instanceof Error?v.message:"Failed to generate warnings document",variant:"destructive"})}finally{setTimeout(()=>N(!1),500)}}},[h,e,H,Y]),y=x.useCallback(async()=>{const v=r==null?void 0:r.current;if(v!=null&&v.src){K(!0);try{await new Promise(be=>{let fe=null,M=!1;const B=()=>{fe&&(clearTimeout(fe),fe=null),v.removeEventListener("load",pe),v.removeEventListener("error",ge)},ee=()=>{M||(M=!0,B(),be())},pe=()=>ee(),ge=()=>ee();v.addEventListener("load",pe),v.addEventListener("error",ge),fe=setTimeout(()=>{console.warn("Iframe reload timed out after 5 seconds"),ee()},5e3);const Xe=v.src,nt=Xe.includes("?")?"&":"?",Ie=Date.now();v.src=`${Xe}${nt}_reload=${Ie}`})}catch(se){console.error("Iframe reload failed:",se)}finally{K(!1)}}},[r]),ue=x.useCallback(async()=>{q(!0);try{await Dg.delete(`/${vt}/cache`),window.dispatchEvent(new CustomEvent("cache:cleared")),Y({title:"Cache Cleared",description:"All caches (document and component) have been successfully cleared.",variant:"default"})}catch(v){console.error("Failed to clear cache:",v),Y({title:"Cache Clear Failed",description:"Failed to clear caches. Please try again.",variant:"destructive"})}finally{q(!1)}},[Y]),re=x.useCallback(async()=>{if(!f){Y({title:"No document available",description:"Please select a document to copy standard components",variant:"destructive"});return}O(!0);try{const v=await fetch(`/api/${vt}/standard-components`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonDefinition:f})});if(!v.ok){let fe=`Request failed with status ${v.status}`;try{const M=await v.json();M.message&&(fe=M.message)}catch{}Y({title:"Failed to get standard components",description:fe,variant:"destructive"});return}const se=await v.json(),be=JSON.stringify(se.data,null,2);await navigator.clipboard.writeText(be),Y({title:"Copied to clipboard",description:"Standard modules JSON has been copied"})}catch(v){console.error("Error copying standard components:",v),Y({title:"Error",description:v instanceof Error?v.message:"Failed to copy standard components",variant:"destructive"})}finally{O(!1)}},[f,Y]);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(Ge,{children:[c.jsx(Ke,{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(tc,{className:"h-3.5 w-3.5 text-muted-foreground"})})}),c.jsx(Ye,{className:"max-w-sm",children:c.jsxs("p",{className:"text-sm",children:["Preview uses ",vt==="docx"?"docx-preview":"LibreOffice PDF conversion",". Download the ",Ir," to verify fidelity."]})})]})]}),c.jsxs("div",{className:"flex flex-row items-center gap-x-1 shrink-0",children:[(!i||g)&&c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsxs(Ne,{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(Th,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Run"})]})}),c.jsx(Ye,{children:c.jsx("p",{children:_===!1?"Open preview to run":l?"Rendering preview...":"Render preview"})})]}),vt==="docx"&&c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsxs("div",{className:"flex items-center gap-1.5 cursor-help ml-2 mr-1",children:[c.jsx(fa,{className:"text-xs text-muted-foreground hidden sm:inline",children:"Auto"}),c.jsx(ya,{checked:i,onCheckedChange:s,disabled:g})]})}),c.jsx(Ye,{children:c.jsx("p",{children:g?"Auto-reload is not available for Office, Docs, and LibreOffice renderers":`${i?"Disable":"Enable"} automatic preview reload on content changes`})})]}),n&&i&&c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(Ne,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:y,disabled:F||o||l,children:F?c.jsx(qt,{size:"sm"}):c.jsx(Ah,{className:"h-3.5 w-3.5"})})}),c.jsx(Ye,{children:c.jsx("p",{children:F?"Reloading...":"Reload"})})]}),c.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsxs(Ne,{variant:"outline",size:"sm",className:"gap-1.5 h-7 px-2.5",disabled:!t||D||o,onClick:z,children:[D?c.jsx(qt,{size:"sm"}):c.jsx(zh,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Download"})]})}),c.jsx(Ye,{children:c.jsxs("p",{children:["Download ",Ir]})})]}),h&&h.length>0&&c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(Ne,{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:J,children:k?c.jsx(qt,{size:"sm"}):c.jsx(nc,{className:"h-3.5 w-3.5"})})}),c.jsx(Ye,{children:c.jsxs("p",{children:["Download warnings (",h.length,")"]})})]}),p&&m&&c.jsxs(ha,{value:p,onValueChange:m,children:[c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(Si,{className:"w-[140px] h-7 text-xs hidden lg:flex",children:c.jsx(ma,{placeholder:"Renderer"})})}),c.jsx(Ye,{children:c.jsx("p",{children:"Select the rendering library"})})]}),c.jsx(ji,{className:"text-sidebar-foreground",children:xo.map(v=>c.jsxs(cr,{value:v,children:[c.jsxs(Ge,{children:[c.jsx(Ke,{tabIndex:-1,children:Wi[v][0]}),c.jsx(Ye,{children:Wi[v][1]})]})," ",v]},v))})]}),c.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),c.jsxs(Jc,{children:[c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(qc,{asChild:!0,children:c.jsx(Ne,{variant:"ghost",size:"icon",className:"h-7 w-7",children:c.jsx(Oh,{className:"h-3.5 w-3.5"})})})}),c.jsx(Ye,{children:c.jsx("p",{children:"More actions"})})]}),c.jsxs(ba,{align:"end",className:"w-52",children:[d&&c.jsxs(Wt,{onClick:d,children:[c.jsx(Ph,{className:"h-4 w-4 mr-2"}),"View JSON Schemas"]}),u&&c.jsxs(Wt,{onClick:u,children:[c.jsx(Dh,{className:"h-4 w-4 mr-2"}),"View cache metrics"]}),c.jsxs(Wt,{onClick:re,disabled:!f||Z,children:[c.jsx(rc,{className:"h-4 w-4 mr-2"}),Z?"Copying...":"Copy standard components"]}),c.jsx(ni,{}),c.jsxs(Wt,{onClick:()=>V(!0),disabled:C,className:"text-destructive focus:text-destructive",children:[c.jsx(aa,{className:"h-4 w-4 mr-2"}),C?"Clearing...":"Clear all caches"]}),p&&m&&c.jsxs(c.Fragment,{children:[c.jsx(ni,{className:"lg:hidden"}),xo.map(v=>c.jsxs(Wt,{className:"lg:hidden",onClick:()=>m(v),children:[c.jsx("span",{className:"mr-2",children:p===v?"●":"○"}),Wi[v][0]," ",v]},v))]})]})]}),b&&c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(Ne,{variant:_?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:b,children:_?c.jsx(ic,{className:"h-3.5 w-3.5"}):c.jsx(Rh,{className:"h-3.5 w-3.5"})})}),c.jsx(Ye,{children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[_?"Hide":"Show"," Preview ",c.jsx(Os,{shortcut:"mod+shift+p"})]})})]}),w&&c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(Ne,{variant:S?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:w,children:c.jsx(sc,{className:"h-3.5 w-3.5"})})}),c.jsx(Ye,{children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[S?"Close":"Open"," AI Chat ",c.jsx(Os,{shortcut:"mod+shift+j"})]})})]})]})]}),c.jsx(Lt,{open:$,onOpenChange:V,children:c.jsxs(Ot,{className:"max-w-sm",children:[c.jsxs(pn,{children:[c.jsx(hn,{children:"Clear all caches?"}),c.jsx(An,{children:"This will clear document and component caches. Next generation will be uncached."})]}),c.jsxs(ur,{children:[c.jsx(Ne,{variant:"outline",size:"sm",onClick:()=>V(!1),children:"Cancel"}),c.jsx(Ne,{variant:"destructive",size:"sm",disabled:C,onClick:async()=>{await ue(),V(!1)},children:C?c.jsx(qt,{size:"sm"}):"Clear"})]})]})})]})}const $g=je.memo(Fg);function yo({previewOpen:e,onTogglePreview:t}){const n=on(N=>N.name||""),r=on(N=>N.blob),i=on(N=>N.isGenerating),s=on(N=>N.text),a=on(N=>N.warnings),o=on(N=>N.isRendering),l=Tr(N=>N.autoReload),u=Tr(N=>N.renderingLibrary),d=Tr(N=>N.setSettings),f=Tr(N=>N.useGlobalPreviewHeader??!0),h=qe(N=>N.activeTab),p=qe(N=>N.documentTypes),m=h&&p[h]==="application/json+theme"?"theme":"document",w=Ce(N=>N.chatOpen),S=Ce(N=>N.toggleChat),[b,_]=je.useState(!1);if(!f)return null;const g=x.useCallback(()=>d({saveDocumentDebounceWait:2e3,autoReload:!l}),[l,d]),D=x.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:manualRender"))},[]),E=x.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($g,{name:k,blob:r,displayReloadButton:!1,autoReload:l,onToggleAutoReload:g,onManualRender:D,isGenerating:i,isRendering:!!o,onShowCacheMetrics:E,onShowSchemas:()=>_(!0),documentText:s,warnings:a,renderingLibrary:u,setRenderingLibrary:N=>d({renderingLibrary:N}),onToggleChat:S,chatOpen:w,onTogglePreview:t,previewOpen:e}),c.jsx(Wc,{open:b,onOpenChange:_,defaultTab:m==="theme"?"theme":"document"})]})}function Lg(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Zg=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Vg=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Bg={};function bo(e,t){return(Bg.jsx?Vg:Zg).test(e)}const Ug=/[ \t\n\f\r]/g;function Jg(e){return typeof e=="object"?e.type==="text"?vo(e.value):!1:vo(e)}function vo(e){return e.replace(Ug,"")===""}class kr{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}kr.prototype.normal={};kr.prototype.property={};kr.prototype.space=void 0;function Gc(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new kr(n,r,t)}function Ps(e){return e.toLowerCase()}class ft{constructor(t,n){this.attribute=n,this.property=t}}ft.prototype.attribute="";ft.prototype.booleanish=!1;ft.prototype.boolean=!1;ft.prototype.commaOrSpaceSeparated=!1;ft.prototype.commaSeparated=!1;ft.prototype.defined=!1;ft.prototype.mustUseProperty=!1;ft.prototype.number=!1;ft.prototype.overloadedBoolean=!1;ft.prototype.property="";ft.prototype.spaceSeparated=!1;ft.prototype.space=void 0;let qg=0;const xe=xn(),Je=xn(),Ds=xn(),W=xn(),Pe=xn(),In=xn(),ht=xn();function xn(){return 2**++qg}const Rs=Object.freeze(Object.defineProperty({__proto__:null,boolean:xe,booleanish:Je,commaOrSpaceSeparated:ht,commaSeparated:In,number:W,overloadedBoolean:Ds,spaceSeparated:Pe},Symbol.toStringTag,{value:"Module"})),Gi=Object.keys(Rs);class va extends ft{constructor(t,n,r,i){let s=-1;if(super(t,n),wo(this,"space",i),typeof r=="number")for(;++s<Gi.length;){const a=Gi[s];wo(this,Gi[s],(r&Rs[a])===Rs[a])}}}va.prototype.defined=!0;function wo(e,t,n){n&&(e[t]=n)}function Mn(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new va(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Ps(r)]=r,n[Ps(s.attribute)]=r}return new kr(t,n,e.space)}const Kc=Mn({properties:{ariaActiveDescendant:null,ariaAtomic:Je,ariaAutoComplete:null,ariaBusy:Je,ariaChecked:Je,ariaColCount:W,ariaColIndex:W,ariaColSpan:W,ariaControls:Pe,ariaCurrent:null,ariaDescribedBy:Pe,ariaDetails:null,ariaDisabled:Je,ariaDropEffect:Pe,ariaErrorMessage:null,ariaExpanded:Je,ariaFlowTo:Pe,ariaGrabbed:Je,ariaHasPopup:null,ariaHidden:Je,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Pe,ariaLevel:W,ariaLive:null,ariaModal:Je,ariaMultiLine:Je,ariaMultiSelectable:Je,ariaOrientation:null,ariaOwns:Pe,ariaPlaceholder:null,ariaPosInSet:W,ariaPressed:Je,ariaReadOnly:Je,ariaRelevant:null,ariaRequired:Je,ariaRoleDescription:Pe,ariaRowCount:W,ariaRowIndex:W,ariaRowSpan:W,ariaSelected:Je,ariaSetSize:W,ariaSort:null,ariaValueMax:W,ariaValueMin:W,ariaValueNow:W,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Yc(e,t){return t in e?e[t]:t}function Xc(e,t){return Yc(e,t.toLowerCase())}const Hg=Mn({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:In,acceptCharset:Pe,accessKey:Pe,action:null,allow:null,allowFullScreen:xe,allowPaymentRequest:xe,allowUserMedia:xe,alt:null,as:null,async:xe,autoCapitalize:null,autoComplete:Pe,autoFocus:xe,autoPlay:xe,blocking:Pe,capture:null,charSet:null,checked:xe,cite:null,className:Pe,cols:W,colSpan:null,content:null,contentEditable:Je,controls:xe,controlsList:Pe,coords:W|In,crossOrigin:null,data:null,dateTime:null,decoding:null,default:xe,defer:xe,dir:null,dirName:null,disabled:xe,download:Ds,draggable:Je,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:xe,formTarget:null,headers:Pe,height:W,hidden:Ds,high:W,href:null,hrefLang:null,htmlFor:Pe,httpEquiv:Pe,id:null,imageSizes:null,imageSrcSet:null,inert:xe,inputMode:null,integrity:null,is:null,isMap:xe,itemId:null,itemProp:Pe,itemRef:Pe,itemScope:xe,itemType:Pe,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:xe,low:W,manifest:null,max:null,maxLength:W,media:null,method:null,min:null,minLength:W,multiple:xe,muted:xe,name:null,nonce:null,noModule:xe,noValidate:xe,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:xe,optimum:W,pattern:null,ping:Pe,placeholder:null,playsInline:xe,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:xe,referrerPolicy:null,rel:Pe,required:xe,reversed:xe,rows:W,rowSpan:W,sandbox:Pe,scope:null,scoped:xe,seamless:xe,selected:xe,shadowRootClonable:xe,shadowRootDelegatesFocus:xe,shadowRootMode:null,shape:null,size:W,sizes:null,slot:null,span:W,spellCheck:Je,src:null,srcDoc:null,srcLang:null,srcSet:null,start:W,step:null,style:null,tabIndex:W,target:null,title:null,translate:null,type:null,typeMustMatch:xe,useMap:null,value:Je,width:W,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Pe,axis:null,background:null,bgColor:null,border:W,borderColor:null,bottomMargin:W,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:xe,declare:xe,event:null,face:null,frame:null,frameBorder:null,hSpace:W,leftMargin:W,link:null,longDesc:null,lowSrc:null,marginHeight:W,marginWidth:W,noResize:xe,noHref:xe,noShade:xe,noWrap:xe,object:null,profile:null,prompt:null,rev:null,rightMargin:W,rules:null,scheme:null,scrolling:Je,standby:null,summary:null,text:null,topMargin:W,valueType:null,version:null,vAlign:null,vLink:null,vSpace:W,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:xe,disableRemotePlayback:xe,prefix:null,property:null,results:W,security:null,unselectable:null},space:"html",transform:Xc}),Wg=Mn({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:ht,accentHeight:W,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:W,amplitude:W,arabicForm:null,ascent:W,attributeName:null,attributeType:null,azimuth:W,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:W,by:null,calcMode:null,capHeight:W,className:Pe,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:W,diffuseConstant:W,direction:null,display:null,dur:null,divisor:W,dominantBaseline:null,download:xe,dx:null,dy:null,edgeMode:null,editable:null,elevation:W,enableBackground:null,end:null,event:null,exponent:W,externalResourcesRequired:null,fill:null,fillOpacity:W,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:In,g2:In,glyphName:In,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:W,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:W,horizOriginX:W,horizOriginY:W,id:null,ideographic:W,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:W,k:W,k1:W,k2:W,k3:W,k4:W,kernelMatrix:ht,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:W,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:W,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:W,overlineThickness:W,paintOrder:null,panose1:null,path:null,pathLength:W,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Pe,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:W,pointsAtY:W,pointsAtZ:W,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ht,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ht,rev:ht,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ht,requiredFeatures:ht,requiredFonts:ht,requiredFormats:ht,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:W,specularExponent:W,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:W,strikethroughThickness:W,string:null,stroke:null,strokeDashArray:ht,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:W,strokeOpacity:W,strokeWidth:null,style:null,surfaceScale:W,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ht,tabIndex:W,tableValues:null,target:null,targetX:W,targetY:W,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ht,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:W,underlineThickness:W,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:W,values:null,vAlphabetic:W,vMathematical:W,vectorEffect:null,vHanging:W,vIdeographic:W,version:null,vertAdvY:W,vertOriginX:W,vertOriginY:W,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:W,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Yc}),Qc=Mn({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()}}),ed=Mn({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Xc}),td=Mn({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Gg={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"},Kg=/[A-Z]/g,ko=/-[a-z]/g,Yg=/^data[-\w.:]+$/i;function Xg(e,t){const n=Ps(t);let r=t,i=ft;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Yg.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(ko,ex);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!ko.test(s)){let a=s.replace(Kg,Qg);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=va}return new i(r,t)}function Qg(e){return"-"+e.toLowerCase()}function ex(e){return e.charAt(1).toUpperCase()}const tx=Gc([Kc,Hg,Qc,ed,td],"html"),wa=Gc([Kc,Wg,Qc,ed,td],"svg");function nx(e){return e.join(" ").trim()}var vn={},Ki,_o;function rx(){if(_o)return Ki;_o=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="/",d="*",f="",h="comment",p="declaration";function m(S,b){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];b=b||{};var _=1,g=1;function D(Z){var O=Z.match(t);O&&(_+=O.length);var Y=Z.lastIndexOf(l);g=~Y?Z.length-Y:g+Z.length}function E(){var Z={line:_,column:g};return function(O){return O.position=new k(Z),K(),O}}function k(Z){this.start=Z,this.end={line:_,column:g},this.source=b.source}k.prototype.content=S;function N(Z){var O=new Error(b.source+":"+_+":"+g+": "+Z);if(O.reason=Z,O.filename=b.source,O.line=_,O.column=g,O.source=S,!b.silent)throw O}function F(Z){var O=Z.exec(S);if(O){var Y=O[0];return D(Y),S=S.slice(Y.length),O}}function K(){F(n)}function C(Z){var O;for(Z=Z||[];O=q();)O!==!1&&Z.push(O);return Z}function q(){var Z=E();if(!(u!=S.charAt(0)||d!=S.charAt(1))){for(var O=2;f!=S.charAt(O)&&(d!=S.charAt(O)||u!=S.charAt(O+1));)++O;if(O+=2,f===S.charAt(O-1))return N("End of comment missing");var Y=S.slice(2,O-2);return g+=2,D(Y),S=S.slice(O),g+=2,Z({type:h,comment:Y})}}function $(){var Z=E(),O=F(r);if(O){if(q(),!F(i))return N("property missing ':'");var Y=F(s),H=Z({type:p,property:w(O[0].replace(e,f)),value:Y?w(Y[0].replace(e,f)):f});return F(a),H}}function V(){var Z=[];C(Z);for(var O;O=$();)O!==!1&&(Z.push(O),C(Z));return Z}return K(),V()}function w(S){return S?S.replace(o,f):f}return Ki=m,Ki}var So;function ix(){if(So)return vn;So=1;var e=vn&&vn.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(vn,"__esModule",{value:!0}),vn.default=n;const t=e(rx());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:d}=l;o?i(u,d,l):d&&(s=s||{},s[u]=d)}),s}return vn}var Un={},jo;function sx(){if(jo)return Un;jo=1,Object.defineProperty(Un,"__esModule",{value:!0}),Un.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,d){return d.toUpperCase()},o=function(u,d){return"".concat(d,"-")},l=function(u,d){return d===void 0&&(d={}),s(u)?u:(u=u.toLowerCase(),d.reactCompat?u=u.replace(i,o):u=u.replace(r,o),u.replace(t,a))};return Un.camelCase=l,Un}var Jn,No;function ax(){if(No)return Jn;No=1;var e=Jn&&Jn.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(ix()),n=sx();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,Jn=r,Jn}var ox=ax();const lx=ra(ox),nd=rd("end"),ka=rd("start");function rd(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 ux(e){const t=ka(e),n=nd(e);if(t&&n)return{start:t,end:n}}function ar(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Co(e.position):"start"in e||"end"in e?Co(e):"line"in e||"column"in e?Ms(e):""}function Ms(e){return Eo(e&&e.line)+":"+Eo(e&&e.column)}function Co(e){return Ms(e&&e.start)+"-"+Ms(e&&e.end)}function Eo(e){return e&&typeof e=="number"?e:1}class tt 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=ar(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}}tt.prototype.file="";tt.prototype.name="";tt.prototype.reason="";tt.prototype.message="";tt.prototype.stack="";tt.prototype.column=void 0;tt.prototype.line=void 0;tt.prototype.ancestors=void 0;tt.prototype.cause=void 0;tt.prototype.fatal=void 0;tt.prototype.place=void 0;tt.prototype.ruleId=void 0;tt.prototype.source=void 0;const _a={}.hasOwnProperty,cx=new Map,dx=/[A-Z]/g,fx=new Set(["table","tbody","thead","tfoot","tr"]),px=new Set(["td","th"]),id="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function hx(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=kx(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=wx(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"?wa:tx,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=sd(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function sd(e,t,n){if(t.type==="element")return mx(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return gx(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return yx(e,t,n);if(t.type==="mdxjsEsm")return xx(e,t);if(t.type==="root")return bx(e,t,n);if(t.type==="text")return vx(e,t)}function mx(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=wa,e.schema=i),e.ancestors.push(t);const s=od(e,t.tagName,!1),a=_x(e,t);let o=ja(e,t);return fx.has(t.tagName)&&(o=o.filter(function(l){return typeof l=="string"?!Jg(l):!0})),ad(e,a,s,t),Sa(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function gx(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}fr(e,t.position)}function xx(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);fr(e,t.position)}function yx(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=wa,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:od(e,t.name,!0),a=Sx(e,t),o=ja(e,t);return ad(e,a,s,t),Sa(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function bx(e,t,n){const r={};return Sa(r,ja(e,t)),e.create(t,e.Fragment,r,n)}function vx(e,t){return t.value}function ad(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Sa(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function wx(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 kx(e,t){return n;function n(r,i,s,a){const o=Array.isArray(s.children),l=ka(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 _x(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&_a.call(t.properties,i)){const s=jx(e,i,t.properties[i]);if(s){const[a,o]=s;e.tableCellAlignToStyle&&a==="align"&&typeof o=="string"&&px.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 Sx(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const a=s.expression;a.type;const o=a.properties[0];o.type,Object.assign(n,e.evaluater.evaluateExpression(o.argument))}else fr(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const o=r.value.data.estree.body[0];o.type,s=e.evaluater.evaluateExpression(o.expression)}else fr(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function ja(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:cx;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=sd(e,s,a);o!==void 0&&n.push(o)}return n}function jx(e,t,n){const r=Xg(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Lg(n):nx(n)),r.property==="style"){let i=typeof n=="object"?n:Nx(e,String(n));return e.stylePropertyNameCase==="css"&&(i=Cx(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?Gg[r.property]||r.property:r.attribute,n]}}function Nx(e,t){try{return lx(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new tt("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=id+"#cannot-parse-style-attribute",i}}function od(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=bo(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=bo(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return _a.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);fr(e)}function fr(e,t){const n=new tt("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=id+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Cx(e){const t={};let n;for(n in e)_a.call(e,n)&&(t[Ex(n)]=e[n]);return t}function Ex(e){let t=e.replace(dx,Ix);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Ix(e){return"-"+e.toLowerCase()}const Yi={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"]},Tx={};function Na(e,t){const n=Tx,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return ld(e,r,i)}function ld(e,t,n){if(Ax(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 Io(e.children,t,n)}return Array.isArray(e)?Io(e,t,n):""}function Io(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=ld(e[i],t,n);return r.join("")}function Ax(e){return!!(e&&typeof e=="object")}const To=document.createElement("i");function Ca(e){const t="&"+e+";";To.innerHTML=t;const n=To.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function mt(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 bt(e,t){return e.length>0?(mt(e,e.length,0,t),e):t}const Ao={}.hasOwnProperty;function ud(e){const t={};let n=-1;for(;++n<e.length;)zx(t,e[n]);return t}function zx(e,t){let n;for(n in t){const i=(Ao.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let a;if(s)for(a in s){Ao.call(i,a)||(i[a]=[]);const o=s[a];Ox(i[a],Array.isArray(o)?o:o?[o]:[])}}}function Ox(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);mt(e,0,0,r)}function cd(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 Ct(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ot=Qt(/[A-Za-z]/),et=Qt(/[\dA-Za-z]/),Px=Qt(/[#-'*+\--9=?A-Z^-~]/);function ri(e){return e!==null&&(e<32||e===127)}const Fs=Qt(/\d/),Dx=Qt(/[\dA-Fa-f]/),Rx=Qt(/[!-/:-@[-`{-~]/);function ce(e){return e!==null&&e<-2}function ze(e){return e!==null&&(e<0||e===32)}function ve(e){return e===-2||e===-1||e===32}const Ci=Qt(new RegExp("\\p{P}|\\p{S}","u")),mn=Qt(/\s/);function Qt(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Fn(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let a="";if(s===37&&et(e.charCodeAt(n+1))&&et(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 Se(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return a;function a(l){return ve(l)?(e.enter(n),o(l)):t(l)}function o(l){return ve(l)&&s++<i?(e.consume(l),o):(e.exit(n),t(l))}}const Mx={tokenize:Fx};function Fx(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"),Se(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 ce(o)?(e.consume(o),e.exit("chunkText"),s):(e.consume(o),a)}}const $x={tokenize:Lx},zo={tokenize:Zx};function Lx(e){const t=this,n=[];let r=0,i,s,a;return o;function o(g){if(r<n.length){const D=n[r];return t.containerState=D[1],e.attempt(D[0].continuation,l,u)(g)}return u(g)}function l(g){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&_();const D=t.events.length;let E=D,k;for(;E--;)if(t.events[E][0]==="exit"&&t.events[E][1].type==="chunkFlow"){k=t.events[E][1].end;break}b(r);let N=D;for(;N<t.events.length;)t.events[N][1].end={...k},N++;return mt(t.events,E+1,0,t.events.slice(D)),t.events.length=N,u(g)}return o(g)}function u(g){if(r===n.length){if(!i)return h(g);if(i.currentConstruct&&i.currentConstruct.concrete)return m(g);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(zo,d,f)(g)}function d(g){return i&&_(),b(r),h(g)}function f(g){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,m(g)}function h(g){return t.containerState={},e.attempt(zo,p,m)(g)}function p(g){return r++,n.push([t.currentConstruct,t.containerState]),h(g)}function m(g){if(g===null){i&&_(),b(0),e.consume(g);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),w(g)}function w(g){if(g===null){S(e.exit("chunkFlow"),!0),b(0),e.consume(g);return}return ce(g)?(e.consume(g),S(e.exit("chunkFlow")),r=0,t.interrupt=void 0,o):(e.consume(g),w)}function S(g,D){const E=t.sliceStream(g);if(D&&E.push(null),g.previous=s,s&&(s.next=g),s=g,i.defineSkip(g.start),i.write(E),t.parser.lazy[g.start.line]){let k=i.events.length;for(;k--;)if(i.events[k][1].start.offset<a&&(!i.events[k][1].end||i.events[k][1].end.offset>a))return;const N=t.events.length;let F=N,K,C;for(;F--;)if(t.events[F][0]==="exit"&&t.events[F][1].type==="chunkFlow"){if(K){C=t.events[F][1].end;break}K=!0}for(b(r),k=N;k<t.events.length;)t.events[k][1].end={...C},k++;mt(t.events,F+1,0,t.events.slice(N)),t.events.length=k}}function b(g){let D=n.length;for(;D-- >g;){const E=n[D];t.containerState=E[1],E[0].exit.call(t,e)}n.length=g}function _(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Zx(e,t,n){return Se(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function zn(e){if(e===null||ze(e)||mn(e))return 1;if(Ci(e))return 2}function Ei(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 $s={name:"attention",resolveAll:Vx,tokenize:Bx};function Vx(e,t){let n=-1,r,i,s,a,o,l,u,d;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},h={...e[n][1].start};Oo(f,-l),Oo(h,l),a={type:l>1?"strongSequence":"emphasisSequence",start:f,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=bt(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=bt(u,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",s,t]]),u=bt(u,Ei(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=bt(u,[["exit",s,t],["enter",o,t],["exit",o,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,u=bt(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,mt(e,r-1,n-r+3,u),n=r+u.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function Bx(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=zn(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"),d=zn(l),f=!d||d===2&&i||n.includes(l),h=!i||i===2&&d||n.includes(r);return u._open=!!(s===42?f:f&&(i||!h)),u._close=!!(s===42?h:h&&(d||!f)),t(l)}}function Oo(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Ux={name:"autolink",tokenize:Jx};function Jx(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 ot(p)?(e.consume(p),a):p===64?n(p):u(p)}function a(p){return p===43||p===45||p===46||et(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||et(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||ri(p)?n(p):(e.consume(p),l)}function u(p){return p===64?(e.consume(p),d):Px(p)?(e.consume(p),u):n(p)}function d(p){return et(p)?f(p):n(p)}function f(p){return p===46?(e.consume(p),r=0,d):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||et(p))&&r++<63){const m=p===45?h:f;return e.consume(p),m}return n(p)}}const _r={partial:!0,tokenize:qx};function qx(e,t,n){return r;function r(s){return ve(s)?Se(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||ce(s)?t(s):n(s)}}const dd={continuation:{tokenize:Wx},exit:Gx,name:"blockQuote",tokenize:Hx};function Hx(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 ve(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function Wx(e,t,n){const r=this;return i;function i(a){return ve(a)?Se(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):s(a)}function s(a){return e.attempt(dd,t,n)(a)}}function Gx(e){e.exit("blockQuote")}const fd={name:"characterEscape",tokenize:Kx};function Kx(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 Rx(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const pd={name:"characterReference",tokenize:Yx};function Yx(e,t,n){const r=this;let i=0,s,a;return o;function o(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),l}function l(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),s=31,a=et,d(f))}function u(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,a=Dx,d):(e.enter("characterReferenceValue"),s=7,a=Fs,d(f))}function d(f){if(f===59&&i){const h=e.exit("characterReferenceValue");return a===et&&!Ca(r.sliceSerialize(h))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(f)&&i++<s?(e.consume(f),d):n(f)}}const Po={partial:!0,tokenize:Qx},Do={concrete:!0,name:"codeFenced",tokenize:Xx};function Xx(e,t,n){const r=this,i={partial:!0,tokenize:E};let s=0,a=0,o;return l;function l(k){return u(k)}function u(k){const N=r.events[r.events.length-1];return s=N&&N[1].type==="linePrefix"?N[2].sliceSerialize(N[1],!0).length:0,o=k,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(k)}function d(k){return k===o?(a++,e.consume(k),d):a<3?n(k):(e.exit("codeFencedFenceSequence"),ve(k)?Se(e,f,"whitespace")(k):f(k))}function f(k){return k===null||ce(k)?(e.exit("codeFencedFence"),r.interrupt?t(k):e.check(Po,w,D)(k)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),h(k))}function h(k){return k===null||ce(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(k)):ve(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Se(e,p,"whitespace")(k)):k===96&&k===o?n(k):(e.consume(k),h)}function p(k){return k===null||ce(k)?f(k):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(k))}function m(k){return k===null||ce(k)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(k)):k===96&&k===o?n(k):(e.consume(k),m)}function w(k){return e.attempt(i,D,S)(k)}function S(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),b}function b(k){return s>0&&ve(k)?Se(e,_,"linePrefix",s+1)(k):_(k)}function _(k){return k===null||ce(k)?e.check(Po,w,D)(k):(e.enter("codeFlowValue"),g(k))}function g(k){return k===null||ce(k)?(e.exit("codeFlowValue"),_(k)):(e.consume(k),g)}function D(k){return e.exit("codeFenced"),t(k)}function E(k,N,F){let K=0;return C;function C(O){return k.enter("lineEnding"),k.consume(O),k.exit("lineEnding"),q}function q(O){return k.enter("codeFencedFence"),ve(O)?Se(k,$,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):$(O)}function $(O){return O===o?(k.enter("codeFencedFenceSequence"),V(O)):F(O)}function V(O){return O===o?(K++,k.consume(O),V):K>=a?(k.exit("codeFencedFenceSequence"),ve(O)?Se(k,Z,"whitespace")(O):Z(O)):F(O)}function Z(O){return O===null||ce(O)?(k.exit("codeFencedFence"),N(O)):F(O)}}}function Qx(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 Xi={name:"codeIndented",tokenize:ty},ey={partial:!0,tokenize:ny};function ty(e,t,n){const r=this;return i;function i(u){return e.enter("codeIndented"),Se(e,s,"linePrefix",5)(u)}function s(u){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?a(u):n(u)}function a(u){return u===null?l(u):ce(u)?e.attempt(ey,a,l)(u):(e.enter("codeFlowValue"),o(u))}function o(u){return u===null||ce(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),o)}function l(u){return e.exit("codeIndented"),t(u)}}function ny(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):ce(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):Se(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):ce(a)?i(a):n(a)}}const ry={name:"codeText",previous:sy,resolve:iy,tokenize:ay};function iy(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 sy(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function ay(e,t,n){let r=0,i,s;return a;function a(f){return e.enter("codeText"),e.enter("codeTextSequence"),o(f)}function o(f){return f===96?(e.consume(f),r++,o):(e.exit("codeTextSequence"),l(f))}function l(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),l):f===96?(s=e.enter("codeTextSequence"),i=0,d(f)):ce(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),l):(e.enter("codeTextData"),u(f))}function u(f){return f===null||f===32||f===96||ce(f)?(e.exit("codeTextData"),l(f)):(e.consume(f),u)}function d(f){return f===96?(e.consume(f),i++,d):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(s.type="codeTextData",u(f))}}class oy{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&&qn(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),qn(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),qn(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);qn(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);qn(this.left,n.reverse())}}}function qn(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 hd(e){const t={};let n=-1,r,i,s,a,o,l,u;const d=new oy(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type==="chunkFlow"&&d.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,ly(d,n)),n=t[n],u=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(a=d.get(s),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(i&&(d.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={...d.get(i)[1].start},o=d.slice(i,n),o.unshift(r),d.splice(i,n-i+1,o))}}return mt(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function ly(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 d,f,h=-1,p=n,m=0,w=0;const S=[w];for(;p;){for(;e.get(++i)[1]!==p;);s.push(i),p._tokenizer||(d=r.sliceStream(p),p.next||d.push(null),f&&a.defineSkip(p.start),p._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(d),p._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),f=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 b=o.slice(S[h],S[h+1]),_=s.pop();l.push([_,_+b.length-1]),e.splice(_,2,b)}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 uy={resolve:dy,tokenize:fy},cy={partial:!0,tokenize:py};function dy(e){return hd(e),e}function fy(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):ce(o)?e.check(cy,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 py(e,t,n){const r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Se(e,s,"linePrefix")}function s(a){if(a===null||ce(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 md(e,t,n,r,i,s,a,o,l){const u=l||Number.POSITIVE_INFINITY;let d=0;return f;function f(b){return b===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(b),e.exit(s),h):b===null||b===32||b===41||ri(b)?n(b):(e.enter(r),e.enter(a),e.enter(o),e.enter("chunkString",{contentType:"string"}),w(b))}function h(b){return b===62?(e.enter(s),e.consume(b),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),p(b))}function p(b){return b===62?(e.exit("chunkString"),e.exit(o),h(b)):b===null||b===60||ce(b)?n(b):(e.consume(b),b===92?m:p)}function m(b){return b===60||b===62||b===92?(e.consume(b),p):p(b)}function w(b){return!d&&(b===null||b===41||ze(b))?(e.exit("chunkString"),e.exit(o),e.exit(a),e.exit(r),t(b)):d<u&&b===40?(e.consume(b),d++,w):b===41?(e.consume(b),d--,w):b===null||b===32||b===40||ri(b)?n(b):(e.consume(b),b===92?S:w)}function S(b){return b===40||b===41||b===92?(e.consume(b),w):w(b)}}function gd(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),d}function d(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):ce(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===null||p===91||p===93||ce(p)||o++>999?(e.exit("chunkString"),d(p)):(e.consume(p),l||(l=!ve(p)),p===92?h:f)}function h(p){return p===91||p===92||p===93?(e.consume(p),o++,f):f(p)}}function xd(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):ce(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),Se(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(h))}function d(h){return h===a||h===null||ce(h)?(e.exit("chunkString"),u(h)):(e.consume(h),h===92?f:d)}function f(h){return h===a||h===92?(e.consume(h),d):d(h)}}function or(e,t){let n;return r;function r(i){return ce(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):ve(i)?Se(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const hy={name:"definition",tokenize:gy},my={partial:!0,tokenize:xy};function gy(e,t,n){const r=this;let i;return s;function s(p){return e.enter("definition"),a(p)}function a(p){return gd.call(r,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function o(p){return i=Ct(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 ze(p)?or(e,u)(p):u(p)}function u(p){return md(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function d(p){return e.attempt(my,f,f)(p)}function f(p){return ve(p)?Se(e,h,"whitespace")(p):h(p)}function h(p){return p===null||ce(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function xy(e,t,n){return r;function r(o){return ze(o)?or(e,i)(o):n(o)}function i(o){return xd(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function s(o){return ve(o)?Se(e,a,"whitespace")(o):a(o)}function a(o){return o===null||ce(o)?t(o):n(o)}}const yy={name:"hardBreakEscape",tokenize:by};function by(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return ce(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const vy={name:"headingAtx",resolve:wy,tokenize:ky};function wy(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"},mt(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function ky(e,t,n){let r=0;return i;function i(d){return e.enter("atxHeading"),s(d)}function s(d){return e.enter("atxHeadingSequence"),a(d)}function a(d){return d===35&&r++<6?(e.consume(d),a):d===null||ze(d)?(e.exit("atxHeadingSequence"),o(d)):n(d)}function o(d){return d===35?(e.enter("atxHeadingSequence"),l(d)):d===null||ce(d)?(e.exit("atxHeading"),t(d)):ve(d)?Se(e,o,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function l(d){return d===35?(e.consume(d),l):(e.exit("atxHeadingSequence"),o(d))}function u(d){return d===null||d===35||ze(d)?(e.exit("atxHeadingText"),o(d)):(e.consume(d),u)}}const _y=["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"],Ro=["pre","script","style","textarea"],Sy={concrete:!0,name:"htmlFlow",resolveTo:Cy,tokenize:Ey},jy={partial:!0,tokenize:Ty},Ny={partial:!0,tokenize:Iy};function Cy(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 Ey(e,t,n){const r=this;let i,s,a,o,l;return u;function u(v){return d(v)}function d(v){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(v),f}function f(v){return v===33?(e.consume(v),h):v===47?(e.consume(v),s=!0,w):v===63?(e.consume(v),i=3,r.interrupt?t:y):ot(v)?(e.consume(v),a=String.fromCharCode(v),S):n(v)}function h(v){return v===45?(e.consume(v),i=2,p):v===91?(e.consume(v),i=5,o=0,m):ot(v)?(e.consume(v),i=4,r.interrupt?t:y):n(v)}function p(v){return v===45?(e.consume(v),r.interrupt?t:y):n(v)}function m(v){const se="CDATA[";return v===se.charCodeAt(o++)?(e.consume(v),o===se.length?r.interrupt?t:$:m):n(v)}function w(v){return ot(v)?(e.consume(v),a=String.fromCharCode(v),S):n(v)}function S(v){if(v===null||v===47||v===62||ze(v)){const se=v===47,be=a.toLowerCase();return!se&&!s&&Ro.includes(be)?(i=1,r.interrupt?t(v):$(v)):_y.includes(a.toLowerCase())?(i=6,se?(e.consume(v),b):r.interrupt?t(v):$(v)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(v):s?_(v):g(v))}return v===45||et(v)?(e.consume(v),a+=String.fromCharCode(v),S):n(v)}function b(v){return v===62?(e.consume(v),r.interrupt?t:$):n(v)}function _(v){return ve(v)?(e.consume(v),_):C(v)}function g(v){return v===47?(e.consume(v),C):v===58||v===95||ot(v)?(e.consume(v),D):ve(v)?(e.consume(v),g):C(v)}function D(v){return v===45||v===46||v===58||v===95||et(v)?(e.consume(v),D):E(v)}function E(v){return v===61?(e.consume(v),k):ve(v)?(e.consume(v),E):g(v)}function k(v){return v===null||v===60||v===61||v===62||v===96?n(v):v===34||v===39?(e.consume(v),l=v,N):ve(v)?(e.consume(v),k):F(v)}function N(v){return v===l?(e.consume(v),l=null,K):v===null||ce(v)?n(v):(e.consume(v),N)}function F(v){return v===null||v===34||v===39||v===47||v===60||v===61||v===62||v===96||ze(v)?E(v):(e.consume(v),F)}function K(v){return v===47||v===62||ve(v)?g(v):n(v)}function C(v){return v===62?(e.consume(v),q):n(v)}function q(v){return v===null||ce(v)?$(v):ve(v)?(e.consume(v),q):n(v)}function $(v){return v===45&&i===2?(e.consume(v),Y):v===60&&i===1?(e.consume(v),H):v===62&&i===4?(e.consume(v),ue):v===63&&i===3?(e.consume(v),y):v===93&&i===5?(e.consume(v),J):ce(v)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(jy,re,V)(v)):v===null||ce(v)?(e.exit("htmlFlowData"),V(v)):(e.consume(v),$)}function V(v){return e.check(Ny,Z,re)(v)}function Z(v){return e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),O}function O(v){return v===null||ce(v)?V(v):(e.enter("htmlFlowData"),$(v))}function Y(v){return v===45?(e.consume(v),y):$(v)}function H(v){return v===47?(e.consume(v),a="",z):$(v)}function z(v){if(v===62){const se=a.toLowerCase();return Ro.includes(se)?(e.consume(v),ue):$(v)}return ot(v)&&a.length<8?(e.consume(v),a+=String.fromCharCode(v),z):$(v)}function J(v){return v===93?(e.consume(v),y):$(v)}function y(v){return v===62?(e.consume(v),ue):v===45&&i===2?(e.consume(v),y):$(v)}function ue(v){return v===null||ce(v)?(e.exit("htmlFlowData"),re(v)):(e.consume(v),ue)}function re(v){return e.exit("htmlFlow"),t(v)}}function Iy(e,t,n){const r=this;return i;function i(a){return ce(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 Ty(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(_r,t,n)}}const Ay={name:"htmlText",tokenize:zy};function zy(e,t,n){const r=this;let i,s,a;return o;function o(y){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(y),l}function l(y){return y===33?(e.consume(y),u):y===47?(e.consume(y),E):y===63?(e.consume(y),g):ot(y)?(e.consume(y),F):n(y)}function u(y){return y===45?(e.consume(y),d):y===91?(e.consume(y),s=0,m):ot(y)?(e.consume(y),_):n(y)}function d(y){return y===45?(e.consume(y),p):n(y)}function f(y){return y===null?n(y):y===45?(e.consume(y),h):ce(y)?(a=f,H(y)):(e.consume(y),f)}function h(y){return y===45?(e.consume(y),p):f(y)}function p(y){return y===62?Y(y):y===45?h(y):f(y)}function m(y){const ue="CDATA[";return y===ue.charCodeAt(s++)?(e.consume(y),s===ue.length?w:m):n(y)}function w(y){return y===null?n(y):y===93?(e.consume(y),S):ce(y)?(a=w,H(y)):(e.consume(y),w)}function S(y){return y===93?(e.consume(y),b):w(y)}function b(y){return y===62?Y(y):y===93?(e.consume(y),b):w(y)}function _(y){return y===null||y===62?Y(y):ce(y)?(a=_,H(y)):(e.consume(y),_)}function g(y){return y===null?n(y):y===63?(e.consume(y),D):ce(y)?(a=g,H(y)):(e.consume(y),g)}function D(y){return y===62?Y(y):g(y)}function E(y){return ot(y)?(e.consume(y),k):n(y)}function k(y){return y===45||et(y)?(e.consume(y),k):N(y)}function N(y){return ce(y)?(a=N,H(y)):ve(y)?(e.consume(y),N):Y(y)}function F(y){return y===45||et(y)?(e.consume(y),F):y===47||y===62||ze(y)?K(y):n(y)}function K(y){return y===47?(e.consume(y),Y):y===58||y===95||ot(y)?(e.consume(y),C):ce(y)?(a=K,H(y)):ve(y)?(e.consume(y),K):Y(y)}function C(y){return y===45||y===46||y===58||y===95||et(y)?(e.consume(y),C):q(y)}function q(y){return y===61?(e.consume(y),$):ce(y)?(a=q,H(y)):ve(y)?(e.consume(y),q):K(y)}function $(y){return y===null||y===60||y===61||y===62||y===96?n(y):y===34||y===39?(e.consume(y),i=y,V):ce(y)?(a=$,H(y)):ve(y)?(e.consume(y),$):(e.consume(y),Z)}function V(y){return y===i?(e.consume(y),i=void 0,O):y===null?n(y):ce(y)?(a=V,H(y)):(e.consume(y),V)}function Z(y){return y===null||y===34||y===39||y===60||y===61||y===96?n(y):y===47||y===62||ze(y)?K(y):(e.consume(y),Z)}function O(y){return y===47||y===62||ze(y)?K(y):n(y)}function Y(y){return y===62?(e.consume(y),e.exit("htmlTextData"),e.exit("htmlText"),t):n(y)}function H(y){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),z}function z(y){return ve(y)?Se(e,J,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(y):J(y)}function J(y){return e.enter("htmlTextData"),a(y)}}const Ea={name:"labelEnd",resolveAll:Ry,resolveTo:My,tokenize:Fy},Oy={tokenize:$y},Py={tokenize:Ly},Dy={tokenize:Zy};function Ry(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&&mt(e,0,e.length,n),e}function My(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}},d={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[a-2][1].start}};return o=[["enter",l,t],["enter",u,t]],o=bt(o,e.slice(s+1,s+r+3)),o=bt(o,[["enter",d,t]]),o=bt(o,Ei(t.parser.constructs.insideSpan.null,e.slice(s+r+4,a-3),t)),o=bt(o,[["exit",d,t],e[a-2],e[a-1],["exit",u,t]]),o=bt(o,e.slice(a+1)),o=bt(o,[["exit",l,t]]),mt(e,s,e.length,o),e}function Fy(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?f(h):(a=r.parser.defined.includes(Ct(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(Oy,d,a?d:f)(h):h===91?e.attempt(Py,d,a?u:f)(h):a?d(h):f(h)}function u(h){return e.attempt(Dy,d,f)(h)}function d(h){return t(h)}function f(h){return s._balanced=!0,n(h)}}function $y(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),i}function i(f){return ze(f)?or(e,s)(f):s(f)}function s(f){return f===41?d(f):md(e,a,o,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function a(f){return ze(f)?or(e,l)(f):d(f)}function o(f){return n(f)}function l(f){return f===34||f===39||f===40?xd(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):d(f)}function u(f){return ze(f)?or(e,d)(f):d(f)}function d(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function Ly(e,t,n){const r=this;return i;function i(o){return gd.call(r,e,s,a,"reference","referenceMarker","referenceString")(o)}function s(o){return r.parser.defined.includes(Ct(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(o):n(o)}function a(o){return n(o)}}function Zy(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 Vy={name:"labelStartImage",resolveAll:Ea.resolveAll,tokenize:By};function By(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 Uy={name:"labelStartLink",resolveAll:Ea.resolveAll,tokenize:Jy};function Jy(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 Qi={name:"lineEnding",tokenize:qy};function qy(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Se(e,t,"linePrefix")}}const Ur={name:"thematicBreak",tokenize:Hy};function Hy(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||ce(u))?(e.exit("thematicBreak"),t(u)):n(u)}function l(u){return u===i?(e.consume(u),r++,l):(e.exit("thematicBreakSequence"),ve(u)?Se(e,o,"whitespace")(u):o(u))}}const ut={continuation:{tokenize:Yy},exit:Qy,name:"list",tokenize:Ky},Wy={partial:!0,tokenize:eb},Gy={partial:!0,tokenize:Xy};function Ky(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:Fs(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(Ur,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 Fs(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(_r,r.interrupt?n:d,e.attempt(Wy,h,f))}function d(p){return r.containerState.initialBlankLine=!0,s++,h(p)}function f(p){return ve(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 Yy(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(_r,i,s);function i(o){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Se(e,t,"listItemIndent",r.containerState.size+1)(o)}function s(o){return r.containerState.furtherBlankLines||!ve(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(Gy,t,a)(o))}function a(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,Se(e,e.attempt(ut,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}function Xy(e,t,n){const r=this;return Se(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 Qy(e){e.exit(this.containerState.type)}function eb(e,t,n){const r=this;return Se(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!ve(s)&&a&&a[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const Mo={name:"setextUnderline",resolveTo:tb,tokenize:nb};function tb(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 nb(e,t,n){const r=this;let i;return s;function s(u){let d=r.events.length,f;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){f=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),i=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"),ve(u)?Se(e,l,"lineSuffix")(u):l(u))}function l(u){return u===null||ce(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const rb={tokenize:ib};function ib(e){const t=this,n=e.attempt(_r,r,e.attempt(this.parser.constructs.flowInitial,i,Se(e,e.attempt(this.parser.constructs.flow,i,e.attempt(uy,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 sb={resolveAll:bd()},ab=yd("string"),ob=yd("text");function yd(e){return{resolveAll:bd(e==="text"?lb: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(d){return u(d)?s(d):o(d)}function o(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),l}function l(d){return u(d)?(n.exit("data"),s(d)):(n.consume(d),l)}function u(d){if(d===null)return!0;const f=i[d];let h=-1;if(f)for(;++h<f.length;){const p=f[h];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function bd(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 lb(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 ub={42:ut,43:ut,45:ut,48:ut,49:ut,50:ut,51:ut,52:ut,53:ut,54:ut,55:ut,56:ut,57:ut,62:dd},cb={91:hy},db={[-2]:Xi,[-1]:Xi,32:Xi},fb={35:vy,42:Ur,45:[Mo,Ur],60:Sy,61:Mo,95:Ur,96:Do,126:Do},pb={38:pd,92:fd},hb={[-5]:Qi,[-4]:Qi,[-3]:Qi,33:Vy,38:pd,42:$s,60:[Ux,Ay],91:Uy,92:[yy,fd],93:Ea,95:$s,96:ry},mb={null:[$s,sb]},gb={null:[42,95]},xb={null:[]},yb=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:gb,contentInitial:cb,disable:xb,document:ub,flow:fb,flowInitial:db,insideSpan:mb,string:pb,text:hb},Symbol.toStringTag,{value:"Module"}));function bb(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let a=[],o=[];const l={attempt:N(E),check:N(k),consume:_,enter:g,exit:D,interrupt:N(k,{interrupt:!0})},u={code:null,containerState:{},defineSkip:w,events:[],now:m,parser:e,previous:null,sliceSerialize:h,sliceStream:p,write:f};let d=t.tokenize.call(u,l);return t.resolveAll&&s.push(t),u;function f(q){return a=bt(a,q),S(),a[a.length-1]!==null?[]:(F(t,0),u.events=Ei(s,u.events,u),u.events)}function h(q,$){return wb(p(q),$)}function p(q){return vb(a,q)}function m(){const{_bufferIndex:q,_index:$,line:V,column:Z,offset:O}=r;return{_bufferIndex:q,_index:$,line:V,column:Z,offset:O}}function w(q){i[q.line]=q.column,C()}function S(){let q;for(;r._index<a.length;){const $=a[r._index];if(typeof $=="string")for(q=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===q&&r._bufferIndex<$.length;)b($.charCodeAt(r._bufferIndex));else b($)}}function b(q){d=d(q)}function _(q){ce(q)?(r.line++,r.column=1,r.offset+=q===-3?2:1,C()):q!==-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=q}function g(q,$){const V=$||{};return V.type=q,V.start=m(),u.events.push(["enter",V,u]),o.push(V),V}function D(q){const $=o.pop();return $.end=m(),u.events.push(["exit",$,u]),$}function E(q,$){F(q,$.from)}function k(q,$){$.restore()}function N(q,$){return V;function V(Z,O,Y){let H,z,J,y;return Array.isArray(Z)?re(Z):"tokenize"in Z?re([Z]):ue(Z);function ue(fe){return M;function M(B){const ee=B!==null&&fe[B],pe=B!==null&&fe.null,ge=[...Array.isArray(ee)?ee:ee?[ee]:[],...Array.isArray(pe)?pe:pe?[pe]:[]];return re(ge)(B)}}function re(fe){return H=fe,z=0,fe.length===0?Y:v(fe[z])}function v(fe){return M;function M(B){return y=K(),J=fe,fe.partial||(u.currentConstruct=fe),fe.name&&u.parser.constructs.disable.null.includes(fe.name)?be():fe.tokenize.call($?Object.assign(Object.create(u),$):u,l,se,be)(B)}}function se(fe){return q(J,y),O}function be(fe){return y.restore(),++z<H.length?v(H[z]):Y}}}function F(q,$){q.resolveAll&&!s.includes(q)&&s.push(q),q.resolve&&mt(u.events,$,u.events.length-$,q.resolve(u.events.slice($),u)),q.resolveTo&&(u.events=q.resolveTo(u.events,u))}function K(){const q=m(),$=u.previous,V=u.currentConstruct,Z=u.events.length,O=Array.from(o);return{from:Z,restore:Y};function Y(){r=q,u.previous=$,u.currentConstruct=V,u.events.length=Z,o=O,C()}}function C(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function vb(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 wb(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 kb(e){const r={constructs:ud([yb,...(e||{}).extensions||[]]),content:i(Mx),defined:[],document:i($x),flow:i(rb),lazy:{},string:i(ab),text:i(ob)};return r;function i(s){return a;function a(o){return bb(r,s,o)}}}function _b(e){for(;!hd(e););return e}const Fo=/[\0\t\n\r]/g;function Sb(){let e=1,t="",n=!0,r;return i;function i(s,a,o){const l=[];let u,d,f,h,p;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(a||void 0).decode(s)),f=0,t="",n&&(s.charCodeAt(0)===65279&&f++,n=void 0);f<s.length;){if(Fo.lastIndex=f,u=Fo.exec(s),h=u&&u.index!==void 0?u.index:s.length,p=s.charCodeAt(h),!u){t=s.slice(f);break}if(p===10&&f===h&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),f<h&&(l.push(s.slice(f,h)),e+=h-f),p){case 0:{l.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,l.push(-2);e++<d;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}f=h+1}return o&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const jb=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Nb(e){return e.replace(jb,Cb)}function Cb(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return cd(n.slice(s?2:1),s?16:10)}return Ca(n)||e}const vd={}.hasOwnProperty;function Eb(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),Ib(n)(_b(kb(n).document().write(Sb()(e,t,!0))))}function Ib(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(I),autolinkProtocol:K,autolinkEmail:K,atxHeading:s(Rt),blockQuote:s(pe),characterEscape:K,characterReference:K,codeFenced:s(ge),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:s(ge,a),codeText:s(Xe,a),codeTextData:K,data:K,codeFlowValue:K,definition:s(nt),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:s(Ie),hardBreakEscape:s(nn),hardBreakTrailing:s(nn),htmlFlow:s(Mt,a),htmlFlowData:K,htmlText:s(Mt,a),htmlTextData:K,image:s(j),label:a,link:s(I),listItem:s(ne),listItemValue:h,listOrdered:s(P,f),listUnordered:s(P),paragraph:s(X),reference:v,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:s(Rt),strong:s(G),thematicBreak:s(me)},exit:{atxHeading:l(),atxHeadingSequence:E,autolink:l(),autolinkEmail:ee,autolinkProtocol:B,blockQuote:l(),characterEscapeValue:C,characterReferenceMarkerHexadecimal:be,characterReferenceMarkerNumeric:be,characterReferenceValue:fe,characterReference:M,codeFenced:l(S),codeFencedFence:w,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:C,codeIndented:l(b),codeText:l(O),codeTextData:C,data:C,definition:l(),definitionDestinationString:D,definitionLabelString:_,definitionTitleString:g,emphasis:l(),hardBreakEscape:l($),hardBreakTrailing:l($),htmlFlow:l(V),htmlFlowData:C,htmlText:l(Z),htmlTextData:C,image:l(H),label:J,labelText:z,lineEnding:q,link:l(Y),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:se,resourceDestinationString:y,resourceTitleString:ue,resource:re,setextHeading:l(F),setextHeadingLineSequence:N,setextHeadingText:k,strong:l(),thematicBreak:l()}};wd(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(A){let U={type:"root",children:[]};const oe={stack:[U],tokenStack:[],config:t,enter:o,exit:u,buffer:a,resume:d,data:n},ye=[];let T=-1;for(;++T<A.length;)if(A[T][1].type==="listOrdered"||A[T][1].type==="listUnordered")if(A[T][0]==="enter")ye.push(T);else{const le=ye.pop();T=i(A,le,T)}for(T=-1;++T<A.length;){const le=t[A[T][0]];vd.call(le,A[T][1].type)&&le[A[T][1].type].call(Object.assign({sliceSerialize:A[T][2].sliceSerialize},oe),A[T][1])}if(oe.tokenStack.length>0){const le=oe.tokenStack[oe.tokenStack.length-1];(le[1]||$o).call(oe,void 0,le[0])}for(U.position={start:Bt(A.length>0?A[0][1].start:{line:1,column:1,offset:0}),end:Bt(A.length>0?A[A.length-2][1].end:{line:1,column:1,offset:0})},T=-1;++T<t.transforms.length;)U=t.transforms[T](U)||U;return U}function i(A,U,oe){let ye=U-1,T=-1,le=!1,we,Oe,He,Ue;for(;++ye<=oe;){const Qe=A[ye];switch(Qe[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Qe[0]==="enter"?T++:T--,Ue=void 0;break}case"lineEndingBlank":{Qe[0]==="enter"&&(we&&!Ue&&!T&&!He&&(He=ye),Ue=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Ue=void 0}if(!T&&Qe[0]==="enter"&&Qe[1].type==="listItemPrefix"||T===-1&&Qe[0]==="exit"&&(Qe[1].type==="listUnordered"||Qe[1].type==="listOrdered")){if(we){let Vt=ye;for(Oe=void 0;Vt--;){const Ft=A[Vt];if(Ft[1].type==="lineEnding"||Ft[1].type==="lineEndingBlank"){if(Ft[0]==="exit")continue;Oe&&(A[Oe][1].type="lineEndingBlank",le=!0),Ft[1].type="lineEnding",Oe=Vt}else if(!(Ft[1].type==="linePrefix"||Ft[1].type==="blockQuotePrefix"||Ft[1].type==="blockQuotePrefixWhitespace"||Ft[1].type==="blockQuoteMarker"||Ft[1].type==="listItemIndent"))break}He&&(!Oe||He<Oe)&&(we._spread=!0),we.end=Object.assign({},Oe?A[Oe][1].start:Qe[1].end),A.splice(Oe||ye,0,["exit",we,Qe[2]]),ye++,oe++}if(Qe[1].type==="listItemPrefix"){const Vt={type:"listItem",_spread:!1,start:Object.assign({},Qe[1].start),end:void 0};we=Vt,A.splice(ye,0,["enter",Vt,Qe[2]]),ye++,oe++,He=void 0,Ue=!0}}}return A[U][1]._spread=le,oe}function s(A,U){return oe;function oe(ye){o.call(this,A(ye),ye),U&&U.call(this,ye)}}function a(){this.stack.push({type:"fragment",children:[]})}function o(A,U,oe){this.stack[this.stack.length-1].children.push(A),this.stack.push(A),this.tokenStack.push([U,oe||void 0]),A.position={start:Bt(U.start),end:void 0}}function l(A){return U;function U(oe){A&&A.call(this,oe),u.call(this,oe)}}function u(A,U){const oe=this.stack.pop(),ye=this.tokenStack.pop();if(ye)ye[0].type!==A.type&&(U?U.call(this,A,ye[0]):(ye[1]||$o).call(this,A,ye[0]));else throw new Error("Cannot close `"+A.type+"` ("+ar({start:A.start,end:A.end})+"): it’s not open");oe.position.end=Bt(A.end)}function d(){return Na(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function h(A){if(this.data.expectingFirstListItemValue){const U=this.stack[this.stack.length-2];U.start=Number.parseInt(this.sliceSerialize(A),10),this.data.expectingFirstListItemValue=void 0}}function p(){const A=this.resume(),U=this.stack[this.stack.length-1];U.lang=A}function m(){const A=this.resume(),U=this.stack[this.stack.length-1];U.meta=A}function w(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const A=this.resume(),U=this.stack[this.stack.length-1];U.value=A.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function b(){const A=this.resume(),U=this.stack[this.stack.length-1];U.value=A.replace(/(\r?\n|\r)$/g,"")}function _(A){const U=this.resume(),oe=this.stack[this.stack.length-1];oe.label=U,oe.identifier=Ct(this.sliceSerialize(A)).toLowerCase()}function g(){const A=this.resume(),U=this.stack[this.stack.length-1];U.title=A}function D(){const A=this.resume(),U=this.stack[this.stack.length-1];U.url=A}function E(A){const U=this.stack[this.stack.length-1];if(!U.depth){const oe=this.sliceSerialize(A).length;U.depth=oe}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function N(A){const U=this.stack[this.stack.length-1];U.depth=this.sliceSerialize(A).codePointAt(0)===61?1:2}function F(){this.data.setextHeadingSlurpLineEnding=void 0}function K(A){const oe=this.stack[this.stack.length-1].children;let ye=oe[oe.length-1];(!ye||ye.type!=="text")&&(ye=ae(),ye.position={start:Bt(A.start),end:void 0},oe.push(ye)),this.stack.push(ye)}function C(A){const U=this.stack.pop();U.value+=this.sliceSerialize(A),U.position.end=Bt(A.end)}function q(A){const U=this.stack[this.stack.length-1];if(this.data.atHardBreak){const oe=U.children[U.children.length-1];oe.position.end=Bt(A.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(U.type)&&(K.call(this,A),C.call(this,A))}function $(){this.data.atHardBreak=!0}function V(){const A=this.resume(),U=this.stack[this.stack.length-1];U.value=A}function Z(){const A=this.resume(),U=this.stack[this.stack.length-1];U.value=A}function O(){const A=this.resume(),U=this.stack[this.stack.length-1];U.value=A}function Y(){const A=this.stack[this.stack.length-1];if(this.data.inReference){const U=this.data.referenceType||"shortcut";A.type+="Reference",A.referenceType=U,delete A.url,delete A.title}else delete A.identifier,delete A.label;this.data.referenceType=void 0}function H(){const A=this.stack[this.stack.length-1];if(this.data.inReference){const U=this.data.referenceType||"shortcut";A.type+="Reference",A.referenceType=U,delete A.url,delete A.title}else delete A.identifier,delete A.label;this.data.referenceType=void 0}function z(A){const U=this.sliceSerialize(A),oe=this.stack[this.stack.length-2];oe.label=Nb(U),oe.identifier=Ct(U).toLowerCase()}function J(){const A=this.stack[this.stack.length-1],U=this.resume(),oe=this.stack[this.stack.length-1];if(this.data.inReference=!0,oe.type==="link"){const ye=A.children;oe.children=ye}else oe.alt=U}function y(){const A=this.resume(),U=this.stack[this.stack.length-1];U.url=A}function ue(){const A=this.resume(),U=this.stack[this.stack.length-1];U.title=A}function re(){this.data.inReference=void 0}function v(){this.data.referenceType="collapsed"}function se(A){const U=this.resume(),oe=this.stack[this.stack.length-1];oe.label=U,oe.identifier=Ct(this.sliceSerialize(A)).toLowerCase(),this.data.referenceType="full"}function be(A){this.data.characterReferenceType=A.type}function fe(A){const U=this.sliceSerialize(A),oe=this.data.characterReferenceType;let ye;oe?(ye=cd(U,oe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ye=Ca(U);const T=this.stack[this.stack.length-1];T.value+=ye}function M(A){const U=this.stack.pop();U.position.end=Bt(A.end)}function B(A){C.call(this,A);const U=this.stack[this.stack.length-1];U.url=this.sliceSerialize(A)}function ee(A){C.call(this,A);const U=this.stack[this.stack.length-1];U.url="mailto:"+this.sliceSerialize(A)}function pe(){return{type:"blockquote",children:[]}}function ge(){return{type:"code",lang:null,meta:null,value:""}}function Xe(){return{type:"inlineCode",value:""}}function nt(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ie(){return{type:"emphasis",children:[]}}function Rt(){return{type:"heading",depth:0,children:[]}}function nn(){return{type:"break"}}function Mt(){return{type:"html",value:""}}function j(){return{type:"image",title:null,url:"",alt:null}}function I(){return{type:"link",title:null,url:"",children:[]}}function P(A){return{type:"list",ordered:A.type==="listOrdered",start:null,spread:A._spread,children:[]}}function ne(A){return{type:"listItem",spread:A._spread,checked:null,children:[]}}function X(){return{type:"paragraph",children:[]}}function G(){return{type:"strong",children:[]}}function ae(){return{type:"text",value:""}}function me(){return{type:"thematicBreak"}}}function Bt(e){return{line:e.line,column:e.column,offset:e.offset}}function wd(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?wd(e,r):Tb(e,r)}}function Tb(e,t){let n;for(n in t)if(vd.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 $o(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+ar({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+ar({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+ar({start:t.start,end:t.end})+") is still open")}function Ab(e){const t=this;t.parser=n;function n(r){return Eb(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function zb(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 Ob(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
6
+ `}]}function Pb(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 Db(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Rb(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Mb(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=Fn(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 Fb(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 $b(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function kd(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 Lb(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return kd(e,t);const i={src:Fn(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 Zb(e,t){const n={src:Fn(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 Vb(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 Bb(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return kd(e,t);const i={href:Fn(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 Ub(e,t){const n={href:Fn(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 Jb(e,t,n){const r=e.all(t),i=n?qb(n):_d(t),s={},a=[];if(typeof t.checked=="boolean"){const d=r[0];let f;d&&d.type==="element"&&d.tagName==="p"?f=d:(f={type:"element",tagName:"p",properties:{},children:[]},r.unshift(f)),f.children.length>0&&f.children.unshift({type:"text",value:" "}),f.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let o=-1;for(;++o<r.length;){const d=r[o];(i||o!==0||d.type!=="element"||d.tagName!=="p")&&a.push({type:"text",value:`
8
+ `}),d.type==="element"&&d.tagName==="p"&&!i?a.push(...d.children):a.push(d)}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 qb(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=_d(n[r])}return t}function _d(e){const t=e.spread;return t??e.children.length>1}function Hb(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 Wb(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Gb(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function Kb(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Yb(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=ka(t.children[1]),l=nd(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 Xb(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 f=t.children[l],h={},p=a?a[l]:void 0;p&&(h.align=p);let m={type:"element",tagName:s,properties:h,children:[]};f&&(m.children=e.all(f),e.patch(f,m),m=e.applyData(f,m)),u.push(m)}const d={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,d),e.applyData(t,d)}function Qb(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const Lo=9,Zo=32;function ev(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const s=[];for(;r;)s.push(Vo(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return s.push(Vo(t.slice(i),i>0,!1)),s.join("")}function Vo(e,t,n){let r=0,i=e.length;if(t){let s=e.codePointAt(r);for(;s===Lo||s===Zo;)r++,s=e.codePointAt(r)}if(n){let s=e.codePointAt(i-1);for(;s===Lo||s===Zo;)i--,s=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function tv(e,t){const n={type:"text",value:ev(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function nv(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const rv={blockquote:zb,break:Ob,code:Pb,delete:Db,emphasis:Rb,footnoteReference:Mb,heading:Fb,html:$b,imageReference:Lb,image:Zb,inlineCode:Vb,linkReference:Bb,link:Ub,listItem:Jb,list:Hb,paragraph:Wb,root:Gb,strong:Kb,table:Yb,tableCell:Qb,tableRow:Xb,text:tv,thematicBreak:nv,toml:zr,yaml:zr,definition:zr,footnoteDefinition:zr};function zr(){}const Sd=-1,Ii=0,lr=1,ii=2,Ia=3,Ta=4,Aa=5,za=6,jd=7,Nd=8,Bo=typeof self=="object"?self:globalThis,iv=(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 Ii:case Sd:return n(a,i);case lr:{const o=n([],i);for(const l of a)o.push(r(l));return o}case ii:{const o=n({},i);for(const[l,u]of a)o[r(l)]=r(u);return o}case Ia:return n(new Date(a),i);case Ta:{const{source:o,flags:l}=a;return n(new RegExp(o,l),i)}case Aa:{const o=n(new Map,i);for(const[l,u]of a)o.set(r(l),r(u));return o}case za:{const o=n(new Set,i);for(const l of a)o.add(r(l));return o}case jd:{const{name:o,message:l}=a;return n(new Bo[o](l),i)}case Nd: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 Bo[s](a),i)};return r},Uo=e=>iv(new Map,e)(0),wn="",{toString:sv}={},{keys:av}=Object,Hn=e=>{const t=typeof e;if(t!=="object"||!e)return[Ii,t];const n=sv.call(e).slice(8,-1);switch(n){case"Array":return[lr,wn];case"Object":return[ii,wn];case"Date":return[Ia,wn];case"RegExp":return[Ta,wn];case"Map":return[Aa,wn];case"Set":return[za,wn];case"DataView":return[lr,n]}return n.includes("Array")?[lr,n]:n.includes("Error")?[jd,n]:[ii,n]},Or=([e,t])=>e===Ii&&(t==="function"||t==="symbol"),ov=(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]=Hn(a);switch(o){case Ii:{let d=a;switch(l){case"bigint":o=Nd,d=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+l);d=null;break;case"undefined":return i([Sd],a)}return i([o,d],a)}case lr:{if(l){let h=a;return l==="DataView"?h=new Uint8Array(a.buffer):l==="ArrayBuffer"&&(h=new Uint8Array(a)),i([l,[...h]],a)}const d=[],f=i([o,d],a);for(const h of a)d.push(s(h));return f}case ii:{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 d=[],f=i([o,d],a);for(const h of av(a))(e||!Or(Hn(a[h])))&&d.push([s(h),s(a[h])]);return f}case Ia:return i([o,a.toISOString()],a);case Ta:{const{source:d,flags:f}=a;return i([o,{source:d,flags:f}],a)}case Aa:{const d=[],f=i([o,d],a);for(const[h,p]of a)(e||!(Or(Hn(h))||Or(Hn(p))))&&d.push([s(h),s(p)]);return f}case za:{const d=[],f=i([o,d],a);for(const h of a)(e||!Or(Hn(h)))&&d.push(s(h));return f}}const{message:u}=a;return i([o,{name:l,message:u}],a)};return s},Jo=(e,{json:t,lossy:n}={})=>{const r=[];return ov(!(t||n),!!t,new Map,r)(e),r},si=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Uo(Jo(e,t)):structuredClone(e):(e,t)=>Uo(Jo(e,t));function lv(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 uv(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function cv(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||lv,r=e.options.footnoteBackLabel||uv,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 d=e.all(u),f=String(u.identifier).toUpperCase(),h=Fn(f.toLowerCase());let p=0;const m=[],w=e.footnoteCounts.get(f);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=d[d.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 d.push(...m);const b={type:"element",tagName:"li",properties:{id:t+"fn-"+h},children:e.wrap(d,!0)};e.patch(u,b),o.push(b)}if(o.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...si(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 Ti=function(e){if(e==null)return hv;if(typeof e=="function")return Ai(e);if(typeof e=="object")return Array.isArray(e)?dv(e):fv(e);if(typeof e=="string")return pv(e);throw new Error("Expected function, string, or object as test")};function dv(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Ti(e[n]);return Ai(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function fv(e){const t=e;return Ai(n);function n(r){const i=r;let s;for(s in e)if(i[s]!==t[s])return!1;return!0}}function pv(e){return Ai(t);function t(n){return n&&n.type===e}}function Ai(e){return t;function t(n,r,i){return!!(mv(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function hv(){return!0}function mv(e){return e!==null&&typeof e=="object"&&"type"in e}const Cd=[],gv=!0,Ls=!1,xv="skip";function Ed(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const s=Ti(i),a=r?-1:1;o(e,void 0,[])();function o(l,u,d){const f=l&&typeof l=="object"?l:{};if(typeof f.type=="string"){const p=typeof f.tagName=="string"?f.tagName:typeof f.name=="string"?f.name:void 0;Object.defineProperty(h,"name",{value:"node ("+(l.type+(p?"<"+p+">":""))+")"})}return h;function h(){let p=Cd,m,w,S;if((!t||s(l,u,d[d.length-1]||void 0))&&(p=yv(n(l,d)),p[0]===Ls))return p;if("children"in l&&l.children){const b=l;if(b.children&&p[0]!==xv)for(w=(r?b.children.length:-1)+a,S=d.concat(b);w>-1&&w<b.children.length;){const _=b.children[w];if(m=o(_,w,S)(),m[0]===Ls)return m;w=typeof m[1]=="number"?m[1]:w+a}}return p}}}function yv(e){return Array.isArray(e)?e:typeof e=="number"?[gv,e]:e==null?Cd:[e]}function Oa(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),Ed(e,s,o,i);function o(l,u){const d=u[u.length-1],f=d?d.children.indexOf(l):void 0;return a(l,f,d)}}const Zs={}.hasOwnProperty,bv={};function vv(e,t){const n=t||bv,r=new Map,i=new Map,s=new Map,a={...rv,...n.handlers},o={all:u,applyData:kv,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:a,one:l,options:n,patch:wv,wrap:Sv};return Oa(e,function(d){if(d.type==="definition"||d.type==="footnoteDefinition"){const f=d.type==="definition"?r:i,h=String(d.identifier).toUpperCase();f.has(h)||f.set(h,d)}}),o;function l(d,f){const h=d.type,p=o.handlers[h];if(Zs.call(o.handlers,h)&&p)return p(o,d,f);if(o.options.passThrough&&o.options.passThrough.includes(h)){if("children"in d){const{children:w,...S}=d,b=si(S);return b.children=o.all(d),b}return si(d)}return(o.options.unknownHandler||_v)(o,d,f)}function u(d){const f=[];if("children"in d){const h=d.children;let p=-1;for(;++p<h.length;){const m=o.one(h[p],d);if(m){if(p&&h[p-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=qo(m.value)),!Array.isArray(m)&&m.type==="element")){const w=m.children[0];w&&w.type==="text"&&(w.value=qo(w.value))}Array.isArray(m)?f.push(...m):f.push(m)}}}return f}}function wv(e,t){e.position&&(t.position=ux(e))}function kv(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,si(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function _v(e,t){const n=t.data||{},r="value"in t&&!(Zs.call(n,"hProperties")||Zs.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 Sv(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 qo(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Ho(e,t){const n=vv(e,t),r=n.one(e,void 0),i=cv(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 jv(e,t){return e&&"run"in e?async function(n,r){const i=Ho(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Ho(n,{file:r,...e||t})}}function Wo(e){if(e)throw e}var es,Go;function Nv(){if(Go)return es;Go=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 d=e.call(u,"constructor"),f=u.constructor&&u.constructor.prototype&&e.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!d&&!f)return!1;var h;for(h in u);return typeof h>"u"||e.call(u,h)},a=function(u,d){n&&d.name==="__proto__"?n(u,d.name,{enumerable:!0,configurable:!0,value:d.newValue,writable:!0}):u[d.name]=d.newValue},o=function(u,d){if(d==="__proto__")if(e.call(u,d)){if(r)return r(u,d).value}else return;return u[d]};return es=function l(){var u,d,f,h,p,m,w=arguments[0],S=1,b=arguments.length,_=!1;for(typeof w=="boolean"&&(_=w,w=arguments[1]||{},S=2),(w==null||typeof w!="object"&&typeof w!="function")&&(w={});S<b;++S)if(u=arguments[S],u!=null)for(d in u)f=o(w,d),h=o(u,d),w!==h&&(_&&h&&(s(h)||(p=i(h)))?(p?(p=!1,m=f&&i(f)?f:[]):m=f&&s(f)?f:{},a(w,{name:d,newValue:l(_,m,h)})):typeof h<"u"&&a(w,{name:d,newValue:h}));return w},es}var Cv=Nv();const ts=ra(Cv);function Vs(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 Ev(){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 d=e[++s];let f=-1;if(l){a(l);return}for(;++f<i.length;)(u[f]===null||u[f]===void 0)&&(u[f]=i[f]);i=u,d?Iv(d,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 Iv(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 d=u;if(o&&n)throw d;return i(d)}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 It={basename:Tv,dirname:Av,extname:zv,join:Ov,sep:"/"};function Tv(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Sr(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 Av(e){if(Sr(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 zv(e){Sr(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 Ov(...e){let t=-1,n;for(;++t<e.length;)Sr(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":Pv(n)}function Pv(e){Sr(e);const t=e.codePointAt(0)===47;let n=Dv(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function Dv(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 Sr(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Rv={cwd:Mv};function Mv(){return"/"}function Bs(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function Fv(e){if(typeof e=="string")e=new URL(e);else if(!Bs(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 $v(e)}function $v(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 ns=["history","path","basename","stem","extname","dirname"];class Id{constructor(t){let n;t?Bs(t)?n={path:t}:typeof t=="string"||Lv(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":Rv.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<ns.length;){const s=ns[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)ns.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?It.basename(this.path):void 0}set basename(t){is(t,"basename"),rs(t,"basename"),this.path=It.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?It.dirname(this.path):void 0}set dirname(t){Ko(this.basename,"dirname"),this.path=It.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?It.extname(this.path):void 0}set extname(t){if(rs(t,"extname"),Ko(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=It.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Bs(t)&&(t=Fv(t)),is(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?It.basename(this.path,this.extname):void 0}set stem(t){is(t,"stem"),rs(t,"stem"),this.path=It.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 tt(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(It.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+It.sep+"`")}function is(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Ko(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function Lv(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Zv=function(e){const r=this.constructor.prototype,i=r[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s},Vv={}.hasOwnProperty;class Pa extends Zv{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=Ev()}copy(){const t=new Pa;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(ts(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(os("data",this.frozen),this.namespace[t]=n,this):Vv.call(this.namespace,t)&&this.namespace[t]||void 0:t?(os("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=Pr(t),r=this.parser||this.Parser;return ss("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),ss("process",this.parser||this.Parser),as("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,a){const o=Pr(t),l=r.parse(o);r.run(l,o,function(d,f,h){if(d||!f||!h)return u(d);const p=f,m=r.stringify(p,h);Jv(m)?h.value=m:h.result=m,u(d,h)});function u(d,f){d||!f?a(d):s?s(f):n(void 0,f)}}}processSync(t){let n=!1,r;return this.freeze(),ss("processSync",this.parser||this.Parser),as("processSync",this.compiler||this.Compiler),this.process(t,i),Xo("processSync","process",n),r;function i(s,a){n=!0,Wo(s),r=a}}run(t,n,r){Yo(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=Pr(n);i.run(t,l,u);function u(d,f,h){const p=f||t;d?o(d):a?a(p):r(void 0,p,h)}}}runSync(t,n){let r=!1,i;return this.run(t,n,s),Xo("runSync","run",r),i;function s(a,o){Wo(a),i=o,r=!0}}stringify(t,n){this.freeze();const r=Pr(n),i=this.compiler||this.Compiler;return as("stringify",i),Yo(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(os("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[d,...f]=u;l(d,f)}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=ts(!0,i.settings,u.settings))}function o(u){let d=-1;if(u!=null)if(Array.isArray(u))for(;++d<u.length;){const f=u[d];s(f)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function l(u,d){let f=-1,h=-1;for(;++f<r.length;)if(r[f][0]===u){h=f;break}if(h===-1)r.push([u,...d]);else if(d.length>0){let[p,...m]=d;const w=r[h][1];Vs(w)&&Vs(p)&&(p=ts(!0,w,p)),r[h]=[u,p,...m]}}}}const Bv=new Pa().freeze();function ss(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function as(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function os(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 Yo(e){if(!Vs(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Xo(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Pr(e){return Uv(e)?e:new Id(e)}function Uv(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function Jv(e){return typeof e=="string"||qv(e)}function qv(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Hv="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Qo=[],el={allowDangerousHtml:!0},Wv=/^(https?|ircs?|mailto|xmpp)$/i,Gv=[{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 Kv(e){const t=Yv(e),n=Xv(e);return Qv(t.runSync(t.parse(n),n),e)}function Yv(e){const t=e.rehypePlugins||Qo,n=e.remarkPlugins||Qo,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...el}:el;return Bv().use(Ab).use(n).use(jv,r).use(t)}function Xv(e){const t=e.children||"",n=new Id;return typeof t=="string"&&(n.value=t),n}function Qv(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,s=t.disallowedElements,a=t.skipHtml,o=t.unwrapDisallowed,l=t.urlTransform||ew;for(const d of Gv)Object.hasOwn(t,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+Hv+d.id,void 0);return Oa(e,u),hx(e,{Fragment:c.Fragment,components:i,ignoreInvalidStyle:!0,jsx:c.jsx,jsxs:c.jsxs,passKeys:!0,passNode:!0});function u(d,f,h){if(d.type==="raw"&&h&&typeof f=="number")return a?h.children.splice(f,1):h.children[f]={type:"text",value:d.value},f;if(d.type==="element"){let p;for(p in Yi)if(Object.hasOwn(Yi,p)&&Object.hasOwn(d.properties,p)){const m=d.properties[p],w=Yi[p];(w===null||w.includes(d.tagName))&&(d.properties[p]=l(String(m||""),p,d))}}if(d.type==="element"){let p=n?!n.includes(d.tagName):s?s.includes(d.tagName):!1;if(!p&&r&&typeof f=="number"&&(p=!r(d,f,h)),p&&h&&typeof f=="number")return o&&d.children?h.children.splice(f,1,...d.children):h.children.splice(f,1),f}}}function ew(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||Wv.test(e.slice(0,t))?e:""}function tl(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 tw(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function nw(e,t,n){const i=Ti((n||{}).ignore||[]),s=rw(t);let a=-1;for(;++a<s.length;)Ed(e,"text",o);function o(u,d){let f=-1,h;for(;++f<d.length;){const p=d[f],m=h?h.children:void 0;if(i(p,m?m.indexOf(p):void 0,h))return;h=p}if(h)return l(u,d)}function l(u,d){const f=d[d.length-1],h=s[a][0],p=s[a][1];let m=0;const S=f.children.indexOf(u);let b=!1,_=[];h.lastIndex=0;let g=h.exec(u.value);for(;g;){const D=g.index,E={index:g.index,input:g.input,stack:[...d,u]};let k=p(...g,E);if(typeof k=="string"&&(k=k.length>0?{type:"text",value:k}:void 0),k===!1?h.lastIndex=D+1:(m!==D&&_.push({type:"text",value:u.value.slice(m,D)}),Array.isArray(k)?_.push(...k):k&&_.push(k),m=D+g[0].length,b=!0),!h.global)break;g=h.exec(u.value)}return b?(m<u.value.length&&_.push({type:"text",value:u.value.slice(m)}),f.children.splice(S,1,..._)):_=[u],S+_.length}}function rw(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([iw(i[0]),sw(i[1])])}return t}function iw(e){return typeof e=="string"?new RegExp(tw(e),"g"):e}function sw(e){return typeof e=="function"?e:function(){return e}}const ls="phrasing",us=["autolink","link","image","label"];function aw(){return{transforms:[pw],enter:{literalAutolink:lw,literalAutolinkEmail:cs,literalAutolinkHttp:cs,literalAutolinkWww:cs},exit:{literalAutolink:fw,literalAutolinkEmail:dw,literalAutolinkHttp:uw,literalAutolinkWww:cw}}}function ow(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:ls,notInConstruct:us},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:ls,notInConstruct:us},{character:":",before:"[ps]",after:"\\/",inConstruct:ls,notInConstruct:us}]}}function lw(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function cs(e){this.config.enter.autolinkProtocol.call(this,e)}function uw(e){this.config.exit.autolinkProtocol.call(this,e)}function cw(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 dw(e){this.config.exit.autolinkEmail.call(this,e)}function fw(e){this.exit(e)}function pw(e){nw(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,hw],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),mw]],{ignore:["link","linkReference"]})}function hw(e,t,n,r,i){let s="";if(!Td(i)||(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!gw(n)))return!1;const a=xw(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 mw(e,t,n,r){return!Td(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function gw(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 xw(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=tl(e,"(");let s=tl(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 Td(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||mn(n)||Ci(n))&&(!t||n!==47)}Ad.peek=Nw;function yw(){this.buffer()}function bw(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function vw(){this.buffer()}function ww(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function kw(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ct(this.sliceSerialize(e)).toLowerCase(),n.label=t}function _w(e){this.exit(e)}function Sw(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ct(this.sliceSerialize(e)).toLowerCase(),n.label=t}function jw(e){this.exit(e)}function Nw(){return"["}function Ad(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 Cw(){return{enter:{gfmFootnoteCallString:yw,gfmFootnoteCall:bw,gfmFootnoteDefinitionLabelString:vw,gfmFootnoteDefinition:ww},exit:{gfmFootnoteCallString:kw,gfmFootnoteCall:_w,gfmFootnoteDefinitionLabelString:Sw,gfmFootnoteDefinition:jw}}}function Ew(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Ad},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"),d=s.enter("label");return l+=o.move(s.safe(s.associationId(r),{before:l,after:"]"})),d(),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?zd:Iw))),u(),l}}function Iw(e,t,n){return t===0?e:zd(e,t,n)}function zd(e,t,n){return(n?"":" ")+e}const Tw=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Od.peek=Dw;function Aw(){return{canContainEols:["delete"],enter:{strikethrough:Ow},exit:{strikethrough:Pw}}}function zw(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Tw}],handlers:{delete:Od}}}function Ow(e){this.enter({type:"delete",children:[]},e)}function Pw(e){this.exit(e)}function Od(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 Dw(){return"~"}function Rw(e){return e.length}function Mw(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||Rw,s=[],a=[],o=[],l=[];let u=0,d=-1;for(;++d<e.length;){const w=[],S=[];let b=-1;for(e[d].length>u&&(u=e[d].length);++b<e[d].length;){const _=Fw(e[d][b]);if(n.alignDelimiters!==!1){const g=i(_);S[b]=g,(l[b]===void 0||g>l[b])&&(l[b]=g)}w.push(_)}a[d]=w,o[d]=S}let f=-1;if(typeof r=="object"&&"length"in r)for(;++f<u;)s[f]=nl(r[f]);else{const w=nl(r);for(;++f<u;)s[f]=w}f=-1;const h=[],p=[];for(;++f<u;){const w=s[f];let S="",b="";w===99?(S=":",b=":"):w===108?S=":":w===114&&(b=":");let _=n.alignDelimiters===!1?1:Math.max(1,l[f]-S.length-b.length);const g=S+"-".repeat(_)+b;n.alignDelimiters!==!1&&(_=S.length+_+b.length,_>l[f]&&(l[f]=_),p[f]=_),h[f]=g}a.splice(1,0,h),o.splice(1,0,p),d=-1;const m=[];for(;++d<a.length;){const w=a[d],S=o[d];f=-1;const b=[];for(;++f<u;){const _=w[f]||"";let g="",D="";if(n.alignDelimiters!==!1){const E=l[f]-(S[f]||0),k=s[f];k===114?g=" ".repeat(E):k===99?E%2?(g=" ".repeat(E/2+.5),D=" ".repeat(E/2-.5)):(g=" ".repeat(E/2),D=g):D=" ".repeat(E)}n.delimiterStart!==!1&&!f&&b.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&_==="")&&(n.delimiterStart!==!1||f)&&b.push(" "),n.alignDelimiters!==!1&&b.push(g),b.push(_),n.alignDelimiters!==!1&&b.push(D),n.padding!==!1&&b.push(" "),(n.delimiterEnd!==!1||f!==u-1)&&b.push("|")}m.push(n.delimiterEnd===!1?b.join("").replace(/ +$/,""):b.join(""))}return m.join(`
17
+ `)}function Fw(e){return e==null?"":String(e)}function nl(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 $w(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()),Lw);return i(),a}function Lw(e,t,n){return">"+(n?"":" ")+e}function Zw(e,t){return rl(e,t.inConstruct,!0)&&!rl(e,t.notInConstruct,!1)}function rl(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 il(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
18
+ `&&Zw(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
19
+ `}function Vw(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 Bw(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 Uw(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 Jw(e,t,n,r){const i=Uw(n),s=e.value||"",a=i==="`"?"GraveAccent":"Tilde";if(Bw(e,n)){const f=n.enter("codeIndented"),h=n.indentLines(s,qw);return f(),h}const o=n.createTracker(r),l=i.repeat(Math.max(Vw(s,i)+1,3)),u=n.enter("codeFenced");let d=o.move(l);if(e.lang){const f=n.enter(`codeFencedLang${a}`);d+=o.move(n.safe(e.lang,{before:d,after:" ",encode:["`"],...o.current()})),f()}if(e.lang&&e.meta){const f=n.enter(`codeFencedMeta${a}`);d+=o.move(" "),d+=o.move(n.safe(e.meta,{before:d,after:`
20
+ `,encode:["`"],...o.current()})),f()}return d+=o.move(`
21
+ `),s&&(d+=o.move(s+`
22
+ `)),d+=o.move(l),u(),d}function qw(e,t,n){return(n?"":" ")+e}function Da(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 Hw(e,t,n,r){const i=Da(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 Ww(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 pr(e){return"&#x"+e.toString(16).toUpperCase()+";"}function ai(e,t,n){const r=zn(e),i=zn(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}}Pd.peek=Gw;function Pd(e,t,n,r){const i=Ww(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),d=ai(r.before.charCodeAt(r.before.length-1),u,i);d.inside&&(l=pr(u)+l.slice(1));const f=l.charCodeAt(l.length-1),h=ai(r.after.charCodeAt(0),f,i);h.inside&&(l=l.slice(0,-1)+pr(f));const p=a.move(i);return s(),n.attentionEncodeSurroundingInfo={after:h.outside,before:d.outside},o+l+p}function Gw(e,t,n){return n.options.emphasis||"*"}function Kw(e,t){let n=!1;return Oa(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,Ls}),!!((!e.depth||e.depth<3)&&Na(e)&&(t.options.setext||n))}function Yw(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(Kw(e,n)){const d=n.enter("headingSetext"),f=n.enter("phrasing"),h=n.containerPhrasing(e,{...s.current(),before:`
24
+ `,after:`
25
+ `});return f(),d(),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=pr(u.charCodeAt(0))+u.slice(1)),u=u?a+" "+u:a,n.options.closeAtx&&(u+=" "+a),l(),o(),u}Dd.peek=Xw;function Dd(e){return e.value||""}function Xw(){return"<"}Rd.peek=Qw;function Rd(e,t,n,r){const i=Da(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 Qw(){return"!"}Md.peek=e0;function Md(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 d=n.stack;n.stack=[],a=n.enter("reference");const f=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return a(),n.stack=d,s(),i==="full"||!u||u!==f?l+=o.move(f+"]"):i==="shortcut"?l=l.slice(0,-1):l+=o.move("]"),l}function e0(){return"!"}Fd.peek=t0;function Fd(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 t0(){return"`"}function $d(e,t){const n=Na(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))}Ld.peek=n0;function Ld(e,t,n,r){const i=Da(n),s=i==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let o,l;if($d(e,n)){const d=n.stack;n.stack=[],o=n.enter("autolink");let f=a.move("<");return f+=a.move(n.containerPhrasing(e,{before:f,after:">",...a.current()})),f+=a.move(">"),o(),n.stack=d,f}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 n0(e,t,n){return $d(e,n)?"<":"["}Zd.peek=r0;function Zd(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 d=n.stack;n.stack=[],a=n.enter("reference");const f=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return a(),n.stack=d,s(),i==="full"||!u||u!==f?l+=o.move(f+"]"):i==="shortcut"?l=l.slice(0,-1):l+=o.move("]"),l}function r0(){return"["}function Ra(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 i0(e){const t=Ra(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 s0(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 Vd(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 a0(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let a=e.ordered?s0(n):Ra(n);const o=e.ordered?a==="."?")":".":i0(n);let l=t&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!e.ordered){const d=e.children?e.children[0]:void 0;if((a==="*"||a==="-")&&d&&(!d.children||!d.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(l=!0),Vd(n)===a&&d){let f=-1;for(;++f<e.children.length;){const h=e.children[f];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 o0(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 l0(e,t,n,r){const i=o0(n);let s=n.bulletCurrent||Ra(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()),d);return l(),u;function d(f,h,p){return h?(p?"":" ".repeat(a))+f:(p?s:s+" ".repeat(a-s.length))+f}}function u0(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),a=n.containerPhrasing(e,r);return s(),i(),a}const c0=Ti(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function d0(e,t,n,r){return(e.children.some(function(a){return c0(a)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function f0(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Bd.peek=p0;function Bd(e,t,n,r){const i=f0(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),d=ai(r.before.charCodeAt(r.before.length-1),u,i);d.inside&&(l=pr(u)+l.slice(1));const f=l.charCodeAt(l.length-1),h=ai(r.after.charCodeAt(0),f,i);h.inside&&(l=l.slice(0,-1)+pr(f));const p=a.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:h.outside,before:d.outside},o+l+p}function p0(e,t,n){return n.options.strong||"*"}function h0(e,t,n,r){return n.safe(e.value,r)}function m0(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 g0(e,t,n){const r=(Vd(n)+(n.options.ruleSpaces?" ":"")).repeat(m0(n));return n.options.ruleSpaces?r.slice(0,-1):r}const Ud={blockquote:$w,break:il,code:Jw,definition:Hw,emphasis:Pd,hardBreak:il,heading:Yw,html:Dd,image:Rd,imageReference:Md,inlineCode:Fd,link:Ld,linkReference:Zd,list:a0,listItem:l0,paragraph:u0,root:d0,strong:Bd,text:h0,thematicBreak:g0};function x0(){return{enter:{table:y0,tableData:sl,tableHeader:sl,tableRow:v0},exit:{codeText:w0,table:b0,tableData:ds,tableHeader:ds,tableRow:ds}}}function y0(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 b0(e){this.exit(e),this.data.inTable=void 0}function v0(e){this.enter({type:"tableRow",children:[]},e)}function ds(e){this.exit(e)}function sl(e){this.enter({type:"tableCell",children:[]},e)}function w0(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,k0));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function k0(e,t){return t==="|"?t:e}function _0(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(d(p,w,S),p.align)}function o(p,m,w,S){const b=f(p,w,S),_=u([b]);return _.slice(0,_.indexOf(`
30
+ `))}function l(p,m,w,S){const b=w.enter("tableCell"),_=w.enter("phrasing"),g=w.containerPhrasing(p,{...S,before:s,after:s});return _(),b(),g}function u(p,m){return Mw(p,{align:m,alignDelimiters:r,padding:n,stringLength:i})}function d(p,m,w){const S=p.children;let b=-1;const _=[],g=m.enter("table");for(;++b<S.length;)_[b]=f(S[b],m,w);return g(),_}function f(p,m,w){const S=p.children;let b=-1;const _=[],g=m.enter("tableRow");for(;++b<S.length;)_[b]=l(S[b],p,m,w);return g(),_}function h(p,m,w){let S=Ud.inlineCode(p,m,w);return w.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function S0(){return{exit:{taskListCheckValueChecked:al,taskListCheckValueUnchecked:al,paragraph:N0}}}function j0(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:C0}}}function al(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function N0(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 C0(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=Ud.listItem(e,t,n,{...r,...o.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),l;function u(d){return d+a}}function E0(){return[aw(),Cw(),Aw(),x0(),S0()]}function I0(e){return{extensions:[ow(),Ew(e),zw(),_0(e),j0()]}}const T0={tokenize:R0,partial:!0},Jd={tokenize:M0,partial:!0},qd={tokenize:F0,partial:!0},Hd={tokenize:$0,partial:!0},A0={tokenize:L0,partial:!0},Wd={name:"wwwAutolink",tokenize:P0,previous:Kd},Gd={name:"protocolAutolink",tokenize:D0,previous:Yd},Zt={name:"emailAutolink",tokenize:O0,previous:Xd},Dt={};function z0(){return{text:Dt}}let rn=48;for(;rn<123;)Dt[rn]=Zt,rn++,rn===58?rn=65:rn===91&&(rn=97);Dt[43]=Zt;Dt[45]=Zt;Dt[46]=Zt;Dt[95]=Zt;Dt[72]=[Zt,Gd];Dt[104]=[Zt,Gd];Dt[87]=[Zt,Wd];Dt[119]=[Zt,Wd];function O0(e,t,n){const r=this;let i,s;return a;function a(f){return!Us(f)||!Xd.call(r,r.previous)||Ma(r.events)?n(f):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),o(f))}function o(f){return Us(f)?(e.consume(f),o):f===64?(e.consume(f),l):n(f)}function l(f){return f===46?e.check(A0,d,u)(f):f===45||f===95||et(f)?(s=!0,e.consume(f),l):d(f)}function u(f){return e.consume(f),i=!0,l}function d(f){return s&&i&&ot(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(f)):n(f)}}function P0(e,t,n){const r=this;return i;function i(a){return a!==87&&a!==119||!Kd.call(r,r.previous)||Ma(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(T0,e.attempt(Jd,e.attempt(qd,s),n),n)(a))}function s(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function D0(e,t,n){const r=this;let i="",s=!1;return a;function a(f){return(f===72||f===104)&&Yd.call(r,r.previous)&&!Ma(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(f),e.consume(f),o):n(f)}function o(f){if(ot(f)&&i.length<5)return i+=String.fromCodePoint(f),e.consume(f),o;if(f===58){const h=i.toLowerCase();if(h==="http"||h==="https")return e.consume(f),l}return n(f)}function l(f){return f===47?(e.consume(f),s?u:(s=!0,l)):n(f)}function u(f){return f===null||ri(f)||ze(f)||mn(f)||Ci(f)?n(f):e.attempt(Jd,e.attempt(qd,d),n)(f)}function d(f){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(f)}}function R0(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 M0(e,t,n){let r,i,s;return a;function a(u){return u===46||u===95?e.check(Hd,l,o)(u):u===null||ze(u)||mn(u)||u!==45&&Ci(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 F0(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(Hd,t,s)(a):a===null||ze(a)||mn(a)?t(a):(e.consume(a),i)}function s(a){return a===41&&r++,e.consume(a),i}}function $0(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||ze(o)||mn(o)?t(o):n(o)}function i(o){return o===null||o===40||o===91||ze(o)||mn(o)?t(o):r(o)}function s(o){return ot(o)?a(o):n(o)}function a(o){return o===59?(e.consume(o),r):ot(o)?(e.consume(o),a):n(o)}}function L0(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return et(s)?n(s):t(s)}}function Kd(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||ze(e)}function Yd(e){return!ot(e)}function Xd(e){return!(e===47||Us(e))}function Us(e){return e===43||e===45||e===46||e===95||et(e)}function Ma(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 Z0={tokenize:G0,partial:!0};function V0(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:q0,continuation:{tokenize:H0},exit:W0}},text:{91:{name:"gfmFootnoteCall",tokenize:J0},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:B0,resolveTo:U0}}}}function B0(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=Ct(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 U0(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 J0(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,a;return o;function o(f){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),l}function l(f){return f!==94?n(f):(e.enter("gfmFootnoteCallMarker"),e.consume(f),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(f){if(s>999||f===93&&!a||f===null||f===91||ze(f))return n(f);if(f===93){e.exit("chunkString");const h=e.exit("gfmFootnoteCallString");return i.includes(Ct(r.sliceSerialize(h)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(f)}return ze(f)||(a=!0),s++,e.consume(f),f===92?d:u}function d(f){return f===91||f===92||f===93?(e.consume(f),s++,u):u(f)}}function q0(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",d):n(m)}function d(m){if(a>999||m===93&&!o||m===null||m===91||ze(m))return n(m);if(m===93){e.exit("chunkString");const w=e.exit("gfmFootnoteDefinitionLabelString");return s=Ct(r.sliceSerialize(w)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),h}return ze(m)||(o=!0),a++,e.consume(m),m===92?f:d}function f(m){return m===91||m===92||m===93?(e.consume(m),a++,d):d(m)}function h(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),i.includes(s)||i.push(s),Se(e,p,"gfmFootnoteDefinitionWhitespace")):n(m)}function p(m){return t(m)}}function H0(e,t,n){return e.check(_r,t,e.attempt(Z0,t,n))}function W0(e){e.exit("gfmFootnoteDefinition")}function G0(e,t,n){const r=this;return Se(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 K0(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 d={type:"strikethrough",start:Object.assign({},a[u][1].start),end:Object.assign({},a[l][1].end)},f={type:"strikethroughText",start:Object.assign({},a[u][1].end),end:Object.assign({},a[l][1].start)},h=[["enter",d,o],["enter",a[u][1],o],["exit",a[u][1],o],["enter",f,o]],p=o.parser.constructs.insideSpan.null;p&&mt(h,h.length,0,Ei(p,a.slice(u+1,l),o)),mt(h,h.length,0,[["exit",f,o],["enter",a[l][1],o],["exit",a[l][1],o],["exit",d,o]]),mt(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,d=this.events;let f=0;return h;function h(m){return u===126&&d[d.length-1][1].type!=="characterEscape"?l(m):(a.enter("strikethroughSequenceTemporary"),p(m))}function p(m){const w=zn(u);if(m===126)return f>1?l(m):(a.consume(m),f++,p);if(f<2&&!n)return l(m);const S=a.exit("strikethroughSequenceTemporary"),b=zn(m);return S._open=!b||b===2&&!!w,S._close=!w||w===2&&!!b,o(m)}}}class Y0{constructor(){this.map=[]}add(t,n,r){X0(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 X0(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 Q0(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 ek(){return{flow:{null:{name:"table",tokenize:tk,resolveAll:nk}}}}function tk(e,t,n){const r=this;let i=0,s=0,a;return o;function o(C){let q=r.events.length-1;for(;q>-1;){const Z=r.events[q][1].type;if(Z==="lineEnding"||Z==="linePrefix")q--;else break}const $=q>-1?r.events[q][1].type:null,V=$==="tableHead"||$==="tableRow"?k:l;return V===k&&r.parser.lazy[r.now().line]?n(C):V(C)}function l(C){return e.enter("tableHead"),e.enter("tableRow"),u(C)}function u(C){return C===124||(a=!0,s+=1),d(C)}function d(C){return C===null?n(C):ce(C)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),p):n(C):ve(C)?Se(e,d,"whitespace")(C):(s+=1,a&&(a=!1,i+=1),C===124?(e.enter("tableCellDivider"),e.consume(C),e.exit("tableCellDivider"),a=!0,d):(e.enter("data"),f(C)))}function f(C){return C===null||C===124||ze(C)?(e.exit("data"),d(C)):(e.consume(C),C===92?h:f)}function h(C){return C===92||C===124?(e.consume(C),f):f(C)}function p(C){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(C):(e.enter("tableDelimiterRow"),a=!1,ve(C)?Se(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):m(C))}function m(C){return C===45||C===58?S(C):C===124?(a=!0,e.enter("tableCellDivider"),e.consume(C),e.exit("tableCellDivider"),w):E(C)}function w(C){return ve(C)?Se(e,S,"whitespace")(C):S(C)}function S(C){return C===58?(s+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(C),e.exit("tableDelimiterMarker"),b):C===45?(s+=1,b(C)):C===null||ce(C)?D(C):E(C)}function b(C){return C===45?(e.enter("tableDelimiterFiller"),_(C)):E(C)}function _(C){return C===45?(e.consume(C),_):C===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(C),e.exit("tableDelimiterMarker"),g):(e.exit("tableDelimiterFiller"),g(C))}function g(C){return ve(C)?Se(e,D,"whitespace")(C):D(C)}function D(C){return C===124?m(C):C===null||ce(C)?!a||i!==s?E(C):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(C)):E(C)}function E(C){return n(C)}function k(C){return e.enter("tableRow"),N(C)}function N(C){return C===124?(e.enter("tableCellDivider"),e.consume(C),e.exit("tableCellDivider"),N):C===null||ce(C)?(e.exit("tableRow"),t(C)):ve(C)?Se(e,N,"whitespace")(C):(e.enter("data"),F(C))}function F(C){return C===null||C===124||ze(C)?(e.exit("data"),N(C)):(e.consume(C),C===92?K:F)}function K(C){return C===92||C===124?(e.consume(C),F):F(C)}}function nk(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],a=[0,0,0,0],o=!1,l=0,u,d,f;const h=new Y0;for(;++n<e.length;){const p=e[n],m=p[1];p[0]==="enter"?m.type==="tableHead"?(o=!1,l!==0&&(ol(h,t,l,u,d),d=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,f=void 0,s=[0,0,0,0],a=[0,n+1,0,0],o&&(o=!1,d={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},h.add(n,0,[["enter",d,t]])),i=m.type==="tableDelimiterRow"?2:d?3:1):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,a[2]===0&&(s[1]!==0&&(a[0]=a[1],f=Dr(h,t,s,i,void 0,f),s=[0,0,0,0]),a[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(a[0]=a[1],f=Dr(h,t,s,i,void 0,f)),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],f=Dr(h,t,s,i,n,f)):a[1]!==0&&(f=Dr(h,t,a,i,n,f)),i=0):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(a[3]=n)}for(l!==0&&ol(h,t,l,u,d),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=Q0(t.events,n))}return e}function Dr(e,t,n,r,i,s){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",o="tableContent";n[0]!==0&&(s.end=Object.assign({},Sn(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=Sn(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=Sn(t.events,n[2]),d=Sn(t.events,n[3]),f={type:o,start:Object.assign({},u),end:Object.assign({},d)};if(e.add(n[2],0,[["enter",f,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",f,t]])}return i!==void 0&&(s.end=Object.assign({},Sn(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function ol(e,t,n,r,i){const s=[],a=Sn(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 Sn(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const rk={name:"tasklistCheck",tokenize:sk};function ik(){return{text:{91:rk}}}function sk(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 ze(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 ce(l)?t(l):ve(l)?e.check({tokenize:ak},t,n)(l):n(l)}}function ak(e,t,n){return Se(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function ok(e){return ud([z0(),V0(),K0(e),ek(),ik()])}const lk={};function uk(e){const t=this,n=e||lk,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(ok(n)),s.push(E0()),a.push(I0(n))}var Qd="vercel.ai.error",ck=Symbol.for(Qd),ll,ul,Pt=class ef extends(ul=Error,ll=ck,ul){constructor({name:t,message:n,cause:r}){super(n),this[ll]=!0,this.name=t,this.cause=r}static isInstance(t){return ef.hasMarker(t,Qd)}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 tf(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var nf="AI_InvalidArgumentError",rf=`vercel.ai.error.${nf}`,dk=Symbol.for(rf),cl,dl,fk=class extends(dl=Pt,cl=dk,dl){constructor({message:e,cause:t,argument:n}){super({name:nf,message:e,cause:t}),this[cl]=!0,this.argument=n}static isInstance(e){return Pt.hasMarker(e,rf)}},sf="AI_JSONParseError",af=`vercel.ai.error.${sf}`,pk=Symbol.for(af),fl,pl,hl=class extends(pl=Pt,fl=pk,pl){constructor({text:e,cause:t}){super({name:sf,message:`JSON parsing failed: Text: ${e}.
31
+ Error message: ${tf(t)}`,cause:t}),this[fl]=!0,this.text=e}static isInstance(e){return Pt.hasMarker(e,af)}},of="AI_TypeValidationError",lf=`vercel.ai.error.${of}`,hk=Symbol.for(lf),ml,gl,On=class Js extends(gl=Pt,ml=hk,gl){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:of,message:`${i}: Value: ${JSON.stringify(t)}.
32
+ Error message: ${tf(n)}`,cause:n}),this[ml]=!0,this.value=t,this.context=r}static isInstance(t){return Pt.hasMarker(t,lf)}static wrap({value:t,cause:n,context:r}){var i,s,a;return Js.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 Js({value:t,cause:n,context:r})}};function R(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,d=Object.keys(u);for(let f=0;f<d.length;f++){const h=d[f];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 d of u._zod.deferred)d();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 Tn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class uf extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const cf={};function Yt(e){return cf}function df(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 qs(e,t){return typeof t=="bigint"?t.toString():t}function zi(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Fa(e){return e==null}function $a(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function mk(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 xl=Symbol("evaluating");function _e(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==xl)return r===void 0&&(r=xl,r=n()),r},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function yn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function en(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function yl(e){return JSON.stringify(e)}function gk(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const ff="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function hr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const xk=zi(()=>{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 Pn(e){if(hr(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(hr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function pf(e){return Pn(e)?{...e}:Array.isArray(e)?[...e]:e}const yk=new Set(["string","number","symbol"]);function Dn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function tn(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 ie(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 bk(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const vk={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 wk(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=en(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 yn(this,"shape",a),a},checks:[]});return tn(e,s)}function kk(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=en(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 yn(this,"shape",a),a},checks:[]});return tn(e,s)}function _k(e,t){if(!Pn(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=en(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return yn(this,"shape",s),s}});return tn(e,i)}function Sk(e,t){if(!Pn(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=en(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return yn(this,"shape",r),r}});return tn(e,n)}function jk(e,t){const n=en(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return yn(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return tn(e,n)}function Nk(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=en(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 yn(this,"shape",l),l},checks:[]});return tn(t,a)}function Ck(e,t,n){const r=en(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 yn(this,"shape",s),s}});return tn(t,r)}function Cn(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 En(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Rr(e){return typeof e=="string"?e:e==null?void 0:e.message}function Xt(e,t,n){var i,s,a,o,l,u;const r={...e,path:e.path??[]};if(!e.message){const d=Rr((a=(s=(i=e.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:a.call(s,e))??Rr((o=t==null?void 0:t.error)==null?void 0:o.call(t,e))??Rr((l=n.customError)==null?void 0:l.call(n,e))??Rr((u=n.localeError)==null?void 0:u.call(n,e))??"Invalid input";r.message=d}return delete r.inst,delete r.continue,t!=null&&t.reportInput||delete r.input,r}function La(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function mr(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const hf=(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,qs,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},mf=R("$ZodError",hf),gf=R("$ZodError",hf,{Parent:Error});function Ek(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 Ik(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 Za=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 Tn;if(a.issues.length){const o=new((i==null?void 0:i.Err)??e)(a.issues.map(l=>Xt(l,s,Yt())));throw ff(o,i==null?void 0:i.callee),o}return a.value},Va=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=>Xt(l,s,Yt())));throw ff(o,i==null?void 0:i.callee),o}return a.value},Oi=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 Tn;return s.issues.length?{success:!1,error:new(e??mf)(s.issues.map(a=>Xt(a,i,Yt())))}:{success:!0,data:s.value}},Tk=Oi(gf),Pi=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=>Xt(a,i,Yt())))}:{success:!0,data:s.value}},Ak=Pi(gf),zk=e=>(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Za(e)(t,n,i)},Ok=e=>(t,n,r)=>Za(e)(t,n,r),Pk=e=>async(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Va(e)(t,n,i)},Dk=e=>async(t,n,r)=>Va(e)(t,n,r),Rk=e=>(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Oi(e)(t,n,i)},Mk=e=>(t,n,r)=>Oi(e)(t,n,r),Fk=e=>async(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Pi(e)(t,n,i)},$k=e=>async(t,n,r)=>Pi(e)(t,n,r),Lk=/^[cC][^\s-]{8,}$/,Zk=/^[0-9a-z]+$/,Vk=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Bk=/^[0-9a-vA-V]{20}$/,Uk=/^[A-Za-z0-9]{27}$/,Jk=/^[a-zA-Z0-9_-]{21}$/,qk=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Hk=/^([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})$/,bl=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)$/,Wk=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Gk="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Kk(){return new RegExp(Gk,"u")}const Yk=/^(?:(?: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])$/,Xk=/^(([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}|:))$/,Qk=/^((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])$/,e_=/^(([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])$/,t_=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,xf=/^[A-Za-z0-9_-]*$/,n_=/^\+[1-9]\d{6,14}$/,yf="(?:(?:\\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])))",r_=new RegExp(`^${yf}$`);function bf(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 i_(e){return new RegExp(`^${bf(e)}$`)}function s_(e){const t=bf({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(`^${yf}T(?:${r})$`)}const a_=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}$`)},o_=/^-?\d+$/,vf=/^-?\d+(?:\.\d+)?$/,l_=/^(?:true|false)$/i,u_=/^null$/i,c_=/^[^A-Z]*$/,d_=/^[^a-z]*$/,pt=R("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),wf={number:"number",bigint:"bigint",object:"date"},kf=R("$ZodCheckLessThan",(e,t)=>{pt.init(e,t);const n=wf[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})}}),_f=R("$ZodCheckGreaterThan",(e,t)=>{pt.init(e,t);const n=wf[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})}}),f_=R("$ZodCheckMultipleOf",(e,t)=>{pt.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):mk(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})}}),p_=R("$ZodCheckNumberFormat",(e,t)=>{var a;pt.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]=vk[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=o_)}),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})}}),h_=R("$ZodCheckMaxLength",(e,t)=>{var n;pt.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!Fa(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=La(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),m_=R("$ZodCheckMinLength",(e,t)=>{var n;pt.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!Fa(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=La(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),g_=R("$ZodCheckLengthEquals",(e,t)=>{var n;pt.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!Fa(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=La(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})}}),Di=R("$ZodCheckStringFormat",(e,t)=>{var n,r;pt.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=()=>{})}),x_=R("$ZodCheckRegex",(e,t)=>{Di.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})}}),y_=R("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=c_),Di.init(e,t)}),b_=R("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=d_),Di.init(e,t)}),v_=R("$ZodCheckIncludes",(e,t)=>{pt.init(e,t);const n=Dn(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})}}),w_=R("$ZodCheckStartsWith",(e,t)=>{pt.init(e,t);const n=new RegExp(`^${Dn(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})}}),k_=R("$ZodCheckEndsWith",(e,t)=>{pt.init(e,t);const n=new RegExp(`.*${Dn(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})}}),__=R("$ZodCheckOverwrite",(e,t)=>{pt.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class S_{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 j_={major:4,minor:3,patch:6},Fe=R("$ZodType",(e,t)=>{var i;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=j_;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 d=Cn(o),f;for(const h of l){if(h._zod.def.when){if(!h._zod.def.when(o))continue}else if(d)continue;const p=o.issues.length,m=h._zod.check(o);if(m instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Tn;if(f||m instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await m,o.issues.length!==p&&(d||(d=Cn(o,p)))});else{if(o.issues.length===p)continue;d||(d=Cn(o,p))}}return f?f.then(()=>o):o},a=(o,l,u)=>{if(Cn(o))return o.aborted=!0,o;const d=s(l,r,u);if(d instanceof Promise){if(u.async===!1)throw new Tn;return d.then(f=>e._zod.parse(f,u))}return e._zod.parse(d,u)};e._zod.run=(o,l)=>{if(l.skipChecks)return e._zod.parse(o,l);if(l.direction==="backward"){const d=e._zod.parse({value:o.value,issues:[]},{...l,skipChecks:!0});return d instanceof Promise?d.then(f=>a(f,o,l)):a(d,o,l)}const u=e._zod.parse(o,l);if(u instanceof Promise){if(l.async===!1)throw new Tn;return u.then(d=>s(d,r,l))}return s(u,r,l)}}_e(e,"~standard",()=>({validate:s=>{var a;try{const o=Tk(e,s);return o.success?{value:o.data}:{issues:(a=o.error)==null?void 0:a.issues}}catch{return Ak(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}))}),Ba=R("$ZodString",(e,t)=>{var n;Fe.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??a_(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}}),Le=R("$ZodStringFormat",(e,t)=>{Di.init(e,t),Ba.init(e,t)}),N_=R("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Hk),Le.init(e,t)}),C_=R("$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=bl(r))}else t.pattern??(t.pattern=bl());Le.init(e,t)}),E_=R("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Wk),Le.init(e,t)}),I_=R("$ZodURL",(e,t)=>{Le.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})}}}),T_=R("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Kk()),Le.init(e,t)}),A_=R("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Jk),Le.init(e,t)}),z_=R("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Lk),Le.init(e,t)}),O_=R("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Zk),Le.init(e,t)}),P_=R("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Vk),Le.init(e,t)}),D_=R("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Bk),Le.init(e,t)}),R_=R("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Uk),Le.init(e,t)}),M_=R("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=s_(t)),Le.init(e,t)}),F_=R("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=r_),Le.init(e,t)}),$_=R("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=i_(t)),Le.init(e,t)}),L_=R("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=qk),Le.init(e,t)}),Z_=R("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Yk),Le.init(e,t),e._zod.bag.format="ipv4"}),V_=R("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Xk),Le.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})}}}),B_=R("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Qk),Le.init(e,t)}),U_=R("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=e_),Le.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 Sf(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const J_=R("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=t_),Le.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Sf(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function q_(e){if(!xf.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Sf(n)}const H_=R("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=xf),Le.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{q_(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),W_=R("$ZodE164",(e,t)=>{t.pattern??(t.pattern=n_),Le.init(e,t)});function G_(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 K_=R("$ZodJWT",(e,t)=>{Le.init(e,t),e._zod.check=n=>{G_(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),jf=R("$ZodNumber",(e,t)=>{Fe.init(e,t),e._zod.pattern=e._zod.bag.pattern??vf,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}}),Y_=R("$ZodNumberFormat",(e,t)=>{p_.init(e,t),jf.init(e,t)}),X_=R("$ZodBoolean",(e,t)=>{Fe.init(e,t),e._zod.pattern=l_,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}}),Q_=R("$ZodNull",(e,t)=>{Fe.init(e,t),e._zod.pattern=u_,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}}),e1=R("$ZodUnknown",(e,t)=>{Fe.init(e,t),e._zod.parse=n=>n}),t1=R("$ZodNever",(e,t)=>{Fe.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function vl(e,t,n){e.issues.length&&t.issues.push(...En(n,e.issues)),t.value[n]=e.value}const n1=R("$ZodArray",(e,t)=>{Fe.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=>vl(u,n,a))):vl(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(...En(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Nf(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=bk(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Cf(e,t,n,r,i,s){const a=[],o=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optout==="optional";for(const f in t){if(o.has(f))continue;if(u==="never"){a.push(f);continue}const h=l.run({value:t[f],issues:[]},r);h instanceof Promise?e.push(h.then(p=>oi(p,n,f,t,d))):oi(h,n,f,t,d)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const r1=R("$ZodObject",(e,t)=>{Fe.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=zi(()=>Nf(t));_e(e._zod,"propValues",()=>{const o=t.shape,l={};for(const u in o){const d=o[u]._zod;if(d.values){l[u]??(l[u]=new Set);for(const f of d.values)l[u].add(f)}}return l});const i=hr,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 d=[],f=a.shape;for(const h of a.keys){const p=f[h],m=p._zod.optout==="optional",w=p._zod.run({value:u[h],issues:[]},l);w instanceof Promise?d.push(w.then(S=>oi(S,o,h,u,m))):oi(w,o,h,u,m)}return s?Cf(d,u,o,l,r.value,e):d.length?Promise.all(d).then(()=>o):o}}),i1=R("$ZodObjectJIT",(e,t)=>{r1.init(e,t);const n=e._zod.parse,r=zi(()=>Nf(t)),i=h=>{var g;const p=new S_(["shape","payload","ctx"]),m=r.value,w=D=>{const E=yl(D);return`shape[${E}]._zod.run({ value: input[${E}], issues: [] }, ctx)`};p.write("const input = payload.value;");const S=Object.create(null);let b=0;for(const D of m.keys)S[D]=`key_${b++}`;p.write("const newResult = {};");for(const D of m.keys){const E=S[D],k=yl(D),N=h[D],F=((g=N==null?void 0:N._zod)==null?void 0:g.optout)==="optional";p.write(`const ${E} = ${w(D)};`),F?p.write(`
35
+ if (${E}.issues.length) {
36
+ if (${k} in input) {
37
+ payload.issues = payload.issues.concat(${E}.issues.map(iss => ({
38
+ ...iss,
39
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
40
+ })));
41
+ }
42
+ }
43
+
44
+ if (${E}.value === undefined) {
45
+ if (${k} in input) {
46
+ newResult[${k}] = undefined;
47
+ }
48
+ } else {
49
+ newResult[${k}] = ${E}.value;
50
+ }
51
+
52
+ `):p.write(`
53
+ if (${E}.issues.length) {
54
+ payload.issues = payload.issues.concat(${E}.issues.map(iss => ({
55
+ ...iss,
56
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
57
+ })));
58
+ }
59
+
60
+ if (${E}.value === undefined) {
61
+ if (${k} in input) {
62
+ newResult[${k}] = undefined;
63
+ }
64
+ } else {
65
+ newResult[${k}] = ${E}.value;
66
+ }
67
+
68
+ `)}p.write("payload.value = newResult;"),p.write("return payload;");const _=p.compile();return(D,E)=>_(h,D,E)};let s;const a=hr,o=!cf.jitless,u=o&&xk.value,d=t.catchall;let f;e._zod.parse=(h,p)=>{f??(f=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),d?Cf([],m,h,p,f,e):h):n(h,p):(h.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),h)}});function wl(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=>!Cn(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=>Xt(a,r,Yt())))}),t)}const Ef=R("$ZodUnion",(e,t)=>{Fe.init(e,t),_e(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),_e(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),_e(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),_e(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=>$a(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=>wl(l,i,e,s)):wl(o,i,e,s)}}),s1=R("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ef.init(e,t);const n=e._zod.parse;_e(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=zi(()=>{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(!hr(a))return i.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),i;const o=r.value.get(a==null?void 0:a[t.discriminator]);return o?o._zod.run(i,s):t.unionFallback?n(i,s):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),i)}}),a1=R("$ZodIntersection",(e,t)=>{Fe.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])=>kl(n,l,u)):kl(n,s,a)}});function Hs(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(Pn(e)&&Pn(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=Hs(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=Hs(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 kl(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}),Cn(e))return e;const a=Hs(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 o1=R("$ZodRecord",(e,t)=>{Fe.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!Pn(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 d=t.valueType._zod.run({value:i[u],issues:[]},r);d instanceof Promise?s.push(d.then(f=>{f.issues.length&&n.issues.push(...En(u,f.issues)),n.value[u]=f.value})):(d.issues.length&&n.issues.push(...En(u,d.issues)),n.value[u]=d.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"&&vf.test(o)&&l.issues.length){const f=t.keyType._zod.run({value:Number(o),issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(l=f)}if(l.issues.length){t.mode==="loose"?n.value[o]=i[o]:n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(f=>Xt(f,r,Yt())),input:o,path:[o],inst:e});continue}const d=t.valueType._zod.run({value:i[o],issues:[]},r);d instanceof Promise?s.push(d.then(f=>{f.issues.length&&n.issues.push(...En(o,f.issues)),n.value[l.value]=f.value})):(d.issues.length&&n.issues.push(...En(o,d.issues)),n.value[l.value]=d.value)}}return s.length?Promise.all(s).then(()=>n):n}}),l1=R("$ZodEnum",(e,t)=>{Fe.init(e,t);const n=df(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(i=>yk.has(typeof i)).map(i=>typeof i=="string"?Dn(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}}),u1=R("$ZodLiteral",(e,t)=>{if(Fe.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"?Dn(r):r?Dn(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}}),c1=R("$ZodTransform",(e,t)=>{Fe.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new uf(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 Tn;return n.value=i,n}});function _l(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const If=R("$ZodOptional",(e,t)=>{Fe.init(e,t),e._zod.optin="optional",e._zod.optout="optional",_e(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),_e(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${$a(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=>_l(s,n.value)):_l(i,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),d1=R("$ZodExactOptional",(e,t)=>{If.init(e,t),_e(e._zod,"values",()=>t.innerType._zod.values),_e(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),f1=R("$ZodNullable",(e,t)=>{Fe.init(e,t),_e(e._zod,"optin",()=>t.innerType._zod.optin),_e(e._zod,"optout",()=>t.innerType._zod.optout),_e(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${$a(n.source)}|null)$`):void 0}),_e(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)}),p1=R("$ZodDefault",(e,t)=>{Fe.init(e,t),e._zod.optin="optional",_e(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=>Sl(s,t)):Sl(i,t)}});function Sl(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const h1=R("$ZodPrefault",(e,t)=>{Fe.init(e,t),e._zod.optin="optional",_e(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))}),m1=R("$ZodNonOptional",(e,t)=>{Fe.init(e,t),_e(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=>jl(s,e)):jl(i,e)}});function jl(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 g1=R("$ZodCatch",(e,t)=>{Fe.init(e,t),_e(e._zod,"optin",()=>t.innerType._zod.optin),_e(e._zod,"optout",()=>t.innerType._zod.optout),_e(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=>Xt(a,r,Yt()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(s=>Xt(s,r,Yt()))},input:n.value}),n.issues=[]),n)}}),x1=R("$ZodPipe",(e,t)=>{Fe.init(e,t),_e(e._zod,"values",()=>t.in._zod.values),_e(e._zod,"optin",()=>t.in._zod.optin),_e(e._zod,"optout",()=>t.out._zod.optout),_e(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=>Mr(a,t.in,r)):Mr(s,t.in,r)}const i=t.in._zod.run(n,r);return i instanceof Promise?i.then(s=>Mr(s,t.out,r)):Mr(i,t.out,r)}});function Mr(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const y1=R("$ZodReadonly",(e,t)=>{Fe.init(e,t),_e(e._zod,"propValues",()=>t.innerType._zod.propValues),_e(e._zod,"values",()=>t.innerType._zod.values),_e(e._zod,"optin",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),_e(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(Nl):Nl(i)}});function Nl(e){return e.value=Object.freeze(e.value),e}const b1=R("$ZodLazy",(e,t)=>{Fe.init(e,t),_e(e._zod,"innerType",()=>t.getter()),_e(e._zod,"pattern",()=>{var n,r;return(r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.pattern}),_e(e._zod,"propValues",()=>{var n,r;return(r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.propValues}),_e(e._zod,"optin",()=>{var n,r;return((r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.optin)??void 0}),_e(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)}),v1=R("$ZodCustom",(e,t)=>{pt.init(e,t),Fe.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=>Cl(s,n,r,e));Cl(i,n,r,e)}});function Cl(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(mr(i))}}var El;class w1{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 k1(){return new w1}(El=globalThis).__zod_globalRegistry??(El.__zod_globalRegistry=k1());const Xn=globalThis.__zod_globalRegistry;function _1(e,t){return new e({type:"string",...ie(t)})}function S1(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ie(t)})}function Il(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ie(t)})}function j1(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ie(t)})}function N1(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ie(t)})}function C1(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ie(t)})}function E1(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ie(t)})}function I1(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ie(t)})}function T1(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ie(t)})}function A1(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ie(t)})}function z1(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ie(t)})}function O1(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ie(t)})}function P1(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ie(t)})}function D1(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ie(t)})}function R1(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ie(t)})}function M1(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ie(t)})}function F1(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ie(t)})}function $1(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ie(t)})}function L1(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ie(t)})}function Z1(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ie(t)})}function V1(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ie(t)})}function B1(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ie(t)})}function U1(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ie(t)})}function J1(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ie(t)})}function q1(e,t){return new e({type:"string",format:"date",check:"string_format",...ie(t)})}function H1(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ie(t)})}function W1(e,t){return new e({type:"string",format:"duration",check:"string_format",...ie(t)})}function G1(e,t){return new e({type:"number",checks:[],...ie(t)})}function K1(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ie(t)})}function Y1(e,t){return new e({type:"boolean",...ie(t)})}function X1(e,t){return new e({type:"null",...ie(t)})}function Q1(e){return new e({type:"unknown"})}function eS(e,t){return new e({type:"never",...ie(t)})}function Tl(e,t){return new kf({check:"less_than",...ie(t),value:e,inclusive:!1})}function fs(e,t){return new kf({check:"less_than",...ie(t),value:e,inclusive:!0})}function Al(e,t){return new _f({check:"greater_than",...ie(t),value:e,inclusive:!1})}function ps(e,t){return new _f({check:"greater_than",...ie(t),value:e,inclusive:!0})}function zl(e,t){return new f_({check:"multiple_of",...ie(t),value:e})}function Tf(e,t){return new h_({check:"max_length",...ie(t),maximum:e})}function li(e,t){return new m_({check:"min_length",...ie(t),minimum:e})}function Af(e,t){return new g_({check:"length_equals",...ie(t),length:e})}function tS(e,t){return new x_({check:"string_format",format:"regex",...ie(t),pattern:e})}function nS(e){return new y_({check:"string_format",format:"lowercase",...ie(e)})}function rS(e){return new b_({check:"string_format",format:"uppercase",...ie(e)})}function iS(e,t){return new v_({check:"string_format",format:"includes",...ie(t),includes:e})}function sS(e,t){return new w_({check:"string_format",format:"starts_with",...ie(t),prefix:e})}function aS(e,t){return new k_({check:"string_format",format:"ends_with",...ie(t),suffix:e})}function $n(e){return new __({check:"overwrite",tx:e})}function oS(e){return $n(t=>t.normalize(e))}function lS(){return $n(e=>e.trim())}function uS(){return $n(e=>e.toLowerCase())}function cS(){return $n(e=>e.toUpperCase())}function dS(){return $n(e=>gk(e))}function fS(e,t,n){return new e({type:"array",element:t,...ie(n)})}function pS(e,t,n){const r=ie(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function hS(e,t,n){return new e({type:"custom",check:"custom",fn:t,...ie(n)})}function mS(e){const t=gS(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(mr(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(mr(i))}},e(n.value,n)));return t}function gS(e,t){const n=new pt({check:"custom",...ie(t)});return n._zod.check=e,n}function ui(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)??Xn,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 De(e,t,n={path:[],schemaPath:[]}){var d,f;var r;const i=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a);const o=(f=(d=e._zod).toJSONSchema)==null?void 0:f.call(d);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),De(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"&&it(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 ci(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 d of e.seen.entries()){const f=(a=e.metadataRegistry.get(d[0]))==null?void 0:a.id;if(f){const h=r.get(f);if(h&&h!==d[0])throw new Error(`Duplicate schema id "${f}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(f,d[0])}}const i=d=>{var w;const f=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const S=(w=e.external.registry.get(d[0]))==null?void 0:w.id,b=e.external.uri??(g=>g);if(S)return{ref:b(S)};const _=d[1].defId??d[1].schema.id??`schema${e.counter++}`;return d[1].defId=_,{defId:_,ref:`${b("__shared")}#/${f}/${_}`}}if(d[1]===n)return{ref:"#"};const p=`#/${f}/`,m=d[1].schema.id??`__schema${e.counter++}`;return{defId:m,ref:p+m}},s=d=>{if(d[1].schema.$ref)return;const f=d[1],{ref:h,defId:p}=i(d);f.def={...f.schema},p&&(f.defId=p);const m=f.schema;for(const w in m)delete m[w];m.$ref=h};if(e.cycles==="throw")for(const d of e.seen.entries()){const f=d[1];if(f.cycle)throw new Error(`Cycle detected: #/${(o=f.cycle)==null?void 0:o.join("/")}/<root>
69
+
70
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of e.seen.entries()){const f=d[1];if(t===d[0]){s(d);continue}if(e.external){const p=(l=e.external.registry.get(d[0]))==null?void 0:l.id;if(t!==d[0]&&p){s(d);continue}}if((u=e.metadataRegistry.get(d[0]))==null?void 0:u.id){s(d);continue}if(f.cycle){s(d);continue}if(f.count>1&&e.reused==="ref"){s(d);continue}}}function di(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 d=e.seen.get(u);if(d.ref===null)return;const f=d.def??d.schema,h={...f},p=d.ref;if(d.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")?(f.allOf=f.allOf??[],f.allOf.push(S)):Object.assign(f,S),Object.assign(f,h),u._zod.parent===p)for(const _ in f)_==="$ref"||_==="allOf"||_ in h||delete f[_];if(S.$ref&&w.def)for(const _ in f)_==="$ref"||_==="allOf"||_ in w.def&&JSON.stringify(f[_])===JSON.stringify(w.def[_])&&delete f[_]}const m=u._zod.parent;if(m&&m!==p){r(m);const w=e.seen.get(m);if(w!=null&&w.schema.$ref&&(f.$ref=w.schema.$ref,w.def))for(const S in f)S==="$ref"||S==="allOf"||S in w.def&&JSON.stringify(f[S])===JSON.stringify(w.def[S])&&delete f[S]}e.override({zodSchema:u,jsonSchema:f,path:d.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 d=u[1];d.def&&d.defId&&(s[d.defId]=d.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const 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 it(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 it(r.element,n);if(r.type==="set")return it(r.valueType,n);if(r.type==="lazy")return it(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 it(r.innerType,n);if(r.type==="intersection")return it(r.left,n)||it(r.right,n);if(r.type==="record"||r.type==="map")return it(r.keyType,n)||it(r.valueType,n);if(r.type==="pipe")return it(r.in,n)||it(r.out,n);if(r.type==="object"){for(const i in r.shape)if(it(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(it(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(it(i,n))return!0;return!!(r.rest&&it(r.rest,n))}return!1}const xS=(e,t={})=>n=>{const r=ui({...n,processors:t});return De(e,r),ci(r,e),di(r,e)},fi=(e,t,n={})=>r=>{const{libraryOptions:i,target:s}=r??{},a=ui({...i??{},target:s,io:t,processors:n});return De(e,a),ci(a,e),di(a,e)},yS={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},zf=(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=yS[o]??o,i.format===""&&delete i.format,o==="time"&&delete i.format),u&&(i.contentEncoding=u),l&&l.size>0){const d=[...l];d.length===1?i.pattern=d[0].source:d.length>1&&(i.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},Of=(e,t,n,r)=>{const i=n,{minimum:s,maximum:a,format:o,multipleOf:l,exclusiveMaximum:u,exclusiveMinimum:d}=e._zod.bag;typeof o=="string"&&o.includes("int")?i.type="integer":i.type="number",typeof d=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=d,i.exclusiveMinimum=!0):i.exclusiveMinimum=d),typeof s=="number"&&(i.minimum=s,typeof d=="number"&&t.target!=="draft-04"&&(d>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof 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)},Pf=(e,t,n,r)=>{n.type="boolean"},bS=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},vS=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},Df=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},wS=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},kS=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},Rf=(e,t,n,r)=>{n.not={}},_S=(e,t,n,r)=>{},Mf=(e,t,n,r)=>{},SS=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},Ff=(e,t,n,r)=>{const i=e._zod.def,s=df(i.entries);s.every(a=>typeof a=="number")&&(n.type="number"),s.every(a=>typeof a=="string")&&(n.type="string"),n.enum=s},$f=(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},jS=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},NS=(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},CS=(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)},ES=(e,t,n,r)=>{n.type="boolean"},Lf=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},IS=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},Zf=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},TS=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},AS=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},Vf=(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=De(s.element,t,{...r,path:[...r.path,"items"]})},Bf=(e,t,n,r)=>{var u;const i=n,s=e._zod.def;i.type="object",i.properties={};const a=s.shape;for(const d in a)i.properties[d]=De(a[d],t,{...r,path:[...r.path,"properties",d]});const o=new Set(Object.keys(a)),l=new Set([...o].filter(d=>{const f=s.shape[d]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));l.size>0&&(i.required=Array.from(l)),((u=s.catchall)==null?void 0:u._zod.def.type)==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=De(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},Uf=(e,t,n,r)=>{const i=e._zod.def,s=i.inclusive===!1,a=i.options.map((o,l)=>De(o,t,{...r,path:[...r.path,s?"oneOf":"anyOf",l]}));s?n.oneOf=a:n.anyOf=a},Jf=(e,t,n,r)=>{const i=e._zod.def,s=De(i.left,t,{...r,path:[...r.path,"allOf",0]}),a=De(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},zS=(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)=>De(h,t,{...r,path:[...r.path,a,p]})),u=s.rest?De(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:d,maximum:f}=e._zod.bag;typeof d=="number"&&(i.minItems=d),typeof f=="number"&&(i.maxItems=f)},qf=(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 d=De(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const f of l)i.patternProperties[f.source]=d}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=De(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=De(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const u=a._zod.values;if(u){const d=[...u].filter(f=>typeof f=="string"||typeof f=="number");d.length>0&&(i.required=d)}},Hf=(e,t,n,r)=>{const i=e._zod.def,s=De(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"}]},Wf=(e,t,n,r)=>{const i=e._zod.def;De(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},Gf=(e,t,n,r)=>{const i=e._zod.def;De(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Kf=(e,t,n,r)=>{const i=e._zod.def;De(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)))},Yf=(e,t,n,r)=>{const i=e._zod.def;De(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},Xf=(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;De(s,t,r);const a=t.seen.get(e);a.ref=s},Qf=(e,t,n,r)=>{const i=e._zod.def;De(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,n.readOnly=!0},OS=(e,t,n,r)=>{const i=e._zod.def;De(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},Ua=(e,t,n,r)=>{const i=e._zod.def;De(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},ep=(e,t,n,r)=>{const i=e._zod.innerType;De(i,t,r);const s=t.seen.get(e);s.ref=i},Ol={string:zf,number:Of,boolean:Pf,bigint:bS,symbol:vS,null:Df,undefined:wS,void:kS,never:Rf,any:_S,unknown:Mf,date:SS,enum:Ff,literal:$f,nan:jS,template_literal:NS,file:CS,success:ES,custom:Lf,function:IS,transform:Zf,map:TS,set:AS,array:Vf,object:Bf,union:Uf,intersection:Jf,tuple:zS,record:qf,nullable:Hf,nonoptional:Wf,default:Gf,prefault:Kf,catch:Yf,pipe:Xf,readonly:Qf,promise:OS,optional:Ua,lazy:ep};function PS(e,t){if("_idmap"in e){const r=e,i=ui({...t,processors:Ol}),s={};for(const l of r._idmap.entries()){const[u,d]=l;De(d,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,d]=l;ci(i,d),a[u]=di(i,d)}if(Object.keys(s).length>0){const l=i.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[l]:s}}return{schemas:a}}const n=ui({...t,processors:Ol});return De(e,n),ci(n,e),di(n,e)}const DS=R("ZodISODateTime",(e,t)=>{M_.init(e,t),Ze.init(e,t)});function RS(e){return J1(DS,e)}const MS=R("ZodISODate",(e,t)=>{F_.init(e,t),Ze.init(e,t)});function FS(e){return q1(MS,e)}const $S=R("ZodISOTime",(e,t)=>{$_.init(e,t),Ze.init(e,t)});function LS(e){return H1($S,e)}const ZS=R("ZodISODuration",(e,t)=>{L_.init(e,t),Ze.init(e,t)});function VS(e){return W1(ZS,e)}const BS=(e,t)=>{mf.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Ik(e,n)},flatten:{value:n=>Ek(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,qs,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,qs,2)}},isEmpty:{get(){return e.issues.length===0}}})},wt=R("ZodError",BS,{Parent:Error}),US=Za(wt),JS=Va(wt),qS=Oi(wt),tp=Pi(wt),HS=zk(wt),WS=Ok(wt),GS=Pk(wt),KS=Dk(wt),YS=Rk(wt),XS=Mk(wt),QS=Fk(wt),ej=$k(wt),$e=R("ZodType",(e,t)=>(Fe.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:fi(e,"input"),output:fi(e,"output")}}),e.toJSONSchema=xS(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(en(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)=>tn(e,n,r),e.brand=()=>e,e.register=(n,r)=>(n.add(e,r),e),e.parse=(n,r)=>US(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>qS(e,n,r),e.parseAsync=async(n,r)=>JS(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>tp(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>HS(e,n,r),e.decode=(n,r)=>WS(e,n,r),e.encodeAsync=async(n,r)=>GS(e,n,r),e.decodeAsync=async(n,r)=>KS(e,n,r),e.safeEncode=(n,r)=>YS(e,n,r),e.safeDecode=(n,r)=>XS(e,n,r),e.safeEncodeAsync=async(n,r)=>QS(e,n,r),e.safeDecodeAsync=async(n,r)=>ej(e,n,r),e.refine=(n,r)=>e.check(Kj(n,r)),e.superRefine=n=>e.check(Yj(n)),e.overwrite=n=>e.check($n(n)),e.optional=()=>Rl(e),e.exactOptional=()=>Rj(e),e.nullable=()=>Ml(e),e.nullish=()=>Rl(Ml(e)),e.nonoptional=n=>Vj(e,n),e.array=()=>Ln(e),e.or=n=>lt([e,n]),e.and=n=>Tj(e,n),e.transform=n=>Fl(e,Pj(n)),e.default=n=>$j(e,n),e.prefault=n=>Zj(e,n),e.catch=n=>Uj(e,n),e.pipe=n=>Fl(e,n),e.readonly=()=>Hj(e),e.describe=n=>{const r=e.clone();return Xn.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){var n;return(n=Xn.get(e))==null?void 0:n.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Xn.get(e);const r=e.clone();return Xn.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),np=R("_ZodString",(e,t)=>{Ba.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(r,i,s)=>zf(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(tS(...r)),e.includes=(...r)=>e.check(iS(...r)),e.startsWith=(...r)=>e.check(sS(...r)),e.endsWith=(...r)=>e.check(aS(...r)),e.min=(...r)=>e.check(li(...r)),e.max=(...r)=>e.check(Tf(...r)),e.length=(...r)=>e.check(Af(...r)),e.nonempty=(...r)=>e.check(li(1,...r)),e.lowercase=r=>e.check(nS(r)),e.uppercase=r=>e.check(rS(r)),e.trim=()=>e.check(lS()),e.normalize=(...r)=>e.check(oS(...r)),e.toLowerCase=()=>e.check(uS()),e.toUpperCase=()=>e.check(cS()),e.slugify=()=>e.check(dS())}),tj=R("ZodString",(e,t)=>{Ba.init(e,t),np.init(e,t),e.email=n=>e.check(S1(nj,n)),e.url=n=>e.check(I1(rj,n)),e.jwt=n=>e.check(U1(yj,n)),e.emoji=n=>e.check(T1(ij,n)),e.guid=n=>e.check(Il(Pl,n)),e.uuid=n=>e.check(j1(Fr,n)),e.uuidv4=n=>e.check(N1(Fr,n)),e.uuidv6=n=>e.check(C1(Fr,n)),e.uuidv7=n=>e.check(E1(Fr,n)),e.nanoid=n=>e.check(A1(sj,n)),e.guid=n=>e.check(Il(Pl,n)),e.cuid=n=>e.check(z1(aj,n)),e.cuid2=n=>e.check(O1(oj,n)),e.ulid=n=>e.check(P1(lj,n)),e.base64=n=>e.check(Z1(mj,n)),e.base64url=n=>e.check(V1(gj,n)),e.xid=n=>e.check(D1(uj,n)),e.ksuid=n=>e.check(R1(cj,n)),e.ipv4=n=>e.check(M1(dj,n)),e.ipv6=n=>e.check(F1(fj,n)),e.cidrv4=n=>e.check($1(pj,n)),e.cidrv6=n=>e.check(L1(hj,n)),e.e164=n=>e.check(B1(xj,n)),e.datetime=n=>e.check(RS(n)),e.date=n=>e.check(FS(n)),e.time=n=>e.check(LS(n)),e.duration=n=>e.check(VS(n))});function Q(e){return _1(tj,e)}const Ze=R("ZodStringFormat",(e,t)=>{Le.init(e,t),np.init(e,t)}),nj=R("ZodEmail",(e,t)=>{E_.init(e,t),Ze.init(e,t)}),Pl=R("ZodGUID",(e,t)=>{N_.init(e,t),Ze.init(e,t)}),Fr=R("ZodUUID",(e,t)=>{C_.init(e,t),Ze.init(e,t)}),rj=R("ZodURL",(e,t)=>{I_.init(e,t),Ze.init(e,t)}),ij=R("ZodEmoji",(e,t)=>{T_.init(e,t),Ze.init(e,t)}),sj=R("ZodNanoID",(e,t)=>{A_.init(e,t),Ze.init(e,t)}),aj=R("ZodCUID",(e,t)=>{z_.init(e,t),Ze.init(e,t)}),oj=R("ZodCUID2",(e,t)=>{O_.init(e,t),Ze.init(e,t)}),lj=R("ZodULID",(e,t)=>{P_.init(e,t),Ze.init(e,t)}),uj=R("ZodXID",(e,t)=>{D_.init(e,t),Ze.init(e,t)}),cj=R("ZodKSUID",(e,t)=>{R_.init(e,t),Ze.init(e,t)}),dj=R("ZodIPv4",(e,t)=>{Z_.init(e,t),Ze.init(e,t)}),fj=R("ZodIPv6",(e,t)=>{V_.init(e,t),Ze.init(e,t)}),pj=R("ZodCIDRv4",(e,t)=>{B_.init(e,t),Ze.init(e,t)}),hj=R("ZodCIDRv6",(e,t)=>{U_.init(e,t),Ze.init(e,t)}),mj=R("ZodBase64",(e,t)=>{J_.init(e,t),Ze.init(e,t)}),gj=R("ZodBase64URL",(e,t)=>{H_.init(e,t),Ze.init(e,t)}),xj=R("ZodE164",(e,t)=>{W_.init(e,t),Ze.init(e,t)}),yj=R("ZodJWT",(e,t)=>{K_.init(e,t),Ze.init(e,t)}),rp=R("ZodNumber",(e,t)=>{jf.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(r,i,s)=>Of(e,r,i),e.gt=(r,i)=>e.check(Al(r,i)),e.gte=(r,i)=>e.check(ps(r,i)),e.min=(r,i)=>e.check(ps(r,i)),e.lt=(r,i)=>e.check(Tl(r,i)),e.lte=(r,i)=>e.check(fs(r,i)),e.max=(r,i)=>e.check(fs(r,i)),e.int=r=>e.check(Dl(r)),e.safe=r=>e.check(Dl(r)),e.positive=r=>e.check(Al(0,r)),e.nonnegative=r=>e.check(ps(0,r)),e.negative=r=>e.check(Tl(0,r)),e.nonpositive=r=>e.check(fs(0,r)),e.multipleOf=(r,i)=>e.check(zl(r,i)),e.step=(r,i)=>e.check(zl(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 bj(e){return G1(rp,e)}const vj=R("ZodNumberFormat",(e,t)=>{Y_.init(e,t),rp.init(e,t)});function Dl(e){return K1(vj,e)}const wj=R("ZodBoolean",(e,t)=>{X_.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Pf(e,n,r)});function st(e){return Y1(wj,e)}const kj=R("ZodNull",(e,t)=>{Q_.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Df(e,n,r)});function _j(e){return X1(kj,e)}const Sj=R("ZodUnknown",(e,t)=>{e1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Mf()});function Tt(){return Q1(Sj)}const jj=R("ZodNever",(e,t)=>{t1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Rf(e,n,r)});function ip(e){return eS(jj,e)}const Nj=R("ZodArray",(e,t)=>{n1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Vf(e,n,r,i),e.element=t.element,e.min=(n,r)=>e.check(li(n,r)),e.nonempty=n=>e.check(li(1,n)),e.max=(n,r)=>e.check(Tf(n,r)),e.length=(n,r)=>e.check(Af(n,r)),e.unwrap=()=>e.element});function Ln(e,t){return fS(Nj,e,t)}const sp=R("ZodObject",(e,t)=>{i1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Bf(e,n,r,i),_e(e,"shape",()=>t.shape),e.keyof=()=>op(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Tt()}),e.loose=()=>e.clone({...e._zod.def,catchall:Tt()}),e.strict=()=>e.clone({...e._zod.def,catchall:ip()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>_k(e,n),e.safeExtend=n=>Sk(e,n),e.merge=n=>jk(e,n),e.pick=n=>wk(e,n),e.omit=n=>kk(e,n),e.partial=(...n)=>Nk(lp,e,n[0]),e.required=(...n)=>Ck(up,e,n[0])});function Ae(e,t){const n={type:"object",shape:e??{},...ie(t)};return new sp(n)}function Re(e,t){return new sp({type:"object",shape:e,catchall:ip(),...ie(t)})}const ap=R("ZodUnion",(e,t)=>{Ef.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Uf(e,n,r,i),e.options=t.options});function lt(e,t){return new ap({type:"union",options:e,...ie(t)})}const Cj=R("ZodDiscriminatedUnion",(e,t)=>{ap.init(e,t),s1.init(e,t)});function Ej(e,t,n){return new Cj({type:"union",options:t,discriminator:e,...ie(n)})}const Ij=R("ZodIntersection",(e,t)=>{a1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Jf(e,n,r,i)});function Tj(e,t){return new Ij({type:"intersection",left:e,right:t})}const Aj=R("ZodRecord",(e,t)=>{o1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>qf(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function gr(e,t,n){return new Aj({type:"record",keyType:e,valueType:t,...ie(n)})}const Ws=R("ZodEnum",(e,t)=>{l1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(r,i,s)=>Ff(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 Ws({...t,checks:[],...ie(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 Ws({...t,checks:[],...ie(i),entries:s})}});function op(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Ws({type:"enum",entries:n,...ie(t)})}const zj=R("ZodLiteral",(e,t)=>{u1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>$f(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 de(e,t){return new zj({type:"literal",values:Array.isArray(e)?e:[e],...ie(t)})}const Oj=R("ZodTransform",(e,t)=>{c1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Zf(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new uf(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(mr(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(mr(a))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(s=>(n.value=s,n)):(n.value=i,n)}});function Pj(e){return new Oj({type:"transform",transform:e})}const lp=R("ZodOptional",(e,t)=>{If.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ua(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Rl(e){return new lp({type:"optional",innerType:e})}const Dj=R("ZodExactOptional",(e,t)=>{d1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ua(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Rj(e){return new Dj({type:"optional",innerType:e})}const Mj=R("ZodNullable",(e,t)=>{f1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Hf(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Ml(e){return new Mj({type:"nullable",innerType:e})}const Fj=R("ZodDefault",(e,t)=>{p1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Gf(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function $j(e,t){return new Fj({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():pf(t)}})}const Lj=R("ZodPrefault",(e,t)=>{h1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Kf(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Zj(e,t){return new Lj({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():pf(t)}})}const up=R("ZodNonOptional",(e,t)=>{m1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Wf(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Vj(e,t){return new up({type:"nonoptional",innerType:e,...ie(t)})}const Bj=R("ZodCatch",(e,t)=>{g1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Yf(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Uj(e,t){return new Bj({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Jj=R("ZodPipe",(e,t)=>{x1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Xf(e,n,r,i),e.in=t.in,e.out=t.out});function Fl(e,t){return new Jj({type:"pipe",in:e,out:t})}const qj=R("ZodReadonly",(e,t)=>{y1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Qf(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Hj(e){return new qj({type:"readonly",innerType:e})}const Wj=R("ZodLazy",(e,t)=>{b1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ep(e,n,r,i),e.unwrap=()=>e._zod.def.getter()});function Gj(e){return new Wj({type:"lazy",getter:e})}const Ja=R("ZodCustom",(e,t)=>{v1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Lf(e,n)});function cp(e,t){return pS(Ja,e??(()=>!0),t)}function Kj(e,t={}){return hS(Ja,e,t)}function Yj(e){return mS(e)}function pi(e,t={}){const n=new Ja({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...ie(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 xr;(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})(xr||(xr={}));var $l;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})($l||($l={}));xr.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);xr.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class hi extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(s){return s.message},r={_errors:[]},i=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let o=r,l=0;for(;l<a.path.length;){const u=a.path[l];l===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(n(a))):o[u]=o[u]||{_errors:[]},o=o[u],l++}}};return i(this),r}static assert(t){if(!(t instanceof hi))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,xr.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n=Object.create(null),r=[];for(const i of this.issues)if(i.path.length>0){const s=i.path[0];n[s]=n[s]||[],n[s].push(t(i))}else r.push(t(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}hi.create=e=>new hi(e);var Ll;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Ll||(Ll={}));var he;(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"})(he||(he={}));class Zl 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 hs(e){}function Xj(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=hs,onError:n=hs,onRetry:r=hs,onComment:i}=e;let s="",a=!0,o,l="",u="";function d(w){const S=a?w.replace(/^\xEF\xBB\xBF/,""):w,[b,_]=Qj(`${s}${S}`);for(const g of b)f(g);s=_,a=!1}function f(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 b=w.slice(0,S),_=w[S+1]===" "?2:1,g=w.slice(S+_);h(b,g,w);return}h(w,"",w)}function h(w,S,b){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 Zl(`Invalid \`retry\` value: "${S}"`,{type:"invalid-retry",value:S,line:b}));break;default:n(new Zl(`Unknown field "${w.length>20?`${w.slice(0,20)}…`:w}"`,{type:"unknown-field",field:w,value:S,line:b}));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&&f(s),a=!0,o=void 0,l="",u="",s=""}return{feed:d,reset:m}}function Qj(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 eN extends TransformStream{constructor({onError:t,onRetry:n,onComment:r}={}){let i;super({start(s){i=Xj({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 jr=({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 fk({argument:"separator",message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`},tN=jr();function Vl(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 ln(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 Bl(e,...t){const n=new Headers(ln(e)),r=n.get("user-agent")||"";return n.set("user-agent",[r,...t].filter(Boolean).join(" ")),Object.fromEntries(n.entries())}var nN=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,rN=/"(?: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 Ul(e){const t=JSON.parse(e);return t===null||typeof t!="object"||nN.test(e)===!1&&rN.test(e)===!1?t:iN(t)}function iN(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 sN(e){const{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return Ul(e)}try{return Ul(e)}finally{Error.stackTraceLimit=t}}function qa(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]=sn(n[r])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(sn):sn(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(sn)),e.allOf!=null&&(e.allOf=e.allOf.map(sn)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(sn));const{definitions:t}=e;if(t!=null)for(const n of Object.keys(t))t[n]=sn(t[n]);return e}function sn(e){return typeof e=="boolean"?e:qa(e)}var aN=Symbol("Let zodToJsonSchema decide on which parser to use"),Jl={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"},oN=e=>typeof e=="string"?{...Jl,name:e}:{...Jl,...e};function gt(){return{}}function lN(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)!==he.ZodAny&&(s.items=Ee(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 uN(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 cN(){return{type:"boolean"}}function dp(e,t){return Ee(e.type._def,t)}var dN=(e,t)=>Ee(e.innerType._def,t);function fp(e,t,n){const r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((i,s)=>fp(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 fN(e)}}var fN=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 pN(e,t){return{...Ee(e.innerType._def,t),default:e.defaultValue()}}function hN(e,t){return t.effectStrategy==="input"?Ee(e.schema._def,t):gt()}function mN(e){return{type:"string",enum:Array.from(e.values)}}var gN=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function xN(e,t){const n=[Ee(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),Ee(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(i=>!!i),r=[];return n.forEach(i=>{if(gN(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 yN(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 ms=void 0,kt={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:()=>(ms===void 0&&(ms=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),ms),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 pp(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":_t(n,"email",r.message,t);break;case"format:idn-email":_t(n,"idn-email",r.message,t);break;case"pattern:zod":rt(n,kt.email,r.message,t);break}break;case"url":_t(n,"uri",r.message,t);break;case"uuid":_t(n,"uuid",r.message,t);break;case"regex":rt(n,r.regex,r.message,t);break;case"cuid":rt(n,kt.cuid,r.message,t);break;case"cuid2":rt(n,kt.cuid2,r.message,t);break;case"startsWith":rt(n,RegExp(`^${gs(r.value,t)}`),r.message,t);break;case"endsWith":rt(n,RegExp(`${gs(r.value,t)}$`),r.message,t);break;case"datetime":_t(n,"date-time",r.message,t);break;case"date":_t(n,"date",r.message,t);break;case"time":_t(n,"time",r.message,t);break;case"duration":_t(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":{rt(n,RegExp(gs(r.value,t)),r.message,t);break}case"ip":{r.version!=="v6"&&_t(n,"ipv4",r.message,t),r.version!=="v4"&&_t(n,"ipv6",r.message,t);break}case"base64url":rt(n,kt.base64url,r.message,t);break;case"jwt":rt(n,kt.jwt,r.message,t);break;case"cidr":{r.version!=="v6"&&rt(n,kt.ipv4Cidr,r.message,t),r.version!=="v4"&&rt(n,kt.ipv6Cidr,r.message,t);break}case"emoji":rt(n,kt.emoji(),r.message,t);break;case"ulid":{rt(n,kt.ulid,r.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{_t(n,"binary",r.message,t);break}case"contentEncoding:base64":{n.contentEncoding="base64";break}case"pattern:zod":{rt(n,kt.base64,r.message,t);break}}break}case"nanoid":rt(n,kt.nanoid,r.message,t)}return n}function gs(e,t){return t.patternStrategy==="escape"?vN(e):e}var bN=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function vN(e){let t="";for(let n=0;n<e.length;n++)bN.has(e[n])||(t+="\\"),t+=e[n];return t}function _t(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 rt(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:ql(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=ql(t,r)}function ql(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 hp(e,t){var n,r,i,s,a,o;const l={type:"object",additionalProperties:(n=Ee(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?n:t.allowedAdditionalProperties};if(((r=e.keyType)==null?void 0:r._def.typeName)===he.ZodString&&((i=e.keyType._def.checks)!=null&&i.length)){const{type:u,...d}=pp(e.keyType._def,t);return{...l,propertyNames:d}}else{if(((s=e.keyType)==null?void 0:s._def.typeName)===he.ZodEnum)return{...l,propertyNames:{enum:e.keyType._def.values}};if(((a=e.keyType)==null?void 0:a._def.typeName)===he.ZodBranded&&e.keyType._def.type._def.typeName===he.ZodString&&((o=e.keyType._def.type._def.checks)!=null&&o.length)){const{type:u,...d}=dp(e.keyType._def,t);return{...l,propertyNames:d}}}return l}function wN(e,t){if(t.mapStrategy==="record")return hp(e,t);const n=Ee(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||gt(),r=Ee(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||gt();return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}function kN(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 _N(){return{not:gt()}}function SN(){return{type:"null"}}var Gs={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function jN(e,t){const n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(r=>r._def.typeName in Gs&&(!r._def.checks||!r._def.checks.length))){const r=n.reduce((i,s)=>{const a=Gs[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 NN(e,t)}var NN=(e,t)=>{const n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((r,i)=>Ee(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 CN(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[Gs[e.innerType._def.typeName],"null"]};const n=Ee(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function EN(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 IN(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=AN(o),u=Ee(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=TN(e,t);return s!==void 0&&(n.additionalProperties=s),n}function TN(e,t){if(e.catchall._def.typeName!=="ZodNever")return Ee(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 AN(e){try{return e.isOptional()}catch{return!0}}var zN=(e,t)=>{var n;if(t.currentPath.toString()===((n=t.propertyPath)==null?void 0:n.toString()))return Ee(e.innerType._def,t);const r=Ee(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:gt()},r]}:gt()},ON=(e,t)=>{if(t.pipeStrategy==="input")return Ee(e.in._def,t);if(t.pipeStrategy==="output")return Ee(e.out._def,t);const n=Ee(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),r=Ee(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,r].filter(i=>i!==void 0)}};function PN(e,t){return Ee(e.type._def,t)}function DN(e,t){const r={type:"array",uniqueItems:!0,items:Ee(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 RN(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,r)=>Ee(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:Ee(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,r)=>Ee(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[])}}function MN(){return{not:gt()}}function FN(){return gt()}var $N=(e,t)=>Ee(e.innerType._def,t),LN=(e,t,n)=>{switch(t){case he.ZodString:return pp(e,n);case he.ZodNumber:return EN(e);case he.ZodObject:return IN(e,n);case he.ZodBigInt:return uN(e);case he.ZodBoolean:return cN();case he.ZodDate:return fp(e,n);case he.ZodUndefined:return MN();case he.ZodNull:return SN();case he.ZodArray:return lN(e,n);case he.ZodUnion:case he.ZodDiscriminatedUnion:return jN(e,n);case he.ZodIntersection:return xN(e,n);case he.ZodTuple:return RN(e,n);case he.ZodRecord:return hp(e,n);case he.ZodLiteral:return yN(e);case he.ZodEnum:return mN(e);case he.ZodNativeEnum:return kN(e);case he.ZodNullable:return CN(e,n);case he.ZodOptional:return zN(e,n);case he.ZodMap:return wN(e,n);case he.ZodSet:return DN(e,n);case he.ZodLazy:return()=>e.getter()._def;case he.ZodPromise:return PN(e,n);case he.ZodNaN:case he.ZodNever:return _N();case he.ZodEffects:return hN(e,n);case he.ZodAny:return gt();case he.ZodUnknown:return FN();case he.ZodDefault:return pN(e,n);case he.ZodBranded:return dp(e,n);case he.ZodReadonly:return $N(e,n);case he.ZodCatch:return dN(e,n);case he.ZodPipeline:return ON(e,n);case he.ZodFunction:case he.ZodVoid:case he.ZodSymbol:return;default:return(r=>{})()}},ZN=(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 Ee(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!==aN)return l}if(i&&!n){const l=VN(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=LN(e,e.typeName,t),o=typeof a=="function"?Ee(a(),t):a;if(o&&BN(e,t,o),t.postProcess){const l=t.postProcess(o,e,t);return s.jsonSchema=o,l}return s.jsonSchema=o,o}var VN=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:ZN(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`),gt()):t.$refStrategy==="seen"?gt():void 0}},BN=(e,t,n)=>(e.description&&(n.description=e.description),n),UN=e=>{const t=oN(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}]))}},JN=(e,t)=>{var n;const r=UN(t);let i=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((u,[d,f])=>{var h;return{...u,[d]:(h=Ee(f._def,{...r,currentPath:[...r.basePath,r.definitionPath,d]},!0))!=null?h:gt()}},{}):void 0;const s=typeof t=="string"?t:(t==null?void 0:t.nameStrategy)==="title"||t==null?void 0:t.name,a=(n=Ee(e._def,s===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1))!=null?n:gt(),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},Ks=Symbol.for("vercel.ai.schema");function qN(e){let t;return()=>(t==null&&(t=e()),t)}function Ri(e,{validate:t}={}){return{[Ks]:!0,_type:void 0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function HN(e){return typeof e=="object"&&e!==null&&Ks in e&&e[Ks]===!0&&"jsonSchema"in e&&"validate"in e}function Ha(e){return e==null?Ri({properties:{},additionalProperties:!1}):HN(e)?e:"~standard"in e?e["~standard"].vendor==="zod"?mp(e):WN(e):e()}function WN(e){return Ri(()=>qa(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 On({value:t,cause:n.issues})}}})}function GN(e,t){var n;const r=(n=void 0)!=null?n:!1;return Ri(()=>JN(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 KN(e,t){var n;const r=(n=void 0)!=null?n:!1;return Ri(()=>qa(PS(e,{target:"draft-7",io:"input",reused:r?"ref":"inline"})),{validate:async i=>{const s=await tp(e,i);return s.success?{success:!0,value:s.data}:{success:!1,error:s.error}}})}function YN(e){return"_zod"in e}function mp(e,t){return YN(e)?KN(e):GN(e)}async function Hl({value:e,schema:t,context:n}){const r=await yr({value:e,schema:t,context:n});if(!r.success)throw On.wrap({value:e,cause:r.error,context:n});return r.value}async function yr({value:e,schema:t,context:n}){const r=Ha(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:On.wrap({value:e,cause:i.error,context:n}),rawValue:e}}catch(i){return{success:!1,error:On.wrap({value:e,cause:i,context:n}),rawValue:e}}}async function gn({text:e,schema:t}){try{const n=sN(e);return t==null?{success:!0,value:n,rawValue:n}:await yr({value:n,schema:t})}catch(n){return{success:!1,error:hl.isInstance(n)?n:new hl({text:e,cause:n}),rawValue:void 0}}}function XN({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new eN).pipeThrough(new TransformStream({async transform({data:n},r){n!=="[DONE]"&&r.enqueue(await gn({text:n,schema:t}))}}))}async function Jt(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}var QN=Object.defineProperty,eC=(e,t)=>{for(var n in t)QN(e,n,{get:t[n],enumerable:!0})},gp="AI_NoObjectGeneratedError",xp=`vercel.ai.error.${gp}`,tC=Symbol.for(xp),yp,Kt=class extends Pt{constructor({message:e="No object generated.",cause:t,text:n,response:r,usage:i,finishReason:s}){super({name:gp,message:e,cause:t}),this[yp]=!0,this.text=n,this.response=r,this.usage=i,this.finishReason=s}static isInstance(e){return Pt.hasMarker(e,xp)}};yp=tC;var bp="AI_UIMessageStreamError",vp=`vercel.ai.error.${bp}`,nC=Symbol.for(vp),wp,kn=class extends Pt{constructor({chunkType:e,chunkId:t,message:n}){super({name:bp,message:n}),this[wp]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return Pt.hasMarker(e,vp)}};wp=nC;var Wl="6.0.116",kp=lt([Q(),pi(Uint8Array),pi(ArrayBuffer),cp(e=>{var t,n;return(n=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?n:!1},{message:"Must be a Buffer"})]),br=Gj(()=>lt([_j(),Q(),bj(),st(),gr(Q(),br.optional()),Ln(br)])),ke=gr(Q(),gr(Q(),br.optional())),_p=Ae({type:de("text"),text:Q(),providerOptions:ke.optional()}),rC=Ae({type:de("image"),image:lt([kp,pi(URL)]),mediaType:Q().optional(),providerOptions:ke.optional()}),Sp=Ae({type:de("file"),data:lt([kp,pi(URL)]),filename:Q().optional(),mediaType:Q(),providerOptions:ke.optional()}),iC=Ae({type:de("reasoning"),text:Q(),providerOptions:ke.optional()}),sC=Ae({type:de("tool-call"),toolCallId:Q(),toolName:Q(),input:Tt(),providerOptions:ke.optional(),providerExecuted:st().optional()}),aC=Ej("type",[Ae({type:de("text"),value:Q(),providerOptions:ke.optional()}),Ae({type:de("json"),value:br,providerOptions:ke.optional()}),Ae({type:de("execution-denied"),reason:Q().optional(),providerOptions:ke.optional()}),Ae({type:de("error-text"),value:Q(),providerOptions:ke.optional()}),Ae({type:de("error-json"),value:br,providerOptions:ke.optional()}),Ae({type:de("content"),value:Ln(lt([Ae({type:de("text"),text:Q(),providerOptions:ke.optional()}),Ae({type:de("media"),data:Q(),mediaType:Q()}),Ae({type:de("file-data"),data:Q(),mediaType:Q(),filename:Q().optional(),providerOptions:ke.optional()}),Ae({type:de("file-url"),url:Q(),providerOptions:ke.optional()}),Ae({type:de("file-id"),fileId:lt([Q(),gr(Q(),Q())]),providerOptions:ke.optional()}),Ae({type:de("image-data"),data:Q(),mediaType:Q(),providerOptions:ke.optional()}),Ae({type:de("image-url"),url:Q(),providerOptions:ke.optional()}),Ae({type:de("image-file-id"),fileId:lt([Q(),gr(Q(),Q())]),providerOptions:ke.optional()}),Ae({type:de("custom"),providerOptions:ke.optional()})]))})]),jp=Ae({type:de("tool-result"),toolCallId:Q(),toolName:Q(),output:aC,providerOptions:ke.optional()}),oC=Ae({type:de("tool-approval-request"),approvalId:Q(),toolCallId:Q()}),lC=Ae({type:de("tool-approval-response"),approvalId:Q(),approved:st(),reason:Q().optional()}),uC=Ae({role:de("system"),content:Q(),providerOptions:ke.optional()}),cC=Ae({role:de("user"),content:lt([Q(),Ln(lt([_p,rC,Sp]))]),providerOptions:ke.optional()}),dC=Ae({role:de("assistant"),content:lt([Q(),Ln(lt([_p,Sp,iC,sC,jp,oC]))]),providerOptions:ke.optional()}),fC=Ae({role:de("tool"),content:Ln(lt([jp,lC])),providerOptions:ke.optional()});lt([uC,cC,dC,fC]);function Np(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]=Np(s,i):n[r]=i}return n}var pC={};eC(pC,{array:()=>xC,choice:()=>yC,json:()=>bC,object:()=>gC,text:()=>mC});function hC(e){const t=["ROOT"];let n=-1,r=null;function i(l,u,d){switch(l){case'"':{n=u,t.pop(),t.push(d),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=u,r=u,t.pop(),t.push(d),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(d),t.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=u,t.pop(),t.push(d),t.push("INSIDE_NUMBER");break}case"{":{n=u,t.pop(),t.push(d),t.push("INSIDE_OBJECT_START");break}case"[":{n=u,t.pop(),t.push(d),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 f=e.substring(r,l+1);!"false".startsWith(f)&&!"true".startsWith(f)&&!"null".startsWith(f)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?s(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 d=e.substring(r,e.length);"true".startsWith(d)?o+="true".slice(d.length):"false".startsWith(d)?o+="false".slice(d.length):"null".startsWith(d)&&(o+="null".slice(d.length))}}return o}async function Nr(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await gn({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await gn({text:hC(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var mC=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),gC=({schema:e,name:t,description:n})=>{const r=Ha(e);return{name:"object",responseFormat:Jt(r.jsonSchema).then(i=>({type:"json",schema:i,...t!=null&&{name:t},...n!=null&&{description:n}})),async parseCompleteOutput({text:i},s){const a=await gn({text:i});if(!a.success)throw new Kt({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 yr({value:a.value,schema:r});if(!o.success)throw new Kt({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 Nr(i);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:s.value}}},createElementStreamTransform(){}}},xC=({element:e,name:t,description:n})=>{const r=Ha(e);return{name:"array",responseFormat:Jt(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 gn({text:i});if(!a.success)throw new Kt({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 Kt({message:"No object generated: response did not match schema.",cause:new On({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 yr({value:l,schema:r});if(!u.success)throw new Kt({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 Nr(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 d=await yr({value:u,schema:r});d.success&&l.push(d.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])}})}}},yC=({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 gn({text:r});if(!s.success)throw new Kt({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 Kt({message:"No object generated: response did not match schema.",cause:new On({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 Nr(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(){}}),bC=({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 gn({text:n});if(!i.success)throw new Kt({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 Nr(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(){}});jr({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 vC=qN(()=>mp(lt([Re({type:de("text-start"),id:Q(),providerMetadata:ke.optional()}),Re({type:de("text-delta"),id:Q(),delta:Q(),providerMetadata:ke.optional()}),Re({type:de("text-end"),id:Q(),providerMetadata:ke.optional()}),Re({type:de("error"),errorText:Q()}),Re({type:de("tool-input-start"),toolCallId:Q(),toolName:Q(),providerExecuted:st().optional(),providerMetadata:ke.optional(),dynamic:st().optional(),title:Q().optional()}),Re({type:de("tool-input-delta"),toolCallId:Q(),inputTextDelta:Q()}),Re({type:de("tool-input-available"),toolCallId:Q(),toolName:Q(),input:Tt(),providerExecuted:st().optional(),providerMetadata:ke.optional(),dynamic:st().optional(),title:Q().optional()}),Re({type:de("tool-input-error"),toolCallId:Q(),toolName:Q(),input:Tt(),providerExecuted:st().optional(),providerMetadata:ke.optional(),dynamic:st().optional(),errorText:Q(),title:Q().optional()}),Re({type:de("tool-approval-request"),approvalId:Q(),toolCallId:Q()}),Re({type:de("tool-output-available"),toolCallId:Q(),output:Tt(),providerExecuted:st().optional(),dynamic:st().optional(),preliminary:st().optional()}),Re({type:de("tool-output-error"),toolCallId:Q(),errorText:Q(),providerExecuted:st().optional(),dynamic:st().optional()}),Re({type:de("tool-output-denied"),toolCallId:Q()}),Re({type:de("reasoning-start"),id:Q(),providerMetadata:ke.optional()}),Re({type:de("reasoning-delta"),id:Q(),delta:Q(),providerMetadata:ke.optional()}),Re({type:de("reasoning-end"),id:Q(),providerMetadata:ke.optional()}),Re({type:de("source-url"),sourceId:Q(),url:Q(),title:Q().optional(),providerMetadata:ke.optional()}),Re({type:de("source-document"),sourceId:Q(),mediaType:Q(),title:Q(),filename:Q().optional(),providerMetadata:ke.optional()}),Re({type:de("file"),url:Q(),mediaType:Q(),providerMetadata:ke.optional()}),Re({type:cp(e=>typeof e=="string"&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:Q().optional(),data:Tt(),transient:st().optional()}),Re({type:de("start-step")}),Re({type:de("finish-step")}),Re({type:de("start"),messageId:Q().optional(),messageMetadata:Tt().optional()}),Re({type:de("finish"),finishReason:op(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:Tt().optional()}),Re({type:de("abort"),reason:Q().optional()}),Re({type:de("message-metadata"),messageMetadata:Tt()})])));function wC(e){return e.type.startsWith("data-")}function Ys(e){return e.type.startsWith("tool-")}function kC(e){return e.type==="dynamic-tool"}function mi(e){return Ys(e)||kC(e)}function Gl(e){return e.type.split("-").slice(1).join("-")}function _C({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 SC({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:d})=>{var f,h,p,m;function w(g){const E=u.message.parts.filter(mi).find(k=>k.toolCallId===g);if(E==null)throw new kn({chunkType:"tool-invocation",chunkId:g,message:`No tool invocation found for tool call ID "${g}".`});return E}function S(g){var D;const E=u.message.parts.find(F=>Ys(F)&&F.toolCallId===g.toolCallId),k=g,N=E;E!=null?(E.state=g.state,N.input=k.input,N.output=k.output,N.errorText=k.errorText,N.rawInput=k.rawInput,N.preliminary=k.preliminary,g.title!==void 0&&(N.title=g.title),N.providerExecuted=(D=k.providerExecuted)!=null?D:E.providerExecuted,k.providerMetadata!=null&&(E.callProviderMetadata=k.providerMetadata)):u.message.parts.push({type:`tool-${g.toolName}`,toolCallId:g.toolCallId,state:g.state,title:g.title,input:k.input,output:k.output,rawInput:k.rawInput,errorText:k.errorText,providerExecuted:k.providerExecuted,preliminary:k.preliminary,...k.providerMetadata!=null?{callProviderMetadata:k.providerMetadata}:{}})}function b(g){var D,E;const k=u.message.parts.find(K=>K.type==="dynamic-tool"&&K.toolCallId===g.toolCallId),N=g,F=k;k!=null?(k.state=g.state,F.toolName=g.toolName,F.input=N.input,F.output=N.output,F.errorText=N.errorText,F.rawInput=(D=N.rawInput)!=null?D:F.rawInput,F.preliminary=N.preliminary,g.title!==void 0&&(F.title=g.title),F.providerExecuted=(E=N.providerExecuted)!=null?E:k.providerExecuted,N.providerMetadata!=null&&(k.callProviderMetadata=N.providerMetadata)):u.message.parts.push({type:"dynamic-tool",toolName:g.toolName,toolCallId:g.toolCallId,state:g.state,input:N.input,output:N.output,errorText:N.errorText,preliminary:N.preliminary,providerExecuted:N.providerExecuted,title:g.title,...N.providerMetadata!=null?{callProviderMetadata:N.providerMetadata}:{}})}async function _(g){if(g!=null){const D=u.message.metadata!=null?Np(u.message.metadata,g):g;t!=null&&await Hl({value:D,schema:t,context:{field:"message.metadata",entityId:u.message.id}}),u.message.metadata=D}}switch(o.type){case"text-start":{const g={type:"text",text:"",providerMetadata:o.providerMetadata,state:"streaming"};u.activeTextParts[o.id]=g,u.message.parts.push(g),d();break}case"text-delta":{const g=u.activeTextParts[o.id];if(g==null)throw new kn({chunkType:"text-delta",chunkId:o.id,message:`Received text-delta for missing text part with ID "${o.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});g.text+=o.delta,g.providerMetadata=(f=o.providerMetadata)!=null?f:g.providerMetadata,d();break}case"text-end":{const g=u.activeTextParts[o.id];if(g==null)throw new kn({chunkType:"text-end",chunkId:o.id,message:`Received text-end for missing text part with ID "${o.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});g.state="done",g.providerMetadata=(h=o.providerMetadata)!=null?h:g.providerMetadata,delete u.activeTextParts[o.id],d();break}case"reasoning-start":{const g={type:"reasoning",text:"",providerMetadata:o.providerMetadata,state:"streaming"};u.activeReasoningParts[o.id]=g,u.message.parts.push(g),d();break}case"reasoning-delta":{const g=u.activeReasoningParts[o.id];if(g==null)throw new kn({chunkType:"reasoning-delta",chunkId:o.id,message:`Received reasoning-delta for missing reasoning part with ID "${o.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});g.text+=o.delta,g.providerMetadata=(p=o.providerMetadata)!=null?p:g.providerMetadata,d();break}case"reasoning-end":{const g=u.activeReasoningParts[o.id];if(g==null)throw new kn({chunkType:"reasoning-end",chunkId:o.id,message:`Received reasoning-end for missing reasoning part with ID "${o.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});g.providerMetadata=(m=o.providerMetadata)!=null?m:g.providerMetadata,g.state="done",delete u.activeReasoningParts[o.id],d();break}case"file":{u.message.parts.push({type:"file",mediaType:o.mediaType,url:o.url,...o.providerMetadata!=null?{providerMetadata:o.providerMetadata}:{}}),d();break}case"source-url":{u.message.parts.push({type:"source-url",sourceId:o.sourceId,url:o.url,title:o.title,providerMetadata:o.providerMetadata}),d();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}),d();break}case"tool-input-start":{const g=u.message.parts.filter(Ys);u.partialToolCalls[o.toolCallId]={text:"",toolName:o.toolName,index:g.length,dynamic:o.dynamic,title:o.title},o.dynamic?b({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}),d();break}case"tool-input-delta":{const g=u.partialToolCalls[o.toolCallId];if(g==null)throw new kn({chunkType:"tool-input-delta",chunkId:o.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${o.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});g.text+=o.inputTextDelta;const{value:D}=await Nr(g.text);g.dynamic?b({toolCallId:o.toolCallId,toolName:g.toolName,state:"input-streaming",input:D,title:g.title}):S({toolCallId:o.toolCallId,toolName:g.toolName,state:"input-streaming",input:D,title:g.title}),d();break}case"tool-input-available":{o.dynamic?b({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}),d(),s&&!o.providerExecuted&&await s({toolCall:o});break}case"tool-input-error":{const g=u.message.parts.filter(mi).find(E=>E.toolCallId===o.toolCallId);(g!=null?g.type==="dynamic-tool":!!o.dynamic)?b({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}),d();break}case"tool-approval-request":{const g=w(o.toolCallId);g.state="approval-requested",g.approval={id:o.approvalId},d();break}case"tool-output-denied":{const g=w(o.toolCallId);g.state="output-denied",d();break}case"tool-output-available":{const g=w(o.toolCallId);g.type==="dynamic-tool"?b({toolCallId:o.toolCallId,toolName:g.toolName,state:"output-available",input:g.input,output:o.output,preliminary:o.preliminary,providerExecuted:o.providerExecuted,title:g.title}):S({toolCallId:o.toolCallId,toolName:Gl(g),state:"output-available",input:g.input,output:o.output,providerExecuted:o.providerExecuted,preliminary:o.preliminary,title:g.title}),d();break}case"tool-output-error":{const g=w(o.toolCallId);g.type==="dynamic-tool"?b({toolCallId:o.toolCallId,toolName:g.toolName,state:"output-error",input:g.input,errorText:o.errorText,providerExecuted:o.providerExecuted,title:g.title}):S({toolCallId:o.toolCallId,toolName:Gl(g),state:"output-error",input:g.input,rawInput:g.rawInput,errorText:o.errorText,providerExecuted:o.providerExecuted,title:g.title}),d();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)&&d();break}case"finish":{o.finishReason!=null&&(u.finishReason=o.finishReason),await _(o.messageMetadata),o.messageMetadata!=null&&d();break}case"message-metadata":{await _(o.messageMetadata),o.messageMetadata!=null&&d();break}case"error":{i==null||i(new Error(o.errorText));break}default:if(wC(o)){if((n==null?void 0:n[o.type])!=null){const E=u.message.parts.findIndex(N=>"id"in N&&"data"in N&&N.id===o.id&&N.type===o.type),k=E>=0?E:u.message.parts.length;await Hl({value:o.data,schema:n[o.type],context:{field:`message.parts[${k}].data`,entityName:o.type,entityId:o.id}})}const g=o;if(g.transient){a==null||a(g);break}const D=g.id!=null?u.message.parts.find(E=>g.type===E.type&&g.id===E.id):void 0;D!=null?D.data=g.data:u.message.parts.push(g),a==null||a(g),d()}}l.enqueue(o)})}}))}async function jC({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()}}jr({prefix:"aitxt",size:24});jr({prefix:"aiobj",size:24});var NC=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()})}};jr({prefix:"aiobj",size:24});async function CC(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 EC=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 Jt(this.body),l=await Jt(this.headers),u=await Jt(this.credentials),d={...ln(l),...ln(t.headers)},f=await((n=this.prepareSendMessagesRequest)==null?void 0:n.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...o,...t.body},headers:d,credentials:u,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId})),h=(r=f==null?void 0:f.api)!=null?r:this.api,p=(f==null?void 0:f.headers)!==void 0?ln(f.headers):d,m=(f==null?void 0:f.body)!==void 0?f.body:{...o,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId},w=(i=f==null?void 0:f.credentials)!=null?i:u,b=await((s=this.fetch)!=null?s:globalThis.fetch)(h,{method:"POST",headers:Bl({"Content-Type":"application/json",...p},`ai-sdk/${Wl}`,Vl()),body:JSON.stringify(m),credentials:w,signal:e});if(!b.ok)throw new Error((a=await b.text())!=null?a:"Failed to fetch the chat response.");if(!b.body)throw new Error("The response body is empty.");return this.processResponseStream(b.body)}async reconnectToStream(e){var t,n,r,i,s;const a=await Jt(this.body),o=await Jt(this.headers),l=await Jt(this.credentials),u={...ln(o),...ln(e.headers)},d=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})),f=(n=d==null?void 0:d.api)!=null?n:`${this.api}/${e.chatId}/stream`,h=(d==null?void 0:d.headers)!==void 0?ln(d.headers):u,p=(r=d==null?void 0:d.credentials)!=null?r:l,w=await((i=this.fetch)!=null?i:globalThis.fetch)(f,{method:"GET",headers:Bl(h,`ai-sdk/${Wl}`,Vl()),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)}},Cp=class extends EC{constructor(e={}){super(e)}processResponseStream(e){return XN({stream:e,schema:vC}).pipeThrough(new TransformStream({async transform(t,n){if(!t.success)throw t.error;n.enqueue(t.value)}}))}},IC=class{constructor({generateId:e=tN,id:t=e(),transport:n=new Cp,messageMetadataSchema:r,dataPartSchemas:i,state:s,onError:a,onToolCall:o,onFinish:l,onData:u,sendAutomaticallyWhen:d}){this.activeResponse=void 0,this.jobExecutor=new NC,this.sendMessage=async(f,h)=>{var p,m,w,S;if(f==null){await this.makeRequest({trigger:"submit-message",messageId:(p=this.lastMessage)==null?void 0:p.id,...h});return}let b;if("text"in f||"files"in f?b={parts:[...Array.isArray(f.files)?f.files:await CC(f.files),..."text"in f&&f.text!=null?[{type:"text",text:f.text}]:[]]}:b=f,f.messageId!=null){const _=this.state.messages.findIndex(g=>g.id===f.messageId);if(_===-1)throw new Error(`message with id ${f.messageId} not found`);if(this.state.messages[_].role!=="user")throw new Error(`message with id ${f.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,_+1),this.state.replaceMessage(_,{...b,id:f.messageId,role:(m=b.role)!=null?m:"user",metadata:f.metadata})}else this.state.pushMessage({...b,id:(w=b.id)!=null?w:this.generateId(),role:(S=b.role)!=null?S:"user",metadata:f.metadata});await this.makeRequest({trigger:"submit-message",messageId:f.messageId,...h})},this.regenerate=async({messageId:f,...h}={})=>{const p=f==null?this.state.messages.length-1:this.state.messages.findIndex(m=>m.id===f);if(p===-1)throw new Error(`message ${f} 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:f,...h})},this.resumeStream=async(f={})=>{await this.makeRequest({trigger:"resume-stream",...f})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:f,approved:h,reason:p})=>this.jobExecutor.run(async()=>{const m=this.state.messages,w=m[m.length-1],S=b=>mi(b)&&b.state==="approval-requested"&&b.approval.id===f?{...b,state:"approval-responded",approval:{id:f,approved:h,reason:p}}:b;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(b=>{var _;b&&this.makeRequest({trigger:"submit-message",messageId:(_=this.lastMessage)==null?void 0:_.id})})}),this.addToolOutput=async({state:f="output-available",tool:h,toolCallId:p,output:m,errorText:w})=>this.jobExecutor.run(async()=>{const S=this.state.messages,b=S[S.length-1],_=g=>mi(g)&&g.toolCallId===p?{...g,state:f,output:m,errorText:w}:g;this.state.replaceMessage(S.length-1,{...b,parts:b.parts.map(_)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(_)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(g=>{var D;g&&this.makeRequest({trigger:"submit-message",messageId:(D=this.lastMessage)==null?void 0:D.id})})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var f;this.status!=="streaming"&&this.status!=="submitted"||(f=this.activeResponse)!=null&&f.abortController&&this.activeResponse.abortController.abort()},this.id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=r,this.dataPartSchemas=i,this.state=s,this.onError=a,this.onToolCall=o,this.onFinish=l,this.onData=u,this.sendAutomaticallyWhen=d}get status(){return this.state.status}setStatus({status:e,error:t}){this.status!==e&&(this.state.status=e,this.state.error=t)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(e){this.state.messages=e}async shouldSendAutomatically(){if(!this.sendAutomaticallyWhen)return!1;const e=this.sendAutomaticallyWhen({messages:this.state.messages});return e&&typeof e=="object"&&"then"in e?await e:e}async makeRequest({trigger:e,metadata:t,headers:n,body:r,messageId:i}){var s,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 d=!1,f=!1,h=!1;try{const p={state:_C({lastMessage:this.state.snapshot(u),messageId:this.generateId()}),abortController:new AbortController};p.abortController.signal.addEventListener("abort",()=>{d=!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 b;this.setStatus({status:"streaming"}),p.state.message.id===((b=this.lastMessage)==null?void 0:b.id)?this.state.replaceMessage(this.state.messages.length-1,p.state.message):this.state.pushMessage(p.state.message)}}));await jC({stream:SC({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(d||p.name==="AbortError")return d=!0,this.setStatus({status:"ready"}),null;h=!0,p instanceof TypeError&&(p.message.toLowerCase().includes("fetch")||p.message.toLowerCase().includes("network"))&&(f=!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:d,isDisconnect:f,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})}},xs,Kl;function TC(){if(Kl)return xs;Kl=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 xs=e,xs}var AC=TC();const zC=ra(AC);var Ep=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Me=(e,t,n)=>(Ep(e,t,"read from private field"),n?n.call(e):t.get(e)),Et=(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)},Ut=(e,t,n,r)=>(Ep(e,t,"write to private field"),t.set(e,n),n);function OC(e,t){return t!=null?zC(e,t):e}var xt,Jr,qr,Qn,er,tr,jn,Xs,Qs,PC=class{constructor(e=[]){Et(this,xt,void 0),Et(this,Jr,"ready"),Et(this,qr,void 0),Et(this,Qn,new Set),Et(this,er,new Set),Et(this,tr,new Set),this.pushMessage=t=>{Ut(this,xt,Me(this,xt).concat(t)),Me(this,jn).call(this)},this.popMessage=()=>{Ut(this,xt,Me(this,xt).slice(0,-1)),Me(this,jn).call(this)},this.replaceMessage=(t,n)=>{Ut(this,xt,[...Me(this,xt).slice(0,t),this.snapshot(n),...Me(this,xt).slice(t+1)]),Me(this,jn).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,n)=>{const r=n?OC(t,n):t;return Me(this,Qn).add(r),()=>{Me(this,Qn).delete(r)}},this["~registerStatusCallback"]=t=>(Me(this,er).add(t),()=>{Me(this,er).delete(t)}),this["~registerErrorCallback"]=t=>(Me(this,tr).add(t),()=>{Me(this,tr).delete(t)}),Et(this,jn,()=>{Me(this,Qn).forEach(t=>t())}),Et(this,Xs,()=>{Me(this,er).forEach(t=>t())}),Et(this,Qs,()=>{Me(this,tr).forEach(t=>t())}),Ut(this,xt,e)}get status(){return Me(this,Jr)}set status(e){Ut(this,Jr,e),Me(this,Xs).call(this)}get error(){return Me(this,qr)}set error(e){Ut(this,qr,e),Me(this,Qs).call(this)}get messages(){return Me(this,xt)}set messages(e){Ut(this,xt,[...e]),Me(this,jn).call(this)}};xt=new WeakMap;Jr=new WeakMap;qr=new WeakMap;Qn=new WeakMap;er=new WeakMap;tr=new WeakMap;jn=new WeakMap;Xs=new WeakMap;Qs=new WeakMap;var Nn,Yl=class extends IC{constructor({messages:e,...t}){const n=new PC(e);super({...t,state:n}),Et(this,Nn,void 0),this["~registerMessagesCallback"]=(r,i)=>Me(this,Nn)["~registerMessagesCallback"](r,i),this["~registerStatusCallback"]=r=>Me(this,Nn)["~registerStatusCallback"](r),this["~registerErrorCallback"]=r=>Me(this,Nn)["~registerErrorCallback"](r),Ut(this,Nn,n)}};Nn=new WeakMap;function DC({experimental_throttle:e,resume:t=!1,...n}={}){const r=x.useRef("chat"in n?{}:{onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});"chat"in n||(r.current={onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});const i={...n,onToolCall: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=x.useRef("chat"in n?n.chat:new Yl(i));("chat"in n&&n.chat!==s.current||"id"in n&&s.current.id!==n.id)&&(s.current="chat"in n?n.chat:new Yl(i));const o=x.useCallback(h=>s.current["~registerMessagesCallback"](h,e),[e,s.current.id]),l=x.useSyncExternalStore(o,()=>s.current.messages,()=>s.current.messages),u=x.useSyncExternalStore(s.current["~registerStatusCallback"],()=>s.current.status,()=>s.current.status),d=x.useSyncExternalStore(s.current["~registerErrorCallback"],()=>s.current.error,()=>s.current.error),f=x.useCallback(h=>{typeof h=="function"&&(h=h(s.current.messages)),s.current.messages=h},[s]);return x.useEffect(()=>{t&&s.current.resumeStream()},[t,s]),{id:s.current.id,messages:l,setMessages:f,sendMessage:s.current.sendMessage,regenerate:s.current.regenerate,clearError:s.current.clearError,stop:s.current.stop,error:d,resumeStream:s.current.resumeStream,status:u,addToolResult:s.current.addToolOutput,addToolOutput:s.current.addToolOutput,addToolApprovalResponse:s.current.addToolApprovalResponse}}function Ip(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 Tp(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 Ap(e,t,n){if(!(n!=null&&n.selectedText)){const i=RC(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 f=VC(e,n.startLine);l=BC(e,i,f)}else l=s;const u=e.slice(0,l),d=e.slice(l+i.length);return{original:e,modified:u+t+d}}if(n.startLine&&n.endLine){const o=LC(e,t,n.startLine,n.endLine);if(o)return o}const a=Xl(e,t);return a||{original:e,modified:t}}const r=Xl(e,t);return r||{original:e,modified:t}}function RC(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(!ea(i,r,n))return null;const o=JSON.stringify(i,null,a);return{original:e,modified:o}}function ea(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(ea(i,t,n))return!0}return!1}if(e&&typeof e=="object"){for(const r of Object.values(e))if(ea(r,t,n))return!0}return!1}function Xl(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=MC(t);if(n.length===0)return null;let r=e,i=!1;for(const s of n){const a=FC(r,t,s);a&&(r=a,i=!0)}return i?{original:e,modified:r}:null}function MC(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 FC(e,t,n){const r=`"${n}"`,i=Ql(e,r);if(i.length===0)return null;const s=Ql(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 d=-1;for(let f=0;f<i.length;f++){const h=e.slice(i[f].start,i[f].end),p=ZC(h,o);p>d&&(d=p,l=f)}}const u=i[l];return e.slice(0,u.start)+o+e.slice(u.end)}function Ql(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=$C(e,l);if(u===-1){r=i+1;continue}n.push({start:i,end:u}),r=u}return n}function $C(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 LC(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 ZC(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 VC(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 BC(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 UC(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 JC(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=Ip(r.props.templates||[],i.templates);else return null;return{original:e,modified:JSON.stringify(r,null,2)}}catch{return null}}function qC(){const e=Ce(H=>H.threads),t=Ce(H=>H.activeThreadId),n=Ce(H=>H.updateThreadMessages),r=Ce(H=>H.updateThreadTitle),i=Ce(H=>H.clearContext),s=Ce(H=>H.contextAttachments),a=Ce(H=>H.scope),o=Ce(H=>H.model),l=qe(H=>H.activeTab),u=qe(H=>H.documents),d=qe(H=>H.documentTypes),f=qe(H=>H.setPendingDiff),h=qe(H=>H.createDocument),p=qe(H=>H.openDocument),m=x.useRef(e);m.current=e;const w=x.useRef(l);w.current=l;const S=x.useRef(u);S.current=u;const b=x.useRef(d);b.current=d;const _=x.useRef(t);_.current=t;const g=l?t[l]:void 0,D=x.useRef(g);D.current=g;const E=x.useRef([]),k=x.useRef([]),N=x.useRef({}),F=x.useRef({}),[,K]=x.useState(0),C=x.useCallback(()=>K(H=>H+1),[]),q=x.useRef(null);q.current||(q.current=new Cp({api:"/api/ai/chat"}));const $=x.useCallback(()=>{const H=S.current.find(z=>z.name===w.current);return H?{name:H.name,text:H.text}:void 0},[]),V=x.useCallback(H=>N.current[H]||[],[]),Z=DC({transport:q.current,onError:()=>{E.current.shift(),k.current.shift(),i()},onFinish:({messages:H})=>{var se,be;const z=D.current;if(z){n(z,H);const fe=m.current[z];if(fe&&fe.title.startsWith("Chat ")){const M=H.find(B=>B.role==="user");if(M){const B=((se=M.parts)==null?void 0:se.filter(ee=>ee.type==="text").map(ee=>ee.text).join(""))||"";if(B){const ee=B.length>50?B.slice(0,50)+"...":B;r(z,ee)}}}}const J=E.current.shift()||[],y=k.current.shift()||"global",ue=H.filter(fe=>fe.role==="user"),re=ue[ue.length-1];re!=null&&re.id&&(N.current[re.id]=J,F.current[re.id]=y);const v=H.filter(fe=>fe.role==="assistant").pop();if(v){const M=[...(((be=v.parts)==null?void 0:be.filter(B=>B.type==="text").map(B=>B.text).join(""))||"").matchAll(/```(?:json|jsonc)\s*\n([\s\S]*?)```/g)];if(M.length>0){const B=UC(M);if(B){const ee=M[M.length-1][1],pe=w.current;if(pe){const ge=S.current.find(Mt=>Mt.name===pe),Xe=(ge==null?void 0:ge.text)||"",nt=J[0],Ie=JC(Xe,B,y);!Ie&&y!=="global"&&console.warn(`[chat] scopedMerge failed for scope="${y}", falling back to text merge`);const{original:Rt,modified:nn}=Ie??Ap(Xe,B,nt);f(pe,Rt,nn,Tp(ee.replace(/\n$/,"")))}else{const ge=`ai-generated-${Date.now()}`;h(ge,B),p(ge)}}}}i()}});x.useEffect(()=>{const H=Z.messages.filter(z=>z.role==="user");for(let z=H.length-1;z>=0;z--){const J=H[z].id;if(J in N.current)break;E.current.length>0&&(N.current[J]=E.current[0],F.current[J]=k.current[0]||"global",C());break}},[Z.messages,C]);const O=x.useCallback((H,z)=>{E.current.push([...s]),k.current.push(a),i();const J={text:H};z!=null&&z.length&&(J.files=z),Z.sendMessage(J,{body:{format:vt,context:s,activeDocument:$(),documentType:w.current&&b.current[w.current]||"application/json+report",scope:a,model:o}})},[Z.sendMessage,s,$,i,a,o]),Y=x.useCallback(H=>F.current[H],[]);return{messages:Z.messages,sendMessage:O,status:Z.status,error:Z.error,setMessages:Z.setMessages,stop:Z.stop,getMessageContext:V,getMessageScope:Y}}const zp=x.createContext(null);function eu({children:e}){const t=qC();return c.jsx(zp.Provider,{value:t,children:e})}function HC(){const e=x.useContext(zp);if(!e)throw new Error("useChatSessionContext must be used within ChatSessionProvider");return e}function WC(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 GC(e,t=50){const n=e.replace(/[\n\r]+/g," ").replace(/\s+/g," ").trim();return n.length>t?n.slice(0,t)+"…":n}function Op({context:e,onRemove:t,variant:n="default"}){var u;const r=WC(e),i=((u=e.documentName)==null?void 0:u.replace(/\.json$/,""))??"",s=i?`${i} › ${r}`:r,a=GC(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(Mh,{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(dn,{className:"h-3 w-3"})})]});return c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:l}),c.jsxs(Ye,{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 _n extends Error{constructor(t,n){super(`${t} at position ${n}`),this.position=n}}const Pp=32,KC=10,Dp=9,Rp=13,YC=160,XC=6158,QC=8192,eE=8203,tE=8239,nE=8287,rE=12288,iE=65279;function sE(e){return/^[0-9A-Fa-f]$/.test(e)}function an(e){return e>="0"&&e<="9"}function aE(e){return e>=" "}function $r(e){return`,:[]/{}()
92
+ +`.includes(e)}function tu(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"}function nu(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"||e>="0"&&e<="9"}const ru=/^(http|https|ftp|mailto|file|data|irc):\/\/$/,iu=/^[A-Za-z0-9-._~:/?#@!$&'()*+;=]$/;function su(e){return`,[]/{}
93
+ +`.includes(e)}function au(e){return Hr(e)||oE.test(e)}const oE=/^[[{\w-]$/;function lE(e){return e===`
94
+ `||e==="\r"||e===" "||e==="\b"||e==="\f"}function un(e,t){const n=e.charCodeAt(t);return n===Pp||n===KC||n===Dp||n===Rp}function uE(e,t){const n=e.charCodeAt(t);return n===Pp||n===Dp||n===Rp}function cE(e,t){const n=e.charCodeAt(t);return n===YC||n===XC||n>=QC&&n<=eE||n===tE||n===nE||n===rE||n===iE}function Hr(e){return Mp(e)||ta(e)}function Mp(e){return e==='"'||e==="“"||e==="”"}function ou(e){return e==='"'}function ta(e){return e==="'"||e==="‘"||e==="’"||e==="`"||e==="´"}function lu(e){return e==="'"}function Wn(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 St(e,t){let n=e.length;if(!un(e,n-1))return e+t;for(;un(e,n-1);)n--;return e.substring(0,n)+t+e.substring(n)}function dE(e,t,n){return e.substring(0,t)+e.substring(t+n)}function fE(e){return/[,\n][ \t\r]*$/.test(e)}const pE={"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"},hE={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
95
+ `,r:"\r",t:" "};function uu(e){let t=0,n="";u(["```","[```","{```"]),s()||Z(),u(["```","```]","```}"]);const i=f(",");for(i&&a(),au(e[t])&&fE(n)?(i||(n=St(n,",")),b()):i&&(n=Wn(n,","));e[t]==="}"||e[t]==="]";)t++,a();if(t>=e.length)return n;V();function s(){a();const z=w()||S()||_()||D()||E()||N(!1)||F();return a(),z}function a(){let z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;const J=t;let y=o(z);do y=l(),y&&(y=o(z));while(y);return t>J}function o(z){const J=z?un:uE;let y="";for(;;)if(J(e,t))y+=e[t],t++;else if(cE(e,t))y+=" ",t++;else break;return y.length>0?(n+=y,!0):!1}function l(){if(e[t]==="/"&&e[t+1]==="*"){for(;t<e.length&&!mE(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(z){if(d(z)){if(tu(e[t]))for(;t<e.length&&nu(e[t]);)t++;return a(),!0}return!1}function d(z){o(!0);for(const J of z){const y=t+J.length;if(e.slice(t,y)===J)return t=y,!0}return!1}function f(z){return e[t]===z?(n+=e[t],t++,!0):!1}function h(z){return e[t]===z?(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 z=!0;for(;t<e.length&&e[t]!=="}";){let J;if(z?(J=!0,z=!1):(J=f(","),J||(n=St(n,",")),a()),m(),!(_()||N(!0))){e[t]==="}"||e[t]==="{"||e[t]==="]"||e[t]==="["||e[t]===void 0?n=Wn(n,","):O();break}a();const ue=f(":"),re=t>=e.length;ue||(au(e[t])||re?n=St(n,":"):Y()),s()||(ue||re?n+="null":Y())}return e[t]==="}"?(n+="}",t++):n=St(n,"}"),!0}return!1}function S(){if(e[t]==="["){n+="[",t++,a(),h(",")&&a();let z=!0;for(;t<e.length&&e[t]!=="]";)if(z?z=!1:f(",")||(n=St(n,",")),m(),!s()){n=Wn(n,",");break}return e[t]==="]"?(n+="]",t++):n=St(n,"]"),!0}return!1}function b(){let z=!0,J=!0;for(;J;)z?z=!1:f(",")||(n=St(n,",")),J=s();J||(n=Wn(n,",")),n=`[
97
+ ${n}
98
+ ]`}function _(){let z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,J=arguments.length>1&&arguments[1]!==void 0?arguments[1]:-1,y=e[t]==="\\";if(y&&(t++,y=!0),Hr(e[t])){const ue=ou(e[t])?ou:lu(e[t])?lu:ta(e[t])?ta:Mp,re=t,v=n.length;let se='"';for(t++;;){if(t>=e.length){const be=K(t-1);return!z&&$r(e.charAt(be))?(t=re,n=n.substring(0,v),_(!0)):(se=St(se,'"'),n+=se,!0)}if(t===J)return se=St(se,'"'),n+=se,!0;if(ue(e[t])){const be=t,fe=se.length;if(se+='"',t++,n+=se,a(!1),z||t>=e.length||$r(e[t])||Hr(e[t])||an(e[t]))return g(),!0;const M=K(be-1),B=e.charAt(M);if(B===",")return t=re,n=n.substring(0,v),_(!1,M);if($r(B))return t=re,n=n.substring(0,v),_(!0);n=n.substring(0,v),t=be+1,se=`${se.substring(0,fe)}\\${se.substring(fe)}`}else if(z&&su(e[t])){if(e[t-1]===":"&&ru.test(e.substring(re+1,t+2)))for(;t<e.length&&iu.test(e[t]);)se+=e[t],t++;return se=St(se,'"'),n+=se,g(),!0}else if(e[t]==="\\"){const be=e.charAt(t+1);if(hE[be]!==void 0)se+=e.slice(t,t+2),t+=2;else if(be==="u"){let M=2;for(;M<6&&sE(e[t+M]);)M++;M===6?(se+=e.slice(t,t+6),t+=6):t+M>=e.length?t=e.length:H()}else se+=be,t+=2}else{const be=e.charAt(t);be==='"'&&e[t-1]!=="\\"?(se+=`\\${be}`,t++):lE(be)?(se+=pE[be],t++):(aE(be)||$(be),se+=be,t++)}y&&p()}}return!1}function g(){let z=!1;for(a();e[t]==="+";){z=!0,t++,a(),n=Wn(n,'"',!0);const J=n.length;_()?n=dE(n,J,1):n=St(n,'"')}return z}function D(){const z=t;if(e[t]==="-"){if(t++,C())return q(z),!0;if(!an(e[t]))return t=z,!1}for(;an(e[t]);)t++;if(e[t]==="."){if(t++,C())return q(z),!0;if(!an(e[t]))return t=z,!1;for(;an(e[t]);)t++}if(e[t]==="e"||e[t]==="E"){if(t++,(e[t]==="-"||e[t]==="+")&&t++,C())return q(z),!0;if(!an(e[t]))return t=z,!1;for(;an(e[t]);)t++}if(!C())return t=z,!1;if(t>z){const J=e.slice(z,t),y=/^0\d/.test(J);return n+=y?`"${J}"`:J,!0}return!1}function E(){return k("true","true")||k("false","false")||k("null","null")||k("True","true")||k("False","false")||k("None","null")}function k(z,J){return e.slice(t,t+z.length)===z?(n+=J,t+=z.length,!0):!1}function N(z){const J=t;if(tu(e[t])){for(;t<e.length&&nu(e[t]);)t++;let y=t;for(;un(e,y);)y++;if(e[y]==="(")return t=y+1,s(),e[t]===")"&&(t++,e[t]===";"&&t++),!0}for(;t<e.length&&!su(e[t])&&!Hr(e[t])&&(!z||e[t]!==":");)t++;if(e[t-1]===":"&&ru.test(e.substring(J,t+2)))for(;t<e.length&&iu.test(e[t]);)t++;if(t>J){for(;un(e,t-1)&&t>0;)t--;const y=e.slice(J,t);return n+=y==="undefined"?"null":JSON.stringify(y),e[t]==='"'&&t++,!0}}function F(){if(e[t]==="/"){const z=t;for(t++;t<e.length&&(e[t]!=="/"||e[t-1]==="\\");)t++;return t++,n+=JSON.stringify(e.substring(z,t)),!0}}function K(z){let J=z;for(;J>0&&un(e,J);)J--;return J}function C(){return t>=e.length||$r(e[t])||un(e,t)}function q(z){n+=`${e.slice(z,t)}0`}function $(z){throw new _n(`Invalid character ${JSON.stringify(z)}`,t)}function V(){throw new _n(`Unexpected character ${JSON.stringify(e[t])}`,t)}function Z(){throw new _n("Unexpected end of json string",e.length)}function O(){throw new _n("Object key expected",t)}function Y(){throw new _n("Colon expected",t)}function H(){const z=e.slice(t,t+6);throw new _n(`Invalid unicode character "${z}"`,t)}}function mE(e,t){return e[t]==="*"&&e[t+1]==="/"}function gE({json:e,context:t,scope:n}){const[r,i]=x.useState(!1),[s,a]=x.useState(null),o=x.useMemo(()=>{try{return JSON.parse(e),e}catch{}try{return uu(e)}catch{}const b=`{${e}}`;try{return JSON.parse(b),b}catch{}try{return uu(b)}catch{return null}},[e]),l=x.useMemo(()=>Tp(o||e),[o,e]),u=qe(b=>b.activeTab),d=qe(b=>b.documents),f=qe(b=>(b.acceptedApplyIds||[]).includes(l)),h=qe(b=>b.setPendingDiff),p=qe(b=>b.createDocument),m=qe(b=>b.openDocument),w=x.useCallback(()=>{if(o){a(null);try{if(u){const b=d.find(k=>k.name===u),_=(b==null?void 0:b.text)||"";if(n==="templates")try{const k=JSON.parse(_),N=JSON.parse(o);if(Array.isArray(N.templates)){k.props||(k.props={}),k.props.templates=Ip(k.props.templates||[],N.templates);const F=JSON.stringify(k,null,2);h(u,_,F,l);return}}catch{}const g=t==null?void 0:t[0],{original:D,modified:E}=Ap(_,o,g);h(u,D,E,l)}else{const b=`ai-generated-${Date.now()}`;p(b,o),m(b)}}catch(b){a(b instanceof Error?b.message:"Merge failed")}}},[o,u,d,h,p,m,t,n,l]),S=x.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(Ne,{variant:"secondary",size:"sm",onClick:w,disabled:f||!o,children:f?"Applied":o?"Apply to Editor":"Invalid JSON"}),c.jsx(Ne,{variant:"ghost",size:"sm",onClick:S,children:r?c.jsx(fn,{className:"h-3.5 w-3.5"}):c.jsx(sa,{className:"h-3.5 w-3.5"})})]}),s&&c.jsx("p",{className:"text-xs text-destructive m-0",children:s})]})}function xE({threads:e,activeThread:t,disabled:n,onSwitch:r,onCreate:i,onDelete:s,onRename:a}){const[o,l]=x.useState(null),[u,d]=x.useState(""),[f,h]=x.useState(null),p=x.useRef(null),m=(t==null?void 0:t.title)||"New Chat",w=m.length>24?m.slice(0,24)+"...":m;x.useEffect(()=>{o&&requestAnimationFrame(()=>{var N;return(N=p.current)==null?void 0:N.focus()})},[o]);const S=x.useCallback((N,F)=>{F.stopPropagation(),F.preventDefault(),l(N.id),d(N.title),h(null)},[]),b=x.useCallback(()=>{o&&u.trim()&&a(o,u.trim()),l(null),d("")},[o,u,a]),_=x.useCallback(()=>{l(null),d("")},[]),g=x.useCallback(N=>{N.stopPropagation(),N.key==="Enter"?(N.preventDefault(),b()):N.key==="Escape"&&(N.preventDefault(),_())},[b,_]),D=x.useCallback((N,F)=>{F.stopPropagation(),F.preventDefault(),h(N),l(null)},[]),E=x.useCallback(N=>{N.stopPropagation(),N.preventDefault(),f&&(s(f),h(null))},[f,s]),k=x.useCallback(N=>{N.stopPropagation(),N.preventDefault(),h(null)},[]);return c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsxs(Jc,{onOpenChange:N=>{N||(l(null),h(null))},children:[c.jsx(qc,{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(Gt,{className:"h-3 w-3 shrink-0 opacity-60"})]})}),c.jsxs(ba,{align:"start",className:"w-64",children:[e.map(N=>{const F=o===N.id;return f===N.id?c.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 text-sm",children:[c.jsx("span",{className:"text-red-400 text-xs flex-1 truncate",children:"Delete this thread?"}),c.jsx("button",{className:"shrink-0 text-red-400 hover:text-red-300 transition-colors cursor-pointer",onClick:E,children:c.jsx(fn,{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(dn,{className:"h-3.5 w-3.5"})})]},N.id):F?c.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1",onClick:C=>C.stopPropagation(),onPointerDown:C=>C.stopPropagation(),children:[c.jsx("input",{ref:p,type:"text",value:u,onChange:C=>d(C.target.value),onKeyDown:g,onBlur:b,className:"flex-1 min-w-0 text-sm rounded border border-border bg-background px-1.5 py-0.5 outline-none focus:ring-1 focus:ring-primary/40"}),c.jsx("button",{className:"shrink-0 text-primary hover:text-primary/80 transition-colors cursor-pointer",onMouseDown:C=>{C.preventDefault(),b()},children:c.jsx(fn,{className:"h-3.5 w-3.5"})}),c.jsx("button",{className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onMouseDown:C=>{C.preventDefault(),_()},children:c.jsx(dn,{className:"h-3.5 w-3.5"})})]},N.id):c.jsxs(Wt,{onSelect:()=>r(N.id),className:`group ${N.id===(t==null?void 0:t.id)?"bg-accent":""}`,children:[c.jsx("span",{className:"truncate flex-1",children:N.title.length>30?N.title.slice(0,30)+"...":N.title}),c.jsxs("div",{className:"ml-auto shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[c.jsx("button",{className:"text-muted-foreground hover:text-foreground transition-colors p-0.5 cursor-pointer",onClick:C=>S(N,C),children:c.jsx(Fh,{className:"h-3 w-3"})}),e.length>1&&c.jsx("button",{className:"text-muted-foreground hover:text-destructive transition-colors p-0.5 cursor-pointer",onClick:C=>D(N.id,C),children:c.jsx(aa,{className:"h-3 w-3"})})]})]},N.id)}),c.jsx(ni,{}),c.jsxs(Wt,{onSelect:N=>{N.preventDefault();const F=i();F&&(l(F),d(ga()),h(null))},children:[c.jsx(Wr,{className:"h-3.5 w-3.5 mr-1.5"}),"New Chat"]})]})]}),c.jsx(Ne,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-foreground",onClick:()=>i(),disabled:n,title:"New chat thread",children:c.jsx(Wr,{className:"h-3.5 w-3.5"})})]})}const Fp=new Set(["image/png","image/jpeg","image/gif","image/webp","application/pdf","text/plain","text/markdown","text/csv","text/html"]),yE=Array.from(Fp).join(","),bE=20*1024*1024,cu=10;function vE(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 du(e){return Array.from(e).filter(t=>Fp.has(t.type)&&t.size<=bE)}function $p(e){return e.startsWith("image/")}function fu(){var U,oe,ye;const e=Ce(T=>T.contextAttachments),t=Ce(T=>T.addContext),n=Ce(T=>T.removeContext),r=Ce(T=>T.scope),i=Ce(T=>T.setScope),s=Ce(T=>T.model),a=Ce(T=>T.setModel),o=Ce(T=>T.openChat),l=Ce(T=>T.closeChat),u=Ce(T=>T.threads),d=Ce(T=>T.activeThreadId),f=Ce(T=>T.createThread),h=Ce(T=>T.deleteThread),p=Ce(T=>T.switchThread),m=Ce(T=>T.updateThreadMessages),w=Ce(T=>T.updateThreadTitle),S=Ce(T=>T.deleteThreadsForDocument),b=qe(T=>T.activeTab),_=qe(T=>T.documents),{messages:g,sendMessage:D,status:E,error:k,setMessages:N,stop:F,getMessageContext:K,getMessageScope:C}=HC(),[q,$]=x.useState(""),[V,Z]=x.useState([]),[O,Y]=x.useState(!1),[H,z]=x.useState(!1),J=x.useRef(null),y=x.useRef(null),ue=x.useRef(null),re=x.useCallback(async T=>{const le=du(T);if(le.length===0)return;const we=await Promise.all(le.map(vE));Z(Oe=>{const He=[...Oe,...we];return He.length>cu?He.slice(0,cu):He})},[]),v=x.useCallback(T=>{Z(le=>le.filter((we,Oe)=>Oe!==T))},[]),se=x.useCallback(T=>{var we;const le=(we=T.clipboardData)==null?void 0:we.files;if(le&&le.length>0){const Oe=du(le);Oe.length>0&&(T.preventDefault(),re(Oe))}},[re]),be=x.useCallback(T=>{var we;T.preventDefault(),z(!1);const le=(we=T.dataTransfer)==null?void 0:we.files;le&&le.length>0&&re(Array.from(le))},[re]),fe=x.useCallback(T=>{T.preventDefault(),z(!0)},[]),M=x.useCallback(()=>z(!1),[]),B=b?d[b]:void 0,ee=B?u[B]:void 0,pe=x.useMemo(()=>b?Object.values(u).filter(T=>T.documentName===b).sort((T,le)=>le.updatedAt-T.updatedAt):[],[u,b]);x.useEffect(()=>{b&&pe.length===0&&f(b)},[b,pe.length,f]);const ge=x.useRef(u);ge.current=u,x.useEffect(()=>{const T=new Set(_.map(we=>we.name)),le=new Set;for(const we of Object.values(ge.current))!T.has(we.documentName)&&we.documentName!=="__migrated__"&&le.add(we.documentName);for(const we of le)S(we)},[_,S]);const Xe=x.useRef(null);x.useEffect(()=>{Xe.current!==B&&(Xe.current=B,N((ee==null?void 0:ee.messages)??[]))},[B,ee,N]),x.useEffect(()=>{var T;(T=J.current)==null||T.scrollIntoView({behavior:"smooth"})},[g,E]),x.useEffect(()=>{const T=le=>{var He;const{documentName:we,selection:Oe}=le.detail;t({...Oe,documentName:we}),o(),(He=y.current)==null||He.focus()};return window.addEventListener("monaco-selection-to-ai",T),()=>window.removeEventListener("monaco-selection-to-ai",T)},[t,o]);const nt=E==="streaming",Ie=E==="submitted"||nt,Rt=x.useCallback(T=>{T.preventDefault(),!(!q.trim()&&V.length===0||Ie)&&(D(q,V.length>0?V:void 0),$(""),Z([]))},[q,V,Ie,D]),nn=x.useCallback(T=>{T.key==="Enter"&&!T.shiftKey&&(T.preventDefault(),Rt(T))},[Rt]),Mt=x.useCallback(()=>{g.length!==0&&Y(!0)},[g.length]),j=x.useCallback(()=>{Y(!1),N([]),B&&(m(B,[]),w(B,ga()))},[N,B,m,w]),[I,P]=x.useState(null),ne=x.useCallback(T=>{P(T)},[]),X=x.useCallback(()=>{var He,Ue;if(!I)return;const T=g.findIndex(Qe=>Qe.id===I);if(T===-1){P(null);return}const le=g[T],we=new Set([T]);le.role==="user"&&((He=g[T+1])==null?void 0:He.role)==="assistant"?we.add(T+1):le.role==="assistant"&&T>0&&((Ue=g[T-1])==null?void 0:Ue.role)==="user"&&we.add(T-1);const Oe=g.filter((Qe,Vt)=>!we.has(Vt));N(Oe),B&&m(B,Oe),P(null)},[I,g,N,B,m]),G=x.useCallback(T=>{if(!Ie){if(pe.length<=1){Mt();return}h(T)}},[Ie,pe.length,Mt,h]),ae=x.useCallback(()=>{if(!(!b||Ie))return f(b)},[b,Ie,f]),me=x.useCallback(T=>{Ie||T===B||p(T)},[Ie,B,p]),A=x.useCallback((T,le)=>{w(T,le)},[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(xE,{threads:pe,activeThread:ee,disabled:Ie,onSwitch:me,onCreate:ae,onDelete:G,onRename:A}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(Ne,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:Mt,disabled:Ie||g.length===0,children:"Clear"}),c.jsx(Ne,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:l,title:"Close chat",children:c.jsx(dn,{className:"h-3.5 w-3.5"})})]})]}),c.jsx(dr,{className:"flex-1 min-h-0 [&_[data-radix-scroll-area-viewport]>div]:!block",children:c.jsxs("div",{className:"p-3 space-y-4 min-w-0",children:[g.length===0&&c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-4",children:[c.jsx("div",{className:"rounded-xl bg-primary/10 p-3 mb-4",children:c.jsx(Xa,{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(Os,{shortcut:"mod+k"}),c.jsx("span",{className:"text-xs text-muted-foreground",children:"to send a selection"})]})]}),g.map((T,le)=>{let we;if(T.role==="user"){const Ue=K(T.id);Ue&&Ue.length>0&&(we=Ue)}else if(T.role==="assistant"){for(let Ue=le-1;Ue>=0;Ue--)if(g[Ue].role==="user"){we=K(g[Ue].id);break}}const Oe=nt&&le===g.length-1&&T.role==="assistant",He=T.role==="user"?C(T.id):void 0;return c.jsx(wE,{msg:T,isStreaming:Oe,context:we,scope:He,onDelete:Ie?void 0:ne},T.id)}),Ie&&((U=g[g.length-1])==null?void 0:U.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($h,{className:"h-3.5 w-3.5 animate-spin text-primary"}),c.jsx("span",{children:"Thinking..."})]})})}),k&&!Ie&&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:J})]})}),c.jsxs("div",{className:`border-t border-border/60 p-2.5 space-y-2 bg-surface-chat transition-colors ${H?"ring-2 ring-primary/40 bg-primary/5":""}`,onDrop:be,onDragOver:fe,onDragLeave:M,children:[e.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.map((T,le)=>c.jsx(Op,{context:T,onRemove:()=>n(le)},le))}),c.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[c.jsx(SE,{model:s,setModel:a}),vt==="pptx"&&b&&c.jsx(NE,{scope:r,setScope:i,docSize:((ye=(oe=_.find(T=>T.name===b))==null?void 0:oe.text)==null?void 0:ye.length)??0})]}),V.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1.5",children:V.map((T,le)=>c.jsxs("div",{className:"relative group",children:[$p(T.mediaType)?c.jsx("img",{src:T.url,alt:T.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:T.filename||"file"})]}),c.jsx("button",{type:"button",onClick:()=>v(le),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(dn,{className:"h-3 w-3"})})]},le))}),c.jsxs("form",{onSubmit:Rt,className:"flex items-end gap-2",children:[c.jsx("input",{ref:ue,type:"file",accept:yE,multiple:!0,className:"hidden",onChange:T=>{T.target.files&&re(Array.from(T.target.files)),T.target.value=""}}),c.jsx(Ne,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 h-9 w-9 rounded-lg text-muted-foreground hover:text-foreground",onClick:()=>{var T;return(T=ue.current)==null?void 0:T.click()},title:"Attach file",children:c.jsx(ys,{className:"h-4 w-4"})}),c.jsx("textarea",{ref:y,value:q,onChange:T=>{$(T.target.value);const le=T.target;le.style.height="auto",le.style.height=`${Math.min(le.scrollHeight,128)}px`},onKeyDown:nn,onPaste:se,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}),Ie?c.jsx(Ne,{type:"button",size:"icon",variant:"destructive",className:"shrink-0 h-9 w-9 rounded-lg",onClick:F,title:"Stop generating",children:c.jsx(Lh,{className:"h-4 w-4"})}):c.jsx(Ne,{type:"submit",size:"icon",disabled:!q.trim()&&V.length===0,className:"shrink-0 h-9 w-9 rounded-lg",children:c.jsx(Xa,{className:"h-4 w-4"})})]})]}),c.jsx(Lt,{open:O,onOpenChange:Y,children:c.jsxs(Ot,{className:"max-w-sm",children:[c.jsxs(pn,{children:[c.jsx(hn,{children:"Clear thread"}),c.jsx(An,{children:"This will delete all messages in this thread. This action cannot be undone."})]}),c.jsxs(ur,{children:[c.jsx(uo,{asChild:!0,children:c.jsx(Ne,{variant:"ghost",size:"sm",children:"Cancel"})}),c.jsx(Ne,{variant:"destructive",size:"sm",onClick:j,children:"Clear"})]})]})}),c.jsx(Lt,{open:I!==null,onOpenChange:T=>{T||P(null)},children:c.jsxs(Ot,{className:"max-w-sm",children:[c.jsxs(pn,{children:[c.jsx(hn,{children:"Delete message"}),c.jsx(An,{children:"This will delete the message and its paired response. This action cannot be undone."})]}),c.jsxs(ur,{children:[c.jsx(uo,{asChild:!0,children:c.jsx(Ne,{variant:"ghost",size:"sm",children:"Cancel"})}),c.jsx(Ne,{variant:"destructive",size:"sm",onClick:X,children:"Delete"})]})]})})]})}const wE=x.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(d=>d.type==="text").map(d=>d.text).join(""))||"",o=((u=t.parts)==null?void 0:u.filter(d=>d.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((d,f)=>$p(d.mediaType)?c.jsx("img",{src:d.url,alt:d.filename||"image",className:"h-20 max-w-[160px] rounded object-cover"},f):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:d.filename||"file"})]},f))}),r&&r.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1 mb-1.5",children:r.map((d,f)=>c.jsx(Op,{context:d,variant:"sent"},f))}),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(kE,{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(aa,{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 kE({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(Kv,{remarkPlugins:[uk],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(CE,{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(gE,{json:l,context:n,scope:r})]})}},children:e})})}const _E=[{value:"opus",label:"Opus"},{value:"sonnet",label:"Sonnet"},{value:"haiku",label:"Haiku"}];function SE({model:e,setModel:t}){return c.jsxs(ha,{value:e,onValueChange:n=>t(n),children:[c.jsx(Si,{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(ma,{})}),c.jsx(ji,{children:_E.map(n=>c.jsx(cr,{value:n.value,className:"text-xs",children:n.label},n.value))})]})}const pu={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"},jE=1e5;function NE({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(pu).map(r=>c.jsxs(Ge,{children:[c.jsx(Ke,{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(Ye,{side:"top",className:"text-xs max-w-[200px]",children:pu[r]})]},r))})]}),e==="global"&&n>jE&&c.jsxs("div",{className:"text-[10px] text-amber-500 flex items-center gap-1",children:[c.jsx(nc,{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 CE({text:e}){const[t,n]=x.useState(!1),r=x.useCallback(async()=>{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)},[e]);return c.jsx("button",{onClick:r,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:t?"Copied!":"Copy"})}function EE({discoveryData:e}){const t=Pc(),n=Jm(),r=Ce(F=>F.chatOpen),i=Ce(F=>F.toggleChat),[s,a]=x.useState(()=>{try{const F=localStorage.getItem("dev-env.sidebar-open");return F?F==="true":!0}catch{return!0}}),[o,l]=x.useState(()=>{try{const F=localStorage.getItem("dev-env.preview-open");return F?F==="true":!0}catch{return!0}}),[u,d]=x.useState("editor"),[f,h]=x.useState(!1),p=120,[m,w]=x.useState(!s),[S,b]=x.useState(!1);x.useEffect(()=>{try{localStorage.setItem("dev-env.sidebar-open",String(s))}catch{}},[s]),x.useEffect(()=>{try{localStorage.setItem("dev-env.preview-open",String(o))}catch{}},[o]);const _=x.useRef(n);x.useEffect(()=>{n&&!_.current&&s&&(b(!0),setTimeout(()=>{a(!1),w(!0)},p)),!n&&_.current&&!s&&(b(!0),setTimeout(()=>{a(!0),w(!1)},p)),_.current=n},[n,s]);const g=x.useCallback(()=>{if(t){h(F=>!F);return}b(!0),setTimeout(()=>{a(F=>!F),w(F=>!F)},p)},[t]),D=x.useCallback(()=>l(F=>!F),[]),E=x.useRef(i),k=x.useRef(g),N=x.useRef(D);return x.useEffect(()=>{E.current=i}),x.useEffect(()=>{k.current=g}),x.useEffect(()=>{N.current=D}),x.useEffect(()=>{const F=K=>{(K.metaKey||K.ctrlKey)&&(K.code==="KeyB"&&!K.shiftKey&&(K.preventDefault(),k.current()),K.code==="KeyJ"&&K.shiftKey&&(K.preventDefault(),K.stopPropagation(),E.current()),K.code==="KeyP"&&K.shiftKey&&(K.preventDefault(),N.current()))};return window.addEventListener("keydown",F,!0),()=>window.removeEventListener("keydown",F,!0)},[]),t?c.jsx(eu,{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(zc,{open:f,onOpenChange:h,children:[c.jsx(Lm,{asChild:!0,children:c.jsx(Ne,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:c.jsx(ec,{className:"h-4 w-4"})})}),c.jsx(xa,{side:"left",className:"p-0 w-72",children:c.jsx(po,{discoveryData:e,onToggleSidebar:()=>h(!1),isCollapsed:!1})})]}),c.jsx("div",{className:"flex gap-0.5 flex-1 min-w-0",children:[{key:"editor",icon:rc,label:"Editor"},{key:"preview",icon:ic,label:"Preview"},{key:"chat",icon:sc,label:"Chat"}].map(({key:F,icon:K,label:C})=>c.jsxs(Ne,{variant:u===F?"default":"ghost",size:"sm",className:"h-7 gap-1.5 text-xs flex-1",onClick:()=>d(F),children:[c.jsx(K,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"hidden xs:inline",children:C})]},F))})]}),u!=="chat"&&c.jsx(yo,{previewOpen:o,onTogglePreview:D}),c.jsxs("div",{className:"flex-1 min-h-0",children:[u==="editor"&&c.jsx("div",{className:"h-full bg-surface-editor",children:c.jsx(ho,{})}),u==="preview"&&c.jsx("div",{className:"h-full bg-surface-preview",children:c.jsx(mo,{})}),u==="chat"&&c.jsx(fu,{})]})]})}):c.jsx(eu,{children:c.jsxs("div",{className:"flex h-full w-full overflow-hidden",children:[c.jsx("div",{className:L("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:F=>{F.propertyName==="width"&&F.target===F.currentTarget&&b(!1)},children:c.jsx(po,{discoveryData:e,onToggleSidebar:g,isCollapsed:m,isAnimating:S})}),c.jsxs("div",{className:"flex-1 min-w-0 flex flex-col h-full",children:[c.jsx(yo,{previewOpen:o,onTogglePreview:D}),c.jsxs(Ag,{direction:"horizontal",autoSaveId:"layout-main",className:"flex-1 min-h-0",children:[c.jsx(Hi,{defaultSize:o?50:100,minSize:20,id:"editor",order:1,children:c.jsx("div",{className:"h-full bg-surface-editor",children:c.jsx(ho,{})})}),o&&c.jsxs(c.Fragment,{children:[c.jsx(go,{withHandle:!0}),c.jsx(Hi,{defaultSize:50,minSize:20,id:"preview",order:2,children:c.jsx("div",{className:"h-full bg-surface-preview",children:c.jsx(mo,{})})})]}),r&&c.jsxs(c.Fragment,{children:[c.jsx(go,{withHandle:!0}),c.jsx(Hi,{defaultSize:30,minSize:25,maxSize:50,id:"chat",order:3,children:c.jsx(fu,{})})]})]})]})]})})}function IE(){const[e,t]=x.useState(null),[n,r]=x.useState(!0),[i,s]=x.useState(null),a=x.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 x.useEffect(()=>{a()},[a]),{data:e,loading:n,error:i,refetch:a}}function TE(){const[e,t]=x.useState(!1),[n,r]=x.useState(null),[i,s]=x.useState(0);return{loadPlugins:x.useCallback(async()=>{t(!0),r(null);try{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 AE(){const{data:e,loading:t,error:n}=IE(),{loadPlugins:r}=TE(),i=Nt(s=>s.applyPluginsWithValidation);return x.useEffect(()=>{e&&e.plugins.length>0&&r().then(s=>{if(s){console.log("Plugins loaded successfully");const a=Nt.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(Bh,{children:c.jsx(Uh,{children:c.jsx(Jh,{children:c.jsx(qh,{children:c.jsx(Hh,{children:c.jsx(Cm,{children:c.jsx(Rc,{children:c.jsx("section",{className:"flex h-screen w-full flex-col",children:c.jsx("div",{className:"grow overflow-hidden",children:c.jsx(EE,{discoveryData:e})})})})})})})})})})}const ZE=Object.freeze(Object.defineProperty({__proto__:null,HomePage:AE},Symbol.toStringTag,{value:"Module"}));export{sr as B,Lt as D,ZE as H,$g as P,ir as S,zs as T,Sg as a,Ac as b,Ot as c,pn as d,hn as e,Rg as u};
99
+ //# sourceMappingURL=HomePage-DX_EbLqY.js.map