@json-to-office/jto 0.5.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +6 -4
- package/dist/cli.js.map +1 -1
- package/dist/client/assets/{HomePage-DJlT2M9Q.js → HomePage-5f3HNqyO.js} +3 -3
- package/dist/client/assets/{HomePage-DJlT2M9Q.js.map → HomePage-5f3HNqyO.js.map} +1 -1
- package/dist/client/assets/{JsonEditorPage-CUlhCM3Z.js → JsonEditorPage-C-MqODVJ.js} +3 -3
- package/dist/client/assets/{JsonEditorPage-CUlhCM3Z.js.map → JsonEditorPage-C-MqODVJ.js.map} +1 -1
- package/dist/client/assets/{MonacoPluginProvider-BT8Rmjt0.js → MonacoPluginProvider-DGH9IJWW.js} +3 -3
- package/dist/client/assets/{MonacoPluginProvider-BT8Rmjt0.js.map → MonacoPluginProvider-DGH9IJWW.js.map} +1 -1
- package/dist/client/assets/{button-DMYqGwZJ.js → button-6lzkhC2g.js} +2 -2
- package/dist/client/assets/{button-DMYqGwZJ.js.map → button-6lzkhC2g.js.map} +1 -1
- package/dist/client/assets/{editor-Cjfikke2.js → editor-BW0GiZPm.js} +2 -2
- package/dist/client/assets/{editor-Cjfikke2.js.map → editor-BW0GiZPm.js.map} +1 -1
- package/dist/client/assets/{editor-monaco-json-CmHmtw8m.js → editor-monaco-json-15fGSTnt.js} +2 -2
- package/dist/client/assets/{editor-monaco-json-CmHmtw8m.js.map → editor-monaco-json-15fGSTnt.js.map} +1 -1
- package/dist/client/assets/index-DcPXTvEZ.js +3 -0
- package/dist/client/assets/index-DcPXTvEZ.js.map +1 -0
- package/dist/client/assets/{preview-CqOfvXmU.js → preview-DqEl98dA.js} +2 -2
- package/dist/client/assets/{preview-CqOfvXmU.js.map → preview-DqEl98dA.js.map} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/client/assets/index-CyWrP8_G.js +0 -3
- package/dist/client/assets/index-CyWrP8_G.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-
|
|
2
|
-
var Qh=Object.defineProperty;var em=(e,t,n)=>t in e?Qh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ao=(e,t,n)=>em(e,typeof t!="symbol"?t+"":t,n);import{c as Ee,r as v,j as c,R as nc,g as Da}from"./react-vendor-CTFDOf2G.js";import{B as Ie}from"./button-DMYqGwZJ.js";import{c as U,T as Kr,C as tm,E as nm,F as Nt,S as Qt,a as rm,b as Ge,d as Ke,e as Ye,u as rc,f as Ra,s as ps,_ as ic,g as Yr,A as im,h as Xr}from"./index-CyWrP8_G.js";import{b as sc,c as Ma,d as ac,e as oc,f as Bi,g as Vi,D as Ui,O as Ji,h as lc,S as tr,i as sm,V as am,j as uc,I as om,k as lm,l as cc,m as um,n as dc,o as cm,p as dm,G as fm,q as fc,r as pc,L as hc,s as mc,t as pm,u as hm,v as mm,w as gc,x as xc,y as yc,z as bc,A as vc,B as wc,E as kc,F as Sc,H as _c,J as Cc,K as jc,M as gm,N as xm,Q as Nc,U as ym,W as bm,X as vm,Y as wm,Z as km,_ as Sm,$ as _m,a0 as Cm,a1 as jm,a2 as Ec,a3 as Ic,a4 as zc,a5 as Tc,a6 as Ac,a7 as Pc,a8 as Oc,a9 as Dc,aa as Rc,ab as Nm,ac as Mc,ad as $c,ae as Fc}from"./radix-ui-BZ5iKMtq.js";import{X as wn,a as Vr,C as rn,b as kn,d as Em,e as Hi,f as Lc,P as Im,g as Po,h as Gs,F as Zc,S as Bc,B as Oo,i as zm,j as Tm,k as Am,l as $a,m as Pm,M as Om,n as Dm,o as Rm,p as Vc,q as Mm,r as Do,s as yi,t as $m,I as Uc,G as Fm,u as Lm,R as Zm,v as Bm,T as Jc,E as Vm,w as Um,x as Jm,y as Hc,z as Fa,A as qc,D as Hm,H as Wc,J as qm,K as Wm,L as Ro,N as Gm,O as Ks,Q as Km}from"./ui-vendor-Dyg3GRT-.js";import{i as Ym,u as Xe,a as Ys,b as mn,g as Xs,c as Pt,T as Xm,d as Qr,S as Qm,O as eg,e as tg,M as ng,D as rg}from"./MonacoPluginProvider-BT8Rmjt0.js";import{c as ig,d as sg,p as ag,a as og,u as lg,b as ug}from"./state-vendor-BDrPu9qj.js";import{b as cg}from"./query-vendor-Df8-oete.js";var Ur=e=>e.type==="checkbox",xn=e=>e instanceof Date,lt=e=>e==null;const Gc=e=>typeof e=="object";var He=e=>!lt(e)&&!Array.isArray(e)&&Gc(e)&&!xn(e),Kc=e=>He(e)&&e.target?Ur(e.target)?e.target.checked:e.target.value:e,dg=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Yc=(e,t)=>e.has(dg(t)),fg=e=>{const t=e.constructor&&e.constructor.prototype;return He(t)&&t.hasOwnProperty("isPrototypeOf")},La=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function pt(e){let t;const n=Array.isArray(e),r=typeof FileList<"u"?e instanceof FileList:!1;if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(La&&(e instanceof Blob||r))&&(n||He(e)))if(t=n?[]:{},!n&&!fg(e))t=e;else for(const i in e)e.hasOwnProperty(i)&&(t[i]=pt(e[i]));else return e;return t}var qi=e=>Array.isArray(e)?e.filter(Boolean):[],Je=e=>e===void 0,se=(e,t,n)=>{if(!t||!He(e))return n;const r=qi(t.split(/[,[\].]+?/)).reduce((i,s)=>lt(i)?i:i[s],e);return Je(r)||r===e?Je(e[t])?n:e[t]:r},Ct=e=>typeof e=="boolean",Za=e=>/^\w*$/.test(e),Xc=e=>qi(e.replace(/["|']|\]/g,"").split(/\.|\[/)),Pe=(e,t,n)=>{let r=-1;const i=Za(t)?[t]:Xc(t),s=i.length,a=s-1;for(;++r<s;){const o=i[r];let l=n;if(r!==a){const u=e[o];l=He(u)||Array.isArray(u)?u:isNaN(+i[r+1])?{}:[]}if(o==="__proto__"||o==="constructor"||o==="prototype")return;e[o]=l,e=e[o]}return e};const bi={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},At={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Jt={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Qc=Ee.createContext(null),Wi=()=>Ee.useContext(Qc),pg=e=>{const{children:t,...n}=e;return Ee.createElement(Qc.Provider,{value:n},t)};var ed=(e,t,n,r=!0)=>{const i={defaultValues:t._defaultValues};for(const s in e)Object.defineProperty(i,s,{get:()=>{const a=s;return t._proxyFormState[a]!==At.all&&(t._proxyFormState[a]=!r||At.all),n&&(n[a]=!0),e[a]}});return i},ht=e=>He(e)&&!Object.keys(e).length,td=(e,t,n,r)=>{n(e);const{name:i,...s}=e;return ht(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(a=>t[a]===(!r||At.all))},Sr=e=>Array.isArray(e)?e:[e],nd=(e,t,n)=>!e||!t||e===t||Sr(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r)));function Ba(e){const t=Ee.useRef(e);t.current=e,Ee.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}function hg(e){const t=Wi(),{control:n=t.control,disabled:r,name:i,exact:s}=e||{},[a,o]=Ee.useState(n._formState),l=Ee.useRef(!0),u=Ee.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),f=Ee.useRef(i);return f.current=i,Ba({disabled:r,next:d=>l.current&&nd(f.current,d.name,s)&&td(d,u.current,n._updateFormState)&&o({...n._formState,...d}),subject:n._subjects.state}),Ee.useEffect(()=>(l.current=!0,u.current.isValid&&n._updateValid(!0),()=>{l.current=!1}),[n]),Ee.useMemo(()=>ed(a,n,u.current,!1),[a,n])}var Lt=e=>typeof e=="string",rd=(e,t,n,r,i)=>Lt(e)?(r&&t.watch.add(e),se(n,e,i)):Array.isArray(e)?e.map(s=>(r&&t.watch.add(s),se(n,s))):(r&&(t.watchAll=!0),n);function mg(e){const t=Wi(),{control:n=t.control,name:r,defaultValue:i,disabled:s,exact:a}=e||{},o=Ee.useRef(r);o.current=r,Ba({disabled:s,subject:n._subjects.values,next:f=>{nd(o.current,f.name,a)&&u(pt(rd(o.current,n._names,f.values||n._formValues,!1,i)))}});const[l,u]=Ee.useState(n._getWatch(r,i));return Ee.useEffect(()=>n._removeUnmounted()),l}function gg(e){const t=Wi(),{name:n,disabled:r,control:i=t.control,shouldUnregister:s}=e,a=Yc(i._names.array,n),o=mg({control:i,name:n,defaultValue:se(i._formValues,n,se(i._defaultValues,n,e.defaultValue)),exact:!0}),l=hg({control:i,name:n,exact:!0}),u=Ee.useRef(i.register(n,{...e.rules,value:o,...Ct(e.disabled)?{disabled:e.disabled}:{}})),f=Ee.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!se(l.errors,n)},isDirty:{enumerable:!0,get:()=>!!se(l.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!se(l.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!se(l.validatingFields,n)},error:{enumerable:!0,get:()=>se(l.errors,n)}}),[l,n]),d=Ee.useMemo(()=>({name:n,value:o,...Ct(r)||l.disabled?{disabled:l.disabled||r}:{},onChange:h=>u.current.onChange({target:{value:Kc(h),name:n},type:bi.CHANGE}),onBlur:()=>u.current.onBlur({target:{value:se(i._formValues,n),name:n},type:bi.BLUR}),ref:h=>{const p=se(i._fields,n);p&&h&&(p._f.ref={focus:()=>h.focus(),select:()=>h.select(),setCustomValidity:m=>h.setCustomValidity(m),reportValidity:()=>h.reportValidity()})}}),[n,i._formValues,r,l.disabled,o,i._fields]);return Ee.useEffect(()=>{const h=i._options.shouldUnregister||s,p=(m,w)=>{const S=se(i._fields,m);S&&S._f&&(S._f.mount=w)};if(p(n,!0),h){const m=pt(se(i._options.defaultValues,n));Pe(i._defaultValues,n,m),Je(se(i._formValues,n))&&Pe(i._formValues,n,m)}return!a&&i.register(n),()=>{(a?h&&!i._state.action:h)?i.unregister(n):p(n,!1)}},[n,i,a,s]),Ee.useEffect(()=>{i._updateDisabledField({disabled:r,fields:i._fields,name:n})},[r,n,i]),Ee.useMemo(()=>({field:d,formState:l,fieldState:f}),[d,l,f])}const xg=e=>e.render(gg(e));var yg=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},Mo=e=>({isOnSubmit:!e||e===At.onSubmit,isOnBlur:e===At.onBlur,isOnChange:e===At.onChange,isOnAll:e===At.all,isOnTouch:e===At.onTouched}),$o=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const _r=(e,t,n,r)=>{for(const i of n||Object.keys(e)){const s=se(e,i);if(s){const{_f:a,...o}=s;if(a){if(a.refs&&a.refs[0]&&t(a.refs[0],i)&&!r)return!0;if(a.ref&&t(a.ref,a.name)&&!r)return!0;if(_r(o,t))break}else if(He(o)&&_r(o,t))break}}};var bg=(e,t,n)=>{const r=Sr(se(e,n));return Pe(r,"root",t[n]),Pe(e,n,r),e},Va=e=>e.type==="file",Ft=e=>typeof e=="function",vi=e=>{if(!La)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},ci=e=>Lt(e),Ua=e=>e.type==="radio",wi=e=>e instanceof RegExp;const Fo={value:!1,isValid:!1},Lo={value:!0,isValid:!0};var id=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Je(e[0].attributes.value)?Je(e[0].value)||e[0].value===""?Lo:{value:e[0].value,isValid:!0}:Lo:Fo}return Fo};const Zo={isValid:!1,value:null};var sd=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,Zo):Zo;function Bo(e,t,n="validate"){if(ci(e)||Array.isArray(e)&&e.every(ci)||Ct(e)&&!e)return{type:n,message:ci(e)?e:"",ref:t}}var zn=e=>He(e)&&!wi(e)?e:{value:e,message:""},Vo=async(e,t,n,r,i,s)=>{const{ref:a,refs:o,required:l,maxLength:u,minLength:f,min:d,max:h,pattern:p,validate:m,name:w,valueAsNumber:S,mount:y}=e._f,_=se(n,w);if(!y||t.has(w))return{};const x=o?o[0]:a,P=D=>{i&&x.reportValidity&&(x.setCustomValidity(Ct(D)?"":D||""),x.reportValidity())},E={},k=Ua(a),C=Ur(a),V=k||C,Y=(S||Va(a))&&Je(a.value)&&Je(_)||vi(a)&&a.value===""||_===""||Array.isArray(_)&&!_.length,N=yg.bind(null,w,r,E),Z=(D,B,F,T=Jt.maxLength,H=Jt.minLength)=>{const K=D?B:F;E[w]={type:D?T:H,message:K,ref:a,...N(D?T:H,K)}};if(s?!Array.isArray(_)||!_.length:l&&(!V&&(Y||lt(_))||Ct(_)&&!_||C&&!id(o).isValid||k&&!sd(o).isValid)){const{value:D,message:B}=ci(l)?{value:!!l,message:l}:zn(l);if(D&&(E[w]={type:Jt.required,message:B,ref:x,...N(Jt.required,B)},!r))return P(B),E}if(!Y&&(!lt(d)||!lt(h))){let D,B;const F=zn(h),T=zn(d);if(!lt(_)&&!isNaN(_)){const H=a.valueAsNumber||_&&+_;lt(F.value)||(D=H>F.value),lt(T.value)||(B=H<T.value)}else{const H=a.valueAsDate||new Date(_),K=b=>new Date(new Date().toDateString()+" "+b),O=a.type=="time",W=a.type=="week";Lt(F.value)&&_&&(D=O?K(_)>K(F.value):W?_>F.value:H>new Date(F.value)),Lt(T.value)&&_&&(B=O?K(_)<K(T.value):W?_<T.value:H<new Date(T.value))}if((D||B)&&(Z(!!D,F.message,T.message,Jt.max,Jt.min),!r))return P(E[w].message),E}if((u||f)&&!Y&&(Lt(_)||s&&Array.isArray(_))){const D=zn(u),B=zn(f),F=!lt(D.value)&&_.length>+D.value,T=!lt(B.value)&&_.length<+B.value;if((F||T)&&(Z(F,D.message,B.message),!r))return P(E[w].message),E}if(p&&!Y&&Lt(_)){const{value:D,message:B}=zn(p);if(wi(D)&&!_.match(D)&&(E[w]={type:Jt.pattern,message:B,ref:a,...N(Jt.pattern,B)},!r))return P(B),E}if(m){if(Ft(m)){const D=await m(_,n),B=Bo(D,x);if(B&&(E[w]={...B,...N(Jt.validate,B.message)},!r))return P(B.message),E}else if(He(m)){let D={};for(const B in m){if(!ht(D)&&!r)break;const F=Bo(await m[B](_,n),x,B);F&&(D={...F,...N(B,F.message)},P(F.message),r&&(E[w]=D))}if(!ht(D)&&(E[w]={ref:x,...D},!r))return E}}return P(!0),E};function vg(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=Je(e)?r++:e[t[r++]];return e}function wg(e){for(const t in e)if(e.hasOwnProperty(t)&&!Je(e[t]))return!1;return!0}function et(e,t){const n=Array.isArray(t)?t:Za(t)?[t]:Xc(t),r=n.length===1?e:vg(e,n),i=n.length-1,s=n[i];return r&&delete r[s],i!==0&&(He(r)&&ht(r)||Array.isArray(r)&&wg(r))&&et(e,n.slice(0,-1)),e}var hs=()=>{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=[]}}},Qs=e=>lt(e)||!Gc(e);function en(e,t){if(Qs(e)||Qs(t))return e===t;if(xn(e)&&xn(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(xn(s)&&xn(a)||He(s)&&He(a)||Array.isArray(s)&&Array.isArray(a)?!en(s,a):s!==a)return!1}}return!0}var ad=e=>e.type==="select-multiple",kg=e=>Ua(e)||Ur(e),ms=e=>vi(e)&&e.isConnected,od=e=>{for(const t in e)if(Ft(e[t]))return!0;return!1};function ki(e,t={}){const n=Array.isArray(e);if(He(e)||n)for(const r in e)Array.isArray(e[r])||He(e[r])&&!od(e[r])?(t[r]=Array.isArray(e[r])?[]:{},ki(e[r],t[r])):lt(e[r])||(t[r]=!0);return t}function ld(e,t,n){const r=Array.isArray(e);if(He(e)||r)for(const i in e)Array.isArray(e[i])||He(e[i])&&!od(e[i])?Je(t)||Qs(n[i])?n[i]=Array.isArray(e[i])?ki(e[i],[]):{...ki(e[i])}:ld(e[i],lt(t)?{}:t[i],n[i]):n[i]=!en(e[i],t[i]);return n}var ar=(e,t)=>ld(e,t,ki(t)),ud=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>Je(e)?e:t?e===""?NaN:e&&+e:n&&Lt(e)?new Date(e):r?r(e):e;function gs(e){const t=e.ref;return Va(t)?t.files:Ua(t)?sd(e.refs).value:ad(t)?[...t.selectedOptions].map(({value:n})=>n):Ur(t)?id(e.refs).value:ud(Je(t.value)?e.ref.value:t.value,e)}var Sg=(e,t,n,r)=>{const i={};for(const s of e){const a=se(t,s);a&&Pe(i,s,a._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},or=e=>Je(e)?e:wi(e)?e.source:He(e)?wi(e.value)?e.value.source:e.value:e;const Uo="AsyncFunction";var _g=e=>!!e&&!!e.validate&&!!(Ft(e.validate)&&e.validate.constructor.name===Uo||He(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Uo)),Cg=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Jo(e,t,n){const r=se(e,n);if(r||Za(n))return{error:r,name:n};const i=n.split(".");for(;i.length;){const s=i.join("."),a=se(t,s),o=se(e,s);if(a&&!Array.isArray(a)&&n!==s)return{name:n};if(o&&o.type)return{name:s,error:o};i.pop()}return{name:n}}var jg=(e,t,n,r,i)=>i.isOnAll?!1:!n&&i.isOnTouch?!(t||e):(n?r.isOnBlur:i.isOnBlur)?!e:(n?r.isOnChange:i.isOnChange)?e:!0,Ng=(e,t)=>!qi(se(e,t)).length&&et(e,t);const Eg={mode:At.onSubmit,reValidateMode:At.onChange,shouldFocusError:!0};function Ig(e={}){let t={...Eg,...e},n={submitCount:0,isDirty:!1,isLoading:Ft(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},i=He(t.defaultValues)||He(t.values)?pt(t.defaultValues||t.values)||{}:{},s=t.shouldUnregister?{}:pt(i),a={action:!1,mount:!1,watch:!1},o={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},l,u=0;const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},d={values:hs(),array:hs(),state:hs()},h=Mo(t.mode),p=Mo(t.reValidateMode),m=t.criteriaMode===At.all,w=j=>z=>{clearTimeout(u),u=setTimeout(j,z)},S=async j=>{if(!t.disabled&&(f.isValid||j)){const z=t.resolver?ht((await V()).errors):await N(r,!0);z!==n.isValid&&d.state.next({isValid:z})}},y=(j,z)=>{!t.disabled&&(f.isValidating||f.validatingFields)&&((j||Array.from(o.mount)).forEach($=>{$&&(z?Pe(n.validatingFields,$,z):et(n.validatingFields,$))}),d.state.next({validatingFields:n.validatingFields,isValidating:!ht(n.validatingFields)}))},_=(j,z=[],$,ne,te=!0,ee=!0)=>{if(ne&&$&&!t.disabled){if(a.action=!0,ee&&Array.isArray(se(r,j))){const ce=$(se(r,j),ne.argA,ne.argB);te&&Pe(r,j,ce)}if(ee&&Array.isArray(se(n.errors,j))){const ce=$(se(n.errors,j),ne.argA,ne.argB);te&&Pe(n.errors,j,ce),Ng(n.errors,j)}if(f.touchedFields&&ee&&Array.isArray(se(n.touchedFields,j))){const ce=$(se(n.touchedFields,j),ne.argA,ne.argB);te&&Pe(n.touchedFields,j,ce)}f.dirtyFields&&(n.dirtyFields=ar(i,s)),d.state.next({name:j,isDirty:D(j,z),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Pe(s,j,z)},x=(j,z)=>{Pe(n.errors,j,z),d.state.next({errors:n.errors})},P=j=>{n.errors=j,d.state.next({errors:n.errors,isValid:!1})},E=(j,z,$,ne)=>{const te=se(r,j);if(te){const ee=se(s,j,Je($)?se(i,j):$);Je(ee)||ne&&ne.defaultChecked||z?Pe(s,j,z?ee:gs(te._f)):T(j,ee),a.mount&&S()}},k=(j,z,$,ne,te)=>{let ee=!1,ce=!1;const xe={name:j};if(!t.disabled){const M=!!(se(r,j)&&se(r,j)._f&&se(r,j)._f.disabled);if(!$||ne){f.isDirty&&(ce=n.isDirty,n.isDirty=xe.isDirty=D(),ee=ce!==xe.isDirty);const q=M||en(se(i,j),z);ce=!!(!M&&se(n.dirtyFields,j)),q||M?et(n.dirtyFields,j):Pe(n.dirtyFields,j,!0),xe.dirtyFields=n.dirtyFields,ee=ee||f.dirtyFields&&ce!==!q}if($){const q=se(n.touchedFields,j);q||(Pe(n.touchedFields,j,$),xe.touchedFields=n.touchedFields,ee=ee||f.touchedFields&&q!==$)}ee&&te&&d.state.next(xe)}return ee?xe:{}},C=(j,z,$,ne)=>{const te=se(n.errors,j),ee=f.isValid&&Ct(z)&&n.isValid!==z;if(t.delayError&&$?(l=w(()=>x(j,$)),l(t.delayError)):(clearTimeout(u),l=null,$?Pe(n.errors,j,$):et(n.errors,j)),($?!en(te,$):te)||!ht(ne)||ee){const ce={...ne,...ee&&Ct(z)?{isValid:z}:{},errors:n.errors,name:j};n={...n,...ce},d.state.next(ce)}},V=async j=>{y(j,!0);const z=await t.resolver(s,t.context,Sg(j||o.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return y(j),z},Y=async j=>{const{errors:z}=await V(j);if(j)for(const $ of j){const ne=se(z,$);ne?Pe(n.errors,$,ne):et(n.errors,$)}else n.errors=z;return z},N=async(j,z,$={valid:!0})=>{for(const ne in j){const te=j[ne];if(te){const{_f:ee,...ce}=te;if(ee){const xe=o.array.has(ee.name),M=te._f&&_g(te._f);M&&f.validatingFields&&y([ne],!0);const q=await Vo(te,o.disabled,s,m,t.shouldUseNativeValidation&&!z,xe);if(M&&f.validatingFields&&y([ne]),q[ee.name]&&($.valid=!1,z))break;!z&&(se(q,ee.name)?xe?bg(n.errors,q,ee.name):Pe(n.errors,ee.name,q[ee.name]):et(n.errors,ee.name))}!ht(ce)&&await N(ce,z,$)}}return $.valid},Z=()=>{for(const j of o.unMount){const z=se(r,j);z&&(z._f.refs?z._f.refs.every($=>!ms($)):!ms(z._f.ref))&&Q(j)}o.unMount=new Set},D=(j,z)=>!t.disabled&&(j&&z&&Pe(s,j,z),!en(ue(),i)),B=(j,z,$)=>rd(j,o,{...a.mount?s:Je(z)?i:Lt(j)?{[j]:z}:z},$,z),F=j=>qi(se(a.mount?s:i,j,t.shouldUnregister?se(i,j,[]):[])),T=(j,z,$={})=>{const ne=se(r,j);let te=z;if(ne){const ee=ne._f;ee&&(!ee.disabled&&Pe(s,j,ud(z,ee)),te=vi(ee.ref)&<(z)?"":z,ad(ee.ref)?[...ee.ref.options].forEach(ce=>ce.selected=te.includes(ce.value)):ee.refs?Ur(ee.ref)?ee.refs.length>1?ee.refs.forEach(ce=>(!ce.defaultChecked||!ce.disabled)&&(ce.checked=Array.isArray(te)?!!te.find(xe=>xe===ce.value):te===ce.value)):ee.refs[0]&&(ee.refs[0].checked=!!te):ee.refs.forEach(ce=>ce.checked=ce.value===te):Va(ee.ref)?ee.ref.value="":(ee.ref.value=te,ee.ref.type||d.values.next({name:j,values:{...s}})))}($.shouldDirty||$.shouldTouch)&&k(j,te,$.shouldTouch,$.shouldDirty,!0),$.shouldValidate&&b(j)},H=(j,z,$)=>{for(const ne in z){const te=z[ne],ee=`${j}.${ne}`,ce=se(r,ee);(o.array.has(j)||He(te)||ce&&!ce._f)&&!xn(te)?H(ee,te,$):T(ee,te,$)}},K=(j,z,$={})=>{const ne=se(r,j),te=o.array.has(j),ee=pt(z);Pe(s,j,ee),te?(d.array.next({name:j,values:{...s}}),(f.isDirty||f.dirtyFields)&&$.shouldDirty&&d.state.next({name:j,dirtyFields:ar(i,s),isDirty:D(j,ee)})):ne&&!ne._f&&!lt(ee)?H(j,ee,$):T(j,ee,$),$o(j,o)&&d.state.next({...n}),d.values.next({name:a.mount?j:void 0,values:{...s}})},O=async j=>{a.mount=!0;const z=j.target;let $=z.name,ne=!0;const te=se(r,$),ee=()=>z.type?gs(te._f):Kc(j),ce=xe=>{ne=Number.isNaN(xe)||xn(xe)&&isNaN(xe.getTime())||en(xe,se(s,$,xe))};if(te){let xe,M;const q=ee(),de=j.type===bi.BLUR||j.type===bi.FOCUS_OUT,ve=!Cg(te._f)&&!t.resolver&&!se(n.errors,$)&&!te._f.deps||jg(de,se(n.touchedFields,$),n.isSubmitted,p,h),A=$o($,o,de);Pe(s,$,q),de?(te._f.onBlur&&te._f.onBlur(j),l&&l(0)):te._f.onChange&&te._f.onChange(j);const fe=k($,q,de,!1),Ce=!ht(fe)||A;if(!de&&d.values.next({name:$,type:j.type,values:{...s}}),ve)return f.isValid&&(t.mode==="onBlur"&&de?S():de||S()),Ce&&d.state.next({name:$,...A?{}:fe});if(!de&&A&&d.state.next({...n}),t.resolver){const{errors:Re}=await V([$]);if(ce(q),ne){const Qe=Jo(n.errors,r,$),qe=Jo(Re,r,Qe.name||$);xe=qe.error,$=qe.name,M=ht(Re)}}else y([$],!0),xe=(await Vo(te,o.disabled,s,m,t.shouldUseNativeValidation))[$],y([$]),ce(q),ne&&(xe?M=!1:f.isValid&&(M=await N(r,!0)));ne&&(te._f.deps&&b(te._f.deps),C($,M,xe,fe))}},W=(j,z)=>{if(se(n.errors,z)&&j.focus)return j.focus(),1},b=async(j,z={})=>{let $,ne;const te=Sr(j);if(t.resolver){const ee=await Y(Je(j)?j:te);$=ht(ee),ne=j?!te.some(ce=>se(ee,ce)):$}else j?(ne=(await Promise.all(te.map(async ee=>{const ce=se(r,ee);return await N(ce&&ce._f?{[ee]:ce}:ce)}))).every(Boolean),!(!ne&&!n.isValid)&&S()):ne=$=await N(r);return d.state.next({...!Lt(j)||f.isValid&&$!==n.isValid?{}:{name:j},...t.resolver||!j?{isValid:$}:{},errors:n.errors}),z.shouldFocus&&!ne&&_r(r,W,j?te:o.mount),ne},ue=j=>{const z={...a.mount?s:i};return Je(j)?z:Lt(j)?se(z,j):j.map($=>se(z,$))},ae=(j,z)=>({invalid:!!se((z||n).errors,j),isDirty:!!se((z||n).dirtyFields,j),error:se((z||n).errors,j),isValidating:!!se(n.validatingFields,j),isTouched:!!se((z||n).touchedFields,j)}),g=j=>{j&&Sr(j).forEach(z=>et(n.errors,z)),d.state.next({errors:j?n.errors:{}})},G=(j,z,$)=>{const ne=(se(r,j,{_f:{}})._f||{}).ref,te=se(n.errors,j)||{},{ref:ee,message:ce,type:xe,...M}=te;Pe(n.errors,j,{...M,...z,ref:ne}),d.state.next({name:j,errors:n.errors,isValid:!1}),$&&$.shouldFocus&&ne&&ne.focus&&ne.focus()},ie=(j,z)=>Ft(j)?d.values.subscribe({next:$=>j(B(void 0,z),$)}):B(j,z,!0),Q=(j,z={})=>{for(const $ of j?Sr(j):o.mount)o.mount.delete($),o.array.delete($),z.keepValue||(et(r,$),et(s,$)),!z.keepError&&et(n.errors,$),!z.keepDirty&&et(n.dirtyFields,$),!z.keepTouched&&et(n.touchedFields,$),!z.keepIsValidating&&et(n.validatingFields,$),!t.shouldUnregister&&!z.keepDefaultValue&&et(i,$);d.values.next({values:{...s}}),d.state.next({...n,...z.keepDirty?{isDirty:D()}:{}}),!z.keepIsValid&&S()},I=({disabled:j,name:z,field:$,fields:ne})=>{(Ct(j)&&a.mount||j||o.disabled.has(z))&&(j?o.disabled.add(z):o.disabled.delete(z),k(z,gs($?$._f:se(ne,z)._f),!1,!1,!0))},R=(j,z={})=>{let $=se(r,j);const ne=Ct(z.disabled)||Ct(t.disabled);return Pe(r,j,{...$||{},_f:{...$&&$._f?$._f:{ref:{name:j}},name:j,mount:!0,...z}}),o.mount.add(j),$?I({field:$,disabled:Ct(z.disabled)?z.disabled:t.disabled,name:j}):E(j,!0,z.value),{...ne?{disabled:z.disabled||t.disabled}:{},...t.progressive?{required:!!z.required,min:or(z.min),max:or(z.max),minLength:or(z.minLength),maxLength:or(z.maxLength),pattern:or(z.pattern)}:{},name:j,onChange:O,onBlur:O,ref:te=>{if(te){R(j,z),$=se(r,j);const ee=Je(te.value)&&te.querySelectorAll&&te.querySelectorAll("input,select,textarea")[0]||te,ce=kg(ee),xe=$._f.refs||[];if(ce?xe.find(M=>M===ee):ee===$._f.ref)return;Pe(r,j,{_f:{...$._f,...ce?{refs:[...xe.filter(ms),ee,...Array.isArray(se(i,j))?[{}]:[]],ref:{type:ee.type,name:j}}:{ref:ee}}}),E(j,!1,void 0,ee)}else $=se(r,j,{}),$._f&&($._f.mount=!1),(t.shouldUnregister||z.shouldUnregister)&&!(Yc(o.array,j)&&a.action)&&o.unMount.add(j)}}},J=()=>t.shouldFocusError&&_r(r,W,o.mount),oe=j=>{Ct(j)&&(d.state.next({disabled:j}),_r(r,(z,$)=>{const ne=se(r,$);ne&&(z.disabled=ne._f.disabled||j,Array.isArray(ne._f.refs)&&ne._f.refs.forEach(te=>{te.disabled=ne._f.disabled||j}))},0,!1))},pe=(j,z)=>async $=>{let ne;$&&($.preventDefault&&$.preventDefault(),$.persist&&$.persist());let te=pt(s);if(o.disabled.size)for(const ee of o.disabled)Pe(te,ee,void 0);if(d.state.next({isSubmitting:!0}),t.resolver){const{errors:ee,values:ce}=await V();n.errors=ee,te=ce}else await N(r);if(et(n.errors,"root"),ht(n.errors)){d.state.next({errors:{}});try{await j(te,$)}catch(ee){ne=ee}}else z&&await z({...n.errors},$),J(),setTimeout(J);if(d.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ht(n.errors)&&!ne,submitCount:n.submitCount+1,errors:n.errors}),ne)throw ne},Ae=(j,z={})=>{se(r,j)&&(Je(z.defaultValue)?K(j,pt(se(i,j))):(K(j,z.defaultValue),Pe(i,j,pt(z.defaultValue))),z.keepTouched||et(n.touchedFields,j),z.keepDirty||(et(n.dirtyFields,j),n.isDirty=z.defaultValue?D(j,pt(se(i,j))):D()),z.keepError||(et(n.errors,j),f.isValid&&S()),d.state.next({...n}))},ke=(j,z={})=>{const $=j?pt(j):i,ne=pt($),te=ht(j),ee=te?i:ne;if(z.keepDefaultValues||(i=$),!z.keepValues){if(z.keepDirtyValues){const ce=new Set([...o.mount,...Object.keys(ar(i,s))]);for(const xe of Array.from(ce))se(n.dirtyFields,xe)?Pe(ee,xe,se(s,xe)):K(xe,se(ee,xe))}else{if(La&&Je(j))for(const ce of o.mount){const xe=se(r,ce);if(xe&&xe._f){const M=Array.isArray(xe._f.refs)?xe._f.refs[0]:xe._f.ref;if(vi(M)){const q=M.closest("form");if(q){q.reset();break}}}}r={}}s=t.shouldUnregister?z.keepDefaultValues?pt(i):{}:pt(ee),d.array.next({values:{...ee}}),d.values.next({values:{...ee}})}o={mount:z.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},a.mount=!f.isValid||!!z.keepIsValid||!!z.keepDirtyValues,a.watch=!!t.shouldUnregister,d.state.next({submitCount:z.keepSubmitCount?n.submitCount:0,isDirty:te?!1:z.keepDirty?n.isDirty:!!(z.keepDefaultValues&&!en(j,i)),isSubmitted:z.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:te?{}:z.keepDirtyValues?z.keepDefaultValues&&s?ar(i,s):n.dirtyFields:z.keepDefaultValues&&j?ar(i,j):z.keepDirty?n.dirtyFields:{},touchedFields:z.keepTouched?n.touchedFields:{},errors:z.keepErrors?n.errors:{},isSubmitSuccessful:z.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},be=(j,z)=>ke(Ft(j)?j(s):j,z);return{control:{register:R,unregister:Q,getFieldState:ae,handleSubmit:pe,setError:G,_executeSchema:V,_getWatch:B,_getDirty:D,_updateValid:S,_removeUnmounted:Z,_updateFieldArray:_,_updateDisabledField:I,_getFieldArray:F,_reset:ke,_resetDefaultValues:()=>Ft(t.defaultValues)&&t.defaultValues().then(j=>{be(j,t.resetOptions),d.state.next({isLoading:!1})}),_updateFormState:j=>{n={...n,...j}},_disableForm:oe,_subjects:d,_proxyFormState:f,_setErrors:P,get _fields(){return r},get _formValues(){return s},get _state(){return a},set _state(j){a=j},get _defaultValues(){return i},get _names(){return o},set _names(j){o=j},get _formState(){return n},set _formState(j){n=j},get _options(){return t},set _options(j){t={...t,...j}}},trigger:b,register:R,handleSubmit:pe,watch:ie,setValue:K,getValues:ue,reset:be,resetField:Ae,clearErrors:g,unregister:Q,setError:G,setFocus:(j,z={})=>{const $=se(r,j),ne=$&&$._f;if(ne){const te=ne.refs?ne.refs[0]:ne.ref;te.focus&&(te.focus(),z.shouldSelect&&Ft(te.select)&&te.select())}},getFieldState:ae}}function zg(e={}){const t=Ee.useRef(void 0),n=Ee.useRef(void 0),[r,i]=Ee.useState({isDirty:!1,isValidating:!1,isLoading:Ft(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Ft(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...Ig(e),formState:r});const s=t.current.control;return s._options=e,Ba({subject:s._subjects.state,next:a=>{td(a,s._proxyFormState,s._updateFormState,!0)&&i({...s._formState})}}),Ee.useEffect(()=>s._disableForm(e.disabled),[s,e.disabled]),Ee.useEffect(()=>{if(s._proxyFormState.isDirty){const a=s._getDirty();a!==r.isDirty&&s._subjects.state.next({isDirty:a})}},[s,r.isDirty]),Ee.useEffect(()=>{e.values&&!en(e.values,n.current)?(s._reset(e.values,s._options.resetOptions),n.current=e.values,i(a=>({...a}))):s._resetDefaultValues()},[e.values,s]),Ee.useEffect(()=>{e.errors&&s._setErrors(e.errors)},[e.errors,s]),Ee.useEffect(()=>{s._state.mount||(s._updateValid(),s._state.mount=!0),s._state.watch&&(s._state.watch=!1,s._subjects.state.next({...s._formState})),s._removeUnmounted()}),Ee.useEffect(()=>{e.shouldUnregister&&s._subjects.values.next({values:s._getWatch()})},[e.shouldUnregister,s]),t.current.formState=ed(r,s),t.current}function Tg(e){return async t=>{const n=e(t);if(n.success&&n.data)return{values:n.data,errors:{}};const r={};if(n.errors)for(const i of n.errors){const s=i.path||"root";r[s]||(r[s]={type:"validation",message:i.message})}return{values:{},errors:r}}}const qt=sc,Ho=ac,Ag=oc,qo=Ma,cd=v.forwardRef(({className:e,...t},n)=>c.jsx(Ji,{ref:n,className:U("fixed inset-0 z-50 bg-black/80",e),...t}));cd.displayName=Ji.displayName;const Zt=v.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Ag,{children:[c.jsx(cd,{}),c.jsxs(Bi,{ref:r,className:U("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(Ma,{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(wn,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Zt.displayName=Bi.displayName;const Sn=({className:e,...t})=>c.jsx("div",{className:U("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Sn.displayName="DialogHeader";const zr=({className:e,...t})=>c.jsx("div",{className:U("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});zr.displayName="DialogFooter";const _n=v.forwardRef(({className:e,...t},n)=>c.jsx(Vi,{ref:n,className:U("text-lg leading-none font-semibold tracking-tight",e),...t}));_n.displayName=Vi.displayName;const Gn=v.forwardRef(({className:e,...t},n)=>c.jsx(Ui,{ref:n,className:U("text-muted-foreground text-sm",e),...t}));Gn.displayName=Ui.displayName;const Pg=Vr("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ja=v.forwardRef(({className:e,...t},n)=>c.jsx(lc,{ref:n,className:U(Pg(),e),...t}));Ja.displayName=lc.displayName;const Og=pg,dd=v.createContext({}),Wo=({...e})=>c.jsx(dd.Provider,{value:{name:e.name},children:c.jsx(xg,{...e})}),Gi=()=>{const e=v.useContext(dd),t=v.useContext(fd),{getFieldState:n,formState:r}=Wi(),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}},fd=v.createContext({}),ea=v.forwardRef(({className:e,...t},n)=>{const r=v.useId();return c.jsx(fd.Provider,{value:{id:r},children:c.jsx("div",{ref:n,className:U("space-y-2",e),...t})})});ea.displayName="FormItem";const ta=v.forwardRef(({className:e,...t},n)=>{const{error:r,formItemId:i}=Gi();return c.jsx(Ja,{ref:n,className:U(r&&"text-destructive",e),htmlFor:i,...t})});ta.displayName="FormLabel";const na=v.forwardRef(({...e},t)=>{const{error:n,formItemId:r,formDescriptionId:i,formMessageId:s}=Gi();return c.jsx(tr,{ref:t,id:r,"aria-describedby":n?`${i} ${s}`:`${i}`,"aria-invalid":!!n,...e})});na.displayName="FormControl";const pd=v.forwardRef(({className:e,...t},n)=>{const{formDescriptionId:r}=Gi();return c.jsx("p",{ref:n,id:r,className:U("text-muted-foreground text-[0.8rem]",e),...t})});pd.displayName="FormDescription";const ra=v.forwardRef(({className:e,children:t,...n},r)=>{const{error:i,formMessageId:s}=Gi(),a=i?String(i==null?void 0:i.message):t;return a?c.jsx("p",{ref:r,id:s,className:U("text-destructive text-[0.8rem] font-medium",e),...n,children:a}):null});ra.displayName="FormMessage";const Ha=v.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:U("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}));Ha.displayName="Input";const qa=sm,Dg=fm,Wa=am,Ki=v.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(uc,{ref:r,className:U("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(om,{asChild:!0,children:c.jsx(rn,{className:"h-4 w-4 shrink-0 opacity-50"})})]}));Ki.displayName=uc.displayName;const hd=v.forwardRef(({className:e,...t},n)=>c.jsx(fc,{ref:n,className:U("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(Em,{className:"h-4 w-4"})}));hd.displayName=fc.displayName;const md=v.forwardRef(({className:e,...t},n)=>c.jsx(pc,{ref:n,className:U("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(rn,{className:"h-4 w-4"})}));md.displayName=pc.displayName;const Yi=v.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>c.jsx(lm,{children:c.jsxs(cc,{ref:i,className:U("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(hd,{}),c.jsx(um,{className:U("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(md,{})]})}));Yi.displayName=cc.displayName;const gd=v.forwardRef(({className:e,...t},n)=>c.jsx(hc,{ref:n,className:U("px-2 py-1.5 text-sm font-semibold",e),...t}));gd.displayName=hc.displayName;const Tr=v.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(dc,{ref:r,className:U("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(cm,{children:c.jsx(kn,{className:"h-4 w-4"})})}),c.jsx(dm,{children:t})]}));Tr.displayName=dc.displayName;const Rg=v.forwardRef(({className:e,...t},n)=>c.jsx(mc,{ref:n,className:U("bg-muted -mx-1 my-1 h-px",e),...t}));Rg.displayName=mc.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 xd=()=>({chatOpen:!1,scope:"global",model:"opus",contextAttachments:[],threads:{},activeThreadId:{}}),Mg=(e=xd())=>ig()(sg(ag((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(f=>f.documentName===o);u.length>0?(u.sort((f,d)=>d.updatedAt-f.updatedAt),l[o]=u[0].id):delete l[o]}t({threads:a,activeThreadId:l})},switchThread:r=>{const s=n().threads[r];s&&t(a=>({activeThreadId:{...a.activeThreadId,[s.documentName]:r}}))},updateThreadMessages:(r,i)=>{t(s=>{const a=s.threads[r];return a?{threads:{...s.threads,[r]:{...a,messages:i,updatedAt:Date.now()}}}:s})},updateThreadTitle:(r,i)=>{t(s=>{const a=s.threads[r];return a?{threads:{...s.threads,[r]:{...a,title:i}}}:s})},deleteThreadsForDocument:r=>{t(i=>{const s={...i.threads},a={...i.activeThreadId};for(const[o,l]of Object.entries(s))l.documentName===r&&delete s[o];return delete a[r],{threads:s,activeThreadId:a}})},renameThreadsForDocument:(r,i)=>{t(s=>{const a={...s.threads},o={...s.activeThreadId};for(const[l,u]of Object.entries(a))u.documentName===r&&(a[l]={...u,documentName:i});return r in o&&(o[i]=o[r],delete o[r]),{threads:a,activeThreadId:o}})},clearChat:()=>{t(r=>({contextAttachments:[]}))}}),{name:"chat-storage",version:1,storage:og(()=>Ym),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}}))),yd=v.createContext(void 0),$g=({children:e})=>{const t=v.useRef(null);return t.current||(t.current=Mg(xd())),c.jsx(yd.Provider,{value:t.current,children:e})},ze=e=>{const t=v.useContext(yd);if(!t)throw new Error("useChatStore must be used within ChatStoreProvider");return lg(t,e)};function Fg(e,t,n){return t.filter(r=>r.name!==n).every(r=>r.name!==e)}function Lg(e,t,n){const r={},i=[];e!=="delete"&&(r.name=Kr.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=Kr.Optional(Kr.String({description:"Template selection"})));const s=Kr.Object(r,{additionalProperties:!1,required:i.length>0?i:void 0});return{schema:s,validate:a=>{const o=[];if(!tm(s,a))for(const u of nm(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 Zg(e,t,n){return e==="create"?{name:"",template:t}:e==="update"?{name:n}:{}}const Bg=e=>({create:{title:e?"New Theme":"New Document",description:e?"Create a new theme from scratch or based on discovered themes.":"Create a new document from scratch or based on discovered documents.",button:"Create",buttonVariant:"default"},update:{title:"Rename Document",description:"Give your document a new name.",button:"Save",buttonVariant:"default"},delete:{title:"Are you absolutely sure?",description:"This action cannot be undone. Are you sure you want to permanently delete this document?",button:"Confirm",buttonVariant:"destructive"}}),lr="__empty__";function Vg({mode:e,shouldReset:t,postSubmit:n,selectedName:r,discoveredDocuments:i,discoveredThemes:s,isTheme:a}){const[o,l]=v.useState(!1),[u,f]=v.useState(null),d=Bg(a),{documents:h,openTabs:p,createDocument:m,renameDocument:w,deleteDocument:S,openDocument:y,closeDocument:_}=Xe(O=>O),{updateTheme:x,removeTheme:P}=Ys(O=>O),E=ze(O=>O.renameThreadsForDocument),k=ze(O=>O.deleteThreadsForDocument),C=v.useMemo(()=>a?s||[]:i||[],[a,i,s]),V=v.useMemo(()=>{const O={current:[],downstream:[]};return C.forEach(W=>{O[W.location]&&O[W.location].push(W)}),O},[C]),Y=v.useMemo(()=>C.map(O=>({name:O.name,type:"application/json",text:"",mtime:new Date,ctime:new Date,atime:new Date})),[C]),N=v.useMemo(()=>Lg(e,O=>Fg(O,h,r),Y),[e,h,r,Y]),Z=N.schema,D=v.useMemo(()=>{const O=new Map;return C.forEach(W=>O.set(W.path,W)),O},[C]),B=lr,F=zg({resolver:Tg(N.validate),defaultValues:Zg(e,void 0,r)}),[T,H]=v.useState(B);v.useEffect(()=>{if(T&&T!==lr&&e==="create"){const O=D.get(T);O&&fetch(`/api/discovery/${a?"themes":"documents"}/${encodeURIComponent(O.name)}/content`).then(W=>{if(!W.ok)throw new Error(`Failed to fetch content: ${W.statusText}`);return W.text()}).then(W=>{try{const b=JSON.parse(W);f(JSON.stringify(b,null,2))}catch(b){console.error("Invalid JSON content received:",b),f(null)}}).catch(W=>{console.error("Failed to fetch content:",W),f(null)})}},[T,e,D,a]),v.useEffect(()=>{t&&(F.reset(),f(null),H(B))},[F,t]);const K=F.handleSubmit(async({name:O,template:W})=>{l(!0);try{if(await new Promise(b=>setTimeout(b,200)),e==="create"){const b=T?D.get(T):C.find(R=>R.name===W);let ue,ae=O;if(a){const R=ae.replace(/\.(json|theme)$/i,"").toLowerCase().replace(/\s+/g,"-");ue=u||JSON.stringify(Nt==="docx"?{name:R,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:R,colors:{primary:"#2563EB",secondary:"#64748B",accent:"#F8FAFC",background:"#FFFFFF",text:"#334155"},fonts:{heading:"Calibri",body:"Calibri"},defaults:{fontSize:18,fontColor:"#334155"}},null,2);const oe=`.${Nt}.theme.json`;ae.endsWith(oe)||(ae=ae.replace(/\.(pptx|docx)\.theme\.json$/i,"").replace(/\.theme\.json$/i,"").replace(/\.json$/i,""),ae+=oe)}else{const R=b;ue=u||JSON.stringify(Nt==="docx"?{name:"docx",props:{theme:(R==null?void 0:R.theme)||"default",metadata:{title:(R==null?void 0:R.title)||ae.replace(/\.(json|js)$/i,"")}},children:[{name:"section",props:{},children:[{name:"paragraph",props:{text:"Start writing your document content here..."}}]}]}:{name:"pptx",props:{title:(R==null?void 0:R.title)||ae.replace(/\.(json|js)$/i,""),theme:(R==null?void 0:R.theme)||"default"},children:[{name:"slide",props:{},children:[{name:"text",props:{text:"Start writing your presentation content here...",fontSize:24,y:2,x:1,w:8}}]}]},null,2);const J=Nt==="docx"?".docx.json":".pptx.json";!ae.endsWith(J)&&!ae.endsWith(".json")&&(ae+=J)}const g=ae.match(/(\.(pptx|docx)(\.theme)?\.json|\.json)$/i),G=g?g[0]:"",ie=ae.slice(0,ae.length-G.length);let Q=ae,I=1;for(;h.some(R=>R.name===Q);)I++,Q=`${ie} (${I})${G}`;ae=Q,m(ae,ue),y(ae),a&&x(ae,ue)}else if(e==="update"){const b=r,ue=O,ae=p.includes(b);ae&&_(b),w(b,ue),E(b,ue),ae&&y(ue)}else if(e==="delete"){const b=r;_(b),S(b),k(b),a&&P(b)}n()}finally{l(!1)}});return c.jsx(Og,{...F,children:c.jsxs("form",{onSubmit:K,children:[c.jsxs(Sn,{children:[c.jsx(_n,{children:d[e].title}),c.jsx(Gn,{children:d[e].description})]}),c.jsxs("div",{className:"flex flex-col gap-4 py-4",children:[Z.properties&&"name"in Z.properties&&c.jsx(Wo,{control:F.control,name:"name",render:({field:O})=>c.jsxs(ea,{children:[c.jsx(ta,{children:"Name"}),c.jsx(na,{children:c.jsx(Ha,{placeholder:"Enter a name or select a template below",autoComplete:"off",...O})}),c.jsx(ra,{})]})}),e==="create"&&c.jsx(Wo,{control:F.control,name:"template",render:({field:O})=>c.jsxs(ea,{children:[c.jsx(ta,{children:a?"Base Theme":"Base Document"}),c.jsxs(qa,{onValueChange:W=>{if(W===lr)O.onChange(void 0),F.setValue("name",""),H(lr),f(null);else{const b=D.get(W);b&&(O.onChange(b.name),F.setValue("name",b.name),H(W))}},defaultValue:B,children:[c.jsx(na,{children:c.jsx(Ki,{children:c.jsx(Wa,{placeholder:`Select a discovered ${a?"theme":"document"}`})})}),c.jsxs(Yi,{className:"max-h-[300px]",children:[c.jsxs(Tr,{value:lr,children:["Empty ",a?"theme":"document"]}),Object.entries(V).map(([W,b])=>b.length===0?null:c.jsxs(Dg,{children:[c.jsx(gd,{children:W==="current"?"📁 Current Directory":"📦 Project"}),b.map(ue=>{let ae=ue.name;if(ue.title)ae=`${ue.name} - ${ue.title}`;else if(ue.description){const g=ue.description.length>40?ue.description.substring(0,40)+"...":ue.description;ae=`${ue.name} - ${g}`}return c.jsx(Tr,{value:ue.path,className:"pl-6",children:ae},ue.path)})]},W))]})]}),c.jsxs(pd,{children:["Start empty or select a discovered"," ",a?"theme":"document"," as a starting point"]}),c.jsx(ra,{})]})})]}),c.jsx(zr,{children:c.jsx(Ie,{type:"submit",variant:d[e].buttonVariant,disabled:o,children:o?c.jsxs(c.Fragment,{children:[c.jsx(Qt,{size:"sm",className:"mr-2"}),e==="create"?"Creating...":e==="update"?"Saving...":"Deleting..."]}):d[e].button})})]})})}const Si=Ee.memo(Vg),Ug=pm,Jg=hm,Hg=v.forwardRef(({className:e,inset:t,children:n,...r},i)=>c.jsxs(bc,{ref:i,className:U("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(Hi,{className:"ml-auto h-4 w-4"})]}));Hg.displayName=bc.displayName;const qg=v.forwardRef(({className:e,...t},n)=>c.jsx(vc,{ref:n,className:U("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}));qg.displayName=vc.displayName;const bd=v.forwardRef(({className:e,...t},n)=>c.jsx(mm,{children:c.jsx(gc,{ref:n,className:U("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})}));bd.displayName=gc.displayName;const mr=v.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(xc,{ref:r,className:U("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}));mr.displayName=xc.displayName;const Wg=v.forwardRef(({className:e,children:t,checked:n,...r},i)=>c.jsxs(wc,{ref:i,className:U("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(kc,{children:c.jsx(kn,{className:"h-4 w-4"})})}),t]}));Wg.displayName=wc.displayName;const Gg=v.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Sc,{ref:r,className:U("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(kc,{children:c.jsx(Lc,{className:"h-4 w-4 fill-current"})})}),t]}));Gg.displayName=Sc.displayName;const Kg=v.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(_c,{ref:r,className:U("text-foreground px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Kg.displayName=_c.displayName;const ia=v.forwardRef(({className:e,...t},n)=>c.jsx(yc,{ref:n,className:U("bg-border -mx-1 my-1 h-px",e),...t}));ia.displayName=yc.displayName;const di=({className:e,...t})=>c.jsx("span",{className:U("text-muted-foreground ml-auto text-xs tracking-widest",e),...t});di.displayName="ContextMenuShortcut";const vd=v.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},i)=>c.jsx(Cc,{ref:i,decorative:n,orientation:t,className:U("bg-border shrink-0",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));vd.displayName=Cc.displayName;const wd=sc,Yg=ac,Xg=oc,kd=v.forwardRef(({className:e,...t},n)=>c.jsx(Ji,{className:U("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}));kd.displayName=Ji.displayName;const Qg=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"}}),Ka=v.forwardRef(({side:e="right",className:t,children:n,...r},i)=>c.jsxs(Xg,{children:[c.jsx(kd,{}),c.jsxs(Bi,{ref:i,className:U(Qg({side:e}),t),...r,children:[c.jsxs(Ma,{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(wn,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]}),n]})]}));Ka.displayName=Bi.displayName;const ex=v.forwardRef(({className:e,...t},n)=>c.jsx(Vi,{ref:n,className:U("text-foreground text-lg font-semibold",e),...t}));ex.displayName=Vi.displayName;const tx=v.forwardRef(({className:e,...t},n)=>c.jsx(Ui,{ref:n,className:U("text-muted-foreground text-sm",e),...t}));tx.displayName=Ui.displayName;function Cr({className:e,...t}){return c.jsx("div",{className:U("bg-primary/10 animate-pulse rounded-md",e),...t})}const xs=768,ys=1200;function Sd(e){return typeof window<"u"?window.innerWidth<e:!1}function _d(){const[e,t]=v.useState(()=>Sd(xs));return v.useEffect(()=>{const n=window.matchMedia(`(max-width: ${xs-1}px)`),r=()=>{t(window.innerWidth<xs)};return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}function nx(){const[e,t]=v.useState(()=>Sd(ys));return v.useEffect(()=>{const n=window.matchMedia(`(max-width: ${ys-1}px)`),r=()=>{t(window.innerWidth<ys)};return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}const rx="sidebar_state",ix=60*60*24*7,sx="16rem",ax="18rem",ox="3rem",lx="b",Cd=v.createContext(null);function Xi(){const e=v.useContext(Cd);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const jd=v.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:s,...a},o)=>{const l=_d(),[u,f]=v.useState(!1),[d,h]=v.useState(e),p=t??d,m=v.useCallback(_=>{const x=typeof _=="function"?_(p):_;n?n(x):h(x),document.cookie=`${rx}=${x}; path=/; max-age=${ix}`},[n,p]),w=v.useCallback(()=>l?f(_=>!_):m(_=>!_),[l,m,f]);v.useEffect(()=>{const _=P=>{var C;const E=P;if(!E)return!1;const k=(C=E.tagName)==null?void 0:C.toLowerCase();return k==="input"||k==="textarea"||k==="select"||E.isContentEditable?!0:!!(E.closest&&E.closest(".monaco-editor"))},x=P=>{const E=P.metaKey||P.ctrlKey,k=P.key.toLowerCase();if(E&&k===lx){P.preventDefault(),w();return}E&&k==="s"&&!_(P.target)&&(P.preventDefault(),w())};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[w]);const S=p?"expanded":"collapsed",y=v.useMemo(()=>({state:S,open:p,setOpen:m,isMobile:l,openMobile:u,setOpenMobile:f,toggleSidebar:w}),[S,p,m,l,u,f,w]);return c.jsx(Cd.Provider,{value:y,children:c.jsx(rm,{delayDuration:0,children:c.jsx("div",{style:{"--sidebar-width":sx,"--sidebar-width-icon":ox,...i},className:U("group/sidebar-wrapper has-[[data-variant=inset]]:bg-sidebar flex min-h-svh w-full",r),ref:o,...a,children:s})})})});jd.displayName="SidebarProvider";const Nd=v.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:i,...s},a)=>{const{isMobile:o,state:l,openMobile:u,setOpenMobile:f}=Xi();return n==="none"?c.jsx("div",{className:U("bg-sidebar text-sidebar-foreground flex h-full w-[--sidebar-width] flex-col",r),ref:a,...s,children:i}):o?c.jsx(wd,{open:u,onOpenChange:f,...s,children:c.jsx(Ka,{"data-sidebar":"sidebar","data-mobile":"true",className:"bg-sidebar text-sidebar-foreground w-[--sidebar-width] p-0 [&>button]:hidden",style:{"--sidebar-width":ax},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:U("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:U("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})})]})});Nd.displayName="Sidebar";const ux=v.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:i}=Xi();return c.jsxs(Ie,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:U("h-7 w-7",e),onClick:s=>{t==null||t(s),i()},...n,children:[c.jsx(Im,{}),c.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});ux.displayName="SidebarTrigger";const cx=v.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=Xi();return c.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:U("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})});cx.displayName="SidebarRail";const dx=v.forwardRef(({className:e,...t},n)=>c.jsx("main",{ref:n,className:U("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}));dx.displayName="SidebarInset";const fx=v.forwardRef(({className:e,...t},n)=>c.jsx(Ha,{ref:n,"data-sidebar":"input",className:U("bg-background focus-visible:ring-sidebar-ring h-8 w-full shadow-none focus-visible:ring-2",e),...t}));fx.displayName="SidebarInput";const Ed=v.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"header",className:U("flex flex-col gap-2 p-2",e),...t}));Ed.displayName="SidebarHeader";const Id=v.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"footer",className:U("flex flex-col gap-2 p-2",e),...t}));Id.displayName="SidebarFooter";const zd=v.forwardRef(({className:e,...t},n)=>c.jsx(vd,{ref:n,"data-sidebar":"separator",className:U("bg-sidebar-border mx-2 w-auto",e),...t}));zd.displayName="SidebarSeparator";const Td=v.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"content",className:U("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Td.displayName="SidebarContent";const fi=v.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"group",className:U("relative flex w-full min-w-0 flex-col p-2",e),...t}));fi.displayName="SidebarGroup";const pi=v.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?tr:"div";return c.jsx(i,{ref:r,"data-sidebar":"group-label",className:U("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})});pi.displayName="SidebarGroupLabel";const px=v.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?tr:"button";return c.jsx(i,{ref:r,"data-sidebar":"group-action",className:U("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})});px.displayName="SidebarGroupAction";const gr=v.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"group-content",className:U("w-full text-sm",e),...t}));gr.displayName="SidebarGroupContent";const sa=v.forwardRef(({className:e,...t},n)=>c.jsx("ul",{ref:n,"data-sidebar":"menu",className:U("flex w-full min-w-0 flex-col gap-1",e),...t}));sa.displayName="SidebarMenu";const Ad=v.forwardRef(({className:e,...t},n)=>c.jsx("li",{ref:n,"data-sidebar":"menu-item",className:U("group/menu-item relative",e),...t}));Ad.displayName="SidebarMenuItem";const hx=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"}}),Pd=v.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:i,className:s,...a},o)=>{const l=e?tr:"button",{isMobile:u,state:f}=Xi(),d=c.jsx(l,{ref:o,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:U(hx({variant:n,size:r}),s),...a});return i?(typeof i=="string"&&(i={children:i}),c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:d}),c.jsx(Ye,{side:"right",align:"center",hidden:f!=="collapsed"||u,...i})]})):d});Pd.displayName="SidebarMenuButton";const mx=v.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},i)=>{const s=t?tr:"button";return c.jsx(s,{ref:i,"data-sidebar":"menu-action",className:U("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})});mx.displayName="SidebarMenuAction";const gx=v.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:U("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}));gx.displayName="SidebarMenuBadge";const xx=v.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{const i=v.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return c.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:U("flex h-8 items-center gap-2 rounded-md px-2",e),...n,children:[t&&c.jsx(Cr,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),c.jsx(Cr,{className:"h-4 max-w-[--skeleton-width] flex-1","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":i}})]})});xx.displayName="SidebarMenuSkeleton";const yx=v.forwardRef(({className:e,...t},n)=>c.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:U("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}));yx.displayName="SidebarMenuSub";const bx=v.forwardRef(({...e},t)=>c.jsx("li",{ref:t,...e}));bx.displayName="SidebarMenuSubItem";const vx=v.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...i},s)=>{const a=e?tr:"a";return c.jsx(a,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:U("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})});vx.displayName="SidebarMenuSubButton";function aa(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 wx=typeof window<"u"?navigator.userAgent.toUpperCase().indexOf("MAC")>=0:!1;function kx({document:e,indicator:t,compact:n=!1}){const r=v.useRef(null),[i,s]=v.useState(!1),[a,o]=v.useState(!1),[l,u]=v.useState(!1),{openDocument:f,documentTypes:d,activeTab:h}=Xe(T=>T),{name:p,text:m,isGenerating:w}=mn(T=>T),y=(d[e.name]||"application/json+report")==="application/json+theme",_=h===e.name,[x,P]=v.useState(p),[E,k]=v.useState(m),C=100,V=0;v.useEffect(()=>{const T=setTimeout(()=>{p&&m?(P(p),k(m)):w||(P(""),k(""))},w?C:V);return()=>clearTimeout(T)},[p,m,w]);const Y=x===e.name,N=T=>{var K;const H=new Set;try{const O=JSON.parse(T);(K=O.props)!=null&&K.theme&&H.add(O.props.theme),O.children&&Array.isArray(O.children)&&O.children.forEach(W=>{var b;W.name==="docx"&&((b=W.props)!=null&&b.theme)&&H.add(W.props.theme)})}catch{}return H},Z=v.useMemo(()=>{if(!y||!E)return!1;try{const T=JSON.parse(e.text),H=Xs(T);if(H)return N(E).has(H)}catch{}return!1},[y,E,e.text,e.name,x]),D=v.useCallback(()=>{o(!1)},[]),B=v.useCallback(()=>{u(!1)},[]),F=c.jsxs(Pd,{variant:"default",size:"default",ref:r,className:U("text-sidebar-foreground focus:bg-accent focus:text-accent-foreground w-full",n?"justify-center px-1":"justify-start gap-2",i&&"bg-accent text-accent-foreground",_&&(n?"bg-green-50 text-green-700 dark:bg-green-900/20 dark:text-green-300":"bg-green-50 border-l-2 border-green-500 text-green-700 dark:bg-green-900/20 dark:border-green-400 dark:text-green-300"),Y&&!_&&(n?"bg-blue-50 text-blue-700 dark:bg-blue-900/20 dark:text-blue-300":"bg-blue-50 border-l-2 border-blue-500 text-blue-700 dark:bg-blue-900/20 dark:border-blue-400 dark:text-blue-300"),Z&&!_&&!Y&&(n?"bg-purple-50 text-purple-700 dark:bg-purple-900/20 dark:text-purple-300":"bg-purple-50 border-l-2 border-purple-500 text-purple-700 dark:bg-purple-900/20 dark:border-purple-400 dark:text-purple-300")),title:e.name,onClick:()=>{f(e.name)},onKeyDown:T=>{var H;(T.ctrlKey||T.metaKey)&&T.key==="Enter"?(f(e.name),T.preventDefault()):T.key==="Enter"?(o(!0),T.preventDefault()):T.key==="Backspace"||T.key==="Delete"?(u(!0),T.preventDefault()):T.key==="Escape"&&((H=r.current)==null||H.blur(),T.preventDefault())},children:[_?c.jsx(Po,{className:U("size-4","text-green-600 dark:text-green-400")}):Y?c.jsx(Po,{className:U("size-4","text-blue-600 dark:text-blue-400")}):y?c.jsx(Gs,{className:"size-4 text-purple-600 dark:text-purple-400"}):c.jsx(Zc,{className:"size-4 text-blue-600 dark:text-blue-400"}),!n&&c.jsx("span",{className:U("truncate flex-1",y&&!_&&!Y&&!Z&&"text-purple-700 dark:text-purple-300",(_||Y||Z)&&"font-medium"),children:e.name})]});return c.jsxs(Ad,{children:[c.jsxs(Ug,{onOpenChange:s,children:[c.jsx(Jg,{children:n?c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:F}),c.jsx(Ye,{side:"right",children:c.jsxs("div",{className:"text-xs",children:[e.name,y?c.jsx("div",{className:"opacity-70",children:"Theme"}):c.jsx("div",{className:"opacity-70",children:"Document"})]})})]}):F}),c.jsxs(bd,{children:[c.jsxs(mr,{onClick:()=>f(e.name),children:["Open",c.jsx(di,{children:wx?"⌘⏎":"⌃⏎"})]}),c.jsx(ia,{}),c.jsx(mr,{disabled:!e,onClick:()=>{e&&aa(e.name,new Blob([e.text],{type:e.type}))},children:"Download..."}),c.jsx(ia,{}),c.jsxs(mr,{onClick:()=>o(!0),children:["Rename...",c.jsx(di,{children:"⏎"})]}),c.jsxs(mr,{onClick:()=>u(!0),children:["Delete",c.jsx(di,{children:"⌫"})]})]})]}),c.jsx(qt,{open:a,onOpenChange:o,children:c.jsx(Zt,{className:"sm:max-w-[425px]",onCloseAutoFocus:T=>{var H;T.preventDefault(),(H=r.current)==null||H.focus()},children:c.jsx(Si,{mode:"update",shouldReset:!a,postSubmit:D,selectedName:e.name})})}),c.jsx(qt,{open:l,onOpenChange:u,children:c.jsx(Zt,{className:"sm:max-w-[425px]",onCloseAutoFocus:T=>{var H;T.preventDefault(),(H=r.current)==null||H.focus()},children:c.jsx(Si,{mode:"delete",shouldReset:!l,postSubmit:B,selectedName:e.name})})})]})}const Go=Ee.memo(kx);async function Sx(e,t){const n=JSON.stringify({name:e,props:t,children:[]},null,2);await navigator.clipboard.writeText(n)}const _x=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 jr({className:e,variant:t,...n}){return c.jsx("div",{className:U(_x({variant:t}),e),...n})}const Ar=v.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(jc,{ref:r,className:U("relative overflow-hidden",e),...n,children:[c.jsx(gm,{className:"h-full w-full rounded-[inherit]",children:t}),c.jsx(Od,{}),c.jsx(xm,{})]}));Ar.displayName=jc.displayName;const Od=v.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(Nc,{ref:r,orientation:t,className:U("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(ym,{className:"bg-border relative flex-1 rounded-full"})}));Od.displayName=Nc.displayName;function Ya({className:e,...t}){return c.jsx(bm,{"data-slot":"switch",className:U("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(vm,{"data-slot":"switch-thumb",className:U("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 Cx=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"}}),oa=v.forwardRef(({className:e,variant:t,...n},r)=>c.jsx("div",{ref:r,role:"alert",className:U(Cx({variant:t}),e),...n}));oa.displayName="Alert";const jx=v.forwardRef(({className:e,...t},n)=>c.jsx("h5",{ref:n,className:U("mb-1 font-medium leading-none tracking-tight",e),...t}));jx.displayName="AlertTitle";const la=v.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:U("text-sm [&_p]:leading-relaxed",e),...t}));la.displayName="AlertDescription";const _i=v.memo(({keyName:e,value:t,depth:n=0,isLast:r=!1})=>{const[i,s]=v.useState(n<2),a=t!==null&&typeof t=="object",o=Array.isArray(t),l=()=>s(!i),u=()=>t===null?c.jsx("span",{className:"text-orange-500",children:"null"}):t===void 0?c.jsx("span",{className:"text-gray-500",children:"undefined"}):typeof t=="boolean"?c.jsx("span",{className:"text-blue-500",children:String(t)}):typeof t=="number"?c.jsx("span",{className:"text-green-500",children:t}):typeof t=="string"?t.startsWith("http")?c.jsxs("span",{className:"text-purple-500",children:['"',t,'"']}):t.startsWith("#/")?c.jsxs("span",{className:"text-cyan-500",children:['"',t,'"']}):c.jsxs("span",{className:"text-amber-600",children:['"',t,'"']}):null,f=a?Object.keys(t).length:0;return c.jsxs("div",{className:U("text-sm",n>0&&"ml-4"),children:[c.jsxs("div",{className:"flex items-start hover:bg-muted/30 rounded px-1 py-0.5",children:[a&&c.jsx("button",{onClick:l,className:"mr-1 hover:bg-muted rounded p-0.5","aria-label":i?"Collapse":"Expand",children:i?c.jsx(rn,{className:"h-3 w-3"}):c.jsx(Hi,{className:"h-3 w-3"})}),!a&&c.jsx("span",{className:"w-4"}),e&&c.jsxs(c.Fragment,{children:[c.jsxs("span",{className:"text-blue-600 dark:text-blue-400",children:['"',e,'"']}),c.jsx("span",{className:"mx-1",children:":"})]}),a?c.jsxs("span",{className:"text-muted-foreground",children:[o?"[":"{",!i&&c.jsxs("span",{className:"mx-1 text-xs",children:[f," ",o?"items":"properties"]}),!i&&(o?"]":"}")]}):u(),!a&&!r&&c.jsx("span",{className:"text-muted-foreground",children:","})]}),a&&i&&c.jsxs("div",{className:"ml-4",children:[o?t.map((d,h)=>c.jsx(_i,{keyName:String(h),value:d,depth:n+1,isLast:h===t.length-1},h)):Object.entries(t).map(([d,h],p,m)=>c.jsx(_i,{keyName:d,value:h,depth:n+1,isLast:p===m.length-1},d)),c.jsx("div",{className:"ml-4",children:c.jsxs("span",{className:"text-muted-foreground",children:[o?"]":"}",!r&&","]})})]})]})});_i.displayName="JsonNode";const Ci=v.memo(({schema:e,loading:t=!1,error:n,className:r})=>t?c.jsxs("div",{className:U("space-y-4",r),children:[c.jsx(Cr,{className:"h-8 w-64"}),c.jsx(Cr,{className:"h-4 w-full"}),c.jsx(Cr,{className:"h-64 w-full"})]}):n?c.jsx(oa,{variant:"destructive",className:r,children:c.jsx(la,{children:n})}):e?c.jsx(Ar,{className:U("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(_i,{value:e})})}):c.jsx(oa,{className:r,children:c.jsx(la,{children:"No schema available"})}));Ci.displayName="SchemaViewer";function Nx({plugins:e,initialFocusedPlugin:t}){var x,P;const n=Pt(E=>E.togglePlugin),r=Pt(E=>E.isPluginSelected),i=Pt(E=>E.selectedPlugins),s=Pt(E=>E.isApplyingPlugins),[a,o]=v.useState(null),[l,u]=v.useState(null),[f,d]=v.useState("properties");v.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=v.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 Sx(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(Om,{className:"size-3"});case"downstream":return c.jsx(Pm,{className:"size-3"});case"upstream":return c.jsx(Zc,{className:"size-3"});default:return null}},S=((x=a==null?void 0:a.schema)==null?void 0:x.properties)&&Object.keys(a.schema.properties).length>0,y=(P=a==null?void 0:a.schema)==null?void 0:P.jsonSchema,_=(a==null?void 0:a.examples)&&a.examples.length>0;return c.jsxs(c.Fragment,{children:[c.jsxs(Sn,{children:[c.jsxs(_n,{className:"flex items-center gap-2",children:[c.jsx(Bc,{className:"size-5 text-amber-600 dark:text-amber-400"}),"Plugins",c.jsxs(jr,{variant:"secondary",className:"font-normal",children:[i.size," active"]})]}),c.jsxs(Gn,{children:[e.length," plugin",e.length!==1?"s":""," discovered in your project"]})]}),c.jsxs("div",{className:"mt-3 flex gap-0 h-[600px] border rounded-lg overflow-hidden",children:[c.jsx("div",{className:"w-[240px] flex-none border-r bg-muted/30",children:c.jsx(Ar,{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(C=>{const V=r(C.name),Y=(a==null?void 0:a.name)===C.name;return c.jsxs("button",{onClick:()=>o(C),className:U("w-full text-left px-2 py-1.5 rounded-md transition-colors cursor-pointer","flex items-center gap-2",Y?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"),children:[c.jsx("div",{className:U("size-1.5 rounded-full flex-none transition-colors",V?"bg-amber-500 dark:bg-amber-400":"bg-muted-foreground/30")}),c.jsx("span",{className:"text-sm font-medium truncate flex-1",children:C.name})]},C.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(jr,{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:()=>d("properties"),className:U("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",f==="properties"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(Oo,{className:"size-3.5"}),"Properties"]})}),y&&c.jsx("button",{onClick:()=>d("schema"),className:U("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",f==="schema"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(zm,{className:"size-3.5"}),"Schema"]})}),_&&c.jsx("button",{onClick:()=>d("examples"),className:U("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",f==="examples"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(Tm,{className:"size-3.5"}),"Examples",c.jsx(jr,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-4",children:a.examples.length})]})})]}),c.jsx(Ar,{className:"flex-1",children:c.jsxs("div",{className:"p-5",children:[f==="properties"&&S&&c.jsx("div",{className:"space-y-1",children:Object.entries(a.schema.properties).map(([E,k])=>c.jsx(Ex,{name:E,prop:k},E))}),f==="schema"&&y&&c.jsx(Ci,{schema:a.schema.jsonSchema,loading:!1,className:"h-[420px]"}),f==="examples"&&_&&a.examples.map((E,k)=>c.jsxs("div",{className:U(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(Ie,{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(Am,{className:"size-3 mr-1 text-green-600"}),"Copied"]}):c.jsxs(c.Fragment,{children:[c.jsx($a,{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&&!y&&!_&&c.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[c.jsx(Oo,{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 Ex({name:e,prop:t}){var a;const[n,r]=v.useState(!1),i=t.description||t.enum||t.default!==void 0||t.items||t.properties,s=t.type||(t.enum?"enum":t.oneOf?"oneOf":"—");return c.jsxs("div",{className:"rounded-md border",children:[c.jsxs("button",{onClick:()=>i&&r(!n),className:U("w-full text-left flex items-center gap-2 px-3 py-2 text-sm",i&&"cursor-pointer hover:bg-muted/50"),children:[i?n?c.jsx(rn,{className:"size-3 text-muted-foreground flex-none"}):c.jsx(Hi,{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(jr,{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 bs=wm,vs=km,ws=Sm,Dd=_m,Rd=Cm,Ix=v.forwardRef(({className:e,inset:t,children:n,...r},i)=>c.jsxs(Tc,{ref:i,className:U("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(Hi,{className:"ml-auto"})]}));Ix.displayName=Tc.displayName;const zx=v.forwardRef(({className:e,...t},n)=>c.jsx(Ac,{ref:n,className:U("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-lg",e),...t}));zx.displayName=Ac.displayName;const Xa=v.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(jm,{children:c.jsx(Ec,{ref:r,sideOffset:t,className:U("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})}));Xa.displayName=Ec.displayName;const tn=v.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Ic,{ref:r,className:U("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm transition-colors outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",t&&"pl-8",e),...n}));tn.displayName=Ic.displayName;const Tx=v.forwardRef(({className:e,children:t,checked:n,...r},i)=>c.jsxs(Pc,{ref:i,className:U("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(Oc,{children:c.jsx(kn,{className:"h-4 w-4"})})}),t]}));Tx.displayName=Pc.displayName;const Ax=v.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Dc,{ref:r,className:U("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(Oc,{children:c.jsx(Lc,{className:"h-2 w-2 fill-current"})})}),t]}));Ax.displayName=Dc.displayName;const Px=v.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Rc,{ref:r,className:U("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Px.displayName=Rc.displayName;const ji=v.forwardRef(({className:e,...t},n)=>c.jsx(zc,{ref:n,className:U("bg-muted -mx-1 my-1 h-px",e),...t}));ji.displayName=zc.displayName;function Ox(){const{theme:e,setTheme:t}=rc(),n=e==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e,r=v.useCallback(()=>{t(n==="dark"?"light":"dark")},[n,t]);return c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsxs(Ie,{variant:"ghost",size:"icon",onClick:r,children:[c.jsx(Dm,{className:"hidden dark:block"}),c.jsx(Rm,{className:"block dark:hidden"}),c.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),c.jsx(Ye,{children:c.jsx("p",{children:"Toggle theme"})})]})}const Dx=Nm,Md=v.forwardRef(({className:e,...t},n)=>c.jsx(Mc,{ref:n,className:U("bg-muted text-muted-foreground inline-flex h-9 items-center justify-center rounded-lg p-1",e),...t}));Md.displayName=Mc.displayName;const ua=v.forwardRef(({className:e,...t},n)=>c.jsx($c,{ref:n,className:U("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}));ua.displayName=$c.displayName;const ca=v.forwardRef(({className:e,...t},n)=>c.jsx(Fc,{ref:n,className:U("ring-offset-background focus-visible:ring-ring mt-2 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",e),...t}));ca.displayName=Fc.displayName;async function Rx(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 Mx(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 $x(e){const t=Mx(e);return Rx(t)}const $d=({open:e,onOpenChange:t,defaultTab:n="document"})=>{const[r,i]=v.useState(n),[s,a]=v.useState(null),[o,l]=v.useState(null),[u,f]=v.useState(!1),[d,h]=v.useState(!1),[p,m]=v.useState(null),[w,S]=v.useState(null),[y,_]=v.useState(!1),{toast:x}=Ra(),P=Pt(B=>B.selectedPlugins),E=Array.from(P);v.useEffect(()=>{n&&i(n)},[n]);const k=v.useCallback(async()=>{f(!0),m(null);try{const B=await ps.fetchDocumentSchema(E);a(B)}catch(B){const F=B instanceof Error?B.message:"Failed to load document schema";m(F),x({variant:"destructive",title:"Error loading schema",description:F})}finally{f(!1)}},[E,x]),C=v.useCallback(async()=>{if(!o){h(!0),S(null);try{const B=await ps.fetchThemeSchema();l(B)}catch(B){const F=B instanceof Error?B.message:"Failed to load theme schema";S(F),x({variant:"destructive",title:"Error loading schema",description:F})}finally{h(!1)}}},[o,x]),[V,Y]=v.useState([]);v.useEffect(()=>{e||(a(null),m(null))},[e]),v.useEffect(()=>{if(!e)return;const B=E.length!==V.length||E.some((F,T)=>F!==V[T]);r==="document"?(!s||B)&&(B&&(ps.clearPluginSchemaCache(),Y([...E])),u||k()):r==="theme"&&!o&&!d&&C()},[r,e,s,o,u,d,E,V,k,C]);const N=E.length,Z=r==="document"?s:o,D=async()=>{if(Z)try{await $x(Z)&&(_(!0),x({title:"Schema copied",description:"The JSON schema has been copied to your clipboard"}),setTimeout(()=>_(!1),2e3))}catch(B){console.error("Copy failed:",B)}};return c.jsx(qt,{open:e,onOpenChange:t,children:c.jsxs(Zt,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[c.jsx(Sn,{children:c.jsx(_n,{children:"Schema Viewer"})}),c.jsxs(Dx,{value:r,onValueChange:B=>i(B),className:"flex-1 overflow-hidden flex flex-col",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Md,{children:[c.jsxs(ua,{value:"document",className:"flex items-center gap-1",children:["Document",N>0&&c.jsxs(jr,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:["+",N]})]}),c.jsx(ua,{value:"theme",children:"Theme"})]}),c.jsx("div",{className:"ml-auto",children:c.jsx(Ie,{variant:"ghost",size:"icon",onClick:D,disabled:y||!Z,"aria-label":"Copy schema",children:y?c.jsx(kn,{className:"h-4 w-4"}):c.jsx($a,{className:"h-4 w-4"})})})]}),c.jsxs("div",{className:"flex-1 overflow-auto mt-4",children:[c.jsx(ca,{value:"document",className:"h-full",children:c.jsx(Ci,{schema:s,loading:u,error:p||void 0})}),c.jsx(ca,{value:"theme",className:"h-full",children:c.jsx(Ci,{schema:o,loading:d,error:w||void 0})})]})]})]})})};function Fx({discoveryData:e,onToggleSidebar:t,isCollapsed:n=!1,isAnimating:r=!1}){const{documents:i,documentTypes:s,createDocument:a,openDocument:o}=Xe(ug(I=>({documents:I.documents,documentTypes:I.documentTypes,createDocument:I.createDocument,openDocument:I.openDocument}))),l=Ys(I=>I.updateTheme),u=Ys(I=>I.removeTheme),f=v.useContext(Xm),[d,h]=v.useState(!1),[p,m]=v.useState(!1),[w,S]=v.useState(!1),[y,_]=v.useState(null),x=Pt(I=>I.togglePlugin),P=Pt(I=>I.isPluginSelected),E=Pt(I=>I.selectedPlugins),k=Pt(I=>I.isApplyingPlugins),[C,V]=v.useState(!1),[Y,N]=v.useState(new Set(["current-docs","current-themes"])),{toast:Z}=Ra(),D=i.filter(I=>s[I.name]!=="application/json+theme"),B=i.filter(I=>s[I.name]==="application/json+theme"),F=v.useMemo(()=>{if(!e)return{current:[],downstream:[]};const I={current:[],downstream:[]};return e.documents.forEach(R=>{I[R.location]&&I[R.location].push(R)}),I},[e]),T=v.useMemo(()=>{if(!e)return{current:[],downstream:[]};const I={current:[],downstream:[]};return e.themes.forEach(R=>{I[R.location]&&I[R.location].push(R)}),I},[e]),H=v.useMemo(()=>{const I=new Set;return D.forEach(R=>{try{const J=JSON.parse(R.text);J.children&&Array.isArray(J.children)&&J.children.forEach(oe=>{var pe;oe.name==="docx"&&((pe=oe.props)!=null&&pe.theme)&&I.add(oe.props.theme)})}catch{}}),I},[D]),K=v.useCallback(()=>{h(!1)},[]),O=v.useCallback(()=>{m(!1)},[]),W=v.useRef(new Map);v.useEffect(()=>{const I=W.current,R=new Map;B.forEach(J=>{R.set(J.name,J.text),I.get(J.name)!==J.text&&l(J.name,J.text)}),I.forEach((J,oe)=>{R.has(oe)||u(oe)}),W.current=R},[B,l,u]);const b=v.useRef(!1);v.useEffect(()=>{if(b.current||!f)return;b.current=!0;const I=new Set(B.map(J=>J.name));Object.keys(f.getState().customThemes).forEach(J=>{I.has(J)||u(J)})},[B,u,f]);const ue=I=>{N(R=>{const J=new Set(R);return J.has(I)?J.delete(I):J.add(I),J})},ae=Xe(I=>I.activeTab),g=ae&&s[ae]==="application/json+theme"?"theme":"document",{resolvedTheme:G}=rc(),ie=G==="dark"?"https://ik.imagekit.io/wiseair/Brand%20assets/wiseair-logo-white.svg?updatedAt=1751359555877":"https://ik.imagekit.io/wiseair/Brand%20assets/wiseair-logo.svg?updatedAt=1749817149276",Q=v.useCallback(async(I,R)=>{if(i.some(J=>J.name===I)){o(I);return}try{const J=await fetch(`/api/discovery/${R?"themes":"documents"}/${encodeURIComponent(I)}/content`);if(!J.ok)throw new Error(J.statusText);const oe=await J.text(),pe=JSON.parse(oe);a(I,JSON.stringify(pe,null,2)),o(I),Z({title:`Added ${R?"theme":"document"}: ${I}`})}catch{Z({title:"Failed to load",description:`Could not load ${I}`,variant:"destructive"})}},[i,a,o,Z]);return c.jsxs(c.Fragment,{children:[c.jsxs(Nd,{collapsible:"none",style:{"--sidebar-width":n?"3rem":"16rem"},children:[c.jsx(Ed,{children:c.jsx("div",{className:U("flex items-center transition-opacity duration-150 ease-out",r?"opacity-0":"opacity-100",n?"justify-center":"justify-between"),children:n?c.jsx(Ie,{variant:"ghost",size:"icon","aria-label":"Expand sidebar","aria-expanded":!1,onClick:t,children:c.jsx(Vc,{className:"h-4 w-4"})}):c.jsxs(c.Fragment,{children:[c.jsx("a",{href:"/",className:"flex items-center pl-2",children:c.jsx("img",{src:ie,alt:"WiseAir logo",className:"h-5 w-auto max-w-[120px] shrink-0"})}),c.jsx("div",{className:"flex items-center gap-1",children:c.jsx(Ie,{variant:"ghost",size:"icon","aria-label":"Collapse sidebar","aria-expanded":!0,onClick:t,children:c.jsx(Mm,{className:"h-4 w-4"})})})]})})}),c.jsxs(Td,{className:U("h-full transition-opacity duration-150 ease-out",r?"opacity-0":"opacity-100"),children:[c.jsxs(fi,{children:[c.jsxs(pi,{className:U("flex items-center",n?"justify-center":"justify-between"),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[!n&&c.jsx(Do,{className:"size-3"}),!n&&c.jsx("span",{children:"Active Documents"})]}),c.jsxs(qt,{open:d,onOpenChange:h,children:[c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(Ho,{asChild:!0,children:c.jsx(Ie,{className:U("p-0 flex-shrink-0",n?"mx-auto h-8 w-8 rounded border border-dashed border-sidebar-foreground/20 hover:border-sidebar-foreground/40":"h-6 w-6"),variant:"ghost",size:"icon",children:c.jsx(yi,{className:n?"size-3.5":"size-4"})})})}),c.jsx(Ye,{side:n?"right":"bottom",children:c.jsx("span",{className:"text-xs",children:"New Document"})})]}),c.jsx(Zt,{className:"sm:max-w-[525px]",children:c.jsx(Si,{mode:"create",shouldReset:!d,postSubmit:K,discoveredDocuments:(e==null?void 0:e.documents)||[]})})]})]}),n?c.jsx(gr,{children:c.jsx("div",{className:"flex flex-col items-center gap-0.5 px-0.5",children:D.map(I=>{const R=ae===I.name;return c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsxs("button",{onClick:()=>o(I.name),"aria-label":I.name,className:U("relative w-8 h-8 rounded flex items-center justify-center text-[11px] font-bold transition-colors cursor-pointer",R?"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:[R&&c.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-0.5 rounded-full bg-green-500 dark:bg-green-400"}),I.name.replace(/\.[^.]+$/,"").slice(0,2).toUpperCase()]})}),c.jsx(Ye,{side:"right",children:c.jsx("span",{className:"text-xs",children:I.name})})]},I.name)})})}):c.jsx(gr,{children:c.jsx(sa,{children:D.length>0?D.map((I,R)=>c.jsx(Go,{document:I,compact:n},`doc-${R}`)):c.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No active documents. Click + to create one."})})})]}),c.jsx(zd,{}),c.jsxs(fi,{children:[c.jsxs(pi,{className:U("flex items-center",n?"justify-center":"justify-between"),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[!n&&c.jsx(Gs,{className:"size-3 text-purple-600 dark:text-purple-400"}),!n&&c.jsx("span",{children:"Active Themes"})]}),c.jsxs(qt,{open:p,onOpenChange:m,children:[c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(Ho,{asChild:!0,children:c.jsx(Ie,{className:U("p-0 flex-shrink-0",n?"mx-auto h-8 w-8 rounded border border-dashed border-sidebar-foreground/20 hover:border-sidebar-foreground/40":"h-6 w-6"),variant:"ghost",size:"icon",children:c.jsx(yi,{className:n?"size-3.5":"size-4"})})})}),c.jsx(Ye,{side:n?"right":"bottom",children:c.jsx("span",{className:"text-xs",children:"New Theme"})})]}),c.jsx(Zt,{className:"sm:max-w-[525px]",children:c.jsx(Si,{mode:"create",shouldReset:!p,postSubmit:O,discoveredThemes:(e==null?void 0:e.themes)||[],isTheme:!0})})]})]}),n?c.jsx(gr,{children:c.jsx("div",{className:"flex flex-col items-center gap-0.5 px-0.5",children:B.map(I=>{const R=ae===I.name;let J=null;try{const pe=JSON.parse(I.text);J=Xs(pe)}catch{}const oe=J?H.has(J):!1;return c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsxs("button",{onClick:()=>o(I.name),"aria-label":I.name,className:U("relative w-8 h-8 rounded flex items-center justify-center text-[11px] font-bold transition-colors cursor-pointer",R?"bg-purple-100 text-purple-700 dark:bg-purple-900/40 dark:text-purple-300":oe?"bg-purple-50 text-purple-600 dark:bg-purple-900/20 dark:text-purple-400":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:[R&&c.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-0.5 rounded-full bg-purple-500 dark:bg-purple-400"}),(J||I.name).charAt(0).toUpperCase()]})}),c.jsx(Ye,{side:"right",children:c.jsxs("div",{className:"text-xs",children:[I.name,oe&&c.jsx("div",{className:"opacity-70",children:"In use"})]})})]},I.name)})})}):c.jsx(gr,{children:c.jsx(sa,{children:B.length>0?B.map((I,R)=>{let J=null;try{const pe=JSON.parse(I.text);J=Xs(pe)}catch{}const oe=J?H.has(J):!1;return c.jsx(Go,{document:I,compact:n,indicator:oe?"in-use":void 0},`theme-${R}`)}):c.jsxs("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:["No active themes."," ",e&&e.themes.length>0?"Click + to add one.":"No themes discovered in project."]})})})]}),!n&&e&&(e.documents.length>0||e.themes.length>0)&&c.jsxs(fi,{className:"mt-2 border-t pt-4",children:[c.jsxs(pi,{className:"flex items-center mb-2 gap-2",children:[c.jsx($m,{className:"size-3"}),c.jsx("span",{children:"Discovered Resources"})]}),c.jsxs(c.Fragment,{children:[Object.entries(F).map(([I,R])=>{if(R.length===0)return null;const J=`${I}-docs`,oe=Y.has(J);return c.jsxs(bs,{open:oe,children:[c.jsxs(vs,{className:"flex items-center gap-1 px-3 py-1 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors cursor-pointer w-full",onClick:()=>ue(J),children:[c.jsx(rn,{className:U("size-3 transition-transform",!oe&&"-rotate-90")}),c.jsx(Do,{className:"size-3"}),I==="current"?"Current Directory":"Project"," ","Documents (",R.length,")"]}),c.jsx(ws,{children:c.jsx("div",{className:"pl-4 space-y-0.5",children:R.map((pe,Ae)=>{const ke=i.some(be=>be.name===pe.name);return c.jsxs("button",{onClick:()=>Q(pe.name,!1),className:U("w-full text-left py-1 px-2 rounded text-sm transition-colors","border-l-2 border-blue-400/60 dark:border-blue-500/40","hover:bg-accent hover:text-accent-foreground",ke&&"opacity-50"),children:[c.jsx("div",{className:"font-medium truncate",children:pe.name}),pe.title&&c.jsx("div",{className:"text-xs text-muted-foreground truncate",children:pe.title})]},Ae)})})})]},J)}),Object.entries(T).map(([I,R])=>{if(R.length===0)return null;const J=`${I}-themes`,oe=Y.has(J);return c.jsxs(bs,{open:oe,children:[c.jsxs(vs,{className:"flex items-center gap-1 px-3 py-1 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors cursor-pointer w-full",onClick:()=>ue(J),children:[c.jsx(rn,{className:U("size-3 transition-transform",!oe&&"-rotate-90")}),c.jsx(Gs,{className:"size-3"}),I==="current"?"Current Directory":"Project"," ","Themes (",R.length,")"]}),c.jsx(ws,{children:c.jsx("div",{className:"pl-4 space-y-0.5",children:R.map((pe,Ae)=>{const ke=i.some(be=>be.name===pe.name);return c.jsxs("button",{onClick:()=>Q(pe.name,!0),className:U("w-full text-left py-1 px-2 rounded text-sm transition-colors","border-l-2 border-purple-400/60 dark:border-purple-500/40","hover:bg-accent hover:text-accent-foreground",ke&&"opacity-50"),children:[c.jsx("div",{className:"font-medium truncate",children:pe.name}),pe.description&&c.jsx("div",{className:"text-xs text-muted-foreground truncate",children:pe.description})]},Ae)})})})]},J)}),e&&e.plugins.length>0&&c.jsxs(bs,{open:Y.has("plugins"),children:[c.jsxs(vs,{className:"flex items-center gap-1 px-3 py-1 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors cursor-pointer w-full",onClick:()=>ue("plugins"),children:[c.jsx(rn,{className:U("size-3 transition-transform",!Y.has("plugins")&&"-rotate-90")}),c.jsx(Bc,{className:"size-3 text-amber-600 dark:text-amber-400"}),"Plugins (",E.size,"/",e.plugins.length,")"]}),c.jsx(ws,{children:c.jsx("div",{className:"pl-4 space-y-0.5",children:e.plugins.map((I,R)=>{const J=P(I.name);return c.jsxs("div",{className:U("py-1 px-2 text-sm border-l-2 flex items-center gap-2 group transition-colors",J?"border-amber-500 dark:border-amber-400 text-foreground":"border-amber-400/30 dark:border-amber-500/20 text-muted-foreground"),children:[c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"font-medium truncate",children:I.name}),I.description&&c.jsx("div",{className:"text-xs opacity-70 truncate",children:I.description})]}),c.jsx("button",{className:"flex-none size-5 flex items-center justify-center rounded-sm opacity-0 group-hover:opacity-100 hover:bg-accent transition-all cursor-pointer",title:`View details for ${I.name}`,onClick:oe=>{oe.stopPropagation(),_(I.name),S(!0)},children:c.jsx(Uc,{className:"size-3 text-muted-foreground"})}),c.jsx(Ya,{checked:J,onCheckedChange:()=>x(I),disabled:k,className:"flex-none scale-[0.8]","aria-label":`Toggle ${I.name} plugin`})]},R)})})})]})]})]})]}),c.jsx(Id,{children:c.jsx("div",{className:U("flex w-full items-center transition-opacity duration-150 ease-out",r?"opacity-0":"opacity-100",n?"justify-center":"justify-end pr-2"),children:c.jsx(Ox,{})})}),c.jsx(qt,{open:w,onOpenChange:I=>{S(I),I||_(null)},children:c.jsx(Zt,{className:"sm:max-w-5xl max-h-[85vh] overflow-hidden",children:c.jsx(Nx,{plugins:(e==null?void 0:e.plugins)||[],initialFocusedPlugin:y})})})]}),c.jsx($d,{open:C,onOpenChange:V,defaultTab:g==="theme"?"theme":"document"})]})}const Ko=v.memo(Fx),Lx=v.lazy(()=>ic(()=>import("./editor-Cjfikke2.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(e=>({default:e.Editor})));function Yo(){return c.jsx(v.Suspense,{fallback:c.jsx("div",{className:"flex items-center justify-center h-full",children:c.jsxs("div",{className:"text-center",children:[c.jsx(Qt,{className:"w-8 h-8 mx-auto mb-2"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading editor..."})]})}),children:c.jsx(Lx,{})})}const Zx=v.lazy(()=>ic(()=>import("./preview-CqOfvXmU.js"),__vite__mapDeps([12,1,3,4,5,6,7,8,9,10,11])).then(e=>({default:e.Preview})));function Xo(){return c.jsx(v.Suspense,{fallback:c.jsx("div",{className:"flex items-center justify-center h-full",children:c.jsxs("div",{className:"text-center",children:[c.jsx(Qt,{className:"w-8 h-8 mx-auto mb-2"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading preview..."})]})}),children:c.jsx(Zx,{})})}const{createElement:Kn,createContext:Bx,forwardRef:Fd,useCallback:dt,useContext:Ld,useEffect:bn,useImperativeHandle:Zd,useLayoutEffect:Vx,useMemo:Ux,useRef:mt,useState:Jn}=nc,Qo=nc[`useId${Math.random()}`.slice(0,5)],Jx=Vx,Qi=Bx(null);Qi.displayName="PanelGroupContext";const vn=Jx,Hx=typeof Qo=="function"?Qo:()=>null;let qx=0;function Qa(e=null){const t=Hx(),n=mt(e||t||null);return n.current===null&&(n.current=""+qx++),e??n.current}function Bd({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:i,forwardedRef:s,id:a,maxSize:o,minSize:l,onCollapse:u,onExpand:f,onResize:d,order:h,style:p,tagName:m="div",...w}){const S=Ld(Qi);if(S===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:y,expandPanel:_,getPanelSize:x,getPanelStyle:P,groupId:E,isPanelCollapsed:k,reevaluatePanelConstraints:C,registerPanel:V,resizePanel:Y,unregisterPanel:N}=S,Z=Qa(a),D=mt({callbacks:{onCollapse:u,onExpand:f,onResize:d},constraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:o,minSize:l},id:Z,idIsFromProps:a!==void 0,order:h});mt({didLogMissingDefaultSizeWarning:!1}),vn(()=>{const{callbacks:F,constraints:T}=D.current,H={...T};D.current.id=Z,D.current.idIsFromProps=a!==void 0,D.current.order=h,F.onCollapse=u,F.onExpand=f,F.onResize=d,T.collapsedSize=n,T.collapsible=r,T.defaultSize=i,T.maxSize=o,T.minSize=l,(H.collapsedSize!==T.collapsedSize||H.collapsible!==T.collapsible||H.maxSize!==T.maxSize||H.minSize!==T.minSize)&&C(D.current,H)}),vn(()=>{const F=D.current;return V(F),()=>{N(F)}},[h,Z,V,N]),Zd(s,()=>({collapse:()=>{y(D.current)},expand:F=>{_(D.current,F)},getId(){return Z},getSize(){return x(D.current)},isCollapsed(){return k(D.current)},isExpanded(){return!k(D.current)},resize:F=>{Y(D.current,F)}}),[y,_,x,k,Z,Y]);const B=P(D.current,i);return Kn(m,{...w,children:e,className:t,id:a,style:{...B,...p},"data-panel":"","data-panel-collapsible":r||void 0,"data-panel-group-id":E,"data-panel-id":Z,"data-panel-size":parseFloat(""+B.flexGrow).toFixed(1)})}const Vd=Fd((e,t)=>Kn(Bd,{...e,forwardedRef:t}));Bd.displayName="Panel";Vd.displayName="forwardRef(Panel)";let da=null,yn=null;function Wx(e,t){if(t){const n=(t&Wd)!==0,r=(t&Gd)!==0,i=(t&Kd)!==0,s=(t&Yd)!==0;if(n)return i?"se-resize":s?"ne-resize":"e-resize";if(r)return i?"sw-resize":s?"nw-resize":"w-resize";if(i)return"s-resize";if(s)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function Gx(){yn!==null&&(document.head.removeChild(yn),da=null,yn=null)}function ks(e,t){const n=Wx(e,t);da!==n&&(da=n,yn===null&&(yn=document.createElement("style"),document.head.appendChild(yn)),yn.innerHTML=`*{cursor: ${n}!important;}`)}function Ud(e){return e.type==="keydown"}function Jd(e){return e.type.startsWith("pointer")}function Hd(e){return e.type.startsWith("mouse")}function es(e){if(Jd(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Hd(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function Kx(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function Yx(e,t,n){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Xx(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:nl(e),b:nl(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;we(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:tl(el(n.a)),b:tl(el(n.b))};if(i.a===i.b){const s=r.childNodes,a={a:n.a.at(-1),b:n.b.at(-1)};let o=s.length;for(;o--;){const l=s[o];if(l===a.a)return 1;if(l===a.b)return-1}}return Math.sign(i.a-i.b)}const Qx=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function ey(e){var t;const n=getComputedStyle((t=qd(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function ty(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||ey(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||Qx.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function el(e){let t=e.length;for(;t--;){const n=e[t];if(we(n,"Missing node"),ty(n))return n}return null}function tl(e){return e&&Number(getComputedStyle(e).zIndex)||0}function nl(e){const t=[];for(;e;)t.push(e),e=qd(e);return t}function qd(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const Wd=1,Gd=2,Kd=4,Yd=8,ny=Kx()==="coarse";let Ot=[],Hn=!1,nn=new Map,ts=new Map;const Pr=new Set;function ry(e,t,n,r,i){var s;const{ownerDocument:a}=t,o={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:i},l=(s=nn.get(a))!==null&&s!==void 0?s:0;return nn.set(a,l+1),Pr.add(o),Ni(),function(){var f;ts.delete(e),Pr.delete(o);const d=(f=nn.get(a))!==null&&f!==void 0?f:1;if(nn.set(a,d-1),Ni(),d===1&&nn.delete(a),Ot.includes(o)){const h=Ot.indexOf(o);h>=0&&Ot.splice(h,1),to(),i("up",!0,null)}}}function rl(e){const{target:t}=e,{x:n,y:r}=es(e);Hn=!0,eo({target:t,x:n,y:r}),Ni(),Ot.length>0&&(Ei("down",e),e.preventDefault(),e.stopPropagation())}function ur(e){const{x:t,y:n}=es(e);if(Hn&&e.buttons===0&&(Hn=!1,Ei("up",e)),!Hn){const{target:r}=e;eo({target:r,x:t,y:n})}Ei("move",e),to(),Ot.length>0&&e.preventDefault()}function Tn(e){const{target:t}=e,{x:n,y:r}=es(e);ts.clear(),Hn=!1,Ot.length>0&&e.preventDefault(),Ei("up",e),eo({target:t,x:n,y:r}),to(),Ni()}function eo({target:e,x:t,y:n}){Ot.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),Pr.forEach(i=>{const{element:s,hitAreaMargins:a}=i,o=s.getBoundingClientRect(),{bottom:l,left:u,right:f,top:d}=o,h=ny?a.coarse:a.fine;if(t>=u-h&&t<=f+h&&n>=d-h&&n<=l+h){if(r!==null&&document.contains(r)&&s!==r&&!s.contains(r)&&!r.contains(s)&&Xx(r,s)>0){let m=r,w=!1;for(;m&&!m.contains(s);){if(Yx(m.getBoundingClientRect(),o)){w=!0;break}m=m.parentElement}if(w)return}Ot.push(i)}})}function Ss(e,t){ts.set(e,t)}function to(){let e=!1,t=!1;Ot.forEach(r=>{const{direction:i}=r;i==="horizontal"?e=!0:t=!0});let n=0;ts.forEach(r=>{n|=r}),e&&t?ks("intersection",n):e?ks("horizontal",n):t?ks("vertical",n):Gx()}function Ni(){nn.forEach((e,t)=>{const{body:n}=t;n.removeEventListener("contextmenu",Tn),n.removeEventListener("pointerdown",rl),n.removeEventListener("pointerleave",ur),n.removeEventListener("pointermove",ur)}),window.removeEventListener("pointerup",Tn),window.removeEventListener("pointercancel",Tn),Pr.size>0&&(Hn?(Ot.length>0&&nn.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("contextmenu",Tn),n.addEventListener("pointerleave",ur),n.addEventListener("pointermove",ur))}),window.addEventListener("pointerup",Tn),window.addEventListener("pointercancel",Tn)):nn.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("pointerdown",rl,{capture:!0}),n.addEventListener("pointermove",ur))}))}function Ei(e,t){Pr.forEach(n=>{const{setResizeHandlerState:r}=n,i=Ot.includes(n);r(e,i,t)})}function iy(){const[e,t]=Jn(0);return dt(()=>t(n=>n+1),[])}function we(e,t){if(!e)throw console.error(t),Error(t)}const no=10;function Cn(e,t,n=no){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Ht(e,t,n=no){return Cn(e,t,n)===0}function vt(e,t,n){return Cn(e,t,n)===0}function sy(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const i=e[r],s=t[r];if(!vt(i,s,n))return!1}return!0}function Bn({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];we(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:s,maxSize:a=100,minSize:o=0}=r;if(Cn(n,o)<0)if(s){const l=(i+o)/2;Cn(n,l)<0?n=i:n=o}else n=o;return n=Math.min(a,n),n=parseFloat(n.toFixed(no)),n}function xr({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(vt(e,0))return t;const a=[...t],[o,l]=r;we(o!=null,"Invalid first pivot index"),we(l!=null,"Invalid second pivot index");let u=0;if(s==="keyboard"){{const d=e<0?l:o,h=n[d];we(h,`Panel constraints not found for index ${d}`);const{collapsedSize:p=0,collapsible:m,minSize:w=0}=h;if(m){const S=t[d];if(we(S!=null,`Previous layout not found for panel index ${d}`),vt(S,p)){const y=w-S;Cn(y,Math.abs(e))>0&&(e=e<0?0-y:y)}}}{const d=e<0?o:l,h=n[d];we(h,`No panel constraints found for index ${d}`);const{collapsedSize:p=0,collapsible:m,minSize:w=0}=h;if(m){const S=t[d];if(we(S!=null,`Previous layout not found for panel index ${d}`),vt(S,w)){const y=S-p;Cn(y,Math.abs(e))>0&&(e=e<0?0-y:y)}}}}{const d=e<0?1:-1;let h=e<0?l:o,p=0;for(;;){const w=t[h];we(w!=null,`Previous layout not found for panel index ${h}`);const y=Bn({panelConstraints:n,panelIndex:h,size:100})-w;if(p+=y,h+=d,h<0||h>=n.length)break}const m=Math.min(Math.abs(e),Math.abs(p));e=e<0?0-m:m}{let h=e<0?o:l;for(;h>=0&&h<n.length;){const p=Math.abs(e)-Math.abs(u),m=t[h];we(m!=null,`Previous layout not found for panel index ${h}`);const w=m-p,S=Bn({panelConstraints:n,panelIndex:h,size:w});if(!vt(m,S)&&(u+=m-S,a[h]=S,u.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?h--:h++}}if(sy(i,a))return i;{const d=e<0?l:o,h=t[d];we(h!=null,`Previous layout not found for panel index ${d}`);const p=h+u,m=Bn({panelConstraints:n,panelIndex:d,size:p});if(a[d]=m,!vt(m,p)){let w=p-m,y=e<0?l:o;for(;y>=0&&y<n.length;){const _=a[y];we(_!=null,`Previous layout not found for panel index ${y}`);const x=_+w,P=Bn({panelConstraints:n,panelIndex:y,size:x});if(vt(_,P)||(w-=P-_,a[y]=P),vt(w,0))break;e>0?y--:y++}}}const f=a.reduce((d,h)=>h+d,0);return vt(f,100)?a:i}function ay({layout:e,panelsArray:t,pivotIndices:n}){let r=0,i=100,s=0,a=0;const o=n[0];we(o!=null,"No pivot index found"),t.forEach((d,h)=>{const{constraints:p}=d,{maxSize:m=100,minSize:w=0}=p;h===o?(r=w,i=m):(s+=w,a+=m)});const l=Math.min(i,100-s),u=Math.max(r,100-a),f=e[o];return{valueMax:l,valueMin:u,valueNow:f}}function Or(e,t=document){return Array.from(t.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${e}"]`))}function Xd(e,t,n=document){const i=Or(e,n).findIndex(s=>s.getAttribute("data-panel-resize-handle-id")===t);return i??null}function Qd(e,t,n){const r=Xd(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function ef(e,t=document){var n;if(t instanceof HTMLElement&&(t==null||(n=t.dataset)===null||n===void 0?void 0:n.panelGroupId)==e)return t;const r=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return r||null}function ns(e,t=document){const n=t.querySelector(`[data-panel-resize-handle-id="${e}"]`);return n||null}function oy(e,t,n,r=document){var i,s,a,o;const l=ns(t,r),u=Or(e,r),f=l?u.indexOf(l):-1,d=(i=(s=n[f])===null||s===void 0?void 0:s.id)!==null&&i!==void 0?i:null,h=(a=(o=n[f+1])===null||o===void 0?void 0:o.id)!==null&&a!==void 0?a:null;return[d,h]}function ly({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:i,panelGroupElement:s,setLayout:a}){mt({didWarnAboutMissingResizeHandle:!1}),vn(()=>{if(!s)return;const o=Or(n,s);for(let l=0;l<i.length-1;l++){const{valueMax:u,valueMin:f,valueNow:d}=ay({layout:r,panelsArray:i,pivotIndices:[l,l+1]}),h=o[l];if(h!=null){const p=i[l];we(p,`No panel data found for index "${l}"`),h.setAttribute("aria-controls",p.id),h.setAttribute("aria-valuemax",""+Math.round(u)),h.setAttribute("aria-valuemin",""+Math.round(f)),h.setAttribute("aria-valuenow",d!=null?""+Math.round(d):"")}}return()=>{o.forEach((l,u)=>{l.removeAttribute("aria-controls"),l.removeAttribute("aria-valuemax"),l.removeAttribute("aria-valuemin"),l.removeAttribute("aria-valuenow")})}},[n,r,i,s]),bn(()=>{if(!s)return;const o=t.current;we(o,"Eager values not found");const{panelDataArray:l}=o,u=ef(n,s);we(u!=null,`No group found for id "${n}"`);const f=Or(n,s);we(f,`No resize handles found for group id "${n}"`);const d=f.map(h=>{const p=h.getAttribute("data-panel-resize-handle-id");we(p,"Resize handle element has no handle id attribute");const[m,w]=oy(n,p,l,s);if(m==null||w==null)return()=>{};const S=y=>{if(!y.defaultPrevented)switch(y.key){case"Enter":{y.preventDefault();const _=l.findIndex(x=>x.id===m);if(_>=0){const x=l[_];we(x,`No panel data found for index ${_}`);const P=r[_],{collapsedSize:E=0,collapsible:k,minSize:C=0}=x.constraints;if(P!=null&&k){const V=xr({delta:vt(P,E)?C-E:E-P,initialLayout:r,panelConstraints:l.map(Y=>Y.constraints),pivotIndices:Qd(n,p,s),prevLayout:r,trigger:"keyboard"});r!==V&&a(V)}}break}}};return h.addEventListener("keydown",S),()=>{h.removeEventListener("keydown",S)}});return()=>{d.forEach(h=>h())}},[s,e,t,n,r,i,a])}function il(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function tf(e,t){const n=e==="horizontal",{x:r,y:i}=es(t);return n?r:i}function uy(e,t,n,r,i){const s=n==="horizontal",a=ns(t,i);we(a,`No resize handle element found for id "${t}"`);const o=a.getAttribute("data-panel-group-id");we(o,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=r;const u=tf(n,e),f=ef(o,i);we(f,`No group element found for id "${o}"`);const d=f.getBoundingClientRect(),h=s?d.width:d.height;return(u-l)/h*100}function cy(e,t,n,r,i,s){if(Ud(e)){const a=n==="horizontal";let o=0;e.shiftKey?o=100:i!=null?o=i:o=10;let l=0;switch(e.key){case"ArrowDown":l=a?0:o;break;case"ArrowLeft":l=a?-o:0;break;case"ArrowRight":l=a?o:0;break;case"ArrowUp":l=a?0:-o;break;case"End":l=100;break;case"Home":l=-100;break}return l}else return r==null?0:uy(e,t,n,r,s)}function dy({panelDataArray:e}){const t=Array(e.length),n=e.map(s=>s.constraints);let r=0,i=100;for(let s=0;s<e.length;s++){const a=n[s];we(a,`Panel constraints not found for index ${s}`);const{defaultSize:o}=a;o!=null&&(r++,t[s]=o,i-=o)}for(let s=0;s<e.length;s++){const a=n[s];we(a,`Panel constraints not found for index ${s}`);const{defaultSize:o}=a;if(o!=null)continue;const l=e.length-r,u=i/l;r++,t[s]=u,i-=u}return t}function An(e,t,n){t.forEach((r,i)=>{const s=e[i];we(s,`Panel data not found for index ${i}`);const{callbacks:a,constraints:o,id:l}=s,{collapsedSize:u=0,collapsible:f}=o,d=n[l];if(d==null||r!==d){n[l]=r;const{onCollapse:h,onExpand:p,onResize:m}=a;m&&m(r,d),f&&(h||p)&&(p&&(d==null||Ht(d,u))&&!Ht(r,u)&&p(),h&&(d==null||!Ht(d,u))&&Ht(r,u)&&h())}})}function ei(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function fy({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:i,precision:s=3}){const a=n[i];let o;return a==null?o=e!=null?e.toPrecision(s):"1":r.length===1?o="1":o=a.toPrecision(s),{flexBasis:0,flexGrow:o,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function py(e,t=10){let n=null;return(...i)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...i)},t)}}function sl(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function nf(e){return`react-resizable-panels:${e}`}function rf(e){return e.map(t=>{const{constraints:n,id:r,idIsFromProps:i,order:s}=t;return i?r:s?`${s}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function sf(e,t){try{const n=nf(e),r=t.getItem(n);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function hy(e,t,n){var r,i;const s=(r=sf(e,n))!==null&&r!==void 0?r:{},a=rf(t);return(i=s[a])!==null&&i!==void 0?i:null}function my(e,t,n,r,i){var s;const a=nf(e),o=rf(t),l=(s=sf(e,i))!==null&&s!==void 0?s:{};l[o]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{i.setItem(a,JSON.stringify(l))}catch(u){console.error(u)}}function al({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((s,a)=>s+a,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(s=>`${s}%`).join(", ")}`);if(!vt(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const a=n[s];we(a!=null,`No layout data found for index ${s}`);const o=100/r*a;n[s]=o}let i=0;for(let s=0;s<t.length;s++){const a=n[s];we(a!=null,`No layout data found for index ${s}`);const o=Bn({panelConstraints:t,panelIndex:s,size:a});a!=o&&(i+=a-o,n[s]=o)}if(!vt(i,0))for(let s=0;s<t.length;s++){const a=n[s];we(a!=null,`No layout data found for index ${s}`);const o=a+i,l=Bn({panelConstraints:t,panelIndex:s,size:o});if(a!==l&&(i-=l-a,n[s]=l,vt(i,0)))break}return n}const gy=100,yr={getItem:e=>(sl(yr),yr.getItem(e)),setItem:(e,t)=>{sl(yr),yr.setItem(e,t)}},ol={};function af({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:i,id:s=null,onLayout:a=null,keyboardResizeBy:o=null,storage:l=yr,style:u,tagName:f="div",...d}){const h=Qa(s),p=mt(null),[m,w]=Jn(null),[S,y]=Jn([]),_=iy(),x=mt({}),P=mt(new Map),E=mt(0),k=mt({autoSaveId:e,direction:r,dragState:m,id:h,keyboardResizeBy:o,onLayout:a,storage:l}),C=mt({layout:S,panelDataArray:[],panelDataArrayChanged:!1});mt({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),Zd(i,()=>({getId:()=>k.current.id,getLayout:()=>{const{layout:g}=C.current;return g},setLayout:g=>{const{onLayout:G}=k.current,{layout:ie,panelDataArray:Q}=C.current,I=al({layout:g,panelConstraints:Q.map(R=>R.constraints)});il(ie,I)||(y(I),C.current.layout=I,G&&G(I),An(Q,I,x.current))}}),[]),vn(()=>{k.current.autoSaveId=e,k.current.direction=r,k.current.dragState=m,k.current.id=h,k.current.onLayout=a,k.current.storage=l}),ly({committedValuesRef:k,eagerValuesRef:C,groupId:h,layout:S,panelDataArray:C.current.panelDataArray,setLayout:y,panelGroupElement:p.current}),bn(()=>{const{panelDataArray:g}=C.current;if(e){if(S.length===0||S.length!==g.length)return;let G=ol[e];G==null&&(G=py(my,gy),ol[e]=G);const ie=[...g],Q=new Map(P.current);G(e,ie,Q,S,l)}},[e,S,l]),bn(()=>{});const V=dt(g=>{const{onLayout:G}=k.current,{layout:ie,panelDataArray:Q}=C.current;if(g.constraints.collapsible){const I=Q.map(pe=>pe.constraints),{collapsedSize:R=0,panelSize:J,pivotIndices:oe}=dn(Q,g,ie);if(we(J!=null,`Panel size not found for panel "${g.id}"`),!Ht(J,R)){P.current.set(g.id,J);const Ae=$n(Q,g)===Q.length-1?J-R:R-J,ke=xr({delta:Ae,initialLayout:ie,panelConstraints:I,pivotIndices:oe,prevLayout:ie,trigger:"imperative-api"});ei(ie,ke)||(y(ke),C.current.layout=ke,G&&G(ke),An(Q,ke,x.current))}}},[]),Y=dt((g,G)=>{const{onLayout:ie}=k.current,{layout:Q,panelDataArray:I}=C.current;if(g.constraints.collapsible){const R=I.map(be=>be.constraints),{collapsedSize:J=0,panelSize:oe=0,minSize:pe=0,pivotIndices:Ae}=dn(I,g,Q),ke=G??pe;if(Ht(oe,J)){const be=P.current.get(g.id),it=be!=null&&be>=ke?be:ke,yt=$n(I,g)===I.length-1?oe-it:it-oe,j=xr({delta:yt,initialLayout:Q,panelConstraints:R,pivotIndices:Ae,prevLayout:Q,trigger:"imperative-api"});ei(Q,j)||(y(j),C.current.layout=j,ie&&ie(j),An(I,j,x.current))}}},[]),N=dt(g=>{const{layout:G,panelDataArray:ie}=C.current,{panelSize:Q}=dn(ie,g,G);return we(Q!=null,`Panel size not found for panel "${g.id}"`),Q},[]),Z=dt((g,G)=>{const{panelDataArray:ie}=C.current,Q=$n(ie,g);return fy({defaultSize:G,dragState:m,layout:S,panelData:ie,panelIndex:Q})},[m,S]),D=dt(g=>{const{layout:G,panelDataArray:ie}=C.current,{collapsedSize:Q=0,collapsible:I,panelSize:R}=dn(ie,g,G);return we(R!=null,`Panel size not found for panel "${g.id}"`),I===!0&&Ht(R,Q)},[]),B=dt(g=>{const{layout:G,panelDataArray:ie}=C.current,{collapsedSize:Q=0,collapsible:I,panelSize:R}=dn(ie,g,G);return we(R!=null,`Panel size not found for panel "${g.id}"`),!I||Cn(R,Q)>0},[]),F=dt(g=>{const{panelDataArray:G}=C.current;G.push(g),G.sort((ie,Q)=>{const I=ie.order,R=Q.order;return I==null&&R==null?0:I==null?-1:R==null?1:I-R}),C.current.panelDataArrayChanged=!0,_()},[_]);vn(()=>{if(C.current.panelDataArrayChanged){C.current.panelDataArrayChanged=!1;const{autoSaveId:g,onLayout:G,storage:ie}=k.current,{layout:Q,panelDataArray:I}=C.current;let R=null;if(g){const oe=hy(g,I,ie);oe&&(P.current=new Map(Object.entries(oe.expandToSizes)),R=oe.layout)}R==null&&(R=dy({panelDataArray:I}));const J=al({layout:R,panelConstraints:I.map(oe=>oe.constraints)});il(Q,J)||(y(J),C.current.layout=J,G&&G(J),An(I,J,x.current))}}),vn(()=>{const g=C.current;return()=>{g.layout=[]}},[]);const T=dt(g=>{let G=!1;const ie=p.current;return ie&&window.getComputedStyle(ie,null).getPropertyValue("direction")==="rtl"&&(G=!0),function(I){I.preventDefault();const R=p.current;if(!R)return()=>null;const{direction:J,dragState:oe,id:pe,keyboardResizeBy:Ae,onLayout:ke}=k.current,{layout:be,panelDataArray:it}=C.current,{initialLayout:St}=oe??{},yt=Qd(pe,g,R);let j=cy(I,g,J,oe,Ae,R);const z=J==="horizontal";z&&G&&(j=-j);const $=it.map(ee=>ee.constraints),ne=xr({delta:j,initialLayout:St??be,panelConstraints:$,pivotIndices:yt,prevLayout:be,trigger:Ud(I)?"keyboard":"mouse-or-touch"}),te=!ei(be,ne);(Jd(I)||Hd(I))&&E.current!=j&&(E.current=j,!te&&j!==0?z?Ss(g,j<0?Wd:Gd):Ss(g,j<0?Kd:Yd):Ss(g,0)),te&&(y(ne),C.current.layout=ne,ke&&ke(ne),An(it,ne,x.current))}},[]),H=dt((g,G)=>{const{onLayout:ie}=k.current,{layout:Q,panelDataArray:I}=C.current,R=I.map(be=>be.constraints),{panelSize:J,pivotIndices:oe}=dn(I,g,Q);we(J!=null,`Panel size not found for panel "${g.id}"`);const Ae=$n(I,g)===I.length-1?J-G:G-J,ke=xr({delta:Ae,initialLayout:Q,panelConstraints:R,pivotIndices:oe,prevLayout:Q,trigger:"imperative-api"});ei(Q,ke)||(y(ke),C.current.layout=ke,ie&&ie(ke),An(I,ke,x.current))},[]),K=dt((g,G)=>{const{layout:ie,panelDataArray:Q}=C.current,{collapsedSize:I=0,collapsible:R}=G,{collapsedSize:J=0,collapsible:oe,maxSize:pe=100,minSize:Ae=0}=g.constraints,{panelSize:ke}=dn(Q,g,ie);ke!=null&&(R&&oe&&Ht(ke,I)?Ht(I,J)||H(g,J):ke<Ae?H(g,Ae):ke>pe&&H(g,pe))},[H]),O=dt((g,G)=>{const{direction:ie}=k.current,{layout:Q}=C.current;if(!p.current)return;const I=ns(g,p.current);we(I,`Drag handle element not found for id "${g}"`);const R=tf(ie,G);w({dragHandleId:g,dragHandleRect:I.getBoundingClientRect(),initialCursorPosition:R,initialLayout:Q})},[]),W=dt(()=>{w(null)},[]),b=dt(g=>{const{panelDataArray:G}=C.current,ie=$n(G,g);ie>=0&&(G.splice(ie,1),delete x.current[g.id],C.current.panelDataArrayChanged=!0,_())},[_]),ue=Ux(()=>({collapsePanel:V,direction:r,dragState:m,expandPanel:Y,getPanelSize:N,getPanelStyle:Z,groupId:h,isPanelCollapsed:D,isPanelExpanded:B,reevaluatePanelConstraints:K,registerPanel:F,registerResizeHandle:T,resizePanel:H,startDragging:O,stopDragging:W,unregisterPanel:b,panelGroupElement:p.current}),[V,m,r,Y,N,Z,h,D,B,K,F,T,H,O,W,b]),ae={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return Kn(Qi.Provider,{value:ue},Kn(f,{...d,children:t,className:n,id:s,ref:p,style:{...ae,...u},"data-panel-group":"","data-panel-group-direction":r,"data-panel-group-id":h}))}const of=Fd((e,t)=>Kn(af,{...e,forwardedRef:t}));af.displayName="PanelGroup";of.displayName="forwardRef(PanelGroup)";function $n(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function dn(e,t,n){const r=$n(e,t),s=r===e.length-1?[r-1,r]:[r,r+1],a=n[r];return{...t.constraints,panelSize:a,pivotIndices:s}}function xy({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){bn(()=>{if(e||n==null||r==null)return;const i=ns(t,r);if(i==null)return;const s=a=>{if(!a.defaultPrevented)switch(a.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{a.preventDefault(),n(a);break}case"F6":{a.preventDefault();const o=i.getAttribute("data-panel-group-id");we(o,`No group element found for id "${o}"`);const l=Or(o,r),u=Xd(o,t,r);we(u!==null,`No resize element found for id "${t}"`);const f=a.shiftKey?u>0?u-1:l.length-1:u+1<l.length?u+1:0;l[f].focus();break}}};return i.addEventListener("keydown",s),()=>{i.removeEventListener("keydown",s)}},[r,e,t,n])}function lf({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:i,onBlur:s,onDragging:a,onFocus:o,style:l={},tabIndex:u=0,tagName:f="div",...d}){var h,p;const m=mt(null),w=mt({onDragging:a});bn(()=>{w.current.onDragging=a});const S=Ld(Qi);if(S===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:y,groupId:_,registerResizeHandle:x,startDragging:P,stopDragging:E,panelGroupElement:k}=S,C=Qa(i),[V,Y]=Jn("inactive"),[N,Z]=Jn(!1),[D,B]=Jn(null),F=mt({state:V});vn(()=>{F.current.state=V}),bn(()=>{if(n)B(null);else{const O=x(C);B(()=>O)}},[n,C,x]);const T=(h=r==null?void 0:r.coarse)!==null&&h!==void 0?h:15,H=(p=r==null?void 0:r.fine)!==null&&p!==void 0?p:5;return bn(()=>{if(n||D==null)return;const O=m.current;return we(O,"Element ref not attached"),ry(C,O,y,{coarse:T,fine:H},(b,ue,ae)=>{if(ue)switch(b){case"down":{Y("drag"),we(ae,'Expected event to be defined for "down" action'),P(C,ae);const{onDragging:g}=w.current;g&&g(!0);break}case"move":{const{state:g}=F.current;g!=="drag"&&Y("hover"),we(ae,'Expected event to be defined for "move" action'),D(ae);break}case"up":{Y("hover"),E();const{onDragging:g}=w.current;g&&g(!1);break}}else Y("inactive")})},[T,y,n,H,x,C,D,P,E]),xy({disabled:n,handleId:C,resizeHandler:D,panelGroupElement:k}),Kn(f,{...d,children:e,className:t,id:i,onBlur:()=>{Z(!1),s==null||s()},onFocus:()=>{Z(!0),o==null||o()},ref:m,role:"separator",style:{...{touchAction:"none",userSelect:"none"},...l},tabIndex:u,"data-panel-group-direction":y,"data-panel-group-id":_,"data-resize-handle":"","data-resize-handle-active":V==="drag"?"pointer":N?"keyboard":void 0,"data-resize-handle-state":V,"data-panel-resize-handle-enabled":!n,"data-panel-resize-handle-id":C})}lf.displayName="PanelResizeHandle";const yy=({className:e,...t})=>c.jsx(of,{className:U("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),_s=Vd,ll=({withHandle:e,className:t,...n})=>c.jsx(lf,{className:U("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(Fm,{className:"h-2.5 w-2.5"})})});function by({children:e,className:t}){return c.jsx("kbd",{className:U("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 vy({children:e,className:t}){return c.jsx("span",{className:U("inline-flex items-center gap-0.5",t),children:e})}const ti=typeof navigator<"u"&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);function fa({shortcut:e,className:t}){const r=e.split("+").map(i=>i.trim().toLowerCase()).map(i=>{switch(i){case"mod":return ti?"⌘":"Ctrl";case"shift":return ti?"⇧":"Shift";case"alt":return ti?"⌥":"Alt";case"ctrl":return ti?"⌃":"Ctrl";case"enter":return"↵";default:return i.toUpperCase()}});return c.jsx(vy,{className:t,children:r.map((i,s)=>c.jsx(by,{children:i},s))})}class wy{constructor(t){Ao(this,"client");this.client=cg.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 ky=new wy;function Sy(){const e=v.useRef(null),t=v.useCallback(async(r,i,s,a,o)=>{e.current&&e.current.abort();const l=new AbortController;e.current=l;try{a==null||a("parsing","Validating JSON structure...");let u;try{u=JSON.parse(i)}catch(k){throw new Error(`Invalid JSON: ${k instanceof Error?k.message:"Unknown parse error"}`)}a==null||a("building",`Building ${Yr.toLowerCase()} structure...`);const f={jsonDefinition:u,options:o||{}};f.customThemes=s??{},a==null||a("rendering",`Generating ${Nt.toUpperCase()} content...`);const d={"Content-Type":"application/json"};o!=null&&o.bypassCache&&(d["X-Bypass-Cache"]="true");const h=await fetch(im.generate,{method:"POST",headers:d,body:JSON.stringify(f),signal:l.signal}),p=await h.json();if(!h.ok||!p.success){const k=p.error||p.message||`API request failed with status: ${h.status}`;throw new Error(k)}const{data:m,cache:w,warnings:S}=p,y=w.status==="HIT"?"HIT":w.status==="MISS"?"MISS":"UNKNOWN",_=y==="HIT"?`Served from cache (Hit rate: ${w.hitRate})`:`Generated fresh ${Yr.toLowerCase()}`;a==null||a("finalizing",_);const x=globalThis.atob(m.document),P=new Uint8Array(x.length);for(let k=0;k<x.length;k++)P[k]=x.charCodeAt(k);const E=new Blob([P],{type:m.contentType});if(E.size===0)throw new Error(`Received empty ${Yr.toLowerCase()} from API`);return{name:r,text:i,blob:E,filename:m.filename,fileId:m.fileId,cacheStatus:y,cacheHitRate:w.hitRate,warnings:S}}catch(u){throw u instanceof Error&&u.name==="AbortError"?new Error(`${Yr} generation was cancelled`):u}finally{e.current===l&&(e.current=null)}},[]),n=v.useCallback(()=>{e.current&&(e.current.abort(),e.current=null)},[]);return{generatePresentation:t,cancelGeneration:n}}function _y(e){if(!e||e.length===0)return null;const t=[{name:"heading",props:{level:1,text:"Document Generation Warnings"}},{name:"paragraph",props:{text:`${e.length} warning(s) were generated during document processing.`,spacing:{after:240}}}],n=new Map;for(const r of e){const i=n.get(r.component)||[];i.push(r),n.set(r.component,i)}for(const[r,i]of n.entries()){t.push({name:"heading",props:{level:2,text:`Component: ${r}`}});const s=[];for(const a of i){let o=a.message;if(a.context&&Object.keys(a.context).length>0){const l=Object.entries(a.context).map(([u,f])=>`${u}: ${JSON.stringify(f)}`).join(", ");o+=` (${l})`}s.push(o)}t.push({name:"list",props:{items:s,spacing:{after:120}}})}return{name:"docx",props:{metadata:{title:"Generation Warnings"},theme:"minimal"},children:t}}const ul=Nt==="docx"?["docxjs","LibreOffice"]:["LibreOffice"],Cs={docxjs:["⚡","(Fast) works in the browser — lower fidelity"],LibreOffice:["🖨️","(High fidelity) converts to PDF locally with LibreOffice"]};function Cy({name:e,blob:t,displayReloadButton:n,iframeRef:r,autoReload:i,onToggleAutoReload:s,onManualRender:a,isGenerating:o,isRendering:l,onShowCacheMetrics:u,onShowSchemas:f,documentText:d,warnings:h,renderingLibrary:p,setRenderingLibrary:m,onToggleChat:w,chatOpen:S,onTogglePreview:y,previewOpen:_}){const x=p!=="docxjs",[P,E]=v.useState(!1),[k,C]=v.useState(!1),[V,Y]=v.useState(!1),[N,Z]=v.useState(!1),[D,B]=v.useState(!1),[F,T]=v.useState(!1),{toast:H}=Ra(),{generatePresentation:K}=Sy(),O=v.useCallback(async()=>{if(t){E(!0);try{await new Promise(g=>setTimeout(g,100)),aa(`${e}${Xr}`,t)}finally{setTimeout(()=>E(!1),500)}}},[t,e]),W=v.useCallback(async()=>{if(!(!h||h.length===0)){C(!0);try{const g=_y(h);if(!g){H({title:"No warnings",description:"There are no warnings to download.",variant:"destructive"});return}const G=await K("warnings",JSON.stringify(g,null,2),{});G&&typeof G=="object"&&"blob"in G&&G.blob&&(aa(`${e}-warnings${Xr}`,G.blob),H({title:"Warnings downloaded",description:`Downloaded warnings document with ${h.length} warning(s).`}))}catch(g){console.error("Failed to generate warnings document:",g),H({title:"Download failed",description:g instanceof Error?g.message:"Failed to generate warnings document",variant:"destructive"})}finally{setTimeout(()=>C(!1),500)}}},[h,e,K,H]),b=v.useCallback(async()=>{const g=r==null?void 0:r.current;if(g!=null&&g.src){Y(!0);try{await new Promise(ie=>{let Q=null,I=!1;const R=()=>{Q&&(clearTimeout(Q),Q=null),g.removeEventListener("load",oe),g.removeEventListener("error",pe)},J=()=>{I||(I=!0,R(),ie())},oe=()=>J(),pe=()=>J();g.addEventListener("load",oe),g.addEventListener("error",pe),Q=setTimeout(()=>{console.warn("Iframe reload timed out after 5 seconds"),J()},5e3);const Ae=g.src,ke=Ae.includes("?")?"&":"?",be=Date.now();g.src=`${Ae}${ke}_reload=${be}`})}catch(G){console.error("Iframe reload failed:",G)}finally{Y(!1)}}},[r]),ue=v.useCallback(async()=>{Z(!0);try{await ky.delete(`/${Nt}/cache`),window.dispatchEvent(new CustomEvent("cache:cleared")),H({title:"Cache Cleared",description:"All caches (document and component) have been successfully cleared.",variant:"default"})}catch(g){console.error("Failed to clear cache:",g),H({title:"Cache Clear Failed",description:"Failed to clear caches. Please try again.",variant:"destructive"})}finally{Z(!1)}},[H]),ae=v.useCallback(async()=>{if(!d){H({title:"No document available",description:"Please select a document to copy standard components",variant:"destructive"});return}T(!0);try{const g=await fetch(`/api/${Nt}/standard-components`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonDefinition:d})});if(!g.ok){let Q=`Request failed with status ${g.status}`;try{const I=await g.json();I.message&&(Q=I.message)}catch{}H({title:"Failed to get standard components",description:Q,variant:"destructive"});return}const G=await g.json(),ie=JSON.stringify(G.data,null,2);await navigator.clipboard.writeText(ie),H({title:"Copied to clipboard",description:"Standard modules JSON has been copied"})}catch(g){console.error("Error copying standard components:",g),H({title:"Error",description:g instanceof Error?g.message:"Failed to copy standard components",variant:"destructive"})}finally{T(!1)}},[d,H]);return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"bg-sidebar flex flex-row flex-nowrap items-center justify-between gap-x-2 px-3 py-1.5",children:[c.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[c.jsx("p",{className:"text-foreground text-sm font-semibold tracking-tight truncate flex-1 min-w-0",children:e}),c.jsxs(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(Uc,{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"," ",Nt==="docx"?"docx-preview":"LibreOffice PDF conversion",". Download the ",Xr," to verify fidelity."]})})]})]}),c.jsxs("div",{className:"flex flex-row items-center gap-x-1 shrink-0",children:[(!i||x)&&c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsxs(Ie,{variant:"default",size:"sm",className:"gap-1.5 h-7 px-2.5",onClick:a,"aria-label":"Render preview",disabled:o||l||_===!1,children:[l?c.jsx(Qt,{size:"sm"}):c.jsx(Lm,{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"})})]}),Nt==="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(Ja,{className:"text-xs text-muted-foreground hidden sm:inline",children:"Auto"}),c.jsx(Ya,{checked:i,onCheckedChange:s,disabled:x})]})}),c.jsx(Ye,{children:c.jsx("p",{children:x?"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(Ie,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:b,disabled:V||o||l,children:V?c.jsx(Qt,{size:"sm"}):c.jsx(Zm,{className:"h-3.5 w-3.5"})})}),c.jsx(Ye,{children:c.jsx("p",{children:V?"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(Ie,{variant:"outline",size:"sm",className:"gap-1.5 h-7 px-2.5",disabled:!t||P||o,onClick:O,children:[P?c.jsx(Qt,{size:"sm"}):c.jsx(Bm,{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 ",Xr]})})]}),h&&h.length>0&&c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(Ie,{variant:"outline",size:"icon",className:"h-7 w-7 bg-amber-50 dark:bg-amber-950 text-amber-600 dark:text-amber-400 border-amber-200 dark:border-amber-800 hover:bg-amber-100 dark:hover:bg-amber-900",disabled:k||o,onClick:W,children:k?c.jsx(Qt,{size:"sm"}):c.jsx(Jc,{className:"h-3.5 w-3.5"})})}),c.jsx(Ye,{children:c.jsxs("p",{children:["Download warnings (",h.length,")"]})})]}),p&&m&&c.jsxs(qa,{value:p,onValueChange:m,children:[c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(Ki,{className:"w-[140px] h-7 text-xs hidden lg:flex",children:c.jsx(Wa,{placeholder:"Renderer"})})}),c.jsx(Ye,{children:c.jsx("p",{children:"Select the rendering library"})})]}),c.jsx(Yi,{className:"text-sidebar-foreground",children:ul.map(g=>c.jsxs(Tr,{value:g,children:[c.jsxs(Ge,{children:[c.jsx(Ke,{tabIndex:-1,children:Cs[g][0]}),c.jsx(Ye,{children:Cs[g][1]})]})," ",g]},g))})]}),c.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),c.jsxs(Dd,{children:[c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(Rd,{asChild:!0,children:c.jsx(Ie,{variant:"ghost",size:"icon",className:"h-7 w-7",children:c.jsx(Vm,{className:"h-3.5 w-3.5"})})})}),c.jsx(Ye,{children:c.jsx("p",{children:"More actions"})})]}),c.jsxs(Xa,{align:"end",className:"w-52",children:[f&&c.jsxs(tn,{onClick:f,children:[c.jsx(Um,{className:"h-4 w-4 mr-2"}),"View JSON Schemas"]}),u&&c.jsxs(tn,{onClick:u,children:[c.jsx(Jm,{className:"h-4 w-4 mr-2"}),"View cache metrics"]}),c.jsxs(tn,{onClick:ae,disabled:!d||F,children:[c.jsx(Hc,{className:"h-4 w-4 mr-2"}),F?"Copying...":"Copy standard components"]}),c.jsx(ji,{}),c.jsxs(tn,{onClick:()=>B(!0),disabled:N,className:"text-destructive focus:text-destructive",children:[c.jsx(Fa,{className:"h-4 w-4 mr-2"}),N?"Clearing...":"Clear all caches"]}),p&&m&&c.jsxs(c.Fragment,{children:[c.jsx(ji,{className:"lg:hidden"}),ul.map(g=>c.jsxs(tn,{className:"lg:hidden",onClick:()=>m(g),children:[c.jsx("span",{className:"mr-2",children:p===g?"●":"○"}),Cs[g][0]," ",g]},g))]})]})]}),y&&c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(Ie,{variant:_?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:y,children:_?c.jsx(qc,{className:"h-3.5 w-3.5"}):c.jsx(Hm,{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(fa,{shortcut:"mod+shift+p"})]})})]}),w&&c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(Ie,{variant:S?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:w,children:c.jsx(Wc,{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(fa,{shortcut:"mod+shift+j"})]})})]})]})]}),c.jsx(qt,{open:D,onOpenChange:B,children:c.jsxs(Zt,{className:"max-w-sm",children:[c.jsxs(Sn,{children:[c.jsx(_n,{children:"Clear all caches?"}),c.jsx(Gn,{children:"This will clear document and component caches. Next generation will be uncached."})]}),c.jsxs(zr,{children:[c.jsx(Ie,{variant:"outline",size:"sm",onClick:()=>B(!1),children:"Cancel"}),c.jsx(Ie,{variant:"destructive",size:"sm",disabled:N,onClick:async()=>{await ue(),B(!1)},children:N?c.jsx(Qt,{size:"sm"}):"Clear"})]})]})})]})}const jy=Ee.memo(Cy);function cl({previewOpen:e,onTogglePreview:t}){const n=mn(C=>C.name||""),r=mn(C=>C.blob),i=mn(C=>C.isGenerating),s=mn(C=>C.text),a=mn(C=>C.warnings),o=mn(C=>C.isRendering),l=Qr(C=>C.autoReload),u=Qr(C=>C.renderingLibrary),f=Qr(C=>C.setSettings),d=Qr(C=>C.useGlobalPreviewHeader??!0),h=Xe(C=>C.activeTab),p=Xe(C=>C.documentTypes),m=h&&p[h]==="application/json+theme"?"theme":"document",w=ze(C=>C.chatOpen),S=ze(C=>C.toggleChat),[y,_]=Ee.useState(!1);if(!d)return null;const x=v.useCallback(()=>f({saveDocumentDebounceWait:2e3,autoReload:!l}),[l,f]),P=v.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:manualRender"))},[]),E=v.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:showCacheMetrics"))},[]),k=(n==null?void 0:n.trim())||"Preview";return c.jsxs("div",{className:"sticky top-0 z-20",children:[c.jsx(jy,{name:k,blob:r,displayReloadButton:!1,autoReload:l,onToggleAutoReload:x,onManualRender:P,isGenerating:i,isRendering:!!o,onShowCacheMetrics:E,onShowSchemas:()=>_(!0),documentText:s,warnings:a,renderingLibrary:u,setRenderingLibrary:C=>f({renderingLibrary:C}),onToggleChat:S,chatOpen:w,onTogglePreview:t,previewOpen:e}),c.jsx($d,{open:y,onOpenChange:_,defaultTab:m==="theme"?"theme":"document"})]})}function Ny(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Ey=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Iy=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,zy={};function dl(e,t){return(zy.jsx?Iy:Ey).test(e)}const Ty=/[ \t\n\f\r]/g;function Ay(e){return typeof e=="object"?e.type==="text"?fl(e.value):!1:fl(e)}function fl(e){return e.replace(Ty,"")===""}class Jr{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Jr.prototype.normal={};Jr.prototype.property={};Jr.prototype.space=void 0;function uf(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Jr(n,r,t)}function pa(e){return e.toLowerCase()}class gt{constructor(t,n){this.attribute=n,this.property=t}}gt.prototype.attribute="";gt.prototype.booleanish=!1;gt.prototype.boolean=!1;gt.prototype.commaOrSpaceSeparated=!1;gt.prototype.commaSeparated=!1;gt.prototype.defined=!1;gt.prototype.mustUseProperty=!1;gt.prototype.number=!1;gt.prototype.overloadedBoolean=!1;gt.prototype.property="";gt.prototype.spaceSeparated=!1;gt.prototype.space=void 0;let Py=0;const ye=En(),We=En(),ha=En(),X=En(),Me=En(),qn=En(),bt=En();function En(){return 2**++Py}const ma=Object.freeze(Object.defineProperty({__proto__:null,boolean:ye,booleanish:We,commaOrSpaceSeparated:bt,commaSeparated:qn,number:X,overloadedBoolean:ha,spaceSeparated:Me},Symbol.toStringTag,{value:"Module"})),js=Object.keys(ma);class ro extends gt{constructor(t,n,r,i){let s=-1;if(super(t,n),pl(this,"space",i),typeof r=="number")for(;++s<js.length;){const a=js[s];pl(this,js[s],(r&ma[a])===ma[a])}}}ro.prototype.defined=!0;function pl(e,t,n){n&&(e[t]=n)}function nr(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new ro(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[pa(r)]=r,n[pa(s.attribute)]=r}return new Jr(t,n,e.space)}const cf=nr({properties:{ariaActiveDescendant:null,ariaAtomic:We,ariaAutoComplete:null,ariaBusy:We,ariaChecked:We,ariaColCount:X,ariaColIndex:X,ariaColSpan:X,ariaControls:Me,ariaCurrent:null,ariaDescribedBy:Me,ariaDetails:null,ariaDisabled:We,ariaDropEffect:Me,ariaErrorMessage:null,ariaExpanded:We,ariaFlowTo:Me,ariaGrabbed:We,ariaHasPopup:null,ariaHidden:We,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Me,ariaLevel:X,ariaLive:null,ariaModal:We,ariaMultiLine:We,ariaMultiSelectable:We,ariaOrientation:null,ariaOwns:Me,ariaPlaceholder:null,ariaPosInSet:X,ariaPressed:We,ariaReadOnly:We,ariaRelevant:null,ariaRequired:We,ariaRoleDescription:Me,ariaRowCount:X,ariaRowIndex:X,ariaRowSpan:X,ariaSelected:We,ariaSetSize:X,ariaSort:null,ariaValueMax:X,ariaValueMin:X,ariaValueNow:X,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function df(e,t){return t in e?e[t]:t}function ff(e,t){return df(e,t.toLowerCase())}const Oy=nr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:qn,acceptCharset:Me,accessKey:Me,action:null,allow:null,allowFullScreen:ye,allowPaymentRequest:ye,allowUserMedia:ye,alt:null,as:null,async:ye,autoCapitalize:null,autoComplete:Me,autoFocus:ye,autoPlay:ye,blocking:Me,capture:null,charSet:null,checked:ye,cite:null,className:Me,cols:X,colSpan:null,content:null,contentEditable:We,controls:ye,controlsList:Me,coords:X|qn,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ye,defer:ye,dir:null,dirName:null,disabled:ye,download:ha,draggable:We,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ye,formTarget:null,headers:Me,height:X,hidden:ha,high:X,href:null,hrefLang:null,htmlFor:Me,httpEquiv:Me,id:null,imageSizes:null,imageSrcSet:null,inert:ye,inputMode:null,integrity:null,is:null,isMap:ye,itemId:null,itemProp:Me,itemRef:Me,itemScope:ye,itemType:Me,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ye,low:X,manifest:null,max:null,maxLength:X,media:null,method:null,min:null,minLength:X,multiple:ye,muted:ye,name:null,nonce:null,noModule:ye,noValidate:ye,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:ye,optimum:X,pattern:null,ping:Me,placeholder:null,playsInline:ye,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ye,referrerPolicy:null,rel:Me,required:ye,reversed:ye,rows:X,rowSpan:X,sandbox:Me,scope:null,scoped:ye,seamless:ye,selected:ye,shadowRootClonable:ye,shadowRootDelegatesFocus:ye,shadowRootMode:null,shape:null,size:X,sizes:null,slot:null,span:X,spellCheck:We,src:null,srcDoc:null,srcLang:null,srcSet:null,start:X,step:null,style:null,tabIndex:X,target:null,title:null,translate:null,type:null,typeMustMatch:ye,useMap:null,value:We,width:X,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Me,axis:null,background:null,bgColor:null,border:X,borderColor:null,bottomMargin:X,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ye,declare:ye,event:null,face:null,frame:null,frameBorder:null,hSpace:X,leftMargin:X,link:null,longDesc:null,lowSrc:null,marginHeight:X,marginWidth:X,noResize:ye,noHref:ye,noShade:ye,noWrap:ye,object:null,profile:null,prompt:null,rev:null,rightMargin:X,rules:null,scheme:null,scrolling:We,standby:null,summary:null,text:null,topMargin:X,valueType:null,version:null,vAlign:null,vLink:null,vSpace:X,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:ye,disableRemotePlayback:ye,prefix:null,property:null,results:X,security:null,unselectable:null},space:"html",transform:ff}),Dy=nr({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:bt,accentHeight:X,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:X,amplitude:X,arabicForm:null,ascent:X,attributeName:null,attributeType:null,azimuth:X,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:X,by:null,calcMode:null,capHeight:X,className:Me,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:X,diffuseConstant:X,direction:null,display:null,dur:null,divisor:X,dominantBaseline:null,download:ye,dx:null,dy:null,edgeMode:null,editable:null,elevation:X,enableBackground:null,end:null,event:null,exponent:X,externalResourcesRequired:null,fill:null,fillOpacity:X,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:qn,g2:qn,glyphName:qn,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:X,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:X,horizOriginX:X,horizOriginY:X,id:null,ideographic:X,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:X,k:X,k1:X,k2:X,k3:X,k4:X,kernelMatrix:bt,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:X,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:X,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:X,overlineThickness:X,paintOrder:null,panose1:null,path:null,pathLength:X,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Me,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:X,pointsAtY:X,pointsAtZ:X,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:bt,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:bt,rev:bt,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:bt,requiredFeatures:bt,requiredFonts:bt,requiredFormats:bt,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:X,specularExponent:X,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:X,strikethroughThickness:X,string:null,stroke:null,strokeDashArray:bt,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:X,strokeOpacity:X,strokeWidth:null,style:null,surfaceScale:X,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:bt,tabIndex:X,tableValues:null,target:null,targetX:X,targetY:X,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:bt,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:X,underlineThickness:X,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:X,values:null,vAlphabetic:X,vMathematical:X,vectorEffect:null,vHanging:X,vIdeographic:X,version:null,vertAdvY:X,vertOriginX:X,vertOriginY:X,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:X,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:df}),pf=nr({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),hf=nr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:ff}),mf=nr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Ry={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"},My=/[A-Z]/g,hl=/-[a-z]/g,$y=/^data[-\w.:]+$/i;function Fy(e,t){const n=pa(t);let r=t,i=gt;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&$y.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(hl,Zy);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!hl.test(s)){let a=s.replace(My,Ly);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=ro}return new i(r,t)}function Ly(e){return"-"+e.toLowerCase()}function Zy(e){return e.charAt(1).toUpperCase()}const By=uf([cf,Oy,pf,hf,mf],"html"),io=uf([cf,Dy,pf,hf,mf],"svg");function Vy(e){return e.join(" ").trim()}var Pn={},Ns,ml;function Uy(){if(ml)return Ns;ml=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=`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-BW0GiZPm.js","assets/react-vendor-CTFDOf2G.js","assets/editor-monaco-json-15fGSTnt.js","assets/index-DcPXTvEZ.js","assets/query-vendor-Df8-oete.js","assets/radix-ui-BZ5iKMtq.js","assets/ui-vendor-Dyg3GRT-.js","assets/monaco-editor-BcgxPCqT.js","assets/index-B0s8Zyy_.css","assets/MonacoPluginProvider-DGH9IJWW.js","assets/state-vendor-BDrPu9qj.js","assets/button-6lzkhC2g.js","assets/preview-DqEl98dA.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Qh=Object.defineProperty;var em=(e,t,n)=>t in e?Qh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ao=(e,t,n)=>em(e,typeof t!="symbol"?t+"":t,n);import{c as Ee,r as v,j as c,R as nc,g as Da}from"./react-vendor-CTFDOf2G.js";import{B as Ie}from"./button-6lzkhC2g.js";import{c as U,T as Kr,C as tm,E as nm,F as Nt,S as Qt,a as rm,b as Ge,d as Ke,e as Ye,u as rc,f as Ra,s as ps,_ as ic,g as Yr,A as im,h as Xr}from"./index-DcPXTvEZ.js";import{b as sc,c as Ma,d as ac,e as oc,f as Bi,g as Vi,D as Ui,O as Ji,h as lc,S as tr,i as sm,V as am,j as uc,I as om,k as lm,l as cc,m as um,n as dc,o as cm,p as dm,G as fm,q as fc,r as pc,L as hc,s as mc,t as pm,u as hm,v as mm,w as gc,x as xc,y as yc,z as bc,A as vc,B as wc,E as kc,F as Sc,H as _c,J as Cc,K as jc,M as gm,N as xm,Q as Nc,U as ym,W as bm,X as vm,Y as wm,Z as km,_ as Sm,$ as _m,a0 as Cm,a1 as jm,a2 as Ec,a3 as Ic,a4 as zc,a5 as Tc,a6 as Ac,a7 as Pc,a8 as Oc,a9 as Dc,aa as Rc,ab as Nm,ac as Mc,ad as $c,ae as Fc}from"./radix-ui-BZ5iKMtq.js";import{X as wn,a as Vr,C as rn,b as kn,d as Em,e as Hi,f as Lc,P as Im,g as Po,h as Gs,F as Zc,S as Bc,B as Oo,i as zm,j as Tm,k as Am,l as $a,m as Pm,M as Om,n as Dm,o as Rm,p as Vc,q as Mm,r as Do,s as yi,t as $m,I as Uc,G as Fm,u as Lm,R as Zm,v as Bm,T as Jc,E as Vm,w as Um,x as Jm,y as Hc,z as Fa,A as qc,D as Hm,H as Wc,J as qm,K as Wm,L as Ro,N as Gm,O as Ks,Q as Km}from"./ui-vendor-Dyg3GRT-.js";import{i as Ym,u as Xe,a as Ys,b as mn,g as Xs,c as Pt,T as Xm,d as Qr,S as Qm,O as eg,e as tg,M as ng,D as rg}from"./MonacoPluginProvider-DGH9IJWW.js";import{c as ig,d as sg,p as ag,a as og,u as lg,b as ug}from"./state-vendor-BDrPu9qj.js";import{b as cg}from"./query-vendor-Df8-oete.js";var Ur=e=>e.type==="checkbox",xn=e=>e instanceof Date,lt=e=>e==null;const Gc=e=>typeof e=="object";var He=e=>!lt(e)&&!Array.isArray(e)&&Gc(e)&&!xn(e),Kc=e=>He(e)&&e.target?Ur(e.target)?e.target.checked:e.target.value:e,dg=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Yc=(e,t)=>e.has(dg(t)),fg=e=>{const t=e.constructor&&e.constructor.prototype;return He(t)&&t.hasOwnProperty("isPrototypeOf")},La=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function pt(e){let t;const n=Array.isArray(e),r=typeof FileList<"u"?e instanceof FileList:!1;if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(La&&(e instanceof Blob||r))&&(n||He(e)))if(t=n?[]:{},!n&&!fg(e))t=e;else for(const i in e)e.hasOwnProperty(i)&&(t[i]=pt(e[i]));else return e;return t}var qi=e=>Array.isArray(e)?e.filter(Boolean):[],Je=e=>e===void 0,se=(e,t,n)=>{if(!t||!He(e))return n;const r=qi(t.split(/[,[\].]+?/)).reduce((i,s)=>lt(i)?i:i[s],e);return Je(r)||r===e?Je(e[t])?n:e[t]:r},Ct=e=>typeof e=="boolean",Za=e=>/^\w*$/.test(e),Xc=e=>qi(e.replace(/["|']|\]/g,"").split(/\.|\[/)),Pe=(e,t,n)=>{let r=-1;const i=Za(t)?[t]:Xc(t),s=i.length,a=s-1;for(;++r<s;){const o=i[r];let l=n;if(r!==a){const u=e[o];l=He(u)||Array.isArray(u)?u:isNaN(+i[r+1])?{}:[]}if(o==="__proto__"||o==="constructor"||o==="prototype")return;e[o]=l,e=e[o]}return e};const bi={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},At={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Jt={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Qc=Ee.createContext(null),Wi=()=>Ee.useContext(Qc),pg=e=>{const{children:t,...n}=e;return Ee.createElement(Qc.Provider,{value:n},t)};var ed=(e,t,n,r=!0)=>{const i={defaultValues:t._defaultValues};for(const s in e)Object.defineProperty(i,s,{get:()=>{const a=s;return t._proxyFormState[a]!==At.all&&(t._proxyFormState[a]=!r||At.all),n&&(n[a]=!0),e[a]}});return i},ht=e=>He(e)&&!Object.keys(e).length,td=(e,t,n,r)=>{n(e);const{name:i,...s}=e;return ht(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(a=>t[a]===(!r||At.all))},Sr=e=>Array.isArray(e)?e:[e],nd=(e,t,n)=>!e||!t||e===t||Sr(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r)));function Ba(e){const t=Ee.useRef(e);t.current=e,Ee.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}function hg(e){const t=Wi(),{control:n=t.control,disabled:r,name:i,exact:s}=e||{},[a,o]=Ee.useState(n._formState),l=Ee.useRef(!0),u=Ee.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),f=Ee.useRef(i);return f.current=i,Ba({disabled:r,next:d=>l.current&&nd(f.current,d.name,s)&&td(d,u.current,n._updateFormState)&&o({...n._formState,...d}),subject:n._subjects.state}),Ee.useEffect(()=>(l.current=!0,u.current.isValid&&n._updateValid(!0),()=>{l.current=!1}),[n]),Ee.useMemo(()=>ed(a,n,u.current,!1),[a,n])}var Lt=e=>typeof e=="string",rd=(e,t,n,r,i)=>Lt(e)?(r&&t.watch.add(e),se(n,e,i)):Array.isArray(e)?e.map(s=>(r&&t.watch.add(s),se(n,s))):(r&&(t.watchAll=!0),n);function mg(e){const t=Wi(),{control:n=t.control,name:r,defaultValue:i,disabled:s,exact:a}=e||{},o=Ee.useRef(r);o.current=r,Ba({disabled:s,subject:n._subjects.values,next:f=>{nd(o.current,f.name,a)&&u(pt(rd(o.current,n._names,f.values||n._formValues,!1,i)))}});const[l,u]=Ee.useState(n._getWatch(r,i));return Ee.useEffect(()=>n._removeUnmounted()),l}function gg(e){const t=Wi(),{name:n,disabled:r,control:i=t.control,shouldUnregister:s}=e,a=Yc(i._names.array,n),o=mg({control:i,name:n,defaultValue:se(i._formValues,n,se(i._defaultValues,n,e.defaultValue)),exact:!0}),l=hg({control:i,name:n,exact:!0}),u=Ee.useRef(i.register(n,{...e.rules,value:o,...Ct(e.disabled)?{disabled:e.disabled}:{}})),f=Ee.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!se(l.errors,n)},isDirty:{enumerable:!0,get:()=>!!se(l.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!se(l.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!se(l.validatingFields,n)},error:{enumerable:!0,get:()=>se(l.errors,n)}}),[l,n]),d=Ee.useMemo(()=>({name:n,value:o,...Ct(r)||l.disabled?{disabled:l.disabled||r}:{},onChange:h=>u.current.onChange({target:{value:Kc(h),name:n},type:bi.CHANGE}),onBlur:()=>u.current.onBlur({target:{value:se(i._formValues,n),name:n},type:bi.BLUR}),ref:h=>{const p=se(i._fields,n);p&&h&&(p._f.ref={focus:()=>h.focus(),select:()=>h.select(),setCustomValidity:m=>h.setCustomValidity(m),reportValidity:()=>h.reportValidity()})}}),[n,i._formValues,r,l.disabled,o,i._fields]);return Ee.useEffect(()=>{const h=i._options.shouldUnregister||s,p=(m,w)=>{const S=se(i._fields,m);S&&S._f&&(S._f.mount=w)};if(p(n,!0),h){const m=pt(se(i._options.defaultValues,n));Pe(i._defaultValues,n,m),Je(se(i._formValues,n))&&Pe(i._formValues,n,m)}return!a&&i.register(n),()=>{(a?h&&!i._state.action:h)?i.unregister(n):p(n,!1)}},[n,i,a,s]),Ee.useEffect(()=>{i._updateDisabledField({disabled:r,fields:i._fields,name:n})},[r,n,i]),Ee.useMemo(()=>({field:d,formState:l,fieldState:f}),[d,l,f])}const xg=e=>e.render(gg(e));var yg=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},Mo=e=>({isOnSubmit:!e||e===At.onSubmit,isOnBlur:e===At.onBlur,isOnChange:e===At.onChange,isOnAll:e===At.all,isOnTouch:e===At.onTouched}),$o=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const _r=(e,t,n,r)=>{for(const i of n||Object.keys(e)){const s=se(e,i);if(s){const{_f:a,...o}=s;if(a){if(a.refs&&a.refs[0]&&t(a.refs[0],i)&&!r)return!0;if(a.ref&&t(a.ref,a.name)&&!r)return!0;if(_r(o,t))break}else if(He(o)&&_r(o,t))break}}};var bg=(e,t,n)=>{const r=Sr(se(e,n));return Pe(r,"root",t[n]),Pe(e,n,r),e},Va=e=>e.type==="file",Ft=e=>typeof e=="function",vi=e=>{if(!La)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},ci=e=>Lt(e),Ua=e=>e.type==="radio",wi=e=>e instanceof RegExp;const Fo={value:!1,isValid:!1},Lo={value:!0,isValid:!0};var id=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Je(e[0].attributes.value)?Je(e[0].value)||e[0].value===""?Lo:{value:e[0].value,isValid:!0}:Lo:Fo}return Fo};const Zo={isValid:!1,value:null};var sd=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,Zo):Zo;function Bo(e,t,n="validate"){if(ci(e)||Array.isArray(e)&&e.every(ci)||Ct(e)&&!e)return{type:n,message:ci(e)?e:"",ref:t}}var zn=e=>He(e)&&!wi(e)?e:{value:e,message:""},Vo=async(e,t,n,r,i,s)=>{const{ref:a,refs:o,required:l,maxLength:u,minLength:f,min:d,max:h,pattern:p,validate:m,name:w,valueAsNumber:S,mount:y}=e._f,_=se(n,w);if(!y||t.has(w))return{};const x=o?o[0]:a,P=D=>{i&&x.reportValidity&&(x.setCustomValidity(Ct(D)?"":D||""),x.reportValidity())},E={},k=Ua(a),C=Ur(a),V=k||C,Y=(S||Va(a))&&Je(a.value)&&Je(_)||vi(a)&&a.value===""||_===""||Array.isArray(_)&&!_.length,N=yg.bind(null,w,r,E),Z=(D,B,F,T=Jt.maxLength,H=Jt.minLength)=>{const K=D?B:F;E[w]={type:D?T:H,message:K,ref:a,...N(D?T:H,K)}};if(s?!Array.isArray(_)||!_.length:l&&(!V&&(Y||lt(_))||Ct(_)&&!_||C&&!id(o).isValid||k&&!sd(o).isValid)){const{value:D,message:B}=ci(l)?{value:!!l,message:l}:zn(l);if(D&&(E[w]={type:Jt.required,message:B,ref:x,...N(Jt.required,B)},!r))return P(B),E}if(!Y&&(!lt(d)||!lt(h))){let D,B;const F=zn(h),T=zn(d);if(!lt(_)&&!isNaN(_)){const H=a.valueAsNumber||_&&+_;lt(F.value)||(D=H>F.value),lt(T.value)||(B=H<T.value)}else{const H=a.valueAsDate||new Date(_),K=b=>new Date(new Date().toDateString()+" "+b),O=a.type=="time",W=a.type=="week";Lt(F.value)&&_&&(D=O?K(_)>K(F.value):W?_>F.value:H>new Date(F.value)),Lt(T.value)&&_&&(B=O?K(_)<K(T.value):W?_<T.value:H<new Date(T.value))}if((D||B)&&(Z(!!D,F.message,T.message,Jt.max,Jt.min),!r))return P(E[w].message),E}if((u||f)&&!Y&&(Lt(_)||s&&Array.isArray(_))){const D=zn(u),B=zn(f),F=!lt(D.value)&&_.length>+D.value,T=!lt(B.value)&&_.length<+B.value;if((F||T)&&(Z(F,D.message,B.message),!r))return P(E[w].message),E}if(p&&!Y&&Lt(_)){const{value:D,message:B}=zn(p);if(wi(D)&&!_.match(D)&&(E[w]={type:Jt.pattern,message:B,ref:a,...N(Jt.pattern,B)},!r))return P(B),E}if(m){if(Ft(m)){const D=await m(_,n),B=Bo(D,x);if(B&&(E[w]={...B,...N(Jt.validate,B.message)},!r))return P(B.message),E}else if(He(m)){let D={};for(const B in m){if(!ht(D)&&!r)break;const F=Bo(await m[B](_,n),x,B);F&&(D={...F,...N(B,F.message)},P(F.message),r&&(E[w]=D))}if(!ht(D)&&(E[w]={ref:x,...D},!r))return E}}return P(!0),E};function vg(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=Je(e)?r++:e[t[r++]];return e}function wg(e){for(const t in e)if(e.hasOwnProperty(t)&&!Je(e[t]))return!1;return!0}function et(e,t){const n=Array.isArray(t)?t:Za(t)?[t]:Xc(t),r=n.length===1?e:vg(e,n),i=n.length-1,s=n[i];return r&&delete r[s],i!==0&&(He(r)&&ht(r)||Array.isArray(r)&&wg(r))&&et(e,n.slice(0,-1)),e}var hs=()=>{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=[]}}},Qs=e=>lt(e)||!Gc(e);function en(e,t){if(Qs(e)||Qs(t))return e===t;if(xn(e)&&xn(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(xn(s)&&xn(a)||He(s)&&He(a)||Array.isArray(s)&&Array.isArray(a)?!en(s,a):s!==a)return!1}}return!0}var ad=e=>e.type==="select-multiple",kg=e=>Ua(e)||Ur(e),ms=e=>vi(e)&&e.isConnected,od=e=>{for(const t in e)if(Ft(e[t]))return!0;return!1};function ki(e,t={}){const n=Array.isArray(e);if(He(e)||n)for(const r in e)Array.isArray(e[r])||He(e[r])&&!od(e[r])?(t[r]=Array.isArray(e[r])?[]:{},ki(e[r],t[r])):lt(e[r])||(t[r]=!0);return t}function ld(e,t,n){const r=Array.isArray(e);if(He(e)||r)for(const i in e)Array.isArray(e[i])||He(e[i])&&!od(e[i])?Je(t)||Qs(n[i])?n[i]=Array.isArray(e[i])?ki(e[i],[]):{...ki(e[i])}:ld(e[i],lt(t)?{}:t[i],n[i]):n[i]=!en(e[i],t[i]);return n}var ar=(e,t)=>ld(e,t,ki(t)),ud=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>Je(e)?e:t?e===""?NaN:e&&+e:n&&Lt(e)?new Date(e):r?r(e):e;function gs(e){const t=e.ref;return Va(t)?t.files:Ua(t)?sd(e.refs).value:ad(t)?[...t.selectedOptions].map(({value:n})=>n):Ur(t)?id(e.refs).value:ud(Je(t.value)?e.ref.value:t.value,e)}var Sg=(e,t,n,r)=>{const i={};for(const s of e){const a=se(t,s);a&&Pe(i,s,a._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},or=e=>Je(e)?e:wi(e)?e.source:He(e)?wi(e.value)?e.value.source:e.value:e;const Uo="AsyncFunction";var _g=e=>!!e&&!!e.validate&&!!(Ft(e.validate)&&e.validate.constructor.name===Uo||He(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Uo)),Cg=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Jo(e,t,n){const r=se(e,n);if(r||Za(n))return{error:r,name:n};const i=n.split(".");for(;i.length;){const s=i.join("."),a=se(t,s),o=se(e,s);if(a&&!Array.isArray(a)&&n!==s)return{name:n};if(o&&o.type)return{name:s,error:o};i.pop()}return{name:n}}var jg=(e,t,n,r,i)=>i.isOnAll?!1:!n&&i.isOnTouch?!(t||e):(n?r.isOnBlur:i.isOnBlur)?!e:(n?r.isOnChange:i.isOnChange)?e:!0,Ng=(e,t)=>!qi(se(e,t)).length&&et(e,t);const Eg={mode:At.onSubmit,reValidateMode:At.onChange,shouldFocusError:!0};function Ig(e={}){let t={...Eg,...e},n={submitCount:0,isDirty:!1,isLoading:Ft(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},i=He(t.defaultValues)||He(t.values)?pt(t.defaultValues||t.values)||{}:{},s=t.shouldUnregister?{}:pt(i),a={action:!1,mount:!1,watch:!1},o={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},l,u=0;const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},d={values:hs(),array:hs(),state:hs()},h=Mo(t.mode),p=Mo(t.reValidateMode),m=t.criteriaMode===At.all,w=j=>z=>{clearTimeout(u),u=setTimeout(j,z)},S=async j=>{if(!t.disabled&&(f.isValid||j)){const z=t.resolver?ht((await V()).errors):await N(r,!0);z!==n.isValid&&d.state.next({isValid:z})}},y=(j,z)=>{!t.disabled&&(f.isValidating||f.validatingFields)&&((j||Array.from(o.mount)).forEach($=>{$&&(z?Pe(n.validatingFields,$,z):et(n.validatingFields,$))}),d.state.next({validatingFields:n.validatingFields,isValidating:!ht(n.validatingFields)}))},_=(j,z=[],$,ne,te=!0,ee=!0)=>{if(ne&&$&&!t.disabled){if(a.action=!0,ee&&Array.isArray(se(r,j))){const ce=$(se(r,j),ne.argA,ne.argB);te&&Pe(r,j,ce)}if(ee&&Array.isArray(se(n.errors,j))){const ce=$(se(n.errors,j),ne.argA,ne.argB);te&&Pe(n.errors,j,ce),Ng(n.errors,j)}if(f.touchedFields&&ee&&Array.isArray(se(n.touchedFields,j))){const ce=$(se(n.touchedFields,j),ne.argA,ne.argB);te&&Pe(n.touchedFields,j,ce)}f.dirtyFields&&(n.dirtyFields=ar(i,s)),d.state.next({name:j,isDirty:D(j,z),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Pe(s,j,z)},x=(j,z)=>{Pe(n.errors,j,z),d.state.next({errors:n.errors})},P=j=>{n.errors=j,d.state.next({errors:n.errors,isValid:!1})},E=(j,z,$,ne)=>{const te=se(r,j);if(te){const ee=se(s,j,Je($)?se(i,j):$);Je(ee)||ne&&ne.defaultChecked||z?Pe(s,j,z?ee:gs(te._f)):T(j,ee),a.mount&&S()}},k=(j,z,$,ne,te)=>{let ee=!1,ce=!1;const xe={name:j};if(!t.disabled){const M=!!(se(r,j)&&se(r,j)._f&&se(r,j)._f.disabled);if(!$||ne){f.isDirty&&(ce=n.isDirty,n.isDirty=xe.isDirty=D(),ee=ce!==xe.isDirty);const q=M||en(se(i,j),z);ce=!!(!M&&se(n.dirtyFields,j)),q||M?et(n.dirtyFields,j):Pe(n.dirtyFields,j,!0),xe.dirtyFields=n.dirtyFields,ee=ee||f.dirtyFields&&ce!==!q}if($){const q=se(n.touchedFields,j);q||(Pe(n.touchedFields,j,$),xe.touchedFields=n.touchedFields,ee=ee||f.touchedFields&&q!==$)}ee&&te&&d.state.next(xe)}return ee?xe:{}},C=(j,z,$,ne)=>{const te=se(n.errors,j),ee=f.isValid&&Ct(z)&&n.isValid!==z;if(t.delayError&&$?(l=w(()=>x(j,$)),l(t.delayError)):(clearTimeout(u),l=null,$?Pe(n.errors,j,$):et(n.errors,j)),($?!en(te,$):te)||!ht(ne)||ee){const ce={...ne,...ee&&Ct(z)?{isValid:z}:{},errors:n.errors,name:j};n={...n,...ce},d.state.next(ce)}},V=async j=>{y(j,!0);const z=await t.resolver(s,t.context,Sg(j||o.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return y(j),z},Y=async j=>{const{errors:z}=await V(j);if(j)for(const $ of j){const ne=se(z,$);ne?Pe(n.errors,$,ne):et(n.errors,$)}else n.errors=z;return z},N=async(j,z,$={valid:!0})=>{for(const ne in j){const te=j[ne];if(te){const{_f:ee,...ce}=te;if(ee){const xe=o.array.has(ee.name),M=te._f&&_g(te._f);M&&f.validatingFields&&y([ne],!0);const q=await Vo(te,o.disabled,s,m,t.shouldUseNativeValidation&&!z,xe);if(M&&f.validatingFields&&y([ne]),q[ee.name]&&($.valid=!1,z))break;!z&&(se(q,ee.name)?xe?bg(n.errors,q,ee.name):Pe(n.errors,ee.name,q[ee.name]):et(n.errors,ee.name))}!ht(ce)&&await N(ce,z,$)}}return $.valid},Z=()=>{for(const j of o.unMount){const z=se(r,j);z&&(z._f.refs?z._f.refs.every($=>!ms($)):!ms(z._f.ref))&&Q(j)}o.unMount=new Set},D=(j,z)=>!t.disabled&&(j&&z&&Pe(s,j,z),!en(ue(),i)),B=(j,z,$)=>rd(j,o,{...a.mount?s:Je(z)?i:Lt(j)?{[j]:z}:z},$,z),F=j=>qi(se(a.mount?s:i,j,t.shouldUnregister?se(i,j,[]):[])),T=(j,z,$={})=>{const ne=se(r,j);let te=z;if(ne){const ee=ne._f;ee&&(!ee.disabled&&Pe(s,j,ud(z,ee)),te=vi(ee.ref)&<(z)?"":z,ad(ee.ref)?[...ee.ref.options].forEach(ce=>ce.selected=te.includes(ce.value)):ee.refs?Ur(ee.ref)?ee.refs.length>1?ee.refs.forEach(ce=>(!ce.defaultChecked||!ce.disabled)&&(ce.checked=Array.isArray(te)?!!te.find(xe=>xe===ce.value):te===ce.value)):ee.refs[0]&&(ee.refs[0].checked=!!te):ee.refs.forEach(ce=>ce.checked=ce.value===te):Va(ee.ref)?ee.ref.value="":(ee.ref.value=te,ee.ref.type||d.values.next({name:j,values:{...s}})))}($.shouldDirty||$.shouldTouch)&&k(j,te,$.shouldTouch,$.shouldDirty,!0),$.shouldValidate&&b(j)},H=(j,z,$)=>{for(const ne in z){const te=z[ne],ee=`${j}.${ne}`,ce=se(r,ee);(o.array.has(j)||He(te)||ce&&!ce._f)&&!xn(te)?H(ee,te,$):T(ee,te,$)}},K=(j,z,$={})=>{const ne=se(r,j),te=o.array.has(j),ee=pt(z);Pe(s,j,ee),te?(d.array.next({name:j,values:{...s}}),(f.isDirty||f.dirtyFields)&&$.shouldDirty&&d.state.next({name:j,dirtyFields:ar(i,s),isDirty:D(j,ee)})):ne&&!ne._f&&!lt(ee)?H(j,ee,$):T(j,ee,$),$o(j,o)&&d.state.next({...n}),d.values.next({name:a.mount?j:void 0,values:{...s}})},O=async j=>{a.mount=!0;const z=j.target;let $=z.name,ne=!0;const te=se(r,$),ee=()=>z.type?gs(te._f):Kc(j),ce=xe=>{ne=Number.isNaN(xe)||xn(xe)&&isNaN(xe.getTime())||en(xe,se(s,$,xe))};if(te){let xe,M;const q=ee(),de=j.type===bi.BLUR||j.type===bi.FOCUS_OUT,ve=!Cg(te._f)&&!t.resolver&&!se(n.errors,$)&&!te._f.deps||jg(de,se(n.touchedFields,$),n.isSubmitted,p,h),A=$o($,o,de);Pe(s,$,q),de?(te._f.onBlur&&te._f.onBlur(j),l&&l(0)):te._f.onChange&&te._f.onChange(j);const fe=k($,q,de,!1),Ce=!ht(fe)||A;if(!de&&d.values.next({name:$,type:j.type,values:{...s}}),ve)return f.isValid&&(t.mode==="onBlur"&&de?S():de||S()),Ce&&d.state.next({name:$,...A?{}:fe});if(!de&&A&&d.state.next({...n}),t.resolver){const{errors:Re}=await V([$]);if(ce(q),ne){const Qe=Jo(n.errors,r,$),qe=Jo(Re,r,Qe.name||$);xe=qe.error,$=qe.name,M=ht(Re)}}else y([$],!0),xe=(await Vo(te,o.disabled,s,m,t.shouldUseNativeValidation))[$],y([$]),ce(q),ne&&(xe?M=!1:f.isValid&&(M=await N(r,!0)));ne&&(te._f.deps&&b(te._f.deps),C($,M,xe,fe))}},W=(j,z)=>{if(se(n.errors,z)&&j.focus)return j.focus(),1},b=async(j,z={})=>{let $,ne;const te=Sr(j);if(t.resolver){const ee=await Y(Je(j)?j:te);$=ht(ee),ne=j?!te.some(ce=>se(ee,ce)):$}else j?(ne=(await Promise.all(te.map(async ee=>{const ce=se(r,ee);return await N(ce&&ce._f?{[ee]:ce}:ce)}))).every(Boolean),!(!ne&&!n.isValid)&&S()):ne=$=await N(r);return d.state.next({...!Lt(j)||f.isValid&&$!==n.isValid?{}:{name:j},...t.resolver||!j?{isValid:$}:{},errors:n.errors}),z.shouldFocus&&!ne&&_r(r,W,j?te:o.mount),ne},ue=j=>{const z={...a.mount?s:i};return Je(j)?z:Lt(j)?se(z,j):j.map($=>se(z,$))},ae=(j,z)=>({invalid:!!se((z||n).errors,j),isDirty:!!se((z||n).dirtyFields,j),error:se((z||n).errors,j),isValidating:!!se(n.validatingFields,j),isTouched:!!se((z||n).touchedFields,j)}),g=j=>{j&&Sr(j).forEach(z=>et(n.errors,z)),d.state.next({errors:j?n.errors:{}})},G=(j,z,$)=>{const ne=(se(r,j,{_f:{}})._f||{}).ref,te=se(n.errors,j)||{},{ref:ee,message:ce,type:xe,...M}=te;Pe(n.errors,j,{...M,...z,ref:ne}),d.state.next({name:j,errors:n.errors,isValid:!1}),$&&$.shouldFocus&&ne&&ne.focus&&ne.focus()},ie=(j,z)=>Ft(j)?d.values.subscribe({next:$=>j(B(void 0,z),$)}):B(j,z,!0),Q=(j,z={})=>{for(const $ of j?Sr(j):o.mount)o.mount.delete($),o.array.delete($),z.keepValue||(et(r,$),et(s,$)),!z.keepError&&et(n.errors,$),!z.keepDirty&&et(n.dirtyFields,$),!z.keepTouched&&et(n.touchedFields,$),!z.keepIsValidating&&et(n.validatingFields,$),!t.shouldUnregister&&!z.keepDefaultValue&&et(i,$);d.values.next({values:{...s}}),d.state.next({...n,...z.keepDirty?{isDirty:D()}:{}}),!z.keepIsValid&&S()},I=({disabled:j,name:z,field:$,fields:ne})=>{(Ct(j)&&a.mount||j||o.disabled.has(z))&&(j?o.disabled.add(z):o.disabled.delete(z),k(z,gs($?$._f:se(ne,z)._f),!1,!1,!0))},R=(j,z={})=>{let $=se(r,j);const ne=Ct(z.disabled)||Ct(t.disabled);return Pe(r,j,{...$||{},_f:{...$&&$._f?$._f:{ref:{name:j}},name:j,mount:!0,...z}}),o.mount.add(j),$?I({field:$,disabled:Ct(z.disabled)?z.disabled:t.disabled,name:j}):E(j,!0,z.value),{...ne?{disabled:z.disabled||t.disabled}:{},...t.progressive?{required:!!z.required,min:or(z.min),max:or(z.max),minLength:or(z.minLength),maxLength:or(z.maxLength),pattern:or(z.pattern)}:{},name:j,onChange:O,onBlur:O,ref:te=>{if(te){R(j,z),$=se(r,j);const ee=Je(te.value)&&te.querySelectorAll&&te.querySelectorAll("input,select,textarea")[0]||te,ce=kg(ee),xe=$._f.refs||[];if(ce?xe.find(M=>M===ee):ee===$._f.ref)return;Pe(r,j,{_f:{...$._f,...ce?{refs:[...xe.filter(ms),ee,...Array.isArray(se(i,j))?[{}]:[]],ref:{type:ee.type,name:j}}:{ref:ee}}}),E(j,!1,void 0,ee)}else $=se(r,j,{}),$._f&&($._f.mount=!1),(t.shouldUnregister||z.shouldUnregister)&&!(Yc(o.array,j)&&a.action)&&o.unMount.add(j)}}},J=()=>t.shouldFocusError&&_r(r,W,o.mount),oe=j=>{Ct(j)&&(d.state.next({disabled:j}),_r(r,(z,$)=>{const ne=se(r,$);ne&&(z.disabled=ne._f.disabled||j,Array.isArray(ne._f.refs)&&ne._f.refs.forEach(te=>{te.disabled=ne._f.disabled||j}))},0,!1))},pe=(j,z)=>async $=>{let ne;$&&($.preventDefault&&$.preventDefault(),$.persist&&$.persist());let te=pt(s);if(o.disabled.size)for(const ee of o.disabled)Pe(te,ee,void 0);if(d.state.next({isSubmitting:!0}),t.resolver){const{errors:ee,values:ce}=await V();n.errors=ee,te=ce}else await N(r);if(et(n.errors,"root"),ht(n.errors)){d.state.next({errors:{}});try{await j(te,$)}catch(ee){ne=ee}}else z&&await z({...n.errors},$),J(),setTimeout(J);if(d.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ht(n.errors)&&!ne,submitCount:n.submitCount+1,errors:n.errors}),ne)throw ne},Ae=(j,z={})=>{se(r,j)&&(Je(z.defaultValue)?K(j,pt(se(i,j))):(K(j,z.defaultValue),Pe(i,j,pt(z.defaultValue))),z.keepTouched||et(n.touchedFields,j),z.keepDirty||(et(n.dirtyFields,j),n.isDirty=z.defaultValue?D(j,pt(se(i,j))):D()),z.keepError||(et(n.errors,j),f.isValid&&S()),d.state.next({...n}))},ke=(j,z={})=>{const $=j?pt(j):i,ne=pt($),te=ht(j),ee=te?i:ne;if(z.keepDefaultValues||(i=$),!z.keepValues){if(z.keepDirtyValues){const ce=new Set([...o.mount,...Object.keys(ar(i,s))]);for(const xe of Array.from(ce))se(n.dirtyFields,xe)?Pe(ee,xe,se(s,xe)):K(xe,se(ee,xe))}else{if(La&&Je(j))for(const ce of o.mount){const xe=se(r,ce);if(xe&&xe._f){const M=Array.isArray(xe._f.refs)?xe._f.refs[0]:xe._f.ref;if(vi(M)){const q=M.closest("form");if(q){q.reset();break}}}}r={}}s=t.shouldUnregister?z.keepDefaultValues?pt(i):{}:pt(ee),d.array.next({values:{...ee}}),d.values.next({values:{...ee}})}o={mount:z.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},a.mount=!f.isValid||!!z.keepIsValid||!!z.keepDirtyValues,a.watch=!!t.shouldUnregister,d.state.next({submitCount:z.keepSubmitCount?n.submitCount:0,isDirty:te?!1:z.keepDirty?n.isDirty:!!(z.keepDefaultValues&&!en(j,i)),isSubmitted:z.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:te?{}:z.keepDirtyValues?z.keepDefaultValues&&s?ar(i,s):n.dirtyFields:z.keepDefaultValues&&j?ar(i,j):z.keepDirty?n.dirtyFields:{},touchedFields:z.keepTouched?n.touchedFields:{},errors:z.keepErrors?n.errors:{},isSubmitSuccessful:z.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},be=(j,z)=>ke(Ft(j)?j(s):j,z);return{control:{register:R,unregister:Q,getFieldState:ae,handleSubmit:pe,setError:G,_executeSchema:V,_getWatch:B,_getDirty:D,_updateValid:S,_removeUnmounted:Z,_updateFieldArray:_,_updateDisabledField:I,_getFieldArray:F,_reset:ke,_resetDefaultValues:()=>Ft(t.defaultValues)&&t.defaultValues().then(j=>{be(j,t.resetOptions),d.state.next({isLoading:!1})}),_updateFormState:j=>{n={...n,...j}},_disableForm:oe,_subjects:d,_proxyFormState:f,_setErrors:P,get _fields(){return r},get _formValues(){return s},get _state(){return a},set _state(j){a=j},get _defaultValues(){return i},get _names(){return o},set _names(j){o=j},get _formState(){return n},set _formState(j){n=j},get _options(){return t},set _options(j){t={...t,...j}}},trigger:b,register:R,handleSubmit:pe,watch:ie,setValue:K,getValues:ue,reset:be,resetField:Ae,clearErrors:g,unregister:Q,setError:G,setFocus:(j,z={})=>{const $=se(r,j),ne=$&&$._f;if(ne){const te=ne.refs?ne.refs[0]:ne.ref;te.focus&&(te.focus(),z.shouldSelect&&Ft(te.select)&&te.select())}},getFieldState:ae}}function zg(e={}){const t=Ee.useRef(void 0),n=Ee.useRef(void 0),[r,i]=Ee.useState({isDirty:!1,isValidating:!1,isLoading:Ft(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Ft(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...Ig(e),formState:r});const s=t.current.control;return s._options=e,Ba({subject:s._subjects.state,next:a=>{td(a,s._proxyFormState,s._updateFormState,!0)&&i({...s._formState})}}),Ee.useEffect(()=>s._disableForm(e.disabled),[s,e.disabled]),Ee.useEffect(()=>{if(s._proxyFormState.isDirty){const a=s._getDirty();a!==r.isDirty&&s._subjects.state.next({isDirty:a})}},[s,r.isDirty]),Ee.useEffect(()=>{e.values&&!en(e.values,n.current)?(s._reset(e.values,s._options.resetOptions),n.current=e.values,i(a=>({...a}))):s._resetDefaultValues()},[e.values,s]),Ee.useEffect(()=>{e.errors&&s._setErrors(e.errors)},[e.errors,s]),Ee.useEffect(()=>{s._state.mount||(s._updateValid(),s._state.mount=!0),s._state.watch&&(s._state.watch=!1,s._subjects.state.next({...s._formState})),s._removeUnmounted()}),Ee.useEffect(()=>{e.shouldUnregister&&s._subjects.values.next({values:s._getWatch()})},[e.shouldUnregister,s]),t.current.formState=ed(r,s),t.current}function Tg(e){return async t=>{const n=e(t);if(n.success&&n.data)return{values:n.data,errors:{}};const r={};if(n.errors)for(const i of n.errors){const s=i.path||"root";r[s]||(r[s]={type:"validation",message:i.message})}return{values:{},errors:r}}}const qt=sc,Ho=ac,Ag=oc,qo=Ma,cd=v.forwardRef(({className:e,...t},n)=>c.jsx(Ji,{ref:n,className:U("fixed inset-0 z-50 bg-black/80",e),...t}));cd.displayName=Ji.displayName;const Zt=v.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Ag,{children:[c.jsx(cd,{}),c.jsxs(Bi,{ref:r,className:U("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(Ma,{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(wn,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Zt.displayName=Bi.displayName;const Sn=({className:e,...t})=>c.jsx("div",{className:U("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Sn.displayName="DialogHeader";const zr=({className:e,...t})=>c.jsx("div",{className:U("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});zr.displayName="DialogFooter";const _n=v.forwardRef(({className:e,...t},n)=>c.jsx(Vi,{ref:n,className:U("text-lg leading-none font-semibold tracking-tight",e),...t}));_n.displayName=Vi.displayName;const Gn=v.forwardRef(({className:e,...t},n)=>c.jsx(Ui,{ref:n,className:U("text-muted-foreground text-sm",e),...t}));Gn.displayName=Ui.displayName;const Pg=Vr("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ja=v.forwardRef(({className:e,...t},n)=>c.jsx(lc,{ref:n,className:U(Pg(),e),...t}));Ja.displayName=lc.displayName;const Og=pg,dd=v.createContext({}),Wo=({...e})=>c.jsx(dd.Provider,{value:{name:e.name},children:c.jsx(xg,{...e})}),Gi=()=>{const e=v.useContext(dd),t=v.useContext(fd),{getFieldState:n,formState:r}=Wi(),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}},fd=v.createContext({}),ea=v.forwardRef(({className:e,...t},n)=>{const r=v.useId();return c.jsx(fd.Provider,{value:{id:r},children:c.jsx("div",{ref:n,className:U("space-y-2",e),...t})})});ea.displayName="FormItem";const ta=v.forwardRef(({className:e,...t},n)=>{const{error:r,formItemId:i}=Gi();return c.jsx(Ja,{ref:n,className:U(r&&"text-destructive",e),htmlFor:i,...t})});ta.displayName="FormLabel";const na=v.forwardRef(({...e},t)=>{const{error:n,formItemId:r,formDescriptionId:i,formMessageId:s}=Gi();return c.jsx(tr,{ref:t,id:r,"aria-describedby":n?`${i} ${s}`:`${i}`,"aria-invalid":!!n,...e})});na.displayName="FormControl";const pd=v.forwardRef(({className:e,...t},n)=>{const{formDescriptionId:r}=Gi();return c.jsx("p",{ref:n,id:r,className:U("text-muted-foreground text-[0.8rem]",e),...t})});pd.displayName="FormDescription";const ra=v.forwardRef(({className:e,children:t,...n},r)=>{const{error:i,formMessageId:s}=Gi(),a=i?String(i==null?void 0:i.message):t;return a?c.jsx("p",{ref:r,id:s,className:U("text-destructive text-[0.8rem] font-medium",e),...n,children:a}):null});ra.displayName="FormMessage";const Ha=v.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:U("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}));Ha.displayName="Input";const qa=sm,Dg=fm,Wa=am,Ki=v.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(uc,{ref:r,className:U("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(om,{asChild:!0,children:c.jsx(rn,{className:"h-4 w-4 shrink-0 opacity-50"})})]}));Ki.displayName=uc.displayName;const hd=v.forwardRef(({className:e,...t},n)=>c.jsx(fc,{ref:n,className:U("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(Em,{className:"h-4 w-4"})}));hd.displayName=fc.displayName;const md=v.forwardRef(({className:e,...t},n)=>c.jsx(pc,{ref:n,className:U("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(rn,{className:"h-4 w-4"})}));md.displayName=pc.displayName;const Yi=v.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>c.jsx(lm,{children:c.jsxs(cc,{ref:i,className:U("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(hd,{}),c.jsx(um,{className:U("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(md,{})]})}));Yi.displayName=cc.displayName;const gd=v.forwardRef(({className:e,...t},n)=>c.jsx(hc,{ref:n,className:U("px-2 py-1.5 text-sm font-semibold",e),...t}));gd.displayName=hc.displayName;const Tr=v.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(dc,{ref:r,className:U("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(cm,{children:c.jsx(kn,{className:"h-4 w-4"})})}),c.jsx(dm,{children:t})]}));Tr.displayName=dc.displayName;const Rg=v.forwardRef(({className:e,...t},n)=>c.jsx(mc,{ref:n,className:U("bg-muted -mx-1 my-1 h-px",e),...t}));Rg.displayName=mc.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 xd=()=>({chatOpen:!1,scope:"global",model:"opus",contextAttachments:[],threads:{},activeThreadId:{}}),Mg=(e=xd())=>ig()(sg(ag((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(f=>f.documentName===o);u.length>0?(u.sort((f,d)=>d.updatedAt-f.updatedAt),l[o]=u[0].id):delete l[o]}t({threads:a,activeThreadId:l})},switchThread:r=>{const s=n().threads[r];s&&t(a=>({activeThreadId:{...a.activeThreadId,[s.documentName]:r}}))},updateThreadMessages:(r,i)=>{t(s=>{const a=s.threads[r];return a?{threads:{...s.threads,[r]:{...a,messages:i,updatedAt:Date.now()}}}:s})},updateThreadTitle:(r,i)=>{t(s=>{const a=s.threads[r];return a?{threads:{...s.threads,[r]:{...a,title:i}}}:s})},deleteThreadsForDocument:r=>{t(i=>{const s={...i.threads},a={...i.activeThreadId};for(const[o,l]of Object.entries(s))l.documentName===r&&delete s[o];return delete a[r],{threads:s,activeThreadId:a}})},renameThreadsForDocument:(r,i)=>{t(s=>{const a={...s.threads},o={...s.activeThreadId};for(const[l,u]of Object.entries(a))u.documentName===r&&(a[l]={...u,documentName:i});return r in o&&(o[i]=o[r],delete o[r]),{threads:a,activeThreadId:o}})},clearChat:()=>{t(r=>({contextAttachments:[]}))}}),{name:"chat-storage",version:1,storage:og(()=>Ym),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}}))),yd=v.createContext(void 0),$g=({children:e})=>{const t=v.useRef(null);return t.current||(t.current=Mg(xd())),c.jsx(yd.Provider,{value:t.current,children:e})},ze=e=>{const t=v.useContext(yd);if(!t)throw new Error("useChatStore must be used within ChatStoreProvider");return lg(t,e)};function Fg(e,t,n){return t.filter(r=>r.name!==n).every(r=>r.name!==e)}function Lg(e,t,n){const r={},i=[];e!=="delete"&&(r.name=Kr.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=Kr.Optional(Kr.String({description:"Template selection"})));const s=Kr.Object(r,{additionalProperties:!1,required:i.length>0?i:void 0});return{schema:s,validate:a=>{const o=[];if(!tm(s,a))for(const u of nm(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 Zg(e,t,n){return e==="create"?{name:"",template:t}:e==="update"?{name:n}:{}}const Bg=e=>({create:{title:e?"New Theme":"New Document",description:e?"Create a new theme from scratch or based on discovered themes.":"Create a new document from scratch or based on discovered documents.",button:"Create",buttonVariant:"default"},update:{title:"Rename Document",description:"Give your document a new name.",button:"Save",buttonVariant:"default"},delete:{title:"Are you absolutely sure?",description:"This action cannot be undone. Are you sure you want to permanently delete this document?",button:"Confirm",buttonVariant:"destructive"}}),lr="__empty__";function Vg({mode:e,shouldReset:t,postSubmit:n,selectedName:r,discoveredDocuments:i,discoveredThemes:s,isTheme:a}){const[o,l]=v.useState(!1),[u,f]=v.useState(null),d=Bg(a),{documents:h,openTabs:p,createDocument:m,renameDocument:w,deleteDocument:S,openDocument:y,closeDocument:_}=Xe(O=>O),{updateTheme:x,removeTheme:P}=Ys(O=>O),E=ze(O=>O.renameThreadsForDocument),k=ze(O=>O.deleteThreadsForDocument),C=v.useMemo(()=>a?s||[]:i||[],[a,i,s]),V=v.useMemo(()=>{const O={current:[],downstream:[]};return C.forEach(W=>{O[W.location]&&O[W.location].push(W)}),O},[C]),Y=v.useMemo(()=>C.map(O=>({name:O.name,type:"application/json",text:"",mtime:new Date,ctime:new Date,atime:new Date})),[C]),N=v.useMemo(()=>Lg(e,O=>Fg(O,h,r),Y),[e,h,r,Y]),Z=N.schema,D=v.useMemo(()=>{const O=new Map;return C.forEach(W=>O.set(W.path,W)),O},[C]),B=lr,F=zg({resolver:Tg(N.validate),defaultValues:Zg(e,void 0,r)}),[T,H]=v.useState(B);v.useEffect(()=>{if(T&&T!==lr&&e==="create"){const O=D.get(T);O&&fetch(`/api/discovery/${a?"themes":"documents"}/${encodeURIComponent(O.name)}/content`).then(W=>{if(!W.ok)throw new Error(`Failed to fetch content: ${W.statusText}`);return W.text()}).then(W=>{try{const b=JSON.parse(W);f(JSON.stringify(b,null,2))}catch(b){console.error("Invalid JSON content received:",b),f(null)}}).catch(W=>{console.error("Failed to fetch content:",W),f(null)})}},[T,e,D,a]),v.useEffect(()=>{t&&(F.reset(),f(null),H(B))},[F,t]);const K=F.handleSubmit(async({name:O,template:W})=>{l(!0);try{if(await new Promise(b=>setTimeout(b,200)),e==="create"){const b=T?D.get(T):C.find(R=>R.name===W);let ue,ae=O;if(a){const R=ae.replace(/\.(json|theme)$/i,"").toLowerCase().replace(/\s+/g,"-");ue=u||JSON.stringify(Nt==="docx"?{name:R,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:R,colors:{primary:"#2563EB",secondary:"#64748B",accent:"#F8FAFC",background:"#FFFFFF",text:"#334155"},fonts:{heading:"Calibri",body:"Calibri"},defaults:{fontSize:18,fontColor:"#334155"}},null,2);const oe=`.${Nt}.theme.json`;ae.endsWith(oe)||(ae=ae.replace(/\.(pptx|docx)\.theme\.json$/i,"").replace(/\.theme\.json$/i,"").replace(/\.json$/i,""),ae+=oe)}else{const R=b;ue=u||JSON.stringify(Nt==="docx"?{name:"docx",props:{theme:(R==null?void 0:R.theme)||"default",metadata:{title:(R==null?void 0:R.title)||ae.replace(/\.(json|js)$/i,"")}},children:[{name:"section",props:{},children:[{name:"paragraph",props:{text:"Start writing your document content here..."}}]}]}:{name:"pptx",props:{title:(R==null?void 0:R.title)||ae.replace(/\.(json|js)$/i,""),theme:(R==null?void 0:R.theme)||"default"},children:[{name:"slide",props:{},children:[{name:"text",props:{text:"Start writing your presentation content here...",fontSize:24,y:2,x:1,w:8}}]}]},null,2);const J=Nt==="docx"?".docx.json":".pptx.json";!ae.endsWith(J)&&!ae.endsWith(".json")&&(ae+=J)}const g=ae.match(/(\.(pptx|docx)(\.theme)?\.json|\.json)$/i),G=g?g[0]:"",ie=ae.slice(0,ae.length-G.length);let Q=ae,I=1;for(;h.some(R=>R.name===Q);)I++,Q=`${ie} (${I})${G}`;ae=Q,m(ae,ue),y(ae),a&&x(ae,ue)}else if(e==="update"){const b=r,ue=O,ae=p.includes(b);ae&&_(b),w(b,ue),E(b,ue),ae&&y(ue)}else if(e==="delete"){const b=r;_(b),S(b),k(b),a&&P(b)}n()}finally{l(!1)}});return c.jsx(Og,{...F,children:c.jsxs("form",{onSubmit:K,children:[c.jsxs(Sn,{children:[c.jsx(_n,{children:d[e].title}),c.jsx(Gn,{children:d[e].description})]}),c.jsxs("div",{className:"flex flex-col gap-4 py-4",children:[Z.properties&&"name"in Z.properties&&c.jsx(Wo,{control:F.control,name:"name",render:({field:O})=>c.jsxs(ea,{children:[c.jsx(ta,{children:"Name"}),c.jsx(na,{children:c.jsx(Ha,{placeholder:"Enter a name or select a template below",autoComplete:"off",...O})}),c.jsx(ra,{})]})}),e==="create"&&c.jsx(Wo,{control:F.control,name:"template",render:({field:O})=>c.jsxs(ea,{children:[c.jsx(ta,{children:a?"Base Theme":"Base Document"}),c.jsxs(qa,{onValueChange:W=>{if(W===lr)O.onChange(void 0),F.setValue("name",""),H(lr),f(null);else{const b=D.get(W);b&&(O.onChange(b.name),F.setValue("name",b.name),H(W))}},defaultValue:B,children:[c.jsx(na,{children:c.jsx(Ki,{children:c.jsx(Wa,{placeholder:`Select a discovered ${a?"theme":"document"}`})})}),c.jsxs(Yi,{className:"max-h-[300px]",children:[c.jsxs(Tr,{value:lr,children:["Empty ",a?"theme":"document"]}),Object.entries(V).map(([W,b])=>b.length===0?null:c.jsxs(Dg,{children:[c.jsx(gd,{children:W==="current"?"📁 Current Directory":"📦 Project"}),b.map(ue=>{let ae=ue.name;if(ue.title)ae=`${ue.name} - ${ue.title}`;else if(ue.description){const g=ue.description.length>40?ue.description.substring(0,40)+"...":ue.description;ae=`${ue.name} - ${g}`}return c.jsx(Tr,{value:ue.path,className:"pl-6",children:ae},ue.path)})]},W))]})]}),c.jsxs(pd,{children:["Start empty or select a discovered"," ",a?"theme":"document"," as a starting point"]}),c.jsx(ra,{})]})})]}),c.jsx(zr,{children:c.jsx(Ie,{type:"submit",variant:d[e].buttonVariant,disabled:o,children:o?c.jsxs(c.Fragment,{children:[c.jsx(Qt,{size:"sm",className:"mr-2"}),e==="create"?"Creating...":e==="update"?"Saving...":"Deleting..."]}):d[e].button})})]})})}const Si=Ee.memo(Vg),Ug=pm,Jg=hm,Hg=v.forwardRef(({className:e,inset:t,children:n,...r},i)=>c.jsxs(bc,{ref:i,className:U("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(Hi,{className:"ml-auto h-4 w-4"})]}));Hg.displayName=bc.displayName;const qg=v.forwardRef(({className:e,...t},n)=>c.jsx(vc,{ref:n,className:U("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}));qg.displayName=vc.displayName;const bd=v.forwardRef(({className:e,...t},n)=>c.jsx(mm,{children:c.jsx(gc,{ref:n,className:U("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})}));bd.displayName=gc.displayName;const mr=v.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(xc,{ref:r,className:U("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}));mr.displayName=xc.displayName;const Wg=v.forwardRef(({className:e,children:t,checked:n,...r},i)=>c.jsxs(wc,{ref:i,className:U("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(kc,{children:c.jsx(kn,{className:"h-4 w-4"})})}),t]}));Wg.displayName=wc.displayName;const Gg=v.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Sc,{ref:r,className:U("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(kc,{children:c.jsx(Lc,{className:"h-4 w-4 fill-current"})})}),t]}));Gg.displayName=Sc.displayName;const Kg=v.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(_c,{ref:r,className:U("text-foreground px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Kg.displayName=_c.displayName;const ia=v.forwardRef(({className:e,...t},n)=>c.jsx(yc,{ref:n,className:U("bg-border -mx-1 my-1 h-px",e),...t}));ia.displayName=yc.displayName;const di=({className:e,...t})=>c.jsx("span",{className:U("text-muted-foreground ml-auto text-xs tracking-widest",e),...t});di.displayName="ContextMenuShortcut";const vd=v.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},i)=>c.jsx(Cc,{ref:i,decorative:n,orientation:t,className:U("bg-border shrink-0",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));vd.displayName=Cc.displayName;const wd=sc,Yg=ac,Xg=oc,kd=v.forwardRef(({className:e,...t},n)=>c.jsx(Ji,{className:U("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}));kd.displayName=Ji.displayName;const Qg=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"}}),Ka=v.forwardRef(({side:e="right",className:t,children:n,...r},i)=>c.jsxs(Xg,{children:[c.jsx(kd,{}),c.jsxs(Bi,{ref:i,className:U(Qg({side:e}),t),...r,children:[c.jsxs(Ma,{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(wn,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]}),n]})]}));Ka.displayName=Bi.displayName;const ex=v.forwardRef(({className:e,...t},n)=>c.jsx(Vi,{ref:n,className:U("text-foreground text-lg font-semibold",e),...t}));ex.displayName=Vi.displayName;const tx=v.forwardRef(({className:e,...t},n)=>c.jsx(Ui,{ref:n,className:U("text-muted-foreground text-sm",e),...t}));tx.displayName=Ui.displayName;function Cr({className:e,...t}){return c.jsx("div",{className:U("bg-primary/10 animate-pulse rounded-md",e),...t})}const xs=768,ys=1200;function Sd(e){return typeof window<"u"?window.innerWidth<e:!1}function _d(){const[e,t]=v.useState(()=>Sd(xs));return v.useEffect(()=>{const n=window.matchMedia(`(max-width: ${xs-1}px)`),r=()=>{t(window.innerWidth<xs)};return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}function nx(){const[e,t]=v.useState(()=>Sd(ys));return v.useEffect(()=>{const n=window.matchMedia(`(max-width: ${ys-1}px)`),r=()=>{t(window.innerWidth<ys)};return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}const rx="sidebar_state",ix=60*60*24*7,sx="16rem",ax="18rem",ox="3rem",lx="b",Cd=v.createContext(null);function Xi(){const e=v.useContext(Cd);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const jd=v.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:s,...a},o)=>{const l=_d(),[u,f]=v.useState(!1),[d,h]=v.useState(e),p=t??d,m=v.useCallback(_=>{const x=typeof _=="function"?_(p):_;n?n(x):h(x),document.cookie=`${rx}=${x}; path=/; max-age=${ix}`},[n,p]),w=v.useCallback(()=>l?f(_=>!_):m(_=>!_),[l,m,f]);v.useEffect(()=>{const _=P=>{var C;const E=P;if(!E)return!1;const k=(C=E.tagName)==null?void 0:C.toLowerCase();return k==="input"||k==="textarea"||k==="select"||E.isContentEditable?!0:!!(E.closest&&E.closest(".monaco-editor"))},x=P=>{const E=P.metaKey||P.ctrlKey,k=P.key.toLowerCase();if(E&&k===lx){P.preventDefault(),w();return}E&&k==="s"&&!_(P.target)&&(P.preventDefault(),w())};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[w]);const S=p?"expanded":"collapsed",y=v.useMemo(()=>({state:S,open:p,setOpen:m,isMobile:l,openMobile:u,setOpenMobile:f,toggleSidebar:w}),[S,p,m,l,u,f,w]);return c.jsx(Cd.Provider,{value:y,children:c.jsx(rm,{delayDuration:0,children:c.jsx("div",{style:{"--sidebar-width":sx,"--sidebar-width-icon":ox,...i},className:U("group/sidebar-wrapper has-[[data-variant=inset]]:bg-sidebar flex min-h-svh w-full",r),ref:o,...a,children:s})})})});jd.displayName="SidebarProvider";const Nd=v.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:i,...s},a)=>{const{isMobile:o,state:l,openMobile:u,setOpenMobile:f}=Xi();return n==="none"?c.jsx("div",{className:U("bg-sidebar text-sidebar-foreground flex h-full w-[--sidebar-width] flex-col",r),ref:a,...s,children:i}):o?c.jsx(wd,{open:u,onOpenChange:f,...s,children:c.jsx(Ka,{"data-sidebar":"sidebar","data-mobile":"true",className:"bg-sidebar text-sidebar-foreground w-[--sidebar-width] p-0 [&>button]:hidden",style:{"--sidebar-width":ax},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:U("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:U("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})})]})});Nd.displayName="Sidebar";const ux=v.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:i}=Xi();return c.jsxs(Ie,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:U("h-7 w-7",e),onClick:s=>{t==null||t(s),i()},...n,children:[c.jsx(Im,{}),c.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});ux.displayName="SidebarTrigger";const cx=v.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=Xi();return c.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:U("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})});cx.displayName="SidebarRail";const dx=v.forwardRef(({className:e,...t},n)=>c.jsx("main",{ref:n,className:U("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}));dx.displayName="SidebarInset";const fx=v.forwardRef(({className:e,...t},n)=>c.jsx(Ha,{ref:n,"data-sidebar":"input",className:U("bg-background focus-visible:ring-sidebar-ring h-8 w-full shadow-none focus-visible:ring-2",e),...t}));fx.displayName="SidebarInput";const Ed=v.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"header",className:U("flex flex-col gap-2 p-2",e),...t}));Ed.displayName="SidebarHeader";const Id=v.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"footer",className:U("flex flex-col gap-2 p-2",e),...t}));Id.displayName="SidebarFooter";const zd=v.forwardRef(({className:e,...t},n)=>c.jsx(vd,{ref:n,"data-sidebar":"separator",className:U("bg-sidebar-border mx-2 w-auto",e),...t}));zd.displayName="SidebarSeparator";const Td=v.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"content",className:U("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Td.displayName="SidebarContent";const fi=v.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"group",className:U("relative flex w-full min-w-0 flex-col p-2",e),...t}));fi.displayName="SidebarGroup";const pi=v.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?tr:"div";return c.jsx(i,{ref:r,"data-sidebar":"group-label",className:U("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})});pi.displayName="SidebarGroupLabel";const px=v.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?tr:"button";return c.jsx(i,{ref:r,"data-sidebar":"group-action",className:U("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})});px.displayName="SidebarGroupAction";const gr=v.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"group-content",className:U("w-full text-sm",e),...t}));gr.displayName="SidebarGroupContent";const sa=v.forwardRef(({className:e,...t},n)=>c.jsx("ul",{ref:n,"data-sidebar":"menu",className:U("flex w-full min-w-0 flex-col gap-1",e),...t}));sa.displayName="SidebarMenu";const Ad=v.forwardRef(({className:e,...t},n)=>c.jsx("li",{ref:n,"data-sidebar":"menu-item",className:U("group/menu-item relative",e),...t}));Ad.displayName="SidebarMenuItem";const hx=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"}}),Pd=v.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:i,className:s,...a},o)=>{const l=e?tr:"button",{isMobile:u,state:f}=Xi(),d=c.jsx(l,{ref:o,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:U(hx({variant:n,size:r}),s),...a});return i?(typeof i=="string"&&(i={children:i}),c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:d}),c.jsx(Ye,{side:"right",align:"center",hidden:f!=="collapsed"||u,...i})]})):d});Pd.displayName="SidebarMenuButton";const mx=v.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},i)=>{const s=t?tr:"button";return c.jsx(s,{ref:i,"data-sidebar":"menu-action",className:U("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})});mx.displayName="SidebarMenuAction";const gx=v.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:U("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}));gx.displayName="SidebarMenuBadge";const xx=v.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{const i=v.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return c.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:U("flex h-8 items-center gap-2 rounded-md px-2",e),...n,children:[t&&c.jsx(Cr,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),c.jsx(Cr,{className:"h-4 max-w-[--skeleton-width] flex-1","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":i}})]})});xx.displayName="SidebarMenuSkeleton";const yx=v.forwardRef(({className:e,...t},n)=>c.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:U("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}));yx.displayName="SidebarMenuSub";const bx=v.forwardRef(({...e},t)=>c.jsx("li",{ref:t,...e}));bx.displayName="SidebarMenuSubItem";const vx=v.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...i},s)=>{const a=e?tr:"a";return c.jsx(a,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:U("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})});vx.displayName="SidebarMenuSubButton";function aa(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 wx=typeof window<"u"?navigator.userAgent.toUpperCase().indexOf("MAC")>=0:!1;function kx({document:e,indicator:t,compact:n=!1}){const r=v.useRef(null),[i,s]=v.useState(!1),[a,o]=v.useState(!1),[l,u]=v.useState(!1),{openDocument:f,documentTypes:d,activeTab:h}=Xe(T=>T),{name:p,text:m,isGenerating:w}=mn(T=>T),y=(d[e.name]||"application/json+report")==="application/json+theme",_=h===e.name,[x,P]=v.useState(p),[E,k]=v.useState(m),C=100,V=0;v.useEffect(()=>{const T=setTimeout(()=>{p&&m?(P(p),k(m)):w||(P(""),k(""))},w?C:V);return()=>clearTimeout(T)},[p,m,w]);const Y=x===e.name,N=T=>{var K;const H=new Set;try{const O=JSON.parse(T);(K=O.props)!=null&&K.theme&&H.add(O.props.theme),O.children&&Array.isArray(O.children)&&O.children.forEach(W=>{var b;W.name==="docx"&&((b=W.props)!=null&&b.theme)&&H.add(W.props.theme)})}catch{}return H},Z=v.useMemo(()=>{if(!y||!E)return!1;try{const T=JSON.parse(e.text),H=Xs(T);if(H)return N(E).has(H)}catch{}return!1},[y,E,e.text,e.name,x]),D=v.useCallback(()=>{o(!1)},[]),B=v.useCallback(()=>{u(!1)},[]),F=c.jsxs(Pd,{variant:"default",size:"default",ref:r,className:U("text-sidebar-foreground focus:bg-accent focus:text-accent-foreground w-full",n?"justify-center px-1":"justify-start gap-2",i&&"bg-accent text-accent-foreground",_&&(n?"bg-green-50 text-green-700 dark:bg-green-900/20 dark:text-green-300":"bg-green-50 border-l-2 border-green-500 text-green-700 dark:bg-green-900/20 dark:border-green-400 dark:text-green-300"),Y&&!_&&(n?"bg-blue-50 text-blue-700 dark:bg-blue-900/20 dark:text-blue-300":"bg-blue-50 border-l-2 border-blue-500 text-blue-700 dark:bg-blue-900/20 dark:border-blue-400 dark:text-blue-300"),Z&&!_&&!Y&&(n?"bg-purple-50 text-purple-700 dark:bg-purple-900/20 dark:text-purple-300":"bg-purple-50 border-l-2 border-purple-500 text-purple-700 dark:bg-purple-900/20 dark:border-purple-400 dark:text-purple-300")),title:e.name,onClick:()=>{f(e.name)},onKeyDown:T=>{var H;(T.ctrlKey||T.metaKey)&&T.key==="Enter"?(f(e.name),T.preventDefault()):T.key==="Enter"?(o(!0),T.preventDefault()):T.key==="Backspace"||T.key==="Delete"?(u(!0),T.preventDefault()):T.key==="Escape"&&((H=r.current)==null||H.blur(),T.preventDefault())},children:[_?c.jsx(Po,{className:U("size-4","text-green-600 dark:text-green-400")}):Y?c.jsx(Po,{className:U("size-4","text-blue-600 dark:text-blue-400")}):y?c.jsx(Gs,{className:"size-4 text-purple-600 dark:text-purple-400"}):c.jsx(Zc,{className:"size-4 text-blue-600 dark:text-blue-400"}),!n&&c.jsx("span",{className:U("truncate flex-1",y&&!_&&!Y&&!Z&&"text-purple-700 dark:text-purple-300",(_||Y||Z)&&"font-medium"),children:e.name})]});return c.jsxs(Ad,{children:[c.jsxs(Ug,{onOpenChange:s,children:[c.jsx(Jg,{children:n?c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:F}),c.jsx(Ye,{side:"right",children:c.jsxs("div",{className:"text-xs",children:[e.name,y?c.jsx("div",{className:"opacity-70",children:"Theme"}):c.jsx("div",{className:"opacity-70",children:"Document"})]})})]}):F}),c.jsxs(bd,{children:[c.jsxs(mr,{onClick:()=>f(e.name),children:["Open",c.jsx(di,{children:wx?"⌘⏎":"⌃⏎"})]}),c.jsx(ia,{}),c.jsx(mr,{disabled:!e,onClick:()=>{e&&aa(e.name,new Blob([e.text],{type:e.type}))},children:"Download..."}),c.jsx(ia,{}),c.jsxs(mr,{onClick:()=>o(!0),children:["Rename...",c.jsx(di,{children:"⏎"})]}),c.jsxs(mr,{onClick:()=>u(!0),children:["Delete",c.jsx(di,{children:"⌫"})]})]})]}),c.jsx(qt,{open:a,onOpenChange:o,children:c.jsx(Zt,{className:"sm:max-w-[425px]",onCloseAutoFocus:T=>{var H;T.preventDefault(),(H=r.current)==null||H.focus()},children:c.jsx(Si,{mode:"update",shouldReset:!a,postSubmit:D,selectedName:e.name})})}),c.jsx(qt,{open:l,onOpenChange:u,children:c.jsx(Zt,{className:"sm:max-w-[425px]",onCloseAutoFocus:T=>{var H;T.preventDefault(),(H=r.current)==null||H.focus()},children:c.jsx(Si,{mode:"delete",shouldReset:!l,postSubmit:B,selectedName:e.name})})})]})}const Go=Ee.memo(kx);async function Sx(e,t){const n=JSON.stringify({name:e,props:t,children:[]},null,2);await navigator.clipboard.writeText(n)}const _x=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 jr({className:e,variant:t,...n}){return c.jsx("div",{className:U(_x({variant:t}),e),...n})}const Ar=v.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(jc,{ref:r,className:U("relative overflow-hidden",e),...n,children:[c.jsx(gm,{className:"h-full w-full rounded-[inherit]",children:t}),c.jsx(Od,{}),c.jsx(xm,{})]}));Ar.displayName=jc.displayName;const Od=v.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(Nc,{ref:r,orientation:t,className:U("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(ym,{className:"bg-border relative flex-1 rounded-full"})}));Od.displayName=Nc.displayName;function Ya({className:e,...t}){return c.jsx(bm,{"data-slot":"switch",className:U("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(vm,{"data-slot":"switch-thumb",className:U("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 Cx=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"}}),oa=v.forwardRef(({className:e,variant:t,...n},r)=>c.jsx("div",{ref:r,role:"alert",className:U(Cx({variant:t}),e),...n}));oa.displayName="Alert";const jx=v.forwardRef(({className:e,...t},n)=>c.jsx("h5",{ref:n,className:U("mb-1 font-medium leading-none tracking-tight",e),...t}));jx.displayName="AlertTitle";const la=v.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:U("text-sm [&_p]:leading-relaxed",e),...t}));la.displayName="AlertDescription";const _i=v.memo(({keyName:e,value:t,depth:n=0,isLast:r=!1})=>{const[i,s]=v.useState(n<2),a=t!==null&&typeof t=="object",o=Array.isArray(t),l=()=>s(!i),u=()=>t===null?c.jsx("span",{className:"text-orange-500",children:"null"}):t===void 0?c.jsx("span",{className:"text-gray-500",children:"undefined"}):typeof t=="boolean"?c.jsx("span",{className:"text-blue-500",children:String(t)}):typeof t=="number"?c.jsx("span",{className:"text-green-500",children:t}):typeof t=="string"?t.startsWith("http")?c.jsxs("span",{className:"text-purple-500",children:['"',t,'"']}):t.startsWith("#/")?c.jsxs("span",{className:"text-cyan-500",children:['"',t,'"']}):c.jsxs("span",{className:"text-amber-600",children:['"',t,'"']}):null,f=a?Object.keys(t).length:0;return c.jsxs("div",{className:U("text-sm",n>0&&"ml-4"),children:[c.jsxs("div",{className:"flex items-start hover:bg-muted/30 rounded px-1 py-0.5",children:[a&&c.jsx("button",{onClick:l,className:"mr-1 hover:bg-muted rounded p-0.5","aria-label":i?"Collapse":"Expand",children:i?c.jsx(rn,{className:"h-3 w-3"}):c.jsx(Hi,{className:"h-3 w-3"})}),!a&&c.jsx("span",{className:"w-4"}),e&&c.jsxs(c.Fragment,{children:[c.jsxs("span",{className:"text-blue-600 dark:text-blue-400",children:['"',e,'"']}),c.jsx("span",{className:"mx-1",children:":"})]}),a?c.jsxs("span",{className:"text-muted-foreground",children:[o?"[":"{",!i&&c.jsxs("span",{className:"mx-1 text-xs",children:[f," ",o?"items":"properties"]}),!i&&(o?"]":"}")]}):u(),!a&&!r&&c.jsx("span",{className:"text-muted-foreground",children:","})]}),a&&i&&c.jsxs("div",{className:"ml-4",children:[o?t.map((d,h)=>c.jsx(_i,{keyName:String(h),value:d,depth:n+1,isLast:h===t.length-1},h)):Object.entries(t).map(([d,h],p,m)=>c.jsx(_i,{keyName:d,value:h,depth:n+1,isLast:p===m.length-1},d)),c.jsx("div",{className:"ml-4",children:c.jsxs("span",{className:"text-muted-foreground",children:[o?"]":"}",!r&&","]})})]})]})});_i.displayName="JsonNode";const Ci=v.memo(({schema:e,loading:t=!1,error:n,className:r})=>t?c.jsxs("div",{className:U("space-y-4",r),children:[c.jsx(Cr,{className:"h-8 w-64"}),c.jsx(Cr,{className:"h-4 w-full"}),c.jsx(Cr,{className:"h-64 w-full"})]}):n?c.jsx(oa,{variant:"destructive",className:r,children:c.jsx(la,{children:n})}):e?c.jsx(Ar,{className:U("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(_i,{value:e})})}):c.jsx(oa,{className:r,children:c.jsx(la,{children:"No schema available"})}));Ci.displayName="SchemaViewer";function Nx({plugins:e,initialFocusedPlugin:t}){var x,P;const n=Pt(E=>E.togglePlugin),r=Pt(E=>E.isPluginSelected),i=Pt(E=>E.selectedPlugins),s=Pt(E=>E.isApplyingPlugins),[a,o]=v.useState(null),[l,u]=v.useState(null),[f,d]=v.useState("properties");v.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=v.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 Sx(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(Om,{className:"size-3"});case"downstream":return c.jsx(Pm,{className:"size-3"});case"upstream":return c.jsx(Zc,{className:"size-3"});default:return null}},S=((x=a==null?void 0:a.schema)==null?void 0:x.properties)&&Object.keys(a.schema.properties).length>0,y=(P=a==null?void 0:a.schema)==null?void 0:P.jsonSchema,_=(a==null?void 0:a.examples)&&a.examples.length>0;return c.jsxs(c.Fragment,{children:[c.jsxs(Sn,{children:[c.jsxs(_n,{className:"flex items-center gap-2",children:[c.jsx(Bc,{className:"size-5 text-amber-600 dark:text-amber-400"}),"Plugins",c.jsxs(jr,{variant:"secondary",className:"font-normal",children:[i.size," active"]})]}),c.jsxs(Gn,{children:[e.length," plugin",e.length!==1?"s":""," discovered in your project"]})]}),c.jsxs("div",{className:"mt-3 flex gap-0 h-[600px] border rounded-lg overflow-hidden",children:[c.jsx("div",{className:"w-[240px] flex-none border-r bg-muted/30",children:c.jsx(Ar,{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(C=>{const V=r(C.name),Y=(a==null?void 0:a.name)===C.name;return c.jsxs("button",{onClick:()=>o(C),className:U("w-full text-left px-2 py-1.5 rounded-md transition-colors cursor-pointer","flex items-center gap-2",Y?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"),children:[c.jsx("div",{className:U("size-1.5 rounded-full flex-none transition-colors",V?"bg-amber-500 dark:bg-amber-400":"bg-muted-foreground/30")}),c.jsx("span",{className:"text-sm font-medium truncate flex-1",children:C.name})]},C.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(jr,{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:()=>d("properties"),className:U("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",f==="properties"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(Oo,{className:"size-3.5"}),"Properties"]})}),y&&c.jsx("button",{onClick:()=>d("schema"),className:U("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",f==="schema"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(zm,{className:"size-3.5"}),"Schema"]})}),_&&c.jsx("button",{onClick:()=>d("examples"),className:U("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",f==="examples"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(Tm,{className:"size-3.5"}),"Examples",c.jsx(jr,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-4",children:a.examples.length})]})})]}),c.jsx(Ar,{className:"flex-1",children:c.jsxs("div",{className:"p-5",children:[f==="properties"&&S&&c.jsx("div",{className:"space-y-1",children:Object.entries(a.schema.properties).map(([E,k])=>c.jsx(Ex,{name:E,prop:k},E))}),f==="schema"&&y&&c.jsx(Ci,{schema:a.schema.jsonSchema,loading:!1,className:"h-[420px]"}),f==="examples"&&_&&a.examples.map((E,k)=>c.jsxs("div",{className:U(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(Ie,{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(Am,{className:"size-3 mr-1 text-green-600"}),"Copied"]}):c.jsxs(c.Fragment,{children:[c.jsx($a,{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&&!y&&!_&&c.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[c.jsx(Oo,{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 Ex({name:e,prop:t}){var a;const[n,r]=v.useState(!1),i=t.description||t.enum||t.default!==void 0||t.items||t.properties,s=t.type||(t.enum?"enum":t.oneOf?"oneOf":"—");return c.jsxs("div",{className:"rounded-md border",children:[c.jsxs("button",{onClick:()=>i&&r(!n),className:U("w-full text-left flex items-center gap-2 px-3 py-2 text-sm",i&&"cursor-pointer hover:bg-muted/50"),children:[i?n?c.jsx(rn,{className:"size-3 text-muted-foreground flex-none"}):c.jsx(Hi,{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(jr,{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 bs=wm,vs=km,ws=Sm,Dd=_m,Rd=Cm,Ix=v.forwardRef(({className:e,inset:t,children:n,...r},i)=>c.jsxs(Tc,{ref:i,className:U("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(Hi,{className:"ml-auto"})]}));Ix.displayName=Tc.displayName;const zx=v.forwardRef(({className:e,...t},n)=>c.jsx(Ac,{ref:n,className:U("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-lg",e),...t}));zx.displayName=Ac.displayName;const Xa=v.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(jm,{children:c.jsx(Ec,{ref:r,sideOffset:t,className:U("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})}));Xa.displayName=Ec.displayName;const tn=v.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Ic,{ref:r,className:U("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm transition-colors outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",t&&"pl-8",e),...n}));tn.displayName=Ic.displayName;const Tx=v.forwardRef(({className:e,children:t,checked:n,...r},i)=>c.jsxs(Pc,{ref:i,className:U("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(Oc,{children:c.jsx(kn,{className:"h-4 w-4"})})}),t]}));Tx.displayName=Pc.displayName;const Ax=v.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Dc,{ref:r,className:U("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(Oc,{children:c.jsx(Lc,{className:"h-2 w-2 fill-current"})})}),t]}));Ax.displayName=Dc.displayName;const Px=v.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Rc,{ref:r,className:U("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Px.displayName=Rc.displayName;const ji=v.forwardRef(({className:e,...t},n)=>c.jsx(zc,{ref:n,className:U("bg-muted -mx-1 my-1 h-px",e),...t}));ji.displayName=zc.displayName;function Ox(){const{theme:e,setTheme:t}=rc(),n=e==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e,r=v.useCallback(()=>{t(n==="dark"?"light":"dark")},[n,t]);return c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsxs(Ie,{variant:"ghost",size:"icon",onClick:r,children:[c.jsx(Dm,{className:"hidden dark:block"}),c.jsx(Rm,{className:"block dark:hidden"}),c.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),c.jsx(Ye,{children:c.jsx("p",{children:"Toggle theme"})})]})}const Dx=Nm,Md=v.forwardRef(({className:e,...t},n)=>c.jsx(Mc,{ref:n,className:U("bg-muted text-muted-foreground inline-flex h-9 items-center justify-center rounded-lg p-1",e),...t}));Md.displayName=Mc.displayName;const ua=v.forwardRef(({className:e,...t},n)=>c.jsx($c,{ref:n,className:U("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}));ua.displayName=$c.displayName;const ca=v.forwardRef(({className:e,...t},n)=>c.jsx(Fc,{ref:n,className:U("ring-offset-background focus-visible:ring-ring mt-2 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",e),...t}));ca.displayName=Fc.displayName;async function Rx(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 Mx(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 $x(e){const t=Mx(e);return Rx(t)}const $d=({open:e,onOpenChange:t,defaultTab:n="document"})=>{const[r,i]=v.useState(n),[s,a]=v.useState(null),[o,l]=v.useState(null),[u,f]=v.useState(!1),[d,h]=v.useState(!1),[p,m]=v.useState(null),[w,S]=v.useState(null),[y,_]=v.useState(!1),{toast:x}=Ra(),P=Pt(B=>B.selectedPlugins),E=Array.from(P);v.useEffect(()=>{n&&i(n)},[n]);const k=v.useCallback(async()=>{f(!0),m(null);try{const B=await ps.fetchDocumentSchema(E);a(B)}catch(B){const F=B instanceof Error?B.message:"Failed to load document schema";m(F),x({variant:"destructive",title:"Error loading schema",description:F})}finally{f(!1)}},[E,x]),C=v.useCallback(async()=>{if(!o){h(!0),S(null);try{const B=await ps.fetchThemeSchema();l(B)}catch(B){const F=B instanceof Error?B.message:"Failed to load theme schema";S(F),x({variant:"destructive",title:"Error loading schema",description:F})}finally{h(!1)}}},[o,x]),[V,Y]=v.useState([]);v.useEffect(()=>{e||(a(null),m(null))},[e]),v.useEffect(()=>{if(!e)return;const B=E.length!==V.length||E.some((F,T)=>F!==V[T]);r==="document"?(!s||B)&&(B&&(ps.clearPluginSchemaCache(),Y([...E])),u||k()):r==="theme"&&!o&&!d&&C()},[r,e,s,o,u,d,E,V,k,C]);const N=E.length,Z=r==="document"?s:o,D=async()=>{if(Z)try{await $x(Z)&&(_(!0),x({title:"Schema copied",description:"The JSON schema has been copied to your clipboard"}),setTimeout(()=>_(!1),2e3))}catch(B){console.error("Copy failed:",B)}};return c.jsx(qt,{open:e,onOpenChange:t,children:c.jsxs(Zt,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[c.jsx(Sn,{children:c.jsx(_n,{children:"Schema Viewer"})}),c.jsxs(Dx,{value:r,onValueChange:B=>i(B),className:"flex-1 overflow-hidden flex flex-col",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Md,{children:[c.jsxs(ua,{value:"document",className:"flex items-center gap-1",children:["Document",N>0&&c.jsxs(jr,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:["+",N]})]}),c.jsx(ua,{value:"theme",children:"Theme"})]}),c.jsx("div",{className:"ml-auto",children:c.jsx(Ie,{variant:"ghost",size:"icon",onClick:D,disabled:y||!Z,"aria-label":"Copy schema",children:y?c.jsx(kn,{className:"h-4 w-4"}):c.jsx($a,{className:"h-4 w-4"})})})]}),c.jsxs("div",{className:"flex-1 overflow-auto mt-4",children:[c.jsx(ca,{value:"document",className:"h-full",children:c.jsx(Ci,{schema:s,loading:u,error:p||void 0})}),c.jsx(ca,{value:"theme",className:"h-full",children:c.jsx(Ci,{schema:o,loading:d,error:w||void 0})})]})]})]})})};function Fx({discoveryData:e,onToggleSidebar:t,isCollapsed:n=!1,isAnimating:r=!1}){const{documents:i,documentTypes:s,createDocument:a,openDocument:o}=Xe(ug(I=>({documents:I.documents,documentTypes:I.documentTypes,createDocument:I.createDocument,openDocument:I.openDocument}))),l=Ys(I=>I.updateTheme),u=Ys(I=>I.removeTheme),f=v.useContext(Xm),[d,h]=v.useState(!1),[p,m]=v.useState(!1),[w,S]=v.useState(!1),[y,_]=v.useState(null),x=Pt(I=>I.togglePlugin),P=Pt(I=>I.isPluginSelected),E=Pt(I=>I.selectedPlugins),k=Pt(I=>I.isApplyingPlugins),[C,V]=v.useState(!1),[Y,N]=v.useState(new Set(["current-docs","current-themes"])),{toast:Z}=Ra(),D=i.filter(I=>s[I.name]!=="application/json+theme"),B=i.filter(I=>s[I.name]==="application/json+theme"),F=v.useMemo(()=>{if(!e)return{current:[],downstream:[]};const I={current:[],downstream:[]};return e.documents.forEach(R=>{I[R.location]&&I[R.location].push(R)}),I},[e]),T=v.useMemo(()=>{if(!e)return{current:[],downstream:[]};const I={current:[],downstream:[]};return e.themes.forEach(R=>{I[R.location]&&I[R.location].push(R)}),I},[e]),H=v.useMemo(()=>{const I=new Set;return D.forEach(R=>{try{const J=JSON.parse(R.text);J.children&&Array.isArray(J.children)&&J.children.forEach(oe=>{var pe;oe.name==="docx"&&((pe=oe.props)!=null&&pe.theme)&&I.add(oe.props.theme)})}catch{}}),I},[D]),K=v.useCallback(()=>{h(!1)},[]),O=v.useCallback(()=>{m(!1)},[]),W=v.useRef(new Map);v.useEffect(()=>{const I=W.current,R=new Map;B.forEach(J=>{R.set(J.name,J.text),I.get(J.name)!==J.text&&l(J.name,J.text)}),I.forEach((J,oe)=>{R.has(oe)||u(oe)}),W.current=R},[B,l,u]);const b=v.useRef(!1);v.useEffect(()=>{if(b.current||!f)return;b.current=!0;const I=new Set(B.map(J=>J.name));Object.keys(f.getState().customThemes).forEach(J=>{I.has(J)||u(J)})},[B,u,f]);const ue=I=>{N(R=>{const J=new Set(R);return J.has(I)?J.delete(I):J.add(I),J})},ae=Xe(I=>I.activeTab),g=ae&&s[ae]==="application/json+theme"?"theme":"document",{resolvedTheme:G}=rc(),ie=G==="dark"?"https://ik.imagekit.io/wiseair/Brand%20assets/wiseair-logo-white.svg?updatedAt=1751359555877":"https://ik.imagekit.io/wiseair/Brand%20assets/wiseair-logo.svg?updatedAt=1749817149276",Q=v.useCallback(async(I,R)=>{if(i.some(J=>J.name===I)){o(I);return}try{const J=await fetch(`/api/discovery/${R?"themes":"documents"}/${encodeURIComponent(I)}/content`);if(!J.ok)throw new Error(J.statusText);const oe=await J.text(),pe=JSON.parse(oe);a(I,JSON.stringify(pe,null,2)),o(I),Z({title:`Added ${R?"theme":"document"}: ${I}`})}catch{Z({title:"Failed to load",description:`Could not load ${I}`,variant:"destructive"})}},[i,a,o,Z]);return c.jsxs(c.Fragment,{children:[c.jsxs(Nd,{collapsible:"none",style:{"--sidebar-width":n?"3rem":"16rem"},children:[c.jsx(Ed,{children:c.jsx("div",{className:U("flex items-center transition-opacity duration-150 ease-out",r?"opacity-0":"opacity-100",n?"justify-center":"justify-between"),children:n?c.jsx(Ie,{variant:"ghost",size:"icon","aria-label":"Expand sidebar","aria-expanded":!1,onClick:t,children:c.jsx(Vc,{className:"h-4 w-4"})}):c.jsxs(c.Fragment,{children:[c.jsx("a",{href:"/",className:"flex items-center pl-2",children:c.jsx("img",{src:ie,alt:"WiseAir logo",className:"h-5 w-auto max-w-[120px] shrink-0"})}),c.jsx("div",{className:"flex items-center gap-1",children:c.jsx(Ie,{variant:"ghost",size:"icon","aria-label":"Collapse sidebar","aria-expanded":!0,onClick:t,children:c.jsx(Mm,{className:"h-4 w-4"})})})]})})}),c.jsxs(Td,{className:U("h-full transition-opacity duration-150 ease-out",r?"opacity-0":"opacity-100"),children:[c.jsxs(fi,{children:[c.jsxs(pi,{className:U("flex items-center",n?"justify-center":"justify-between"),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[!n&&c.jsx(Do,{className:"size-3"}),!n&&c.jsx("span",{children:"Active Documents"})]}),c.jsxs(qt,{open:d,onOpenChange:h,children:[c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(Ho,{asChild:!0,children:c.jsx(Ie,{className:U("p-0 flex-shrink-0",n?"mx-auto h-8 w-8 rounded border border-dashed border-sidebar-foreground/20 hover:border-sidebar-foreground/40":"h-6 w-6"),variant:"ghost",size:"icon",children:c.jsx(yi,{className:n?"size-3.5":"size-4"})})})}),c.jsx(Ye,{side:n?"right":"bottom",children:c.jsx("span",{className:"text-xs",children:"New Document"})})]}),c.jsx(Zt,{className:"sm:max-w-[525px]",children:c.jsx(Si,{mode:"create",shouldReset:!d,postSubmit:K,discoveredDocuments:(e==null?void 0:e.documents)||[]})})]})]}),n?c.jsx(gr,{children:c.jsx("div",{className:"flex flex-col items-center gap-0.5 px-0.5",children:D.map(I=>{const R=ae===I.name;return c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsxs("button",{onClick:()=>o(I.name),"aria-label":I.name,className:U("relative w-8 h-8 rounded flex items-center justify-center text-[11px] font-bold transition-colors cursor-pointer",R?"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:[R&&c.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-0.5 rounded-full bg-green-500 dark:bg-green-400"}),I.name.replace(/\.[^.]+$/,"").slice(0,2).toUpperCase()]})}),c.jsx(Ye,{side:"right",children:c.jsx("span",{className:"text-xs",children:I.name})})]},I.name)})})}):c.jsx(gr,{children:c.jsx(sa,{children:D.length>0?D.map((I,R)=>c.jsx(Go,{document:I,compact:n},`doc-${R}`)):c.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No active documents. Click + to create one."})})})]}),c.jsx(zd,{}),c.jsxs(fi,{children:[c.jsxs(pi,{className:U("flex items-center",n?"justify-center":"justify-between"),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[!n&&c.jsx(Gs,{className:"size-3 text-purple-600 dark:text-purple-400"}),!n&&c.jsx("span",{children:"Active Themes"})]}),c.jsxs(qt,{open:p,onOpenChange:m,children:[c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(Ho,{asChild:!0,children:c.jsx(Ie,{className:U("p-0 flex-shrink-0",n?"mx-auto h-8 w-8 rounded border border-dashed border-sidebar-foreground/20 hover:border-sidebar-foreground/40":"h-6 w-6"),variant:"ghost",size:"icon",children:c.jsx(yi,{className:n?"size-3.5":"size-4"})})})}),c.jsx(Ye,{side:n?"right":"bottom",children:c.jsx("span",{className:"text-xs",children:"New Theme"})})]}),c.jsx(Zt,{className:"sm:max-w-[525px]",children:c.jsx(Si,{mode:"create",shouldReset:!p,postSubmit:O,discoveredThemes:(e==null?void 0:e.themes)||[],isTheme:!0})})]})]}),n?c.jsx(gr,{children:c.jsx("div",{className:"flex flex-col items-center gap-0.5 px-0.5",children:B.map(I=>{const R=ae===I.name;let J=null;try{const pe=JSON.parse(I.text);J=Xs(pe)}catch{}const oe=J?H.has(J):!1;return c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsxs("button",{onClick:()=>o(I.name),"aria-label":I.name,className:U("relative w-8 h-8 rounded flex items-center justify-center text-[11px] font-bold transition-colors cursor-pointer",R?"bg-purple-100 text-purple-700 dark:bg-purple-900/40 dark:text-purple-300":oe?"bg-purple-50 text-purple-600 dark:bg-purple-900/20 dark:text-purple-400":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:[R&&c.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-0.5 rounded-full bg-purple-500 dark:bg-purple-400"}),(J||I.name).charAt(0).toUpperCase()]})}),c.jsx(Ye,{side:"right",children:c.jsxs("div",{className:"text-xs",children:[I.name,oe&&c.jsx("div",{className:"opacity-70",children:"In use"})]})})]},I.name)})})}):c.jsx(gr,{children:c.jsx(sa,{children:B.length>0?B.map((I,R)=>{let J=null;try{const pe=JSON.parse(I.text);J=Xs(pe)}catch{}const oe=J?H.has(J):!1;return c.jsx(Go,{document:I,compact:n,indicator:oe?"in-use":void 0},`theme-${R}`)}):c.jsxs("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:["No active themes."," ",e&&e.themes.length>0?"Click + to add one.":"No themes discovered in project."]})})})]}),!n&&e&&(e.documents.length>0||e.themes.length>0)&&c.jsxs(fi,{className:"mt-2 border-t pt-4",children:[c.jsxs(pi,{className:"flex items-center mb-2 gap-2",children:[c.jsx($m,{className:"size-3"}),c.jsx("span",{children:"Discovered Resources"})]}),c.jsxs(c.Fragment,{children:[Object.entries(F).map(([I,R])=>{if(R.length===0)return null;const J=`${I}-docs`,oe=Y.has(J);return c.jsxs(bs,{open:oe,children:[c.jsxs(vs,{className:"flex items-center gap-1 px-3 py-1 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors cursor-pointer w-full",onClick:()=>ue(J),children:[c.jsx(rn,{className:U("size-3 transition-transform",!oe&&"-rotate-90")}),c.jsx(Do,{className:"size-3"}),I==="current"?"Current Directory":"Project"," ","Documents (",R.length,")"]}),c.jsx(ws,{children:c.jsx("div",{className:"pl-4 space-y-0.5",children:R.map((pe,Ae)=>{const ke=i.some(be=>be.name===pe.name);return c.jsxs("button",{onClick:()=>Q(pe.name,!1),className:U("w-full text-left py-1 px-2 rounded text-sm transition-colors","border-l-2 border-blue-400/60 dark:border-blue-500/40","hover:bg-accent hover:text-accent-foreground",ke&&"opacity-50"),children:[c.jsx("div",{className:"font-medium truncate",children:pe.name}),pe.title&&c.jsx("div",{className:"text-xs text-muted-foreground truncate",children:pe.title})]},Ae)})})})]},J)}),Object.entries(T).map(([I,R])=>{if(R.length===0)return null;const J=`${I}-themes`,oe=Y.has(J);return c.jsxs(bs,{open:oe,children:[c.jsxs(vs,{className:"flex items-center gap-1 px-3 py-1 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors cursor-pointer w-full",onClick:()=>ue(J),children:[c.jsx(rn,{className:U("size-3 transition-transform",!oe&&"-rotate-90")}),c.jsx(Gs,{className:"size-3"}),I==="current"?"Current Directory":"Project"," ","Themes (",R.length,")"]}),c.jsx(ws,{children:c.jsx("div",{className:"pl-4 space-y-0.5",children:R.map((pe,Ae)=>{const ke=i.some(be=>be.name===pe.name);return c.jsxs("button",{onClick:()=>Q(pe.name,!0),className:U("w-full text-left py-1 px-2 rounded text-sm transition-colors","border-l-2 border-purple-400/60 dark:border-purple-500/40","hover:bg-accent hover:text-accent-foreground",ke&&"opacity-50"),children:[c.jsx("div",{className:"font-medium truncate",children:pe.name}),pe.description&&c.jsx("div",{className:"text-xs text-muted-foreground truncate",children:pe.description})]},Ae)})})})]},J)}),e&&e.plugins.length>0&&c.jsxs(bs,{open:Y.has("plugins"),children:[c.jsxs(vs,{className:"flex items-center gap-1 px-3 py-1 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors cursor-pointer w-full",onClick:()=>ue("plugins"),children:[c.jsx(rn,{className:U("size-3 transition-transform",!Y.has("plugins")&&"-rotate-90")}),c.jsx(Bc,{className:"size-3 text-amber-600 dark:text-amber-400"}),"Plugins (",E.size,"/",e.plugins.length,")"]}),c.jsx(ws,{children:c.jsx("div",{className:"pl-4 space-y-0.5",children:e.plugins.map((I,R)=>{const J=P(I.name);return c.jsxs("div",{className:U("py-1 px-2 text-sm border-l-2 flex items-center gap-2 group transition-colors",J?"border-amber-500 dark:border-amber-400 text-foreground":"border-amber-400/30 dark:border-amber-500/20 text-muted-foreground"),children:[c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"font-medium truncate",children:I.name}),I.description&&c.jsx("div",{className:"text-xs opacity-70 truncate",children:I.description})]}),c.jsx("button",{className:"flex-none size-5 flex items-center justify-center rounded-sm opacity-0 group-hover:opacity-100 hover:bg-accent transition-all cursor-pointer",title:`View details for ${I.name}`,onClick:oe=>{oe.stopPropagation(),_(I.name),S(!0)},children:c.jsx(Uc,{className:"size-3 text-muted-foreground"})}),c.jsx(Ya,{checked:J,onCheckedChange:()=>x(I),disabled:k,className:"flex-none scale-[0.8]","aria-label":`Toggle ${I.name} plugin`})]},R)})})})]})]})]})]}),c.jsx(Id,{children:c.jsx("div",{className:U("flex w-full items-center transition-opacity duration-150 ease-out",r?"opacity-0":"opacity-100",n?"justify-center":"justify-end pr-2"),children:c.jsx(Ox,{})})}),c.jsx(qt,{open:w,onOpenChange:I=>{S(I),I||_(null)},children:c.jsx(Zt,{className:"sm:max-w-5xl max-h-[85vh] overflow-hidden",children:c.jsx(Nx,{plugins:(e==null?void 0:e.plugins)||[],initialFocusedPlugin:y})})})]}),c.jsx($d,{open:C,onOpenChange:V,defaultTab:g==="theme"?"theme":"document"})]})}const Ko=v.memo(Fx),Lx=v.lazy(()=>ic(()=>import("./editor-BW0GiZPm.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(e=>({default:e.Editor})));function Yo(){return c.jsx(v.Suspense,{fallback:c.jsx("div",{className:"flex items-center justify-center h-full",children:c.jsxs("div",{className:"text-center",children:[c.jsx(Qt,{className:"w-8 h-8 mx-auto mb-2"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading editor..."})]})}),children:c.jsx(Lx,{})})}const Zx=v.lazy(()=>ic(()=>import("./preview-DqEl98dA.js"),__vite__mapDeps([12,1,3,4,5,6,7,8,9,10,11])).then(e=>({default:e.Preview})));function Xo(){return c.jsx(v.Suspense,{fallback:c.jsx("div",{className:"flex items-center justify-center h-full",children:c.jsxs("div",{className:"text-center",children:[c.jsx(Qt,{className:"w-8 h-8 mx-auto mb-2"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading preview..."})]})}),children:c.jsx(Zx,{})})}const{createElement:Kn,createContext:Bx,forwardRef:Fd,useCallback:dt,useContext:Ld,useEffect:bn,useImperativeHandle:Zd,useLayoutEffect:Vx,useMemo:Ux,useRef:mt,useState:Jn}=nc,Qo=nc[`useId${Math.random()}`.slice(0,5)],Jx=Vx,Qi=Bx(null);Qi.displayName="PanelGroupContext";const vn=Jx,Hx=typeof Qo=="function"?Qo:()=>null;let qx=0;function Qa(e=null){const t=Hx(),n=mt(e||t||null);return n.current===null&&(n.current=""+qx++),e??n.current}function Bd({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:i,forwardedRef:s,id:a,maxSize:o,minSize:l,onCollapse:u,onExpand:f,onResize:d,order:h,style:p,tagName:m="div",...w}){const S=Ld(Qi);if(S===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:y,expandPanel:_,getPanelSize:x,getPanelStyle:P,groupId:E,isPanelCollapsed:k,reevaluatePanelConstraints:C,registerPanel:V,resizePanel:Y,unregisterPanel:N}=S,Z=Qa(a),D=mt({callbacks:{onCollapse:u,onExpand:f,onResize:d},constraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:o,minSize:l},id:Z,idIsFromProps:a!==void 0,order:h});mt({didLogMissingDefaultSizeWarning:!1}),vn(()=>{const{callbacks:F,constraints:T}=D.current,H={...T};D.current.id=Z,D.current.idIsFromProps=a!==void 0,D.current.order=h,F.onCollapse=u,F.onExpand=f,F.onResize=d,T.collapsedSize=n,T.collapsible=r,T.defaultSize=i,T.maxSize=o,T.minSize=l,(H.collapsedSize!==T.collapsedSize||H.collapsible!==T.collapsible||H.maxSize!==T.maxSize||H.minSize!==T.minSize)&&C(D.current,H)}),vn(()=>{const F=D.current;return V(F),()=>{N(F)}},[h,Z,V,N]),Zd(s,()=>({collapse:()=>{y(D.current)},expand:F=>{_(D.current,F)},getId(){return Z},getSize(){return x(D.current)},isCollapsed(){return k(D.current)},isExpanded(){return!k(D.current)},resize:F=>{Y(D.current,F)}}),[y,_,x,k,Z,Y]);const B=P(D.current,i);return Kn(m,{...w,children:e,className:t,id:a,style:{...B,...p},"data-panel":"","data-panel-collapsible":r||void 0,"data-panel-group-id":E,"data-panel-id":Z,"data-panel-size":parseFloat(""+B.flexGrow).toFixed(1)})}const Vd=Fd((e,t)=>Kn(Bd,{...e,forwardedRef:t}));Bd.displayName="Panel";Vd.displayName="forwardRef(Panel)";let da=null,yn=null;function Wx(e,t){if(t){const n=(t&Wd)!==0,r=(t&Gd)!==0,i=(t&Kd)!==0,s=(t&Yd)!==0;if(n)return i?"se-resize":s?"ne-resize":"e-resize";if(r)return i?"sw-resize":s?"nw-resize":"w-resize";if(i)return"s-resize";if(s)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function Gx(){yn!==null&&(document.head.removeChild(yn),da=null,yn=null)}function ks(e,t){const n=Wx(e,t);da!==n&&(da=n,yn===null&&(yn=document.createElement("style"),document.head.appendChild(yn)),yn.innerHTML=`*{cursor: ${n}!important;}`)}function Ud(e){return e.type==="keydown"}function Jd(e){return e.type.startsWith("pointer")}function Hd(e){return e.type.startsWith("mouse")}function es(e){if(Jd(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Hd(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function Kx(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function Yx(e,t,n){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Xx(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:nl(e),b:nl(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;we(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:tl(el(n.a)),b:tl(el(n.b))};if(i.a===i.b){const s=r.childNodes,a={a:n.a.at(-1),b:n.b.at(-1)};let o=s.length;for(;o--;){const l=s[o];if(l===a.a)return 1;if(l===a.b)return-1}}return Math.sign(i.a-i.b)}const Qx=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function ey(e){var t;const n=getComputedStyle((t=qd(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function ty(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||ey(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||Qx.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function el(e){let t=e.length;for(;t--;){const n=e[t];if(we(n,"Missing node"),ty(n))return n}return null}function tl(e){return e&&Number(getComputedStyle(e).zIndex)||0}function nl(e){const t=[];for(;e;)t.push(e),e=qd(e);return t}function qd(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const Wd=1,Gd=2,Kd=4,Yd=8,ny=Kx()==="coarse";let Ot=[],Hn=!1,nn=new Map,ts=new Map;const Pr=new Set;function ry(e,t,n,r,i){var s;const{ownerDocument:a}=t,o={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:i},l=(s=nn.get(a))!==null&&s!==void 0?s:0;return nn.set(a,l+1),Pr.add(o),Ni(),function(){var f;ts.delete(e),Pr.delete(o);const d=(f=nn.get(a))!==null&&f!==void 0?f:1;if(nn.set(a,d-1),Ni(),d===1&&nn.delete(a),Ot.includes(o)){const h=Ot.indexOf(o);h>=0&&Ot.splice(h,1),to(),i("up",!0,null)}}}function rl(e){const{target:t}=e,{x:n,y:r}=es(e);Hn=!0,eo({target:t,x:n,y:r}),Ni(),Ot.length>0&&(Ei("down",e),e.preventDefault(),e.stopPropagation())}function ur(e){const{x:t,y:n}=es(e);if(Hn&&e.buttons===0&&(Hn=!1,Ei("up",e)),!Hn){const{target:r}=e;eo({target:r,x:t,y:n})}Ei("move",e),to(),Ot.length>0&&e.preventDefault()}function Tn(e){const{target:t}=e,{x:n,y:r}=es(e);ts.clear(),Hn=!1,Ot.length>0&&e.preventDefault(),Ei("up",e),eo({target:t,x:n,y:r}),to(),Ni()}function eo({target:e,x:t,y:n}){Ot.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),Pr.forEach(i=>{const{element:s,hitAreaMargins:a}=i,o=s.getBoundingClientRect(),{bottom:l,left:u,right:f,top:d}=o,h=ny?a.coarse:a.fine;if(t>=u-h&&t<=f+h&&n>=d-h&&n<=l+h){if(r!==null&&document.contains(r)&&s!==r&&!s.contains(r)&&!r.contains(s)&&Xx(r,s)>0){let m=r,w=!1;for(;m&&!m.contains(s);){if(Yx(m.getBoundingClientRect(),o)){w=!0;break}m=m.parentElement}if(w)return}Ot.push(i)}})}function Ss(e,t){ts.set(e,t)}function to(){let e=!1,t=!1;Ot.forEach(r=>{const{direction:i}=r;i==="horizontal"?e=!0:t=!0});let n=0;ts.forEach(r=>{n|=r}),e&&t?ks("intersection",n):e?ks("horizontal",n):t?ks("vertical",n):Gx()}function Ni(){nn.forEach((e,t)=>{const{body:n}=t;n.removeEventListener("contextmenu",Tn),n.removeEventListener("pointerdown",rl),n.removeEventListener("pointerleave",ur),n.removeEventListener("pointermove",ur)}),window.removeEventListener("pointerup",Tn),window.removeEventListener("pointercancel",Tn),Pr.size>0&&(Hn?(Ot.length>0&&nn.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("contextmenu",Tn),n.addEventListener("pointerleave",ur),n.addEventListener("pointermove",ur))}),window.addEventListener("pointerup",Tn),window.addEventListener("pointercancel",Tn)):nn.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("pointerdown",rl,{capture:!0}),n.addEventListener("pointermove",ur))}))}function Ei(e,t){Pr.forEach(n=>{const{setResizeHandlerState:r}=n,i=Ot.includes(n);r(e,i,t)})}function iy(){const[e,t]=Jn(0);return dt(()=>t(n=>n+1),[])}function we(e,t){if(!e)throw console.error(t),Error(t)}const no=10;function Cn(e,t,n=no){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Ht(e,t,n=no){return Cn(e,t,n)===0}function vt(e,t,n){return Cn(e,t,n)===0}function sy(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const i=e[r],s=t[r];if(!vt(i,s,n))return!1}return!0}function Bn({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];we(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:s,maxSize:a=100,minSize:o=0}=r;if(Cn(n,o)<0)if(s){const l=(i+o)/2;Cn(n,l)<0?n=i:n=o}else n=o;return n=Math.min(a,n),n=parseFloat(n.toFixed(no)),n}function xr({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(vt(e,0))return t;const a=[...t],[o,l]=r;we(o!=null,"Invalid first pivot index"),we(l!=null,"Invalid second pivot index");let u=0;if(s==="keyboard"){{const d=e<0?l:o,h=n[d];we(h,`Panel constraints not found for index ${d}`);const{collapsedSize:p=0,collapsible:m,minSize:w=0}=h;if(m){const S=t[d];if(we(S!=null,`Previous layout not found for panel index ${d}`),vt(S,p)){const y=w-S;Cn(y,Math.abs(e))>0&&(e=e<0?0-y:y)}}}{const d=e<0?o:l,h=n[d];we(h,`No panel constraints found for index ${d}`);const{collapsedSize:p=0,collapsible:m,minSize:w=0}=h;if(m){const S=t[d];if(we(S!=null,`Previous layout not found for panel index ${d}`),vt(S,w)){const y=S-p;Cn(y,Math.abs(e))>0&&(e=e<0?0-y:y)}}}}{const d=e<0?1:-1;let h=e<0?l:o,p=0;for(;;){const w=t[h];we(w!=null,`Previous layout not found for panel index ${h}`);const y=Bn({panelConstraints:n,panelIndex:h,size:100})-w;if(p+=y,h+=d,h<0||h>=n.length)break}const m=Math.min(Math.abs(e),Math.abs(p));e=e<0?0-m:m}{let h=e<0?o:l;for(;h>=0&&h<n.length;){const p=Math.abs(e)-Math.abs(u),m=t[h];we(m!=null,`Previous layout not found for panel index ${h}`);const w=m-p,S=Bn({panelConstraints:n,panelIndex:h,size:w});if(!vt(m,S)&&(u+=m-S,a[h]=S,u.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?h--:h++}}if(sy(i,a))return i;{const d=e<0?l:o,h=t[d];we(h!=null,`Previous layout not found for panel index ${d}`);const p=h+u,m=Bn({panelConstraints:n,panelIndex:d,size:p});if(a[d]=m,!vt(m,p)){let w=p-m,y=e<0?l:o;for(;y>=0&&y<n.length;){const _=a[y];we(_!=null,`Previous layout not found for panel index ${y}`);const x=_+w,P=Bn({panelConstraints:n,panelIndex:y,size:x});if(vt(_,P)||(w-=P-_,a[y]=P),vt(w,0))break;e>0?y--:y++}}}const f=a.reduce((d,h)=>h+d,0);return vt(f,100)?a:i}function ay({layout:e,panelsArray:t,pivotIndices:n}){let r=0,i=100,s=0,a=0;const o=n[0];we(o!=null,"No pivot index found"),t.forEach((d,h)=>{const{constraints:p}=d,{maxSize:m=100,minSize:w=0}=p;h===o?(r=w,i=m):(s+=w,a+=m)});const l=Math.min(i,100-s),u=Math.max(r,100-a),f=e[o];return{valueMax:l,valueMin:u,valueNow:f}}function Or(e,t=document){return Array.from(t.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${e}"]`))}function Xd(e,t,n=document){const i=Or(e,n).findIndex(s=>s.getAttribute("data-panel-resize-handle-id")===t);return i??null}function Qd(e,t,n){const r=Xd(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function ef(e,t=document){var n;if(t instanceof HTMLElement&&(t==null||(n=t.dataset)===null||n===void 0?void 0:n.panelGroupId)==e)return t;const r=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return r||null}function ns(e,t=document){const n=t.querySelector(`[data-panel-resize-handle-id="${e}"]`);return n||null}function oy(e,t,n,r=document){var i,s,a,o;const l=ns(t,r),u=Or(e,r),f=l?u.indexOf(l):-1,d=(i=(s=n[f])===null||s===void 0?void 0:s.id)!==null&&i!==void 0?i:null,h=(a=(o=n[f+1])===null||o===void 0?void 0:o.id)!==null&&a!==void 0?a:null;return[d,h]}function ly({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:i,panelGroupElement:s,setLayout:a}){mt({didWarnAboutMissingResizeHandle:!1}),vn(()=>{if(!s)return;const o=Or(n,s);for(let l=0;l<i.length-1;l++){const{valueMax:u,valueMin:f,valueNow:d}=ay({layout:r,panelsArray:i,pivotIndices:[l,l+1]}),h=o[l];if(h!=null){const p=i[l];we(p,`No panel data found for index "${l}"`),h.setAttribute("aria-controls",p.id),h.setAttribute("aria-valuemax",""+Math.round(u)),h.setAttribute("aria-valuemin",""+Math.round(f)),h.setAttribute("aria-valuenow",d!=null?""+Math.round(d):"")}}return()=>{o.forEach((l,u)=>{l.removeAttribute("aria-controls"),l.removeAttribute("aria-valuemax"),l.removeAttribute("aria-valuemin"),l.removeAttribute("aria-valuenow")})}},[n,r,i,s]),bn(()=>{if(!s)return;const o=t.current;we(o,"Eager values not found");const{panelDataArray:l}=o,u=ef(n,s);we(u!=null,`No group found for id "${n}"`);const f=Or(n,s);we(f,`No resize handles found for group id "${n}"`);const d=f.map(h=>{const p=h.getAttribute("data-panel-resize-handle-id");we(p,"Resize handle element has no handle id attribute");const[m,w]=oy(n,p,l,s);if(m==null||w==null)return()=>{};const S=y=>{if(!y.defaultPrevented)switch(y.key){case"Enter":{y.preventDefault();const _=l.findIndex(x=>x.id===m);if(_>=0){const x=l[_];we(x,`No panel data found for index ${_}`);const P=r[_],{collapsedSize:E=0,collapsible:k,minSize:C=0}=x.constraints;if(P!=null&&k){const V=xr({delta:vt(P,E)?C-E:E-P,initialLayout:r,panelConstraints:l.map(Y=>Y.constraints),pivotIndices:Qd(n,p,s),prevLayout:r,trigger:"keyboard"});r!==V&&a(V)}}break}}};return h.addEventListener("keydown",S),()=>{h.removeEventListener("keydown",S)}});return()=>{d.forEach(h=>h())}},[s,e,t,n,r,i,a])}function il(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function tf(e,t){const n=e==="horizontal",{x:r,y:i}=es(t);return n?r:i}function uy(e,t,n,r,i){const s=n==="horizontal",a=ns(t,i);we(a,`No resize handle element found for id "${t}"`);const o=a.getAttribute("data-panel-group-id");we(o,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=r;const u=tf(n,e),f=ef(o,i);we(f,`No group element found for id "${o}"`);const d=f.getBoundingClientRect(),h=s?d.width:d.height;return(u-l)/h*100}function cy(e,t,n,r,i,s){if(Ud(e)){const a=n==="horizontal";let o=0;e.shiftKey?o=100:i!=null?o=i:o=10;let l=0;switch(e.key){case"ArrowDown":l=a?0:o;break;case"ArrowLeft":l=a?-o:0;break;case"ArrowRight":l=a?o:0;break;case"ArrowUp":l=a?0:-o;break;case"End":l=100;break;case"Home":l=-100;break}return l}else return r==null?0:uy(e,t,n,r,s)}function dy({panelDataArray:e}){const t=Array(e.length),n=e.map(s=>s.constraints);let r=0,i=100;for(let s=0;s<e.length;s++){const a=n[s];we(a,`Panel constraints not found for index ${s}`);const{defaultSize:o}=a;o!=null&&(r++,t[s]=o,i-=o)}for(let s=0;s<e.length;s++){const a=n[s];we(a,`Panel constraints not found for index ${s}`);const{defaultSize:o}=a;if(o!=null)continue;const l=e.length-r,u=i/l;r++,t[s]=u,i-=u}return t}function An(e,t,n){t.forEach((r,i)=>{const s=e[i];we(s,`Panel data not found for index ${i}`);const{callbacks:a,constraints:o,id:l}=s,{collapsedSize:u=0,collapsible:f}=o,d=n[l];if(d==null||r!==d){n[l]=r;const{onCollapse:h,onExpand:p,onResize:m}=a;m&&m(r,d),f&&(h||p)&&(p&&(d==null||Ht(d,u))&&!Ht(r,u)&&p(),h&&(d==null||!Ht(d,u))&&Ht(r,u)&&h())}})}function ei(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function fy({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:i,precision:s=3}){const a=n[i];let o;return a==null?o=e!=null?e.toPrecision(s):"1":r.length===1?o="1":o=a.toPrecision(s),{flexBasis:0,flexGrow:o,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function py(e,t=10){let n=null;return(...i)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...i)},t)}}function sl(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function nf(e){return`react-resizable-panels:${e}`}function rf(e){return e.map(t=>{const{constraints:n,id:r,idIsFromProps:i,order:s}=t;return i?r:s?`${s}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function sf(e,t){try{const n=nf(e),r=t.getItem(n);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function hy(e,t,n){var r,i;const s=(r=sf(e,n))!==null&&r!==void 0?r:{},a=rf(t);return(i=s[a])!==null&&i!==void 0?i:null}function my(e,t,n,r,i){var s;const a=nf(e),o=rf(t),l=(s=sf(e,i))!==null&&s!==void 0?s:{};l[o]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{i.setItem(a,JSON.stringify(l))}catch(u){console.error(u)}}function al({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((s,a)=>s+a,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(s=>`${s}%`).join(", ")}`);if(!vt(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const a=n[s];we(a!=null,`No layout data found for index ${s}`);const o=100/r*a;n[s]=o}let i=0;for(let s=0;s<t.length;s++){const a=n[s];we(a!=null,`No layout data found for index ${s}`);const o=Bn({panelConstraints:t,panelIndex:s,size:a});a!=o&&(i+=a-o,n[s]=o)}if(!vt(i,0))for(let s=0;s<t.length;s++){const a=n[s];we(a!=null,`No layout data found for index ${s}`);const o=a+i,l=Bn({panelConstraints:t,panelIndex:s,size:o});if(a!==l&&(i-=l-a,n[s]=l,vt(i,0)))break}return n}const gy=100,yr={getItem:e=>(sl(yr),yr.getItem(e)),setItem:(e,t)=>{sl(yr),yr.setItem(e,t)}},ol={};function af({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:i,id:s=null,onLayout:a=null,keyboardResizeBy:o=null,storage:l=yr,style:u,tagName:f="div",...d}){const h=Qa(s),p=mt(null),[m,w]=Jn(null),[S,y]=Jn([]),_=iy(),x=mt({}),P=mt(new Map),E=mt(0),k=mt({autoSaveId:e,direction:r,dragState:m,id:h,keyboardResizeBy:o,onLayout:a,storage:l}),C=mt({layout:S,panelDataArray:[],panelDataArrayChanged:!1});mt({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),Zd(i,()=>({getId:()=>k.current.id,getLayout:()=>{const{layout:g}=C.current;return g},setLayout:g=>{const{onLayout:G}=k.current,{layout:ie,panelDataArray:Q}=C.current,I=al({layout:g,panelConstraints:Q.map(R=>R.constraints)});il(ie,I)||(y(I),C.current.layout=I,G&&G(I),An(Q,I,x.current))}}),[]),vn(()=>{k.current.autoSaveId=e,k.current.direction=r,k.current.dragState=m,k.current.id=h,k.current.onLayout=a,k.current.storage=l}),ly({committedValuesRef:k,eagerValuesRef:C,groupId:h,layout:S,panelDataArray:C.current.panelDataArray,setLayout:y,panelGroupElement:p.current}),bn(()=>{const{panelDataArray:g}=C.current;if(e){if(S.length===0||S.length!==g.length)return;let G=ol[e];G==null&&(G=py(my,gy),ol[e]=G);const ie=[...g],Q=new Map(P.current);G(e,ie,Q,S,l)}},[e,S,l]),bn(()=>{});const V=dt(g=>{const{onLayout:G}=k.current,{layout:ie,panelDataArray:Q}=C.current;if(g.constraints.collapsible){const I=Q.map(pe=>pe.constraints),{collapsedSize:R=0,panelSize:J,pivotIndices:oe}=dn(Q,g,ie);if(we(J!=null,`Panel size not found for panel "${g.id}"`),!Ht(J,R)){P.current.set(g.id,J);const Ae=$n(Q,g)===Q.length-1?J-R:R-J,ke=xr({delta:Ae,initialLayout:ie,panelConstraints:I,pivotIndices:oe,prevLayout:ie,trigger:"imperative-api"});ei(ie,ke)||(y(ke),C.current.layout=ke,G&&G(ke),An(Q,ke,x.current))}}},[]),Y=dt((g,G)=>{const{onLayout:ie}=k.current,{layout:Q,panelDataArray:I}=C.current;if(g.constraints.collapsible){const R=I.map(be=>be.constraints),{collapsedSize:J=0,panelSize:oe=0,minSize:pe=0,pivotIndices:Ae}=dn(I,g,Q),ke=G??pe;if(Ht(oe,J)){const be=P.current.get(g.id),it=be!=null&&be>=ke?be:ke,yt=$n(I,g)===I.length-1?oe-it:it-oe,j=xr({delta:yt,initialLayout:Q,panelConstraints:R,pivotIndices:Ae,prevLayout:Q,trigger:"imperative-api"});ei(Q,j)||(y(j),C.current.layout=j,ie&&ie(j),An(I,j,x.current))}}},[]),N=dt(g=>{const{layout:G,panelDataArray:ie}=C.current,{panelSize:Q}=dn(ie,g,G);return we(Q!=null,`Panel size not found for panel "${g.id}"`),Q},[]),Z=dt((g,G)=>{const{panelDataArray:ie}=C.current,Q=$n(ie,g);return fy({defaultSize:G,dragState:m,layout:S,panelData:ie,panelIndex:Q})},[m,S]),D=dt(g=>{const{layout:G,panelDataArray:ie}=C.current,{collapsedSize:Q=0,collapsible:I,panelSize:R}=dn(ie,g,G);return we(R!=null,`Panel size not found for panel "${g.id}"`),I===!0&&Ht(R,Q)},[]),B=dt(g=>{const{layout:G,panelDataArray:ie}=C.current,{collapsedSize:Q=0,collapsible:I,panelSize:R}=dn(ie,g,G);return we(R!=null,`Panel size not found for panel "${g.id}"`),!I||Cn(R,Q)>0},[]),F=dt(g=>{const{panelDataArray:G}=C.current;G.push(g),G.sort((ie,Q)=>{const I=ie.order,R=Q.order;return I==null&&R==null?0:I==null?-1:R==null?1:I-R}),C.current.panelDataArrayChanged=!0,_()},[_]);vn(()=>{if(C.current.panelDataArrayChanged){C.current.panelDataArrayChanged=!1;const{autoSaveId:g,onLayout:G,storage:ie}=k.current,{layout:Q,panelDataArray:I}=C.current;let R=null;if(g){const oe=hy(g,I,ie);oe&&(P.current=new Map(Object.entries(oe.expandToSizes)),R=oe.layout)}R==null&&(R=dy({panelDataArray:I}));const J=al({layout:R,panelConstraints:I.map(oe=>oe.constraints)});il(Q,J)||(y(J),C.current.layout=J,G&&G(J),An(I,J,x.current))}}),vn(()=>{const g=C.current;return()=>{g.layout=[]}},[]);const T=dt(g=>{let G=!1;const ie=p.current;return ie&&window.getComputedStyle(ie,null).getPropertyValue("direction")==="rtl"&&(G=!0),function(I){I.preventDefault();const R=p.current;if(!R)return()=>null;const{direction:J,dragState:oe,id:pe,keyboardResizeBy:Ae,onLayout:ke}=k.current,{layout:be,panelDataArray:it}=C.current,{initialLayout:St}=oe??{},yt=Qd(pe,g,R);let j=cy(I,g,J,oe,Ae,R);const z=J==="horizontal";z&&G&&(j=-j);const $=it.map(ee=>ee.constraints),ne=xr({delta:j,initialLayout:St??be,panelConstraints:$,pivotIndices:yt,prevLayout:be,trigger:Ud(I)?"keyboard":"mouse-or-touch"}),te=!ei(be,ne);(Jd(I)||Hd(I))&&E.current!=j&&(E.current=j,!te&&j!==0?z?Ss(g,j<0?Wd:Gd):Ss(g,j<0?Kd:Yd):Ss(g,0)),te&&(y(ne),C.current.layout=ne,ke&&ke(ne),An(it,ne,x.current))}},[]),H=dt((g,G)=>{const{onLayout:ie}=k.current,{layout:Q,panelDataArray:I}=C.current,R=I.map(be=>be.constraints),{panelSize:J,pivotIndices:oe}=dn(I,g,Q);we(J!=null,`Panel size not found for panel "${g.id}"`);const Ae=$n(I,g)===I.length-1?J-G:G-J,ke=xr({delta:Ae,initialLayout:Q,panelConstraints:R,pivotIndices:oe,prevLayout:Q,trigger:"imperative-api"});ei(Q,ke)||(y(ke),C.current.layout=ke,ie&&ie(ke),An(I,ke,x.current))},[]),K=dt((g,G)=>{const{layout:ie,panelDataArray:Q}=C.current,{collapsedSize:I=0,collapsible:R}=G,{collapsedSize:J=0,collapsible:oe,maxSize:pe=100,minSize:Ae=0}=g.constraints,{panelSize:ke}=dn(Q,g,ie);ke!=null&&(R&&oe&&Ht(ke,I)?Ht(I,J)||H(g,J):ke<Ae?H(g,Ae):ke>pe&&H(g,pe))},[H]),O=dt((g,G)=>{const{direction:ie}=k.current,{layout:Q}=C.current;if(!p.current)return;const I=ns(g,p.current);we(I,`Drag handle element not found for id "${g}"`);const R=tf(ie,G);w({dragHandleId:g,dragHandleRect:I.getBoundingClientRect(),initialCursorPosition:R,initialLayout:Q})},[]),W=dt(()=>{w(null)},[]),b=dt(g=>{const{panelDataArray:G}=C.current,ie=$n(G,g);ie>=0&&(G.splice(ie,1),delete x.current[g.id],C.current.panelDataArrayChanged=!0,_())},[_]),ue=Ux(()=>({collapsePanel:V,direction:r,dragState:m,expandPanel:Y,getPanelSize:N,getPanelStyle:Z,groupId:h,isPanelCollapsed:D,isPanelExpanded:B,reevaluatePanelConstraints:K,registerPanel:F,registerResizeHandle:T,resizePanel:H,startDragging:O,stopDragging:W,unregisterPanel:b,panelGroupElement:p.current}),[V,m,r,Y,N,Z,h,D,B,K,F,T,H,O,W,b]),ae={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return Kn(Qi.Provider,{value:ue},Kn(f,{...d,children:t,className:n,id:s,ref:p,style:{...ae,...u},"data-panel-group":"","data-panel-group-direction":r,"data-panel-group-id":h}))}const of=Fd((e,t)=>Kn(af,{...e,forwardedRef:t}));af.displayName="PanelGroup";of.displayName="forwardRef(PanelGroup)";function $n(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function dn(e,t,n){const r=$n(e,t),s=r===e.length-1?[r-1,r]:[r,r+1],a=n[r];return{...t.constraints,panelSize:a,pivotIndices:s}}function xy({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){bn(()=>{if(e||n==null||r==null)return;const i=ns(t,r);if(i==null)return;const s=a=>{if(!a.defaultPrevented)switch(a.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{a.preventDefault(),n(a);break}case"F6":{a.preventDefault();const o=i.getAttribute("data-panel-group-id");we(o,`No group element found for id "${o}"`);const l=Or(o,r),u=Xd(o,t,r);we(u!==null,`No resize element found for id "${t}"`);const f=a.shiftKey?u>0?u-1:l.length-1:u+1<l.length?u+1:0;l[f].focus();break}}};return i.addEventListener("keydown",s),()=>{i.removeEventListener("keydown",s)}},[r,e,t,n])}function lf({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:i,onBlur:s,onDragging:a,onFocus:o,style:l={},tabIndex:u=0,tagName:f="div",...d}){var h,p;const m=mt(null),w=mt({onDragging:a});bn(()=>{w.current.onDragging=a});const S=Ld(Qi);if(S===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:y,groupId:_,registerResizeHandle:x,startDragging:P,stopDragging:E,panelGroupElement:k}=S,C=Qa(i),[V,Y]=Jn("inactive"),[N,Z]=Jn(!1),[D,B]=Jn(null),F=mt({state:V});vn(()=>{F.current.state=V}),bn(()=>{if(n)B(null);else{const O=x(C);B(()=>O)}},[n,C,x]);const T=(h=r==null?void 0:r.coarse)!==null&&h!==void 0?h:15,H=(p=r==null?void 0:r.fine)!==null&&p!==void 0?p:5;return bn(()=>{if(n||D==null)return;const O=m.current;return we(O,"Element ref not attached"),ry(C,O,y,{coarse:T,fine:H},(b,ue,ae)=>{if(ue)switch(b){case"down":{Y("drag"),we(ae,'Expected event to be defined for "down" action'),P(C,ae);const{onDragging:g}=w.current;g&&g(!0);break}case"move":{const{state:g}=F.current;g!=="drag"&&Y("hover"),we(ae,'Expected event to be defined for "move" action'),D(ae);break}case"up":{Y("hover"),E();const{onDragging:g}=w.current;g&&g(!1);break}}else Y("inactive")})},[T,y,n,H,x,C,D,P,E]),xy({disabled:n,handleId:C,resizeHandler:D,panelGroupElement:k}),Kn(f,{...d,children:e,className:t,id:i,onBlur:()=>{Z(!1),s==null||s()},onFocus:()=>{Z(!0),o==null||o()},ref:m,role:"separator",style:{...{touchAction:"none",userSelect:"none"},...l},tabIndex:u,"data-panel-group-direction":y,"data-panel-group-id":_,"data-resize-handle":"","data-resize-handle-active":V==="drag"?"pointer":N?"keyboard":void 0,"data-resize-handle-state":V,"data-panel-resize-handle-enabled":!n,"data-panel-resize-handle-id":C})}lf.displayName="PanelResizeHandle";const yy=({className:e,...t})=>c.jsx(of,{className:U("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),_s=Vd,ll=({withHandle:e,className:t,...n})=>c.jsx(lf,{className:U("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(Fm,{className:"h-2.5 w-2.5"})})});function by({children:e,className:t}){return c.jsx("kbd",{className:U("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 vy({children:e,className:t}){return c.jsx("span",{className:U("inline-flex items-center gap-0.5",t),children:e})}const ti=typeof navigator<"u"&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);function fa({shortcut:e,className:t}){const r=e.split("+").map(i=>i.trim().toLowerCase()).map(i=>{switch(i){case"mod":return ti?"⌘":"Ctrl";case"shift":return ti?"⇧":"Shift";case"alt":return ti?"⌥":"Alt";case"ctrl":return ti?"⌃":"Ctrl";case"enter":return"↵";default:return i.toUpperCase()}});return c.jsx(vy,{className:t,children:r.map((i,s)=>c.jsx(by,{children:i},s))})}class wy{constructor(t){Ao(this,"client");this.client=cg.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 ky=new wy;function Sy(){const e=v.useRef(null),t=v.useCallback(async(r,i,s,a,o)=>{e.current&&e.current.abort();const l=new AbortController;e.current=l;try{a==null||a("parsing","Validating JSON structure...");let u;try{u=JSON.parse(i)}catch(k){throw new Error(`Invalid JSON: ${k instanceof Error?k.message:"Unknown parse error"}`)}a==null||a("building",`Building ${Yr.toLowerCase()} structure...`);const f={jsonDefinition:u,options:o||{}};f.customThemes=s??{},a==null||a("rendering",`Generating ${Nt.toUpperCase()} content...`);const d={"Content-Type":"application/json"};o!=null&&o.bypassCache&&(d["X-Bypass-Cache"]="true");const h=await fetch(im.generate,{method:"POST",headers:d,body:JSON.stringify(f),signal:l.signal}),p=await h.json();if(!h.ok||!p.success){const k=p.error||p.message||`API request failed with status: ${h.status}`;throw new Error(k)}const{data:m,cache:w,warnings:S}=p,y=w.status==="HIT"?"HIT":w.status==="MISS"?"MISS":"UNKNOWN",_=y==="HIT"?`Served from cache (Hit rate: ${w.hitRate})`:`Generated fresh ${Yr.toLowerCase()}`;a==null||a("finalizing",_);const x=globalThis.atob(m.document),P=new Uint8Array(x.length);for(let k=0;k<x.length;k++)P[k]=x.charCodeAt(k);const E=new Blob([P],{type:m.contentType});if(E.size===0)throw new Error(`Received empty ${Yr.toLowerCase()} from API`);return{name:r,text:i,blob:E,filename:m.filename,fileId:m.fileId,cacheStatus:y,cacheHitRate:w.hitRate,warnings:S}}catch(u){throw u instanceof Error&&u.name==="AbortError"?new Error(`${Yr} generation was cancelled`):u}finally{e.current===l&&(e.current=null)}},[]),n=v.useCallback(()=>{e.current&&(e.current.abort(),e.current=null)},[]);return{generatePresentation:t,cancelGeneration:n}}function _y(e){if(!e||e.length===0)return null;const t=[{name:"heading",props:{level:1,text:"Document Generation Warnings"}},{name:"paragraph",props:{text:`${e.length} warning(s) were generated during document processing.`,spacing:{after:240}}}],n=new Map;for(const r of e){const i=n.get(r.component)||[];i.push(r),n.set(r.component,i)}for(const[r,i]of n.entries()){t.push({name:"heading",props:{level:2,text:`Component: ${r}`}});const s=[];for(const a of i){let o=a.message;if(a.context&&Object.keys(a.context).length>0){const l=Object.entries(a.context).map(([u,f])=>`${u}: ${JSON.stringify(f)}`).join(", ");o+=` (${l})`}s.push(o)}t.push({name:"list",props:{items:s,spacing:{after:120}}})}return{name:"docx",props:{metadata:{title:"Generation Warnings"},theme:"minimal"},children:t}}const ul=Nt==="docx"?["docxjs","LibreOffice"]:["LibreOffice"],Cs={docxjs:["⚡","(Fast) works in the browser — lower fidelity"],LibreOffice:["🖨️","(High fidelity) converts to PDF locally with LibreOffice"]};function Cy({name:e,blob:t,displayReloadButton:n,iframeRef:r,autoReload:i,onToggleAutoReload:s,onManualRender:a,isGenerating:o,isRendering:l,onShowCacheMetrics:u,onShowSchemas:f,documentText:d,warnings:h,renderingLibrary:p,setRenderingLibrary:m,onToggleChat:w,chatOpen:S,onTogglePreview:y,previewOpen:_}){const x=p!=="docxjs",[P,E]=v.useState(!1),[k,C]=v.useState(!1),[V,Y]=v.useState(!1),[N,Z]=v.useState(!1),[D,B]=v.useState(!1),[F,T]=v.useState(!1),{toast:H}=Ra(),{generatePresentation:K}=Sy(),O=v.useCallback(async()=>{if(t){E(!0);try{await new Promise(g=>setTimeout(g,100)),aa(`${e}${Xr}`,t)}finally{setTimeout(()=>E(!1),500)}}},[t,e]),W=v.useCallback(async()=>{if(!(!h||h.length===0)){C(!0);try{const g=_y(h);if(!g){H({title:"No warnings",description:"There are no warnings to download.",variant:"destructive"});return}const G=await K("warnings",JSON.stringify(g,null,2),{});G&&typeof G=="object"&&"blob"in G&&G.blob&&(aa(`${e}-warnings${Xr}`,G.blob),H({title:"Warnings downloaded",description:`Downloaded warnings document with ${h.length} warning(s).`}))}catch(g){console.error("Failed to generate warnings document:",g),H({title:"Download failed",description:g instanceof Error?g.message:"Failed to generate warnings document",variant:"destructive"})}finally{setTimeout(()=>C(!1),500)}}},[h,e,K,H]),b=v.useCallback(async()=>{const g=r==null?void 0:r.current;if(g!=null&&g.src){Y(!0);try{await new Promise(ie=>{let Q=null,I=!1;const R=()=>{Q&&(clearTimeout(Q),Q=null),g.removeEventListener("load",oe),g.removeEventListener("error",pe)},J=()=>{I||(I=!0,R(),ie())},oe=()=>J(),pe=()=>J();g.addEventListener("load",oe),g.addEventListener("error",pe),Q=setTimeout(()=>{console.warn("Iframe reload timed out after 5 seconds"),J()},5e3);const Ae=g.src,ke=Ae.includes("?")?"&":"?",be=Date.now();g.src=`${Ae}${ke}_reload=${be}`})}catch(G){console.error("Iframe reload failed:",G)}finally{Y(!1)}}},[r]),ue=v.useCallback(async()=>{Z(!0);try{await ky.delete(`/${Nt}/cache`),window.dispatchEvent(new CustomEvent("cache:cleared")),H({title:"Cache Cleared",description:"All caches (document and component) have been successfully cleared.",variant:"default"})}catch(g){console.error("Failed to clear cache:",g),H({title:"Cache Clear Failed",description:"Failed to clear caches. Please try again.",variant:"destructive"})}finally{Z(!1)}},[H]),ae=v.useCallback(async()=>{if(!d){H({title:"No document available",description:"Please select a document to copy standard components",variant:"destructive"});return}T(!0);try{const g=await fetch(`/api/${Nt}/standard-components`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonDefinition:d})});if(!g.ok){let Q=`Request failed with status ${g.status}`;try{const I=await g.json();I.message&&(Q=I.message)}catch{}H({title:"Failed to get standard components",description:Q,variant:"destructive"});return}const G=await g.json(),ie=JSON.stringify(G.data,null,2);await navigator.clipboard.writeText(ie),H({title:"Copied to clipboard",description:"Standard modules JSON has been copied"})}catch(g){console.error("Error copying standard components:",g),H({title:"Error",description:g instanceof Error?g.message:"Failed to copy standard components",variant:"destructive"})}finally{T(!1)}},[d,H]);return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"bg-sidebar flex flex-row flex-nowrap items-center justify-between gap-x-2 px-3 py-1.5",children:[c.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[c.jsx("p",{className:"text-foreground text-sm font-semibold tracking-tight truncate flex-1 min-w-0",children:e}),c.jsxs(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(Uc,{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"," ",Nt==="docx"?"docx-preview":"LibreOffice PDF conversion",". Download the ",Xr," to verify fidelity."]})})]})]}),c.jsxs("div",{className:"flex flex-row items-center gap-x-1 shrink-0",children:[(!i||x)&&c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsxs(Ie,{variant:"default",size:"sm",className:"gap-1.5 h-7 px-2.5",onClick:a,"aria-label":"Render preview",disabled:o||l||_===!1,children:[l?c.jsx(Qt,{size:"sm"}):c.jsx(Lm,{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"})})]}),Nt==="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(Ja,{className:"text-xs text-muted-foreground hidden sm:inline",children:"Auto"}),c.jsx(Ya,{checked:i,onCheckedChange:s,disabled:x})]})}),c.jsx(Ye,{children:c.jsx("p",{children:x?"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(Ie,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:b,disabled:V||o||l,children:V?c.jsx(Qt,{size:"sm"}):c.jsx(Zm,{className:"h-3.5 w-3.5"})})}),c.jsx(Ye,{children:c.jsx("p",{children:V?"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(Ie,{variant:"outline",size:"sm",className:"gap-1.5 h-7 px-2.5",disabled:!t||P||o,onClick:O,children:[P?c.jsx(Qt,{size:"sm"}):c.jsx(Bm,{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 ",Xr]})})]}),h&&h.length>0&&c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(Ie,{variant:"outline",size:"icon",className:"h-7 w-7 bg-amber-50 dark:bg-amber-950 text-amber-600 dark:text-amber-400 border-amber-200 dark:border-amber-800 hover:bg-amber-100 dark:hover:bg-amber-900",disabled:k||o,onClick:W,children:k?c.jsx(Qt,{size:"sm"}):c.jsx(Jc,{className:"h-3.5 w-3.5"})})}),c.jsx(Ye,{children:c.jsxs("p",{children:["Download warnings (",h.length,")"]})})]}),p&&m&&c.jsxs(qa,{value:p,onValueChange:m,children:[c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(Ki,{className:"w-[140px] h-7 text-xs hidden lg:flex",children:c.jsx(Wa,{placeholder:"Renderer"})})}),c.jsx(Ye,{children:c.jsx("p",{children:"Select the rendering library"})})]}),c.jsx(Yi,{className:"text-sidebar-foreground",children:ul.map(g=>c.jsxs(Tr,{value:g,children:[c.jsxs(Ge,{children:[c.jsx(Ke,{tabIndex:-1,children:Cs[g][0]}),c.jsx(Ye,{children:Cs[g][1]})]})," ",g]},g))})]}),c.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),c.jsxs(Dd,{children:[c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(Rd,{asChild:!0,children:c.jsx(Ie,{variant:"ghost",size:"icon",className:"h-7 w-7",children:c.jsx(Vm,{className:"h-3.5 w-3.5"})})})}),c.jsx(Ye,{children:c.jsx("p",{children:"More actions"})})]}),c.jsxs(Xa,{align:"end",className:"w-52",children:[f&&c.jsxs(tn,{onClick:f,children:[c.jsx(Um,{className:"h-4 w-4 mr-2"}),"View JSON Schemas"]}),u&&c.jsxs(tn,{onClick:u,children:[c.jsx(Jm,{className:"h-4 w-4 mr-2"}),"View cache metrics"]}),c.jsxs(tn,{onClick:ae,disabled:!d||F,children:[c.jsx(Hc,{className:"h-4 w-4 mr-2"}),F?"Copying...":"Copy standard components"]}),c.jsx(ji,{}),c.jsxs(tn,{onClick:()=>B(!0),disabled:N,className:"text-destructive focus:text-destructive",children:[c.jsx(Fa,{className:"h-4 w-4 mr-2"}),N?"Clearing...":"Clear all caches"]}),p&&m&&c.jsxs(c.Fragment,{children:[c.jsx(ji,{className:"lg:hidden"}),ul.map(g=>c.jsxs(tn,{className:"lg:hidden",onClick:()=>m(g),children:[c.jsx("span",{className:"mr-2",children:p===g?"●":"○"}),Cs[g][0]," ",g]},g))]})]})]}),y&&c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(Ie,{variant:_?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:y,children:_?c.jsx(qc,{className:"h-3.5 w-3.5"}):c.jsx(Hm,{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(fa,{shortcut:"mod+shift+p"})]})})]}),w&&c.jsxs(Ge,{children:[c.jsx(Ke,{asChild:!0,children:c.jsx(Ie,{variant:S?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:w,children:c.jsx(Wc,{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(fa,{shortcut:"mod+shift+j"})]})})]})]})]}),c.jsx(qt,{open:D,onOpenChange:B,children:c.jsxs(Zt,{className:"max-w-sm",children:[c.jsxs(Sn,{children:[c.jsx(_n,{children:"Clear all caches?"}),c.jsx(Gn,{children:"This will clear document and component caches. Next generation will be uncached."})]}),c.jsxs(zr,{children:[c.jsx(Ie,{variant:"outline",size:"sm",onClick:()=>B(!1),children:"Cancel"}),c.jsx(Ie,{variant:"destructive",size:"sm",disabled:N,onClick:async()=>{await ue(),B(!1)},children:N?c.jsx(Qt,{size:"sm"}):"Clear"})]})]})})]})}const jy=Ee.memo(Cy);function cl({previewOpen:e,onTogglePreview:t}){const n=mn(C=>C.name||""),r=mn(C=>C.blob),i=mn(C=>C.isGenerating),s=mn(C=>C.text),a=mn(C=>C.warnings),o=mn(C=>C.isRendering),l=Qr(C=>C.autoReload),u=Qr(C=>C.renderingLibrary),f=Qr(C=>C.setSettings),d=Qr(C=>C.useGlobalPreviewHeader??!0),h=Xe(C=>C.activeTab),p=Xe(C=>C.documentTypes),m=h&&p[h]==="application/json+theme"?"theme":"document",w=ze(C=>C.chatOpen),S=ze(C=>C.toggleChat),[y,_]=Ee.useState(!1);if(!d)return null;const x=v.useCallback(()=>f({saveDocumentDebounceWait:2e3,autoReload:!l}),[l,f]),P=v.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:manualRender"))},[]),E=v.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:showCacheMetrics"))},[]),k=(n==null?void 0:n.trim())||"Preview";return c.jsxs("div",{className:"sticky top-0 z-20",children:[c.jsx(jy,{name:k,blob:r,displayReloadButton:!1,autoReload:l,onToggleAutoReload:x,onManualRender:P,isGenerating:i,isRendering:!!o,onShowCacheMetrics:E,onShowSchemas:()=>_(!0),documentText:s,warnings:a,renderingLibrary:u,setRenderingLibrary:C=>f({renderingLibrary:C}),onToggleChat:S,chatOpen:w,onTogglePreview:t,previewOpen:e}),c.jsx($d,{open:y,onOpenChange:_,defaultTab:m==="theme"?"theme":"document"})]})}function Ny(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Ey=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Iy=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,zy={};function dl(e,t){return(zy.jsx?Iy:Ey).test(e)}const Ty=/[ \t\n\f\r]/g;function Ay(e){return typeof e=="object"?e.type==="text"?fl(e.value):!1:fl(e)}function fl(e){return e.replace(Ty,"")===""}class Jr{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Jr.prototype.normal={};Jr.prototype.property={};Jr.prototype.space=void 0;function uf(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Jr(n,r,t)}function pa(e){return e.toLowerCase()}class gt{constructor(t,n){this.attribute=n,this.property=t}}gt.prototype.attribute="";gt.prototype.booleanish=!1;gt.prototype.boolean=!1;gt.prototype.commaOrSpaceSeparated=!1;gt.prototype.commaSeparated=!1;gt.prototype.defined=!1;gt.prototype.mustUseProperty=!1;gt.prototype.number=!1;gt.prototype.overloadedBoolean=!1;gt.prototype.property="";gt.prototype.spaceSeparated=!1;gt.prototype.space=void 0;let Py=0;const ye=En(),We=En(),ha=En(),X=En(),Me=En(),qn=En(),bt=En();function En(){return 2**++Py}const ma=Object.freeze(Object.defineProperty({__proto__:null,boolean:ye,booleanish:We,commaOrSpaceSeparated:bt,commaSeparated:qn,number:X,overloadedBoolean:ha,spaceSeparated:Me},Symbol.toStringTag,{value:"Module"})),js=Object.keys(ma);class ro extends gt{constructor(t,n,r,i){let s=-1;if(super(t,n),pl(this,"space",i),typeof r=="number")for(;++s<js.length;){const a=js[s];pl(this,js[s],(r&ma[a])===ma[a])}}}ro.prototype.defined=!0;function pl(e,t,n){n&&(e[t]=n)}function nr(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new ro(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[pa(r)]=r,n[pa(s.attribute)]=r}return new Jr(t,n,e.space)}const cf=nr({properties:{ariaActiveDescendant:null,ariaAtomic:We,ariaAutoComplete:null,ariaBusy:We,ariaChecked:We,ariaColCount:X,ariaColIndex:X,ariaColSpan:X,ariaControls:Me,ariaCurrent:null,ariaDescribedBy:Me,ariaDetails:null,ariaDisabled:We,ariaDropEffect:Me,ariaErrorMessage:null,ariaExpanded:We,ariaFlowTo:Me,ariaGrabbed:We,ariaHasPopup:null,ariaHidden:We,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Me,ariaLevel:X,ariaLive:null,ariaModal:We,ariaMultiLine:We,ariaMultiSelectable:We,ariaOrientation:null,ariaOwns:Me,ariaPlaceholder:null,ariaPosInSet:X,ariaPressed:We,ariaReadOnly:We,ariaRelevant:null,ariaRequired:We,ariaRoleDescription:Me,ariaRowCount:X,ariaRowIndex:X,ariaRowSpan:X,ariaSelected:We,ariaSetSize:X,ariaSort:null,ariaValueMax:X,ariaValueMin:X,ariaValueNow:X,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function df(e,t){return t in e?e[t]:t}function ff(e,t){return df(e,t.toLowerCase())}const Oy=nr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:qn,acceptCharset:Me,accessKey:Me,action:null,allow:null,allowFullScreen:ye,allowPaymentRequest:ye,allowUserMedia:ye,alt:null,as:null,async:ye,autoCapitalize:null,autoComplete:Me,autoFocus:ye,autoPlay:ye,blocking:Me,capture:null,charSet:null,checked:ye,cite:null,className:Me,cols:X,colSpan:null,content:null,contentEditable:We,controls:ye,controlsList:Me,coords:X|qn,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ye,defer:ye,dir:null,dirName:null,disabled:ye,download:ha,draggable:We,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ye,formTarget:null,headers:Me,height:X,hidden:ha,high:X,href:null,hrefLang:null,htmlFor:Me,httpEquiv:Me,id:null,imageSizes:null,imageSrcSet:null,inert:ye,inputMode:null,integrity:null,is:null,isMap:ye,itemId:null,itemProp:Me,itemRef:Me,itemScope:ye,itemType:Me,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ye,low:X,manifest:null,max:null,maxLength:X,media:null,method:null,min:null,minLength:X,multiple:ye,muted:ye,name:null,nonce:null,noModule:ye,noValidate:ye,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:ye,optimum:X,pattern:null,ping:Me,placeholder:null,playsInline:ye,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ye,referrerPolicy:null,rel:Me,required:ye,reversed:ye,rows:X,rowSpan:X,sandbox:Me,scope:null,scoped:ye,seamless:ye,selected:ye,shadowRootClonable:ye,shadowRootDelegatesFocus:ye,shadowRootMode:null,shape:null,size:X,sizes:null,slot:null,span:X,spellCheck:We,src:null,srcDoc:null,srcLang:null,srcSet:null,start:X,step:null,style:null,tabIndex:X,target:null,title:null,translate:null,type:null,typeMustMatch:ye,useMap:null,value:We,width:X,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Me,axis:null,background:null,bgColor:null,border:X,borderColor:null,bottomMargin:X,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ye,declare:ye,event:null,face:null,frame:null,frameBorder:null,hSpace:X,leftMargin:X,link:null,longDesc:null,lowSrc:null,marginHeight:X,marginWidth:X,noResize:ye,noHref:ye,noShade:ye,noWrap:ye,object:null,profile:null,prompt:null,rev:null,rightMargin:X,rules:null,scheme:null,scrolling:We,standby:null,summary:null,text:null,topMargin:X,valueType:null,version:null,vAlign:null,vLink:null,vSpace:X,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:ye,disableRemotePlayback:ye,prefix:null,property:null,results:X,security:null,unselectable:null},space:"html",transform:ff}),Dy=nr({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:bt,accentHeight:X,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:X,amplitude:X,arabicForm:null,ascent:X,attributeName:null,attributeType:null,azimuth:X,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:X,by:null,calcMode:null,capHeight:X,className:Me,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:X,diffuseConstant:X,direction:null,display:null,dur:null,divisor:X,dominantBaseline:null,download:ye,dx:null,dy:null,edgeMode:null,editable:null,elevation:X,enableBackground:null,end:null,event:null,exponent:X,externalResourcesRequired:null,fill:null,fillOpacity:X,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:qn,g2:qn,glyphName:qn,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:X,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:X,horizOriginX:X,horizOriginY:X,id:null,ideographic:X,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:X,k:X,k1:X,k2:X,k3:X,k4:X,kernelMatrix:bt,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:X,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:X,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:X,overlineThickness:X,paintOrder:null,panose1:null,path:null,pathLength:X,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Me,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:X,pointsAtY:X,pointsAtZ:X,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:bt,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:bt,rev:bt,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:bt,requiredFeatures:bt,requiredFonts:bt,requiredFormats:bt,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:X,specularExponent:X,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:X,strikethroughThickness:X,string:null,stroke:null,strokeDashArray:bt,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:X,strokeOpacity:X,strokeWidth:null,style:null,surfaceScale:X,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:bt,tabIndex:X,tableValues:null,target:null,targetX:X,targetY:X,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:bt,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:X,underlineThickness:X,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:X,values:null,vAlphabetic:X,vMathematical:X,vectorEffect:null,vHanging:X,vIdeographic:X,version:null,vertAdvY:X,vertOriginX:X,vertOriginY:X,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:X,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:df}),pf=nr({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),hf=nr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:ff}),mf=nr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Ry={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"},My=/[A-Z]/g,hl=/-[a-z]/g,$y=/^data[-\w.:]+$/i;function Fy(e,t){const n=pa(t);let r=t,i=gt;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&$y.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(hl,Zy);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!hl.test(s)){let a=s.replace(My,Ly);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=ro}return new i(r,t)}function Ly(e){return"-"+e.toLowerCase()}function Zy(e){return e.charAt(1).toUpperCase()}const By=uf([cf,Oy,pf,hf,mf],"html"),io=uf([cf,Dy,pf,hf,mf],"svg");function Vy(e){return e.join(" ").trim()}var Pn={},Ns,ml;function Uy(){if(ml)return Ns;ml=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
3
|
`,u="/",f="*",d="",h="comment",p="declaration";function m(S,y){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];y=y||{};var _=1,x=1;function P(F){var T=F.match(t);T&&(_+=T.length);var H=F.lastIndexOf(l);x=~H?F.length-H:x+F.length}function E(){var F={line:_,column:x};return function(T){return T.position=new k(F),Y(),T}}function k(F){this.start=F,this.end={line:_,column:x},this.source=y.source}k.prototype.content=S;function C(F){var T=new Error(y.source+":"+_+":"+x+": "+F);if(T.reason=F,T.filename=y.source,T.line=_,T.column=x,T.source=S,!y.silent)throw T}function V(F){var T=F.exec(S);if(T){var H=T[0];return P(H),S=S.slice(H.length),T}}function Y(){V(n)}function N(F){var T;for(F=F||[];T=Z();)T!==!1&&F.push(T);return F}function Z(){var F=E();if(!(u!=S.charAt(0)||f!=S.charAt(1))){for(var T=2;d!=S.charAt(T)&&(f!=S.charAt(T)||u!=S.charAt(T+1));)++T;if(T+=2,d===S.charAt(T-1))return C("End of comment missing");var H=S.slice(2,T-2);return x+=2,P(H),S=S.slice(T),x+=2,F({type:h,comment:H})}}function D(){var F=E(),T=V(r);if(T){if(Z(),!V(i))return C("property missing ':'");var H=V(s),K=F({type:p,property:w(T[0].replace(e,d)),value:H?w(H[0].replace(e,d)):d});return V(a),K}}function B(){var F=[];N(F);for(var T;T=D();)T!==!1&&(F.push(T),N(F));return F}return Y(),B()}function w(S){return S?S.replace(o,d):d}return Ns=m,Ns}var gl;function Jy(){if(gl)return Pn;gl=1;var e=Pn&&Pn.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Pn,"__esModule",{value:!0}),Pn.default=n;const t=e(Uy());function n(r,i){let s=null;if(!r||typeof r!="string")return s;const a=(0,t.default)(r),o=typeof i=="function";return a.forEach(l=>{if(l.type!=="declaration")return;const{property:u,value:f}=l;o?i(u,f,l):f&&(s=s||{},s[u]=f)}),s}return Pn}var cr={},xl;function Hy(){if(xl)return cr;xl=1,Object.defineProperty(cr,"__esModule",{value:!0}),cr.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(u){return!u||n.test(u)||e.test(u)},a=function(u,f){return f.toUpperCase()},o=function(u,f){return"".concat(f,"-")},l=function(u,f){return f===void 0&&(f={}),s(u)?u:(u=u.toLowerCase(),f.reactCompat?u=u.replace(i,o):u=u.replace(r,o),u.replace(t,a))};return cr.camelCase=l,cr}var dr,yl;function qy(){if(yl)return dr;yl=1;var e=dr&&dr.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(Jy()),n=Hy();function r(i,s){var a={};return!i||typeof i!="string"||(0,t.default)(i,function(o,l){o&&l&&(a[(0,n.camelCase)(o,s)]=l)}),a}return r.default=r,dr=r,dr}var Wy=qy();const Gy=Da(Wy),gf=xf("end"),so=xf("start");function xf(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 Ky(e){const t=so(e),n=gf(e);if(t&&n)return{start:t,end:n}}function Nr(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?bl(e.position):"start"in e||"end"in e?bl(e):"line"in e||"column"in e?ga(e):""}function ga(e){return vl(e&&e.line)+":"+vl(e&&e.column)}function bl(e){return ga(e&&e.start)+"-"+ga(e&&e.end)}function vl(e){return e&&typeof e=="number"?e:1}class rt extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},a=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(a=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const o=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=o?o.line:void 0,this.name=Nr(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=a&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}rt.prototype.file="";rt.prototype.name="";rt.prototype.reason="";rt.prototype.message="";rt.prototype.stack="";rt.prototype.column=void 0;rt.prototype.line=void 0;rt.prototype.ancestors=void 0;rt.prototype.cause=void 0;rt.prototype.fatal=void 0;rt.prototype.place=void 0;rt.prototype.ruleId=void 0;rt.prototype.source=void 0;const ao={}.hasOwnProperty,Yy=new Map,Xy=/[A-Z]/g,Qy=new Set(["table","tbody","thead","tfoot","tr"]),eb=new Set(["td","th"]),yf="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function tb(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=ub(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=lb(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"?io:By,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=bf(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function bf(e,t,n){if(t.type==="element")return nb(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return rb(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return sb(e,t,n);if(t.type==="mdxjsEsm")return ib(e,t);if(t.type==="root")return ab(e,t,n);if(t.type==="text")return ob(e,t)}function nb(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=io,e.schema=i),e.ancestors.push(t);const s=wf(e,t.tagName,!1),a=cb(e,t);let o=lo(e,t);return Qy.has(t.tagName)&&(o=o.filter(function(l){return typeof l=="string"?!Ay(l):!0})),vf(e,a,s,t),oo(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function rb(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)}Dr(e,t.position)}function ib(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Dr(e,t.position)}function sb(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=io,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:wf(e,t.name,!0),a=db(e,t),o=lo(e,t);return vf(e,a,s,t),oo(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function ab(e,t,n){const r={};return oo(r,lo(e,t)),e.create(t,e.Fragment,r,n)}function ob(e,t){return t.value}function vf(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function oo(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function lb(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 ub(e,t){return n;function n(r,i,s,a){const o=Array.isArray(s.children),l=so(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 cb(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&ao.call(t.properties,i)){const s=fb(e,i,t.properties[i]);if(s){const[a,o]=s;e.tableCellAlignToStyle&&a==="align"&&typeof o=="string"&&eb.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 db(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 Dr(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 Dr(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function lo(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:Yy;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=bf(e,s,a);o!==void 0&&n.push(o)}return n}function fb(e,t,n){const r=Fy(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Ny(n):Vy(n)),r.property==="style"){let i=typeof n=="object"?n:pb(e,String(n));return e.stylePropertyNameCase==="css"&&(i=hb(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?Ry[r.property]||r.property:r.attribute,n]}}function pb(e,t){try{return Gy(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new rt("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=yf+"#cannot-parse-style-attribute",i}}function wf(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=dl(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=dl(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return ao.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);Dr(e)}function Dr(e,t){const n=new rt("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=yf+"#cannot-handle-mdx-estrees-without-createevaluater",n}function hb(e){const t={};let n;for(n in e)ao.call(e,n)&&(t[mb(n)]=e[n]);return t}function mb(e){let t=e.replace(Xy,gb);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function gb(e){return"-"+e.toLowerCase()}const Es={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"]},xb={};function uo(e,t){const n=xb,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return kf(e,r,i)}function kf(e,t,n){if(yb(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 wl(e.children,t,n)}return Array.isArray(e)?wl(e,t,n):""}function wl(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=kf(e[i],t,n);return r.join("")}function yb(e){return!!(e&&typeof e=="object")}const kl=document.createElement("i");function co(e){const t="&"+e+";";kl.innerHTML=t;const n=kl.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function wt(e,t,n,r){const i=e.length;let s=0,a;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);s<r.length;)a=r.slice(s,s+1e4),a.unshift(t,0),e.splice(...a),s+=1e4,t+=1e4}function jt(e,t){return e.length>0?(wt(e,e.length,0,t),e):t}const Sl={}.hasOwnProperty;function Sf(e){const t={};let n=-1;for(;++n<e.length;)bb(t,e[n]);return t}function bb(e,t){let n;for(n in t){const i=(Sl.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let a;if(s)for(a in s){Sl.call(i,a)||(i[a]=[]);const o=s[a];vb(i[a],Array.isArray(o)?o:o?[o]:[])}}}function vb(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);wt(e,0,0,r)}function _f(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Dt(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ut=ln(/[A-Za-z]/),nt=ln(/[\dA-Za-z]/),wb=ln(/[#-'*+\--9=?A-Z^-~]/);function Ii(e){return e!==null&&(e<32||e===127)}const xa=ln(/\d/),kb=ln(/[\dA-Fa-f]/),Sb=ln(/[!-/:-@[-`{-~]/);function he(e){return e!==null&&e<-2}function De(e){return e!==null&&(e<0||e===32)}function _e(e){return e===-2||e===-1||e===32}const rs=ln(new RegExp("\\p{P}|\\p{S}","u")),jn=ln(/\s/);function ln(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function rr(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let a="";if(s===37&&nt(e.charCodeAt(n+1))&&nt(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(a=String.fromCharCode(s));else if(s>55295&&s<57344){const o=e.charCodeAt(n+1);s<56320&&o>56319&&o<57344?(a=String.fromCharCode(s,o),i=1):a="�"}else a=String.fromCharCode(s);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function Ne(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return a;function a(l){return _e(l)?(e.enter(n),o(l)):t(l)}function o(l){return _e(l)&&s++<i?(e.consume(l),o):(e.exit(n),t(l))}}const _b={tokenize:Cb};function Cb(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),Ne(e,t,"linePrefix")}function i(o){return e.enter("paragraph"),s(o)}function s(o){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,a(o)}function a(o){if(o===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(o);return}return he(o)?(e.consume(o),e.exit("chunkText"),s):(e.consume(o),a)}}const jb={tokenize:Nb},_l={tokenize:Eb};function Nb(e){const t=this,n=[];let r=0,i,s,a;return o;function o(x){if(r<n.length){const P=n[r];return t.containerState=P[1],e.attempt(P[0].continuation,l,u)(x)}return u(x)}function l(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&_();const P=t.events.length;let E=P,k;for(;E--;)if(t.events[E][0]==="exit"&&t.events[E][1].type==="chunkFlow"){k=t.events[E][1].end;break}y(r);let C=P;for(;C<t.events.length;)t.events[C][1].end={...k},C++;return wt(t.events,E+1,0,t.events.slice(P)),t.events.length=C,u(x)}return o(x)}function u(x){if(r===n.length){if(!i)return h(x);if(i.currentConstruct&&i.currentConstruct.concrete)return m(x);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(_l,f,d)(x)}function f(x){return i&&_(),y(r),h(x)}function d(x){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,m(x)}function h(x){return t.containerState={},e.attempt(_l,p,m)(x)}function p(x){return r++,n.push([t.currentConstruct,t.containerState]),h(x)}function m(x){if(x===null){i&&_(),y(0),e.consume(x);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),w(x)}function w(x){if(x===null){S(e.exit("chunkFlow"),!0),y(0),e.consume(x);return}return he(x)?(e.consume(x),S(e.exit("chunkFlow")),r=0,t.interrupt=void 0,o):(e.consume(x),w)}function S(x,P){const E=t.sliceStream(x);if(P&&E.push(null),x.previous=s,s&&(s.next=x),s=x,i.defineSkip(x.start),i.write(E),t.parser.lazy[x.start.line]){let k=i.events.length;for(;k--;)if(i.events[k][1].start.offset<a&&(!i.events[k][1].end||i.events[k][1].end.offset>a))return;const C=t.events.length;let V=C,Y,N;for(;V--;)if(t.events[V][0]==="exit"&&t.events[V][1].type==="chunkFlow"){if(Y){N=t.events[V][1].end;break}Y=!0}for(y(r),k=C;k<t.events.length;)t.events[k][1].end={...N},k++;wt(t.events,V+1,0,t.events.slice(C)),t.events.length=k}}function y(x){let P=n.length;for(;P-- >x;){const E=n[P];t.containerState=E[1],E[0].exit.call(t,e)}n.length=x}function _(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Eb(e,t,n){return Ne(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Yn(e){if(e===null||De(e)||jn(e))return 1;if(rs(e))return 2}function is(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 ya={name:"attention",resolveAll:Ib,tokenize:zb};function Ib(e,t){let n=-1,r,i,s,a,o,l,u,f;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const d={...e[r][1].end},h={...e[n][1].start};Cl(d,-l),Cl(h,l),a={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},o={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:h},s={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...a.start},end:{...o.end}},e[r][1].end={...a.start},e[n][1].start={...o.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=jt(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=jt(u,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",s,t]]),u=jt(u,is(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=jt(u,[["exit",s,t],["enter",o,t],["exit",o,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,u=jt(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):f=0,wt(e,r-1,n-r+3,u),n=r+u.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function zb(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Yn(r);let s;return a;function a(l){return s=l,e.enter("attentionSequence"),o(l)}function o(l){if(l===s)return e.consume(l),o;const u=e.exit("attentionSequence"),f=Yn(l),d=!f||f===2&&i||n.includes(l),h=!i||i===2&&f||n.includes(r);return u._open=!!(s===42?d:d&&(i||!h)),u._close=!!(s===42?h:h&&(f||!d)),t(l)}}function Cl(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Tb={name:"autolink",tokenize:Ab};function Ab(e,t,n){let r=0;return i;function i(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(p){return ut(p)?(e.consume(p),a):p===64?n(p):u(p)}function a(p){return p===43||p===45||p===46||nt(p)?(r=1,o(p)):u(p)}function o(p){return p===58?(e.consume(p),r=0,l):(p===43||p===45||p===46||nt(p))&&r++<32?(e.consume(p),o):(r=0,u(p))}function l(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||Ii(p)?n(p):(e.consume(p),l)}function u(p){return p===64?(e.consume(p),f):wb(p)?(e.consume(p),u):n(p)}function f(p){return nt(p)?d(p):n(p)}function d(p){return p===46?(e.consume(p),r=0,f):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):h(p)}function h(p){if((p===45||nt(p))&&r++<63){const m=p===45?h:d;return e.consume(p),m}return n(p)}}const Hr={partial:!0,tokenize:Pb};function Pb(e,t,n){return r;function r(s){return _e(s)?Ne(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||he(s)?t(s):n(s)}}const Cf={continuation:{tokenize:Db},exit:Rb,name:"blockQuote",tokenize:Ob};function Ob(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 _e(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function Db(e,t,n){const r=this;return i;function i(a){return _e(a)?Ne(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):s(a)}function s(a){return e.attempt(Cf,t,n)(a)}}function Rb(e){e.exit("blockQuote")}const jf={name:"characterEscape",tokenize:Mb};function Mb(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 Sb(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const Nf={name:"characterReference",tokenize:$b};function $b(e,t,n){const r=this;let i=0,s,a;return o;function o(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),l}function l(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),s=31,a=nt,f(d))}function u(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,a=kb,f):(e.enter("characterReferenceValue"),s=7,a=xa,f(d))}function f(d){if(d===59&&i){const h=e.exit("characterReferenceValue");return a===nt&&!co(r.sliceSerialize(h))?n(d):(e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(d)&&i++<s?(e.consume(d),f):n(d)}}const jl={partial:!0,tokenize:Lb},Nl={concrete:!0,name:"codeFenced",tokenize:Fb};function Fb(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 C=r.events[r.events.length-1];return s=C&&C[1].type==="linePrefix"?C[2].sliceSerialize(C[1],!0).length:0,o=k,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),f(k)}function f(k){return k===o?(a++,e.consume(k),f):a<3?n(k):(e.exit("codeFencedFenceSequence"),_e(k)?Ne(e,d,"whitespace")(k):d(k))}function d(k){return k===null||he(k)?(e.exit("codeFencedFence"),r.interrupt?t(k):e.check(jl,w,P)(k)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),h(k))}function h(k){return k===null||he(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(k)):_e(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ne(e,p,"whitespace")(k)):k===96&&k===o?n(k):(e.consume(k),h)}function p(k){return k===null||he(k)?d(k):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(k))}function m(k){return k===null||he(k)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(k)):k===96&&k===o?n(k):(e.consume(k),m)}function w(k){return e.attempt(i,P,S)(k)}function S(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),y}function y(k){return s>0&&_e(k)?Ne(e,_,"linePrefix",s+1)(k):_(k)}function _(k){return k===null||he(k)?e.check(jl,w,P)(k):(e.enter("codeFlowValue"),x(k))}function x(k){return k===null||he(k)?(e.exit("codeFlowValue"),_(k)):(e.consume(k),x)}function P(k){return e.exit("codeFenced"),t(k)}function E(k,C,V){let Y=0;return N;function N(T){return k.enter("lineEnding"),k.consume(T),k.exit("lineEnding"),Z}function Z(T){return k.enter("codeFencedFence"),_e(T)?Ne(k,D,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):D(T)}function D(T){return T===o?(k.enter("codeFencedFenceSequence"),B(T)):V(T)}function B(T){return T===o?(Y++,k.consume(T),B):Y>=a?(k.exit("codeFencedFenceSequence"),_e(T)?Ne(k,F,"whitespace")(T):F(T)):V(T)}function F(T){return T===null||he(T)?(k.exit("codeFencedFence"),C(T)):V(T)}}}function Lb(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 Is={name:"codeIndented",tokenize:Bb},Zb={partial:!0,tokenize:Vb};function Bb(e,t,n){const r=this;return i;function i(u){return e.enter("codeIndented"),Ne(e,s,"linePrefix",5)(u)}function s(u){const f=r.events[r.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?a(u):n(u)}function a(u){return u===null?l(u):he(u)?e.attempt(Zb,a,l)(u):(e.enter("codeFlowValue"),o(u))}function o(u){return u===null||he(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),o)}function l(u){return e.exit("codeIndented"),t(u)}}function Vb(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):he(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):Ne(e,s,"linePrefix",5)(a)}function s(a){const o=r.events[r.events.length-1];return o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):he(a)?i(a):n(a)}}const Ub={name:"codeText",previous:Hb,resolve:Jb,tokenize:qb};function Jb(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 Hb(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function qb(e,t,n){let r=0,i,s;return a;function a(d){return e.enter("codeText"),e.enter("codeTextSequence"),o(d)}function o(d){return d===96?(e.consume(d),r++,o):(e.exit("codeTextSequence"),l(d))}function l(d){return d===null?n(d):d===32?(e.enter("space"),e.consume(d),e.exit("space"),l):d===96?(s=e.enter("codeTextSequence"),i=0,f(d)):he(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),l):(e.enter("codeTextData"),u(d))}function u(d){return d===null||d===32||d===96||he(d)?(e.exit("codeTextData"),l(d)):(e.consume(d),u)}function f(d){return d===96?(e.consume(d),i++,f):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(d)):(s.type="codeTextData",u(d))}}class Wb{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&fr(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),fr(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),fr(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);fr(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);fr(this.left,n.reverse())}}}function fr(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Ef(e){const t={};let n=-1,r,i,s,a,o,l,u;const f=new Wb(e);for(;++n<f.length;){for(;n in t;)n=t[n];if(r=f.get(n),n&&r[1].type==="chunkFlow"&&f.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,Gb(f,n)),n=t[n],u=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(a=f.get(s),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(i&&(f.get(i)[1].type="lineEndingBlank"),a[1].type="lineEnding",i=s);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;i&&(r[1].end={...f.get(i)[1].start},o=f.slice(i,n),o.unshift(r),f.splice(i,n-i+1,o))}}return wt(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!u}function Gb(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const o=a.events,l=[],u={};let f,d,h=-1,p=n,m=0,w=0;const S=[w];for(;p;){for(;e.get(++i)[1]!==p;);s.push(i),p._tokenizer||(f=r.sliceStream(p),p.next||f.push(null),d&&a.defineSkip(p.start),p._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(f),p._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++h<o.length;)o[h][0]==="exit"&&o[h-1][0]==="enter"&&o[h][1].type===o[h-1][1].type&&o[h][1].start.line!==o[h][1].end.line&&(w=h+1,S.push(w),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(a.events=[],p?(p._tokenizer=void 0,p.previous=void 0):S.pop(),h=S.length;h--;){const y=o.slice(S[h],S[h+1]),_=s.pop();l.push([_,_+y.length-1]),e.splice(_,2,y)}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 Kb={resolve:Xb,tokenize:Qb},Yb={partial:!0,tokenize:ev};function Xb(e){return Ef(e),e}function Qb(e,t){let n;return r;function r(o){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(o)}function i(o){return o===null?s(o):he(o)?e.check(Yb,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 ev(e,t,n){const r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Ne(e,s,"linePrefix")}function s(a){if(a===null||he(a))return n(a);const o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function If(e,t,n,r,i,s,a,o,l){const u=l||Number.POSITIVE_INFINITY;let f=0;return d;function d(y){return y===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(y),e.exit(s),h):y===null||y===32||y===41||Ii(y)?n(y):(e.enter(r),e.enter(a),e.enter(o),e.enter("chunkString",{contentType:"string"}),w(y))}function h(y){return y===62?(e.enter(s),e.consume(y),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),p(y))}function p(y){return y===62?(e.exit("chunkString"),e.exit(o),h(y)):y===null||y===60||he(y)?n(y):(e.consume(y),y===92?m:p)}function m(y){return y===60||y===62||y===92?(e.consume(y),p):p(y)}function w(y){return!f&&(y===null||y===41||De(y))?(e.exit("chunkString"),e.exit(o),e.exit(a),e.exit(r),t(y)):f<u&&y===40?(e.consume(y),f++,w):y===41?(e.consume(y),f--,w):y===null||y===32||y===40||Ii(y)?n(y):(e.consume(y),y===92?S:w)}function S(y){return y===40||y===41||y===92?(e.consume(y),w):w(y)}}function zf(e,t,n,r,i,s){const a=this;let o=0,l;return u;function u(p){return e.enter(r),e.enter(i),e.consume(p),e.exit(i),e.enter(s),f}function f(p){return o>999||p===null||p===91||p===93&&!l||p===94&&!o&&"_hiddenFootnoteSupport"in a.parser.constructs?n(p):p===93?(e.exit(s),e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):he(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),f):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===null||p===91||p===93||he(p)||o++>999?(e.exit("chunkString"),f(p)):(e.consume(p),l||(l=!_e(p)),p===92?h:d)}function h(p){return p===91||p===92||p===93?(e.consume(p),o++,d):d(p)}}function Tf(e,t,n,r,i,s){let a;return o;function o(h){return h===34||h===39||h===40?(e.enter(r),e.enter(i),e.consume(h),e.exit(i),a=h===40?41:h,l):n(h)}function l(h){return h===a?(e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):(e.enter(s),u(h))}function u(h){return h===a?(e.exit(s),l(a)):h===null?n(h):he(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),Ne(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===a||h===null||he(h)?(e.exit("chunkString"),u(h)):(e.consume(h),h===92?d:f)}function d(h){return h===a||h===92?(e.consume(h),f):f(h)}}function Er(e,t){let n;return r;function r(i){return he(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):_e(i)?Ne(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const tv={name:"definition",tokenize:rv},nv={partial:!0,tokenize:iv};function rv(e,t,n){const r=this;let i;return s;function s(p){return e.enter("definition"),a(p)}function a(p){return zf.call(r,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function o(p){return i=Dt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),l):n(p)}function l(p){return De(p)?Er(e,u)(p):u(p)}function u(p){return If(e,f,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function f(p){return e.attempt(nv,d,d)(p)}function d(p){return _e(p)?Ne(e,h,"whitespace")(p):h(p)}function h(p){return p===null||he(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function iv(e,t,n){return r;function r(o){return De(o)?Er(e,i)(o):n(o)}function i(o){return Tf(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function s(o){return _e(o)?Ne(e,a,"whitespace")(o):a(o)}function a(o){return o===null||he(o)?t(o):n(o)}}const sv={name:"hardBreakEscape",tokenize:av};function av(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return he(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const ov={name:"headingAtx",resolve:lv,tokenize:uv};function lv(e,t){let n=e.length-2,r=3,i,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},wt(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function uv(e,t,n){let r=0;return i;function i(f){return e.enter("atxHeading"),s(f)}function s(f){return e.enter("atxHeadingSequence"),a(f)}function a(f){return f===35&&r++<6?(e.consume(f),a):f===null||De(f)?(e.exit("atxHeadingSequence"),o(f)):n(f)}function o(f){return f===35?(e.enter("atxHeadingSequence"),l(f)):f===null||he(f)?(e.exit("atxHeading"),t(f)):_e(f)?Ne(e,o,"whitespace")(f):(e.enter("atxHeadingText"),u(f))}function l(f){return f===35?(e.consume(f),l):(e.exit("atxHeadingSequence"),o(f))}function u(f){return f===null||f===35||De(f)?(e.exit("atxHeadingText"),o(f)):(e.consume(f),u)}}const cv=["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"],El=["pre","script","style","textarea"],dv={concrete:!0,name:"htmlFlow",resolveTo:hv,tokenize:mv},fv={partial:!0,tokenize:xv},pv={partial:!0,tokenize:gv};function hv(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function mv(e,t,n){const r=this;let i,s,a,o,l;return u;function u(g){return f(g)}function f(g){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(g),d}function d(g){return g===33?(e.consume(g),h):g===47?(e.consume(g),s=!0,w):g===63?(e.consume(g),i=3,r.interrupt?t:b):ut(g)?(e.consume(g),a=String.fromCharCode(g),S):n(g)}function h(g){return g===45?(e.consume(g),i=2,p):g===91?(e.consume(g),i=5,o=0,m):ut(g)?(e.consume(g),i=4,r.interrupt?t:b):n(g)}function p(g){return g===45?(e.consume(g),r.interrupt?t:b):n(g)}function m(g){const G="CDATA[";return g===G.charCodeAt(o++)?(e.consume(g),o===G.length?r.interrupt?t:D:m):n(g)}function w(g){return ut(g)?(e.consume(g),a=String.fromCharCode(g),S):n(g)}function S(g){if(g===null||g===47||g===62||De(g)){const G=g===47,ie=a.toLowerCase();return!G&&!s&&El.includes(ie)?(i=1,r.interrupt?t(g):D(g)):cv.includes(a.toLowerCase())?(i=6,G?(e.consume(g),y):r.interrupt?t(g):D(g)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(g):s?_(g):x(g))}return g===45||nt(g)?(e.consume(g),a+=String.fromCharCode(g),S):n(g)}function y(g){return g===62?(e.consume(g),r.interrupt?t:D):n(g)}function _(g){return _e(g)?(e.consume(g),_):N(g)}function x(g){return g===47?(e.consume(g),N):g===58||g===95||ut(g)?(e.consume(g),P):_e(g)?(e.consume(g),x):N(g)}function P(g){return g===45||g===46||g===58||g===95||nt(g)?(e.consume(g),P):E(g)}function E(g){return g===61?(e.consume(g),k):_e(g)?(e.consume(g),E):x(g)}function k(g){return g===null||g===60||g===61||g===62||g===96?n(g):g===34||g===39?(e.consume(g),l=g,C):_e(g)?(e.consume(g),k):V(g)}function C(g){return g===l?(e.consume(g),l=null,Y):g===null||he(g)?n(g):(e.consume(g),C)}function V(g){return g===null||g===34||g===39||g===47||g===60||g===61||g===62||g===96||De(g)?E(g):(e.consume(g),V)}function Y(g){return g===47||g===62||_e(g)?x(g):n(g)}function N(g){return g===62?(e.consume(g),Z):n(g)}function Z(g){return g===null||he(g)?D(g):_e(g)?(e.consume(g),Z):n(g)}function D(g){return g===45&&i===2?(e.consume(g),H):g===60&&i===1?(e.consume(g),K):g===62&&i===4?(e.consume(g),ue):g===63&&i===3?(e.consume(g),b):g===93&&i===5?(e.consume(g),W):he(g)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(fv,ae,B)(g)):g===null||he(g)?(e.exit("htmlFlowData"),B(g)):(e.consume(g),D)}function B(g){return e.check(pv,F,ae)(g)}function F(g){return e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),T}function T(g){return g===null||he(g)?B(g):(e.enter("htmlFlowData"),D(g))}function H(g){return g===45?(e.consume(g),b):D(g)}function K(g){return g===47?(e.consume(g),a="",O):D(g)}function O(g){if(g===62){const G=a.toLowerCase();return El.includes(G)?(e.consume(g),ue):D(g)}return ut(g)&&a.length<8?(e.consume(g),a+=String.fromCharCode(g),O):D(g)}function W(g){return g===93?(e.consume(g),b):D(g)}function b(g){return g===62?(e.consume(g),ue):g===45&&i===2?(e.consume(g),b):D(g)}function ue(g){return g===null||he(g)?(e.exit("htmlFlowData"),ae(g)):(e.consume(g),ue)}function ae(g){return e.exit("htmlFlow"),t(g)}}function gv(e,t,n){const r=this;return i;function i(a){return he(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):n(a)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function xv(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Hr,t,n)}}const yv={name:"htmlText",tokenize:bv};function bv(e,t,n){const r=this;let i,s,a;return o;function o(b){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(b),l}function l(b){return b===33?(e.consume(b),u):b===47?(e.consume(b),E):b===63?(e.consume(b),x):ut(b)?(e.consume(b),V):n(b)}function u(b){return b===45?(e.consume(b),f):b===91?(e.consume(b),s=0,m):ut(b)?(e.consume(b),_):n(b)}function f(b){return b===45?(e.consume(b),p):n(b)}function d(b){return b===null?n(b):b===45?(e.consume(b),h):he(b)?(a=d,K(b)):(e.consume(b),d)}function h(b){return b===45?(e.consume(b),p):d(b)}function p(b){return b===62?H(b):b===45?h(b):d(b)}function m(b){const ue="CDATA[";return b===ue.charCodeAt(s++)?(e.consume(b),s===ue.length?w:m):n(b)}function w(b){return b===null?n(b):b===93?(e.consume(b),S):he(b)?(a=w,K(b)):(e.consume(b),w)}function S(b){return b===93?(e.consume(b),y):w(b)}function y(b){return b===62?H(b):b===93?(e.consume(b),y):w(b)}function _(b){return b===null||b===62?H(b):he(b)?(a=_,K(b)):(e.consume(b),_)}function x(b){return b===null?n(b):b===63?(e.consume(b),P):he(b)?(a=x,K(b)):(e.consume(b),x)}function P(b){return b===62?H(b):x(b)}function E(b){return ut(b)?(e.consume(b),k):n(b)}function k(b){return b===45||nt(b)?(e.consume(b),k):C(b)}function C(b){return he(b)?(a=C,K(b)):_e(b)?(e.consume(b),C):H(b)}function V(b){return b===45||nt(b)?(e.consume(b),V):b===47||b===62||De(b)?Y(b):n(b)}function Y(b){return b===47?(e.consume(b),H):b===58||b===95||ut(b)?(e.consume(b),N):he(b)?(a=Y,K(b)):_e(b)?(e.consume(b),Y):H(b)}function N(b){return b===45||b===46||b===58||b===95||nt(b)?(e.consume(b),N):Z(b)}function Z(b){return b===61?(e.consume(b),D):he(b)?(a=Z,K(b)):_e(b)?(e.consume(b),Z):Y(b)}function D(b){return b===null||b===60||b===61||b===62||b===96?n(b):b===34||b===39?(e.consume(b),i=b,B):he(b)?(a=D,K(b)):_e(b)?(e.consume(b),D):(e.consume(b),F)}function B(b){return b===i?(e.consume(b),i=void 0,T):b===null?n(b):he(b)?(a=B,K(b)):(e.consume(b),B)}function F(b){return b===null||b===34||b===39||b===60||b===61||b===96?n(b):b===47||b===62||De(b)?Y(b):(e.consume(b),F)}function T(b){return b===47||b===62||De(b)?Y(b):n(b)}function H(b){return b===62?(e.consume(b),e.exit("htmlTextData"),e.exit("htmlText"),t):n(b)}function K(b){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),O}function O(b){return _e(b)?Ne(e,W,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(b):W(b)}function W(b){return e.enter("htmlTextData"),a(b)}}const fo={name:"labelEnd",resolveAll:Sv,resolveTo:_v,tokenize:Cv},vv={tokenize:jv},wv={tokenize:Nv},kv={tokenize:Ev};function Sv(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&wt(e,0,e.length,n),e}function _v(e,t){let n=e.length,r=0,i,s,a,o;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(a=n);const l={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[s][1].start},end:{...e[a][1].end}},f={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[a-2][1].start}};return o=[["enter",l,t],["enter",u,t]],o=jt(o,e.slice(s+1,s+r+3)),o=jt(o,[["enter",f,t]]),o=jt(o,is(t.parser.constructs.insideSpan.null,e.slice(s+r+4,a-3),t)),o=jt(o,[["exit",f,t],e[a-2],e[a-1],["exit",u,t]]),o=jt(o,e.slice(a+1)),o=jt(o,[["exit",l,t]]),wt(e,s,e.length,o),e}function Cv(e,t,n){const r=this;let i=r.events.length,s,a;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return o;function o(h){return s?s._inactive?d(h):(a=r.parser.defined.includes(Dt(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(h),e.exit("labelMarker"),e.exit("labelEnd"),l):n(h)}function l(h){return h===40?e.attempt(vv,f,a?f:d)(h):h===91?e.attempt(wv,f,a?u:d)(h):a?f(h):d(h)}function u(h){return e.attempt(kv,f,d)(h)}function f(h){return t(h)}function d(h){return s._balanced=!0,n(h)}}function jv(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),i}function i(d){return De(d)?Er(e,s)(d):s(d)}function s(d){return d===41?f(d):If(e,a,o,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function a(d){return De(d)?Er(e,l)(d):f(d)}function o(d){return n(d)}function l(d){return d===34||d===39||d===40?Tf(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):f(d)}function u(d){return De(d)?Er(e,f)(d):f(d)}function f(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}function Nv(e,t,n){const r=this;return i;function i(o){return zf.call(r,e,s,a,"reference","referenceMarker","referenceString")(o)}function s(o){return r.parser.defined.includes(Dt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(o):n(o)}function a(o){return n(o)}}function Ev(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 Iv={name:"labelStartImage",resolveAll:fo.resolveAll,tokenize:zv};function zv(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 Tv={name:"labelStartLink",resolveAll:fo.resolveAll,tokenize:Av};function Av(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 zs={name:"lineEnding",tokenize:Pv};function Pv(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ne(e,t,"linePrefix")}}const hi={name:"thematicBreak",tokenize:Ov};function Ov(e,t,n){let r=0,i;return s;function s(u){return e.enter("thematicBreak"),a(u)}function a(u){return i=u,o(u)}function o(u){return u===i?(e.enter("thematicBreakSequence"),l(u)):r>=3&&(u===null||he(u))?(e.exit("thematicBreak"),t(u)):n(u)}function l(u){return u===i?(e.consume(u),r++,l):(e.exit("thematicBreakSequence"),_e(u)?Ne(e,o,"whitespace")(u):o(u))}}const ft={continuation:{tokenize:$v},exit:Lv,name:"list",tokenize:Mv},Dv={partial:!0,tokenize:Zv},Rv={partial:!0,tokenize:Fv};function Mv(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:xa(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(hi,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 xa(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(Hr,r.interrupt?n:f,e.attempt(Dv,h,d))}function f(p){return r.containerState.initialBlankLine=!0,s++,h(p)}function d(p){return _e(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 $v(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Hr,i,s);function i(o){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ne(e,t,"listItemIndent",r.containerState.size+1)(o)}function s(o){return r.containerState.furtherBlankLines||!_e(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(Rv,t,a)(o))}function a(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ne(e,e.attempt(ft,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}function Fv(e,t,n){const r=this;return Ne(e,i,"listItemIndent",r.containerState.size+1);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(s):n(s)}}function Lv(e){e.exit(this.containerState.type)}function Zv(e,t,n){const r=this;return Ne(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const a=r.events[r.events.length-1];return!_e(s)&&a&&a[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const Il={name:"setextUnderline",resolveTo:Bv,tokenize:Vv};function Bv(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 Vv(e,t,n){const r=this;let i;return s;function s(u){let f=r.events.length,d;for(;f--;)if(r.events[f][1].type!=="lineEnding"&&r.events[f][1].type!=="linePrefix"&&r.events[f][1].type!=="content"){d=r.events[f][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),i=u,a(u)):n(u)}function a(u){return e.enter("setextHeadingLineSequence"),o(u)}function o(u){return u===i?(e.consume(u),o):(e.exit("setextHeadingLineSequence"),_e(u)?Ne(e,l,"lineSuffix")(u):l(u))}function l(u){return u===null||he(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const Uv={tokenize:Jv};function Jv(e){const t=this,n=e.attempt(Hr,r,e.attempt(this.parser.constructs.flowInitial,i,Ne(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Kb,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 Hv={resolveAll:Pf()},qv=Af("string"),Wv=Af("text");function Af(e){return{resolveAll:Pf(e==="text"?Gv:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,a,o);return a;function a(f){return u(f)?s(f):o(f)}function o(f){if(f===null){n.consume(f);return}return n.enter("data"),n.consume(f),l}function l(f){return u(f)?(n.exit("data"),s(f)):(n.consume(f),l)}function u(f){if(f===null)return!0;const d=i[f];let h=-1;if(d)for(;++h<d.length;){const p=d[h];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function Pf(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 Gv(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 Kv={42:ft,43:ft,45:ft,48:ft,49:ft,50:ft,51:ft,52:ft,53:ft,54:ft,55:ft,56:ft,57:ft,62:Cf},Yv={91:tv},Xv={[-2]:Is,[-1]:Is,32:Is},Qv={35:ov,42:hi,45:[Il,hi],60:dv,61:Il,95:hi,96:Nl,126:Nl},ew={38:Nf,92:jf},tw={[-5]:zs,[-4]:zs,[-3]:zs,33:Iv,38:Nf,42:ya,60:[Tb,yv],91:Tv,92:[sv,jf],93:fo,95:ya,96:Ub},nw={null:[ya,Hv]},rw={null:[42,95]},iw={null:[]},sw=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:rw,contentInitial:Yv,disable:iw,document:Kv,flow:Qv,flowInitial:Xv,insideSpan:nw,string:ew,text:tw},Symbol.toStringTag,{value:"Module"}));function aw(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let a=[],o=[];const l={attempt:C(E),check:C(k),consume:_,enter:x,exit:P,interrupt:C(k,{interrupt:!0})},u={code:null,containerState:{},defineSkip:w,events:[],now:m,parser:e,previous:null,sliceSerialize:h,sliceStream:p,write:d};let f=t.tokenize.call(u,l);return t.resolveAll&&s.push(t),u;function d(Z){return a=jt(a,Z),S(),a[a.length-1]!==null?[]:(V(t,0),u.events=is(s,u.events,u),u.events)}function h(Z,D){return lw(p(Z),D)}function p(Z){return ow(a,Z)}function m(){const{_bufferIndex:Z,_index:D,line:B,column:F,offset:T}=r;return{_bufferIndex:Z,_index:D,line:B,column:F,offset:T}}function w(Z){i[Z.line]=Z.column,N()}function S(){let Z;for(;r._index<a.length;){const D=a[r._index];if(typeof D=="string")for(Z=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===Z&&r._bufferIndex<D.length;)y(D.charCodeAt(r._bufferIndex));else y(D)}}function y(Z){f=f(Z)}function _(Z){he(Z)?(r.line++,r.column=1,r.offset+=Z===-3?2:1,N()):Z!==-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=Z}function x(Z,D){const B=D||{};return B.type=Z,B.start=m(),u.events.push(["enter",B,u]),o.push(B),B}function P(Z){const D=o.pop();return D.end=m(),u.events.push(["exit",D,u]),D}function E(Z,D){V(Z,D.from)}function k(Z,D){D.restore()}function C(Z,D){return B;function B(F,T,H){let K,O,W,b;return Array.isArray(F)?ae(F):"tokenize"in F?ae([F]):ue(F);function ue(Q){return I;function I(R){const J=R!==null&&Q[R],oe=R!==null&&Q.null,pe=[...Array.isArray(J)?J:J?[J]:[],...Array.isArray(oe)?oe:oe?[oe]:[]];return ae(pe)(R)}}function ae(Q){return K=Q,O=0,Q.length===0?H:g(Q[O])}function g(Q){return I;function I(R){return b=Y(),W=Q,Q.partial||(u.currentConstruct=Q),Q.name&&u.parser.constructs.disable.null.includes(Q.name)?ie():Q.tokenize.call(D?Object.assign(Object.create(u),D):u,l,G,ie)(R)}}function G(Q){return Z(W,b),T}function ie(Q){return b.restore(),++O<K.length?g(K[O]):H}}}function V(Z,D){Z.resolveAll&&!s.includes(Z)&&s.push(Z),Z.resolve&&wt(u.events,D,u.events.length-D,Z.resolve(u.events.slice(D),u)),Z.resolveTo&&(u.events=Z.resolveTo(u.events,u))}function Y(){const Z=m(),D=u.previous,B=u.currentConstruct,F=u.events.length,T=Array.from(o);return{from:F,restore:H};function H(){r=Z,u.previous=D,u.currentConstruct=B,u.events.length=F,o=T,N()}}function N(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function ow(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 lw(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
4
|
`;break}case-3:{a=`\r
|
|
5
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 uw(e){const r={constructs:Sf([sw,...(e||{}).extensions||[]]),content:i(_b),defined:[],document:i(jb),flow:i(Uv),lazy:{},string:i(qv),text:i(Wv)};return r;function i(s){return a;function a(o){return aw(r,s,o)}}}function cw(e){for(;!Ef(e););return e}const zl=/[\0\t\n\r]/g;function dw(){let e=1,t="",n=!0,r;return i;function i(s,a,o){const l=[];let u,f,d,h,p;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(a||void 0).decode(s)),d=0,t="",n&&(s.charCodeAt(0)===65279&&d++,n=void 0);d<s.length;){if(zl.lastIndex=d,u=zl.exec(s),h=u&&u.index!==void 0?u.index:s.length,p=s.charCodeAt(h),!u){t=s.slice(d);break}if(p===10&&d===h&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),d<h&&(l.push(s.slice(d,h)),e+=h-d),p){case 0:{l.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,l.push(-2);e++<f;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}d=h+1}return o&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const fw=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function pw(e){return e.replace(fw,hw)}function hw(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return _f(n.slice(s?2:1),s?16:10)}return co(n)||e}const Of={}.hasOwnProperty;function mw(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),gw(n)(cw(uw(n).document().write(dw()(e,t,!0))))}function gw(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(z),autolinkProtocol:Y,autolinkEmail:Y,atxHeading:s(it),blockQuote:s(oe),characterEscape:Y,characterReference:Y,codeFenced:s(pe),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:s(pe,a),codeText:s(Ae,a),codeTextData:Y,data:Y,codeFlowValue:Y,definition:s(ke),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:s(be),hardBreakEscape:s(St),hardBreakTrailing:s(St),htmlFlow:s(yt,a),htmlFlowData:Y,htmlText:s(yt,a),htmlTextData:Y,image:s(j),label:a,link:s(z),listItem:s(ne),listItemValue:h,listOrdered:s($,d),listUnordered:s($),paragraph:s(te),reference:g,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:s(it),strong:s(ee),thematicBreak:s(xe)},exit:{atxHeading:l(),atxHeadingSequence:E,autolink:l(),autolinkEmail:J,autolinkProtocol:R,blockQuote:l(),characterEscapeValue:N,characterReferenceMarkerHexadecimal:ie,characterReferenceMarkerNumeric:ie,characterReferenceValue:Q,characterReference:I,codeFenced:l(S),codeFencedFence:w,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:N,codeIndented:l(y),codeText:l(T),codeTextData:N,data:N,definition:l(),definitionDestinationString:P,definitionLabelString:_,definitionTitleString:x,emphasis:l(),hardBreakEscape:l(D),hardBreakTrailing:l(D),htmlFlow:l(B),htmlFlowData:N,htmlText:l(F),htmlTextData:N,image:l(K),label:W,labelText:O,lineEnding:Z,link:l(H),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:G,resourceDestinationString:b,resourceTitleString:ue,resource:ae,setextHeading:l(V),setextHeadingLineSequence:C,setextHeadingText:k,strong:l(),thematicBreak:l()}};Df(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(M){let q={type:"root",children:[]};const de={stack:[q],tokenStack:[],config:t,enter:o,exit:u,buffer:a,resume:f,data:n},ve=[];let A=-1;for(;++A<M.length;)if(M[A][1].type==="listOrdered"||M[A][1].type==="listUnordered")if(M[A][0]==="enter")ve.push(A);else{const fe=ve.pop();A=i(M,fe,A)}for(A=-1;++A<M.length;){const fe=t[M[A][0]];Of.call(fe,M[A][1].type)&&fe[M[A][1].type].call(Object.assign({sliceSerialize:M[A][2].sliceSerialize},de),M[A][1])}if(de.tokenStack.length>0){const fe=de.tokenStack[de.tokenStack.length-1];(fe[1]||Tl).call(de,void 0,fe[0])}for(q.position={start:Kt(M.length>0?M[0][1].start:{line:1,column:1,offset:0}),end:Kt(M.length>0?M[M.length-2][1].end:{line:1,column:1,offset:0})},A=-1;++A<t.transforms.length;)q=t.transforms[A](q)||q;return q}function i(M,q,de){let ve=q-1,A=-1,fe=!1,Ce,Re,Qe,qe;for(;++ve<=de;){const tt=M[ve];switch(tt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{tt[0]==="enter"?A++:A--,qe=void 0;break}case"lineEndingBlank":{tt[0]==="enter"&&(Ce&&!qe&&!A&&!Qe&&(Qe=ve),qe=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:qe=void 0}if(!A&&tt[0]==="enter"&&tt[1].type==="listItemPrefix"||A===-1&&tt[0]==="exit"&&(tt[1].type==="listUnordered"||tt[1].type==="listOrdered")){if(Ce){let Gt=ve;for(Re=void 0;Gt--;){const Ut=M[Gt];if(Ut[1].type==="lineEnding"||Ut[1].type==="lineEndingBlank"){if(Ut[0]==="exit")continue;Re&&(M[Re][1].type="lineEndingBlank",fe=!0),Ut[1].type="lineEnding",Re=Gt}else if(!(Ut[1].type==="linePrefix"||Ut[1].type==="blockQuotePrefix"||Ut[1].type==="blockQuotePrefixWhitespace"||Ut[1].type==="blockQuoteMarker"||Ut[1].type==="listItemIndent"))break}Qe&&(!Re||Qe<Re)&&(Ce._spread=!0),Ce.end=Object.assign({},Re?M[Re][1].start:tt[1].end),M.splice(Re||ve,0,["exit",Ce,tt[2]]),ve++,de++}if(tt[1].type==="listItemPrefix"){const Gt={type:"listItem",_spread:!1,start:Object.assign({},tt[1].start),end:void 0};Ce=Gt,M.splice(ve,0,["enter",Gt,tt[2]]),ve++,de++,Qe=void 0,qe=!0}}}return M[q][1]._spread=fe,de}function s(M,q){return de;function de(ve){o.call(this,M(ve),ve),q&&q.call(this,ve)}}function a(){this.stack.push({type:"fragment",children:[]})}function o(M,q,de){this.stack[this.stack.length-1].children.push(M),this.stack.push(M),this.tokenStack.push([q,de||void 0]),M.position={start:Kt(q.start),end:void 0}}function l(M){return q;function q(de){M&&M.call(this,de),u.call(this,de)}}function u(M,q){const de=this.stack.pop(),ve=this.tokenStack.pop();if(ve)ve[0].type!==M.type&&(q?q.call(this,M,ve[0]):(ve[1]||Tl).call(this,M,ve[0]));else throw new Error("Cannot close `"+M.type+"` ("+Nr({start:M.start,end:M.end})+"): it’s not open");de.position.end=Kt(M.end)}function f(){return uo(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function h(M){if(this.data.expectingFirstListItemValue){const q=this.stack[this.stack.length-2];q.start=Number.parseInt(this.sliceSerialize(M),10),this.data.expectingFirstListItemValue=void 0}}function p(){const M=this.resume(),q=this.stack[this.stack.length-1];q.lang=M}function m(){const M=this.resume(),q=this.stack[this.stack.length-1];q.meta=M}function w(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const M=this.resume(),q=this.stack[this.stack.length-1];q.value=M.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const M=this.resume(),q=this.stack[this.stack.length-1];q.value=M.replace(/(\r?\n|\r)$/g,"")}function _(M){const q=this.resume(),de=this.stack[this.stack.length-1];de.label=q,de.identifier=Dt(this.sliceSerialize(M)).toLowerCase()}function x(){const M=this.resume(),q=this.stack[this.stack.length-1];q.title=M}function P(){const M=this.resume(),q=this.stack[this.stack.length-1];q.url=M}function E(M){const q=this.stack[this.stack.length-1];if(!q.depth){const de=this.sliceSerialize(M).length;q.depth=de}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function C(M){const q=this.stack[this.stack.length-1];q.depth=this.sliceSerialize(M).codePointAt(0)===61?1:2}function V(){this.data.setextHeadingSlurpLineEnding=void 0}function Y(M){const de=this.stack[this.stack.length-1].children;let ve=de[de.length-1];(!ve||ve.type!=="text")&&(ve=ce(),ve.position={start:Kt(M.start),end:void 0},de.push(ve)),this.stack.push(ve)}function N(M){const q=this.stack.pop();q.value+=this.sliceSerialize(M),q.position.end=Kt(M.end)}function Z(M){const q=this.stack[this.stack.length-1];if(this.data.atHardBreak){const de=q.children[q.children.length-1];de.position.end=Kt(M.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(q.type)&&(Y.call(this,M),N.call(this,M))}function D(){this.data.atHardBreak=!0}function B(){const M=this.resume(),q=this.stack[this.stack.length-1];q.value=M}function F(){const M=this.resume(),q=this.stack[this.stack.length-1];q.value=M}function T(){const M=this.resume(),q=this.stack[this.stack.length-1];q.value=M}function H(){const M=this.stack[this.stack.length-1];if(this.data.inReference){const q=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=q,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function K(){const M=this.stack[this.stack.length-1];if(this.data.inReference){const q=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=q,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function O(M){const q=this.sliceSerialize(M),de=this.stack[this.stack.length-2];de.label=pw(q),de.identifier=Dt(q).toLowerCase()}function W(){const M=this.stack[this.stack.length-1],q=this.resume(),de=this.stack[this.stack.length-1];if(this.data.inReference=!0,de.type==="link"){const ve=M.children;de.children=ve}else de.alt=q}function b(){const M=this.resume(),q=this.stack[this.stack.length-1];q.url=M}function ue(){const M=this.resume(),q=this.stack[this.stack.length-1];q.title=M}function ae(){this.data.inReference=void 0}function g(){this.data.referenceType="collapsed"}function G(M){const q=this.resume(),de=this.stack[this.stack.length-1];de.label=q,de.identifier=Dt(this.sliceSerialize(M)).toLowerCase(),this.data.referenceType="full"}function ie(M){this.data.characterReferenceType=M.type}function Q(M){const q=this.sliceSerialize(M),de=this.data.characterReferenceType;let ve;de?(ve=_f(q,de==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ve=co(q);const A=this.stack[this.stack.length-1];A.value+=ve}function I(M){const q=this.stack.pop();q.position.end=Kt(M.end)}function R(M){N.call(this,M);const q=this.stack[this.stack.length-1];q.url=this.sliceSerialize(M)}function J(M){N.call(this,M);const q=this.stack[this.stack.length-1];q.url="mailto:"+this.sliceSerialize(M)}function oe(){return{type:"blockquote",children:[]}}function pe(){return{type:"code",lang:null,meta:null,value:""}}function Ae(){return{type:"inlineCode",value:""}}function ke(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function be(){return{type:"emphasis",children:[]}}function it(){return{type:"heading",depth:0,children:[]}}function St(){return{type:"break"}}function yt(){return{type:"html",value:""}}function j(){return{type:"image",title:null,url:"",alt:null}}function z(){return{type:"link",title:null,url:"",children:[]}}function $(M){return{type:"list",ordered:M.type==="listOrdered",start:null,spread:M._spread,children:[]}}function ne(M){return{type:"listItem",spread:M._spread,checked:null,children:[]}}function te(){return{type:"paragraph",children:[]}}function ee(){return{type:"strong",children:[]}}function ce(){return{type:"text",value:""}}function xe(){return{type:"thematicBreak"}}}function Kt(e){return{line:e.line,column:e.column,offset:e.offset}}function Df(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Df(e,r):xw(e,r)}}function xw(e,t){let n;for(n in t)if(Of.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 Tl(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Nr({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Nr({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Nr({start:t.start,end:t.end})+") is still open")}function yw(e){const t=this;t.parser=n;function n(r){return mw(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function bw(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 vw(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
@@ -96,4 +96,4 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
96
96
|
`;)t++;return!0}return!1}function u(O){if(f(O)){if(Vu(e[t]))for(;t<e.length&&Uu(e[t]);)t++;return a(),!0}return!1}function f(O){o(!0);for(const W of O){const b=t+W.length;if(e.slice(t,b)===W)return t=b,!0}return!1}function d(O){return e[t]===O?(n+=e[t],t++,!0):!1}function h(O){return e[t]===O?(t++,!0):!1}function p(){return h("\\")}function m(){return a(),e[t]==="."&&e[t+1]==="."&&e[t+2]==="."?(t+=3,a(),h(","),!0):!1}function w(){if(e[t]==="{"){n+="{",t++,a(),h(",")&&a();let O=!0;for(;t<e.length&&e[t]!=="}";){let W;if(O?(W=!0,O=!1):(W=d(","),W||(n=Tt(n,",")),a()),m(),!(_()||C(!0))){e[t]==="}"||e[t]==="{"||e[t]==="]"||e[t]==="["||e[t]===void 0?n=hr(n,","):T();break}a();const ue=d(":"),ae=t>=e.length;ue||(Wu(e[t])||ae?n=Tt(n,":"):H()),s()||(ue||ae?n+="null":H())}return e[t]==="}"?(n+="}",t++):n=Tt(n,"}"),!0}return!1}function S(){if(e[t]==="["){n+="[",t++,a(),h(",")&&a();let O=!0;for(;t<e.length&&e[t]!=="]";)if(O?O=!1:d(",")||(n=Tt(n,",")),m(),!s()){n=hr(n,",");break}return e[t]==="]"?(n+="]",t++):n=Tt(n,"]"),!0}return!1}function y(){let O=!0,W=!0;for(;W;)O?O=!1:d(",")||(n=Tt(n,",")),W=s();W||(n=hr(n,",")),n=`[
|
|
97
97
|
${n}
|
|
98
98
|
]`}function _(){let O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,W=arguments.length>1&&arguments[1]!==void 0?arguments[1]:-1,b=e[t]==="\\";if(b&&(t++,b=!0),xi(e[t])){const ue=Gu(e[t])?Gu:Ku(e[t])?Ku:Oa(e[t])?Oa:Kh,ae=t,g=n.length;let G='"';for(t++;;){if(t>=e.length){const ie=Y(t-1);return!O&&ui(e.charAt(ie))?(t=ae,n=n.substring(0,g),_(!0)):(G=Tt(G,'"'),n+=G,!0)}if(t===W)return G=Tt(G,'"'),n+=G,!0;if(ue(e[t])){const ie=t,Q=G.length;if(G+='"',t++,n+=G,a(!1),O||t>=e.length||ui(e[t])||xi(e[t])||hn(e[t]))return x(),!0;const I=Y(ie-1),R=e.charAt(I);if(R===",")return t=ae,n=n.substring(0,g),_(!1,I);if(ui(R))return t=ae,n=n.substring(0,g),_(!0);n=n.substring(0,g),t=ie+1,G=`${G.substring(0,Q)}\\${G.substring(Q)}`}else if(O&&qu(e[t])){if(e[t-1]===":"&&Ju.test(e.substring(ae+1,t+2)))for(;t<e.length&&Hu.test(e[t]);)G+=e[t],t++;return G=Tt(G,'"'),n+=G,x(),!0}else if(e[t]==="\\"){const ie=e.charAt(t+1);if(nz[ie]!==void 0)G+=e.slice(t,t+2),t+=2;else if(ie==="u"){let I=2;for(;I<6&&qI(e[t+I]);)I++;I===6?(G+=e.slice(t,t+6),t+=6):t+I>=e.length?t=e.length:K()}else G+=ie,t+=2}else{const ie=e.charAt(t);ie==='"'&&e[t-1]!=="\\"?(G+=`\\${ie}`,t++):KI(ie)?(G+=tz[ie],t++):(WI(ie)||D(ie),G+=ie,t++)}b&&p()}}return!1}function x(){let O=!1;for(a();e[t]==="+";){O=!0,t++,a(),n=hr(n,'"',!0);const W=n.length;_()?n=QI(n,W,1):n=Tt(n,'"')}return O}function P(){const O=t;if(e[t]==="-"){if(t++,N())return Z(O),!0;if(!hn(e[t]))return t=O,!1}for(;hn(e[t]);)t++;if(e[t]==="."){if(t++,N())return Z(O),!0;if(!hn(e[t]))return t=O,!1;for(;hn(e[t]);)t++}if(e[t]==="e"||e[t]==="E"){if(t++,(e[t]==="-"||e[t]==="+")&&t++,N())return Z(O),!0;if(!hn(e[t]))return t=O,!1;for(;hn(e[t]);)t++}if(!N())return t=O,!1;if(t>O){const W=e.slice(O,t),b=/^0\d/.test(W);return n+=b?`"${W}"`:W,!0}return!1}function E(){return k("true","true")||k("false","false")||k("null","null")||k("True","true")||k("False","false")||k("None","null")}function k(O,W){return e.slice(t,t+O.length)===O?(n+=W,t+=O.length,!0):!1}function C(O){const W=t;if(Vu(e[t])){for(;t<e.length&&Uu(e[t]);)t++;let b=t;for(;gn(e,b);)b++;if(e[b]==="(")return t=b+1,s(),e[t]===")"&&(t++,e[t]===";"&&t++),!0}for(;t<e.length&&!qu(e[t])&&!xi(e[t])&&(!O||e[t]!==":");)t++;if(e[t-1]===":"&&Ju.test(e.substring(W,t+2)))for(;t<e.length&&Hu.test(e[t]);)t++;if(t>W){for(;gn(e,t-1)&&t>0;)t--;const b=e.slice(W,t);return n+=b==="undefined"?"null":JSON.stringify(b),e[t]==='"'&&t++,!0}}function V(){if(e[t]==="/"){const O=t;for(t++;t<e.length&&(e[t]!=="/"||e[t-1]==="\\");)t++;return t++,n+=JSON.stringify(e.substring(O,t)),!0}}function Y(O){let W=O;for(;W>0&&gn(e,W);)W--;return W}function N(){return t>=e.length||ui(e[t])||gn(e,t)}function Z(O){n+=`${e.slice(O,t)}0`}function D(O){throw new Mn(`Invalid character ${JSON.stringify(O)}`,t)}function B(){throw new Mn(`Unexpected character ${JSON.stringify(e[t])}`,t)}function F(){throw new Mn("Unexpected end of json string",e.length)}function T(){throw new Mn("Object key expected",t)}function H(){throw new Mn("Colon expected",t)}function K(){const O=e.slice(t,t+6);throw new Mn(`Invalid unicode character "${O}"`,t)}}function rz(e,t){return e[t]==="*"&&e[t+1]==="/"}function iz({json:e,context:t,scope:n}){const[r,i]=v.useState(!1),[s,a]=v.useState(null),o=v.useMemo(()=>{try{return JSON.parse(e),e}catch{}try{return Yu(e)}catch{}const y=`{${e}}`;try{return JSON.parse(y),y}catch{}try{return Yu(y)}catch{return null}},[e]),l=v.useMemo(()=>Vh(o||e),[o,e]),u=Xe(y=>y.activeTab),f=Xe(y=>y.documents),d=Xe(y=>(y.acceptedApplyIds||[]).includes(l)),h=Xe(y=>y.setPendingDiff),p=Xe(y=>y.createDocument),m=Xe(y=>y.openDocument),w=v.useCallback(()=>{if(o){a(null);try{if(u){const y=f.find(k=>k.name===u),_=(y==null?void 0:y.text)||"";if(n==="templates")try{const k=JSON.parse(_),C=JSON.parse(o);if(Array.isArray(C.templates)){k.props||(k.props={}),k.props.templates=Bh(k.props.templates||[],C.templates);const V=JSON.stringify(k,null,2);h(u,_,V,l);return}}catch{}const x=t==null?void 0:t[0],{original:P,modified:E}=Uh(_,o,x);h(u,P,E,l)}else{const y=`ai-generated-${Date.now()}`;p(y,o),m(y)}}catch(y){a(y instanceof Error?y.message:"Merge failed")}}},[o,u,f,h,p,m,t,n,l]),S=v.useCallback(async()=>{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),1500)},[e]);return c.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2 border-t",children:[c.jsxs("div",{className:"flex gap-1.5",children:[c.jsx(Ie,{variant:"secondary",size:"sm",onClick:w,disabled:d||!o,children:d?"Applied":o?"Apply to Editor":"Invalid JSON"}),c.jsx(Ie,{variant:"ghost",size:"sm",onClick:S,children:r?c.jsx(kn,{className:"h-3.5 w-3.5"}):c.jsx($a,{className:"h-3.5 w-3.5"})})]}),s&&c.jsx("p",{className:"text-xs text-destructive m-0",children:s})]})}function sz({threads:e,activeThread:t,disabled:n,onSwitch:r,onCreate:i,onDelete:s,onRename:a}){const[o,l]=v.useState(null),[u,f]=v.useState(""),[d,h]=v.useState(null),p=v.useRef(null),m=(t==null?void 0:t.title)||"New Chat",w=m.length>24?m.slice(0,24)+"...":m;v.useEffect(()=>{o&&requestAnimationFrame(()=>{var C;return(C=p.current)==null?void 0:C.focus()})},[o]);const S=v.useCallback((C,V)=>{V.stopPropagation(),V.preventDefault(),l(C.id),f(C.title),h(null)},[]),y=v.useCallback(()=>{o&&u.trim()&&a(o,u.trim()),l(null),f("")},[o,u,a]),_=v.useCallback(()=>{l(null),f("")},[]),x=v.useCallback(C=>{C.stopPropagation(),C.key==="Enter"?(C.preventDefault(),y()):C.key==="Escape"&&(C.preventDefault(),_())},[y,_]),P=v.useCallback((C,V)=>{V.stopPropagation(),V.preventDefault(),h(C),l(null)},[]),E=v.useCallback(C=>{C.stopPropagation(),C.preventDefault(),d&&(s(d),h(null))},[d,s]),k=v.useCallback(C=>{C.stopPropagation(),C.preventDefault(),h(null)},[]);return c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsxs(Dd,{onOpenChange:C=>{C||(l(null),h(null))},children:[c.jsx(Rd,{asChild:!0,disabled:n,children:c.jsxs("button",{className:"flex items-center gap-1 text-sm font-semibold tracking-tight hover:text-foreground/80 transition-colors max-w-[180px] cursor-pointer",children:[c.jsx("div",{className:"h-2 w-2 rounded-full bg-primary/70 shrink-0"}),c.jsx("span",{className:"truncate",children:w}),c.jsx(rn,{className:"h-3 w-3 shrink-0 opacity-60"})]})}),c.jsxs(Xa,{align:"start",className:"w-64",children:[e.map(C=>{const V=o===C.id;return d===C.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(kn,{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(wn,{className:"h-3.5 w-3.5"})})]},C.id):V?c.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1",onClick:N=>N.stopPropagation(),onPointerDown:N=>N.stopPropagation(),children:[c.jsx("input",{ref:p,type:"text",value:u,onChange:N=>f(N.target.value),onKeyDown:x,onBlur:y,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:N=>{N.preventDefault(),y()},children:c.jsx(kn,{className:"h-3.5 w-3.5"})}),c.jsx("button",{className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onMouseDown:N=>{N.preventDefault(),_()},children:c.jsx(wn,{className:"h-3.5 w-3.5"})})]},C.id):c.jsxs(tn,{onSelect:()=>r(C.id),className:`group ${C.id===(t==null?void 0:t.id)?"bg-accent":""}`,children:[c.jsx("span",{className:"truncate flex-1",children:C.title.length>30?C.title.slice(0,30)+"...":C.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:N=>S(C,N),children:c.jsx(Wm,{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:N=>P(C.id,N),children:c.jsx(Fa,{className:"h-3 w-3"})})]})]},C.id)}),c.jsx(ji,{}),c.jsxs(tn,{onSelect:C=>{C.preventDefault();const V=i();V&&(l(V),f(Ga()),h(null))},children:[c.jsx(yi,{className:"h-3.5 w-3.5 mr-1.5"}),"New Chat"]})]})]}),c.jsx(Ie,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-foreground",onClick:()=>i(),disabled:n,title:"New chat thread",children:c.jsx(yi,{className:"h-3.5 w-3.5"})})]})}const Yh=new Set(["image/png","image/jpeg","image/gif","image/webp","application/pdf","text/plain","text/markdown","text/csv","text/html"]),az=Array.from(Yh).join(","),oz=20*1024*1024,Xu=10;function lz(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 Qu(e){return Array.from(e).filter(t=>Yh.has(t.type)&&t.size<=oz)}function Xh(e){return e.startsWith("image/")}function ec(){var q,de,ve;const e=ze(A=>A.contextAttachments),t=ze(A=>A.addContext),n=ze(A=>A.removeContext),r=ze(A=>A.scope),i=ze(A=>A.setScope),s=ze(A=>A.model),a=ze(A=>A.setModel),o=ze(A=>A.openChat),l=ze(A=>A.closeChat),u=ze(A=>A.threads),f=ze(A=>A.activeThreadId),d=ze(A=>A.createThread),h=ze(A=>A.deleteThread),p=ze(A=>A.switchThread),m=ze(A=>A.updateThreadMessages),w=ze(A=>A.updateThreadTitle),S=ze(A=>A.deleteThreadsForDocument),y=Xe(A=>A.activeTab),_=Xe(A=>A.documents),{messages:x,sendMessage:P,status:E,error:k,setMessages:C,stop:V,getMessageContext:Y,getMessageScope:N}=DI(),[Z,D]=v.useState(""),[B,F]=v.useState([]),[T,H]=v.useState(!1),[K,O]=v.useState(!1),W=v.useRef(null),b=v.useRef(null),ue=v.useRef(null),ae=v.useCallback(async A=>{const fe=Qu(A);if(fe.length===0)return;const Ce=await Promise.all(fe.map(lz));F(Re=>{const Qe=[...Re,...Ce];return Qe.length>Xu?Qe.slice(0,Xu):Qe})},[]),g=v.useCallback(A=>{F(fe=>fe.filter((Ce,Re)=>Re!==A))},[]),G=v.useCallback(A=>{var Ce;const fe=(Ce=A.clipboardData)==null?void 0:Ce.files;if(fe&&fe.length>0){const Re=Qu(fe);Re.length>0&&(A.preventDefault(),ae(Re))}},[ae]),ie=v.useCallback(A=>{var Ce;A.preventDefault(),O(!1);const fe=(Ce=A.dataTransfer)==null?void 0:Ce.files;fe&&fe.length>0&&ae(Array.from(fe))},[ae]),Q=v.useCallback(A=>{A.preventDefault(),O(!0)},[]),I=v.useCallback(()=>O(!1),[]),R=y?f[y]:void 0,J=R?u[R]:void 0,oe=v.useMemo(()=>y?Object.values(u).filter(A=>A.documentName===y).sort((A,fe)=>fe.updatedAt-A.updatedAt):[],[u,y]);v.useEffect(()=>{y&&oe.length===0&&d(y)},[y,oe.length,d]);const pe=v.useRef(u);pe.current=u,v.useEffect(()=>{const A=new Set(_.map(Ce=>Ce.name)),fe=new Set;for(const Ce of Object.values(pe.current))!A.has(Ce.documentName)&&Ce.documentName!=="__migrated__"&&fe.add(Ce.documentName);for(const Ce of fe)S(Ce)},[_,S]);const Ae=v.useRef(null);v.useEffect(()=>{Ae.current!==R&&(Ae.current=R,C((J==null?void 0:J.messages)??[]))},[R,J,C]),v.useEffect(()=>{var A;(A=W.current)==null||A.scrollIntoView({behavior:"smooth"})},[x,E]),v.useEffect(()=>{const A=fe=>{var Qe;const{documentName:Ce,selection:Re}=fe.detail;t({...Re,documentName:Ce}),o(),(Qe=b.current)==null||Qe.focus()};return window.addEventListener("monaco-selection-to-ai",A),()=>window.removeEventListener("monaco-selection-to-ai",A)},[t,o]);const ke=E==="streaming",be=E==="submitted"||ke,it=v.useCallback(A=>{A.preventDefault(),!(!Z.trim()&&B.length===0||be)&&(P(Z,B.length>0?B:void 0),D(""),F([]))},[Z,B,be,P]),St=v.useCallback(A=>{A.key==="Enter"&&!A.shiftKey&&(A.preventDefault(),it(A))},[it]),yt=v.useCallback(()=>{x.length!==0&&H(!0)},[x.length]),j=v.useCallback(()=>{H(!1),C([]),R&&(m(R,[]),w(R,Ga()))},[C,R,m,w]),[z,$]=v.useState(null),ne=v.useCallback(A=>{$(A)},[]),te=v.useCallback(()=>{var Qe,qe;if(!z)return;const A=x.findIndex(tt=>tt.id===z);if(A===-1){$(null);return}const fe=x[A],Ce=new Set([A]);fe.role==="user"&&((Qe=x[A+1])==null?void 0:Qe.role)==="assistant"?Ce.add(A+1):fe.role==="assistant"&&A>0&&((qe=x[A-1])==null?void 0:qe.role)==="user"&&Ce.add(A-1);const Re=x.filter((tt,Gt)=>!Ce.has(Gt));C(Re),R&&m(R,Re),$(null)},[z,x,C,R,m]),ee=v.useCallback(A=>{if(!be){if(oe.length<=1){yt();return}h(A)}},[be,oe.length,yt,h]),ce=v.useCallback(()=>{if(!(!y||be))return d(y)},[y,be,d]),xe=v.useCallback(A=>{be||A===R||p(A)},[be,R,p]),M=v.useCallback((A,fe)=>{w(A,fe)},[w]);return c.jsxs("div",{className:"flex flex-col h-full border-l bg-surface-chat",children:[c.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border/60 bg-surface-chat",children:[c.jsx(sz,{threads:oe,activeThread:J,disabled:be,onSwitch:xe,onCreate:ce,onDelete:ee,onRename:M}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(Ie,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:yt,disabled:be||x.length===0,children:"Clear"}),c.jsx(Ie,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:l,title:"Close chat",children:c.jsx(wn,{className:"h-3.5 w-3.5"})})]})]}),c.jsx(Ar,{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:[x.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(Ro,{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(fa,{shortcut:"mod+k"}),c.jsx("span",{className:"text-xs text-muted-foreground",children:"to send a selection"})]})]}),x.map((A,fe)=>{let Ce;if(A.role==="user"){const qe=Y(A.id);qe&&qe.length>0&&(Ce=qe)}else if(A.role==="assistant"){for(let qe=fe-1;qe>=0;qe--)if(x[qe].role==="user"){Ce=Y(x[qe].id);break}}const Re=ke&&fe===x.length-1&&A.role==="assistant",Qe=A.role==="user"?N(A.id):void 0;return c.jsx(uz,{msg:A,isStreaming:Re,context:Ce,scope:Qe,onDelete:be?void 0:ne},A.id)}),be&&((q=x[x.length-1])==null?void 0:q.role)!=="assistant"&&c.jsx("div",{className:"flex justify-start",children:c.jsx("div",{className:"rounded-lg px-3 py-2 bg-muted/60 border border-border/40",children:c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(Gm,{className:"h-3.5 w-3.5 animate-spin text-primary"}),c.jsx("span",{children:"Thinking..."})]})})}),k&&!be&&c.jsx("div",{className:"flex justify-start",children:c.jsx("div",{className:"rounded-lg px-3 py-2 bg-destructive/10 border border-destructive/30 text-destructive text-sm max-w-[90%]",children:k.message||"Something went wrong"})}),c.jsx("div",{ref:W})]})}),c.jsxs("div",{className:`border-t border-border/60 p-2.5 space-y-2 bg-surface-chat transition-colors ${K?"ring-2 ring-primary/40 bg-primary/5":""}`,onDrop:ie,onDragOver:Q,onDragLeave:I,children:[e.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.map((A,fe)=>c.jsx(Hh,{context:A,onRemove:()=>n(fe)},fe))}),c.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[c.jsx(fz,{model:s,setModel:a}),Nt==="pptx"&&y&&c.jsx(hz,{scope:r,setScope:i,docSize:((ve=(de=_.find(A=>A.name===y))==null?void 0:de.text)==null?void 0:ve.length)??0})]}),B.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1.5",children:B.map((A,fe)=>c.jsxs("div",{className:"relative group",children:[Xh(A.mediaType)?c.jsx("img",{src:A.url,alt:A.filename||"attachment",className:"h-14 w-14 rounded-md object-cover border border-border/60"}):c.jsxs("div",{className:"h-14 px-2.5 flex items-center gap-1.5 rounded-md border border-border/60 bg-muted/60 max-w-[140px]",children:[c.jsx(Ks,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),c.jsx("span",{className:"text-xs truncate text-muted-foreground",children:A.filename||"file"})]}),c.jsx("button",{type:"button",onClick:()=>g(fe),className:"absolute -top-1.5 -right-1.5 rounded-full bg-destructive text-destructive-foreground p-0.5 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:c.jsx(wn,{className:"h-3 w-3"})})]},fe))}),c.jsxs("form",{onSubmit:it,className:"flex items-end gap-2",children:[c.jsx("input",{ref:ue,type:"file",accept:az,multiple:!0,className:"hidden",onChange:A=>{A.target.files&&ae(Array.from(A.target.files)),A.target.value=""}}),c.jsx(Ie,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 h-9 w-9 rounded-lg text-muted-foreground hover:text-foreground",onClick:()=>{var A;return(A=ue.current)==null?void 0:A.click()},title:"Attach file",children:c.jsx(Ks,{className:"h-4 w-4"})}),c.jsx("textarea",{ref:b,value:Z,onChange:A=>{D(A.target.value);const fe=A.target;fe.style.height="auto",fe.style.height=`${Math.min(fe.scrollHeight,128)}px`},onKeyDown:St,onPaste:G,placeholder:e.length>0?"Describe how to edit the selection...":r==="slides"?"Add, edit, or remove slides...":r==="templates"?"Edit template layouts and placeholders...":"Ask AI to generate or edit JSON...",className:"flex-1 min-h-[36px] max-h-32 resize-none overflow-y-auto rounded-lg border border-border/60 bg-background px-3 py-1.5 text-sm placeholder:text-muted-foreground placeholder:whitespace-nowrap placeholder:overflow-hidden placeholder:text-ellipsis focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30 focus-visible:border-primary/50 transition-shadow",rows:1}),be?c.jsx(Ie,{type:"button",size:"icon",variant:"destructive",className:"shrink-0 h-9 w-9 rounded-lg",onClick:V,title:"Stop generating",children:c.jsx(Km,{className:"h-4 w-4"})}):c.jsx(Ie,{type:"submit",size:"icon",disabled:!Z.trim()&&B.length===0,className:"shrink-0 h-9 w-9 rounded-lg",children:c.jsx(Ro,{className:"h-4 w-4"})})]})]}),c.jsx(qt,{open:T,onOpenChange:H,children:c.jsxs(Zt,{className:"max-w-sm",children:[c.jsxs(Sn,{children:[c.jsx(_n,{children:"Clear thread"}),c.jsx(Gn,{children:"This will delete all messages in this thread. This action cannot be undone."})]}),c.jsxs(zr,{children:[c.jsx(qo,{asChild:!0,children:c.jsx(Ie,{variant:"ghost",size:"sm",children:"Cancel"})}),c.jsx(Ie,{variant:"destructive",size:"sm",onClick:j,children:"Clear"})]})]})}),c.jsx(qt,{open:z!==null,onOpenChange:A=>{A||$(null)},children:c.jsxs(Zt,{className:"max-w-sm",children:[c.jsxs(Sn,{children:[c.jsx(_n,{children:"Delete message"}),c.jsx(Gn,{children:"This will delete the message and its paired response. This action cannot be undone."})]}),c.jsxs(zr,{children:[c.jsx(qo,{asChild:!0,children:c.jsx(Ie,{variant:"ghost",size:"sm",children:"Cancel"})}),c.jsx(Ie,{variant:"destructive",size:"sm",onClick:te,children:"Delete"})]})]})})]})}const uz=v.memo(function({msg:t,isStreaming:n,context:r,scope:i,onDelete:s}){var l,u;const a=((l=t.parts)==null?void 0:l.filter(f=>f.type==="text").map(f=>f.text).join(""))||"",o=((u=t.parts)==null?void 0:u.filter(f=>f.type==="file"))||[];return c.jsx("div",{className:`group/msg flex ${t.role==="user"?"justify-end":"justify-start"}`,children:c.jsxs("div",{className:`rounded-lg px-3 py-2 max-w-[90%] overflow-hidden min-w-0 ${t.role==="user"?"bg-primary text-primary-foreground":"bg-muted/60 border border-border/40"}`,children:[t.role==="user"?c.jsxs("div",{children:[o.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1 mb-1.5",children:o.map((f,d)=>Xh(f.mediaType)?c.jsx("img",{src:f.url,alt:f.filename||"image",className:"h-20 max-w-[160px] rounded object-cover"},d):c.jsxs("div",{className:"flex items-center gap-1.5 rounded bg-primary-foreground/20 px-2 py-1",children:[c.jsx(Ks,{className:"h-3 w-3 shrink-0"}),c.jsx("span",{className:"text-xs truncate max-w-[120px]",children:f.filename||"file"})]},d))}),r&&r.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1 mb-1.5",children:r.map((f,d)=>c.jsx(Hh,{context:f,variant:"sent"},d))}),a&&c.jsx("div",{className:"whitespace-pre-wrap text-sm break-words",children:a}),i&&i!=="global"&&c.jsx("span",{className:"text-[10px] text-primary-foreground/60 mt-0.5 block text-right",children:i})]}):c.jsx(cz,{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(Fa,{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 cz({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(M0,{remarkPlugins:[KS],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(mz,{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(iz,{json:l,context:n,scope:r})]})}},children:e})})}const dz=[{value:"opus",label:"Opus"},{value:"sonnet",label:"Sonnet"},{value:"haiku",label:"Haiku"}];function fz({model:e,setModel:t}){return c.jsxs(qa,{value:e,onValueChange:n=>t(n),children:[c.jsx(Ki,{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(Wa,{})}),c.jsx(Yi,{children:dz.map(n=>c.jsx(Tr,{value:n.value,className:"text-xs",children:n.label},n.value))})]})}const tc={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"},pz=1e5;function hz({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(tc).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:tc[r]})]},r))})]}),e==="global"&&n>pz&&c.jsxs("div",{className:"text-[10px] text-amber-500 flex items-center gap-1",children:[c.jsx(Jc,{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 mz({text:e}){const[t,n]=v.useState(!1),r=v.useCallback(async()=>{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)},[e]);return c.jsx("button",{onClick:r,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:t?"Copied!":"Copy"})}function gz({discoveryData:e}){const t=_d(),n=nx(),r=ze(N=>N.chatOpen),i=ze(N=>N.toggleChat),[s,a]=v.useState(()=>{try{const N=localStorage.getItem("dev-env.sidebar-open");return n?!1:N?N==="true":!0}catch{return!n}}),[o,l]=v.useState(()=>{try{const N=localStorage.getItem("dev-env.preview-open");return N?N==="true":!0}catch{return!0}}),[u,f]=v.useState("editor"),[d,h]=v.useState(!1),p=150,[m,w]=v.useState(!s),[S,y]=v.useState(!1);v.useEffect(()=>{try{localStorage.setItem("dev-env.sidebar-open",String(s))}catch{}},[s]),v.useEffect(()=>{try{localStorage.setItem("dev-env.preview-open",String(o))}catch{}},[o]);const _=v.useRef(n);v.useEffect(()=>{n&&!_.current&&s&&(y(!0),a(!1),setTimeout(()=>{w(!0),y(!1)},p)),!n&&_.current&&!s&&(y(!0),a(!0),setTimeout(()=>{w(!1),y(!1)},p)),_.current=n},[n,s]);const x=v.useCallback(()=>{if(t){h(N=>!N);return}y(!0),a(N=>!N),setTimeout(()=>{w(N=>!N),y(!1)},p)},[t]),P=v.useCallback(()=>l(N=>!N),[]),E=v.useRef(i),k=v.useRef(x),C=v.useRef(P);v.useEffect(()=>{E.current=i}),v.useEffect(()=>{k.current=x}),v.useEffect(()=>{C.current=P}),v.useEffect(()=>{const N=Z=>{(Z.metaKey||Z.ctrlKey)&&(Z.code==="KeyB"&&!Z.shiftKey&&(Z.preventDefault(),k.current()),Z.code==="KeyJ"&&Z.shiftKey&&(Z.preventDefault(),Z.stopPropagation(),E.current()),Z.code==="KeyP"&&Z.shiftKey&&(Z.preventDefault(),C.current()))};return window.addEventListener("keydown",N,!0),()=>window.removeEventListener("keydown",N,!0)},[]);const V=OI,Y=[{key:"editor",icon:Hc,label:"Editor"},{key:"preview",icon:qc,label:"Preview"},{key:"chat",icon:Wc,label:"Chat"}];return t?c.jsx(V,{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(wd,{open:d,onOpenChange:h,children:[c.jsx(Yg,{asChild:!0,children:c.jsx(Ie,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:c.jsx(Vc,{className:"h-4 w-4"})})}),c.jsx(Ka,{side:"left",className:"p-0 w-72",children:c.jsx(Ko,{discoveryData:e,onToggleSidebar:()=>h(!1),isCollapsed:!1})})]}),c.jsx("div",{className:"flex gap-0.5 flex-1 min-w-0",children:Y.map(({key:N,icon:Z,label:D})=>c.jsxs(Ie,{variant:u===N?"default":"ghost",size:"sm",className:"h-7 gap-1.5 text-xs flex-1",onClick:()=>f(N),children:[c.jsx(Z,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"hidden xs:inline",children:D})]},N))})]}),u!=="chat"&&c.jsx(cl,{previewOpen:o,onTogglePreview:P}),c.jsxs("div",{className:"flex-1 min-h-0",children:[u==="editor"&&c.jsx("div",{className:"h-full bg-surface-editor",children:c.jsx(Yo,{})}),u==="preview"&&c.jsx("div",{className:"h-full bg-surface-preview",children:c.jsx(Xo,{})}),u==="chat"&&c.jsx(ec,{})]})]})}):c.jsx(V,{children:c.jsxs("div",{className:"flex h-full w-full overflow-hidden",children:[c.jsx("div",{className:U("shrink-0 overflow-hidden border-r bg-sidebar","transition-[width] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)]",s?"w-64":"w-12"),children:c.jsx(Ko,{discoveryData:e,onToggleSidebar:x,isCollapsed:m,isAnimating:S})}),c.jsxs("div",{className:"flex-1 min-w-0 flex flex-col h-full",children:[c.jsx(cl,{previewOpen:o,onTogglePreview:P}),c.jsxs(yy,{direction:"horizontal",autoSaveId:"layout-main",className:"flex-1 min-h-0",children:[c.jsx(_s,{defaultSize:o?50:100,minSize:20,id:"editor",order:1,children:c.jsx("div",{className:"h-full bg-surface-editor",children:c.jsx(Yo,{})})}),o&&c.jsxs(c.Fragment,{children:[c.jsx(ll,{withHandle:!0}),c.jsx(_s,{defaultSize:50,minSize:20,id:"preview",order:2,children:c.jsx("div",{className:"h-full bg-surface-preview",children:c.jsx(Xo,{})})})]}),r&&c.jsxs(c.Fragment,{children:[c.jsx(ll,{withHandle:!0}),c.jsx(_s,{defaultSize:30,minSize:25,maxSize:50,id:"chat",order:3,children:c.jsx(ec,{})})]})]})]})]})})}function xz(){const[e,t]=v.useState(null),[n,r]=v.useState(!0),[i,s]=v.useState(null),a=v.useCallback(async()=>{r(!0),s(null);try{const o=await fetch("/api/discovery/all");if(!o.ok)throw new Error(`Discovery failed: ${o.statusText}`);const l=await o.json();if(!l.success)throw new Error(l.error||"Discovery failed");t(l.data)}catch(o){console.error("Discovery error:",o),s(o instanceof Error?o.message:"Failed to fetch discovered items"),t({plugins:[],documents:[],themes:[]})}finally{r(!1)}},[]);return v.useEffect(()=>{a()},[a]),{data:e,loading:n,error:i,refetch:a}}function yz(){const[e,t]=v.useState(!1),[n,r]=v.useState(null),[i,s]=v.useState(0);return{loadPlugins:v.useCallback(async()=>{t(!0),r(null);try{const o=await fetch("/api/discovery/load-plugins",{method:"POST"});if(!o.ok)throw new Error(`Failed to load plugins: ${o.statusText}`);const l=await o.json();if(!l.success)throw new Error(l.error||"Failed to load plugins");return s(l.data.loaded),!0}catch(o){return console.error("Plugin loading error:",o),r(o instanceof Error?o.message:"Failed to load plugins"),!1}finally{t(!1)}},[]),loading:e,error:n,loadedCount:i}}function bz(){const{data:e,loading:t,error:n}=xz(),{loadPlugins:r}=yz(),i=Pt(s=>s.applyPluginsWithValidation);return v.useEffect(()=>{e&&e.plugins.length>0&&r().then(s=>{if(s){console.log("Plugins loaded successfully");const a=Pt.getState().selectedPlugins;a.size>0&&(console.log("Auto-applying persisted plugin selections:",Array.from(a)),i())}})},[e,r,i]),t?c.jsx("div",{className:"flex items-center justify-center h-screen",children:c.jsxs("div",{className:"text-center",children:[c.jsx("div",{className:"text-lg font-medium",children:"Discovering project resources..."}),c.jsx("div",{className:"text-sm text-muted-foreground mt-2",children:"Searching for documents, themes, and plugins"})]})}):n?c.jsx("div",{className:"flex items-center justify-center h-screen",children:c.jsxs("div",{className:"text-center",children:[c.jsx("div",{className:"text-lg font-medium text-destructive",children:"Discovery failed"}),c.jsx("div",{className:"text-sm text-muted-foreground mt-2",children:n}),c.jsx("div",{className:"text-xs text-muted-foreground mt-4",children:"The playground will work with limited functionality."})]})}):c.jsx(Qm,{children:c.jsx(eg,{children:c.jsx(tg,{children:c.jsx(ng,{children:c.jsx(rg,{children:c.jsx($g,{children:c.jsx(jd,{children:c.jsx("section",{className:"flex h-screen w-full flex-col",children:c.jsx("div",{className:"grow overflow-hidden",children:c.jsx(gz,{discoveryData:e})})})})})})})})})})}const Iz=Object.freeze(Object.defineProperty({__proto__:null,HomePage:bz},Symbol.toStringTag,{value:"Module"}));export{jr as B,qt as D,Iz as H,jy as P,Cr as S,ca as T,Dx as a,vd as b,Zt as c,Sn as d,_n as e,Sy as u};
|
|
99
|
-
//# sourceMappingURL=HomePage-
|
|
99
|
+
//# sourceMappingURL=HomePage-5f3HNqyO.js.map
|