@json-to-office/jto 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -1
- package/dist/client/assets/{HomePage-DMpdYyZ0.js → HomePage-mtUb6jxc.js} +4 -4
- package/dist/client/assets/{HomePage-DMpdYyZ0.js.map → HomePage-mtUb6jxc.js.map} +1 -1
- package/dist/client/assets/{JsonEditorPage-Ct7wb9iA.js → JsonEditorPage-DjLAUBv5.js} +3 -3
- package/dist/client/assets/{JsonEditorPage-Ct7wb9iA.js.map → JsonEditorPage-DjLAUBv5.js.map} +1 -1
- package/dist/client/assets/{MonacoPluginProvider-B2fWYflh.js → MonacoPluginProvider-D_GUFwWQ.js} +5 -5
- package/dist/client/assets/{MonacoPluginProvider-B2fWYflh.js.map → MonacoPluginProvider-D_GUFwWQ.js.map} +1 -1
- package/dist/client/assets/{_virtual_jto-plugin-type-libs-BlMraosv.js → _virtual_jto-plugin-type-libs-9elxvZT2.js} +11 -2
- package/dist/client/assets/{_virtual_jto-plugin-type-libs-BlMraosv.js.map → _virtual_jto-plugin-type-libs-9elxvZT2.js.map} +1 -1
- package/dist/client/assets/{_virtual_jto-sandbox-runtime-CNoAasd3.js → _virtual_jto-sandbox-runtime-Dqq17bow.js} +2 -2
- package/dist/client/assets/_virtual_jto-sandbox-runtime-Dqq17bow.js.map +1 -0
- package/dist/client/assets/{editor-DFnlAOyt.js → editor-ZbEHVEFs.js} +2 -2
- package/dist/client/assets/{editor-DFnlAOyt.js.map → editor-ZbEHVEFs.js.map} +1 -1
- package/dist/client/assets/{editor-monaco-json-B_1-Wxq5.js → editor-monaco-json-FaaVfftD.js} +2 -2
- package/dist/client/assets/{editor-monaco-json-B_1-Wxq5.js.map → editor-monaco-json-FaaVfftD.js.map} +1 -1
- package/dist/client/assets/{editor-refs-store-DHeIvmr6.js → editor-refs-store-DAEAPqEk.js} +2 -2
- package/dist/client/assets/{editor-refs-store-DHeIvmr6.js.map → editor-refs-store-DAEAPqEk.js.map} +1 -1
- package/dist/client/assets/index-DRbATnbJ.js +5 -0
- package/dist/client/assets/index-DRbATnbJ.js.map +1 -0
- package/dist/client/assets/{preview-CugO7y1j.js → preview-CM2ywF-8.js} +2 -2
- package/dist/client/assets/{preview-CugO7y1j.js.map → preview-CM2ywF-8.js.map} +1 -1
- package/dist/client/assets/{useQualityAnalysis-DH2idzAY.js → useQualityAnalysis-ClgkaIc2.js} +2 -2
- package/dist/client/assets/{useQualityAnalysis-DH2idzAY.js.map → useQualityAnalysis-ClgkaIc2.js.map} +1 -1
- package/dist/client/index.html +1 -1
- package/package.json +5 -5
- package/dist/client/assets/_virtual_jto-sandbox-runtime-CNoAasd3.js.map +0 -1
- package/dist/client/assets/index-CeZaIyj_.js +0 -5
- package/dist/client/assets/index-CeZaIyj_.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 xg=Object.defineProperty;var yg=(e,t,n)=>t in e?xg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Rr=(e,t,n)=>yg(e,typeof t!="symbol"?t+"":t,n);import{r as x,j as c,c as je,R as dd,g as wa}from"./react-vendor-BmQ2Ko_D.js";import{u as vn,s as fd,p as bg,a as ke,T as ka,v as vg,i as wg,b as Do,c as Xs,d as an,g as kg,e as Jt,B as Sg,f as yr,h as pd,j as jg,k as _g,S as Ng,O as Eg,l as Cg,M as Tg,D as Ig,m as Ag}from"./MonacoPluginProvider-B2fWYflh.js";import{A as zg,F as at,c as W,u as Cr,S as cn,a as ui,T as Ri,C as Og,E as Pg,b as Dg,d as Rg,e as Ye,f as Xe,g as Qe,h as hd,_ as md,i as $i,j as $g,k as Mg,l as Fg,m as $r,s as Qs,W as gd,n as Gi}from"./index-CeZaIyj_.js";import{b as xd,c as Sa,d as yd,e as Cs,f as Ts,D as Is,O as As,g as Lg,V as Bg,G as Vg,h as bd,I as Zg,i as Ug,j as vd,k as Jg,l as wd,m as Hg,n as Wg,L as kd,S as Sd,o as jd,p as _d,q as Nd,r as Tr,s as qg,t as Gg,u as Kg,v as Ed,w as Cd,x as Td,y as Id,z as Ad,B as zd,E as Od,F as Pd,H as Dd,J as Yg,K as Xg,M as Qg,N as Rd,Q as $d,U as Md,W as Fd,X as Ld,Y as Bd,Z as Vd,_ as Zd,$ as Ud,a0 as Jd,a1 as ex,a2 as Hd,a3 as tx,a4 as nx,a5 as Wd,a6 as rx,a7 as ix,a8 as sx,a9 as ox,aa as qd,ab as Gd,ac as Kd}from"./radix-ui-BzbaiLpZ.js";import{X as wn,C as Ni,a as un,b as ax,d as Ei,G as Yd,F as lx,e as Ir,f as Xd,P as cx,g as ux,h as Qd,i as ef,E as ja,B as ns,H as dx,T as Ro,L as $o,j as fx,k as px,S as tf,I as hx,l as mx,m as Mo,n as gx,o as xx,p as yx,q as bx,r as vx,s as wx,t as kx,u as Sx,v as zs,w as jx,M as _x,x as Dt,y as nf,z as Nx,A as Ex,D as Cx,J as Tx,K as rf,N as Ix,O as Ax,Q as zx,R as Ox,U as Px,V as Dx,W as sf,Y as Rx,Z as Fo,_ as _a,$ as of,a0 as $x,a1 as af,a2 as Gr,a3 as Mx,a4 as Fx,a5 as Lx,a6 as wl,a7 as Lo}from"./ui-vendor-BsAtAN16.js";import{B as Ee,u as lf,d as kl}from"./editor-refs-store-DHeIvmr6.js";import{u as Na,a as Bx,d as Vx,p as Zx,b as Ux,e as Jx}from"./state-vendor-Cq67_JbF.js";import{b as Hx}from"./query-vendor--rhYD8mC.js";let Mi=null,Mr=null;const Wx=1e4;function qx(e,t){return t.aborted?Promise.reject(Sl(t)):new Promise((n,r)=>{const i=()=>r(Sl(t));t.addEventListener("abort",i,{once:!0}),e.then(n,r).finally(()=>{t.removeEventListener("abort",i)})})}function Sl(e){return e.reason??new DOMException("Aborted","AbortError")}async function Gx(e){return Mi||(Mr||(Mr=(async()=>{const t=await fetch(`${zg}/discovery/themes/builtin`,{signal:AbortSignal.timeout(Wx)});if(!t.ok)throw new Error(`Built-in themes unavailable (${t.status})`);const n=await t.json();if(!n.success||!n.data)throw new Error(n.error??"Built-in themes unavailable");return Mi=n.data,Mi})().finally(()=>{Mr=null})),e?qx(Mr,e):Mr)}class hn extends Error{constructor(n,r,i){super(n);Rr(this,"pluginName");Rr(this,"path");this.name="PluginExpansionError",this.pluginName=r,this.path=i}}const Kx=20,Yx=1e4;function di(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function jl(e,t){const n=new Set;if(t.size===0)return n;const r=i=>{if(Array.isArray(i)){i.forEach(r);return}di(i)&&(typeof i.name=="string"&&t.has(i.name)&&n.add(i.name),Array.isArray(i.children)&&i.children.forEach(r))};return di(e)&&Array.isArray(e.children)&&e.children.forEach(r),n}const Xx=/^https?:\/\/\S+/i;function rs(e,t=new Set){if(typeof e=="string")Xx.test(e)&&t.add(e);else if(Array.isArray(e))for(const n of e)rs(n,t);else if(di(e))for(const n of Object.values(e))rs(n,t);return t}function Qx(e,t){if(!e.startsWith("/")||t.size===0)return{path:e,insidePlugin:!1};const n=e.split("/");for(let r=n.length;r>1;r--){const i=n.slice(0,r).join("/"),s=t.get(i);if(!s)continue;if(s.synthetic)return{path:s.authored,insidePlugin:!0};const o=n.slice(r).join("/");return{path:o?`${s.authored}/${o}`:s.authored,insidePlugin:!1}}return{path:e,insidePlugin:!1}}async function ey(e,t){const{plugins:n,theme:r,render:i,signal:s}=t,o=t.maxDepth??Kx,a=t.maxNodes??Yx,l=[],u=new Map,d=rs(e);let f=0;function h(k){if(s!=null&&s.aborted)throw new hn("Expansion was cancelled",void 0,k)}async function p(k,S,y,j,m){if(S>o)throw new hn(`Maximum component nesting depth exceeded (${o}). Check for circular component references.`,void 0,y);const A=[],C=(v,w,O)=>{const B=`${j}/${A.length}`;return(O||B!==w)&&u.set(B,{authored:w,synthetic:O}),A.push(v),B};for(let v=0;v<k.length;v++){h(y);const w=k[v],O=m??`${y}/${v}`,B=m!==void 0;if(!di(w)||typeof w.name!="string"){C(w,O,B);continue}const N=n.get(w.name);if(!N){if(Array.isArray(w.children)){const D=`${j}/${A.length}`,J=await p(w.children,S+1,`${O}/children`,`${D}/children`,B?m:void 0);C({...w,children:J},O,B)}else C(w,O,B);continue}if(w.enabled===!1)continue;if(w.props===void 0||w.props===null)throw new hn(`Custom component '${w.name}' must have a 'props' property. Use format: { name: '${w.name}', props: {...} }`,w.name,O);const R=typeof w.version=="string"?w.version:void 0;if(R!==void 0&&!N.versions.includes(R))throw new hn(`Component "${w.name}" does not have version "${R}". Available versions: ${N.versions.join(", ")}`,w.name,O);const T=Array.isArray(w.children)?await p(w.children,S+1,`${O}/children`,`${O}/children`,O):void 0,F=R?`${w.name}@${R}`:w.name;let z;try{z=await i({name:w.name,version:R,props:w.props,theme:r,children:T},s)}catch(D){throw s!=null&&s.aborted?D:new hn(`Error processing custom component '${w.name}': ${D instanceof Error?D.message:String(D)}`,w.name,O)}for(const D of z.warnings??[])l.push({component:F,message:D.message,severity:"warning",...D.context?{context:D.context}:{}});if(!Array.isArray(z.components))throw new hn(`Custom component '${w.name}' must render an array of components.`,w.name,O);for(const D of rs(z.components))d.has(D)||l.push({component:F,message:`Plugin output references a remote source the document did not: ${D}`,severity:"warning",context:{code:"PLUGIN_REMOTE_SOURCE",url:D,path:O}});if(f+=z.components.length,f>a)throw new hn(`Plugin expansion produced more than ${a} components; stopping at '${w.name}'.`,w.name,O);const M=await p(z.components,S+1,O,j,O);for(const D of M)C(D,O,!0)}return A}if(!di(e)||!Array.isArray(e.children))return{document:e,warnings:l,pathMap:u};const g=await p(e.children,0,"/children","/children",void 0);return{document:{...e,children:g},warnings:l,pathMap:u}}function mt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ty(e,t){if(!mt(t))return e;const n=mt(e.fonts)?e.fonts:{},r={...n};if(mt(t.fonts))for(const[o,a]of Object.entries(t.fonts)){const l=n[o],u=mt(l)?l:{};r[o]=mt(a)?{...u,...a}:a}const i=mt(e.styles)?e.styles:{},s={...i};if(mt(t.styles))for(const[o,a]of Object.entries(t.styles)){const l=i[o],u=mt(l)?l:{};s[o]=mt(a)?{...u,...a}:a}return{...e,colors:{...mt(e.colors)?e.colors:{},...mt(t.colors)?t.colors:{}},fonts:r,...Object.keys(s).length>0?{styles:s}:{}}}const _l={docx:"minimal",pptx:"default"};function ny(e,t){const{format:n,customThemes:r,builtinThemes:i}=t,s=mt(e)&&mt(e.props)?e.props:{},o=s.theme;if(n==="pptx"&&mt(o))return{theme:o};const a=typeof o=="string"&&o.length>0?o:_l[n];let l=r[a];if(l===void 0&&n==="docx"){const f=a.toLowerCase(),h=Object.keys(r).find(p=>p.toLowerCase()===f);h&&(l=r[h])}l===void 0&&(l=i[a]);let u;if(l===void 0){const f=_l[n],h=[...Object.keys(i),...Object.keys(r)].sort();u={message:`Theme "${a}" not found; falling back to "${f}". Available themes: ${h.join(", ")}.`,context:{code:"theme_not_found",requested:a,available:h}},l=i[f]}l===void 0&&(l=Object.values(i)[0]??{});const d=n==="docx"&&mt(l)&&s.themeOverrides?ty(l,s.themeOverrides):l;return u?{theme:d,warning:u}:{theme:d}}const eo=e=>({path:e,insidePlugin:!1});function ry(e){if(!e.enabled)return"is turned off — enable it in the plugin header or the sidebar";if(e.status==="compiling"||e.status==="idle")return"is still compiling — try again in a moment";const t=e.diagnostics.filter(n=>n.severity==="error");return t.length>0?`has ${t.length} error${t.length===1?"":"s"} — open ${e.docName} to fix ${t.length===1?"it":"them"}`:`failed to load — open ${e.docName}`}async function Bo(e,t={}){var y;const n=vn.getState(),r=fd(n),i=Object.values(n.records).filter(j=>j.metadata);if(i.length===0)return{text:e,warnings:[],expanded:!1,remap:eo};let s;try{s=JSON.parse(e)}catch{return{text:e,warnings:[],expanded:!1,remap:eo}}const o=new Set(r.map(j=>j.metadata.name)),a=new Map;for(const j of i){const m=j.metadata.name;!o.has(m)&&!a.has(m)&&a.set(m,j)}const l=jl(s,new Set(a.keys()));if(l.size>0){const[j]=l,m=a.get(j);throw new hn(`"${j}" is a browser plugin that ${ry(m)}.`,j)}if(jl(s,o).size===0)return{text:e,warnings:[],expanded:!1,remap:eo};const d=new Map,f=new Map;for(const j of r)d.set(j.metadata.name,{name:j.metadata.name,versions:j.metadata.versions.map(m=>m.version)}),f.set(j.metadata.name,j.docName);let h={};try{h=await Gx(t.signal)}catch(j){if((y=t.signal)!=null&&y.aborted)throw j}const p=ny(s,{format:at,customThemes:t.customThemes??{},builtinThemes:h}),g=await ey(s,{plugins:d,theme:p.theme,signal:t.signal,render:(j,m)=>bg.render(f.get(j.name),j,m)}),k=p.warning?[{component:"theme",message:p.warning.message,severity:"warning",context:p.warning.context},...g.warnings]:g.warnings,S=g.pathMap;return{text:JSON.stringify(g.document,null,2),warnings:k,expanded:!0,remap:j=>Qx(j,S)}}const ct=xd,iy=yd,Nl=Sa,cf=x.forwardRef(({className:e,...t},n)=>c.jsx(As,{ref:n,className:W("fixed inset-0 z-50 bg-black/50",e),...t}));cf.displayName=As.displayName;const lt=x.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(iy,{children:[c.jsx(cf,{}),c.jsxs(Cs,{ref:r,className:W("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(Sa,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 cursor-pointer rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:pointer-events-none",children:[c.jsx(wn,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));lt.displayName=Cs.displayName;const qt=({className:e,...t})=>c.jsx("div",{className:W("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});qt.displayName="DialogHeader";const kn=({className:e,...t})=>c.jsx("div",{className:W("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});kn.displayName="DialogFooter";const Gt=x.forwardRef(({className:e,...t},n)=>c.jsx(Ts,{ref:n,className:W("text-lg leading-none font-semibold tracking-tight",e),...t}));Gt.displayName=Ts.displayName;const dn=x.forwardRef(({className:e,...t},n)=>c.jsx(Is,{ref:n,className:W("text-muted-foreground text-sm",e),...t}));dn.displayName=Is.displayName;const fi=Lg,uf=Vg,pi=Bg,br=x.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(bd,{ref:r,className:W("border-input ring-offset-background placeholder:text-muted-foreground focus:ring-ring flex min-h-9 w-full min-w-0 items-center justify-between gap-2 rounded-sm border bg-background px-3 py-2 text-sm shadow-xs focus:ring-1 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 [&>span]:min-w-0 [&>span]:whitespace-normal [&>span]:break-words text-left cursor-pointer",e),...n,children:[t,c.jsx(Zg,{asChild:!0,children:c.jsx(Ni,{className:"h-4 w-4 shrink-0 opacity-50"})})]}));br.displayName=bd.displayName;const df=x.forwardRef(({className:e,...t},n)=>c.jsx(Sd,{ref:n,className:W("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ax,{className:"h-4 w-4"})}));df.displayName=Sd.displayName;const ff=x.forwardRef(({className:e,...t},n)=>c.jsx(jd,{ref:n,className:W("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(Ni,{className:"h-4 w-4"})}));ff.displayName=jd.displayName;const vr=x.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>c.jsx(Ug,{children:c.jsxs(vd,{ref:i,className:W("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-lg border shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[c.jsx(df,{}),c.jsx(Jg,{className:W("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(ff,{})]})}));vr.displayName=vd.displayName;const Ea=x.forwardRef(({className:e,...t},n)=>c.jsx(kd,{ref:n,className:W("px-2 py-1.5 text-sm font-semibold",e),...t}));Ea.displayName=kd.displayName;const Mn=x.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(wd,{ref:r,className:W("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(Hg,{children:c.jsx(un,{className:"h-4 w-4"})})}),c.jsx(Wg,{children:t})]}));Mn.displayName=wd.displayName;const sy=x.forwardRef(({className:e,...t},n)=>c.jsx(_d,{ref:n,className:W("bg-muted -mx-1 my-1 h-px",e),...t}));sy.displayName=_d.displayName;const wr=x.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:W("border-input file:text-foreground placeholder:text-muted-foreground focus-visible:ring-ring flex h-9 w-full rounded-sm border bg-background px-3 py-1 text-sm shadow-xs transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:ring-1 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...n}));wr.displayName="Input";const oy=Ei("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),ni=x.forwardRef(({className:e,...t},n)=>c.jsx(Nd,{ref:n,className:W(oy(),e),...t}));ni.displayName=Nd.displayName;const ay=Ei("inline-flex items-center rounded-md border px-2.5 py-1 text-xs font-medium transition-colors focus:outline-none",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-destructive-foreground",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function tn({className:e,variant:t,...n}){return c.jsx("div",{className:W(ay({variant:t}),e),...n})}const ly=({open:e,onOpenChange:t})=>{const{documents:n,documentTypes:r,activeTab:i,createDocument:s,openDocument:o}=ke(Na(T=>({documents:T.documents,documentTypes:T.documentTypes,activeTab:T.activeTab,createDocument:T.createDocument,openDocument:T.openDocument}))),a=x.useContext(ka),{toast:l}=Cr(),u=x.useMemo(()=>n.filter(T=>r[T.name]!=="application/json+theme"),[n,r]),[d,f]=x.useState(""),[h,p]=x.useState(""),[g,k]=x.useState("playground"),[S,y]=x.useState(!1),[j,m]=x.useState(null),[A,C]=x.useState(null),[v,w]=x.useState(null),O=()=>{m(null),C(null),w(null)};x.useEffect(()=>{if(!e)return;m(null),C(null),w(null);const T=u.map(z=>z.name),F=T.includes(i)?i:T[0]??"";p(F),f(T.find(z=>z!==F)??"")},[e]);const B=async()=>{const T=u.find(z=>z.name===d),F=u.find(z=>z.name===h);if(!(!T||!F)){y(!0),m(null),C(null),w(null);try{const z=a?vg(a.getState().customThemes):{},[M,D]=await Promise.all([Bo(T.text,{customThemes:z}),Bo(F.text,{customThemes:z})]),J=await fetch(ui.diff,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldDefinition:M.text,newDefinition:D.text,options:{author:g||"playground"}})}),Z=await J.json();if(!J.ok||!Z.success){const X=Array.isArray(Z.errors)?`: ${Z.errors.slice(0,3).map(_=>_.message||String(_)).join("; ")}`:"";throw new Error((Z.error||`Diff failed (${J.status})`)+X)}C(Z.data.summary),w(Z.data.document)}catch(z){m(z instanceof Error?z.message:"Diff failed")}finally{y(!1)}}},N=()=>{if(!v)return;const T=new Set(n.map(M=>M.name));let F=`${h}-redline`,z=2;for(;T.has(F);)F=`${h}-redline-${z++}`;s(F,JSON.stringify(v,null,2)),o(F),l({title:`Redline created: ${F}`}),t(!1)},R=A?A.tracked.modified+A.tracked.inserted+A.tracked.deleted:0;return c.jsx(ct,{open:e,onOpenChange:t,children:c.jsxs(lt,{className:"sm:max-w-[560px]",children:[c.jsxs(qt,{children:[c.jsxs(Gt,{className:"flex items-center gap-2",children:[c.jsx(Yd,{className:"size-4"}),"Compare documents"]}),c.jsx(dn,{children:"Diff two versions into a redline with native Word tracked changes (accept/reject in Word)."})]}),c.jsxs("div",{className:"grid gap-4 py-2",children:[c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsxs("div",{className:"grid gap-1.5",children:[c.jsx(ni,{htmlFor:"diff-base",children:"Base (old)"}),c.jsxs(fi,{value:d,onValueChange:T=>{f(T),O()},children:[c.jsx(br,{id:"diff-base",children:c.jsx(pi,{placeholder:"Select document"})}),c.jsx(vr,{children:u.map(T=>c.jsx(Mn,{value:T.name,children:T.name},T.name))})]})]}),c.jsxs("div",{className:"grid gap-1.5",children:[c.jsx(ni,{htmlFor:"diff-revised",children:"Revised (new)"}),c.jsxs(fi,{value:h,onValueChange:T=>{p(T),O()},children:[c.jsx(br,{id:"diff-revised",children:c.jsx(pi,{placeholder:"Select document"})}),c.jsx(vr,{children:u.map(T=>c.jsx(Mn,{value:T.name,children:T.name},T.name))})]})]})]}),c.jsxs("div",{className:"grid gap-1.5",children:[c.jsx(ni,{htmlFor:"diff-author",children:"Revision author"}),c.jsx(wr,{id:"diff-author",value:g,onChange:T=>{k(T.target.value),O()},placeholder:"playground"})]}),j&&c.jsx("p",{className:"text-sm text-destructive",role:"alert",children:j}),A&&c.jsxs("div",{className:"rounded-md border p-3 text-sm grid gap-2",children:[c.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[c.jsxs(tn,{variant:"secondary",children:[A.tracked.inserted," inserted"]}),c.jsxs(tn,{variant:"secondary",children:[A.tracked.deleted," deleted"]}),c.jsxs(tn,{variant:"secondary",children:[A.tracked.modified," modified"]}),c.jsxs("span",{className:"text-muted-foreground text-xs",children:[A.unchangedBlocks," blocks unchanged"]})]}),R===0&&A.untracked.length===0&&c.jsx("p",{className:"text-muted-foreground",children:"The documents are identical."}),A.untracked.length>0&&c.jsxs("div",{className:"grid gap-1 max-h-32 overflow-y-auto",children:[c.jsxs("p",{className:"font-medium text-warning-bg-foreground",children:[A.untracked.length," change(s) not expressible as tracked changes:"]}),A.untracked.map((T,F)=>c.jsxs("p",{className:"text-xs text-muted-foreground",children:[T.path," [",T.component,"] ",T.detail]},F))]}),A.notes.map((T,F)=>c.jsxs("p",{className:"text-xs text-muted-foreground",children:["Note: ",T]},F))]})]}),c.jsx(kn,{children:A&&R+A.untracked.length>0?c.jsxs(Ee,{onClick:N,children:[c.jsx(lx,{className:"size-4 mr-1"}),"Open redline"]}):c.jsxs(Ee,{onClick:B,disabled:S||!d||!h||d===h,children:[S&&c.jsx(cn,{className:"size-4 mr-1"}),"Compare"]})})]})})};var Ci=e=>e.type==="checkbox",On=e=>e instanceof Date,gt=e=>e==null;const pf=e=>typeof e=="object";var nt=e=>!gt(e)&&!Array.isArray(e)&&pf(e)&&!On(e),hf=e=>nt(e)&&e.target?Ci(e.target)?e.target.checked:e.target.value:e,cy=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,mf=(e,t)=>e.has(cy(t)),uy=e=>{const t=e.constructor&&e.constructor.prototype;return nt(t)&&t.hasOwnProperty("isPrototypeOf")},Ca=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function wt(e){let t;const n=Array.isArray(e),r=typeof FileList<"u"?e instanceof FileList:!1;if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(Ca&&(e instanceof Blob||r))&&(n||nt(e)))if(t=n?[]:{},!n&&!uy(e))t=e;else for(const i in e)e.hasOwnProperty(i)&&(t[i]=wt(e[i]));else return e;return t}var Os=e=>Array.isArray(e)?e.filter(Boolean):[],tt=e=>e===void 0,ue=(e,t,n)=>{if(!t||!nt(e))return n;const r=Os(t.split(/[,[\].]+?/)).reduce((i,s)=>gt(i)?i:i[s],e);return tt(r)||r===e?tt(e[t])?n:e[t]:r},Rt=e=>typeof e=="boolean",Ta=e=>/^\w*$/.test(e),gf=e=>Os(e.replace(/["|']|\]/g,"").split(/\.|\[/)),Le=(e,t,n)=>{let r=-1;const i=Ta(t)?[t]:gf(t),s=i.length,o=s-1;for(;++r<s;){const a=i[r];let l=n;if(r!==o){const u=e[a];l=nt(u)||Array.isArray(u)?u:isNaN(+i[r+1])?{}:[]}if(a==="__proto__"||a==="constructor"||a==="prototype")return;e[a]=l,e=e[a]}return e};const is={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Ut={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},sn={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},xf=je.createContext(null),Ps=()=>je.useContext(xf),dy=e=>{const{children:t,...n}=e;return je.createElement(xf.Provider,{value:n},t)};var yf=(e,t,n,r=!0)=>{const i={defaultValues:t._defaultValues};for(const s in e)Object.defineProperty(i,s,{get:()=>{const o=s;return t._proxyFormState[o]!==Ut.all&&(t._proxyFormState[o]=!r||Ut.all),n&&(n[o]=!0),e[o]}});return i},kt=e=>nt(e)&&!Object.keys(e).length,bf=(e,t,n,r)=>{n(e);const{name:i,...s}=e;return kt(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(o=>t[o]===(!r||Ut.all))},ri=e=>Array.isArray(e)?e:[e],vf=(e,t,n)=>!e||!t||e===t||ri(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r)));function Ia(e){const t=je.useRef(e);t.current=e,je.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}function fy(e){const t=Ps(),{control:n=t.control,disabled:r,name:i,exact:s}=e||{},[o,a]=je.useState(n._formState),l=je.useRef(!0),u=je.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),d=je.useRef(i);return d.current=i,Ia({disabled:r,next:f=>l.current&&vf(d.current,f.name,s)&&bf(f,u.current,n._updateFormState)&&a({...n._formState,...f}),subject:n._subjects.state}),je.useEffect(()=>(l.current=!0,u.current.isValid&&n._updateValid(!0),()=>{l.current=!1}),[n]),je.useMemo(()=>yf(o,n,u.current,!1),[o,n])}var en=e=>typeof e=="string",wf=(e,t,n,r,i)=>en(e)?(r&&t.watch.add(e),ue(n,e,i)):Array.isArray(e)?e.map(s=>(r&&t.watch.add(s),ue(n,s))):(r&&(t.watchAll=!0),n);function py(e){const t=Ps(),{control:n=t.control,name:r,defaultValue:i,disabled:s,exact:o}=e||{},a=je.useRef(r);a.current=r,Ia({disabled:s,subject:n._subjects.values,next:d=>{vf(a.current,d.name,o)&&u(wt(wf(a.current,n._names,d.values||n._formValues,!1,i)))}});const[l,u]=je.useState(n._getWatch(r,i));return je.useEffect(()=>n._removeUnmounted()),l}function hy(e){const t=Ps(),{name:n,disabled:r,control:i=t.control,shouldUnregister:s}=e,o=mf(i._names.array,n),a=py({control:i,name:n,defaultValue:ue(i._formValues,n,ue(i._defaultValues,n,e.defaultValue)),exact:!0}),l=fy({control:i,name:n,exact:!0}),u=je.useRef(i.register(n,{...e.rules,value:a,...Rt(e.disabled)?{disabled:e.disabled}:{}})),d=je.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!ue(l.errors,n)},isDirty:{enumerable:!0,get:()=>!!ue(l.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!ue(l.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!ue(l.validatingFields,n)},error:{enumerable:!0,get:()=>ue(l.errors,n)}}),[l,n]),f=je.useMemo(()=>({name:n,value:a,...Rt(r)||l.disabled?{disabled:l.disabled||r}:{},onChange:h=>u.current.onChange({target:{value:hf(h),name:n},type:is.CHANGE}),onBlur:()=>u.current.onBlur({target:{value:ue(i._formValues,n),name:n},type:is.BLUR}),ref:h=>{const p=ue(i._fields,n);p&&h&&(p._f.ref={focus:()=>h.focus(),select:()=>h.select(),setCustomValidity:g=>h.setCustomValidity(g),reportValidity:()=>h.reportValidity()})}}),[n,i._formValues,r,l.disabled,a,i._fields]);return je.useEffect(()=>{const h=i._options.shouldUnregister||s,p=(g,k)=>{const S=ue(i._fields,g);S&&S._f&&(S._f.mount=k)};if(p(n,!0),h){const g=wt(ue(i._options.defaultValues,n));Le(i._defaultValues,n,g),tt(ue(i._formValues,n))&&Le(i._formValues,n,g)}return!o&&i.register(n),()=>{(o?h&&!i._state.action:h)?i.unregister(n):p(n,!1)}},[n,i,o,s]),je.useEffect(()=>{i._updateDisabledField({disabled:r,fields:i._fields,name:n})},[r,n,i]),je.useMemo(()=>({field:f,formState:l,fieldState:d}),[f,l,d])}const my=e=>e.render(hy(e));var gy=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},El=e=>({isOnSubmit:!e||e===Ut.onSubmit,isOnBlur:e===Ut.onBlur,isOnChange:e===Ut.onChange,isOnAll:e===Ut.all,isOnTouch:e===Ut.onTouched}),Cl=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const ii=(e,t,n,r)=>{for(const i of n||Object.keys(e)){const s=ue(e,i);if(s){const{_f:o,...a}=s;if(o){if(o.refs&&o.refs[0]&&t(o.refs[0],i)&&!r)return!0;if(o.ref&&t(o.ref,o.name)&&!r)return!0;if(ii(a,t))break}else if(nt(a)&&ii(a,t))break}}};var xy=(e,t,n)=>{const r=ri(ue(e,n));return Le(r,"root",t[n]),Le(e,n,r),e},Aa=e=>e.type==="file",Qt=e=>typeof e=="function",ss=e=>{if(!Ca)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Ki=e=>en(e),za=e=>e.type==="radio",os=e=>e instanceof RegExp;const Tl={value:!1,isValid:!1},Il={value:!0,isValid:!0};var kf=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&&!tt(e[0].attributes.value)?tt(e[0].value)||e[0].value===""?Il:{value:e[0].value,isValid:!0}:Il:Tl}return Tl};const Al={isValid:!1,value:null};var Sf=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,Al):Al;function zl(e,t,n="validate"){if(Ki(e)||Array.isArray(e)&&e.every(Ki)||Rt(e)&&!e)return{type:n,message:Ki(e)?e:"",ref:t}}var Jn=e=>nt(e)&&!os(e)?e:{value:e,message:""},Ol=async(e,t,n,r,i,s)=>{const{ref:o,refs:a,required:l,maxLength:u,minLength:d,min:f,max:h,pattern:p,validate:g,name:k,valueAsNumber:S,mount:y}=e._f,j=ue(n,k);if(!y||t.has(k))return{};const m=a?a[0]:o,A=T=>{i&&m.reportValidity&&(m.setCustomValidity(Rt(T)?"":T||""),m.reportValidity())},C={},v=za(o),w=Ci(o),O=v||w,B=(S||Aa(o))&&tt(o.value)&&tt(j)||ss(o)&&o.value===""||j===""||Array.isArray(j)&&!j.length,N=gy.bind(null,k,r,C),R=(T,F,z,M=sn.maxLength,D=sn.minLength)=>{const J=T?F:z;C[k]={type:T?M:D,message:J,ref:o,...N(T?M:D,J)}};if(s?!Array.isArray(j)||!j.length:l&&(!O&&(B||gt(j))||Rt(j)&&!j||w&&!kf(a).isValid||v&&!Sf(a).isValid)){const{value:T,message:F}=Ki(l)?{value:!!l,message:l}:Jn(l);if(T&&(C[k]={type:sn.required,message:F,ref:m,...N(sn.required,F)},!r))return A(F),C}if(!B&&(!gt(f)||!gt(h))){let T,F;const z=Jn(h),M=Jn(f);if(!gt(j)&&!isNaN(j)){const D=o.valueAsNumber||j&&+j;gt(z.value)||(T=D>z.value),gt(M.value)||(F=D<M.value)}else{const D=o.valueAsDate||new Date(j),J=_=>new Date(new Date().toDateString()+" "+_),Z=o.type=="time",X=o.type=="week";en(z.value)&&j&&(T=Z?J(j)>J(z.value):X?j>z.value:D>new Date(z.value)),en(M.value)&&j&&(F=Z?J(j)<J(M.value):X?j<M.value:D<new Date(M.value))}if((T||F)&&(R(!!T,z.message,M.message,sn.max,sn.min),!r))return A(C[k].message),C}if((u||d)&&!B&&(en(j)||s&&Array.isArray(j))){const T=Jn(u),F=Jn(d),z=!gt(T.value)&&j.length>+T.value,M=!gt(F.value)&&j.length<+F.value;if((z||M)&&(R(z,T.message,F.message),!r))return A(C[k].message),C}if(p&&!B&&en(j)){const{value:T,message:F}=Jn(p);if(os(T)&&!j.match(T)&&(C[k]={type:sn.pattern,message:F,ref:o,...N(sn.pattern,F)},!r))return A(F),C}if(g){if(Qt(g)){const T=await g(j,n),F=zl(T,m);if(F&&(C[k]={...F,...N(sn.validate,F.message)},!r))return A(F.message),C}else if(nt(g)){let T={};for(const F in g){if(!kt(T)&&!r)break;const z=zl(await g[F](j,n),m,F);z&&(T={...z,...N(F,z.message)},A(z.message),r&&(C[k]=T))}if(!kt(T)&&(C[k]={ref:m,...T},!r))return C}}return A(!0),C};function yy(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=tt(e)?r++:e[t[r++]];return e}function by(e){for(const t in e)if(e.hasOwnProperty(t)&&!tt(e[t]))return!1;return!0}function st(e,t){const n=Array.isArray(t)?t:Ta(t)?[t]:gf(t),r=n.length===1?e:yy(e,n),i=n.length-1,s=n[i];return r&&delete r[s],i!==0&&(nt(r)&&kt(r)||Array.isArray(r)&&by(r))&&st(e,n.slice(0,-1)),e}var to=()=>{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=[]}}},Vo=e=>gt(e)||!pf(e);function xn(e,t){if(Vo(e)||Vo(t))return e===t;if(On(e)&&On(t))return e.getTime()===t.getTime();const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n){const s=e[i];if(!r.includes(i))return!1;if(i!=="ref"){const o=t[i];if(On(s)&&On(o)||nt(s)&&nt(o)||Array.isArray(s)&&Array.isArray(o)?!xn(s,o):s!==o)return!1}}return!0}var jf=e=>e.type==="select-multiple",vy=e=>za(e)||Ci(e),no=e=>ss(e)&&e.isConnected,_f=e=>{for(const t in e)if(Qt(e[t]))return!0;return!1};function as(e,t={}){const n=Array.isArray(e);if(nt(e)||n)for(const r in e)Array.isArray(e[r])||nt(e[r])&&!_f(e[r])?(t[r]=Array.isArray(e[r])?[]:{},as(e[r],t[r])):gt(e[r])||(t[r]=!0);return t}function Nf(e,t,n){const r=Array.isArray(e);if(nt(e)||r)for(const i in e)Array.isArray(e[i])||nt(e[i])&&!_f(e[i])?tt(t)||Vo(n[i])?n[i]=Array.isArray(e[i])?as(e[i],[]):{...as(e[i])}:Nf(e[i],gt(t)?{}:t[i],n[i]):n[i]=!xn(e[i],t[i]);return n}var Fr=(e,t)=>Nf(e,t,as(t)),Ef=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>tt(e)?e:t?e===""?NaN:e&&+e:n&&en(e)?new Date(e):r?r(e):e;function ro(e){const t=e.ref;return Aa(t)?t.files:za(t)?Sf(e.refs).value:jf(t)?[...t.selectedOptions].map(({value:n})=>n):Ci(t)?kf(e.refs).value:Ef(tt(t.value)?e.ref.value:t.value,e)}var wy=(e,t,n,r)=>{const i={};for(const s of e){const o=ue(t,s);o&&Le(i,s,o._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},Lr=e=>tt(e)?e:os(e)?e.source:nt(e)?os(e.value)?e.value.source:e.value:e;const Pl="AsyncFunction";var ky=e=>!!e&&!!e.validate&&!!(Qt(e.validate)&&e.validate.constructor.name===Pl||nt(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Pl)),Sy=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Dl(e,t,n){const r=ue(e,n);if(r||Ta(n))return{error:r,name:n};const i=n.split(".");for(;i.length;){const s=i.join("."),o=ue(t,s),a=ue(e,s);if(o&&!Array.isArray(o)&&n!==s)return{name:n};if(a&&a.type)return{name:s,error:a};i.pop()}return{name:n}}var jy=(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,_y=(e,t)=>!Os(ue(e,t)).length&&st(e,t);const Ny={mode:Ut.onSubmit,reValidateMode:Ut.onChange,shouldFocusError:!0};function Ey(e={}){let t={...Ny,...e},n={submitCount:0,isDirty:!1,isLoading:Qt(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},i=nt(t.defaultValues)||nt(t.values)?wt(t.defaultValues||t.values)||{}:{},s=t.shouldUnregister?{}:wt(i),o={action:!1,mount:!1,watch:!1},a={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},l,u=0;const d={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={values:to(),array:to(),state:to()},h=El(t.mode),p=El(t.reValidateMode),g=t.criteriaMode===Ut.all,k=E=>P=>{clearTimeout(u),u=setTimeout(E,P)},S=async E=>{if(!t.disabled&&(d.isValid||E)){const P=t.resolver?kt((await O()).errors):await N(r,!0);P!==n.isValid&&f.state.next({isValid:P})}},y=(E,P)=>{!t.disabled&&(d.isValidating||d.validatingFields)&&((E||Array.from(a.mount)).forEach(V=>{V&&(P?Le(n.validatingFields,V,P):st(n.validatingFields,V))}),f.state.next({validatingFields:n.validatingFields,isValidating:!kt(n.validatingFields)}))},j=(E,P=[],V,se,ie=!0,ee=!0)=>{if(se&&V&&!t.disabled){if(o.action=!0,ee&&Array.isArray(ue(r,E))){const me=V(ue(r,E),se.argA,se.argB);ie&&Le(r,E,me)}if(ee&&Array.isArray(ue(n.errors,E))){const me=V(ue(n.errors,E),se.argA,se.argB);ie&&Le(n.errors,E,me),_y(n.errors,E)}if(d.touchedFields&&ee&&Array.isArray(ue(n.touchedFields,E))){const me=V(ue(n.touchedFields,E),se.argA,se.argB);ie&&Le(n.touchedFields,E,me)}d.dirtyFields&&(n.dirtyFields=Fr(i,s)),f.state.next({name:E,isDirty:T(E,P),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Le(s,E,P)},m=(E,P)=>{Le(n.errors,E,P),f.state.next({errors:n.errors})},A=E=>{n.errors=E,f.state.next({errors:n.errors,isValid:!1})},C=(E,P,V,se)=>{const ie=ue(r,E);if(ie){const ee=ue(s,E,tt(V)?ue(i,E):V);tt(ee)||se&&se.defaultChecked||P?Le(s,E,P?ee:ro(ie._f)):M(E,ee),o.mount&&S()}},v=(E,P,V,se,ie)=>{let ee=!1,me=!1;const we={name:E};if(!t.disabled){const U=!!(ue(r,E)&&ue(r,E)._f&&ue(r,E)._f.disabled);if(!V||se){d.isDirty&&(me=n.isDirty,n.isDirty=we.isDirty=T(),ee=me!==we.isDirty);const Y=U||xn(ue(i,E),P);me=!!(!U&&ue(n.dirtyFields,E)),Y||U?st(n.dirtyFields,E):Le(n.dirtyFields,E,!0),we.dirtyFields=n.dirtyFields,ee=ee||d.dirtyFields&&me!==!Y}if(V){const Y=ue(n.touchedFields,E);Y||(Le(n.touchedFields,E,V),we.touchedFields=n.touchedFields,ee=ee||d.touchedFields&&Y!==V)}ee&&ie&&f.state.next(we)}return ee?we:{}},w=(E,P,V,se)=>{const ie=ue(n.errors,E),ee=d.isValid&&Rt(P)&&n.isValid!==P;if(t.delayError&&V?(l=k(()=>m(E,V)),l(t.delayError)):(clearTimeout(u),l=null,V?Le(n.errors,E,V):st(n.errors,E)),(V?!xn(ie,V):ie)||!kt(se)||ee){const me={...se,...ee&&Rt(P)?{isValid:P}:{},errors:n.errors,name:E};n={...n,...me},f.state.next(me)}},O=async E=>{y(E,!0);const P=await t.resolver(s,t.context,wy(E||a.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return y(E),P},B=async E=>{const{errors:P}=await O(E);if(E)for(const V of E){const se=ue(P,V);se?Le(n.errors,V,se):st(n.errors,V)}else n.errors=P;return P},N=async(E,P,V={valid:!0})=>{for(const se in E){const ie=E[se];if(ie){const{_f:ee,...me}=ie;if(ee){const we=a.array.has(ee.name),U=ie._f&&ky(ie._f);U&&d.validatingFields&&y([se],!0);const Y=await Ol(ie,a.disabled,s,g,t.shouldUseNativeValidation&&!P,we);if(U&&d.validatingFields&&y([se]),Y[ee.name]&&(V.valid=!1,P))break;!P&&(ue(Y,ee.name)?we?xy(n.errors,Y,ee.name):Le(n.errors,ee.name,Y[ee.name]):st(n.errors,ee.name))}!kt(me)&&await N(me,P,V)}}return V.valid},R=()=>{for(const E of a.unMount){const P=ue(r,E);P&&(P._f.refs?P._f.refs.every(V=>!no(V)):!no(P._f.ref))&&Q(E)}a.unMount=new Set},T=(E,P)=>!t.disabled&&(E&&P&&Le(s,E,P),!xn(ye(),i)),F=(E,P,V)=>wf(E,a,{...o.mount?s:tt(P)?i:en(E)?{[E]:P}:P},V,P),z=E=>Os(ue(o.mount?s:i,E,t.shouldUnregister?ue(i,E,[]):[])),M=(E,P,V={})=>{const se=ue(r,E);let ie=P;if(se){const ee=se._f;ee&&(!ee.disabled&&Le(s,E,Ef(P,ee)),ie=ss(ee.ref)&>(P)?"":P,jf(ee.ref)?[...ee.ref.options].forEach(me=>me.selected=ie.includes(me.value)):ee.refs?Ci(ee.ref)?ee.refs.length>1?ee.refs.forEach(me=>(!me.defaultChecked||!me.disabled)&&(me.checked=Array.isArray(ie)?!!ie.find(we=>we===me.value):ie===me.value)):ee.refs[0]&&(ee.refs[0].checked=!!ie):ee.refs.forEach(me=>me.checked=me.value===ie):Aa(ee.ref)?ee.ref.value="":(ee.ref.value=ie,ee.ref.type||f.values.next({name:E,values:{...s}})))}(V.shouldDirty||V.shouldTouch)&&v(E,ie,V.shouldTouch,V.shouldDirty,!0),V.shouldValidate&&_(E)},D=(E,P,V)=>{for(const se in P){const ie=P[se],ee=`${E}.${se}`,me=ue(r,ee);(a.array.has(E)||nt(ie)||me&&!me._f)&&!On(ie)?D(ee,ie,V):M(ee,ie,V)}},J=(E,P,V={})=>{const se=ue(r,E),ie=a.array.has(E),ee=wt(P);Le(s,E,ee),ie?(f.array.next({name:E,values:{...s}}),(d.isDirty||d.dirtyFields)&&V.shouldDirty&&f.state.next({name:E,dirtyFields:Fr(i,s),isDirty:T(E,ee)})):se&&!se._f&&!gt(ee)?D(E,ee,V):M(E,ee,V),Cl(E,a)&&f.state.next({...n}),f.values.next({name:o.mount?E:void 0,values:{...s}})},Z=async E=>{o.mount=!0;const P=E.target;let V=P.name,se=!0;const ie=ue(r,V),ee=()=>P.type?ro(ie._f):hf(E),me=we=>{se=Number.isNaN(we)||On(we)&&isNaN(we.getTime())||xn(we,ue(s,V,we))};if(ie){let we,U;const Y=ee(),ge=E.type===is.BLUR||E.type===is.FOCUS_OUT,_e=!Sy(ie._f)&&!t.resolver&&!ue(n.errors,V)&&!ie._f.deps||jy(ge,ue(n.touchedFields,V),n.isSubmitted,p,h),L=Cl(V,a,ge);Le(s,V,Y),ge?(ie._f.onBlur&&ie._f.onBlur(E),l&&l(0)):ie._f.onChange&&ie._f.onChange(E);const $=v(V,Y,ge,!1),xe=!kt($)||L;if(!ge&&f.values.next({name:V,type:E.type,values:{...s}}),_e)return d.isValid&&(t.mode==="onBlur"&&ge?S():ge||S()),xe&&f.state.next({name:V,...L?{}:$});if(!ge&&L&&f.state.next({...n}),t.resolver){const{errors:de}=await O([V]);if(me(Y),se){const Me=Dl(n.errors,r,V),Je=Dl(de,r,Me.name||V);we=Je.error,V=Je.name,U=kt(de)}}else y([V],!0),we=(await Ol(ie,a.disabled,s,g,t.shouldUseNativeValidation))[V],y([V]),me(Y),se&&(we?U=!1:d.isValid&&(U=await N(r,!0)));se&&(ie._f.deps&&_(ie._f.deps),w(V,U,we,$))}},X=(E,P)=>{if(ue(n.errors,P)&&E.focus)return E.focus(),1},_=async(E,P={})=>{let V,se;const ie=ri(E);if(t.resolver){const ee=await B(tt(E)?E:ie);V=kt(ee),se=E?!ie.some(me=>ue(ee,me)):V}else E?(se=(await Promise.all(ie.map(async ee=>{const me=ue(r,ee);return await N(me&&me._f?{[ee]:me}:me)}))).every(Boolean),!(!se&&!n.isValid)&&S()):se=V=await N(r);return f.state.next({...!en(E)||d.isValid&&V!==n.isValid?{}:{name:E},...t.resolver||!E?{isValid:V}:{},errors:n.errors}),P.shouldFocus&&!se&&ii(r,X,E?ie:a.mount),se},ye=E=>{const P={...o.mount?s:i};return tt(E)?P:en(E)?ue(P,E):E.map(V=>ue(P,V))},ce=(E,P)=>({invalid:!!ue((P||n).errors,E),isDirty:!!ue((P||n).dirtyFields,E),error:ue((P||n).errors,E),isValidating:!!ue(n.validatingFields,E),isTouched:!!ue((P||n).touchedFields,E)}),b=E=>{E&&ri(E).forEach(P=>st(n.errors,P)),f.state.next({errors:E?n.errors:{}})},G=(E,P,V)=>{const se=(ue(r,E,{_f:{}})._f||{}).ref,ie=ue(n.errors,E)||{},{ref:ee,message:me,type:we,...U}=ie;Le(n.errors,E,{...U,...P,ref:se}),f.state.next({name:E,errors:n.errors,isValid:!1}),V&&V.shouldFocus&&se&&se.focus&&se.focus()},ne=(E,P)=>Qt(E)?f.values.subscribe({next:V=>E(F(void 0,P),V)}):F(E,P,!0),Q=(E,P={})=>{for(const V of E?ri(E):a.mount)a.mount.delete(V),a.array.delete(V),P.keepValue||(st(r,V),st(s,V)),!P.keepError&&st(n.errors,V),!P.keepDirty&&st(n.dirtyFields,V),!P.keepTouched&&st(n.touchedFields,V),!P.keepIsValidating&&st(n.validatingFields,V),!t.shouldUnregister&&!P.keepDefaultValue&&st(i,V);f.values.next({values:{...s}}),f.state.next({...n,...P.keepDirty?{isDirty:T()}:{}}),!P.keepIsValid&&S()},oe=({disabled:E,name:P,field:V,fields:se})=>{(Rt(E)&&o.mount||E||a.disabled.has(P))&&(E?a.disabled.add(P):a.disabled.delete(P),v(P,ro(V?V._f:ue(se,P)._f),!1,!1,!0))},I=(E,P={})=>{let V=ue(r,E);const se=Rt(P.disabled)||Rt(t.disabled);return Le(r,E,{...V||{},_f:{...V&&V._f?V._f:{ref:{name:E}},name:E,mount:!0,...P}}),a.mount.add(E),V?oe({field:V,disabled:Rt(P.disabled)?P.disabled:t.disabled,name:E}):C(E,!0,P.value),{...se?{disabled:P.disabled||t.disabled}:{},...t.progressive?{required:!!P.required,min:Lr(P.min),max:Lr(P.max),minLength:Lr(P.minLength),maxLength:Lr(P.maxLength),pattern:Lr(P.pattern)}:{},name:E,onChange:Z,onBlur:Z,ref:ie=>{if(ie){I(E,P),V=ue(r,E);const ee=tt(ie.value)&&ie.querySelectorAll&&ie.querySelectorAll("input,select,textarea")[0]||ie,me=vy(ee),we=V._f.refs||[];if(me?we.find(U=>U===ee):ee===V._f.ref)return;Le(r,E,{_f:{...V._f,...me?{refs:[...we.filter(no),ee,...Array.isArray(ue(i,E))?[{}]:[]],ref:{type:ee.type,name:E}}:{ref:ee}}}),C(E,!1,void 0,ee)}else V=ue(r,E,{}),V._f&&(V._f.mount=!1),(t.shouldUnregister||P.shouldUnregister)&&!(mf(a.array,E)&&o.action)&&a.unMount.add(E)}}},re=()=>t.shouldFocusError&&ii(r,X,a.mount),ae=E=>{Rt(E)&&(f.state.next({disabled:E}),ii(r,(P,V)=>{const se=ue(r,V);se&&(P.disabled=se._f.disabled||E,Array.isArray(se._f.refs)&&se._f.refs.forEach(ie=>{ie.disabled=se._f.disabled||E}))},0,!1))},H=(E,P)=>async V=>{let se;V&&(V.preventDefault&&V.preventDefault(),V.persist&&V.persist());let ie=wt(s);if(a.disabled.size)for(const ee of a.disabled)Le(ie,ee,void 0);if(f.state.next({isSubmitting:!0}),t.resolver){const{errors:ee,values:me}=await O();n.errors=ee,ie=me}else await N(r);if(st(n.errors,"root"),kt(n.errors)){f.state.next({errors:{}});try{await E(ie,V)}catch(ee){se=ee}}else P&&await P({...n.errors},V),re(),setTimeout(re);if(f.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:kt(n.errors)&&!se,submitCount:n.submitCount+1,errors:n.errors}),se)throw se},K=(E,P={})=>{ue(r,E)&&(tt(P.defaultValue)?J(E,wt(ue(i,E))):(J(E,P.defaultValue),Le(i,E,wt(P.defaultValue))),P.keepTouched||st(n.touchedFields,E),P.keepDirty||(st(n.dirtyFields,E),n.isDirty=P.defaultValue?T(E,wt(ue(i,E))):T()),P.keepError||(st(n.errors,E),d.isValid&&S()),f.state.next({...n}))},pe=(E,P={})=>{const V=E?wt(E):i,se=wt(V),ie=kt(E),ee=ie?i:se;if(P.keepDefaultValues||(i=V),!P.keepValues){if(P.keepDirtyValues){const me=new Set([...a.mount,...Object.keys(Fr(i,s))]);for(const we of Array.from(me))ue(n.dirtyFields,we)?Le(ee,we,ue(s,we)):J(we,ue(ee,we))}else{if(Ca&&tt(E))for(const me of a.mount){const we=ue(r,me);if(we&&we._f){const U=Array.isArray(we._f.refs)?we._f.refs[0]:we._f.ref;if(ss(U)){const Y=U.closest("form");if(Y){Y.reset();break}}}}r={}}s=t.shouldUnregister?P.keepDefaultValues?wt(i):{}:wt(ee),f.array.next({values:{...ee}}),f.values.next({values:{...ee}})}a={mount:P.keepDirtyValues?a.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!d.isValid||!!P.keepIsValid||!!P.keepDirtyValues,o.watch=!!t.shouldUnregister,f.state.next({submitCount:P.keepSubmitCount?n.submitCount:0,isDirty:ie?!1:P.keepDirty?n.isDirty:!!(P.keepDefaultValues&&!xn(E,i)),isSubmitted:P.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:ie?{}:P.keepDirtyValues?P.keepDefaultValues&&s?Fr(i,s):n.dirtyFields:P.keepDefaultValues&&E?Fr(i,E):P.keepDirty?n.dirtyFields:{},touchedFields:P.keepTouched?n.touchedFields:{},errors:P.keepErrors?n.errors:{},isSubmitSuccessful:P.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},fe=(E,P)=>pe(Qt(E)?E(s):E,P);return{control:{register:I,unregister:Q,getFieldState:ce,handleSubmit:H,setError:G,_executeSchema:O,_getWatch:F,_getDirty:T,_updateValid:S,_removeUnmounted:R,_updateFieldArray:j,_updateDisabledField:oe,_getFieldArray:z,_reset:pe,_resetDefaultValues:()=>Qt(t.defaultValues)&&t.defaultValues().then(E=>{fe(E,t.resetOptions),f.state.next({isLoading:!1})}),_updateFormState:E=>{n={...n,...E}},_disableForm:ae,_subjects:f,_proxyFormState:d,_setErrors:A,get _fields(){return r},get _formValues(){return s},get _state(){return o},set _state(E){o=E},get _defaultValues(){return i},get _names(){return a},set _names(E){a=E},get _formState(){return n},set _formState(E){n=E},get _options(){return t},set _options(E){t={...t,...E}}},trigger:_,register:I,handleSubmit:H,watch:ne,setValue:J,getValues:ye,reset:fe,resetField:K,clearErrors:b,unregister:Q,setError:G,setFocus:(E,P={})=>{const V=ue(r,E),se=V&&V._f;if(se){const ie=se.refs?se.refs[0]:se.ref;ie.focus&&(ie.focus(),P.shouldSelect&&Qt(ie.select)&&ie.select())}},getFieldState:ce}}function Cy(e={}){const t=je.useRef(void 0),n=je.useRef(void 0),[r,i]=je.useState({isDirty:!1,isValidating:!1,isLoading:Qt(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Qt(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...Ey(e),formState:r});const s=t.current.control;return s._options=e,Ia({subject:s._subjects.state,next:o=>{bf(o,s._proxyFormState,s._updateFormState,!0)&&i({...s._formState})}}),je.useEffect(()=>s._disableForm(e.disabled),[s,e.disabled]),je.useEffect(()=>{if(s._proxyFormState.isDirty){const o=s._getDirty();o!==r.isDirty&&s._subjects.state.next({isDirty:o})}},[s,r.isDirty]),je.useEffect(()=>{e.values&&!xn(e.values,n.current)?(s._reset(e.values,s._options.resetOptions),n.current=e.values,i(o=>({...o}))):s._resetDefaultValues()},[e.values,s]),je.useEffect(()=>{e.errors&&s._setErrors(e.errors)},[e.errors,s]),je.useEffect(()=>{s._state.mount||(s._updateValid(),s._state.mount=!0),s._state.watch&&(s._state.watch=!1,s._subjects.state.next({...s._formState})),s._removeUnmounted()}),je.useEffect(()=>{e.shouldUnregister&&s._subjects.values.next({values:s._getWatch()})},[e.shouldUnregister,s]),t.current.formState=yf(r,s),t.current}function Ty(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 Iy=dy,Cf=x.createContext({}),Rl=({...e})=>c.jsx(Cf.Provider,{value:{name:e.name},children:c.jsx(my,{...e})}),Ds=()=>{const e=x.useContext(Cf),t=x.useContext(Tf),{getFieldState:n,formState:r}=Ps(),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}},Tf=x.createContext({}),Zo=x.forwardRef(({className:e,...t},n)=>{const r=x.useId();return c.jsx(Tf.Provider,{value:{id:r},children:c.jsx("div",{ref:n,className:W("space-y-2",e),...t})})});Zo.displayName="FormItem";const Uo=x.forwardRef(({className:e,...t},n)=>{const{error:r,formItemId:i}=Ds();return c.jsx(ni,{ref:n,className:W(r&&"text-destructive",e),htmlFor:i,...t})});Uo.displayName="FormLabel";const Jo=x.forwardRef(({...e},t)=>{const{error:n,formItemId:r,formDescriptionId:i,formMessageId:s}=Ds();return c.jsx(Tr,{ref:t,id:r,"aria-describedby":n?`${i} ${s}`:`${i}`,"aria-invalid":!!n,...e})});Jo.displayName="FormControl";const If=x.forwardRef(({className:e,...t},n)=>{const{formDescriptionId:r}=Ds();return c.jsx("p",{ref:n,id:r,className:W("text-muted-foreground text-[0.8rem]",e),...t})});If.displayName="FormDescription";const Ho=x.forwardRef(({className:e,children:t,...n},r)=>{const{error:i,formMessageId:s}=Ds(),o=i?String(i==null?void 0:i.message):t;return o?c.jsx("p",{ref:r,id:s,className:W("text-destructive text-[0.8rem] font-medium",e),...n,children:o}):null});Ho.displayName="FormMessage";function Oa(){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 Af=()=>({chatOpen:!1,scope:"global",model:"opus",contextAttachments:[],threads:{},activeThreadId:{}}),Ay=(e=Af())=>Bx()(Vx(Zx((t,n)=>({...e,toggleChat:()=>t(r=>({chatOpen:!r.chatOpen})),openChat:()=>t({chatOpen:!0}),closeChat:()=>t({chatOpen:!1}),addContext:r=>t(i=>({contextAttachments:[...i.contextAttachments,r]})),removeContext:r=>t(i=>({contextAttachments:i.contextAttachments.filter((s,o)=>o!==r)})),clearContext:()=>t({contextAttachments:[]}),setScope:r=>t({scope:r}),setModel:r=>t({model:r}),createThread:r=>{const i=crypto.randomUUID(),s=Date.now(),o={id:i,documentName:r,title:Oa(),messages:[],createdAt:s,updatedAt:s};return t(a=>({threads:{...a.threads,[i]:o},activeThreadId:{...a.activeThreadId,[r]:i}})),i},deleteThread:r=>{const i=n(),s=i.threads[r];if(!s)return;const o=Object.fromEntries(Object.entries(i.threads).filter(([u])=>u!==r)),a=s.documentName,l={...i.activeThreadId};if(l[a]===r){const u=Object.values(o).filter(d=>d.documentName===a);u.length>0?(u.sort((d,f)=>f.updatedAt-d.updatedAt),l[a]=u[0].id):delete l[a]}t({threads:o,activeThreadId:l})},switchThread:r=>{const s=n().threads[r];s&&t(o=>({activeThreadId:{...o.activeThreadId,[s.documentName]:r}}))},updateThreadMessages:(r,i)=>{t(s=>{const o=s.threads[r];return o?{threads:{...s.threads,[r]:{...o,messages:i,updatedAt:Date.now()}}}:s})},updateThreadTitle:(r,i)=>{t(s=>{const o=s.threads[r];return o?{threads:{...s.threads,[r]:{...o,title:i}}}:s})},deleteThreadsForDocument:r=>{t(i=>{const s={...i.threads},o={...i.activeThreadId};for(const[a,l]of Object.entries(s))l.documentName===r&&delete s[a];return delete o[r],{threads:s,activeThreadId:o}})},renameThreadsForDocument:(r,i)=>{t(s=>{const o={...s.threads},a={...s.activeThreadId};for(const[l,u]of Object.entries(o))u.documentName===r&&(o[l]={...u,documentName:i});return r in a&&(a[i]=a[r],delete a[r]),{threads:o,activeThreadId:a}})},clearChat:()=>{t(r=>({contextAttachments:[]}))}}),{name:"chat-storage",version:1,storage:Ux(()=>wg),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}}))),zf=x.createContext(void 0),zy=({children:e})=>{const t=x.useRef(null);return t.current||(t.current=Ay(Af())),c.jsx(zf.Provider,{value:t.current,children:e})},De=e=>{const t=x.useContext(zf);if(!t)throw new Error("useChatStore must be used within ChatStoreProvider");return Jx(t,e)};function Of(e){return`${e.split(/[^a-zA-Z0-9]+/).filter(Boolean).map((n,r)=>r===0?n.charAt(0).toLowerCase()+n.slice(1):n.charAt(0).toUpperCase()+n.slice(1)).join("")||"custom"}Component`}function Oy(e){const t=Of(e);return`import { Type } from '@sinclair/typebox';
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-ZbEHVEFs.js","assets/react-vendor-BmQ2Ko_D.js","assets/editor-monaco-json-FaaVfftD.js","assets/index-DRbATnbJ.js","assets/query-vendor--rhYD8mC.js","assets/radix-ui-BzbaiLpZ.js","assets/ui-vendor-BsAtAN16.js","assets/monaco-editor-DJsdM0WK.js","assets/state-vendor-Cq67_JbF.js","assets/index-Bj6ZAKUc.css","assets/editor-refs-store-DAEAPqEk.js","assets/MonacoPluginProvider-D_GUFwWQ.js","assets/useQualityAnalysis-ClgkaIc2.js","assets/preview-CM2ywF-8.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var xg=Object.defineProperty;var yg=(e,t,n)=>t in e?xg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Rr=(e,t,n)=>yg(e,typeof t!="symbol"?t+"":t,n);import{r as x,j as c,c as je,R as dd,g as wa}from"./react-vendor-BmQ2Ko_D.js";import{u as vn,s as fd,p as bg,a as ke,T as ka,v as vg,i as wg,b as Do,c as Xs,d as an,g as kg,e as Jt,B as Sg,f as yr,h as pd,j as jg,k as _g,S as Ng,O as Eg,l as Cg,M as Tg,D as Ig,m as Ag}from"./MonacoPluginProvider-D_GUFwWQ.js";import{A as zg,F as at,c as W,u as Cr,S as cn,a as ui,T as Ri,C as Og,E as Pg,b as Dg,d as Rg,e as Ye,f as Xe,g as Qe,h as hd,_ as md,i as $i,j as $g,k as Mg,l as Fg,m as $r,s as Qs,W as gd,n as Gi}from"./index-DRbATnbJ.js";import{b as xd,c as Sa,d as yd,e as Cs,f as Ts,D as Is,O as As,g as Lg,V as Bg,G as Vg,h as bd,I as Zg,i as Ug,j as vd,k as Jg,l as wd,m as Hg,n as Wg,L as kd,S as Sd,o as jd,p as _d,q as Nd,r as Tr,s as qg,t as Gg,u as Kg,v as Ed,w as Cd,x as Td,y as Id,z as Ad,B as zd,E as Od,F as Pd,H as Dd,J as Yg,K as Xg,M as Qg,N as Rd,Q as $d,U as Md,W as Fd,X as Ld,Y as Bd,Z as Vd,_ as Zd,$ as Ud,a0 as Jd,a1 as ex,a2 as Hd,a3 as tx,a4 as nx,a5 as Wd,a6 as rx,a7 as ix,a8 as sx,a9 as ox,aa as qd,ab as Gd,ac as Kd}from"./radix-ui-BzbaiLpZ.js";import{X as wn,C as Ni,a as un,b as ax,d as Ei,G as Yd,F as lx,e as Ir,f as Xd,P as cx,g as ux,h as Qd,i as ef,E as ja,B as ns,H as dx,T as Ro,L as $o,j as fx,k as px,S as tf,I as hx,l as mx,m as Mo,n as gx,o as xx,p as yx,q as bx,r as vx,s as wx,t as kx,u as Sx,v as zs,w as jx,M as _x,x as Dt,y as nf,z as Nx,A as Ex,D as Cx,J as Tx,K as rf,N as Ix,O as Ax,Q as zx,R as Ox,U as Px,V as Dx,W as sf,Y as Rx,Z as Fo,_ as _a,$ as of,a0 as $x,a1 as af,a2 as Gr,a3 as Mx,a4 as Fx,a5 as Lx,a6 as wl,a7 as Lo}from"./ui-vendor-BsAtAN16.js";import{B as Ee,u as lf,d as kl}from"./editor-refs-store-DAEAPqEk.js";import{u as Na,a as Bx,d as Vx,p as Zx,b as Ux,e as Jx}from"./state-vendor-Cq67_JbF.js";import{b as Hx}from"./query-vendor--rhYD8mC.js";let Mi=null,Mr=null;const Wx=1e4;function qx(e,t){return t.aborted?Promise.reject(Sl(t)):new Promise((n,r)=>{const i=()=>r(Sl(t));t.addEventListener("abort",i,{once:!0}),e.then(n,r).finally(()=>{t.removeEventListener("abort",i)})})}function Sl(e){return e.reason??new DOMException("Aborted","AbortError")}async function Gx(e){return Mi||(Mr||(Mr=(async()=>{const t=await fetch(`${zg}/discovery/themes/builtin`,{signal:AbortSignal.timeout(Wx)});if(!t.ok)throw new Error(`Built-in themes unavailable (${t.status})`);const n=await t.json();if(!n.success||!n.data)throw new Error(n.error??"Built-in themes unavailable");return Mi=n.data,Mi})().finally(()=>{Mr=null})),e?qx(Mr,e):Mr)}class hn extends Error{constructor(n,r,i){super(n);Rr(this,"pluginName");Rr(this,"path");this.name="PluginExpansionError",this.pluginName=r,this.path=i}}const Kx=20,Yx=1e4;function di(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function jl(e,t){const n=new Set;if(t.size===0)return n;const r=i=>{if(Array.isArray(i)){i.forEach(r);return}di(i)&&(typeof i.name=="string"&&t.has(i.name)&&n.add(i.name),Array.isArray(i.children)&&i.children.forEach(r))};return di(e)&&Array.isArray(e.children)&&e.children.forEach(r),n}const Xx=/^https?:\/\/\S+/i;function rs(e,t=new Set){if(typeof e=="string")Xx.test(e)&&t.add(e);else if(Array.isArray(e))for(const n of e)rs(n,t);else if(di(e))for(const n of Object.values(e))rs(n,t);return t}function Qx(e,t){if(!e.startsWith("/")||t.size===0)return{path:e,insidePlugin:!1};const n=e.split("/");for(let r=n.length;r>1;r--){const i=n.slice(0,r).join("/"),s=t.get(i);if(!s)continue;if(s.synthetic)return{path:s.authored,insidePlugin:!0};const o=n.slice(r).join("/");return{path:o?`${s.authored}/${o}`:s.authored,insidePlugin:!1}}return{path:e,insidePlugin:!1}}async function ey(e,t){const{plugins:n,theme:r,render:i,signal:s}=t,o=t.maxDepth??Kx,a=t.maxNodes??Yx,l=[],u=new Map,d=rs(e);let f=0;function h(k){if(s!=null&&s.aborted)throw new hn("Expansion was cancelled",void 0,k)}async function p(k,S,y,j,m){if(S>o)throw new hn(`Maximum component nesting depth exceeded (${o}). Check for circular component references.`,void 0,y);const A=[],C=(v,w,O)=>{const B=`${j}/${A.length}`;return(O||B!==w)&&u.set(B,{authored:w,synthetic:O}),A.push(v),B};for(let v=0;v<k.length;v++){h(y);const w=k[v],O=m??`${y}/${v}`,B=m!==void 0;if(!di(w)||typeof w.name!="string"){C(w,O,B);continue}const N=n.get(w.name);if(!N){if(Array.isArray(w.children)){const D=`${j}/${A.length}`,J=await p(w.children,S+1,`${O}/children`,`${D}/children`,B?m:void 0);C({...w,children:J},O,B)}else C(w,O,B);continue}if(w.enabled===!1)continue;if(w.props===void 0||w.props===null)throw new hn(`Custom component '${w.name}' must have a 'props' property. Use format: { name: '${w.name}', props: {...} }`,w.name,O);const R=typeof w.version=="string"?w.version:void 0;if(R!==void 0&&!N.versions.includes(R))throw new hn(`Component "${w.name}" does not have version "${R}". Available versions: ${N.versions.join(", ")}`,w.name,O);const T=Array.isArray(w.children)?await p(w.children,S+1,`${O}/children`,`${O}/children`,O):void 0,F=R?`${w.name}@${R}`:w.name;let z;try{z=await i({name:w.name,version:R,props:w.props,theme:r,children:T},s)}catch(D){throw s!=null&&s.aborted?D:new hn(`Error processing custom component '${w.name}': ${D instanceof Error?D.message:String(D)}`,w.name,O)}for(const D of z.warnings??[])l.push({component:F,message:D.message,severity:"warning",...D.context?{context:D.context}:{}});if(!Array.isArray(z.components))throw new hn(`Custom component '${w.name}' must render an array of components.`,w.name,O);for(const D of rs(z.components))d.has(D)||l.push({component:F,message:`Plugin output references a remote source the document did not: ${D}`,severity:"warning",context:{code:"PLUGIN_REMOTE_SOURCE",url:D,path:O}});if(f+=z.components.length,f>a)throw new hn(`Plugin expansion produced more than ${a} components; stopping at '${w.name}'.`,w.name,O);const M=await p(z.components,S+1,O,j,O);for(const D of M)C(D,O,!0)}return A}if(!di(e)||!Array.isArray(e.children))return{document:e,warnings:l,pathMap:u};const g=await p(e.children,0,"/children","/children",void 0);return{document:{...e,children:g},warnings:l,pathMap:u}}function mt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ty(e,t){if(!mt(t))return e;const n=mt(e.fonts)?e.fonts:{},r={...n};if(mt(t.fonts))for(const[o,a]of Object.entries(t.fonts)){const l=n[o],u=mt(l)?l:{};r[o]=mt(a)?{...u,...a}:a}const i=mt(e.styles)?e.styles:{},s={...i};if(mt(t.styles))for(const[o,a]of Object.entries(t.styles)){const l=i[o],u=mt(l)?l:{};s[o]=mt(a)?{...u,...a}:a}return{...e,colors:{...mt(e.colors)?e.colors:{},...mt(t.colors)?t.colors:{}},fonts:r,...Object.keys(s).length>0?{styles:s}:{}}}const _l={docx:"minimal",pptx:"default"};function ny(e,t){const{format:n,customThemes:r,builtinThemes:i}=t,s=mt(e)&&mt(e.props)?e.props:{},o=s.theme;if(n==="pptx"&&mt(o))return{theme:o};const a=typeof o=="string"&&o.length>0?o:_l[n];let l=r[a];if(l===void 0&&n==="docx"){const f=a.toLowerCase(),h=Object.keys(r).find(p=>p.toLowerCase()===f);h&&(l=r[h])}l===void 0&&(l=i[a]);let u;if(l===void 0){const f=_l[n],h=[...Object.keys(i),...Object.keys(r)].sort();u={message:`Theme "${a}" not found; falling back to "${f}". Available themes: ${h.join(", ")}.`,context:{code:"theme_not_found",requested:a,available:h}},l=i[f]}l===void 0&&(l=Object.values(i)[0]??{});const d=n==="docx"&&mt(l)&&s.themeOverrides?ty(l,s.themeOverrides):l;return u?{theme:d,warning:u}:{theme:d}}const eo=e=>({path:e,insidePlugin:!1});function ry(e){if(!e.enabled)return"is turned off — enable it in the plugin header or the sidebar";if(e.status==="compiling"||e.status==="idle")return"is still compiling — try again in a moment";const t=e.diagnostics.filter(n=>n.severity==="error");return t.length>0?`has ${t.length} error${t.length===1?"":"s"} — open ${e.docName} to fix ${t.length===1?"it":"them"}`:`failed to load — open ${e.docName}`}async function Bo(e,t={}){var y;const n=vn.getState(),r=fd(n),i=Object.values(n.records).filter(j=>j.metadata);if(i.length===0)return{text:e,warnings:[],expanded:!1,remap:eo};let s;try{s=JSON.parse(e)}catch{return{text:e,warnings:[],expanded:!1,remap:eo}}const o=new Set(r.map(j=>j.metadata.name)),a=new Map;for(const j of i){const m=j.metadata.name;!o.has(m)&&!a.has(m)&&a.set(m,j)}const l=jl(s,new Set(a.keys()));if(l.size>0){const[j]=l,m=a.get(j);throw new hn(`"${j}" is a browser plugin that ${ry(m)}.`,j)}if(jl(s,o).size===0)return{text:e,warnings:[],expanded:!1,remap:eo};const d=new Map,f=new Map;for(const j of r)d.set(j.metadata.name,{name:j.metadata.name,versions:j.metadata.versions.map(m=>m.version)}),f.set(j.metadata.name,j.docName);let h={};try{h=await Gx(t.signal)}catch(j){if((y=t.signal)!=null&&y.aborted)throw j}const p=ny(s,{format:at,customThemes:t.customThemes??{},builtinThemes:h}),g=await ey(s,{plugins:d,theme:p.theme,signal:t.signal,render:(j,m)=>bg.render(f.get(j.name),j,m)}),k=p.warning?[{component:"theme",message:p.warning.message,severity:"warning",context:p.warning.context},...g.warnings]:g.warnings,S=g.pathMap;return{text:JSON.stringify(g.document,null,2),warnings:k,expanded:!0,remap:j=>Qx(j,S)}}const ct=xd,iy=yd,Nl=Sa,cf=x.forwardRef(({className:e,...t},n)=>c.jsx(As,{ref:n,className:W("fixed inset-0 z-50 bg-black/50",e),...t}));cf.displayName=As.displayName;const lt=x.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(iy,{children:[c.jsx(cf,{}),c.jsxs(Cs,{ref:r,className:W("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(Sa,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 cursor-pointer rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:pointer-events-none",children:[c.jsx(wn,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));lt.displayName=Cs.displayName;const qt=({className:e,...t})=>c.jsx("div",{className:W("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});qt.displayName="DialogHeader";const kn=({className:e,...t})=>c.jsx("div",{className:W("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});kn.displayName="DialogFooter";const Gt=x.forwardRef(({className:e,...t},n)=>c.jsx(Ts,{ref:n,className:W("text-lg leading-none font-semibold tracking-tight",e),...t}));Gt.displayName=Ts.displayName;const dn=x.forwardRef(({className:e,...t},n)=>c.jsx(Is,{ref:n,className:W("text-muted-foreground text-sm",e),...t}));dn.displayName=Is.displayName;const fi=Lg,uf=Vg,pi=Bg,br=x.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(bd,{ref:r,className:W("border-input ring-offset-background placeholder:text-muted-foreground focus:ring-ring flex min-h-9 w-full min-w-0 items-center justify-between gap-2 rounded-sm border bg-background px-3 py-2 text-sm shadow-xs focus:ring-1 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 [&>span]:min-w-0 [&>span]:whitespace-normal [&>span]:break-words text-left cursor-pointer",e),...n,children:[t,c.jsx(Zg,{asChild:!0,children:c.jsx(Ni,{className:"h-4 w-4 shrink-0 opacity-50"})})]}));br.displayName=bd.displayName;const df=x.forwardRef(({className:e,...t},n)=>c.jsx(Sd,{ref:n,className:W("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ax,{className:"h-4 w-4"})}));df.displayName=Sd.displayName;const ff=x.forwardRef(({className:e,...t},n)=>c.jsx(jd,{ref:n,className:W("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(Ni,{className:"h-4 w-4"})}));ff.displayName=jd.displayName;const vr=x.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>c.jsx(Ug,{children:c.jsxs(vd,{ref:i,className:W("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-lg border shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[c.jsx(df,{}),c.jsx(Jg,{className:W("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(ff,{})]})}));vr.displayName=vd.displayName;const Ea=x.forwardRef(({className:e,...t},n)=>c.jsx(kd,{ref:n,className:W("px-2 py-1.5 text-sm font-semibold",e),...t}));Ea.displayName=kd.displayName;const Mn=x.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(wd,{ref:r,className:W("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(Hg,{children:c.jsx(un,{className:"h-4 w-4"})})}),c.jsx(Wg,{children:t})]}));Mn.displayName=wd.displayName;const sy=x.forwardRef(({className:e,...t},n)=>c.jsx(_d,{ref:n,className:W("bg-muted -mx-1 my-1 h-px",e),...t}));sy.displayName=_d.displayName;const wr=x.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:W("border-input file:text-foreground placeholder:text-muted-foreground focus-visible:ring-ring flex h-9 w-full rounded-sm border bg-background px-3 py-1 text-sm shadow-xs transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:ring-1 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...n}));wr.displayName="Input";const oy=Ei("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),ni=x.forwardRef(({className:e,...t},n)=>c.jsx(Nd,{ref:n,className:W(oy(),e),...t}));ni.displayName=Nd.displayName;const ay=Ei("inline-flex items-center rounded-md border px-2.5 py-1 text-xs font-medium transition-colors focus:outline-none",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-destructive-foreground",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function tn({className:e,variant:t,...n}){return c.jsx("div",{className:W(ay({variant:t}),e),...n})}const ly=({open:e,onOpenChange:t})=>{const{documents:n,documentTypes:r,activeTab:i,createDocument:s,openDocument:o}=ke(Na(T=>({documents:T.documents,documentTypes:T.documentTypes,activeTab:T.activeTab,createDocument:T.createDocument,openDocument:T.openDocument}))),a=x.useContext(ka),{toast:l}=Cr(),u=x.useMemo(()=>n.filter(T=>r[T.name]!=="application/json+theme"),[n,r]),[d,f]=x.useState(""),[h,p]=x.useState(""),[g,k]=x.useState("playground"),[S,y]=x.useState(!1),[j,m]=x.useState(null),[A,C]=x.useState(null),[v,w]=x.useState(null),O=()=>{m(null),C(null),w(null)};x.useEffect(()=>{if(!e)return;m(null),C(null),w(null);const T=u.map(z=>z.name),F=T.includes(i)?i:T[0]??"";p(F),f(T.find(z=>z!==F)??"")},[e]);const B=async()=>{const T=u.find(z=>z.name===d),F=u.find(z=>z.name===h);if(!(!T||!F)){y(!0),m(null),C(null),w(null);try{const z=a?vg(a.getState().customThemes):{},[M,D]=await Promise.all([Bo(T.text,{customThemes:z}),Bo(F.text,{customThemes:z})]),J=await fetch(ui.diff,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldDefinition:M.text,newDefinition:D.text,options:{author:g||"playground"}})}),Z=await J.json();if(!J.ok||!Z.success){const X=Array.isArray(Z.errors)?`: ${Z.errors.slice(0,3).map(_=>_.message||String(_)).join("; ")}`:"";throw new Error((Z.error||`Diff failed (${J.status})`)+X)}C(Z.data.summary),w(Z.data.document)}catch(z){m(z instanceof Error?z.message:"Diff failed")}finally{y(!1)}}},N=()=>{if(!v)return;const T=new Set(n.map(M=>M.name));let F=`${h}-redline`,z=2;for(;T.has(F);)F=`${h}-redline-${z++}`;s(F,JSON.stringify(v,null,2)),o(F),l({title:`Redline created: ${F}`}),t(!1)},R=A?A.tracked.modified+A.tracked.inserted+A.tracked.deleted:0;return c.jsx(ct,{open:e,onOpenChange:t,children:c.jsxs(lt,{className:"sm:max-w-[560px]",children:[c.jsxs(qt,{children:[c.jsxs(Gt,{className:"flex items-center gap-2",children:[c.jsx(Yd,{className:"size-4"}),"Compare documents"]}),c.jsx(dn,{children:"Diff two versions into a redline with native Word tracked changes (accept/reject in Word)."})]}),c.jsxs("div",{className:"grid gap-4 py-2",children:[c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsxs("div",{className:"grid gap-1.5",children:[c.jsx(ni,{htmlFor:"diff-base",children:"Base (old)"}),c.jsxs(fi,{value:d,onValueChange:T=>{f(T),O()},children:[c.jsx(br,{id:"diff-base",children:c.jsx(pi,{placeholder:"Select document"})}),c.jsx(vr,{children:u.map(T=>c.jsx(Mn,{value:T.name,children:T.name},T.name))})]})]}),c.jsxs("div",{className:"grid gap-1.5",children:[c.jsx(ni,{htmlFor:"diff-revised",children:"Revised (new)"}),c.jsxs(fi,{value:h,onValueChange:T=>{p(T),O()},children:[c.jsx(br,{id:"diff-revised",children:c.jsx(pi,{placeholder:"Select document"})}),c.jsx(vr,{children:u.map(T=>c.jsx(Mn,{value:T.name,children:T.name},T.name))})]})]})]}),c.jsxs("div",{className:"grid gap-1.5",children:[c.jsx(ni,{htmlFor:"diff-author",children:"Revision author"}),c.jsx(wr,{id:"diff-author",value:g,onChange:T=>{k(T.target.value),O()},placeholder:"playground"})]}),j&&c.jsx("p",{className:"text-sm text-destructive",role:"alert",children:j}),A&&c.jsxs("div",{className:"rounded-md border p-3 text-sm grid gap-2",children:[c.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[c.jsxs(tn,{variant:"secondary",children:[A.tracked.inserted," inserted"]}),c.jsxs(tn,{variant:"secondary",children:[A.tracked.deleted," deleted"]}),c.jsxs(tn,{variant:"secondary",children:[A.tracked.modified," modified"]}),c.jsxs("span",{className:"text-muted-foreground text-xs",children:[A.unchangedBlocks," blocks unchanged"]})]}),R===0&&A.untracked.length===0&&c.jsx("p",{className:"text-muted-foreground",children:"The documents are identical."}),A.untracked.length>0&&c.jsxs("div",{className:"grid gap-1 max-h-32 overflow-y-auto",children:[c.jsxs("p",{className:"font-medium text-warning-bg-foreground",children:[A.untracked.length," change(s) not expressible as tracked changes:"]}),A.untracked.map((T,F)=>c.jsxs("p",{className:"text-xs text-muted-foreground",children:[T.path," [",T.component,"] ",T.detail]},F))]}),A.notes.map((T,F)=>c.jsxs("p",{className:"text-xs text-muted-foreground",children:["Note: ",T]},F))]})]}),c.jsx(kn,{children:A&&R+A.untracked.length>0?c.jsxs(Ee,{onClick:N,children:[c.jsx(lx,{className:"size-4 mr-1"}),"Open redline"]}):c.jsxs(Ee,{onClick:B,disabled:S||!d||!h||d===h,children:[S&&c.jsx(cn,{className:"size-4 mr-1"}),"Compare"]})})]})})};var Ci=e=>e.type==="checkbox",On=e=>e instanceof Date,gt=e=>e==null;const pf=e=>typeof e=="object";var nt=e=>!gt(e)&&!Array.isArray(e)&&pf(e)&&!On(e),hf=e=>nt(e)&&e.target?Ci(e.target)?e.target.checked:e.target.value:e,cy=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,mf=(e,t)=>e.has(cy(t)),uy=e=>{const t=e.constructor&&e.constructor.prototype;return nt(t)&&t.hasOwnProperty("isPrototypeOf")},Ca=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function wt(e){let t;const n=Array.isArray(e),r=typeof FileList<"u"?e instanceof FileList:!1;if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(Ca&&(e instanceof Blob||r))&&(n||nt(e)))if(t=n?[]:{},!n&&!uy(e))t=e;else for(const i in e)e.hasOwnProperty(i)&&(t[i]=wt(e[i]));else return e;return t}var Os=e=>Array.isArray(e)?e.filter(Boolean):[],tt=e=>e===void 0,ue=(e,t,n)=>{if(!t||!nt(e))return n;const r=Os(t.split(/[,[\].]+?/)).reduce((i,s)=>gt(i)?i:i[s],e);return tt(r)||r===e?tt(e[t])?n:e[t]:r},Rt=e=>typeof e=="boolean",Ta=e=>/^\w*$/.test(e),gf=e=>Os(e.replace(/["|']|\]/g,"").split(/\.|\[/)),Le=(e,t,n)=>{let r=-1;const i=Ta(t)?[t]:gf(t),s=i.length,o=s-1;for(;++r<s;){const a=i[r];let l=n;if(r!==o){const u=e[a];l=nt(u)||Array.isArray(u)?u:isNaN(+i[r+1])?{}:[]}if(a==="__proto__"||a==="constructor"||a==="prototype")return;e[a]=l,e=e[a]}return e};const is={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Ut={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},sn={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},xf=je.createContext(null),Ps=()=>je.useContext(xf),dy=e=>{const{children:t,...n}=e;return je.createElement(xf.Provider,{value:n},t)};var yf=(e,t,n,r=!0)=>{const i={defaultValues:t._defaultValues};for(const s in e)Object.defineProperty(i,s,{get:()=>{const o=s;return t._proxyFormState[o]!==Ut.all&&(t._proxyFormState[o]=!r||Ut.all),n&&(n[o]=!0),e[o]}});return i},kt=e=>nt(e)&&!Object.keys(e).length,bf=(e,t,n,r)=>{n(e);const{name:i,...s}=e;return kt(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(o=>t[o]===(!r||Ut.all))},ri=e=>Array.isArray(e)?e:[e],vf=(e,t,n)=>!e||!t||e===t||ri(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r)));function Ia(e){const t=je.useRef(e);t.current=e,je.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}function fy(e){const t=Ps(),{control:n=t.control,disabled:r,name:i,exact:s}=e||{},[o,a]=je.useState(n._formState),l=je.useRef(!0),u=je.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),d=je.useRef(i);return d.current=i,Ia({disabled:r,next:f=>l.current&&vf(d.current,f.name,s)&&bf(f,u.current,n._updateFormState)&&a({...n._formState,...f}),subject:n._subjects.state}),je.useEffect(()=>(l.current=!0,u.current.isValid&&n._updateValid(!0),()=>{l.current=!1}),[n]),je.useMemo(()=>yf(o,n,u.current,!1),[o,n])}var en=e=>typeof e=="string",wf=(e,t,n,r,i)=>en(e)?(r&&t.watch.add(e),ue(n,e,i)):Array.isArray(e)?e.map(s=>(r&&t.watch.add(s),ue(n,s))):(r&&(t.watchAll=!0),n);function py(e){const t=Ps(),{control:n=t.control,name:r,defaultValue:i,disabled:s,exact:o}=e||{},a=je.useRef(r);a.current=r,Ia({disabled:s,subject:n._subjects.values,next:d=>{vf(a.current,d.name,o)&&u(wt(wf(a.current,n._names,d.values||n._formValues,!1,i)))}});const[l,u]=je.useState(n._getWatch(r,i));return je.useEffect(()=>n._removeUnmounted()),l}function hy(e){const t=Ps(),{name:n,disabled:r,control:i=t.control,shouldUnregister:s}=e,o=mf(i._names.array,n),a=py({control:i,name:n,defaultValue:ue(i._formValues,n,ue(i._defaultValues,n,e.defaultValue)),exact:!0}),l=fy({control:i,name:n,exact:!0}),u=je.useRef(i.register(n,{...e.rules,value:a,...Rt(e.disabled)?{disabled:e.disabled}:{}})),d=je.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!ue(l.errors,n)},isDirty:{enumerable:!0,get:()=>!!ue(l.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!ue(l.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!ue(l.validatingFields,n)},error:{enumerable:!0,get:()=>ue(l.errors,n)}}),[l,n]),f=je.useMemo(()=>({name:n,value:a,...Rt(r)||l.disabled?{disabled:l.disabled||r}:{},onChange:h=>u.current.onChange({target:{value:hf(h),name:n},type:is.CHANGE}),onBlur:()=>u.current.onBlur({target:{value:ue(i._formValues,n),name:n},type:is.BLUR}),ref:h=>{const p=ue(i._fields,n);p&&h&&(p._f.ref={focus:()=>h.focus(),select:()=>h.select(),setCustomValidity:g=>h.setCustomValidity(g),reportValidity:()=>h.reportValidity()})}}),[n,i._formValues,r,l.disabled,a,i._fields]);return je.useEffect(()=>{const h=i._options.shouldUnregister||s,p=(g,k)=>{const S=ue(i._fields,g);S&&S._f&&(S._f.mount=k)};if(p(n,!0),h){const g=wt(ue(i._options.defaultValues,n));Le(i._defaultValues,n,g),tt(ue(i._formValues,n))&&Le(i._formValues,n,g)}return!o&&i.register(n),()=>{(o?h&&!i._state.action:h)?i.unregister(n):p(n,!1)}},[n,i,o,s]),je.useEffect(()=>{i._updateDisabledField({disabled:r,fields:i._fields,name:n})},[r,n,i]),je.useMemo(()=>({field:f,formState:l,fieldState:d}),[f,l,d])}const my=e=>e.render(hy(e));var gy=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},El=e=>({isOnSubmit:!e||e===Ut.onSubmit,isOnBlur:e===Ut.onBlur,isOnChange:e===Ut.onChange,isOnAll:e===Ut.all,isOnTouch:e===Ut.onTouched}),Cl=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const ii=(e,t,n,r)=>{for(const i of n||Object.keys(e)){const s=ue(e,i);if(s){const{_f:o,...a}=s;if(o){if(o.refs&&o.refs[0]&&t(o.refs[0],i)&&!r)return!0;if(o.ref&&t(o.ref,o.name)&&!r)return!0;if(ii(a,t))break}else if(nt(a)&&ii(a,t))break}}};var xy=(e,t,n)=>{const r=ri(ue(e,n));return Le(r,"root",t[n]),Le(e,n,r),e},Aa=e=>e.type==="file",Qt=e=>typeof e=="function",ss=e=>{if(!Ca)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Ki=e=>en(e),za=e=>e.type==="radio",os=e=>e instanceof RegExp;const Tl={value:!1,isValid:!1},Il={value:!0,isValid:!0};var kf=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&&!tt(e[0].attributes.value)?tt(e[0].value)||e[0].value===""?Il:{value:e[0].value,isValid:!0}:Il:Tl}return Tl};const Al={isValid:!1,value:null};var Sf=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,Al):Al;function zl(e,t,n="validate"){if(Ki(e)||Array.isArray(e)&&e.every(Ki)||Rt(e)&&!e)return{type:n,message:Ki(e)?e:"",ref:t}}var Jn=e=>nt(e)&&!os(e)?e:{value:e,message:""},Ol=async(e,t,n,r,i,s)=>{const{ref:o,refs:a,required:l,maxLength:u,minLength:d,min:f,max:h,pattern:p,validate:g,name:k,valueAsNumber:S,mount:y}=e._f,j=ue(n,k);if(!y||t.has(k))return{};const m=a?a[0]:o,A=T=>{i&&m.reportValidity&&(m.setCustomValidity(Rt(T)?"":T||""),m.reportValidity())},C={},v=za(o),w=Ci(o),O=v||w,B=(S||Aa(o))&&tt(o.value)&&tt(j)||ss(o)&&o.value===""||j===""||Array.isArray(j)&&!j.length,N=gy.bind(null,k,r,C),R=(T,F,z,M=sn.maxLength,D=sn.minLength)=>{const J=T?F:z;C[k]={type:T?M:D,message:J,ref:o,...N(T?M:D,J)}};if(s?!Array.isArray(j)||!j.length:l&&(!O&&(B||gt(j))||Rt(j)&&!j||w&&!kf(a).isValid||v&&!Sf(a).isValid)){const{value:T,message:F}=Ki(l)?{value:!!l,message:l}:Jn(l);if(T&&(C[k]={type:sn.required,message:F,ref:m,...N(sn.required,F)},!r))return A(F),C}if(!B&&(!gt(f)||!gt(h))){let T,F;const z=Jn(h),M=Jn(f);if(!gt(j)&&!isNaN(j)){const D=o.valueAsNumber||j&&+j;gt(z.value)||(T=D>z.value),gt(M.value)||(F=D<M.value)}else{const D=o.valueAsDate||new Date(j),J=_=>new Date(new Date().toDateString()+" "+_),Z=o.type=="time",X=o.type=="week";en(z.value)&&j&&(T=Z?J(j)>J(z.value):X?j>z.value:D>new Date(z.value)),en(M.value)&&j&&(F=Z?J(j)<J(M.value):X?j<M.value:D<new Date(M.value))}if((T||F)&&(R(!!T,z.message,M.message,sn.max,sn.min),!r))return A(C[k].message),C}if((u||d)&&!B&&(en(j)||s&&Array.isArray(j))){const T=Jn(u),F=Jn(d),z=!gt(T.value)&&j.length>+T.value,M=!gt(F.value)&&j.length<+F.value;if((z||M)&&(R(z,T.message,F.message),!r))return A(C[k].message),C}if(p&&!B&&en(j)){const{value:T,message:F}=Jn(p);if(os(T)&&!j.match(T)&&(C[k]={type:sn.pattern,message:F,ref:o,...N(sn.pattern,F)},!r))return A(F),C}if(g){if(Qt(g)){const T=await g(j,n),F=zl(T,m);if(F&&(C[k]={...F,...N(sn.validate,F.message)},!r))return A(F.message),C}else if(nt(g)){let T={};for(const F in g){if(!kt(T)&&!r)break;const z=zl(await g[F](j,n),m,F);z&&(T={...z,...N(F,z.message)},A(z.message),r&&(C[k]=T))}if(!kt(T)&&(C[k]={ref:m,...T},!r))return C}}return A(!0),C};function yy(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=tt(e)?r++:e[t[r++]];return e}function by(e){for(const t in e)if(e.hasOwnProperty(t)&&!tt(e[t]))return!1;return!0}function st(e,t){const n=Array.isArray(t)?t:Ta(t)?[t]:gf(t),r=n.length===1?e:yy(e,n),i=n.length-1,s=n[i];return r&&delete r[s],i!==0&&(nt(r)&&kt(r)||Array.isArray(r)&&by(r))&&st(e,n.slice(0,-1)),e}var to=()=>{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=[]}}},Vo=e=>gt(e)||!pf(e);function xn(e,t){if(Vo(e)||Vo(t))return e===t;if(On(e)&&On(t))return e.getTime()===t.getTime();const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n){const s=e[i];if(!r.includes(i))return!1;if(i!=="ref"){const o=t[i];if(On(s)&&On(o)||nt(s)&&nt(o)||Array.isArray(s)&&Array.isArray(o)?!xn(s,o):s!==o)return!1}}return!0}var jf=e=>e.type==="select-multiple",vy=e=>za(e)||Ci(e),no=e=>ss(e)&&e.isConnected,_f=e=>{for(const t in e)if(Qt(e[t]))return!0;return!1};function as(e,t={}){const n=Array.isArray(e);if(nt(e)||n)for(const r in e)Array.isArray(e[r])||nt(e[r])&&!_f(e[r])?(t[r]=Array.isArray(e[r])?[]:{},as(e[r],t[r])):gt(e[r])||(t[r]=!0);return t}function Nf(e,t,n){const r=Array.isArray(e);if(nt(e)||r)for(const i in e)Array.isArray(e[i])||nt(e[i])&&!_f(e[i])?tt(t)||Vo(n[i])?n[i]=Array.isArray(e[i])?as(e[i],[]):{...as(e[i])}:Nf(e[i],gt(t)?{}:t[i],n[i]):n[i]=!xn(e[i],t[i]);return n}var Fr=(e,t)=>Nf(e,t,as(t)),Ef=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>tt(e)?e:t?e===""?NaN:e&&+e:n&&en(e)?new Date(e):r?r(e):e;function ro(e){const t=e.ref;return Aa(t)?t.files:za(t)?Sf(e.refs).value:jf(t)?[...t.selectedOptions].map(({value:n})=>n):Ci(t)?kf(e.refs).value:Ef(tt(t.value)?e.ref.value:t.value,e)}var wy=(e,t,n,r)=>{const i={};for(const s of e){const o=ue(t,s);o&&Le(i,s,o._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},Lr=e=>tt(e)?e:os(e)?e.source:nt(e)?os(e.value)?e.value.source:e.value:e;const Pl="AsyncFunction";var ky=e=>!!e&&!!e.validate&&!!(Qt(e.validate)&&e.validate.constructor.name===Pl||nt(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Pl)),Sy=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Dl(e,t,n){const r=ue(e,n);if(r||Ta(n))return{error:r,name:n};const i=n.split(".");for(;i.length;){const s=i.join("."),o=ue(t,s),a=ue(e,s);if(o&&!Array.isArray(o)&&n!==s)return{name:n};if(a&&a.type)return{name:s,error:a};i.pop()}return{name:n}}var jy=(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,_y=(e,t)=>!Os(ue(e,t)).length&&st(e,t);const Ny={mode:Ut.onSubmit,reValidateMode:Ut.onChange,shouldFocusError:!0};function Ey(e={}){let t={...Ny,...e},n={submitCount:0,isDirty:!1,isLoading:Qt(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},i=nt(t.defaultValues)||nt(t.values)?wt(t.defaultValues||t.values)||{}:{},s=t.shouldUnregister?{}:wt(i),o={action:!1,mount:!1,watch:!1},a={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},l,u=0;const d={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={values:to(),array:to(),state:to()},h=El(t.mode),p=El(t.reValidateMode),g=t.criteriaMode===Ut.all,k=E=>P=>{clearTimeout(u),u=setTimeout(E,P)},S=async E=>{if(!t.disabled&&(d.isValid||E)){const P=t.resolver?kt((await O()).errors):await N(r,!0);P!==n.isValid&&f.state.next({isValid:P})}},y=(E,P)=>{!t.disabled&&(d.isValidating||d.validatingFields)&&((E||Array.from(a.mount)).forEach(V=>{V&&(P?Le(n.validatingFields,V,P):st(n.validatingFields,V))}),f.state.next({validatingFields:n.validatingFields,isValidating:!kt(n.validatingFields)}))},j=(E,P=[],V,se,ie=!0,ee=!0)=>{if(se&&V&&!t.disabled){if(o.action=!0,ee&&Array.isArray(ue(r,E))){const me=V(ue(r,E),se.argA,se.argB);ie&&Le(r,E,me)}if(ee&&Array.isArray(ue(n.errors,E))){const me=V(ue(n.errors,E),se.argA,se.argB);ie&&Le(n.errors,E,me),_y(n.errors,E)}if(d.touchedFields&&ee&&Array.isArray(ue(n.touchedFields,E))){const me=V(ue(n.touchedFields,E),se.argA,se.argB);ie&&Le(n.touchedFields,E,me)}d.dirtyFields&&(n.dirtyFields=Fr(i,s)),f.state.next({name:E,isDirty:T(E,P),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Le(s,E,P)},m=(E,P)=>{Le(n.errors,E,P),f.state.next({errors:n.errors})},A=E=>{n.errors=E,f.state.next({errors:n.errors,isValid:!1})},C=(E,P,V,se)=>{const ie=ue(r,E);if(ie){const ee=ue(s,E,tt(V)?ue(i,E):V);tt(ee)||se&&se.defaultChecked||P?Le(s,E,P?ee:ro(ie._f)):M(E,ee),o.mount&&S()}},v=(E,P,V,se,ie)=>{let ee=!1,me=!1;const we={name:E};if(!t.disabled){const U=!!(ue(r,E)&&ue(r,E)._f&&ue(r,E)._f.disabled);if(!V||se){d.isDirty&&(me=n.isDirty,n.isDirty=we.isDirty=T(),ee=me!==we.isDirty);const Y=U||xn(ue(i,E),P);me=!!(!U&&ue(n.dirtyFields,E)),Y||U?st(n.dirtyFields,E):Le(n.dirtyFields,E,!0),we.dirtyFields=n.dirtyFields,ee=ee||d.dirtyFields&&me!==!Y}if(V){const Y=ue(n.touchedFields,E);Y||(Le(n.touchedFields,E,V),we.touchedFields=n.touchedFields,ee=ee||d.touchedFields&&Y!==V)}ee&&ie&&f.state.next(we)}return ee?we:{}},w=(E,P,V,se)=>{const ie=ue(n.errors,E),ee=d.isValid&&Rt(P)&&n.isValid!==P;if(t.delayError&&V?(l=k(()=>m(E,V)),l(t.delayError)):(clearTimeout(u),l=null,V?Le(n.errors,E,V):st(n.errors,E)),(V?!xn(ie,V):ie)||!kt(se)||ee){const me={...se,...ee&&Rt(P)?{isValid:P}:{},errors:n.errors,name:E};n={...n,...me},f.state.next(me)}},O=async E=>{y(E,!0);const P=await t.resolver(s,t.context,wy(E||a.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return y(E),P},B=async E=>{const{errors:P}=await O(E);if(E)for(const V of E){const se=ue(P,V);se?Le(n.errors,V,se):st(n.errors,V)}else n.errors=P;return P},N=async(E,P,V={valid:!0})=>{for(const se in E){const ie=E[se];if(ie){const{_f:ee,...me}=ie;if(ee){const we=a.array.has(ee.name),U=ie._f&&ky(ie._f);U&&d.validatingFields&&y([se],!0);const Y=await Ol(ie,a.disabled,s,g,t.shouldUseNativeValidation&&!P,we);if(U&&d.validatingFields&&y([se]),Y[ee.name]&&(V.valid=!1,P))break;!P&&(ue(Y,ee.name)?we?xy(n.errors,Y,ee.name):Le(n.errors,ee.name,Y[ee.name]):st(n.errors,ee.name))}!kt(me)&&await N(me,P,V)}}return V.valid},R=()=>{for(const E of a.unMount){const P=ue(r,E);P&&(P._f.refs?P._f.refs.every(V=>!no(V)):!no(P._f.ref))&&Q(E)}a.unMount=new Set},T=(E,P)=>!t.disabled&&(E&&P&&Le(s,E,P),!xn(ye(),i)),F=(E,P,V)=>wf(E,a,{...o.mount?s:tt(P)?i:en(E)?{[E]:P}:P},V,P),z=E=>Os(ue(o.mount?s:i,E,t.shouldUnregister?ue(i,E,[]):[])),M=(E,P,V={})=>{const se=ue(r,E);let ie=P;if(se){const ee=se._f;ee&&(!ee.disabled&&Le(s,E,Ef(P,ee)),ie=ss(ee.ref)&>(P)?"":P,jf(ee.ref)?[...ee.ref.options].forEach(me=>me.selected=ie.includes(me.value)):ee.refs?Ci(ee.ref)?ee.refs.length>1?ee.refs.forEach(me=>(!me.defaultChecked||!me.disabled)&&(me.checked=Array.isArray(ie)?!!ie.find(we=>we===me.value):ie===me.value)):ee.refs[0]&&(ee.refs[0].checked=!!ie):ee.refs.forEach(me=>me.checked=me.value===ie):Aa(ee.ref)?ee.ref.value="":(ee.ref.value=ie,ee.ref.type||f.values.next({name:E,values:{...s}})))}(V.shouldDirty||V.shouldTouch)&&v(E,ie,V.shouldTouch,V.shouldDirty,!0),V.shouldValidate&&_(E)},D=(E,P,V)=>{for(const se in P){const ie=P[se],ee=`${E}.${se}`,me=ue(r,ee);(a.array.has(E)||nt(ie)||me&&!me._f)&&!On(ie)?D(ee,ie,V):M(ee,ie,V)}},J=(E,P,V={})=>{const se=ue(r,E),ie=a.array.has(E),ee=wt(P);Le(s,E,ee),ie?(f.array.next({name:E,values:{...s}}),(d.isDirty||d.dirtyFields)&&V.shouldDirty&&f.state.next({name:E,dirtyFields:Fr(i,s),isDirty:T(E,ee)})):se&&!se._f&&!gt(ee)?D(E,ee,V):M(E,ee,V),Cl(E,a)&&f.state.next({...n}),f.values.next({name:o.mount?E:void 0,values:{...s}})},Z=async E=>{o.mount=!0;const P=E.target;let V=P.name,se=!0;const ie=ue(r,V),ee=()=>P.type?ro(ie._f):hf(E),me=we=>{se=Number.isNaN(we)||On(we)&&isNaN(we.getTime())||xn(we,ue(s,V,we))};if(ie){let we,U;const Y=ee(),ge=E.type===is.BLUR||E.type===is.FOCUS_OUT,_e=!Sy(ie._f)&&!t.resolver&&!ue(n.errors,V)&&!ie._f.deps||jy(ge,ue(n.touchedFields,V),n.isSubmitted,p,h),L=Cl(V,a,ge);Le(s,V,Y),ge?(ie._f.onBlur&&ie._f.onBlur(E),l&&l(0)):ie._f.onChange&&ie._f.onChange(E);const $=v(V,Y,ge,!1),xe=!kt($)||L;if(!ge&&f.values.next({name:V,type:E.type,values:{...s}}),_e)return d.isValid&&(t.mode==="onBlur"&&ge?S():ge||S()),xe&&f.state.next({name:V,...L?{}:$});if(!ge&&L&&f.state.next({...n}),t.resolver){const{errors:de}=await O([V]);if(me(Y),se){const Me=Dl(n.errors,r,V),Je=Dl(de,r,Me.name||V);we=Je.error,V=Je.name,U=kt(de)}}else y([V],!0),we=(await Ol(ie,a.disabled,s,g,t.shouldUseNativeValidation))[V],y([V]),me(Y),se&&(we?U=!1:d.isValid&&(U=await N(r,!0)));se&&(ie._f.deps&&_(ie._f.deps),w(V,U,we,$))}},X=(E,P)=>{if(ue(n.errors,P)&&E.focus)return E.focus(),1},_=async(E,P={})=>{let V,se;const ie=ri(E);if(t.resolver){const ee=await B(tt(E)?E:ie);V=kt(ee),se=E?!ie.some(me=>ue(ee,me)):V}else E?(se=(await Promise.all(ie.map(async ee=>{const me=ue(r,ee);return await N(me&&me._f?{[ee]:me}:me)}))).every(Boolean),!(!se&&!n.isValid)&&S()):se=V=await N(r);return f.state.next({...!en(E)||d.isValid&&V!==n.isValid?{}:{name:E},...t.resolver||!E?{isValid:V}:{},errors:n.errors}),P.shouldFocus&&!se&&ii(r,X,E?ie:a.mount),se},ye=E=>{const P={...o.mount?s:i};return tt(E)?P:en(E)?ue(P,E):E.map(V=>ue(P,V))},ce=(E,P)=>({invalid:!!ue((P||n).errors,E),isDirty:!!ue((P||n).dirtyFields,E),error:ue((P||n).errors,E),isValidating:!!ue(n.validatingFields,E),isTouched:!!ue((P||n).touchedFields,E)}),b=E=>{E&&ri(E).forEach(P=>st(n.errors,P)),f.state.next({errors:E?n.errors:{}})},G=(E,P,V)=>{const se=(ue(r,E,{_f:{}})._f||{}).ref,ie=ue(n.errors,E)||{},{ref:ee,message:me,type:we,...U}=ie;Le(n.errors,E,{...U,...P,ref:se}),f.state.next({name:E,errors:n.errors,isValid:!1}),V&&V.shouldFocus&&se&&se.focus&&se.focus()},ne=(E,P)=>Qt(E)?f.values.subscribe({next:V=>E(F(void 0,P),V)}):F(E,P,!0),Q=(E,P={})=>{for(const V of E?ri(E):a.mount)a.mount.delete(V),a.array.delete(V),P.keepValue||(st(r,V),st(s,V)),!P.keepError&&st(n.errors,V),!P.keepDirty&&st(n.dirtyFields,V),!P.keepTouched&&st(n.touchedFields,V),!P.keepIsValidating&&st(n.validatingFields,V),!t.shouldUnregister&&!P.keepDefaultValue&&st(i,V);f.values.next({values:{...s}}),f.state.next({...n,...P.keepDirty?{isDirty:T()}:{}}),!P.keepIsValid&&S()},oe=({disabled:E,name:P,field:V,fields:se})=>{(Rt(E)&&o.mount||E||a.disabled.has(P))&&(E?a.disabled.add(P):a.disabled.delete(P),v(P,ro(V?V._f:ue(se,P)._f),!1,!1,!0))},I=(E,P={})=>{let V=ue(r,E);const se=Rt(P.disabled)||Rt(t.disabled);return Le(r,E,{...V||{},_f:{...V&&V._f?V._f:{ref:{name:E}},name:E,mount:!0,...P}}),a.mount.add(E),V?oe({field:V,disabled:Rt(P.disabled)?P.disabled:t.disabled,name:E}):C(E,!0,P.value),{...se?{disabled:P.disabled||t.disabled}:{},...t.progressive?{required:!!P.required,min:Lr(P.min),max:Lr(P.max),minLength:Lr(P.minLength),maxLength:Lr(P.maxLength),pattern:Lr(P.pattern)}:{},name:E,onChange:Z,onBlur:Z,ref:ie=>{if(ie){I(E,P),V=ue(r,E);const ee=tt(ie.value)&&ie.querySelectorAll&&ie.querySelectorAll("input,select,textarea")[0]||ie,me=vy(ee),we=V._f.refs||[];if(me?we.find(U=>U===ee):ee===V._f.ref)return;Le(r,E,{_f:{...V._f,...me?{refs:[...we.filter(no),ee,...Array.isArray(ue(i,E))?[{}]:[]],ref:{type:ee.type,name:E}}:{ref:ee}}}),C(E,!1,void 0,ee)}else V=ue(r,E,{}),V._f&&(V._f.mount=!1),(t.shouldUnregister||P.shouldUnregister)&&!(mf(a.array,E)&&o.action)&&a.unMount.add(E)}}},re=()=>t.shouldFocusError&&ii(r,X,a.mount),ae=E=>{Rt(E)&&(f.state.next({disabled:E}),ii(r,(P,V)=>{const se=ue(r,V);se&&(P.disabled=se._f.disabled||E,Array.isArray(se._f.refs)&&se._f.refs.forEach(ie=>{ie.disabled=se._f.disabled||E}))},0,!1))},H=(E,P)=>async V=>{let se;V&&(V.preventDefault&&V.preventDefault(),V.persist&&V.persist());let ie=wt(s);if(a.disabled.size)for(const ee of a.disabled)Le(ie,ee,void 0);if(f.state.next({isSubmitting:!0}),t.resolver){const{errors:ee,values:me}=await O();n.errors=ee,ie=me}else await N(r);if(st(n.errors,"root"),kt(n.errors)){f.state.next({errors:{}});try{await E(ie,V)}catch(ee){se=ee}}else P&&await P({...n.errors},V),re(),setTimeout(re);if(f.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:kt(n.errors)&&!se,submitCount:n.submitCount+1,errors:n.errors}),se)throw se},K=(E,P={})=>{ue(r,E)&&(tt(P.defaultValue)?J(E,wt(ue(i,E))):(J(E,P.defaultValue),Le(i,E,wt(P.defaultValue))),P.keepTouched||st(n.touchedFields,E),P.keepDirty||(st(n.dirtyFields,E),n.isDirty=P.defaultValue?T(E,wt(ue(i,E))):T()),P.keepError||(st(n.errors,E),d.isValid&&S()),f.state.next({...n}))},pe=(E,P={})=>{const V=E?wt(E):i,se=wt(V),ie=kt(E),ee=ie?i:se;if(P.keepDefaultValues||(i=V),!P.keepValues){if(P.keepDirtyValues){const me=new Set([...a.mount,...Object.keys(Fr(i,s))]);for(const we of Array.from(me))ue(n.dirtyFields,we)?Le(ee,we,ue(s,we)):J(we,ue(ee,we))}else{if(Ca&&tt(E))for(const me of a.mount){const we=ue(r,me);if(we&&we._f){const U=Array.isArray(we._f.refs)?we._f.refs[0]:we._f.ref;if(ss(U)){const Y=U.closest("form");if(Y){Y.reset();break}}}}r={}}s=t.shouldUnregister?P.keepDefaultValues?wt(i):{}:wt(ee),f.array.next({values:{...ee}}),f.values.next({values:{...ee}})}a={mount:P.keepDirtyValues?a.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!d.isValid||!!P.keepIsValid||!!P.keepDirtyValues,o.watch=!!t.shouldUnregister,f.state.next({submitCount:P.keepSubmitCount?n.submitCount:0,isDirty:ie?!1:P.keepDirty?n.isDirty:!!(P.keepDefaultValues&&!xn(E,i)),isSubmitted:P.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:ie?{}:P.keepDirtyValues?P.keepDefaultValues&&s?Fr(i,s):n.dirtyFields:P.keepDefaultValues&&E?Fr(i,E):P.keepDirty?n.dirtyFields:{},touchedFields:P.keepTouched?n.touchedFields:{},errors:P.keepErrors?n.errors:{},isSubmitSuccessful:P.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},fe=(E,P)=>pe(Qt(E)?E(s):E,P);return{control:{register:I,unregister:Q,getFieldState:ce,handleSubmit:H,setError:G,_executeSchema:O,_getWatch:F,_getDirty:T,_updateValid:S,_removeUnmounted:R,_updateFieldArray:j,_updateDisabledField:oe,_getFieldArray:z,_reset:pe,_resetDefaultValues:()=>Qt(t.defaultValues)&&t.defaultValues().then(E=>{fe(E,t.resetOptions),f.state.next({isLoading:!1})}),_updateFormState:E=>{n={...n,...E}},_disableForm:ae,_subjects:f,_proxyFormState:d,_setErrors:A,get _fields(){return r},get _formValues(){return s},get _state(){return o},set _state(E){o=E},get _defaultValues(){return i},get _names(){return a},set _names(E){a=E},get _formState(){return n},set _formState(E){n=E},get _options(){return t},set _options(E){t={...t,...E}}},trigger:_,register:I,handleSubmit:H,watch:ne,setValue:J,getValues:ye,reset:fe,resetField:K,clearErrors:b,unregister:Q,setError:G,setFocus:(E,P={})=>{const V=ue(r,E),se=V&&V._f;if(se){const ie=se.refs?se.refs[0]:se.ref;ie.focus&&(ie.focus(),P.shouldSelect&&Qt(ie.select)&&ie.select())}},getFieldState:ce}}function Cy(e={}){const t=je.useRef(void 0),n=je.useRef(void 0),[r,i]=je.useState({isDirty:!1,isValidating:!1,isLoading:Qt(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Qt(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...Ey(e),formState:r});const s=t.current.control;return s._options=e,Ia({subject:s._subjects.state,next:o=>{bf(o,s._proxyFormState,s._updateFormState,!0)&&i({...s._formState})}}),je.useEffect(()=>s._disableForm(e.disabled),[s,e.disabled]),je.useEffect(()=>{if(s._proxyFormState.isDirty){const o=s._getDirty();o!==r.isDirty&&s._subjects.state.next({isDirty:o})}},[s,r.isDirty]),je.useEffect(()=>{e.values&&!xn(e.values,n.current)?(s._reset(e.values,s._options.resetOptions),n.current=e.values,i(o=>({...o}))):s._resetDefaultValues()},[e.values,s]),je.useEffect(()=>{e.errors&&s._setErrors(e.errors)},[e.errors,s]),je.useEffect(()=>{s._state.mount||(s._updateValid(),s._state.mount=!0),s._state.watch&&(s._state.watch=!1,s._subjects.state.next({...s._formState})),s._removeUnmounted()}),je.useEffect(()=>{e.shouldUnregister&&s._subjects.values.next({values:s._getWatch()})},[e.shouldUnregister,s]),t.current.formState=yf(r,s),t.current}function Ty(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 Iy=dy,Cf=x.createContext({}),Rl=({...e})=>c.jsx(Cf.Provider,{value:{name:e.name},children:c.jsx(my,{...e})}),Ds=()=>{const e=x.useContext(Cf),t=x.useContext(Tf),{getFieldState:n,formState:r}=Ps(),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}},Tf=x.createContext({}),Zo=x.forwardRef(({className:e,...t},n)=>{const r=x.useId();return c.jsx(Tf.Provider,{value:{id:r},children:c.jsx("div",{ref:n,className:W("space-y-2",e),...t})})});Zo.displayName="FormItem";const Uo=x.forwardRef(({className:e,...t},n)=>{const{error:r,formItemId:i}=Ds();return c.jsx(ni,{ref:n,className:W(r&&"text-destructive",e),htmlFor:i,...t})});Uo.displayName="FormLabel";const Jo=x.forwardRef(({...e},t)=>{const{error:n,formItemId:r,formDescriptionId:i,formMessageId:s}=Ds();return c.jsx(Tr,{ref:t,id:r,"aria-describedby":n?`${i} ${s}`:`${i}`,"aria-invalid":!!n,...e})});Jo.displayName="FormControl";const If=x.forwardRef(({className:e,...t},n)=>{const{formDescriptionId:r}=Ds();return c.jsx("p",{ref:n,id:r,className:W("text-muted-foreground text-[0.8rem]",e),...t})});If.displayName="FormDescription";const Ho=x.forwardRef(({className:e,children:t,...n},r)=>{const{error:i,formMessageId:s}=Ds(),o=i?String(i==null?void 0:i.message):t;return o?c.jsx("p",{ref:r,id:s,className:W("text-destructive text-[0.8rem] font-medium",e),...n,children:o}):null});Ho.displayName="FormMessage";function Oa(){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 Af=()=>({chatOpen:!1,scope:"global",model:"opus",contextAttachments:[],threads:{},activeThreadId:{}}),Ay=(e=Af())=>Bx()(Vx(Zx((t,n)=>({...e,toggleChat:()=>t(r=>({chatOpen:!r.chatOpen})),openChat:()=>t({chatOpen:!0}),closeChat:()=>t({chatOpen:!1}),addContext:r=>t(i=>({contextAttachments:[...i.contextAttachments,r]})),removeContext:r=>t(i=>({contextAttachments:i.contextAttachments.filter((s,o)=>o!==r)})),clearContext:()=>t({contextAttachments:[]}),setScope:r=>t({scope:r}),setModel:r=>t({model:r}),createThread:r=>{const i=crypto.randomUUID(),s=Date.now(),o={id:i,documentName:r,title:Oa(),messages:[],createdAt:s,updatedAt:s};return t(a=>({threads:{...a.threads,[i]:o},activeThreadId:{...a.activeThreadId,[r]:i}})),i},deleteThread:r=>{const i=n(),s=i.threads[r];if(!s)return;const o=Object.fromEntries(Object.entries(i.threads).filter(([u])=>u!==r)),a=s.documentName,l={...i.activeThreadId};if(l[a]===r){const u=Object.values(o).filter(d=>d.documentName===a);u.length>0?(u.sort((d,f)=>f.updatedAt-d.updatedAt),l[a]=u[0].id):delete l[a]}t({threads:o,activeThreadId:l})},switchThread:r=>{const s=n().threads[r];s&&t(o=>({activeThreadId:{...o.activeThreadId,[s.documentName]:r}}))},updateThreadMessages:(r,i)=>{t(s=>{const o=s.threads[r];return o?{threads:{...s.threads,[r]:{...o,messages:i,updatedAt:Date.now()}}}:s})},updateThreadTitle:(r,i)=>{t(s=>{const o=s.threads[r];return o?{threads:{...s.threads,[r]:{...o,title:i}}}:s})},deleteThreadsForDocument:r=>{t(i=>{const s={...i.threads},o={...i.activeThreadId};for(const[a,l]of Object.entries(s))l.documentName===r&&delete s[a];return delete o[r],{threads:s,activeThreadId:o}})},renameThreadsForDocument:(r,i)=>{t(s=>{const o={...s.threads},a={...s.activeThreadId};for(const[l,u]of Object.entries(o))u.documentName===r&&(o[l]={...u,documentName:i});return r in a&&(a[i]=a[r],delete a[r]),{threads:o,activeThreadId:a}})},clearChat:()=>{t(r=>({contextAttachments:[]}))}}),{name:"chat-storage",version:1,storage:Ux(()=>wg),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}}))),zf=x.createContext(void 0),zy=({children:e})=>{const t=x.useRef(null);return t.current||(t.current=Ay(Af())),c.jsx(zf.Provider,{value:t.current,children:e})},De=e=>{const t=x.useContext(zf);if(!t)throw new Error("useChatStore must be used within ChatStoreProvider");return Jx(t,e)};function Of(e){return`${e.split(/[^a-zA-Z0-9]+/).filter(Boolean).map((n,r)=>r===0?n.charAt(0).toLowerCase()+n.slice(1):n.charAt(0).toUpperCase()+n.slice(1)).join("")||"custom"}Component`}function Oy(e){const t=Of(e);return`import { Type } from '@sinclair/typebox';
|
|
3
3
|
import { createComponent, createVersion } from '@json-to-office/core-docx';
|
|
4
4
|
import type { ComponentDefinition } from '@json-to-office/shared-docx';
|
|
5
5
|
|
|
@@ -151,7 +151,7 @@ export const ${t} = createComponent({
|
|
|
151
151
|
`+" ".repeat(t)),new Array(qn).fill(0).map((e,t)=>`
|
|
152
152
|
`+" ".repeat(t)),new Array(qn).fill(0).map((e,t)=>"\r"+" ".repeat(t)),new Array(qn).fill(0).map((e,t)=>`\r
|
|
153
153
|
`+" ".repeat(t));var ls;(function(e){e.DEFAULT={allowTrailingComma:!1}})(ls||(ls={}));function Tb(e,t=[],n=ls.DEFAULT){let r={type:"array",offset:-1,length:-1,children:[],parent:void 0};function i(l){r.type==="property"&&(r.length=l-r.offset,r=r.parent)}function s(l){return r.children.push(l),l}Ab(e,{onObjectBegin:l=>{r=s({type:"object",offset:l,length:-1,parent:r,children:[]})},onObjectProperty:(l,u,d)=>{r=s({type:"property",offset:u,length:-1,parent:r,children:[]}),r.children.push({type:"string",value:l,offset:u,length:d,parent:r})},onObjectEnd:(l,u)=>{i(l+u),r.length=l+u-r.offset,r=r.parent,i(l+u)},onArrayBegin:(l,u)=>{r=s({type:"array",offset:l,length:-1,parent:r,children:[]})},onArrayEnd:(l,u)=>{r.length=l+u-r.offset,r=r.parent,i(l+u)},onLiteralValue:(l,u,d)=>{s({type:zb(l),offset:u,length:d,parent:r,value:l}),i(u+d)},onSeparator:(l,u,d)=>{r.type==="property"&&(l===":"?r.colonOffset=u:l===","&&i(u))},onError:(l,u,d)=>{t.push({error:l,offset:u,length:d})}},n);const a=r.children[0];return a&&delete a.parent,a}function Ib(e,t){if(!e)return;let n=e;for(let r of t)if(typeof r=="string"){if(n.type!=="object"||!Array.isArray(n.children))return;let i=!1;for(const s of n.children)if(Array.isArray(s.children)&&s.children[0].value===r&&s.children.length===2){n=s.children[1],i=!0;break}if(!i)return}else{const i=r;if(n.type!=="array"||i<0||!Array.isArray(n.children)||i>=n.children.length)return;n=n.children[i]}return n}function Ab(e,t,n=ls.DEFAULT){const r=Cb(e,!1),i=[];let s=0;function o(z){return z?()=>s===0&&z(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function a(z){return z?M=>s===0&&z(M,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function l(z){return z?M=>s===0&&z(M,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice()):()=>!0}function u(z){return z?()=>{s>0?s++:z(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice())===!1&&(s=1)}:()=>!0}function d(z){return z?()=>{s>0&&s--,s===0&&z(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter())}:()=>!0}const f=u(t.onObjectBegin),h=l(t.onObjectProperty),p=d(t.onObjectEnd),g=u(t.onArrayBegin),k=d(t.onArrayEnd),S=l(t.onLiteralValue),y=a(t.onSeparator),j=o(t.onComment),m=a(t.onError),A=n&&n.disallowComments,C=n&&n.allowTrailingComma;function v(){for(;;){const z=r.scan();switch(r.getTokenError()){case 4:w(14);break;case 5:w(15);break;case 3:w(13);break;case 1:A||w(11);break;case 2:w(12);break;case 6:w(16);break}switch(z){case 12:case 13:A?w(10):j();break;case 16:w(1);break;case 15:case 14:break;default:return z}}}function w(z,M=[],D=[]){if(m(z),M.length+D.length>0){let J=r.getToken();for(;J!==17;){if(M.indexOf(J)!==-1){v();break}else if(D.indexOf(J)!==-1)break;J=v()}}}function O(z){const M=r.getTokenValue();return z?S(M):(h(M),i.push(M)),v(),!0}function B(){switch(r.getToken()){case 11:const z=r.getTokenValue();let M=Number(z);isNaN(M)&&(w(2),M=0),S(M);break;case 7:S(null);break;case 8:S(!0);break;case 9:S(!1);break;default:return!1}return v(),!0}function N(){return r.getToken()!==10?(w(3,[],[2,5]),!1):(O(!1),r.getToken()===6?(y(":"),v(),F()||w(4,[],[2,5])):w(5,[],[2,5]),i.pop(),!0)}function R(){f(),v();let z=!1;for(;r.getToken()!==2&&r.getToken()!==17;){if(r.getToken()===5){if(z||w(4,[],[]),y(","),v(),r.getToken()===2&&C)break}else z&&w(6,[],[]);N()||w(4,[],[2,5]),z=!0}return p(),r.getToken()!==2?w(7,[2],[]):v(),!0}function T(){g(),v();let z=!0,M=!1;for(;r.getToken()!==4&&r.getToken()!==17;){if(r.getToken()===5){if(M||w(4,[],[]),y(","),v(),r.getToken()===4&&C)break}else M&&w(6,[],[]);z?(i.push(0),z=!1):i[i.length-1]++,F()||w(4,[],[4,5]),M=!0}return k(),z||i.pop(),r.getToken()!==4?w(8,[4],[]):v(),!0}function F(){switch(r.getToken()){case 3:return T();case 1:return R();case 10:return O(!0);default:return B()}}return v(),r.getToken()===17?n.allowEmptyContent?!0:(w(4,[],[]),!1):F()?(r.getToken()!==17&&w(9,[],[]),!0):(w(4,[],[]),!1)}function zb(e){switch(typeof e){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(e){if(Array.isArray(e))return"array"}else return"null";return"object"}default:return"null"}}var Fl;(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"})(Fl||(Fl={}));var Ll;(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"})(Ll||(Ll={}));const Ob=Tb,AO=Ib;var Bl;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"})(Bl||(Bl={}));const Pb=60,Db=/§jtoc:\d+§/g;function Ae(e,t){if(!(!e||e.type!=="object"||!e.children))for(const n of e.children){if(n.type!=="property"||!n.children)continue;const[r,i]=n.children;if((r==null?void 0:r.value)===t)return i}}function ot(e){return(e==null?void 0:e.type)==="string"&&typeof e.value=="string"?e.value:void 0}function Yo(e){return(e==null?void 0:e.type)==="number"&&typeof e.value=="number"?e.value:void 0}function It(e){return(e==null?void 0:e.type)==="array"&&e.children?e.children:[]}function St(e,t=Pb,n=!1){const r=e.replace(Db,"…"),i=n?r.replace(/\s*\n\s*/g," ").trim():r.split(`
|
|
154
|
-
`)[0].trim();return i.length>t?`${i.slice(0,t-1)}…`:i}function Rb(e){const t=It(Ae(e,"columns"));if(t.length>0)return`${Math.max(0,...t.map(i=>It(Ae(i,"cells")).length))}×${t.length}`;const n=It(Ae(e,"rows"));if(n.length>0){const r=n[0],i=(r==null?void 0:r.type)==="array"?It(r).length:It(Ae(r,"cells")).length;return i>0?`${n.length}×${i}`:`${n.length} rows`}}function $b(e){const t=ot(Ae(e,"alt"));if(t)return St(t);const n=ot(Ae(e,"src"));if(n){if(n.startsWith("data:")){const i=n.slice(5).split(/[;,]/)[0];return i?`image (${i.split("/").pop()})`:"image"}const r=n.split(/[?#]/)[0].split("/").pop();if(r)return St(r,40)}return"image"}function Mb(e,t){var r;const n=ot(Ae(t,"text"));switch(e){case"heading":{const i=Yo(Ae(t,"level"))??1;return{label:n?St(n):"heading",detail:`H${i}`}}case"text":return{label:n?St(n):"text",detail:ot(Ae(t,"style"))};case"paragraph":return{label:n?St(n):"paragraph"};case"chart":case"highcharts":{const i=ot(Ae(t,"title"))??ot(Ae(Ae(t,"options"),"title"));return{label:i?St(i):e,detail:ot(Ae(t,"type"))}}case"table":return{label:"table",detail:Rb(t)};case"image":return{label:$b(t)};case"shape":return{label:ot(Ae(t,"type"))??"shape"};case"list":{const i=It(Ae(t,"items"));return{label:"list",detail:i.length>0?`${i.length} items`:void 0}}case"section":{const i=ot(Ae(Ae(t,"meta"),"title"))??ot(Ae(t,"title"));return{label:i?St(i):"section"}}case"statistic":{const i=ot(Ae(t,"value"))??((r=Yo(Ae(t,"value")))==null?void 0:r.toString()),s=ot(Ae(t,"label"));return{label:St(s??i??"statistic"),detail:i}}default:return{label:n?St(n):e}}}function kr(e){if(e.type!=="object")return null;const t=ot(Ae(e,"name"));return t?{name:t,props:Ae(e,"props"),childrenArr:Ae(e,"children")}:null}function Fb(e){let t;for(const n of It(e)){const r=kr(n);if(!r)continue;const i=ot(Ae(r.props,"text"));if(i){if(r.name==="heading"||r.name==="text")return St(i,48);r.name==="paragraph"&&t===void 0&&(t=St(i,48))}}return t}function cs(e,t,n){let{label:r,detail:i}=Mb(t.name,t.props);return r===t.name&&t.childrenArr&&(r=Fb(t.childrenArr)??r),{id:"",kind:t.name,label:r,detail:i,start:e.offset,end:e.offset+e.length,children:Kf(t.childrenArr),reorder:n}}function Kf(e){if(!e||e.type!=="array")return[];const t=`arr@${e.offset}`,n=[];for(const r of It(e)){const i=kr(r);i&&n.push(cs(r,i,{groupId:t,sliceStart:r.offset,sliceEnd:r.offset+r.length}))}return n}function Lb(e){const t=Ae(e,"props"),n=ot(Ae(Ae(t,"meta"),"title"));if(n)return St(n,48,!0);let r;const i=(a,l)=>{l&&(!r||a<r.rank)&&(r={rank:a,text:l})},s=Ae(t,"placeholders");if((s==null?void 0:s.type)==="object"&&s.children)for(const a of s.children){if(a.type!=="property"||!a.children)continue;const[l,u]=a.children,d=typeof(l==null?void 0:l.value)=="string"?l.value:"",f=u?kr(u):null,h=f?ot(Ae(f.props,"text")):void 0;i(d==="title"?0:d==="subtitle"||d.startsWith("heading")?1:2,h)}const o=(a,l)=>{const u=kr(a);if(u){if(u.name==="text"||u.name==="heading"){const d=ot(Ae(u.props,"text"));if(d){const f=ot(Ae(u.props,"style"))??"";i(f==="title"?0:f.startsWith("heading")?1:2,d)}}if(l<1)for(const d of It(u.childrenArr))o(d,l+1)}};for(const a of It(Ae(e,"children")))o(a,0);return r?St(r.text,48,!0):void 0}function Bb(e){const t=Ae(e,"children");if(!t||t.type!=="array")return[];const n=`arr@${t.offset}`,r=[];let i=0;for(const s of It(t)){const o=kr(s);if(!o)continue;const a={groupId:n,sliceStart:s.offset,sliceEnd:s.offset+s.length};o.name==="slide"?(i+=1,r.push({id:"",kind:"slide",label:Lb(s)??`Slide ${i}`,detail:`${i}`,start:s.offset,end:s.offset+s.length,children:Kf(o.childrenArr),reorder:a})):r.push(cs(s,o,a))}return r}function Vb(e){const t=Ae(e,"children");if(!t||t.type!=="array")return[];const n=`arr@${t.offset}`,r=[],i=[];for(const o of It(t)){const a=kr(o);if(!a)continue;const l={groupId:n,sliceStart:o.offset,sliceEnd:o.offset+o.length},u=()=>i.length?i[i.length-1].node.children:r;if(a.name==="heading"){const d=Yo(Ae(a.props,"level"))??1;for(;i.length&&i[i.length-1].level>=d;)i.pop();const f=cs(o,a,l);u().push(f),i.push({level:d,node:f})}else u().push(cs(o,a,l))}const s=o=>{o.children.forEach(s);const a=o.children[o.children.length-1];o.kind==="heading"&&a&&(o.end=Math.max(o.end,a.end),o.reorder&&a.reorder&&(o.reorder.sliceEnd=Math.max(o.reorder.sliceEnd,a.reorder.sliceEnd)))};return r.forEach(s),r}function Vl(e){switch(e.type){case"string":return St(String(e.value??""),24);case"number":case"boolean":return String(e.value);case"array":return`${It(e).length} items`;case"object":return;default:return}}function Zb(e){if(e.type!=="object"||!e.children)return[];const t=[];for(const n of e.children){if(n.type!=="property"||!n.children)continue;const[r,i]=n.children,s=typeof(r==null?void 0:r.value)=="string"?r.value:void 0;if(!s||s==="$schema"||!i)continue;const o=[];if(i.type==="object"&&i.children)for(const a of i.children){if(a.type!=="property"||!a.children)continue;const[l,u]=a.children,d=typeof(l==null?void 0:l.value)=="string"?l.value:void 0;!d||!u||o.push({id:"",kind:"key",label:d,detail:Vl(u),start:a.offset,end:a.offset+a.length,children:[]})}t.push({id:"",kind:"key",label:s,detail:o.length===0?Vl(i):void 0,start:n.offset,end:n.offset+n.length,children:o})}return t}function Zl(e,t,n){if(!e.trim())return[];const r=Ob(e,[],{allowTrailingComma:!0});if(!r)return[];const i=n==="theme"?Zb(r):t==="pptx"?Bb(r):Vb(r);return Yf(i,""),i}function Yf(e,t){e.forEach((n,r)=>{n.id=t?`${t}.${r}`:`${r}`,Yf(n.children,n.id)})}function Xf(e,t){const n=[];let r=e;for(;;){const i=r.find(s=>t>=s.start&&t<s.end);if(!i)return n;n.push(i.id),r=i.children}}function Ub(e,t){const n=new Set;for(const r of t)for(const i of Xf(e,r))n.add(i);return n}function Jb(e,t,n,r){if(n===r||n<0||r<0||n>=t.length||r>=t.length)return null;const i=t.map(d=>d.reorder);if(i.some(d=>!d))return null;const s=i[0].groupId;if(i.some(d=>d.groupId!==s))return null;for(let d=1;d<i.length;d++)if(i[d].sliceStart<i[d-1].sliceEnd)return null;const o=i.map(d=>e.slice(d.sliceStart,d.sliceEnd)),a=[];for(let d=1;d<i.length;d++){const f=e.slice(i[d-1].sliceEnd,i[d].sliceStart);if((f.match(/,/g)??[]).length!==1)return null;a.push(f)}const l=o.map((d,f)=>f);l.splice(r,0,l.splice(n,1)[0]);let u="";return l.forEach((d,f)=>{u+=o[d],f<a.length&&(u+=a[f])}),{start:i[0].sliceStart,end:i[i.length-1].sliceEnd,text:u}}const Hb={slide:yx,heading:xx,text:Ro,paragraph:gx,chart:Mo,highcharts:Mo,table:mx,image:hx,shape:tf,list:px,toc:fx,section:$o,columns:$o,"text-box":Ro,statistic:dx,key:ns};function Wb(e,t){let n=e,r=null;for(const i of t.split(".")){if(r=n[Number(i)]??null,!r)return null;n=r.children}return r}function qb(e){const t=e.lastIndexOf(".");return t===-1?"":e.slice(0,t)}function Gb(){const{activeTab:e,documentTypes:t}=ke(Na(w=>({activeTab:w.activeTab,documentTypes:w.documentTypes}))),n=ke(w=>{var O;return w.activeTab?(O=w.documents.find(B=>B.name===w.activeTab))==null?void 0:O.text:void 0}),r=lf(w=>e?w.editors.get(e)??null:null),i=e&&t[e]==="application/json+theme"?"theme":"document",[s,o]=x.useState([]),[a,l]=x.useState(null),[u,d]=x.useState(()=>new Set),[f,h]=x.useState(()=>new Set),[p,g]=x.useState(null),k=x.useRef(s);k.current=s;const S=x.useRef(null),y=x.useRef(null),j=x.useCallback(()=>{var B;if(!e){o([]);return}const w=((B=r==null?void 0:r.editor.getModel())==null?void 0:B.getValue())??n??"",O=Zl(w,at,i);if(o(O),y.current!==e){y.current=e;const N=new Set;if(i==="document"&&at==="docx")for(const R of O)R.kind==="heading"&&N.add(R.id);h(N),l(null)}},[e,r,n,i]);x.useEffect(()=>{j();const w=r==null?void 0:r.editor.getModel();if(!w)return;const O=kl(j,300),B=w.onDidChangeContent(()=>O());return()=>{O.cancel(),B.dispose()}},[j,r]),x.useEffect(()=>{if(!r)return;const{editor:w}=r,O=kl(()=>{const N=w.getModel(),R=w.getPosition();if(!N||!R)return;const T=N.getOffsetAt(R),F=Xf(k.current,T);if(F.length===0){l(null);return}l(F[F.length-1]);const z=F.slice(0,-1);z.length&&h(M=>{if(z.every(J=>M.has(J)))return M;const D=new Set(M);for(const J of z)D.add(J);return D})},150),B=w.onDidChangeCursorPosition(()=>O());return()=>{O.cancel(),B.dispose()}},[r]),x.useEffect(()=>{if(!a||!S.current)return;const w=S.current.querySelector(`[data-oid="${CSS.escape(a)}"]`);w==null||w.scrollIntoView({block:"nearest"})},[a]),x.useEffect(()=>{if(!r){d(new Set);return}const{editor:w,monaco:O}=r,B=()=>{const R=w.getModel();if(!R)return;const T=O.editor.getModelMarkers({resource:R.uri}).filter(F=>F.severity===O.MarkerSeverity.Error).map(F=>R.getOffsetAt({lineNumber:F.startLineNumber,column:F.startColumn}));d(Ub(k.current,T))};B();const N=O.editor.onDidChangeMarkers(R=>{const T=w.getModel();T&&R.some(F=>F.toString()===T.uri.toString())&&B()});return()=>N.dispose()},[r,s]);const m=x.useCallback(w=>{h(O=>{const B=new Set(O);return B.has(w)?B.delete(w):B.add(w),B})},[]),A=x.useCallback(w=>{if(l(w.id),!r)return;const{editor:O,monaco:B}=r,N=O.getModel();if(!N)return;const R=N.getPositionAt(w.start),T=N.getPositionAt(w.end),F=new B.Range(R.lineNumber,R.column,T.lineNumber,T.column);O.revealRangeNearTopIfOutsideViewport(F,B.editor.ScrollType.Smooth),O.setPosition(R),O.focus();const z=O.deltaDecorations([],[{range:F,options:{className:"jto-outline-flash"}}]);window.setTimeout(()=>O.deltaDecorations(z,[]),700)},[r]),C=x.useCallback(w=>{var ye;if(!r||!w.overId)return;const{editor:O,monaco:B,collapse:N}=r,R=O.getModel();if(!R)return;const T=R.getValue(),F=Zl(T,at,i),z=w.parentId?((ye=Wb(F,w.parentId))==null?void 0:ye.children)??[]:F,M=z.findIndex(ce=>ce.id===w.dragId),D=z.findIndex(ce=>ce.id===w.overId);if(M===-1||D===-1)return;let J=D+(w.overHalf==="after"?1:0);M<J&&(J-=1);const Z=Jb(T,z,M,J);if(!Z)return;const X=R.getPositionAt(Z.start),_=R.getPositionAt(Z.end);O.executeEdits("outline-reorder",[{range:new B.Range(X.lineNumber,X.column,_.lineNumber,_.column),text:Z.text}]),N==null||N.resyncDecorations()},[r,i]),v=x.useMemo(()=>{const w=[],O=(B,N,R)=>{var z,M;const T=(M=(z=B[0])==null?void 0:z.reorder)==null?void 0:M.groupId,F=B.length>1&&T!==void 0&&B.every(D=>{var J;return((J=D.reorder)==null?void 0:J.groupId)===T});B.forEach(D=>{const J=Hb[D.kind]??bx,Z=D.children.length>0,X=f.has(D.id),_=a===D.id,ye=(p==null?void 0:p.overId)===D.id;w.push(c.jsxs("div",{"data-oid":D.id,role:"treeitem","aria-selected":_,"aria-expanded":Z?X:void 0,tabIndex:0,draggable:F,onClick:()=>A(D),onKeyDown:ce=>{(ce.key==="Enter"||ce.key===" ")&&(ce.preventDefault(),A(D)),ce.key==="ArrowRight"&&Z&&!X&&m(D.id),ce.key==="ArrowLeft"&&Z&&X&&m(D.id)},onDragStart:ce=>{ce.dataTransfer.setData("text/plain",D.id),ce.dataTransfer.effectAllowed="move",g({dragId:D.id,parentId:R,overId:null,overHalf:"before"})},onDragOver:ce=>{if(!p||p.dragId===D.id||qb(p.dragId)!==R)return;ce.preventDefault(),ce.dataTransfer.dropEffect="move";const b=ce.currentTarget.getBoundingClientRect(),G=ce.clientY<b.top+b.height/2?"before":"after";(p.overId!==D.id||p.overHalf!==G)&&g({...p,overId:D.id,overHalf:G})},onDrop:ce=>{ce.preventDefault(),p&&C({...p,overId:D.id,overHalf:p.overHalf}),g(null)},onDragEnd:()=>g(null),className:W("group flex h-6 w-full cursor-pointer items-center gap-1 rounded-sm pr-1","text-[12px] text-sidebar-foreground/80 transition-colors select-none","hover:bg-sidebar-accent hover:text-sidebar-foreground","focus-visible:ring-sidebar-ring focus-visible:ring-1 focus-visible:outline-none",_&&"bg-sidebar-accent font-medium text-sidebar-foreground",ye&&(p==null?void 0:p.overHalf)==="before"&&"shadow-[inset_0_2px_0_hsl(var(--ring))]",ye&&(p==null?void 0:p.overHalf)==="after"&&"shadow-[inset_0_-2px_0_hsl(var(--ring))]"),style:{paddingLeft:4+N*12},children:[Z?c.jsx("span",{role:"button","aria-label":X?"Collapse":"Expand",onClick:ce=>{ce.stopPropagation(),m(D.id)},className:"flex size-3.5 shrink-0 items-center justify-center rounded-xs text-sidebar-foreground/55 hover:text-sidebar-foreground",children:c.jsx(Ir,{className:W("size-3 transition-transform",X&&"rotate-90")})}):c.jsx("span",{className:"size-3.5 shrink-0"}),D.kind==="slide"&&c.jsx("span",{className:"w-3 shrink-0 text-right text-[10px] tabular-nums text-sidebar-foreground/50",children:D.detail}),c.jsx(J,{className:"size-3.5 shrink-0 text-sidebar-foreground/55"}),c.jsx("span",{className:"min-w-0 flex-1 truncate",children:D.label}),D.kind!=="slide"&&D.detail&&c.jsx("span",{className:"shrink-0 text-[10px] text-sidebar-foreground/50",children:D.detail}),u.has(D.id)&&c.jsx("span",{"aria-label":"Contains validation errors",className:"bg-destructive size-1.5 shrink-0 rounded-full"})]},D.id)),Z&&X&&O(D.children,N+1,D.id)})};return O(s,0,""),w},[s,f,a,u,p,A,m,C]);return!e||s.length===0?null:c.jsx("li",{className:"list-none",children:c.jsx("div",{ref:S,role:"tree","aria-label":`Outline of ${e}`,className:"border-sidebar-border/70 my-0.5 ml-[15px] max-h-[38vh] overflow-y-auto border-l pl-1",children:v})})}const Ul=x.memo(Gb);async function Kb(e,t){const n=JSON.stringify({name:e,props:t,children:[]},null,2);await navigator.clipboard.writeText(n)}const hi=x.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Hd,{ref:r,className:W("relative overflow-hidden",e),...n,children:[c.jsx(tx,{className:"h-full w-full rounded-[inherit]",children:t}),c.jsx(Qf,{}),c.jsx(nx,{})]}));hi.displayName=Hd.displayName;const Qf=x.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(Wd,{ref:r,orientation:t,className:W("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(rx,{className:"bg-border relative flex-1 rounded-full"})}));Qf.displayName=Wd.displayName;function Fa({className:e,...t}){return c.jsx(ix,{"data-slot":"switch",className:W("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-switch-off focus-visible:ring-ring inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent transition-colors outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 cursor-pointer",e),...t,children:c.jsx(sx,{"data-slot":"switch-thumb",className:W("bg-background pointer-events-none block size-4 rounded-full shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}const Yb=Ei("relative w-full rounded-sm border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-card text-foreground",destructive:"border-transparent bg-destructive-bg text-destructive-bg-foreground [&>svg]:text-destructive-bg-foreground",warning:"border-transparent bg-warning-bg text-warning-bg-foreground [&>svg]:text-warning-bg-foreground",success:"border-transparent bg-success-bg text-success-bg-foreground [&>svg]:text-success-bg-foreground",info:"border-transparent bg-data-blue-bg text-data-blue-bg-foreground [&>svg]:text-data-blue-bg-foreground"}},defaultVariants:{variant:"default"}}),ur=x.forwardRef(({className:e,variant:t,...n},r)=>c.jsx("div",{ref:r,role:"alert",className:W(Yb({variant:t}),e),...n}));ur.displayName="Alert";const Xb=x.forwardRef(({className:e,...t},n)=>c.jsx("h5",{ref:n,className:W("mb-1 font-medium leading-none tracking-tight",e),...t}));Xb.displayName="AlertTitle";const dr=x.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:W("text-sm [&_p]:leading-relaxed",e),...t}));dr.displayName="AlertDescription";const us=x.memo(({keyName:e,value:t,depth:n=0,isLast:r=!1})=>{const[i,s]=x.useState(n<2),o=t!==null&&typeof t=="object",a=Array.isArray(t),l=()=>s(!i),u=()=>t===null?c.jsx("span",{className:"text-muted-foreground",children:"null"}):t===void 0?c.jsx("span",{className:"text-muted-foreground",children:"undefined"}):typeof t=="boolean"?c.jsx("span",{className:"text-warning",children:String(t)}):typeof t=="number"?c.jsx("span",{className:"text-success",children:t}):typeof t=="string"?t.startsWith("http")?c.jsxs("span",{className:"text-data-blue",children:['"',t,'"']}):t.startsWith("#/")?c.jsxs("span",{className:"text-warning",children:['"',t,'"']}):c.jsxs("span",{className:"text-destructive",children:['"',t,'"']}):null,d=o?Object.keys(t).length:0;return c.jsxs("div",{className:W("text-sm",n>0&&"ml-4"),children:[c.jsxs("div",{className:"flex items-start hover:bg-muted/30 rounded-sm px-1 py-0.5",children:[o&&c.jsx("button",{onClick:l,className:"mr-1 hover:bg-muted rounded-sm p-0.5","aria-label":i?"Collapse":"Expand",children:i?c.jsx(Ni,{className:"h-3 w-3"}):c.jsx(Ir,{className:"h-3 w-3"})}),!o&&c.jsx("span",{className:"w-4"}),e&&c.jsxs(c.Fragment,{children:[c.jsxs("span",{className:"text-data-blue",children:['"',e,'"']}),c.jsx("span",{className:"mx-1",children:":"})]}),o?c.jsxs("span",{className:"text-muted-foreground",children:[a?"[":"{",!i&&c.jsxs("span",{className:"mx-1 text-xs",children:[d," ",a?"items":"properties"]}),!i&&(a?"]":"}")]}):u(),!o&&!r&&c.jsx("span",{className:"text-muted-foreground",children:","})]}),o&&i&&c.jsxs("div",{className:"ml-4",children:[a?t.map((f,h)=>c.jsx(us,{keyName:String(h),value:f,depth:n+1,isLast:h===t.length-1},h)):Object.entries(t).map(([f,h],p,g)=>c.jsx(us,{keyName:f,value:h,depth:n+1,isLast:p===g.length-1},f)),c.jsx("div",{className:"ml-4",children:c.jsxs("span",{className:"text-muted-foreground",children:[a?"]":"}",!r&&","]})})]})]})});us.displayName="JsonNode";const ds=x.memo(({schema:e,loading:t=!1,error:n,className:r})=>t?c.jsxs("div",{className:W("space-y-4",r),children:[c.jsx(si,{className:"h-8 w-64"}),c.jsx(si,{className:"h-4 w-full"}),c.jsx(si,{className:"h-64 w-full"})]}):n?c.jsx(ur,{variant:"destructive",className:r,children:c.jsx(dr,{children:n})}):e?c.jsx(hi,{className:W("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(us,{value:e})})}):c.jsx(ur,{className:r,children:c.jsx(dr,{children:"No schema available"})}));ds.displayName="SchemaViewer";function Qb({plugins:e,initialFocusedPlugin:t}){var m,A;const n=Jt(C=>C.togglePlugin),r=Jt(C=>C.isPluginSelected),i=Jt(C=>C.selectedPlugins),s=Jt(C=>C.isApplyingPlugins),[o,a]=x.useState(null),[l,u]=x.useState(null),[d,f]=x.useState("properties");x.useEffect(()=>{if(t){const C=e.find(v=>v.name===t);if(C){a(C);return}}e.length>0&&!o&&a(e[0])},[t,e]);const h=x.useMemo(()=>{const C={current:[],downstream:[],upstream:[]};return e.forEach(v=>{C[v.location]&&C[v.location].push(v)}),C},[e]),p=async(C,v)=>{o&&(await Kb(o.name,C.props),u(v),setTimeout(()=>u(null),2e3))},g=C=>{switch(C){case"current":return"Current Directory";case"downstream":return"Project";case"upstream":return"Parent Directories";default:return C}},k=C=>{switch(C){case"current":return c.jsx(_x,{className:"size-3"});case"downstream":return c.jsx(jx,{className:"size-3"});case"upstream":return c.jsx(ef,{className:"size-3"});default:return null}},S=((m=o==null?void 0:o.schema)==null?void 0:m.properties)&&Object.keys(o.schema.properties).length>0,y=(A=o==null?void 0:o.schema)==null?void 0:A.jsonSchema,j=(o==null?void 0:o.examples)&&o.examples.length>0;return c.jsxs(c.Fragment,{children:[c.jsxs(qt,{children:[c.jsxs(Gt,{className:"flex items-center gap-2",children:[c.jsx(vx,{className:"size-5 text-warning"}),"Plugins",c.jsxs(tn,{variant:"secondary",className:"font-normal",children:[i.size," active"]})]}),c.jsxs(dn,{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(hi,{className:"h-full",children:c.jsx("div",{className:"p-2 space-y-3",children:Object.entries(h).map(([C,v])=>v.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:[k(C),g(C)]}),c.jsx("div",{className:"space-y-0.5",children:v.map(w=>{const O=r(w.name),B=(o==null?void 0:o.name)===w.name;return c.jsxs("button",{onClick:()=>a(w),className:W("w-full text-left px-2 py-1.5 rounded-md transition-colors cursor-pointer","flex items-center gap-2",B?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"),children:[c.jsx("div",{className:W("size-1.5 rounded-full flex-none transition-colors",O?"bg-warning":"bg-muted-foreground/30")}),c.jsx("span",{className:"text-sm font-medium truncate flex-1",children:w.name})]},w.name)})})]},C))})})}),o?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:o.name}),o.version&&c.jsxs(tn,{variant:"outline",className:"font-mono text-[11px] flex-none",children:["v",o.version]})]}),o.description&&c.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:o.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(o.name)?"On":"Off"}),c.jsx(Fa,{checked:r(o.name),onCheckedChange:()=>n(o),disabled:s,"aria-label":`Toggle ${o.name}`})]})]}),c.jsxs("div",{className:"flex items-center gap-1.5 mt-2 text-xs text-muted-foreground",children:[k(o.location),c.jsx("span",{children:g(o.location)}),c.jsx("span",{className:"text-muted-foreground/60 mx-1",children:"/"}),c.jsx("span",{className:"font-mono truncate",children:o.relativePath})]})]}),c.jsxs("div",{className:"flex-none px-5 pt-3 pb-0 flex gap-1 border-b bg-background",children:[S&&c.jsx("button",{onClick:()=>f("properties"),className:W("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",d==="properties"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(ns,{className:"size-3.5"}),"Properties"]})}),y&&c.jsx("button",{onClick:()=>f("schema"),className:W("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",d==="schema"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(wx,{className:"size-3.5"}),"Schema"]})}),j&&c.jsx("button",{onClick:()=>f("examples"),className:W("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",d==="examples"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(kx,{className:"size-3.5"}),"Examples",c.jsx(tn,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-4",children:o.examples.length})]})})]}),c.jsx(hi,{className:"flex-1",children:c.jsxs("div",{className:"p-5",children:[d==="properties"&&S&&c.jsx("div",{className:"space-y-1",children:Object.entries(o.schema.properties).map(([C,v])=>c.jsx(ev,{name:C,prop:v},C))}),d==="schema"&&y&&c.jsx(ds,{schema:o.schema.jsonSchema,loading:!1,className:"h-[420px]"}),d==="examples"&&j&&o.examples.map((C,v)=>c.jsxs("div",{className:W(v>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:[C.title&&c.jsx("span",{className:"font-medium text-sm truncate",children:C.title}),!C.title&&c.jsxs("span",{className:"text-sm text-muted-foreground",children:["Example ",v+1]})]}),c.jsx(Ee,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs flex-none",onClick:()=>p(C,v),children:l===v?c.jsxs(c.Fragment,{children:[c.jsx(Sx,{className:"size-3 mr-1 text-success"}),"Copied"]}):c.jsxs(c.Fragment,{children:[c.jsx(zs,{className:"size-3 mr-1"}),"Copy"]})})]}),C.description&&c.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:C.description}),c.jsx("pre",{className:"p-3 bg-muted rounded-md overflow-x-auto text-xs font-mono leading-relaxed",children:JSON.stringify(C.props,null,2)})]},v)),!S&&!y&&!j&&c.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[c.jsx(ns,{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 ev({name:e,prop:t}){var o;const[n,r]=x.useState(!1),i=t.description||t.enum||t.default!==void 0||t.items||t.properties,s=t.type||(t.enum?"enum":t.oneOf?"oneOf":"—");return c.jsxs("div",{className:"rounded-md border",children:[c.jsxs("button",{onClick:()=>i&&r(!n),className:W("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(Ni,{className:"size-3 text-muted-foreground flex-none"}):c.jsx(Ir,{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(tn,{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-destructive 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((a,l)=>c.jsxs("span",{children:[l>0&&", ",c.jsx("code",{className:"bg-muted px-1 rounded-sm",children:JSON.stringify(a)})]},l))]}),((o=t.items)==null?void 0:o.type)&&c.jsxs("p",{children:[c.jsx("span",{className:"font-medium text-foreground",children:"Items: "}),t.items.type]})]})]})}const tv={current:"Current directory",downstream:"Project"};function Jl({location:e}){return c.jsx("li",{className:"list-none px-2 pt-2 pb-0.5 text-[10px] tracking-[0.08em] text-sidebar-foreground/65 uppercase",children:tv[e]??e})}function Hl({name:e,subtitle:t,query:n,onSelect:r}){return c.jsx("li",{className:"list-none",children:c.jsxs("button",{type:"button",onClick:r,title:t?`${e} — ${t}`:e,"aria-label":`Add ${e} to workspace`,className:W("group/row flex h-7 w-full cursor-pointer items-center gap-2 rounded-sm pr-1 pl-2","text-[13px] text-sidebar-foreground/70 transition-colors","hover:bg-sidebar-accent/60 hover:text-sidebar-foreground","focus-visible:ring-sidebar-ring focus-visible:ring-1 focus-visible:outline-none"),children:[c.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:c.jsx(Rs,{text:e,query:n})}),c.jsx(Dt,{"aria-hidden":!0,className:"size-3.5 shrink-0 text-sidebar-foreground/45 opacity-0 transition-opacity group-hover/row:opacity-100 group-focus-visible/row:opacity-100"})]})})}function Wl({children:e}){return c.jsx("div",{className:"px-2 pt-2 pb-0.5 text-[10px] tracking-[0.08em] text-sidebar-foreground/65 uppercase",children:e})}function nv({document:e,query:t}){var B;const n=x.useRef(null),[r,i]=x.useState(!1),[s,o]=x.useState(!1),[a,l]=x.useState(!1),[u,d]=x.useState(!1),f=ke(N=>N.openDocument),h=ke(N=>N.activeTab),p=vn(N=>N.records[e.name]),g=vn(N=>N.setEnabled),k=h===e.name,S=(p==null?void 0:p.enabled)??!0,y=(p==null?void 0:p.status)??"idle",j=(B=p==null?void 0:p.metadata)==null?void 0:B.name,m=((p==null?void 0:p.diagnostics)??[]).filter(N=>N.severity==="error").length,A=y==="ready"?`Ready${j?` — used as "${j}"`:""}`:y==="error"?m>0?`${m} error${m===1?"":"s"} — open to fix`:"Failed to load — open to fix":y==="compiling"?"Compiling…":"Not compiled yet",C=x.useCallback(N=>{g(e.name,N),window.dispatchEvent(new CustomEvent(Sg,{detail:{docName:e.name}}))},[e.name,g]),v=x.useMemo(()=>[{key:"open",label:"Open",run:()=>f(e.name)},{key:"download",label:"Download…",separatorBefore:!0,run:()=>oi(e.name,new Blob([e.text],{type:"text/typescript"}))},{key:"rename",label:"Rename…",separatorBefore:!0,run:()=>l(!0)},{key:"delete",label:"Delete",danger:!0,run:()=>d(!0)}],[e.name,e.text,f]),w=`browser-plugin-${e.name}`,O=r||s;return c.jsxs("li",{className:"group/menu-item relative list-none",children:[c.jsxs(Pf,{onOpenChange:o,children:[c.jsx(Df,{className:"block",children:c.jsxs("div",{className:W("flex h-7 w-full items-center gap-1 rounded-sm pr-1 pl-2 transition-colors","hover:bg-sidebar-accent/60",O&&"bg-sidebar-accent/60",k&&"bg-sidebar-accent font-medium"),title:`${e.name} — ${A}`,children:[k&&c.jsx("span",{"aria-hidden":!0,className:"bg-primary absolute top-1 bottom-1 left-0 w-[2px] rounded-full"}),c.jsxs("button",{ref:n,type:"button",onClick:()=>f(e.name),"aria-label":`${e.name} — ${A}`,className:W("flex h-7 min-w-0 flex-1 cursor-pointer items-center gap-2 text-[13px]","focus-visible:ring-sidebar-ring rounded-sm focus-visible:ring-1 focus-visible:outline-none",S?"text-sidebar-foreground/85":"text-sidebar-foreground/60"),children:[c.jsx(Qd,{className:W("size-3.5 shrink-0",k?"text-sidebar-accent-foreground/70":"text-sidebar-foreground/60")}),c.jsx("span",{className:"truncate",children:c.jsx(Rs,{text:e.name,query:t})}),y==="compiling"&&c.jsx(cn,{size:"sm",className:"shrink-0"}),y==="ready"&&c.jsx(Nx,{"aria-hidden":!0,className:"size-3 shrink-0 text-success"}),y==="error"&&c.jsx(Ex,{"aria-hidden":!0,className:"size-3 shrink-0 text-destructive"})]}),c.jsxs(Ti,{onOpenChange:i,children:[c.jsx(Ii,{asChild:!0,children:c.jsx(Ct,{"aria-label":`Actions for ${e.name}`,className:W("opacity-0 group-hover/menu-item:opacity-100 focus-visible:opacity-100",O&&"opacity-100"),children:c.jsx(ja,{})})}),c.jsx(Ar,{side:"right",align:"start",className:"w-44",children:v.map(N=>c.jsxs(je.Fragment,{children:[N.separatorBefore&&c.jsx(Fn,{}),c.jsx($t,{onClick:N.run,className:W(N.danger&&"text-destructive focus:text-destructive"),children:N.label})]},N.key))})]}),c.jsx(Fa,{id:w,checked:S,onCheckedChange:C,className:"shrink-0","aria-label":`Enable ${e.name}`,title:"On: expanded in every build. Off: a document that names it fails to build until it is switched back on."})]})}),c.jsx(Pa,{className:"w-44",children:v.map(N=>c.jsxs(je.Fragment,{children:[N.separatorBefore&&c.jsx(Ra,{}),c.jsx(Da,{onClick:N.run,className:W(N.danger&&"text-destructive focus:text-destructive"),children:N.label})]},N.key))})]}),c.jsx(ct,{open:a,onOpenChange:l,children:c.jsx(lt,{className:"sm:max-w-[425px]",onCloseAutoFocus:N=>{var R;N.preventDefault(),(R=n.current)==null||R.focus()},children:c.jsx(Dn,{mode:"update",shouldReset:!a,postSubmit:()=>l(!1),selectedName:e.name,isPlugin:!0})})}),c.jsx(ct,{open:u,onOpenChange:d,children:c.jsx(lt,{className:"sm:max-w-[425px]",onCloseAutoFocus:N=>{var R;N.preventDefault(),(R=n.current)==null||R.focus()},children:c.jsx(Dn,{mode:"delete",shouldReset:!u,postSubmit:()=>d(!1),selectedName:e.name,isPlugin:!0})})})]})}const rv=je.memo(nv);function iv({plugins:e,browserPlugins:t,query:n,open:r,onToggleSection:i,onShowPluginDetails:s,onNewPlugin:o,isPluginSelected:a,onTogglePlugin:l,isApplyingPlugins:u,diskPluginsLoadable:d,activeCount:f,totalCount:h}){const p=e.length>0&&t.length>0;return c.jsxs("section",{className:"border-sidebar-border/70 mt-3 border-t pt-2",children:[c.jsx(Wo,{open:r,onToggle:i,count:h>0?`${f}/${h}`:void 0,actions:c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx(Ct,{"aria-label":"New plugin",onClick:o,children:c.jsx(Dt,{})})}),c.jsx(Qe,{side:"bottom",children:"New plugin"})]}),children:"Plugins"}),r&&c.jsxs("div",{className:"flex flex-col gap-0.5",children:[p&&c.jsx(Wl,{children:"In this browser"}),c.jsx("ul",{className:"flex flex-col gap-0.5",children:t.map(g=>c.jsx(rv,{document:g,query:n},g.name))}),p&&c.jsx(Wl,{children:"On disk"}),e.length>0&&!d&&c.jsxs("p",{className:"text-sidebar-foreground/60 px-2 pt-0.5 pb-1 text-[11px] leading-snug",children:["This server does not load plugins from disk, so these cannot be switched on. Set ",c.jsx("code",{children:"PLUGIN_AUTOLOAD=true"})," on the deployment, or write one in the browser."]}),e.map(g=>{const k=a(g.name)&&d,S=`plugin-switch-${g.filePath||g.name}`;return c.jsxs("div",{title:g.description?`${g.name} — ${g.description}`:g.name,className:W("group/row flex h-7 w-full items-center gap-1 rounded-sm pr-1 pl-2","transition-colors hover:bg-sidebar-accent/60"),children:[c.jsx("button",{type:"button",onClick:()=>s(g.name),"aria-label":`Details for ${g.name}`,className:W("flex h-7 min-w-0 flex-1 cursor-pointer items-center text-[13px]","focus-visible:ring-sidebar-ring rounded-sm focus-visible:ring-1 focus-visible:outline-none",k?"text-sidebar-foreground":"text-sidebar-foreground/70"),children:c.jsx("span",{className:"truncate",children:c.jsx(Rs,{text:g.name,query:n})})}),c.jsx(Ct,{"aria-label":`Details for ${g.name}`,onClick:y=>{y.stopPropagation(),s(g.name)},className:"opacity-0 group-hover/row:opacity-100 focus-visible:opacity-100",children:c.jsx(nf,{})}),c.jsx(Fa,{id:S,checked:k,onCheckedChange:()=>l(g),disabled:u||!d,className:"shrink-0","aria-label":`Toggle ${g.name} plugin`,title:d?"On: the server loads this plugin from disk for every build.":"This server does not load plugins from disk (PLUGIN_AUTOLOAD is off)."})]},g.filePath||g.name)}),e.length+t.length===0&&c.jsx(qo,{icon:Dt,label:"New plugin",hint:"Write a custom component in TypeScript, in the browser",onClick:o})]})]})}function ql(e){return x.useMemo(()=>{const t=["current","downstream"],n=new Map;return e.forEach(r=>{const i=n.get(r.location);i?i.push(r):n.set(r.location,[r])}),[...n.entries()].sort(([r],[i])=>t.indexOf(r)-t.indexOf(i))},[e])}function ep({children:e,className:t}){return c.jsx("kbd",{"data-slot":"kbd",className:W("pointer-events-none inline-flex h-5 w-fit min-w-5 select-none items-center justify-center gap-1 rounded-sm bg-muted px-1 font-sans text-xs font-medium text-muted-foreground",t),children:e})}function sv({children:e,className:t}){return c.jsx("span",{className:W("inline-flex items-center gap-0.5",t),children:e})}const Fi=typeof navigator<"u"&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);function mi({shortcut:e,className:t}){const r=e.split("+").map(i=>i.trim().toLowerCase()).map(i=>{switch(i){case"mod":return Fi?"⌘":"Ctrl";case"shift":return Fi?"⇧":"Shift";case"alt":return Fi?"⌥":"Alt";case"ctrl":return Fi?"⌃":"Ctrl";case"enter":return"↵";default:return i.toUpperCase()}});return c.jsx(sv,{className:t,children:r.map((i,s)=>c.jsx(ep,{children:i},s))})}function ov({className:e}={}){const{theme:t,setTheme:n}=hd(),r=t==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t,i=x.useCallback(()=>{n(r==="dark"?"light":"dark")},[r,n]);return c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsxs(Ee,{variant:"ghost",size:"icon",onClick:i,className:e,children:[c.jsx(Cx,{className:"hidden dark:block"}),c.jsx(Tx,{className:"block dark:hidden"}),c.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),c.jsx(Qe,{children:c.jsx("p",{children:"Toggle theme"})})]})}function av({discoveryData:e,onToggleSidebar:t,isCollapsed:n=!1,isAnimating:r=!1}){const{documents:i,documentTypes:s,createDocument:o,openDocument:a,activeTab:l}=ke(Na($=>({documents:$.documents,documentTypes:$.documentTypes,createDocument:$.createDocument,openDocument:$.openDocument,activeTab:$.activeTab}))),u=Do($=>$.updateTheme),d=Do($=>$.removeTheme),f=x.useContext(ka),[h,p]=x.useState(!1),[g,k]=x.useState(!1),[S,y]=x.useState(!1),[j,m]=x.useState(!1),A=vn($=>fd($).length),[C,v]=x.useState(null),w=Jt($=>$.togglePlugin),O=Jt($=>$.isPluginSelected),B=Jt($=>$.selectedPlugins),N=Jt($=>$.isApplyingPlugins),[R,T]=x.useState(!1),[F,z]=x.useState(new Set(["documents","themes"])),[M,D]=x.useState(""),J=x.useRef(null),{toast:Z}=Cr(),X=i.filter($=>(s[$.name]??"application/json+report")==="application/json+report"),_=i.filter($=>s[$.name]==="application/json+theme"),ye=i.filter($=>s[$.name]==="application/typescript+plugin"),ce=x.useCallback(()=>{p(!1)},[]),b=x.useCallback(()=>{k(!1)},[]),G=x.useCallback(()=>{y(!1),z($=>new Set($).add("plugins"))},[]),ne=x.useRef(new Map);x.useEffect(()=>{const $=ne.current,xe=new Map;_.forEach(de=>{xe.set(de.name,de.text),$.get(de.name)!==de.text&&u(de.name,de.text)}),$.forEach((de,Me)=>{xe.has(Me)||d(Me)}),ne.current=xe},[_,u,d]);const Q=x.useRef(!1);x.useEffect(()=>{if(Q.current||!f)return;Q.current=!0;const $=new Set(_.map(de=>de.name));Object.keys(f.getState().customThemes).forEach(de=>{$.has(de)||d(de)})},[_,d,f]);const oe=x.useCallback($=>{z(xe=>{const de=new Set(xe);return de.has($)?de.delete($):de.add($),de})},[]),{resolvedTheme:I}=hd(),re=I==="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",ae=x.useCallback(async($,xe)=>{if(i.some(de=>de.name===$)){a($);return}try{const de=await fetch(`/api/discovery/${xe?"themes":"documents"}/${encodeURIComponent($)}/content`);if(!de.ok)throw new Error(de.statusText);const Me=await de.text(),Je=JSON.parse(Me);o($,JSON.stringify(Je,null,2),{templateSource:$}),a($),Z({title:`Added ${xe?"theme":"document"}: ${$}`})}catch{Z({title:"Failed to load",description:`Could not load ${$}`,variant:"destructive"})}},[i,o,a,Z]);x.useEffect(()=>{if(n)return;const $=xe=>{var Je,it,Lt,Ot,vl;if(xe.key!=="/"||xe.metaKey||xe.ctrlKey||xe.altKey)return;const de=xe.target,Me=(Je=de==null?void 0:de.tagName)==null?void 0:Je.toLowerCase();Me==="input"||Me==="textarea"||Me==="select"||de!=null&&de.isContentEditable||(it=de==null?void 0:de.closest)!=null&&it.call(de,".monaco-editor")||(Lt=J.current)!=null&&Lt.closest('[aria-hidden="true"], [inert]')||(xe.preventDefault(),(Ot=J.current)==null||Ot.focus(),(vl=J.current)==null||vl.select())};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[n]);const H=M.trim(),K=x.useMemo(()=>new Set(i.map($=>$.name)),[i]),pe=x.useMemo(()=>X.filter($=>on($.name,H)),[X,H]),fe=x.useMemo(()=>_.filter($=>on($.name,H)),[_,H]),Re=x.useMemo(()=>ye.filter($=>on($.name,H)),[ye,H]),Oe=x.useMemo(()=>((e==null?void 0:e.documents)??[]).filter($=>!K.has($.name)&&(on($.name,H)||on($.title??"",H))),[e,H,K]),$e=x.useMemo(()=>((e==null?void 0:e.themes)??[]).filter($=>!K.has($.name)&&(on($.name,H)||on($.description??"",H))),[e,H,K]),E=ql(Oe),P=ql($e),V=(e==null?void 0:e.pluginAutoload)??!0,se=x.useMemo(()=>(V?((e==null?void 0:e.plugins)??[]).filter(xe=>B.has(xe.name)).length:0)+A,[e,B,V,A]),ie=((e==null?void 0:e.plugins.length)??0)+ye.length,ee=x.useMemo(()=>((e==null?void 0:e.plugins)??[]).filter($=>on($.name,H)||on($.description??"",H)),[e,H]),me=$=>H.length>0||F.has($),we=me("documents"),U=me("themes"),Y=pe.length+Oe.length,ge=fe.length+$e.length,_e=H.length>0&&pe.length===0&&fe.length===0&&Re.length===0&&Oe.length===0&&$e.length===0&&ee.length===0,L=W("transition-opacity duration-150 ease-out",r?"opacity-0":"opacity-100");return c.jsxs(c.Fragment,{children:[c.jsxs(Jf,{collapsible:"none",style:{"--sidebar-width":n?"3rem":"16rem"},children:[n?c.jsxs(c.Fragment,{children:[c.jsx(Go,{className:W("gap-0 p-1.5",L),children:c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx(Ct,{className:"mx-auto size-7","aria-label":"Expand sidebar","aria-expanded":!1,onClick:t,children:c.jsx(rf,{})})}),c.jsxs(Qe,{side:"right",className:"flex items-center gap-2",children:[c.jsx("span",{children:"Expand sidebar"}),c.jsx(mi,{shortcut:"mod+b"})]})]})}),c.jsxs(Ko,{className:W("gap-2 px-1 py-1",L),children:[c.jsxs(nr,{className:"items-center gap-0.5",children:[X.map($=>c.jsx(Br,{document:$,compact:!0},$.name)),c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx(Ct,{className:"size-7","aria-label":"New document",onClick:()=>p(!0),children:c.jsx(Dt,{})})}),c.jsx(Qe,{side:"right",children:"New document"})]})]}),c.jsx("div",{className:"bg-sidebar-border/70 mx-auto h-px w-6"}),c.jsxs(nr,{className:"items-center gap-0.5",children:[_.map($=>c.jsx(Br,{document:$,compact:!0},$.name)),c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx(Ct,{className:"size-7","aria-label":"New theme",onClick:()=>k(!0),children:c.jsx(Dt,{})})}),c.jsx(Qe,{side:"right",children:"New theme"})]})]}),c.jsx("div",{className:"bg-sidebar-border/70 mx-auto h-px w-6"}),c.jsxs(nr,{className:"items-center gap-0.5",children:[ye.map($=>c.jsx(Br,{document:$,compact:!0},$.name)),c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx(Ct,{className:"size-7","aria-label":"New plugin",onClick:()=>y(!0),children:c.jsx(Dt,{})})}),c.jsx(Qe,{side:"right",children:"New plugin"})]})]})]})]}):c.jsxs(c.Fragment,{children:[c.jsxs(Go,{className:W("gap-0 p-2",L),children:[c.jsxs("div",{className:"flex h-7 items-center justify-between gap-1",children:[c.jsx("a",{href:"/","aria-label":"JSON to Office home",className:"focus-visible:ring-sidebar-ring flex items-center rounded-sm pl-1 focus-visible:ring-1 focus-visible:outline-none",children:c.jsx("img",{src:re,alt:"Wiseair",className:"h-[18px] w-auto max-w-[110px] shrink-0"})}),c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx(Ct,{"aria-label":"Collapse sidebar","aria-expanded":!0,onClick:t,children:c.jsx(Ix,{})})}),c.jsxs(Qe,{side:"right",className:"flex items-center gap-2",children:[c.jsx("span",{children:"Collapse sidebar"}),c.jsx(mi,{shortcut:"mod+b"})]})]})]}),c.jsxs("div",{className:"relative mt-2",children:[c.jsx(Ax,{"aria-hidden":!0,className:"pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-sidebar-foreground/40"}),c.jsx("input",{ref:J,type:"text",value:M,spellCheck:!1,autoComplete:"off",placeholder:"Filter files…","aria-label":"Filter documents, themes and plugins",onChange:$=>D($.target.value),onKeyDown:$=>{$.key==="Escape"&&($.preventDefault(),D(""),$.currentTarget.blur())},className:W("border-sidebar-border/70 bg-sidebar-accent/40 h-7 w-full rounded-sm border","pr-7 pl-7 text-[13px] text-sidebar-foreground transition-colors","placeholder:text-sidebar-foreground/60","focus-visible:border-sidebar-ring focus-visible:bg-sidebar-accent/60","focus-visible:ring-sidebar-ring focus-visible:ring-1 focus-visible:outline-none")}),H?c.jsx(Ct,{"aria-label":"Clear filter",onClick:()=>{var $;D(""),($=J.current)==null||$.focus()},className:"absolute top-1/2 right-1 -translate-y-1/2",children:c.jsx(wn,{})}):c.jsx(ep,{className:"absolute top-1/2 right-1.5 h-4 min-w-4 -translate-y-1/2 bg-transparent px-0 text-[10px] text-sidebar-foreground/65",children:"/"})]})]}),c.jsx(Ko,{className:W("gap-0 px-2 pb-2",L),children:_e?c.jsxs("div",{className:"px-1 py-6 text-center",children:[c.jsxs("p",{className:"text-[13px] text-sidebar-foreground/70",children:["No files match “",H,"”"]}),c.jsx("button",{type:"button",onClick:()=>{var $;D(""),($=J.current)==null||$.focus()},className:"text-sidebar-foreground/70 hover:text-sidebar-foreground focus-visible:ring-sidebar-ring mt-1 cursor-pointer rounded-sm text-[12px] underline-offset-2 hover:underline focus-visible:ring-1 focus-visible:outline-none",children:"Clear filter"})]}):c.jsxs(c.Fragment,{children:[(Y>0||!H)&&c.jsxs("section",{children:[c.jsx(Wo,{open:we,onToggle:()=>oe("documents"),count:Y||void 0,actions:c.jsxs(c.Fragment,{children:[at==="docx"&&c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx(Ct,{"aria-label":"Compare documents",disabled:X.length<2,onClick:()=>T(!0),children:c.jsx(Yd,{})})}),c.jsx(Qe,{side:"bottom",children:X.length<2?"Compare needs two documents":"Compare documents (redline)"})]}),c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx(Ct,{"aria-label":"New document",onClick:()=>p(!0),children:c.jsx(Dt,{})})}),c.jsx(Qe,{side:"bottom",children:"New document"})]})]}),children:"Documents"}),we&&c.jsxs(nr,{className:"gap-0.5",children:[pe.map($=>c.jsxs(x.Fragment,{children:[c.jsx(Br,{document:$,query:H}),!H&&l===$.name&&c.jsx(Ul,{})]},$.name)),E.map(([$,xe])=>c.jsxs(x.Fragment,{children:[E.length>1&&c.jsx(Jl,{location:$}),xe.map(de=>c.jsx(Hl,{name:de.name,subtitle:de.title,query:H,onSelect:()=>ae(de.name,!1)},de.path||de.name))]},$)),Y===0&&c.jsx("li",{className:"list-none",children:c.jsx(qo,{icon:Dt,label:"New document",onClick:()=>p(!0)})})]})]}),(ge>0||!H)&&c.jsxs("section",{className:"mt-3",children:[c.jsx(Wo,{open:U,onToggle:()=>oe("themes"),count:ge||void 0,actions:c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx(Ct,{"aria-label":"New theme",onClick:()=>k(!0),children:c.jsx(Dt,{})})}),c.jsx(Qe,{side:"bottom",children:"New theme"})]}),children:"Themes"}),U&&c.jsxs(nr,{className:"gap-0.5",children:[fe.map($=>c.jsxs(x.Fragment,{children:[c.jsx(Br,{document:$,query:H}),!H&&l===$.name&&c.jsx(Ul,{})]},$.name)),P.map(([$,xe])=>c.jsxs(x.Fragment,{children:[P.length>1&&c.jsx(Jl,{location:$}),xe.map(de=>c.jsx(Hl,{name:de.name,subtitle:de.description,query:H,onSelect:()=>ae(de.name,!0)},de.path||de.name))]},$)),ge===0&&c.jsx("li",{className:"list-none",children:c.jsx(qo,{icon:Dt,label:"New theme",onClick:()=>k(!0)})})]})]}),c.jsx(iv,{plugins:ee,browserPlugins:Re,query:H,open:me("plugins"),onToggleSection:()=>oe("plugins"),onShowPluginDetails:$=>{v($),m(!0)},onNewPlugin:()=>y(!0),isPluginSelected:O,onTogglePlugin:w,isApplyingPlugins:N,diskPluginsLoadable:V,activeCount:se,totalCount:ie})]})})]}),c.jsx(Hf,{className:W("border-sidebar-border/70 gap-0 border-t p-1.5",L),children:c.jsx("div",{className:W("flex items-center",n?"justify-center":"justify-start"),children:c.jsx(ov,{className:"size-7 rounded-sm text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground [&_svg]:size-3.5"})})})]}),c.jsx(ct,{open:h,onOpenChange:p,children:c.jsx(lt,{className:"sm:max-w-[525px]",children:c.jsx(Dn,{mode:"create",shouldReset:!h,postSubmit:ce,discoveredDocuments:(e==null?void 0:e.documents)||[]})})}),c.jsx(ct,{open:g,onOpenChange:k,children:c.jsx(lt,{className:"sm:max-w-[525px]",children:c.jsx(Dn,{mode:"create",shouldReset:!g,postSubmit:b,discoveredThemes:(e==null?void 0:e.themes)||[],isTheme:!0})})}),c.jsx(ct,{open:S,onOpenChange:y,children:c.jsx(lt,{className:"sm:max-w-[525px]",children:c.jsx(Dn,{mode:"create",shouldReset:!S,postSubmit:G,discoveredPlugins:(e==null?void 0:e.plugins)||[],isPlugin:!0})})}),c.jsx(ct,{open:j,onOpenChange:$=>{m($),$||v(null)},children:c.jsx(lt,{className:"max-h-[85vh] overflow-hidden sm:max-w-5xl",children:c.jsx(Qb,{plugins:(e==null?void 0:e.plugins)||[],initialFocusedPlugin:C})})}),c.jsx(ly,{open:R,onOpenChange:T})]})}const Gl=x.memo(av),lv=x.lazy(()=>md(()=>import("./editor-DFnlAOyt.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])).then(e=>({default:e.Editor})));function Kl(){return c.jsx(x.Suspense,{fallback:c.jsx("div",{className:"flex items-center justify-center h-full",children:c.jsxs("div",{className:"text-center",children:[c.jsx(cn,{className:"w-8 h-8 mx-auto mb-2"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading editor..."})]})}),children:c.jsx(lv,{})})}const cv=x.lazy(()=>md(()=>import("./preview-CugO7y1j.js"),__vite__mapDeps([13,1,3,4,5,6,7,8,9,10,12,11])).then(e=>({default:e.Preview})));function Yl(){return c.jsx(x.Suspense,{fallback:c.jsx("div",{className:"flex items-center justify-center h-full",children:c.jsxs("div",{className:"text-center",children:[c.jsx(cn,{className:"w-8 h-8 mx-auto mb-2"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading preview..."})]})}),children:c.jsx(cv,{})})}const{createElement:Sr,createContext:uv,forwardRef:tp,useCallback:bt,useContext:np,useEffect:Rn,useImperativeHandle:rp,useLayoutEffect:dv,useMemo:fv,useRef:jt,useState:fr}=dd,Xl=dd[`useId${Math.random()}`.slice(0,5)],pv=dv,Ms=uv(null);Ms.displayName="PanelGroupContext";const $n=pv,hv=typeof Xl=="function"?Xl:()=>null;let mv=0;function La(e=null){const t=hv(),n=jt(e||t||null);return n.current===null&&(n.current=""+mv++),e??n.current}function ip({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:i,forwardedRef:s,id:o,maxSize:a,minSize:l,onCollapse:u,onExpand:d,onResize:f,order:h,style:p,tagName:g="div",...k}){const S=np(Ms);if(S===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:y,expandPanel:j,getPanelSize:m,getPanelStyle:A,groupId:C,isPanelCollapsed:v,reevaluatePanelConstraints:w,registerPanel:O,resizePanel:B,unregisterPanel:N}=S,R=La(o),T=jt({callbacks:{onCollapse:u,onExpand:d,onResize:f},constraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:a,minSize:l},id:R,idIsFromProps:o!==void 0,order:h});jt({didLogMissingDefaultSizeWarning:!1}),$n(()=>{const{callbacks:z,constraints:M}=T.current,D={...M};T.current.id=R,T.current.idIsFromProps=o!==void 0,T.current.order=h,z.onCollapse=u,z.onExpand=d,z.onResize=f,M.collapsedSize=n,M.collapsible=r,M.defaultSize=i,M.maxSize=a,M.minSize=l,(D.collapsedSize!==M.collapsedSize||D.collapsible!==M.collapsible||D.maxSize!==M.maxSize||D.minSize!==M.minSize)&&w(T.current,D)}),$n(()=>{const z=T.current;return O(z),()=>{N(z)}},[h,R,O,N]),rp(s,()=>({collapse:()=>{y(T.current)},expand:z=>{j(T.current,z)},getId(){return R},getSize(){return m(T.current)},isCollapsed(){return v(T.current)},isExpanded(){return!v(T.current)},resize:z=>{B(T.current,z)}}),[y,j,m,v,R,B]);const F=A(T.current,i);return Sr(g,{...k,children:e,className:t,id:o,style:{...F,...p},"data-panel":"","data-panel-collapsible":r||void 0,"data-panel-group-id":C,"data-panel-id":R,"data-panel-size":parseFloat(""+F.flexGrow).toFixed(1)})}const sp=tp((e,t)=>Sr(ip,{...e,forwardedRef:t}));ip.displayName="Panel";sp.displayName="forwardRef(Panel)";let Xo=null,Pn=null;function gv(e,t){if(t){const n=(t&up)!==0,r=(t&dp)!==0,i=(t&fp)!==0,s=(t&pp)!==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 xv(){Pn!==null&&(document.head.removeChild(Pn),Xo=null,Pn=null)}function ao(e,t){const n=gv(e,t);Xo!==n&&(Xo=n,Pn===null&&(Pn=document.createElement("style"),document.head.appendChild(Pn)),Pn.innerHTML=`*{cursor: ${n}!important;}`)}function op(e){return e.type==="keydown"}function ap(e){return e.type.startsWith("pointer")}function lp(e){return e.type.startsWith("mouse")}function Fs(e){if(ap(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(lp(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function yv(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function bv(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 vv(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:tc(e),b:tc(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;Ce(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:ec(Ql(n.a)),b:ec(Ql(n.b))};if(i.a===i.b){const s=r.childNodes,o={a:n.a.at(-1),b:n.b.at(-1)};let a=s.length;for(;a--;){const l=s[a];if(l===o.a)return 1;if(l===o.b)return-1}}return Math.sign(i.a-i.b)}const wv=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function kv(e){var t;const n=getComputedStyle((t=cp(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function Sv(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||kv(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"||wv.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function Ql(e){let t=e.length;for(;t--;){const n=e[t];if(Ce(n,"Missing node"),Sv(n))return n}return null}function ec(e){return e&&Number(getComputedStyle(e).zIndex)||0}function tc(e){const t=[];for(;e;)t.push(e),e=cp(e);return t}function cp(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const up=1,dp=2,fp=4,pp=8,jv=yv()==="coarse";let Ht=[],pr=!1,yn=new Map,Ls=new Map;const gi=new Set;function _v(e,t,n,r,i){var s;const{ownerDocument:o}=t,a={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:i},l=(s=yn.get(o))!==null&&s!==void 0?s:0;return yn.set(o,l+1),gi.add(a),fs(),function(){var d;Ls.delete(e),gi.delete(a);const f=(d=yn.get(o))!==null&&d!==void 0?d:1;if(yn.set(o,f-1),fs(),f===1&&yn.delete(o),Ht.includes(a)){const h=Ht.indexOf(a);h>=0&&Ht.splice(h,1),Va(),i("up",!0,null)}}}function nc(e){const{target:t}=e,{x:n,y:r}=Fs(e);pr=!0,Ba({target:t,x:n,y:r}),fs(),Ht.length>0&&(ps("down",e),e.preventDefault(),e.stopPropagation())}function Zr(e){const{x:t,y:n}=Fs(e);if(pr&&e.buttons===0&&(pr=!1,ps("up",e)),!pr){const{target:r}=e;Ba({target:r,x:t,y:n})}ps("move",e),Va(),Ht.length>0&&e.preventDefault()}function Gn(e){const{target:t}=e,{x:n,y:r}=Fs(e);Ls.clear(),pr=!1,Ht.length>0&&e.preventDefault(),ps("up",e),Ba({target:t,x:n,y:r}),Va(),fs()}function Ba({target:e,x:t,y:n}){Ht.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),gi.forEach(i=>{const{element:s,hitAreaMargins:o}=i,a=s.getBoundingClientRect(),{bottom:l,left:u,right:d,top:f}=a,h=jv?o.coarse:o.fine;if(t>=u-h&&t<=d+h&&n>=f-h&&n<=l+h){if(r!==null&&document.contains(r)&&s!==r&&!s.contains(r)&&!r.contains(s)&&vv(r,s)>0){let g=r,k=!1;for(;g&&!g.contains(s);){if(bv(g.getBoundingClientRect(),a)){k=!0;break}g=g.parentElement}if(k)return}Ht.push(i)}})}function lo(e,t){Ls.set(e,t)}function Va(){let e=!1,t=!1;Ht.forEach(r=>{const{direction:i}=r;i==="horizontal"?e=!0:t=!0});let n=0;Ls.forEach(r=>{n|=r}),e&&t?ao("intersection",n):e?ao("horizontal",n):t?ao("vertical",n):xv()}function fs(){yn.forEach((e,t)=>{const{body:n}=t;n.removeEventListener("contextmenu",Gn),n.removeEventListener("pointerdown",nc),n.removeEventListener("pointerleave",Zr),n.removeEventListener("pointermove",Zr)}),window.removeEventListener("pointerup",Gn),window.removeEventListener("pointercancel",Gn),gi.size>0&&(pr?(Ht.length>0&&yn.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("contextmenu",Gn),n.addEventListener("pointerleave",Zr),n.addEventListener("pointermove",Zr))}),window.addEventListener("pointerup",Gn),window.addEventListener("pointercancel",Gn)):yn.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("pointerdown",nc,{capture:!0}),n.addEventListener("pointermove",Zr))}))}function ps(e,t){gi.forEach(n=>{const{setResizeHandlerState:r}=n,i=Ht.includes(n);r(e,i,t)})}function Nv(){const[e,t]=fr(0);return bt(()=>t(n=>n+1),[])}function Ce(e,t){if(!e)throw console.error(t),Error(t)}const Za=10;function Ln(e,t,n=Za){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function ln(e,t,n=Za){return Ln(e,t,n)===0}function Tt(e,t,n){return Ln(e,t,n)===0}function Ev(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(!Tt(i,s,n))return!1}return!0}function ar({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];Ce(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:s,maxSize:o=100,minSize:a=0}=r;if(Ln(n,a)<0)if(s){const l=(i+a)/2;Ln(n,l)<0?n=i:n=a}else n=a;return n=Math.min(o,n),n=parseFloat(n.toFixed(Za)),n}function Kr({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(Tt(e,0))return t;const o=[...t],[a,l]=r;Ce(a!=null,"Invalid first pivot index"),Ce(l!=null,"Invalid second pivot index");let u=0;if(s==="keyboard"){{const f=e<0?l:a,h=n[f];Ce(h,`Panel constraints not found for index ${f}`);const{collapsedSize:p=0,collapsible:g,minSize:k=0}=h;if(g){const S=t[f];if(Ce(S!=null,`Previous layout not found for panel index ${f}`),Tt(S,p)){const y=k-S;Ln(y,Math.abs(e))>0&&(e=e<0?0-y:y)}}}{const f=e<0?a:l,h=n[f];Ce(h,`No panel constraints found for index ${f}`);const{collapsedSize:p=0,collapsible:g,minSize:k=0}=h;if(g){const S=t[f];if(Ce(S!=null,`Previous layout not found for panel index ${f}`),Tt(S,k)){const y=S-p;Ln(y,Math.abs(e))>0&&(e=e<0?0-y:y)}}}}{const f=e<0?1:-1;let h=e<0?l:a,p=0;for(;;){const k=t[h];Ce(k!=null,`Previous layout not found for panel index ${h}`);const y=ar({panelConstraints:n,panelIndex:h,size:100})-k;if(p+=y,h+=f,h<0||h>=n.length)break}const g=Math.min(Math.abs(e),Math.abs(p));e=e<0?0-g:g}{let h=e<0?a:l;for(;h>=0&&h<n.length;){const p=Math.abs(e)-Math.abs(u),g=t[h];Ce(g!=null,`Previous layout not found for panel index ${h}`);const k=g-p,S=ar({panelConstraints:n,panelIndex:h,size:k});if(!Tt(g,S)&&(u+=g-S,o[h]=S,u.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?h--:h++}}if(Ev(i,o))return i;{const f=e<0?l:a,h=t[f];Ce(h!=null,`Previous layout not found for panel index ${f}`);const p=h+u,g=ar({panelConstraints:n,panelIndex:f,size:p});if(o[f]=g,!Tt(g,p)){let k=p-g,y=e<0?l:a;for(;y>=0&&y<n.length;){const j=o[y];Ce(j!=null,`Previous layout not found for panel index ${y}`);const m=j+k,A=ar({panelConstraints:n,panelIndex:y,size:m});if(Tt(j,A)||(k-=A-j,o[y]=A),Tt(k,0))break;e>0?y--:y++}}}const d=o.reduce((f,h)=>h+f,0);return Tt(d,100)?o:i}function Cv({layout:e,panelsArray:t,pivotIndices:n}){let r=0,i=100,s=0,o=0;const a=n[0];Ce(a!=null,"No pivot index found"),t.forEach((f,h)=>{const{constraints:p}=f,{maxSize:g=100,minSize:k=0}=p;h===a?(r=k,i=g):(s+=k,o+=g)});const l=Math.min(i,100-s),u=Math.max(r,100-o),d=e[a];return{valueMax:l,valueMin:u,valueNow:d}}function xi(e,t=document){return Array.from(t.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${e}"]`))}function hp(e,t,n=document){const i=xi(e,n).findIndex(s=>s.getAttribute("data-panel-resize-handle-id")===t);return i??null}function mp(e,t,n){const r=hp(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function gp(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 Bs(e,t=document){const n=t.querySelector(`[data-panel-resize-handle-id="${e}"]`);return n||null}function Tv(e,t,n,r=document){var i,s,o,a;const l=Bs(t,r),u=xi(e,r),d=l?u.indexOf(l):-1,f=(i=(s=n[d])===null||s===void 0?void 0:s.id)!==null&&i!==void 0?i:null,h=(o=(a=n[d+1])===null||a===void 0?void 0:a.id)!==null&&o!==void 0?o:null;return[f,h]}function Iv({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:i,panelGroupElement:s,setLayout:o}){jt({didWarnAboutMissingResizeHandle:!1}),$n(()=>{if(!s)return;const a=xi(n,s);for(let l=0;l<i.length-1;l++){const{valueMax:u,valueMin:d,valueNow:f}=Cv({layout:r,panelsArray:i,pivotIndices:[l,l+1]}),h=a[l];if(h!=null){const p=i[l];Ce(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(d)),h.setAttribute("aria-valuenow",f!=null?""+Math.round(f):"")}}return()=>{a.forEach((l,u)=>{l.removeAttribute("aria-controls"),l.removeAttribute("aria-valuemax"),l.removeAttribute("aria-valuemin"),l.removeAttribute("aria-valuenow")})}},[n,r,i,s]),Rn(()=>{if(!s)return;const a=t.current;Ce(a,"Eager values not found");const{panelDataArray:l}=a,u=gp(n,s);Ce(u!=null,`No group found for id "${n}"`);const d=xi(n,s);Ce(d,`No resize handles found for group id "${n}"`);const f=d.map(h=>{const p=h.getAttribute("data-panel-resize-handle-id");Ce(p,"Resize handle element has no handle id attribute");const[g,k]=Tv(n,p,l,s);if(g==null||k==null)return()=>{};const S=y=>{if(!y.defaultPrevented)switch(y.key){case"Enter":{y.preventDefault();const j=l.findIndex(m=>m.id===g);if(j>=0){const m=l[j];Ce(m,`No panel data found for index ${j}`);const A=r[j],{collapsedSize:C=0,collapsible:v,minSize:w=0}=m.constraints;if(A!=null&&v){const O=Kr({delta:Tt(A,C)?w-C:C-A,initialLayout:r,panelConstraints:l.map(B=>B.constraints),pivotIndices:mp(n,p,s),prevLayout:r,trigger:"keyboard"});r!==O&&o(O)}}break}}};return h.addEventListener("keydown",S),()=>{h.removeEventListener("keydown",S)}});return()=>{f.forEach(h=>h())}},[s,e,t,n,r,i,o])}function rc(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 xp(e,t){const n=e==="horizontal",{x:r,y:i}=Fs(t);return n?r:i}function Av(e,t,n,r,i){const s=n==="horizontal",o=Bs(t,i);Ce(o,`No resize handle element found for id "${t}"`);const a=o.getAttribute("data-panel-group-id");Ce(a,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=r;const u=xp(n,e),d=gp(a,i);Ce(d,`No group element found for id "${a}"`);const f=d.getBoundingClientRect(),h=s?f.width:f.height;return(u-l)/h*100}function zv(e,t,n,r,i,s){if(op(e)){const o=n==="horizontal";let a=0;e.shiftKey?a=100:i!=null?a=i:a=10;let l=0;switch(e.key){case"ArrowDown":l=o?0:a;break;case"ArrowLeft":l=o?-a:0;break;case"ArrowRight":l=o?a:0;break;case"ArrowUp":l=o?0:-a;break;case"End":l=100;break;case"Home":l=-100;break}return l}else return r==null?0:Av(e,t,n,r,s)}function Ov({panelDataArray:e}){const t=Array(e.length),n=e.map(s=>s.constraints);let r=0,i=100;for(let s=0;s<e.length;s++){const o=n[s];Ce(o,`Panel constraints not found for index ${s}`);const{defaultSize:a}=o;a!=null&&(r++,t[s]=a,i-=a)}for(let s=0;s<e.length;s++){const o=n[s];Ce(o,`Panel constraints not found for index ${s}`);const{defaultSize:a}=o;if(a!=null)continue;const l=e.length-r,u=i/l;r++,t[s]=u,i-=u}return t}function Kn(e,t,n){t.forEach((r,i)=>{const s=e[i];Ce(s,`Panel data not found for index ${i}`);const{callbacks:o,constraints:a,id:l}=s,{collapsedSize:u=0,collapsible:d}=a,f=n[l];if(f==null||r!==f){n[l]=r;const{onCollapse:h,onExpand:p,onResize:g}=o;g&&g(r,f),d&&(h||p)&&(p&&(f==null||ln(f,u))&&!ln(r,u)&&p(),h&&(f==null||!ln(f,u))&&ln(r,u)&&h())}})}function Li(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 Pv({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:i,precision:s=3}){const o=n[i];let a;return o==null?a=e!=null?e.toPrecision(s):"1":r.length===1?a="1":a=o.toPrecision(s),{flexBasis:0,flexGrow:a,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function Dv(e,t=10){let n=null;return(...i)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...i)},t)}}function ic(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 yp(e){return`react-resizable-panels:${e}`}function bp(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 vp(e,t){try{const n=yp(e),r=t.getItem(n);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function Rv(e,t,n){var r,i;const s=(r=vp(e,n))!==null&&r!==void 0?r:{},o=bp(t);return(i=s[o])!==null&&i!==void 0?i:null}function $v(e,t,n,r,i){var s;const o=yp(e),a=bp(t),l=(s=vp(e,i))!==null&&s!==void 0?s:{};l[a]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{i.setItem(o,JSON.stringify(l))}catch(u){console.error(u)}}function sc({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((s,o)=>s+o,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(s=>`${s}%`).join(", ")}`);if(!Tt(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const o=n[s];Ce(o!=null,`No layout data found for index ${s}`);const a=100/r*o;n[s]=a}let i=0;for(let s=0;s<t.length;s++){const o=n[s];Ce(o!=null,`No layout data found for index ${s}`);const a=ar({panelConstraints:t,panelIndex:s,size:o});o!=a&&(i+=o-a,n[s]=a)}if(!Tt(i,0))for(let s=0;s<t.length;s++){const o=n[s];Ce(o!=null,`No layout data found for index ${s}`);const a=o+i,l=ar({panelConstraints:t,panelIndex:s,size:a});if(o!==l&&(i-=l-o,n[s]=l,Tt(i,0)))break}return n}const Mv=100,Yr={getItem:e=>(ic(Yr),Yr.getItem(e)),setItem:(e,t)=>{ic(Yr),Yr.setItem(e,t)}},oc={};function wp({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:i,id:s=null,onLayout:o=null,keyboardResizeBy:a=null,storage:l=Yr,style:u,tagName:d="div",...f}){const h=La(s),p=jt(null),[g,k]=fr(null),[S,y]=fr([]),j=Nv(),m=jt({}),A=jt(new Map),C=jt(0),v=jt({autoSaveId:e,direction:r,dragState:g,id:h,keyboardResizeBy:a,onLayout:o,storage:l}),w=jt({layout:S,panelDataArray:[],panelDataArrayChanged:!1});jt({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),rp(i,()=>({getId:()=>v.current.id,getLayout:()=>{const{layout:b}=w.current;return b},setLayout:b=>{const{onLayout:G}=v.current,{layout:ne,panelDataArray:Q}=w.current,oe=sc({layout:b,panelConstraints:Q.map(I=>I.constraints)});rc(ne,oe)||(y(oe),w.current.layout=oe,G&&G(oe),Kn(Q,oe,m.current))}}),[]),$n(()=>{v.current.autoSaveId=e,v.current.direction=r,v.current.dragState=g,v.current.id=h,v.current.onLayout=o,v.current.storage=l}),Iv({committedValuesRef:v,eagerValuesRef:w,groupId:h,layout:S,panelDataArray:w.current.panelDataArray,setLayout:y,panelGroupElement:p.current}),Rn(()=>{const{panelDataArray:b}=w.current;if(e){if(S.length===0||S.length!==b.length)return;let G=oc[e];G==null&&(G=Dv($v,Mv),oc[e]=G);const ne=[...b],Q=new Map(A.current);G(e,ne,Q,S,l)}},[e,S,l]),Rn(()=>{});const O=bt(b=>{const{onLayout:G}=v.current,{layout:ne,panelDataArray:Q}=w.current;if(b.constraints.collapsible){const oe=Q.map(H=>H.constraints),{collapsedSize:I=0,panelSize:re,pivotIndices:ae}=Cn(Q,b,ne);if(Ce(re!=null,`Panel size not found for panel "${b.id}"`),!ln(re,I)){A.current.set(b.id,re);const K=rr(Q,b)===Q.length-1?re-I:I-re,pe=Kr({delta:K,initialLayout:ne,panelConstraints:oe,pivotIndices:ae,prevLayout:ne,trigger:"imperative-api"});Li(ne,pe)||(y(pe),w.current.layout=pe,G&&G(pe),Kn(Q,pe,m.current))}}},[]),B=bt((b,G)=>{const{onLayout:ne}=v.current,{layout:Q,panelDataArray:oe}=w.current;if(b.constraints.collapsible){const I=oe.map(fe=>fe.constraints),{collapsedSize:re=0,panelSize:ae=0,minSize:H=0,pivotIndices:K}=Cn(oe,b,Q),pe=G??H;if(ln(ae,re)){const fe=A.current.get(b.id),Re=fe!=null&&fe>=pe?fe:pe,$e=rr(oe,b)===oe.length-1?ae-Re:Re-ae,E=Kr({delta:$e,initialLayout:Q,panelConstraints:I,pivotIndices:K,prevLayout:Q,trigger:"imperative-api"});Li(Q,E)||(y(E),w.current.layout=E,ne&&ne(E),Kn(oe,E,m.current))}}},[]),N=bt(b=>{const{layout:G,panelDataArray:ne}=w.current,{panelSize:Q}=Cn(ne,b,G);return Ce(Q!=null,`Panel size not found for panel "${b.id}"`),Q},[]),R=bt((b,G)=>{const{panelDataArray:ne}=w.current,Q=rr(ne,b);return Pv({defaultSize:G,dragState:g,layout:S,panelData:ne,panelIndex:Q})},[g,S]),T=bt(b=>{const{layout:G,panelDataArray:ne}=w.current,{collapsedSize:Q=0,collapsible:oe,panelSize:I}=Cn(ne,b,G);return Ce(I!=null,`Panel size not found for panel "${b.id}"`),oe===!0&&ln(I,Q)},[]),F=bt(b=>{const{layout:G,panelDataArray:ne}=w.current,{collapsedSize:Q=0,collapsible:oe,panelSize:I}=Cn(ne,b,G);return Ce(I!=null,`Panel size not found for panel "${b.id}"`),!oe||Ln(I,Q)>0},[]),z=bt(b=>{const{panelDataArray:G}=w.current;G.push(b),G.sort((ne,Q)=>{const oe=ne.order,I=Q.order;return oe==null&&I==null?0:oe==null?-1:I==null?1:oe-I}),w.current.panelDataArrayChanged=!0,j()},[j]);$n(()=>{if(w.current.panelDataArrayChanged){w.current.panelDataArrayChanged=!1;const{autoSaveId:b,onLayout:G,storage:ne}=v.current,{layout:Q,panelDataArray:oe}=w.current;let I=null;if(b){const ae=Rv(b,oe,ne);ae&&(A.current=new Map(Object.entries(ae.expandToSizes)),I=ae.layout)}I==null&&(I=Ov({panelDataArray:oe}));const re=sc({layout:I,panelConstraints:oe.map(ae=>ae.constraints)});rc(Q,re)||(y(re),w.current.layout=re,G&&G(re),Kn(oe,re,m.current))}}),$n(()=>{const b=w.current;return()=>{b.layout=[]}},[]);const M=bt(b=>{let G=!1;const ne=p.current;return ne&&window.getComputedStyle(ne,null).getPropertyValue("direction")==="rtl"&&(G=!0),function(oe){oe.preventDefault();const I=p.current;if(!I)return()=>null;const{direction:re,dragState:ae,id:H,keyboardResizeBy:K,onLayout:pe}=v.current,{layout:fe,panelDataArray:Re}=w.current,{initialLayout:Oe}=ae??{},$e=mp(H,b,I);let E=zv(oe,b,re,ae,K,I);const P=re==="horizontal";P&&G&&(E=-E);const V=Re.map(ee=>ee.constraints),se=Kr({delta:E,initialLayout:Oe??fe,panelConstraints:V,pivotIndices:$e,prevLayout:fe,trigger:op(oe)?"keyboard":"mouse-or-touch"}),ie=!Li(fe,se);(ap(oe)||lp(oe))&&C.current!=E&&(C.current=E,!ie&&E!==0?P?lo(b,E<0?up:dp):lo(b,E<0?fp:pp):lo(b,0)),ie&&(y(se),w.current.layout=se,pe&&pe(se),Kn(Re,se,m.current))}},[]),D=bt((b,G)=>{const{onLayout:ne}=v.current,{layout:Q,panelDataArray:oe}=w.current,I=oe.map(fe=>fe.constraints),{panelSize:re,pivotIndices:ae}=Cn(oe,b,Q);Ce(re!=null,`Panel size not found for panel "${b.id}"`);const K=rr(oe,b)===oe.length-1?re-G:G-re,pe=Kr({delta:K,initialLayout:Q,panelConstraints:I,pivotIndices:ae,prevLayout:Q,trigger:"imperative-api"});Li(Q,pe)||(y(pe),w.current.layout=pe,ne&&ne(pe),Kn(oe,pe,m.current))},[]),J=bt((b,G)=>{const{layout:ne,panelDataArray:Q}=w.current,{collapsedSize:oe=0,collapsible:I}=G,{collapsedSize:re=0,collapsible:ae,maxSize:H=100,minSize:K=0}=b.constraints,{panelSize:pe}=Cn(Q,b,ne);pe!=null&&(I&&ae&&ln(pe,oe)?ln(oe,re)||D(b,re):pe<K?D(b,K):pe>H&&D(b,H))},[D]),Z=bt((b,G)=>{const{direction:ne}=v.current,{layout:Q}=w.current;if(!p.current)return;const oe=Bs(b,p.current);Ce(oe,`Drag handle element not found for id "${b}"`);const I=xp(ne,G);k({dragHandleId:b,dragHandleRect:oe.getBoundingClientRect(),initialCursorPosition:I,initialLayout:Q})},[]),X=bt(()=>{k(null)},[]),_=bt(b=>{const{panelDataArray:G}=w.current,ne=rr(G,b);ne>=0&&(G.splice(ne,1),delete m.current[b.id],w.current.panelDataArrayChanged=!0,j())},[j]),ye=fv(()=>({collapsePanel:O,direction:r,dragState:g,expandPanel:B,getPanelSize:N,getPanelStyle:R,groupId:h,isPanelCollapsed:T,isPanelExpanded:F,reevaluatePanelConstraints:J,registerPanel:z,registerResizeHandle:M,resizePanel:D,startDragging:Z,stopDragging:X,unregisterPanel:_,panelGroupElement:p.current}),[O,g,r,B,N,R,h,T,F,J,z,M,D,Z,X,_]),ce={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return Sr(Ms.Provider,{value:ye},Sr(d,{...f,children:t,className:n,id:s,ref:p,style:{...ce,...u},"data-panel-group":"","data-panel-group-direction":r,"data-panel-group-id":h}))}const kp=tp((e,t)=>Sr(wp,{...e,forwardedRef:t}));wp.displayName="PanelGroup";kp.displayName="forwardRef(PanelGroup)";function rr(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function Cn(e,t,n){const r=rr(e,t),s=r===e.length-1?[r-1,r]:[r,r+1],o=n[r];return{...t.constraints,panelSize:o,pivotIndices:s}}function Fv({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){Rn(()=>{if(e||n==null||r==null)return;const i=Bs(t,r);if(i==null)return;const s=o=>{if(!o.defaultPrevented)switch(o.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{o.preventDefault(),n(o);break}case"F6":{o.preventDefault();const a=i.getAttribute("data-panel-group-id");Ce(a,`No group element found for id "${a}"`);const l=xi(a,r),u=hp(a,t,r);Ce(u!==null,`No resize element found for id "${t}"`);const d=o.shiftKey?u>0?u-1:l.length-1:u+1<l.length?u+1:0;l[d].focus();break}}};return i.addEventListener("keydown",s),()=>{i.removeEventListener("keydown",s)}},[r,e,t,n])}function Sp({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:i,onBlur:s,onDragging:o,onFocus:a,style:l={},tabIndex:u=0,tagName:d="div",...f}){var h,p;const g=jt(null),k=jt({onDragging:o});Rn(()=>{k.current.onDragging=o});const S=np(Ms);if(S===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:y,groupId:j,registerResizeHandle:m,startDragging:A,stopDragging:C,panelGroupElement:v}=S,w=La(i),[O,B]=fr("inactive"),[N,R]=fr(!1),[T,F]=fr(null),z=jt({state:O});$n(()=>{z.current.state=O}),Rn(()=>{if(n)F(null);else{const Z=m(w);F(()=>Z)}},[n,w,m]);const M=(h=r==null?void 0:r.coarse)!==null&&h!==void 0?h:15,D=(p=r==null?void 0:r.fine)!==null&&p!==void 0?p:5;return Rn(()=>{if(n||T==null)return;const Z=g.current;return Ce(Z,"Element ref not attached"),_v(w,Z,y,{coarse:M,fine:D},(_,ye,ce)=>{if(ye)switch(_){case"down":{B("drag"),Ce(ce,'Expected event to be defined for "down" action'),A(w,ce);const{onDragging:b}=k.current;b&&b(!0);break}case"move":{const{state:b}=z.current;b!=="drag"&&B("hover"),Ce(ce,'Expected event to be defined for "move" action'),T(ce);break}case"up":{B("hover"),C();const{onDragging:b}=k.current;b&&b(!1);break}}else B("inactive")})},[M,y,n,D,m,w,T,A,C]),Fv({disabled:n,handleId:w,resizeHandler:T,panelGroupElement:v}),Sr(d,{...f,children:e,className:t,id:i,onBlur:()=>{R(!1),s==null||s()},onFocus:()=>{R(!0),a==null||a()},ref:g,role:"separator",style:{...{touchAction:"none",userSelect:"none"},...l},tabIndex:u,"data-panel-group-direction":y,"data-panel-group-id":j,"data-resize-handle":"","data-resize-handle-active":O==="drag"?"pointer":N?"keyboard":void 0,"data-resize-handle-state":O,"data-panel-resize-handle-enabled":!n,"data-panel-resize-handle-id":w})}Sp.displayName="PanelResizeHandle";const Lv=({className:e,...t})=>c.jsx(kp,{className:W("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),co=sp,ac=({withHandle:e,className:t,...n})=>c.jsx(Sp,{className:W("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(zx,{className:"h-2.5 w-2.5"})})}),jp=x.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{className:W("flex min-h-[80px] w-full rounded-sm border border-input bg-background px-3 py-2 text-sm shadow-xs","placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));jp.displayName="Textarea";class Bv{constructor(t){Rr(this,"client");this.client=Hx.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 Vv=new Bv;class Zv extends Error{constructor(n,r){super(n);Rr(this,"quality");this.name="QualityGateFailedError",this.quality=r}}function Uv(e,t){return e??t}function Jv(e){var n;const t=(n=e==null?void 0:e.split(";",1)[0])==null?void 0:n.trim().toLowerCase();return t?t==="application/json"||t.startsWith("application/")&&t.endsWith("+json"):!1}async function Hv(e){if(Jv(e.headers.get("content-type")))try{return await e.json()}catch{return}}function lc(e,t){if(t!=null&&t.error)return t.error;if(t!=null&&t.message)return t.message;if(e.ok)return`The server answered ${e.status} but not with a document. This usually means a proxy or extension replaced the response.`;switch(e.status){case 502:case 503:case 504:return`The server did not finish generating (${e.status}). It usually ran out of memory or restarted mid-request — documents with many full-page images or inline SVGs are the common cause. Try again, or split the document and generate it in parts.`;case 413:return"The document is too large for the server to accept (413). Remove or shrink its largest embedded assets.";case 429:return"Too many requests (429). Wait a moment before generating again.";default:return`Generation failed (${e.status}${e.statusText?` ${e.statusText}`:""}).`}}function Wv(){const e=x.useRef(null),t=yr(s=>s.generationBackend),n=pd(),r=x.useCallback(async(s,o,a,l,u)=>{e.current&&e.current.abort();const d=new AbortController;e.current=d;const f=Uv(u==null?void 0:u.renderer,t);try{l==null||l("parsing","Validating JSON structure...");let h;try{h=JSON.parse(o)}catch(B){throw new Error(`Invalid JSON: ${B instanceof Error?B.message:"Unknown parse error"}`)}l==null||l("building",`Building ${$i.toLowerCase()} structure...`);const p={jsonDefinition:h,options:{...u,sourceName:n(s),...f?{renderer:f}:{}}};p.customThemes=a??{},l==null||l("rendering",`Generating ${at.toUpperCase()} content...`);const g={"Content-Type":"application/json"};u!=null&&u.bypassCache&&(g["X-Bypass-Cache"]="true");const k=await fetch(ui.generate,{method:"POST",headers:g,body:JSON.stringify(p),signal:d.signal}),S=await Hv(k);if(k.status===400&&(S==null?void 0:S.code)==="QUALITY_GATE_FAILED")throw new Zv(lc(k,S),S.quality);if(!k.ok||!(S!=null&&S.success))throw new Error(lc(k,S));const{data:y,cache:j,warnings:m}=S,A=j.status==="HIT"?"HIT":j.status==="MISS"?"MISS":"UNKNOWN",C=A==="HIT"?`Served from cache (Hit rate: ${j.hitRate})`:`Generated fresh ${$i.toLowerCase()}`;l==null||l("finalizing",C);const v=globalThis.atob(y.document),w=new Uint8Array(v.length);for(let B=0;B<v.length;B++)w[B]=v.charCodeAt(B);const O=new Blob([w],{type:y.contentType});if(O.size===0)throw new Error(`Received empty ${$i.toLowerCase()} from API`);return{name:s,text:o,blob:O,...f?{renderer:f}:{},filename:y.filename,fileId:y.fileId,cacheStatus:A,cacheHitRate:j.hitRate,warnings:m}}catch(h){throw h instanceof Error&&h.name==="AbortError"?new Error(`${$i} generation was cancelled`):h}finally{e.current===d&&(e.current=null)}},[t,n]),i=x.useCallback(()=>{e.current&&(e.current.abort(),e.current=null)},[]);return{generatePresentation:r,generateDocument:r,cancelGeneration:i}}const Yi={ids:[],default:null};let cc;function qv(){return cc??(cc=(async()=>{var e;try{const t=await fetch(ui.renderers);if(!t.ok)return Yi;const n=await t.json();return!(n!=null&&n.success)||!Array.isArray((e=n.data)==null?void 0:e.ids)?Yi:n.data}catch{return Yi}})()),cc}function Gv(){const[e,t]=x.useState(Yi);return x.useEffect(()=>{let n=!1;return qv().then(r=>{n||t(r)}),()=>{n=!0}},[]),e}function Kv(e){if(!e||e.length===0)return null;const t=[{name:"heading",props:{level:1,text:"Document Generation Warnings"}},{name:"paragraph",props:{text:`${e.length} warning(s) were generated during document processing.`,spacing:{after:240}}}],n=new Map;for(const r of e){const i=n.get(r.component)||[];i.push(r),n.set(r.component,i)}for(const[r,i]of n.entries()){t.push({name:"heading",props:{level:2,text:`Component: ${r}`}});const s=[];for(const o of i){let a=o.message;if(o.context&&Object.keys(o.context).length>0){const l=Object.entries(o.context).map(([u,d])=>`${u}: ${JSON.stringify(d)}`).join(", ");a+=` (${l})`}s.push(a)}t.push({name:"list",props:{items:s,spacing:{after:120}}})}return{name:"docx",props:{metadata:{title:"Generation Warnings"},theme:"minimal"},children:t}}function Yv({open:e,onClose:t,nonSafeFonts:n,onChoose:r}){const[i,s]=je.useState("custom");je.useEffect(()=>{e&&s("custom")},[e]);const o=n.length===1?n[0]:n.slice(0,3).join(", ")+(n.length>3?` +${n.length-3} more`:""),a=[{value:"custom",title:"Keep custom fonts",desc:"Recipients with the font installed see the authored typeface. Others get a generic fallback."},{value:"substitute",title:"Convert to safe fonts",desc:"Rewrite non-safe families to Calibri / Georgia / Consolas so every recipient sees the same glyphs."}];return c.jsx(ct,{open:e,onOpenChange:l=>!l&&t(),children:c.jsxs(lt,{className:"max-w-md",children:[c.jsxs(qt,{children:[c.jsx(Gt,{children:"Non-safe fonts in this document"}),c.jsxs(dn,{children:[o," ",n.length===1?"is":"are"," not in the built-in safe list. Choose how to export."]})]}),c.jsx("div",{className:"grid gap-2 py-2",children:a.map(l=>{const u=i===l.value;return c.jsxs("button",{type:"button",onClick:()=>s(l.value),className:`text-left rounded-md border px-3 py-2 transition-colors ${u?"border-primary bg-primary/5":"border-border hover:bg-muted/40"}`,children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:`h-3.5 w-3.5 rounded-full border flex items-center justify-center ${u?"border-primary":"border-muted-foreground/50"}`,children:u&&c.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary"})}),c.jsx("span",{className:"text-sm font-medium",children:l.title})]}),c.jsx("p",{className:"mt-1 text-xs text-muted-foreground pl-6",children:l.desc})]},l.value)})}),c.jsxs(kn,{children:[c.jsx(Ee,{variant:"outline",size:"sm",onClick:t,children:"Cancel"}),c.jsx(Ee,{size:"sm",onClick:()=>{r(i),t()},children:"Download"})]})]})})}function Xv(e){const t=e.hasPendingDiff?"Review the proposed change first":e.parses?void 0:"The visual view needs the JSON to parse";return{view:t?"json":e.preferred??"visual",forcedReason:t}}function Qv(e){try{const t=JSON.parse(e);return!!t&&typeof t=="object"&&!Array.isArray(t)}catch{return!1}}function ew(){const e=yr(l=>l.setSettings),t=yr(l=>l.themeEditorView),n=ke(l=>l.activeTab&&l.documentTypes[l.activeTab]==="application/json+theme"?l.activeTab:""),r=ke(l=>{if(!n)return!0;const u=l.documents.find(d=>d.name===n);return u?Qv(u.text):!0}),i=ke(l=>!!n&&l.pendingDiffs[n]!==void 0),s=x.useCallback(l=>e({themeEditorView:l}),[e]);if(!n)return null;const{view:o,forcedReason:a}=Xv({preferred:t,parses:r,hasPendingDiff:i});return c.jsxs("div",{role:"tablist","aria-label":"Theme editor view",title:a,className:"flex h-7 shrink-0 items-center rounded-sm border border-border/70 bg-muted/60 p-0.5",children:[c.jsx(uc,{active:o==="visual",disabled:a!==void 0,onClick:()=>s("visual"),icon:Ox,label:"Visual"}),c.jsx(uc,{active:o==="json",onClick:()=>s("json"),icon:ns,label:"JSON"})]})}function uc({active:e,disabled:t,onClick:n,icon:r,label:i}){return c.jsxs("button",{type:"button",role:"tab","aria-selected":e,"aria-label":i,disabled:t,onClick:n,className:W("flex h-6 cursor-pointer items-center gap-1.5 rounded-[3px] px-2 text-xs transition-colors","focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none","disabled:cursor-not-allowed disabled:opacity-50",e?"bg-background text-foreground shadow-xs":"text-muted-foreground hover:text-foreground"),children:[c.jsx(r,{className:"size-3.5"}),c.jsx("span",{className:"hidden md:inline",children:i})]})}const tw=je.memo(ew);function uo(){return c.jsx("span",{className:"rounded-sm bg-warning/15 px-1 py-px text-[10px] font-semibold uppercase leading-none tracking-wide text-warning",children:"experimental"})}function dc(){return c.jsx("span",{className:"rounded-sm bg-muted px-1 py-px text-[10px] font-semibold uppercase leading-none tracking-wide text-muted-foreground",children:"default"})}function nw({name:e,blob:t,onManualRender:n,isGenerating:r,isRendering:i,onShowCacheMetrics:s,onShowSchemas:o,onShowFonts:a,documentText:l,editorDocumentText:u,editorDocumentName:d,warnings:f,onToggleChat:h,chatOpen:p,onTogglePreview:g,previewOpen:k}){const[S,y]=x.useState(!1),[j,m]=x.useState(!1),[A,C]=x.useState(!1),[v,w]=x.useState(!1),[O,B]=x.useState(!1),[N,R]=x.useState(null),{toast:T}=Cr(),F=pd(),{generateDocument:z}=Wv(),M=x.useContext(ka),D=Gv(),J=yr(K=>K.generationBackend),Z=yr(K=>K.setSettings),X=J??D.default??void 0,_=x.useCallback(()=>{const K={},{customThemes:pe}=M.getState();return Object.values(pe).forEach(fe=>{fe.valid&&fe.parsed&&(K[fe.name]=fe.parsed)}),K},[M]),ye=je.useMemo(()=>{if(!l)return[];try{const K=JSON.parse(l);return[...(at==="pptx"?$g:Mg)(K)].filter(fe=>!Fg(fe))}catch{return[]}},[l]),[ce,b]=x.useState(!1),G=x.useCallback(async()=>{if(t){y(!0);try{await new Promise(K=>setTimeout(K,100)),oi(`${e}${$r}`,t)}finally{setTimeout(()=>y(!1),500)}}},[t,e]),ne=x.useCallback(async()=>{if(t){if(ye.length===0){await G();return}b(!0)}},[t,ye.length,G]),Q=x.useCallback(async K=>{var pe;if(l){y(!0);try{const fe=await z(e,l,_(),void 0,{bypassCache:!0,fonts:{mode:K}});if(fe.blob.size===0)T({title:"Export failed",description:"The server returned an empty document.",variant:"destructive"});else{oi(`${e}${$r}`,fe.blob);const Re=(pe=fe.warnings)==null?void 0:pe.find(Oe=>{var $e,E;return(($e=Oe.context)==null?void 0:$e.code)==="FONT_MODE_SUBSTITUTED"||((E=Oe.context)==null?void 0:E.code)==="FONT_MODE_CUSTOM"});Re&&T({title:K==="substitute"?"Fonts substituted":"Non-safe fonts kept",description:Re.message})}}catch(fe){T({title:"Export failed",description:fe instanceof Error?fe.message:String(fe),variant:"destructive"})}finally{setTimeout(()=>y(!1),500)}}},[l,e,z,T,_]),oe=x.useCallback(async()=>{if(!(!f||f.length===0)){m(!0);try{const K=Kv(f);if(!K){T({title:"No warnings",description:"There are no warnings to download.",variant:"destructive"});return}const pe=await z("warnings",JSON.stringify(K,null,2),{});pe&&typeof pe=="object"&&"blob"in pe&&pe.blob&&(oi(`${e}-warnings${$r}`,pe.blob),T({title:"Warnings downloaded",description:`Downloaded warnings document with ${f.length} warning(s).`}))}catch(K){console.error("Failed to generate warnings document:",K),T({title:"Download failed",description:K instanceof Error?K.message:"Failed to generate warnings document",variant:"destructive"})}finally{setTimeout(()=>m(!1),500)}}},[f,e,z,T]),I=x.useCallback(async()=>{C(!0);try{await Vv.delete(`/${at}/cache`),window.dispatchEvent(new CustomEvent("cache:cleared")),T({title:"Cache Cleared",description:"All active caches have been successfully cleared.",variant:"default"})}catch(K){console.error("Failed to clear cache:",K),T({title:"Cache Clear Failed",description:"Failed to clear caches. Please try again.",variant:"destructive"})}finally{C(!1)}},[T]),re=u??l,ae=x.useCallback(()=>{var fe,Re;if(!re){T({title:"No document available",description:"Please select a document to copy standard components",variant:"destructive"});return}try{JSON.parse(re)}catch{T({title:"Document is not valid JSON",description:"Fix the JSON errors in the editor, then copy again",variant:"destructive"});return}B(!0);const K=(async()=>{const Oe=_(),$e=await Bo(re,{customThemes:Oe}),E=await fetch(`/api/${at}/standard-components`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonDefinition:$e.text,customThemes:Oe,options:{sourceName:F(d??e)}})});if(!E.ok){let V=`Request failed with status ${E.status}`;try{const se=await E.json(),ie=se.error??se.message;typeof ie=="string"&&ie&&(V=ie)}catch{}throw new Error(V)}const P=await E.json();return JSON.stringify(P.data,null,2)})();let pe;typeof ClipboardItem<"u"&&((fe=navigator.clipboard)!=null&&fe.write)?pe=navigator.clipboard.write([new ClipboardItem({"text/plain":K.then(Oe=>new Blob([Oe],{type:"text/plain"}))})]):(Re=navigator.clipboard)!=null&&Re.writeText?pe=K.then(Oe=>navigator.clipboard.writeText(Oe)):pe=Promise.reject(new Error("Clipboard is not available in this context")),(async()=>{try{await pe,T({title:"Copied to clipboard",description:"Standard components JSON has been copied"})}catch(Oe){let $e=null;try{$e=await K}catch(E){console.error("Error fetching standard components:",E),T({title:"Failed to get standard components",description:E instanceof Error?E.message:"Request failed",variant:"destructive"});return}console.error("Clipboard write failed:",Oe),R($e)}finally{B(!1)}})()},[re,e,d,F,_,T]),H=x.useCallback(async()=>{if(N!=null)try{await navigator.clipboard.writeText(N),T({title:"Copied to clipboard",description:"Standard components JSON has been copied"}),R(null)}catch{T({title:"Clipboard unavailable",description:"Select the JSON in the dialog and copy it manually",variant:"destructive"})}},[N,T]);return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"bg-sidebar border-b flex flex-row flex-nowrap items-center justify-between gap-x-2 px-3 py-1.5",children:[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(Ye,{children:[c.jsx(Xe,{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-sm hover:bg-muted/60 shrink-0",children:c.jsx(nf,{className:"h-3.5 w-3.5 text-muted-foreground"})})}),c.jsx(Qe,{className:"max-w-sm",children:c.jsxs("p",{className:"text-sm",children:["Preview converts the file to a PDF with LibreOffice. Download the ",$r," to verify fidelity."]})})]})]}),c.jsxs("div",{className:"flex flex-row items-center gap-x-1 shrink-0",children:[c.jsx(tw,{}),c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsxs(Ee,{variant:"default",size:"sm",className:"gap-1.5 h-7 px-2.5",onClick:n,"aria-label":"Render preview",disabled:r||i||k===!1,children:[i?c.jsx(cn,{size:"sm"}):c.jsx(Px,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Run"})]})}),c.jsx(Qe,{children:c.jsx("p",{children:k===!1?"Open preview to run":i?"Rendering preview...":"Render preview"})})]}),c.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsxs(Ee,{variant:"outline",size:"sm",className:"gap-1.5 h-7 px-2.5",disabled:!t||S||r,onClick:ne,children:[S?c.jsx(cn,{size:"sm"}):c.jsx(Dx,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Download"})]})}),c.jsx(Qe,{children:c.jsxs("p",{children:["Download ",$r]})})]}),f&&f.length>0&&c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx(Ee,{variant:"outline",size:"icon",className:"h-7 w-7 border-transparent bg-warning/10 text-warning hover:bg-warning/20",disabled:j||r,onClick:oe,children:j?c.jsx(cn,{size:"sm"}):c.jsx(sf,{className:"h-3.5 w-3.5"})})}),c.jsx(Qe,{children:c.jsxs("p",{children:["Download warnings (",f.length,")"]})})]}),D.ids.length>1&&c.jsxs(fi,{value:X,onValueChange:K=>Z({generationBackend:K}),children:[c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsxs(br,{"aria-label":"Renderer",className:"hidden h-7 w-auto min-h-0 gap-1.5 px-2 text-xs lg:flex [&>span]:flex [&>span]:items-center [&>span]:gap-1.5 [&>span]:whitespace-nowrap",children:[c.jsx($o,{className:"h-3.5 w-3.5 shrink-0 opacity-60"}),c.jsxs(pi,{placeholder:"Renderer",children:[c.jsx("span",{className:"font-medium",children:X}),X!==D.default&&c.jsx(uo,{})]})]})}),c.jsx(Qe,{children:c.jsxs("p",{children:["Renderer that writes the ",at.toUpperCase()," file. A non-default one may refuse a document it cannot express."]})})]}),c.jsx(vr,{className:"min-w-[var(--radix-select-trigger-width)] text-sidebar-foreground",children:c.jsxs(uf,{children:[c.jsx(Ea,{className:"px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Renderer"}),D.ids.map(K=>c.jsx(Mn,{value:K,className:"text-xs",children:c.jsxs("span",{className:"flex items-center gap-1.5 whitespace-nowrap",children:[c.jsx("span",{className:"font-medium",children:K}),K===D.default?c.jsx(dc,{}):c.jsx(uo,{})]})},K))]})})]}),c.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),c.jsxs(Ti,{children:[c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx(Ii,{asChild:!0,children:c.jsx(Ee,{variant:"ghost",size:"icon",className:"h-7 w-7",children:c.jsx(ja,{className:"h-3.5 w-3.5"})})})}),c.jsx(Qe,{children:c.jsx("p",{children:"More actions"})})]}),c.jsxs(Ar,{align:"end",className:"w-52",children:[o&&c.jsxs($t,{onClick:o,children:[c.jsx(Rx,{className:"h-4 w-4 mr-2"}),"View JSON Schemas"]}),a&&c.jsxs($t,{onClick:a,children:[c.jsx(Ro,{className:"h-4 w-4 mr-2"}),"Browse fonts"]}),s&&c.jsxs($t,{onClick:s,children:[c.jsx(Mo,{className:"h-4 w-4 mr-2"}),"View cache metrics"]}),re?c.jsxs($t,{onClick:ae,disabled:O,children:[c.jsx(Fo,{className:"h-4 w-4 mr-2"}),O?"Copying...":"Copy standard components"]}):c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx("span",{className:"block",children:c.jsxs($t,{disabled:!0,children:[c.jsx(Fo,{className:"h-4 w-4 mr-2"}),"Copy standard components"]})})}),c.jsx(Qe,{side:"left",children:c.jsx("p",{children:"No document selected — open or select a document first"})})]}),c.jsx(Fn,{}),c.jsxs($t,{onClick:()=>w(!0),disabled:A,className:"text-destructive focus:text-destructive",children:[c.jsx(_a,{className:"h-4 w-4 mr-2"}),A?"Clearing...":"Clear all caches"]}),D.ids.length>1&&c.jsxs(c.Fragment,{children:[c.jsx(Fn,{className:"lg:hidden"}),c.jsx($a,{className:"lg:hidden px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Renderer"}),D.ids.map(K=>c.jsxs($t,{className:"lg:hidden gap-1.5",onClick:()=>Z({generationBackend:K}),children:[c.jsx(un,{className:`h-3.5 w-3.5 shrink-0 ${X===K?"opacity-100":"opacity-0"}`}),c.jsx("span",{className:"font-medium",children:K}),K===D.default?c.jsx(dc,{}):c.jsx(uo,{})]},K))]})]})]}),g&&c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx(Ee,{variant:k?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:g,children:k?c.jsx(of,{className:"h-3.5 w-3.5"}):c.jsx($x,{className:"h-3.5 w-3.5"})})}),c.jsx(Qe,{children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[k?"Hide":"Show"," Preview"," ",c.jsx(mi,{shortcut:"mod+shift+p"})]})})]}),h&&c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx(Ee,{variant:p?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:h,children:c.jsx(af,{className:"h-3.5 w-3.5"})})}),c.jsx(Qe,{children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[p?"Close":"Open"," AI Chat"," ",c.jsx(mi,{shortcut:"mod+shift+j"})]})})]})]})]}),c.jsx(Yv,{open:ce,onClose:()=>b(!1),nonSafeFonts:ye,onChoose:Q}),c.jsx(ct,{open:N!=null,onOpenChange:K=>{K||R(null)},children:c.jsxs(lt,{className:"max-w-lg",children:[c.jsxs(qt,{children:[c.jsx(Gt,{children:"Standard components"}),c.jsx(dn,{children:"The browser blocked the automatic clipboard write. Copy the JSON from here instead."})]}),c.jsx(jp,{readOnly:!0,value:N??"",className:"h-64 font-mono text-xs",onFocus:K=>K.currentTarget.select()}),c.jsxs(kn,{children:[c.jsx(Ee,{variant:"outline",size:"sm",onClick:()=>R(null),children:"Close"}),c.jsx(Ee,{size:"sm",onClick:H,children:"Copy to clipboard"})]})]})}),c.jsx(ct,{open:v,onOpenChange:w,children:c.jsxs(lt,{className:"max-w-sm",children:[c.jsxs(qt,{children:[c.jsx(Gt,{children:"Clear all caches?"}),c.jsx(dn,{children:"This will clear the document, component, and rasterized-visual caches. Next generation will be uncached."})]}),c.jsxs(kn,{children:[c.jsx(Ee,{variant:"outline",size:"sm",onClick:()=>w(!1),children:"Cancel"}),c.jsx(Ee,{variant:"destructive",size:"sm",disabled:A,onClick:async()=>{await I(),w(!1)},children:A?c.jsx(cn,{size:"sm"}):"Clear"})]})]})})]})}const rw=je.memo(nw),_p=ox,Ua=x.forwardRef(({className:e,...t},n)=>c.jsx(qd,{ref:n,className:W("bg-muted text-muted-foreground inline-flex h-9 items-center justify-center rounded-sm p-1",e),...t}));Ua.displayName=qd.displayName;const hr=x.forwardRef(({className:e,...t},n)=>c.jsx(Gd,{ref:n,className:W("ring-offset-background focus-visible:ring-ring data-[state=active]:bg-background data-[state=active]:text-foreground inline-flex cursor-pointer items-center justify-center rounded-sm px-3 py-1 text-sm font-medium whitespace-nowrap transition-all focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50",e),...t}));hr.displayName=Gd.displayName;const mr=x.forwardRef(({className:e,...t},n)=>c.jsx(Kd,{ref:n,className:W("ring-offset-background focus-visible:ring-ring mt-2 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",e),...t}));mr.displayName=Kd.displayName;async function iw(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 sw(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 ow(e){const t=sw(e);return iw(t)}const aw=({open:e,onOpenChange:t,defaultTab:n="document"})=>{const[r,i]=x.useState(n),[s,o]=x.useState(null),[a,l]=x.useState(null),[u,d]=x.useState(!1),[f,h]=x.useState(!1),[p,g]=x.useState(null),[k,S]=x.useState(null),[y,j]=x.useState(!1),{toast:m}=Cr(),A=Jt(D=>D.selectedPlugins),C=Array.from(A),v=vn(jg);x.useEffect(()=>{n&&i(n)},[n]);const w=x.useCallback(async()=>{d(!0),g(null);try{const D=await Qs.fetchDocumentSchema(C,_g(vn.getState()));o(D)}catch(D){const J=D instanceof Error?D.message:"Failed to load document schema";g(J),m({variant:"destructive",title:"Error loading schema",description:J})}finally{d(!1)}},[C,v,m]),O=x.useCallback(async()=>{if(!a){h(!0),S(null);try{const D=await Qs.fetchThemeSchema();l(D)}catch(D){const J=D instanceof Error?D.message:"Failed to load theme schema";S(J),m({variant:"destructive",title:"Error loading schema",description:J})}finally{h(!1)}}},[a,m]),[B,N]=x.useState([]),[R,T]=x.useState(v);x.useEffect(()=>{e||(o(null),g(null))},[e]),x.useEffect(()=>{if(!e)return;const D=C.length!==B.length||C.some((Z,X)=>Z!==B[X]),J=v!==R;r==="document"?(!s||D||J)&&((D||J)&&(Qs.clearPluginSchemaCache(),N([...C]),T(v)),u||w()):r==="theme"&&!a&&!f&&O()},[r,e,s,a,u,f,C,B,v,R,w,O]);const F=C.length,z=r==="document"?s:a,M=async()=>{if(z)try{await ow(z)&&(j(!0),m({title:"Schema copied",description:"The JSON schema has been copied to your clipboard"}),setTimeout(()=>j(!1),2e3))}catch(D){console.error("Copy failed:",D)}};return c.jsx(ct,{open:e,onOpenChange:t,children:c.jsxs(lt,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[c.jsx(qt,{children:c.jsx(Gt,{children:"Schema Viewer"})}),c.jsxs(_p,{value:r,onValueChange:D=>i(D),className:"flex-1 overflow-hidden flex flex-col",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Ua,{children:[c.jsxs(hr,{value:"document",className:"flex items-center gap-1",children:["Document",F>0&&c.jsxs(tn,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:["+",F]})]}),c.jsx(hr,{value:"theme",children:"Theme"})]}),c.jsx("div",{className:"ml-auto",children:c.jsx(Ee,{variant:"ghost",size:"icon",onClick:M,disabled:y||!z,"aria-label":"Copy schema",children:y?c.jsx(un,{className:"h-4 w-4"}):c.jsx(zs,{className:"h-4 w-4"})})})]}),c.jsxs("div",{className:"flex-1 overflow-auto mt-4",children:[c.jsx(mr,{value:"document",className:"h-full",children:c.jsx(ds,{schema:s,loading:u,error:p||void 0})}),c.jsx(mr,{value:"theme",className:"h-full",children:c.jsx(ds,{schema:a,loading:f,error:k||void 0})})]})]})]})})};function Ja(e,t){var r;const n=lf.getState().getEditor(e);return(r=n==null?void 0:n.flushPendingSave)==null||r.call(n),n?n.toStorageValue(n.editor.getValue()):t}function Np(e,t,n){if(t.length===0)return n;const r=fc(e,t[0]);let i=r;for(let s=0;s<t.length-1;s++){const o=t[s],a=t[s+1],l=i[o],u=fc(l,a);i[o]=u,i=u}return i[t[t.length-1]]=n,r}function fc(e,t){return typeof t=="number"?Array.isArray(e)?[...e]:[]:e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{}}const pc=2*1024*1024,hc=12*1024*1024;function lw(e){if(e.length<4)return"unknown";const[t,n,r,i]=e;return t===0&&n===1&&r===0&&i===0||t===116&&n===114&&r===117&&i===101||t===116&&n===116&&r===99&&i===102?"ttf":t===79&&n===84&&r===84&&i===79?"otf":t===119&&n===79&&r===70&&i===70?"woff":t===119&&n===79&&r===70&&i===50?"woff2":"unknown"}function cw(e){let n="";for(let r=0;r<e.length;r+=32768)n+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(n)}function hs(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${Math.round(e/1024)} KB`}function uw(e,t){if(t.length===0)return{ok:!1,message:`"${e}" is empty.`};if(t.length>pc)return{ok:!1,message:`"${e}" is ${hs(t.length)}. The limit is ${hs(pc)} per font, because the bytes travel inside the document JSON.`};const n=lw(t);return n==="woff"||n==="woff2"?{ok:!1,message:`"${e}" is a ${n.toUpperCase()} file. Upload the TTF or OTF instead — the preview renderer cannot register web font formats.`}:n!=="ttf"&&n!=="otf"?{ok:!1,message:`"${e}" does not look like a TTF or OTF font file.`}:{ok:!0,format:n,base64:cw(t)}}const dw=new Set(["italic","oblique"]);function fw(e){const t=e.replace(/\.[^.]+$/,""),n=t.split(/[-_\s]+/).filter(Boolean),r=new Map;for(const[o,a]of Object.entries(gd))r.set(a.toLowerCase(),Number(o));let i=400,s=!1;for(;n.length>1;){const o=n[n.length-1].toLowerCase();if(dw.has(o)){s=!0,n.pop();continue}const a=r.get(o);if(a!==void 0){i=a,n.pop();continue}break}return{family:n.join(" ")||t,weight:i,italic:s}}function pw(e,t){const n=Array.isArray(e)?[...e]:[],r=n.findIndex(i=>{var s;return((s=i==null?void 0:i.family)==null?void 0:s.toLowerCase())===t.family.toLowerCase()});return r>=0?n[r]=t:n.push(t),n}function hw(e){return e.kind==="safe"||e.kind==="google"?null:{weight:"weight"in e&&e.weight?e.weight:400,italic:"italic"in e?!!e.italic:!1}}function mw(e,t,n,r){const i=((e==null?void 0:e.sources)??[]).filter(a=>{const l=hw(a);return l?!n.some(u=>u.weight===l.weight&&u.italic===l.italic):!0}),s=n.map(a=>({kind:"data",data:a.data,weight:a.weight,italic:a.italic})),o=r??(e==null?void 0:e.category);return{id:(e==null?void 0:e.id)??t,family:t,...o?{category:o}:{},sources:[...i,...s]}}function gw(e,t){let n=Array.isArray(e)?[...e]:[];for(const r of t){const i=r.sources.filter(o=>o.kind==="data").map(o=>({data:o.data,weight:o.weight??400,italic:o.italic??!1}));if(i.length===0)continue;const s=n.find(o=>{var a;return((a=o==null?void 0:o.family)==null?void 0:a.toLowerCase())===r.family.toLowerCase()});n=pw(n,mw(s,r.family,i,r.category))}return n}function xw(e,t){const n=(e.sources??[]).filter(r=>r.format==="ttf"||r.format==="otf").map(r=>({kind:"data",data:r.data,weight:r.weight,italic:r.italic}));return n.length===0?null:{id:e.family,family:e.family,...t?{category:t}:{},sources:n}}function yw(e){const t=new TextEncoder().encode(e).length;return t<=hc?null:`Adding this font would push the document to ${hs(t)}, past the ${hs(hc)} limit. Remove a font from props.fontRegistry, or use fewer weights.`}const mc=new Set,bw=(e,t,n)=>`${e.toLowerCase()}|${t}|${n?"i":"r"}`;function gc(e,t){var d;if(typeof document>"u"||!e.trim())return;const n=`gf-${e.replace(/\s+/g,"-")}`,r=document.getElementById(n),i=new Set(t&&t.length>0?t:[400,700]),s=new Set(((d=r==null?void 0:r.dataset.weights)==null?void 0:d.split(",").map(Number).filter(f=>!Number.isNaN(f)))??[]),o=new Set([...s,...i]);if(r&&o.size===s.size)return;const a=[...o].sort((f,h)=>f-h).join(";"),l=`https://fonts.googleapis.com/css2?family=${encodeURIComponent(e)}:wght@${a}&display=swap`,u=r??document.createElement("link");r||(u.id=n,u.rel="stylesheet",document.head.appendChild(u)),u.href=l,u.dataset.weights=[...o].sort((f,h)=>f-h).join(",")}function vw(e){const t=e.startsWith("data:")?e.slice(e.indexOf(",")+1):e,n=atob(t),r=new Uint8Array(n.length);for(let i=0;i<n.length;i++)r[i]=n.charCodeAt(i);return r}async function ww(e,t,n,r){const i=bw(e,n,r);if(!mc.has(i))try{if(typeof FontFace>"u"||!(document!=null&&document.fonts))return;const s=vw(t),o=new FontFace(e,s.buffer,{weight:String(n),style:r?"italic":"normal"});await o.load(),document.fonts.add(o),mc.add(i)}catch{}}const kw={safe:[],google:[]};function Sw(){const e=ke(i=>i.activeTab),t=ke(i=>i.documents),n=ke(i=>i.documentTypes),r=ke(i=>i.saveDocument);return x.useCallback(i=>{if(!e)return{ok:!1,error:"No active file"};if(n[e]!=="application/json+theme")return{ok:!1,error:"Fonts are registered on themes, not documents. Open a .theme.json file and try again."};const s=t.find(u=>u.name===e);if(!s)return{ok:!1,error:"Active theme not found"};const o=Ja(e,s.text);let a;try{a=JSON.parse(o)}catch(u){return{ok:!1,error:`Active theme is not valid JSON: ${u.message}`}}const l=i(a);return r(e,JSON.stringify(l,null,2)),{ok:!0,name:e}},[e,t,n,r])}function jw(){const e=ke(r=>r.activeTab),t=ke(r=>r.documents),n=ke(r=>r.saveDocument);return x.useCallback((r,i)=>{if(!e)return{ok:!1,error:"No active file"};const s=t.find(u=>u.name===e);if(!s)return{ok:!1,error:"Active document not found"};const o=Ja(e,s.text);let a;try{a=JSON.parse(o)}catch(u){return{ok:!1,error:`Active document is not valid JSON: ${u.message}`}}const l=Np(a,r,i);return n(e,JSON.stringify(l,null,2)),{ok:!0,name:e}},[e,t,n])}function _w(){const e=ke(i=>i.activeTab),t=ke(i=>i.documents),n=ke(i=>i.documentTypes),r=ke(i=>i.saveDocument);return x.useCallback(i=>{var h;if(i.length===0)return{ok:!0,name:e};if(!e)return{ok:!1,error:"No active file"};if(n[e]==="application/json+theme")return{ok:!1,error:"Custom fonts are registered on the document, not the theme. Open the .docx.json / .pptx.json tab and try again."};const s=t.find(p=>p.name===e);if(!s)return{ok:!1,error:"Active document not found"};const o=Ja(e,s.text);let a;try{a=JSON.parse(o)}catch(p){return{ok:!1,error:`Active document is not valid JSON: ${p.message}`}}const l=gw((h=a==null?void 0:a.props)==null?void 0:h.fontRegistry,i),u=Np(a,["props","fontRegistry"],l),d=JSON.stringify(u,null,2),f=yw(d);return f?{ok:!1,error:f}:(r(e,d),{ok:!0,name:e})},[e,t,n,r])}function Nw(e,t,n){(!e.fonts||typeof e.fonts!="object")&&(e.fonts={});const r=e.fonts[t];r&&typeof r=="object"?e.fonts[t]={...r,family:n}:e.fonts[t]=n}function xc(e){return e.map((t,n)=>typeof t=="number"?`[${t}]`:n===0?t:`.${t}`).join("")}const Ew=({open:e,onOpenChange:t})=>{const n=Gi(I=>I.open),r=Gi(I=>I.contextual),i=Gi(I=>I.close),s=e??n,o=r,a=x.useCallback(I=>{t&&t(I),I||i()},[t,i]),[l,u]=x.useState(kw),[d,f]=x.useState(!1),[h,p]=x.useState(""),[g,k]=x.useState("safe"),[S,y]=x.useState(null),[j,m]=x.useState(null),[A,C]=x.useState(!1),[v,w]=x.useState(!1),[O,B]=x.useState(""),[N,R]=x.useState([]),T=x.useRef(null),{toast:F}=Cr(),z=Sw(),M=jw(),D=_w(),J=ke(I=>I.activeTab),Z=ke(I=>I.documentTypes),X=J&&Z[J]==="application/json+theme",_=!!o||X;x.useEffect(()=>{s&&(l.safe.length>0||l.google.length>0||(f(!0),fetch(ui.fonts.catalog).then(I=>I.json()).then(I=>u(I)).catch(I=>{F({variant:"destructive",title:"Font catalog unavailable",description:I.message})}).finally(()=>f(!1))))},[s,l,F]),x.useEffect(()=>{if(!(g!=="google"||l.google.length===0))for(const I of l.google)gc(I.family,I.weights)},[g,l]);const ye=x.useMemo(()=>l.safe.filter(I=>I.toLowerCase().includes(h.toLowerCase())),[l.safe,h]),ce=x.useMemo(()=>l.google.filter(I=>I.family.toLowerCase().includes(h.toLowerCase())),[l.google,h]),b=x.useCallback(async I=>{try{await navigator.clipboard.writeText(I),m(I),setTimeout(()=>m(null),1500)}catch{F({variant:"destructive",title:"Copy failed",description:"Your browser blocked clipboard write."})}},[F]),G=x.useCallback(async(I,re,ae)=>{y(I);try{const H=z(K=>(Nw(K,ae,I),K));if(!H.ok){F({variant:"destructive",title:"Could not insert font",description:H.error});return}F({title:"Font inserted",description:`${I} set as ${ae} font in "${H.name}".`})}finally{y(null)}},[z,F]),ne=x.useCallback(async I=>{if(o){y(I);try{const re=M(o.jsonPath,I);if(!re.ok){F({variant:"destructive",title:"Could not insert font",description:re.error});return}F({title:"Font inserted",description:`${I} set at ${xc(o.jsonPath)}.`}),a(!1)}finally{y(null)}}},[o,M,F,a]),Q=x.useCallback(async I=>{if(!(!I||I.length===0)){C(!0);try{const re=[];for(const H of Array.from(I)){const K=new Uint8Array(await H.arrayBuffer()),pe=uw(H.name,K);if(!pe.ok){F({variant:"destructive",title:"Font rejected",description:pe.message});continue}re.push({identity:fw(H.name),base64:pe.base64})}if(re.length===0)return;const ae=D(re.map(({identity:H,base64:K})=>({id:H.family,family:H.family,sources:[{kind:"data",data:K,weight:H.weight,italic:H.italic}]})));if(!ae.ok){F({variant:"destructive",title:"Could not register font",description:ae.error});return}for(const{identity:H,base64:K}of re)ww(H.family,K,H.weight,H.italic),F({title:`Added ${H.family}`,description:`Registered at weight ${H.weight}${H.italic?" italic":""} in props.fontRegistry. Reference it as "${H.family}".`})}catch(re){F({variant:"destructive",title:"Upload failed",description:re.message})}finally{C(!1),T.current&&(T.current.value="")}}},[D,F]),oe=x.useCallback(async()=>{var re,ae;const I=O.trim();if(I){w(!0),R([]);try{const H=await fetch(ui.fonts.materialize,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({family:I,weights:[400,700],italics:!1})});if(H.status===429)throw new Error("Too many font fetches — the playground allows 20 every 15 minutes. Try again shortly.");if(!H.ok){const Oe=await H.json().catch(()=>({}));throw new Error(Oe.error??`Materialize failed (${H.status})`)}const K=await H.json();R(K.warnings??[]);const pe=(re=l.google.find(Oe=>Oe.family.toLowerCase()===K.family.toLowerCase()))==null?void 0:re.category,fe=xw(K,pe);if(!fe){F({variant:"destructive",title:"Nothing to embed",description:((ae=K.warnings)==null?void 0:ae.join(" · "))||`Google Fonts has no family named "${I}".`});return}const Re=D([fe]);if(!Re.ok){F({variant:"destructive",title:"Could not register font",description:Re.error});return}gc(K.family,[400,700]),F({title:`Added ${K.family}`,description:`Embedded ${fe.sources.length} weight(s) in props.fontRegistry.`})}catch(H){F({variant:"destructive",title:"Google Fonts fetch failed",description:H.message})}finally{w(!1)}}},[O,l.google,D,F]);return c.jsx(ct,{open:s,onOpenChange:a,children:c.jsxs(lt,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[c.jsx(qt,{children:c.jsx(Gt,{children:o?`Font for ${xc(o.jsonPath)}`:"Fonts"})}),!o&&!X&&g!=="custom"&&c.jsx(ur,{children:c.jsxs(dr,{children:["Fonts are registered on themes. Open a ",c.jsx("code",{children:".theme.json"})," ","file to apply a font — the buttons below are disabled until you do."]})}),c.jsxs(_p,{value:g,onValueChange:I=>k(I),className:"flex-1 overflow-hidden flex flex-col",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Ua,{children:[c.jsxs(hr,{value:"safe",children:["Safe",c.jsx(tn,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:l.safe.length})]}),c.jsxs(hr,{value:"google",children:["Google",c.jsx(tn,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:l.google.length})]}),c.jsx(hr,{value:"custom",children:"Custom"})]}),c.jsx(wr,{type:"search",placeholder:"Search fonts...",value:h,onChange:I=>p(I.target.value),className:"ml-auto max-w-xs"})]}),c.jsxs("div",{className:"flex-1 overflow-auto mt-4 pr-2",children:[c.jsx(mr,{value:"safe",className:"m-0",children:d&&ye.length===0?c.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[c.jsx(Gr,{className:"animate-spin mr-2"})," Loading catalog..."]}):c.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:ye.map(I=>c.jsx(yc,{family:I,meta:c.jsx("span",{className:"text-xs",children:"Installed with Office"}),previewStyle:{fontFamily:`"${I}", sans-serif`},onCopy:()=>b(I),copied:j===I,contextual:!!o,onUseThis:()=>ne(I),onInsertHeading:()=>G(I,"safe","heading"),onInsertBody:()=>G(I,"safe","body"),applying:S===I,disabled:!_},I))})}),c.jsx(mr,{value:"google",className:"m-0",children:d&&ce.length===0?c.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[c.jsx(Gr,{className:"animate-spin mr-2"})," Loading catalog..."]}):c.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:ce.map(I=>c.jsx(yc,{family:I.family,meta:c.jsxs("span",{className:"text-xs",children:[I.category," · ",I.weights.length," weights"]}),previewStyle:{fontFamily:`"${I.family}", sans-serif`},onCopy:()=>b(I.family),copied:j===I.family,contextual:!!o,onUseThis:()=>ne(I.family),onInsertHeading:()=>G(I.family,"google","heading"),onInsertBody:()=>G(I.family,"google","body"),applying:S===I.family,disabled:!_,extraAction:c.jsx(Tw,{family:I.family,weights:I.weights,hasItalic:I.hasItalic})},I.family))})}),c.jsx(mr,{value:"custom",className:"m-0 flex flex-col gap-6",children:X?c.jsx(ur,{children:c.jsxs(dr,{children:["Custom fonts are stored on the document (",c.jsx("code",{children:"props.fontRegistry"}),"), because the bytes travel with the JSON. Open a document tab to add one."]})}):c.jsxs(c.Fragment,{children:[c.jsxs("section",{className:"flex flex-col gap-2",children:[c.jsx("h3",{className:"text-sm font-medium",children:"Upload a font file"}),c.jsxs("p",{className:"text-xs text-muted-foreground",children:["TTF or OTF, up to 2 MB each. The font is embedded in the document as base64, so it survives export and re-import — and renders in the preview. The family and weight are guessed from the filename (e.g."," ",c.jsx("code",{children:"Geist-SemiBold.ttf"}),")."]}),c.jsxs("div",{onDragOver:I=>I.preventDefault(),onDrop:I=>{I.preventDefault(),Q(I.dataTransfer.files)},className:"rounded-md border border-dashed p-6 text-center",children:[c.jsx("input",{ref:T,type:"file",accept:".ttf,.otf,font/ttf,font/otf",multiple:!0,className:"hidden",onChange:I=>void Q(I.target.files)}),c.jsxs(Ee,{variant:"secondary",disabled:A,onClick:()=>{var I;return(I=T.current)==null?void 0:I.click()},children:[A?c.jsx(Gr,{className:"animate-spin mr-2 h-4 w-4"}):c.jsx(Mx,{className:"mr-2 h-4 w-4"}),"Choose font files"]}),c.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"or drop them here"})]})]}),c.jsxs("section",{className:"flex flex-col gap-2",children:[c.jsx("h3",{className:"text-sm font-medium",children:"Embed any Google font"}),c.jsxs("p",{className:"text-xs text-muted-foreground",children:["Not limited to the ",l.google.length," curated families — type any Google Fonts family name and its regular and bold weights are fetched and embedded."]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(wr,{placeholder:"e.g. Geist",value:O,onChange:I=>B(I.target.value),onKeyDown:I=>{I.key==="Enter"&&oe()}}),c.jsxs(Ee,{onClick:()=>void oe(),disabled:v||O.trim()==="",children:[v&&c.jsx(Gr,{className:"animate-spin mr-2 h-4 w-4"}),"Embed"]})]}),N.length>0&&c.jsx(ur,{children:c.jsx(dr,{className:"text-xs",children:N.join(" · ")})})]})]})})]})]})]})})},Cw="The quick brown fox jumps over the lazy dog",Tw=({family:e,weights:t,hasItalic:n})=>{const r=x.useMemo(()=>[...t].sort((i,s)=>i-s),[t]);return c.jsxs(Ti,{children:[c.jsx(Ii,{asChild:!0,children:c.jsx(Ee,{size:"sm",variant:"ghost","aria-label":"Show variants",children:"Variants"})}),c.jsxs(Ar,{align:"end",className:"min-w-[260px]",children:[c.jsxs($a,{className:"text-xs text-muted-foreground",children:[r.length," weight",r.length===1?"":"s",n?" · italic available":""]}),c.jsx(Fn,{}),r.map(i=>{const s=gd[i]??String(i);return c.jsxs("div",{className:"flex flex-col gap-0.5 px-2 py-1.5",children:[c.jsx("span",{className:"truncate",style:{fontFamily:`"${e}", sans-serif`,fontWeight:i},children:s}),c.jsxs("span",{className:"text-xs text-muted-foreground font-mono",children:["fontWeight: ",i]})]},i)})]})]})},yc=({family:e,meta:t,previewStyle:n,onCopy:r,copied:i,contextual:s,onUseThis:o,onInsertHeading:a,onInsertBody:l,applying:u,disabled:d,extraAction:f})=>c.jsxs("div",{className:"border rounded-md p-3 flex flex-col gap-2 bg-card",children:[c.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[c.jsx("div",{className:"font-medium truncate",children:e}),c.jsx("div",{className:"text-muted-foreground",children:t})]}),c.jsx("div",{className:"text-lg truncate",style:n,"aria-hidden":!0,children:Cw}),c.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s?c.jsx(Ee,{size:"sm",onClick:o,disabled:u||d,"aria-label":`Use ${e} at the target path`,children:"Use this font"}):c.jsxs(c.Fragment,{children:[c.jsx(Ee,{size:"sm",variant:"secondary",onClick:a,disabled:u||d,"aria-label":`Set ${e} as heading font`,children:"Set heading"}),c.jsx(Ee,{size:"sm",variant:"secondary",onClick:l,disabled:u||d,"aria-label":`Set ${e} as body font`,children:"Set body"})]}),f,c.jsx(Ee,{size:"sm",variant:"ghost",className:"ml-auto",onClick:r,"aria-label":`Copy ${e}`,children:i?c.jsx(un,{className:"h-4 w-4"}):c.jsx(zs,{className:"h-4 w-4"})})]})]});function bc({previewOpen:e,onTogglePreview:t}){const n=an(v=>v.name||""),r=an(v=>v.blob),i=an(v=>v.isGenerating),s=an(v=>v.text),o=an(v=>v.warnings),a=an(v=>v.isRendering),l=yr(v=>v.useGlobalPreviewHeader??!0),u=ke(v=>v.activeTab),d=ke(v=>v.documentTypes),f=u&&d[u]==="application/json+theme"?"theme":"document",h=ke(v=>{var w;return v.activeTab&&(v.documentTypes[v.activeTab]??"application/json+report")==="application/json+report"?(w=v.documents.find(O=>O.name===v.activeTab))==null?void 0:w.text:void 0}),p=ke(v=>v.activeTab&&(v.documentTypes[v.activeTab]??"application/json+report")==="application/json+report"?v.activeTab:void 0),g=De(v=>v.chatOpen),k=De(v=>v.toggleChat),[S,y]=je.useState(!1),j=Gi(v=>v.openFor);if(!l)return null;const m=x.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:manualRender"))},[]),A=x.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:showCacheMetrics"))},[]),C=(n==null?void 0:n.trim())||"Preview";return c.jsxs("div",{className:"sticky top-0 z-20",children:[c.jsx(rw,{name:C,blob:r,onManualRender:m,isGenerating:i,isRendering:!!a,onShowCacheMetrics:A,onShowSchemas:()=>y(!0),onShowFonts:()=>j(),documentText:s,editorDocumentText:h,editorDocumentName:p,warnings:o,onToggleChat:k,chatOpen:g,onTogglePreview:t,previewOpen:e}),c.jsx(aw,{open:S,onOpenChange:y,defaultTab:f==="theme"?"theme":"document"}),c.jsx(Ew,{})]})}function Iw(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Aw=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,zw=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ow={};function vc(e,t){return(Ow.jsx?zw:Aw).test(e)}const Pw=/[ \t\n\f\r]/g;function Dw(e){return typeof e=="object"?e.type==="text"?wc(e.value):!1:wc(e)}function wc(e){return e.replace(Pw,"")===""}class Ai{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Ai.prototype.normal={};Ai.prototype.property={};Ai.prototype.space=void 0;function Ep(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Ai(n,r,t)}function Qo(e){return e.toLowerCase()}class _t{constructor(t,n){this.attribute=n,this.property=t}}_t.prototype.attribute="";_t.prototype.booleanish=!1;_t.prototype.boolean=!1;_t.prototype.commaOrSpaceSeparated=!1;_t.prototype.commaSeparated=!1;_t.prototype.defined=!1;_t.prototype.mustUseProperty=!1;_t.prototype.number=!1;_t.prototype.overloadedBoolean=!1;_t.prototype.property="";_t.prototype.spaceSeparated=!1;_t.prototype.space=void 0;let Rw=0;const Ne=Zn(),rt=Zn(),ea=Zn(),te=Zn(),Ze=Zn(),gr=Zn(),Et=Zn();function Zn(){return 2**++Rw}const ta=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ne,booleanish:rt,commaOrSpaceSeparated:Et,commaSeparated:gr,number:te,overloadedBoolean:ea,spaceSeparated:Ze},Symbol.toStringTag,{value:"Module"})),fo=Object.keys(ta);class Ha extends _t{constructor(t,n,r,i){let s=-1;if(super(t,n),kc(this,"space",i),typeof r=="number")for(;++s<fo.length;){const o=fo[s];kc(this,fo[s],(r&ta[o])===ta[o])}}}Ha.prototype.defined=!0;function kc(e,t,n){n&&(e[t]=n)}function zr(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new Ha(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Qo(r)]=r,n[Qo(s.attribute)]=r}return new Ai(t,n,e.space)}const Cp=zr({properties:{ariaActiveDescendant:null,ariaAtomic:rt,ariaAutoComplete:null,ariaBusy:rt,ariaChecked:rt,ariaColCount:te,ariaColIndex:te,ariaColSpan:te,ariaControls:Ze,ariaCurrent:null,ariaDescribedBy:Ze,ariaDetails:null,ariaDisabled:rt,ariaDropEffect:Ze,ariaErrorMessage:null,ariaExpanded:rt,ariaFlowTo:Ze,ariaGrabbed:rt,ariaHasPopup:null,ariaHidden:rt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ze,ariaLevel:te,ariaLive:null,ariaModal:rt,ariaMultiLine:rt,ariaMultiSelectable:rt,ariaOrientation:null,ariaOwns:Ze,ariaPlaceholder:null,ariaPosInSet:te,ariaPressed:rt,ariaReadOnly:rt,ariaRelevant:null,ariaRequired:rt,ariaRoleDescription:Ze,ariaRowCount:te,ariaRowIndex:te,ariaRowSpan:te,ariaSelected:rt,ariaSetSize:te,ariaSort:null,ariaValueMax:te,ariaValueMin:te,ariaValueNow:te,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Tp(e,t){return t in e?e[t]:t}function Ip(e,t){return Tp(e,t.toLowerCase())}const $w=zr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:gr,acceptCharset:Ze,accessKey:Ze,action:null,allow:null,allowFullScreen:Ne,allowPaymentRequest:Ne,allowUserMedia:Ne,alt:null,as:null,async:Ne,autoCapitalize:null,autoComplete:Ze,autoFocus:Ne,autoPlay:Ne,blocking:Ze,capture:null,charSet:null,checked:Ne,cite:null,className:Ze,cols:te,colSpan:null,content:null,contentEditable:rt,controls:Ne,controlsList:Ze,coords:te|gr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ne,defer:Ne,dir:null,dirName:null,disabled:Ne,download:ea,draggable:rt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ne,formTarget:null,headers:Ze,height:te,hidden:ea,high:te,href:null,hrefLang:null,htmlFor:Ze,httpEquiv:Ze,id:null,imageSizes:null,imageSrcSet:null,inert:Ne,inputMode:null,integrity:null,is:null,isMap:Ne,itemId:null,itemProp:Ze,itemRef:Ze,itemScope:Ne,itemType:Ze,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ne,low:te,manifest:null,max:null,maxLength:te,media:null,method:null,min:null,minLength:te,multiple:Ne,muted:Ne,name:null,nonce:null,noModule:Ne,noValidate:Ne,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:Ne,optimum:te,pattern:null,ping:Ze,placeholder:null,playsInline:Ne,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ne,referrerPolicy:null,rel:Ze,required:Ne,reversed:Ne,rows:te,rowSpan:te,sandbox:Ze,scope:null,scoped:Ne,seamless:Ne,selected:Ne,shadowRootClonable:Ne,shadowRootDelegatesFocus:Ne,shadowRootMode:null,shape:null,size:te,sizes:null,slot:null,span:te,spellCheck:rt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:te,step:null,style:null,tabIndex:te,target:null,title:null,translate:null,type:null,typeMustMatch:Ne,useMap:null,value:rt,width:te,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ze,axis:null,background:null,bgColor:null,border:te,borderColor:null,bottomMargin:te,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ne,declare:Ne,event:null,face:null,frame:null,frameBorder:null,hSpace:te,leftMargin:te,link:null,longDesc:null,lowSrc:null,marginHeight:te,marginWidth:te,noResize:Ne,noHref:Ne,noShade:Ne,noWrap:Ne,object:null,profile:null,prompt:null,rev:null,rightMargin:te,rules:null,scheme:null,scrolling:rt,standby:null,summary:null,text:null,topMargin:te,valueType:null,version:null,vAlign:null,vLink:null,vSpace:te,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ne,disableRemotePlayback:Ne,prefix:null,property:null,results:te,security:null,unselectable:null},space:"html",transform:Ip}),Mw=zr({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:Et,accentHeight:te,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:te,amplitude:te,arabicForm:null,ascent:te,attributeName:null,attributeType:null,azimuth:te,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:te,by:null,calcMode:null,capHeight:te,className:Ze,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:te,diffuseConstant:te,direction:null,display:null,dur:null,divisor:te,dominantBaseline:null,download:Ne,dx:null,dy:null,edgeMode:null,editable:null,elevation:te,enableBackground:null,end:null,event:null,exponent:te,externalResourcesRequired:null,fill:null,fillOpacity:te,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:gr,g2:gr,glyphName:gr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:te,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:te,horizOriginX:te,horizOriginY:te,id:null,ideographic:te,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:te,k:te,k1:te,k2:te,k3:te,k4:te,kernelMatrix:Et,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:te,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:te,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:te,overlineThickness:te,paintOrder:null,panose1:null,path:null,pathLength:te,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ze,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:te,pointsAtY:te,pointsAtZ:te,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Et,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Et,rev:Et,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Et,requiredFeatures:Et,requiredFonts:Et,requiredFormats:Et,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:te,specularExponent:te,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:te,strikethroughThickness:te,string:null,stroke:null,strokeDashArray:Et,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:te,strokeOpacity:te,strokeWidth:null,style:null,surfaceScale:te,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Et,tabIndex:te,tableValues:null,target:null,targetX:te,targetY:te,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Et,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:te,underlineThickness:te,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:te,values:null,vAlphabetic:te,vMathematical:te,vectorEffect:null,vHanging:te,vIdeographic:te,version:null,vertAdvY:te,vertOriginX:te,vertOriginY:te,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:te,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Tp}),Ap=zr({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()}}),zp=zr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Ip}),Op=zr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Fw={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"},Lw=/[A-Z]/g,Sc=/-[a-z]/g,Bw=/^data[-\w.:]+$/i;function Vw(e,t){const n=Qo(t);let r=t,i=_t;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Bw.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(Sc,Uw);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!Sc.test(s)){let o=s.replace(Lw,Zw);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=Ha}return new i(r,t)}function Zw(e){return"-"+e.toLowerCase()}function Uw(e){return e.charAt(1).toUpperCase()}const Jw=Ep([Cp,$w,Ap,zp,Op],"html"),Wa=Ep([Cp,Mw,Ap,zp,Op],"svg");function Hw(e){return e.join(" ").trim()}var Yn={},po,jc;function Ww(){if(jc)return po;jc=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,a=/^\s+|\s+$/g,l=`
|
|
154
|
+
`)[0].trim();return i.length>t?`${i.slice(0,t-1)}…`:i}function Rb(e){const t=It(Ae(e,"columns"));if(t.length>0)return`${Math.max(0,...t.map(i=>It(Ae(i,"cells")).length))}×${t.length}`;const n=It(Ae(e,"rows"));if(n.length>0){const r=n[0],i=(r==null?void 0:r.type)==="array"?It(r).length:It(Ae(r,"cells")).length;return i>0?`${n.length}×${i}`:`${n.length} rows`}}function $b(e){const t=ot(Ae(e,"alt"));if(t)return St(t);const n=ot(Ae(e,"src"));if(n){if(n.startsWith("data:")){const i=n.slice(5).split(/[;,]/)[0];return i?`image (${i.split("/").pop()})`:"image"}const r=n.split(/[?#]/)[0].split("/").pop();if(r)return St(r,40)}return"image"}function Mb(e,t){var r;const n=ot(Ae(t,"text"));switch(e){case"heading":{const i=Yo(Ae(t,"level"))??1;return{label:n?St(n):"heading",detail:`H${i}`}}case"text":return{label:n?St(n):"text",detail:ot(Ae(t,"style"))};case"paragraph":return{label:n?St(n):"paragraph"};case"chart":case"highcharts":{const i=ot(Ae(t,"title"))??ot(Ae(Ae(t,"options"),"title"));return{label:i?St(i):e,detail:ot(Ae(t,"type"))}}case"table":return{label:"table",detail:Rb(t)};case"image":return{label:$b(t)};case"shape":return{label:ot(Ae(t,"type"))??"shape"};case"list":{const i=It(Ae(t,"items"));return{label:"list",detail:i.length>0?`${i.length} items`:void 0}}case"section":{const i=ot(Ae(Ae(t,"meta"),"title"))??ot(Ae(t,"title"));return{label:i?St(i):"section"}}case"statistic":{const i=ot(Ae(t,"value"))??((r=Yo(Ae(t,"value")))==null?void 0:r.toString()),s=ot(Ae(t,"label"));return{label:St(s??i??"statistic"),detail:i}}default:return{label:n?St(n):e}}}function kr(e){if(e.type!=="object")return null;const t=ot(Ae(e,"name"));return t?{name:t,props:Ae(e,"props"),childrenArr:Ae(e,"children")}:null}function Fb(e){let t;for(const n of It(e)){const r=kr(n);if(!r)continue;const i=ot(Ae(r.props,"text"));if(i){if(r.name==="heading"||r.name==="text")return St(i,48);r.name==="paragraph"&&t===void 0&&(t=St(i,48))}}return t}function cs(e,t,n){let{label:r,detail:i}=Mb(t.name,t.props);return r===t.name&&t.childrenArr&&(r=Fb(t.childrenArr)??r),{id:"",kind:t.name,label:r,detail:i,start:e.offset,end:e.offset+e.length,children:Kf(t.childrenArr),reorder:n}}function Kf(e){if(!e||e.type!=="array")return[];const t=`arr@${e.offset}`,n=[];for(const r of It(e)){const i=kr(r);i&&n.push(cs(r,i,{groupId:t,sliceStart:r.offset,sliceEnd:r.offset+r.length}))}return n}function Lb(e){const t=Ae(e,"props"),n=ot(Ae(Ae(t,"meta"),"title"));if(n)return St(n,48,!0);let r;const i=(a,l)=>{l&&(!r||a<r.rank)&&(r={rank:a,text:l})},s=Ae(t,"placeholders");if((s==null?void 0:s.type)==="object"&&s.children)for(const a of s.children){if(a.type!=="property"||!a.children)continue;const[l,u]=a.children,d=typeof(l==null?void 0:l.value)=="string"?l.value:"",f=u?kr(u):null,h=f?ot(Ae(f.props,"text")):void 0;i(d==="title"?0:d==="subtitle"||d.startsWith("heading")?1:2,h)}const o=(a,l)=>{const u=kr(a);if(u){if(u.name==="text"||u.name==="heading"){const d=ot(Ae(u.props,"text"));if(d){const f=ot(Ae(u.props,"style"))??"";i(f==="title"?0:f.startsWith("heading")?1:2,d)}}if(l<1)for(const d of It(u.childrenArr))o(d,l+1)}};for(const a of It(Ae(e,"children")))o(a,0);return r?St(r.text,48,!0):void 0}function Bb(e){const t=Ae(e,"children");if(!t||t.type!=="array")return[];const n=`arr@${t.offset}`,r=[];let i=0;for(const s of It(t)){const o=kr(s);if(!o)continue;const a={groupId:n,sliceStart:s.offset,sliceEnd:s.offset+s.length};o.name==="slide"?(i+=1,r.push({id:"",kind:"slide",label:Lb(s)??`Slide ${i}`,detail:`${i}`,start:s.offset,end:s.offset+s.length,children:Kf(o.childrenArr),reorder:a})):r.push(cs(s,o,a))}return r}function Vb(e){const t=Ae(e,"children");if(!t||t.type!=="array")return[];const n=`arr@${t.offset}`,r=[],i=[];for(const o of It(t)){const a=kr(o);if(!a)continue;const l={groupId:n,sliceStart:o.offset,sliceEnd:o.offset+o.length},u=()=>i.length?i[i.length-1].node.children:r;if(a.name==="heading"){const d=Yo(Ae(a.props,"level"))??1;for(;i.length&&i[i.length-1].level>=d;)i.pop();const f=cs(o,a,l);u().push(f),i.push({level:d,node:f})}else u().push(cs(o,a,l))}const s=o=>{o.children.forEach(s);const a=o.children[o.children.length-1];o.kind==="heading"&&a&&(o.end=Math.max(o.end,a.end),o.reorder&&a.reorder&&(o.reorder.sliceEnd=Math.max(o.reorder.sliceEnd,a.reorder.sliceEnd)))};return r.forEach(s),r}function Vl(e){switch(e.type){case"string":return St(String(e.value??""),24);case"number":case"boolean":return String(e.value);case"array":return`${It(e).length} items`;case"object":return;default:return}}function Zb(e){if(e.type!=="object"||!e.children)return[];const t=[];for(const n of e.children){if(n.type!=="property"||!n.children)continue;const[r,i]=n.children,s=typeof(r==null?void 0:r.value)=="string"?r.value:void 0;if(!s||s==="$schema"||!i)continue;const o=[];if(i.type==="object"&&i.children)for(const a of i.children){if(a.type!=="property"||!a.children)continue;const[l,u]=a.children,d=typeof(l==null?void 0:l.value)=="string"?l.value:void 0;!d||!u||o.push({id:"",kind:"key",label:d,detail:Vl(u),start:a.offset,end:a.offset+a.length,children:[]})}t.push({id:"",kind:"key",label:s,detail:o.length===0?Vl(i):void 0,start:n.offset,end:n.offset+n.length,children:o})}return t}function Zl(e,t,n){if(!e.trim())return[];const r=Ob(e,[],{allowTrailingComma:!0});if(!r)return[];const i=n==="theme"?Zb(r):t==="pptx"?Bb(r):Vb(r);return Yf(i,""),i}function Yf(e,t){e.forEach((n,r)=>{n.id=t?`${t}.${r}`:`${r}`,Yf(n.children,n.id)})}function Xf(e,t){const n=[];let r=e;for(;;){const i=r.find(s=>t>=s.start&&t<s.end);if(!i)return n;n.push(i.id),r=i.children}}function Ub(e,t){const n=new Set;for(const r of t)for(const i of Xf(e,r))n.add(i);return n}function Jb(e,t,n,r){if(n===r||n<0||r<0||n>=t.length||r>=t.length)return null;const i=t.map(d=>d.reorder);if(i.some(d=>!d))return null;const s=i[0].groupId;if(i.some(d=>d.groupId!==s))return null;for(let d=1;d<i.length;d++)if(i[d].sliceStart<i[d-1].sliceEnd)return null;const o=i.map(d=>e.slice(d.sliceStart,d.sliceEnd)),a=[];for(let d=1;d<i.length;d++){const f=e.slice(i[d-1].sliceEnd,i[d].sliceStart);if((f.match(/,/g)??[]).length!==1)return null;a.push(f)}const l=o.map((d,f)=>f);l.splice(r,0,l.splice(n,1)[0]);let u="";return l.forEach((d,f)=>{u+=o[d],f<a.length&&(u+=a[f])}),{start:i[0].sliceStart,end:i[i.length-1].sliceEnd,text:u}}const Hb={slide:yx,heading:xx,text:Ro,paragraph:gx,chart:Mo,highcharts:Mo,table:mx,image:hx,shape:tf,list:px,toc:fx,section:$o,columns:$o,"text-box":Ro,statistic:dx,key:ns};function Wb(e,t){let n=e,r=null;for(const i of t.split(".")){if(r=n[Number(i)]??null,!r)return null;n=r.children}return r}function qb(e){const t=e.lastIndexOf(".");return t===-1?"":e.slice(0,t)}function Gb(){const{activeTab:e,documentTypes:t}=ke(Na(w=>({activeTab:w.activeTab,documentTypes:w.documentTypes}))),n=ke(w=>{var O;return w.activeTab?(O=w.documents.find(B=>B.name===w.activeTab))==null?void 0:O.text:void 0}),r=lf(w=>e?w.editors.get(e)??null:null),i=e&&t[e]==="application/json+theme"?"theme":"document",[s,o]=x.useState([]),[a,l]=x.useState(null),[u,d]=x.useState(()=>new Set),[f,h]=x.useState(()=>new Set),[p,g]=x.useState(null),k=x.useRef(s);k.current=s;const S=x.useRef(null),y=x.useRef(null),j=x.useCallback(()=>{var B;if(!e){o([]);return}const w=((B=r==null?void 0:r.editor.getModel())==null?void 0:B.getValue())??n??"",O=Zl(w,at,i);if(o(O),y.current!==e){y.current=e;const N=new Set;if(i==="document"&&at==="docx")for(const R of O)R.kind==="heading"&&N.add(R.id);h(N),l(null)}},[e,r,n,i]);x.useEffect(()=>{j();const w=r==null?void 0:r.editor.getModel();if(!w)return;const O=kl(j,300),B=w.onDidChangeContent(()=>O());return()=>{O.cancel(),B.dispose()}},[j,r]),x.useEffect(()=>{if(!r)return;const{editor:w}=r,O=kl(()=>{const N=w.getModel(),R=w.getPosition();if(!N||!R)return;const T=N.getOffsetAt(R),F=Xf(k.current,T);if(F.length===0){l(null);return}l(F[F.length-1]);const z=F.slice(0,-1);z.length&&h(M=>{if(z.every(J=>M.has(J)))return M;const D=new Set(M);for(const J of z)D.add(J);return D})},150),B=w.onDidChangeCursorPosition(()=>O());return()=>{O.cancel(),B.dispose()}},[r]),x.useEffect(()=>{if(!a||!S.current)return;const w=S.current.querySelector(`[data-oid="${CSS.escape(a)}"]`);w==null||w.scrollIntoView({block:"nearest"})},[a]),x.useEffect(()=>{if(!r){d(new Set);return}const{editor:w,monaco:O}=r,B=()=>{const R=w.getModel();if(!R)return;const T=O.editor.getModelMarkers({resource:R.uri}).filter(F=>F.severity===O.MarkerSeverity.Error).map(F=>R.getOffsetAt({lineNumber:F.startLineNumber,column:F.startColumn}));d(Ub(k.current,T))};B();const N=O.editor.onDidChangeMarkers(R=>{const T=w.getModel();T&&R.some(F=>F.toString()===T.uri.toString())&&B()});return()=>N.dispose()},[r,s]);const m=x.useCallback(w=>{h(O=>{const B=new Set(O);return B.has(w)?B.delete(w):B.add(w),B})},[]),A=x.useCallback(w=>{if(l(w.id),!r)return;const{editor:O,monaco:B}=r,N=O.getModel();if(!N)return;const R=N.getPositionAt(w.start),T=N.getPositionAt(w.end),F=new B.Range(R.lineNumber,R.column,T.lineNumber,T.column);O.revealRangeNearTopIfOutsideViewport(F,B.editor.ScrollType.Smooth),O.setPosition(R),O.focus();const z=O.deltaDecorations([],[{range:F,options:{className:"jto-outline-flash"}}]);window.setTimeout(()=>O.deltaDecorations(z,[]),700)},[r]),C=x.useCallback(w=>{var ye;if(!r||!w.overId)return;const{editor:O,monaco:B,collapse:N}=r,R=O.getModel();if(!R)return;const T=R.getValue(),F=Zl(T,at,i),z=w.parentId?((ye=Wb(F,w.parentId))==null?void 0:ye.children)??[]:F,M=z.findIndex(ce=>ce.id===w.dragId),D=z.findIndex(ce=>ce.id===w.overId);if(M===-1||D===-1)return;let J=D+(w.overHalf==="after"?1:0);M<J&&(J-=1);const Z=Jb(T,z,M,J);if(!Z)return;const X=R.getPositionAt(Z.start),_=R.getPositionAt(Z.end);O.executeEdits("outline-reorder",[{range:new B.Range(X.lineNumber,X.column,_.lineNumber,_.column),text:Z.text}]),N==null||N.resyncDecorations()},[r,i]),v=x.useMemo(()=>{const w=[],O=(B,N,R)=>{var z,M;const T=(M=(z=B[0])==null?void 0:z.reorder)==null?void 0:M.groupId,F=B.length>1&&T!==void 0&&B.every(D=>{var J;return((J=D.reorder)==null?void 0:J.groupId)===T});B.forEach(D=>{const J=Hb[D.kind]??bx,Z=D.children.length>0,X=f.has(D.id),_=a===D.id,ye=(p==null?void 0:p.overId)===D.id;w.push(c.jsxs("div",{"data-oid":D.id,role:"treeitem","aria-selected":_,"aria-expanded":Z?X:void 0,tabIndex:0,draggable:F,onClick:()=>A(D),onKeyDown:ce=>{(ce.key==="Enter"||ce.key===" ")&&(ce.preventDefault(),A(D)),ce.key==="ArrowRight"&&Z&&!X&&m(D.id),ce.key==="ArrowLeft"&&Z&&X&&m(D.id)},onDragStart:ce=>{ce.dataTransfer.setData("text/plain",D.id),ce.dataTransfer.effectAllowed="move",g({dragId:D.id,parentId:R,overId:null,overHalf:"before"})},onDragOver:ce=>{if(!p||p.dragId===D.id||qb(p.dragId)!==R)return;ce.preventDefault(),ce.dataTransfer.dropEffect="move";const b=ce.currentTarget.getBoundingClientRect(),G=ce.clientY<b.top+b.height/2?"before":"after";(p.overId!==D.id||p.overHalf!==G)&&g({...p,overId:D.id,overHalf:G})},onDrop:ce=>{ce.preventDefault(),p&&C({...p,overId:D.id,overHalf:p.overHalf}),g(null)},onDragEnd:()=>g(null),className:W("group flex h-6 w-full cursor-pointer items-center gap-1 rounded-sm pr-1","text-[12px] text-sidebar-foreground/80 transition-colors select-none","hover:bg-sidebar-accent hover:text-sidebar-foreground","focus-visible:ring-sidebar-ring focus-visible:ring-1 focus-visible:outline-none",_&&"bg-sidebar-accent font-medium text-sidebar-foreground",ye&&(p==null?void 0:p.overHalf)==="before"&&"shadow-[inset_0_2px_0_hsl(var(--ring))]",ye&&(p==null?void 0:p.overHalf)==="after"&&"shadow-[inset_0_-2px_0_hsl(var(--ring))]"),style:{paddingLeft:4+N*12},children:[Z?c.jsx("span",{role:"button","aria-label":X?"Collapse":"Expand",onClick:ce=>{ce.stopPropagation(),m(D.id)},className:"flex size-3.5 shrink-0 items-center justify-center rounded-xs text-sidebar-foreground/55 hover:text-sidebar-foreground",children:c.jsx(Ir,{className:W("size-3 transition-transform",X&&"rotate-90")})}):c.jsx("span",{className:"size-3.5 shrink-0"}),D.kind==="slide"&&c.jsx("span",{className:"w-3 shrink-0 text-right text-[10px] tabular-nums text-sidebar-foreground/50",children:D.detail}),c.jsx(J,{className:"size-3.5 shrink-0 text-sidebar-foreground/55"}),c.jsx("span",{className:"min-w-0 flex-1 truncate",children:D.label}),D.kind!=="slide"&&D.detail&&c.jsx("span",{className:"shrink-0 text-[10px] text-sidebar-foreground/50",children:D.detail}),u.has(D.id)&&c.jsx("span",{"aria-label":"Contains validation errors",className:"bg-destructive size-1.5 shrink-0 rounded-full"})]},D.id)),Z&&X&&O(D.children,N+1,D.id)})};return O(s,0,""),w},[s,f,a,u,p,A,m,C]);return!e||s.length===0?null:c.jsx("li",{className:"list-none",children:c.jsx("div",{ref:S,role:"tree","aria-label":`Outline of ${e}`,className:"border-sidebar-border/70 my-0.5 ml-[15px] max-h-[38vh] overflow-y-auto border-l pl-1",children:v})})}const Ul=x.memo(Gb);async function Kb(e,t){const n=JSON.stringify({name:e,props:t,children:[]},null,2);await navigator.clipboard.writeText(n)}const hi=x.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Hd,{ref:r,className:W("relative overflow-hidden",e),...n,children:[c.jsx(tx,{className:"h-full w-full rounded-[inherit]",children:t}),c.jsx(Qf,{}),c.jsx(nx,{})]}));hi.displayName=Hd.displayName;const Qf=x.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(Wd,{ref:r,orientation:t,className:W("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(rx,{className:"bg-border relative flex-1 rounded-full"})}));Qf.displayName=Wd.displayName;function Fa({className:e,...t}){return c.jsx(ix,{"data-slot":"switch",className:W("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-switch-off focus-visible:ring-ring inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent transition-colors outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 cursor-pointer",e),...t,children:c.jsx(sx,{"data-slot":"switch-thumb",className:W("bg-background pointer-events-none block size-4 rounded-full shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}const Yb=Ei("relative w-full rounded-sm border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-card text-foreground",destructive:"border-transparent bg-destructive-bg text-destructive-bg-foreground [&>svg]:text-destructive-bg-foreground",warning:"border-transparent bg-warning-bg text-warning-bg-foreground [&>svg]:text-warning-bg-foreground",success:"border-transparent bg-success-bg text-success-bg-foreground [&>svg]:text-success-bg-foreground",info:"border-transparent bg-data-blue-bg text-data-blue-bg-foreground [&>svg]:text-data-blue-bg-foreground"}},defaultVariants:{variant:"default"}}),ur=x.forwardRef(({className:e,variant:t,...n},r)=>c.jsx("div",{ref:r,role:"alert",className:W(Yb({variant:t}),e),...n}));ur.displayName="Alert";const Xb=x.forwardRef(({className:e,...t},n)=>c.jsx("h5",{ref:n,className:W("mb-1 font-medium leading-none tracking-tight",e),...t}));Xb.displayName="AlertTitle";const dr=x.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:W("text-sm [&_p]:leading-relaxed",e),...t}));dr.displayName="AlertDescription";const us=x.memo(({keyName:e,value:t,depth:n=0,isLast:r=!1})=>{const[i,s]=x.useState(n<2),o=t!==null&&typeof t=="object",a=Array.isArray(t),l=()=>s(!i),u=()=>t===null?c.jsx("span",{className:"text-muted-foreground",children:"null"}):t===void 0?c.jsx("span",{className:"text-muted-foreground",children:"undefined"}):typeof t=="boolean"?c.jsx("span",{className:"text-warning",children:String(t)}):typeof t=="number"?c.jsx("span",{className:"text-success",children:t}):typeof t=="string"?t.startsWith("http")?c.jsxs("span",{className:"text-data-blue",children:['"',t,'"']}):t.startsWith("#/")?c.jsxs("span",{className:"text-warning",children:['"',t,'"']}):c.jsxs("span",{className:"text-destructive",children:['"',t,'"']}):null,d=o?Object.keys(t).length:0;return c.jsxs("div",{className:W("text-sm",n>0&&"ml-4"),children:[c.jsxs("div",{className:"flex items-start hover:bg-muted/30 rounded-sm px-1 py-0.5",children:[o&&c.jsx("button",{onClick:l,className:"mr-1 hover:bg-muted rounded-sm p-0.5","aria-label":i?"Collapse":"Expand",children:i?c.jsx(Ni,{className:"h-3 w-3"}):c.jsx(Ir,{className:"h-3 w-3"})}),!o&&c.jsx("span",{className:"w-4"}),e&&c.jsxs(c.Fragment,{children:[c.jsxs("span",{className:"text-data-blue",children:['"',e,'"']}),c.jsx("span",{className:"mx-1",children:":"})]}),o?c.jsxs("span",{className:"text-muted-foreground",children:[a?"[":"{",!i&&c.jsxs("span",{className:"mx-1 text-xs",children:[d," ",a?"items":"properties"]}),!i&&(a?"]":"}")]}):u(),!o&&!r&&c.jsx("span",{className:"text-muted-foreground",children:","})]}),o&&i&&c.jsxs("div",{className:"ml-4",children:[a?t.map((f,h)=>c.jsx(us,{keyName:String(h),value:f,depth:n+1,isLast:h===t.length-1},h)):Object.entries(t).map(([f,h],p,g)=>c.jsx(us,{keyName:f,value:h,depth:n+1,isLast:p===g.length-1},f)),c.jsx("div",{className:"ml-4",children:c.jsxs("span",{className:"text-muted-foreground",children:[a?"]":"}",!r&&","]})})]})]})});us.displayName="JsonNode";const ds=x.memo(({schema:e,loading:t=!1,error:n,className:r})=>t?c.jsxs("div",{className:W("space-y-4",r),children:[c.jsx(si,{className:"h-8 w-64"}),c.jsx(si,{className:"h-4 w-full"}),c.jsx(si,{className:"h-64 w-full"})]}):n?c.jsx(ur,{variant:"destructive",className:r,children:c.jsx(dr,{children:n})}):e?c.jsx(hi,{className:W("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(us,{value:e})})}):c.jsx(ur,{className:r,children:c.jsx(dr,{children:"No schema available"})}));ds.displayName="SchemaViewer";function Qb({plugins:e,initialFocusedPlugin:t}){var m,A;const n=Jt(C=>C.togglePlugin),r=Jt(C=>C.isPluginSelected),i=Jt(C=>C.selectedPlugins),s=Jt(C=>C.isApplyingPlugins),[o,a]=x.useState(null),[l,u]=x.useState(null),[d,f]=x.useState("properties");x.useEffect(()=>{if(t){const C=e.find(v=>v.name===t);if(C){a(C);return}}e.length>0&&!o&&a(e[0])},[t,e]);const h=x.useMemo(()=>{const C={current:[],downstream:[],upstream:[]};return e.forEach(v=>{C[v.location]&&C[v.location].push(v)}),C},[e]),p=async(C,v)=>{o&&(await Kb(o.name,C.props),u(v),setTimeout(()=>u(null),2e3))},g=C=>{switch(C){case"current":return"Current Directory";case"downstream":return"Project";case"upstream":return"Parent Directories";default:return C}},k=C=>{switch(C){case"current":return c.jsx(_x,{className:"size-3"});case"downstream":return c.jsx(jx,{className:"size-3"});case"upstream":return c.jsx(ef,{className:"size-3"});default:return null}},S=((m=o==null?void 0:o.schema)==null?void 0:m.properties)&&Object.keys(o.schema.properties).length>0,y=(A=o==null?void 0:o.schema)==null?void 0:A.jsonSchema,j=(o==null?void 0:o.examples)&&o.examples.length>0;return c.jsxs(c.Fragment,{children:[c.jsxs(qt,{children:[c.jsxs(Gt,{className:"flex items-center gap-2",children:[c.jsx(vx,{className:"size-5 text-warning"}),"Plugins",c.jsxs(tn,{variant:"secondary",className:"font-normal",children:[i.size," active"]})]}),c.jsxs(dn,{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(hi,{className:"h-full",children:c.jsx("div",{className:"p-2 space-y-3",children:Object.entries(h).map(([C,v])=>v.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:[k(C),g(C)]}),c.jsx("div",{className:"space-y-0.5",children:v.map(w=>{const O=r(w.name),B=(o==null?void 0:o.name)===w.name;return c.jsxs("button",{onClick:()=>a(w),className:W("w-full text-left px-2 py-1.5 rounded-md transition-colors cursor-pointer","flex items-center gap-2",B?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"),children:[c.jsx("div",{className:W("size-1.5 rounded-full flex-none transition-colors",O?"bg-warning":"bg-muted-foreground/30")}),c.jsx("span",{className:"text-sm font-medium truncate flex-1",children:w.name})]},w.name)})})]},C))})})}),o?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:o.name}),o.version&&c.jsxs(tn,{variant:"outline",className:"font-mono text-[11px] flex-none",children:["v",o.version]})]}),o.description&&c.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:o.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(o.name)?"On":"Off"}),c.jsx(Fa,{checked:r(o.name),onCheckedChange:()=>n(o),disabled:s,"aria-label":`Toggle ${o.name}`})]})]}),c.jsxs("div",{className:"flex items-center gap-1.5 mt-2 text-xs text-muted-foreground",children:[k(o.location),c.jsx("span",{children:g(o.location)}),c.jsx("span",{className:"text-muted-foreground/60 mx-1",children:"/"}),c.jsx("span",{className:"font-mono truncate",children:o.relativePath})]})]}),c.jsxs("div",{className:"flex-none px-5 pt-3 pb-0 flex gap-1 border-b bg-background",children:[S&&c.jsx("button",{onClick:()=>f("properties"),className:W("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",d==="properties"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(ns,{className:"size-3.5"}),"Properties"]})}),y&&c.jsx("button",{onClick:()=>f("schema"),className:W("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",d==="schema"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(wx,{className:"size-3.5"}),"Schema"]})}),j&&c.jsx("button",{onClick:()=>f("examples"),className:W("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",d==="examples"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(kx,{className:"size-3.5"}),"Examples",c.jsx(tn,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-4",children:o.examples.length})]})})]}),c.jsx(hi,{className:"flex-1",children:c.jsxs("div",{className:"p-5",children:[d==="properties"&&S&&c.jsx("div",{className:"space-y-1",children:Object.entries(o.schema.properties).map(([C,v])=>c.jsx(ev,{name:C,prop:v},C))}),d==="schema"&&y&&c.jsx(ds,{schema:o.schema.jsonSchema,loading:!1,className:"h-[420px]"}),d==="examples"&&j&&o.examples.map((C,v)=>c.jsxs("div",{className:W(v>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:[C.title&&c.jsx("span",{className:"font-medium text-sm truncate",children:C.title}),!C.title&&c.jsxs("span",{className:"text-sm text-muted-foreground",children:["Example ",v+1]})]}),c.jsx(Ee,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs flex-none",onClick:()=>p(C,v),children:l===v?c.jsxs(c.Fragment,{children:[c.jsx(Sx,{className:"size-3 mr-1 text-success"}),"Copied"]}):c.jsxs(c.Fragment,{children:[c.jsx(zs,{className:"size-3 mr-1"}),"Copy"]})})]}),C.description&&c.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:C.description}),c.jsx("pre",{className:"p-3 bg-muted rounded-md overflow-x-auto text-xs font-mono leading-relaxed",children:JSON.stringify(C.props,null,2)})]},v)),!S&&!y&&!j&&c.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[c.jsx(ns,{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 ev({name:e,prop:t}){var o;const[n,r]=x.useState(!1),i=t.description||t.enum||t.default!==void 0||t.items||t.properties,s=t.type||(t.enum?"enum":t.oneOf?"oneOf":"—");return c.jsxs("div",{className:"rounded-md border",children:[c.jsxs("button",{onClick:()=>i&&r(!n),className:W("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(Ni,{className:"size-3 text-muted-foreground flex-none"}):c.jsx(Ir,{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(tn,{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-destructive 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((a,l)=>c.jsxs("span",{children:[l>0&&", ",c.jsx("code",{className:"bg-muted px-1 rounded-sm",children:JSON.stringify(a)})]},l))]}),((o=t.items)==null?void 0:o.type)&&c.jsxs("p",{children:[c.jsx("span",{className:"font-medium text-foreground",children:"Items: "}),t.items.type]})]})]})}const tv={current:"Current directory",downstream:"Project"};function Jl({location:e}){return c.jsx("li",{className:"list-none px-2 pt-2 pb-0.5 text-[10px] tracking-[0.08em] text-sidebar-foreground/65 uppercase",children:tv[e]??e})}function Hl({name:e,subtitle:t,query:n,onSelect:r}){return c.jsx("li",{className:"list-none",children:c.jsxs("button",{type:"button",onClick:r,title:t?`${e} — ${t}`:e,"aria-label":`Add ${e} to workspace`,className:W("group/row flex h-7 w-full cursor-pointer items-center gap-2 rounded-sm pr-1 pl-2","text-[13px] text-sidebar-foreground/70 transition-colors","hover:bg-sidebar-accent/60 hover:text-sidebar-foreground","focus-visible:ring-sidebar-ring focus-visible:ring-1 focus-visible:outline-none"),children:[c.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:c.jsx(Rs,{text:e,query:n})}),c.jsx(Dt,{"aria-hidden":!0,className:"size-3.5 shrink-0 text-sidebar-foreground/45 opacity-0 transition-opacity group-hover/row:opacity-100 group-focus-visible/row:opacity-100"})]})})}function Wl({children:e}){return c.jsx("div",{className:"px-2 pt-2 pb-0.5 text-[10px] tracking-[0.08em] text-sidebar-foreground/65 uppercase",children:e})}function nv({document:e,query:t}){var B;const n=x.useRef(null),[r,i]=x.useState(!1),[s,o]=x.useState(!1),[a,l]=x.useState(!1),[u,d]=x.useState(!1),f=ke(N=>N.openDocument),h=ke(N=>N.activeTab),p=vn(N=>N.records[e.name]),g=vn(N=>N.setEnabled),k=h===e.name,S=(p==null?void 0:p.enabled)??!0,y=(p==null?void 0:p.status)??"idle",j=(B=p==null?void 0:p.metadata)==null?void 0:B.name,m=((p==null?void 0:p.diagnostics)??[]).filter(N=>N.severity==="error").length,A=y==="ready"?`Ready${j?` — used as "${j}"`:""}`:y==="error"?m>0?`${m} error${m===1?"":"s"} — open to fix`:"Failed to load — open to fix":y==="compiling"?"Compiling…":"Not compiled yet",C=x.useCallback(N=>{g(e.name,N),window.dispatchEvent(new CustomEvent(Sg,{detail:{docName:e.name}}))},[e.name,g]),v=x.useMemo(()=>[{key:"open",label:"Open",run:()=>f(e.name)},{key:"download",label:"Download…",separatorBefore:!0,run:()=>oi(e.name,new Blob([e.text],{type:"text/typescript"}))},{key:"rename",label:"Rename…",separatorBefore:!0,run:()=>l(!0)},{key:"delete",label:"Delete",danger:!0,run:()=>d(!0)}],[e.name,e.text,f]),w=`browser-plugin-${e.name}`,O=r||s;return c.jsxs("li",{className:"group/menu-item relative list-none",children:[c.jsxs(Pf,{onOpenChange:o,children:[c.jsx(Df,{className:"block",children:c.jsxs("div",{className:W("flex h-7 w-full items-center gap-1 rounded-sm pr-1 pl-2 transition-colors","hover:bg-sidebar-accent/60",O&&"bg-sidebar-accent/60",k&&"bg-sidebar-accent font-medium"),title:`${e.name} — ${A}`,children:[k&&c.jsx("span",{"aria-hidden":!0,className:"bg-primary absolute top-1 bottom-1 left-0 w-[2px] rounded-full"}),c.jsxs("button",{ref:n,type:"button",onClick:()=>f(e.name),"aria-label":`${e.name} — ${A}`,className:W("flex h-7 min-w-0 flex-1 cursor-pointer items-center gap-2 text-[13px]","focus-visible:ring-sidebar-ring rounded-sm focus-visible:ring-1 focus-visible:outline-none",S?"text-sidebar-foreground/85":"text-sidebar-foreground/60"),children:[c.jsx(Qd,{className:W("size-3.5 shrink-0",k?"text-sidebar-accent-foreground/70":"text-sidebar-foreground/60")}),c.jsx("span",{className:"truncate",children:c.jsx(Rs,{text:e.name,query:t})}),y==="compiling"&&c.jsx(cn,{size:"sm",className:"shrink-0"}),y==="ready"&&c.jsx(Nx,{"aria-hidden":!0,className:"size-3 shrink-0 text-success"}),y==="error"&&c.jsx(Ex,{"aria-hidden":!0,className:"size-3 shrink-0 text-destructive"})]}),c.jsxs(Ti,{onOpenChange:i,children:[c.jsx(Ii,{asChild:!0,children:c.jsx(Ct,{"aria-label":`Actions for ${e.name}`,className:W("opacity-0 group-hover/menu-item:opacity-100 focus-visible:opacity-100",O&&"opacity-100"),children:c.jsx(ja,{})})}),c.jsx(Ar,{side:"right",align:"start",className:"w-44",children:v.map(N=>c.jsxs(je.Fragment,{children:[N.separatorBefore&&c.jsx(Fn,{}),c.jsx($t,{onClick:N.run,className:W(N.danger&&"text-destructive focus:text-destructive"),children:N.label})]},N.key))})]}),c.jsx(Fa,{id:w,checked:S,onCheckedChange:C,className:"shrink-0","aria-label":`Enable ${e.name}`,title:"On: expanded in every build. Off: a document that names it fails to build until it is switched back on."})]})}),c.jsx(Pa,{className:"w-44",children:v.map(N=>c.jsxs(je.Fragment,{children:[N.separatorBefore&&c.jsx(Ra,{}),c.jsx(Da,{onClick:N.run,className:W(N.danger&&"text-destructive focus:text-destructive"),children:N.label})]},N.key))})]}),c.jsx(ct,{open:a,onOpenChange:l,children:c.jsx(lt,{className:"sm:max-w-[425px]",onCloseAutoFocus:N=>{var R;N.preventDefault(),(R=n.current)==null||R.focus()},children:c.jsx(Dn,{mode:"update",shouldReset:!a,postSubmit:()=>l(!1),selectedName:e.name,isPlugin:!0})})}),c.jsx(ct,{open:u,onOpenChange:d,children:c.jsx(lt,{className:"sm:max-w-[425px]",onCloseAutoFocus:N=>{var R;N.preventDefault(),(R=n.current)==null||R.focus()},children:c.jsx(Dn,{mode:"delete",shouldReset:!u,postSubmit:()=>d(!1),selectedName:e.name,isPlugin:!0})})})]})}const rv=je.memo(nv);function iv({plugins:e,browserPlugins:t,query:n,open:r,onToggleSection:i,onShowPluginDetails:s,onNewPlugin:o,isPluginSelected:a,onTogglePlugin:l,isApplyingPlugins:u,diskPluginsLoadable:d,activeCount:f,totalCount:h}){const p=e.length>0&&t.length>0;return c.jsxs("section",{className:"border-sidebar-border/70 mt-3 border-t pt-2",children:[c.jsx(Wo,{open:r,onToggle:i,count:h>0?`${f}/${h}`:void 0,actions:c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx(Ct,{"aria-label":"New plugin",onClick:o,children:c.jsx(Dt,{})})}),c.jsx(Qe,{side:"bottom",children:"New plugin"})]}),children:"Plugins"}),r&&c.jsxs("div",{className:"flex flex-col gap-0.5",children:[p&&c.jsx(Wl,{children:"In this browser"}),c.jsx("ul",{className:"flex flex-col gap-0.5",children:t.map(g=>c.jsx(rv,{document:g,query:n},g.name))}),p&&c.jsx(Wl,{children:"On disk"}),e.length>0&&!d&&c.jsxs("p",{className:"text-sidebar-foreground/60 px-2 pt-0.5 pb-1 text-[11px] leading-snug",children:["This server does not load plugins from disk, so these cannot be switched on. Set ",c.jsx("code",{children:"PLUGIN_AUTOLOAD=true"})," on the deployment, or write one in the browser."]}),e.map(g=>{const k=a(g.name)&&d,S=`plugin-switch-${g.filePath||g.name}`;return c.jsxs("div",{title:g.description?`${g.name} — ${g.description}`:g.name,className:W("group/row flex h-7 w-full items-center gap-1 rounded-sm pr-1 pl-2","transition-colors hover:bg-sidebar-accent/60"),children:[c.jsx("button",{type:"button",onClick:()=>s(g.name),"aria-label":`Details for ${g.name}`,className:W("flex h-7 min-w-0 flex-1 cursor-pointer items-center text-[13px]","focus-visible:ring-sidebar-ring rounded-sm focus-visible:ring-1 focus-visible:outline-none",k?"text-sidebar-foreground":"text-sidebar-foreground/70"),children:c.jsx("span",{className:"truncate",children:c.jsx(Rs,{text:g.name,query:n})})}),c.jsx(Ct,{"aria-label":`Details for ${g.name}`,onClick:y=>{y.stopPropagation(),s(g.name)},className:"opacity-0 group-hover/row:opacity-100 focus-visible:opacity-100",children:c.jsx(nf,{})}),c.jsx(Fa,{id:S,checked:k,onCheckedChange:()=>l(g),disabled:u||!d,className:"shrink-0","aria-label":`Toggle ${g.name} plugin`,title:d?"On: the server loads this plugin from disk for every build.":"This server does not load plugins from disk (PLUGIN_AUTOLOAD is off)."})]},g.filePath||g.name)}),e.length+t.length===0&&c.jsx(qo,{icon:Dt,label:"New plugin",hint:"Write a custom component in TypeScript, in the browser",onClick:o})]})]})}function ql(e){return x.useMemo(()=>{const t=["current","downstream"],n=new Map;return e.forEach(r=>{const i=n.get(r.location);i?i.push(r):n.set(r.location,[r])}),[...n.entries()].sort(([r],[i])=>t.indexOf(r)-t.indexOf(i))},[e])}function ep({children:e,className:t}){return c.jsx("kbd",{"data-slot":"kbd",className:W("pointer-events-none inline-flex h-5 w-fit min-w-5 select-none items-center justify-center gap-1 rounded-sm bg-muted px-1 font-sans text-xs font-medium text-muted-foreground",t),children:e})}function sv({children:e,className:t}){return c.jsx("span",{className:W("inline-flex items-center gap-0.5",t),children:e})}const Fi=typeof navigator<"u"&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);function mi({shortcut:e,className:t}){const r=e.split("+").map(i=>i.trim().toLowerCase()).map(i=>{switch(i){case"mod":return Fi?"⌘":"Ctrl";case"shift":return Fi?"⇧":"Shift";case"alt":return Fi?"⌥":"Alt";case"ctrl":return Fi?"⌃":"Ctrl";case"enter":return"↵";default:return i.toUpperCase()}});return c.jsx(sv,{className:t,children:r.map((i,s)=>c.jsx(ep,{children:i},s))})}function ov({className:e}={}){const{theme:t,setTheme:n}=hd(),r=t==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t,i=x.useCallback(()=>{n(r==="dark"?"light":"dark")},[r,n]);return c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsxs(Ee,{variant:"ghost",size:"icon",onClick:i,className:e,children:[c.jsx(Cx,{className:"hidden dark:block"}),c.jsx(Tx,{className:"block dark:hidden"}),c.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),c.jsx(Qe,{children:c.jsx("p",{children:"Toggle theme"})})]})}function av({discoveryData:e,onToggleSidebar:t,isCollapsed:n=!1,isAnimating:r=!1}){const{documents:i,documentTypes:s,createDocument:o,openDocument:a,activeTab:l}=ke(Na($=>({documents:$.documents,documentTypes:$.documentTypes,createDocument:$.createDocument,openDocument:$.openDocument,activeTab:$.activeTab}))),u=Do($=>$.updateTheme),d=Do($=>$.removeTheme),f=x.useContext(ka),[h,p]=x.useState(!1),[g,k]=x.useState(!1),[S,y]=x.useState(!1),[j,m]=x.useState(!1),A=vn($=>fd($).length),[C,v]=x.useState(null),w=Jt($=>$.togglePlugin),O=Jt($=>$.isPluginSelected),B=Jt($=>$.selectedPlugins),N=Jt($=>$.isApplyingPlugins),[R,T]=x.useState(!1),[F,z]=x.useState(new Set(["documents","themes"])),[M,D]=x.useState(""),J=x.useRef(null),{toast:Z}=Cr(),X=i.filter($=>(s[$.name]??"application/json+report")==="application/json+report"),_=i.filter($=>s[$.name]==="application/json+theme"),ye=i.filter($=>s[$.name]==="application/typescript+plugin"),ce=x.useCallback(()=>{p(!1)},[]),b=x.useCallback(()=>{k(!1)},[]),G=x.useCallback(()=>{y(!1),z($=>new Set($).add("plugins"))},[]),ne=x.useRef(new Map);x.useEffect(()=>{const $=ne.current,xe=new Map;_.forEach(de=>{xe.set(de.name,de.text),$.get(de.name)!==de.text&&u(de.name,de.text)}),$.forEach((de,Me)=>{xe.has(Me)||d(Me)}),ne.current=xe},[_,u,d]);const Q=x.useRef(!1);x.useEffect(()=>{if(Q.current||!f)return;Q.current=!0;const $=new Set(_.map(de=>de.name));Object.keys(f.getState().customThemes).forEach(de=>{$.has(de)||d(de)})},[_,d,f]);const oe=x.useCallback($=>{z(xe=>{const de=new Set(xe);return de.has($)?de.delete($):de.add($),de})},[]),{resolvedTheme:I}=hd(),re=I==="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",ae=x.useCallback(async($,xe)=>{if(i.some(de=>de.name===$)){a($);return}try{const de=await fetch(`/api/discovery/${xe?"themes":"documents"}/${encodeURIComponent($)}/content`);if(!de.ok)throw new Error(de.statusText);const Me=await de.text(),Je=JSON.parse(Me);o($,JSON.stringify(Je,null,2),{templateSource:$}),a($),Z({title:`Added ${xe?"theme":"document"}: ${$}`})}catch{Z({title:"Failed to load",description:`Could not load ${$}`,variant:"destructive"})}},[i,o,a,Z]);x.useEffect(()=>{if(n)return;const $=xe=>{var Je,it,Lt,Ot,vl;if(xe.key!=="/"||xe.metaKey||xe.ctrlKey||xe.altKey)return;const de=xe.target,Me=(Je=de==null?void 0:de.tagName)==null?void 0:Je.toLowerCase();Me==="input"||Me==="textarea"||Me==="select"||de!=null&&de.isContentEditable||(it=de==null?void 0:de.closest)!=null&&it.call(de,".monaco-editor")||(Lt=J.current)!=null&&Lt.closest('[aria-hidden="true"], [inert]')||(xe.preventDefault(),(Ot=J.current)==null||Ot.focus(),(vl=J.current)==null||vl.select())};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[n]);const H=M.trim(),K=x.useMemo(()=>new Set(i.map($=>$.name)),[i]),pe=x.useMemo(()=>X.filter($=>on($.name,H)),[X,H]),fe=x.useMemo(()=>_.filter($=>on($.name,H)),[_,H]),Re=x.useMemo(()=>ye.filter($=>on($.name,H)),[ye,H]),Oe=x.useMemo(()=>((e==null?void 0:e.documents)??[]).filter($=>!K.has($.name)&&(on($.name,H)||on($.title??"",H))),[e,H,K]),$e=x.useMemo(()=>((e==null?void 0:e.themes)??[]).filter($=>!K.has($.name)&&(on($.name,H)||on($.description??"",H))),[e,H,K]),E=ql(Oe),P=ql($e),V=(e==null?void 0:e.pluginAutoload)??!0,se=x.useMemo(()=>(V?((e==null?void 0:e.plugins)??[]).filter(xe=>B.has(xe.name)).length:0)+A,[e,B,V,A]),ie=((e==null?void 0:e.plugins.length)??0)+ye.length,ee=x.useMemo(()=>((e==null?void 0:e.plugins)??[]).filter($=>on($.name,H)||on($.description??"",H)),[e,H]),me=$=>H.length>0||F.has($),we=me("documents"),U=me("themes"),Y=pe.length+Oe.length,ge=fe.length+$e.length,_e=H.length>0&&pe.length===0&&fe.length===0&&Re.length===0&&Oe.length===0&&$e.length===0&&ee.length===0,L=W("transition-opacity duration-150 ease-out",r?"opacity-0":"opacity-100");return c.jsxs(c.Fragment,{children:[c.jsxs(Jf,{collapsible:"none",style:{"--sidebar-width":n?"3rem":"16rem"},children:[n?c.jsxs(c.Fragment,{children:[c.jsx(Go,{className:W("gap-0 p-1.5",L),children:c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx(Ct,{className:"mx-auto size-7","aria-label":"Expand sidebar","aria-expanded":!1,onClick:t,children:c.jsx(rf,{})})}),c.jsxs(Qe,{side:"right",className:"flex items-center gap-2",children:[c.jsx("span",{children:"Expand sidebar"}),c.jsx(mi,{shortcut:"mod+b"})]})]})}),c.jsxs(Ko,{className:W("gap-2 px-1 py-1",L),children:[c.jsxs(nr,{className:"items-center gap-0.5",children:[X.map($=>c.jsx(Br,{document:$,compact:!0},$.name)),c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx(Ct,{className:"size-7","aria-label":"New document",onClick:()=>p(!0),children:c.jsx(Dt,{})})}),c.jsx(Qe,{side:"right",children:"New document"})]})]}),c.jsx("div",{className:"bg-sidebar-border/70 mx-auto h-px w-6"}),c.jsxs(nr,{className:"items-center gap-0.5",children:[_.map($=>c.jsx(Br,{document:$,compact:!0},$.name)),c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx(Ct,{className:"size-7","aria-label":"New theme",onClick:()=>k(!0),children:c.jsx(Dt,{})})}),c.jsx(Qe,{side:"right",children:"New theme"})]})]}),c.jsx("div",{className:"bg-sidebar-border/70 mx-auto h-px w-6"}),c.jsxs(nr,{className:"items-center gap-0.5",children:[ye.map($=>c.jsx(Br,{document:$,compact:!0},$.name)),c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx(Ct,{className:"size-7","aria-label":"New plugin",onClick:()=>y(!0),children:c.jsx(Dt,{})})}),c.jsx(Qe,{side:"right",children:"New plugin"})]})]})]})]}):c.jsxs(c.Fragment,{children:[c.jsxs(Go,{className:W("gap-0 p-2",L),children:[c.jsxs("div",{className:"flex h-7 items-center justify-between gap-1",children:[c.jsx("a",{href:"/","aria-label":"JSON to Office home",className:"focus-visible:ring-sidebar-ring flex items-center rounded-sm pl-1 focus-visible:ring-1 focus-visible:outline-none",children:c.jsx("img",{src:re,alt:"Wiseair",className:"h-[18px] w-auto max-w-[110px] shrink-0"})}),c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx(Ct,{"aria-label":"Collapse sidebar","aria-expanded":!0,onClick:t,children:c.jsx(Ix,{})})}),c.jsxs(Qe,{side:"right",className:"flex items-center gap-2",children:[c.jsx("span",{children:"Collapse sidebar"}),c.jsx(mi,{shortcut:"mod+b"})]})]})]}),c.jsxs("div",{className:"relative mt-2",children:[c.jsx(Ax,{"aria-hidden":!0,className:"pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-sidebar-foreground/40"}),c.jsx("input",{ref:J,type:"text",value:M,spellCheck:!1,autoComplete:"off",placeholder:"Filter files…","aria-label":"Filter documents, themes and plugins",onChange:$=>D($.target.value),onKeyDown:$=>{$.key==="Escape"&&($.preventDefault(),D(""),$.currentTarget.blur())},className:W("border-sidebar-border/70 bg-sidebar-accent/40 h-7 w-full rounded-sm border","pr-7 pl-7 text-[13px] text-sidebar-foreground transition-colors","placeholder:text-sidebar-foreground/60","focus-visible:border-sidebar-ring focus-visible:bg-sidebar-accent/60","focus-visible:ring-sidebar-ring focus-visible:ring-1 focus-visible:outline-none")}),H?c.jsx(Ct,{"aria-label":"Clear filter",onClick:()=>{var $;D(""),($=J.current)==null||$.focus()},className:"absolute top-1/2 right-1 -translate-y-1/2",children:c.jsx(wn,{})}):c.jsx(ep,{className:"absolute top-1/2 right-1.5 h-4 min-w-4 -translate-y-1/2 bg-transparent px-0 text-[10px] text-sidebar-foreground/65",children:"/"})]})]}),c.jsx(Ko,{className:W("gap-0 px-2 pb-2",L),children:_e?c.jsxs("div",{className:"px-1 py-6 text-center",children:[c.jsxs("p",{className:"text-[13px] text-sidebar-foreground/70",children:["No files match “",H,"”"]}),c.jsx("button",{type:"button",onClick:()=>{var $;D(""),($=J.current)==null||$.focus()},className:"text-sidebar-foreground/70 hover:text-sidebar-foreground focus-visible:ring-sidebar-ring mt-1 cursor-pointer rounded-sm text-[12px] underline-offset-2 hover:underline focus-visible:ring-1 focus-visible:outline-none",children:"Clear filter"})]}):c.jsxs(c.Fragment,{children:[(Y>0||!H)&&c.jsxs("section",{children:[c.jsx(Wo,{open:we,onToggle:()=>oe("documents"),count:Y||void 0,actions:c.jsxs(c.Fragment,{children:[at==="docx"&&c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx(Ct,{"aria-label":"Compare documents",disabled:X.length<2,onClick:()=>T(!0),children:c.jsx(Yd,{})})}),c.jsx(Qe,{side:"bottom",children:X.length<2?"Compare needs two documents":"Compare documents (redline)"})]}),c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx(Ct,{"aria-label":"New document",onClick:()=>p(!0),children:c.jsx(Dt,{})})}),c.jsx(Qe,{side:"bottom",children:"New document"})]})]}),children:"Documents"}),we&&c.jsxs(nr,{className:"gap-0.5",children:[pe.map($=>c.jsxs(x.Fragment,{children:[c.jsx(Br,{document:$,query:H}),!H&&l===$.name&&c.jsx(Ul,{})]},$.name)),E.map(([$,xe])=>c.jsxs(x.Fragment,{children:[E.length>1&&c.jsx(Jl,{location:$}),xe.map(de=>c.jsx(Hl,{name:de.name,subtitle:de.title,query:H,onSelect:()=>ae(de.name,!1)},de.path||de.name))]},$)),Y===0&&c.jsx("li",{className:"list-none",children:c.jsx(qo,{icon:Dt,label:"New document",onClick:()=>p(!0)})})]})]}),(ge>0||!H)&&c.jsxs("section",{className:"mt-3",children:[c.jsx(Wo,{open:U,onToggle:()=>oe("themes"),count:ge||void 0,actions:c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx(Ct,{"aria-label":"New theme",onClick:()=>k(!0),children:c.jsx(Dt,{})})}),c.jsx(Qe,{side:"bottom",children:"New theme"})]}),children:"Themes"}),U&&c.jsxs(nr,{className:"gap-0.5",children:[fe.map($=>c.jsxs(x.Fragment,{children:[c.jsx(Br,{document:$,query:H}),!H&&l===$.name&&c.jsx(Ul,{})]},$.name)),P.map(([$,xe])=>c.jsxs(x.Fragment,{children:[P.length>1&&c.jsx(Jl,{location:$}),xe.map(de=>c.jsx(Hl,{name:de.name,subtitle:de.description,query:H,onSelect:()=>ae(de.name,!0)},de.path||de.name))]},$)),ge===0&&c.jsx("li",{className:"list-none",children:c.jsx(qo,{icon:Dt,label:"New theme",onClick:()=>k(!0)})})]})]}),c.jsx(iv,{plugins:ee,browserPlugins:Re,query:H,open:me("plugins"),onToggleSection:()=>oe("plugins"),onShowPluginDetails:$=>{v($),m(!0)},onNewPlugin:()=>y(!0),isPluginSelected:O,onTogglePlugin:w,isApplyingPlugins:N,diskPluginsLoadable:V,activeCount:se,totalCount:ie})]})})]}),c.jsx(Hf,{className:W("border-sidebar-border/70 gap-0 border-t p-1.5",L),children:c.jsx("div",{className:W("flex items-center",n?"justify-center":"justify-start"),children:c.jsx(ov,{className:"size-7 rounded-sm text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground [&_svg]:size-3.5"})})})]}),c.jsx(ct,{open:h,onOpenChange:p,children:c.jsx(lt,{className:"sm:max-w-[525px]",children:c.jsx(Dn,{mode:"create",shouldReset:!h,postSubmit:ce,discoveredDocuments:(e==null?void 0:e.documents)||[]})})}),c.jsx(ct,{open:g,onOpenChange:k,children:c.jsx(lt,{className:"sm:max-w-[525px]",children:c.jsx(Dn,{mode:"create",shouldReset:!g,postSubmit:b,discoveredThemes:(e==null?void 0:e.themes)||[],isTheme:!0})})}),c.jsx(ct,{open:S,onOpenChange:y,children:c.jsx(lt,{className:"sm:max-w-[525px]",children:c.jsx(Dn,{mode:"create",shouldReset:!S,postSubmit:G,discoveredPlugins:(e==null?void 0:e.plugins)||[],isPlugin:!0})})}),c.jsx(ct,{open:j,onOpenChange:$=>{m($),$||v(null)},children:c.jsx(lt,{className:"max-h-[85vh] overflow-hidden sm:max-w-5xl",children:c.jsx(Qb,{plugins:(e==null?void 0:e.plugins)||[],initialFocusedPlugin:C})})}),c.jsx(ly,{open:R,onOpenChange:T})]})}const Gl=x.memo(av),lv=x.lazy(()=>md(()=>import("./editor-ZbEHVEFs.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])).then(e=>({default:e.Editor})));function Kl(){return c.jsx(x.Suspense,{fallback:c.jsx("div",{className:"flex items-center justify-center h-full",children:c.jsxs("div",{className:"text-center",children:[c.jsx(cn,{className:"w-8 h-8 mx-auto mb-2"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading editor..."})]})}),children:c.jsx(lv,{})})}const cv=x.lazy(()=>md(()=>import("./preview-CM2ywF-8.js"),__vite__mapDeps([13,1,3,4,5,6,7,8,9,10,12,11])).then(e=>({default:e.Preview})));function Yl(){return c.jsx(x.Suspense,{fallback:c.jsx("div",{className:"flex items-center justify-center h-full",children:c.jsxs("div",{className:"text-center",children:[c.jsx(cn,{className:"w-8 h-8 mx-auto mb-2"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading preview..."})]})}),children:c.jsx(cv,{})})}const{createElement:Sr,createContext:uv,forwardRef:tp,useCallback:bt,useContext:np,useEffect:Rn,useImperativeHandle:rp,useLayoutEffect:dv,useMemo:fv,useRef:jt,useState:fr}=dd,Xl=dd[`useId${Math.random()}`.slice(0,5)],pv=dv,Ms=uv(null);Ms.displayName="PanelGroupContext";const $n=pv,hv=typeof Xl=="function"?Xl:()=>null;let mv=0;function La(e=null){const t=hv(),n=jt(e||t||null);return n.current===null&&(n.current=""+mv++),e??n.current}function ip({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:i,forwardedRef:s,id:o,maxSize:a,minSize:l,onCollapse:u,onExpand:d,onResize:f,order:h,style:p,tagName:g="div",...k}){const S=np(Ms);if(S===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:y,expandPanel:j,getPanelSize:m,getPanelStyle:A,groupId:C,isPanelCollapsed:v,reevaluatePanelConstraints:w,registerPanel:O,resizePanel:B,unregisterPanel:N}=S,R=La(o),T=jt({callbacks:{onCollapse:u,onExpand:d,onResize:f},constraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:a,minSize:l},id:R,idIsFromProps:o!==void 0,order:h});jt({didLogMissingDefaultSizeWarning:!1}),$n(()=>{const{callbacks:z,constraints:M}=T.current,D={...M};T.current.id=R,T.current.idIsFromProps=o!==void 0,T.current.order=h,z.onCollapse=u,z.onExpand=d,z.onResize=f,M.collapsedSize=n,M.collapsible=r,M.defaultSize=i,M.maxSize=a,M.minSize=l,(D.collapsedSize!==M.collapsedSize||D.collapsible!==M.collapsible||D.maxSize!==M.maxSize||D.minSize!==M.minSize)&&w(T.current,D)}),$n(()=>{const z=T.current;return O(z),()=>{N(z)}},[h,R,O,N]),rp(s,()=>({collapse:()=>{y(T.current)},expand:z=>{j(T.current,z)},getId(){return R},getSize(){return m(T.current)},isCollapsed(){return v(T.current)},isExpanded(){return!v(T.current)},resize:z=>{B(T.current,z)}}),[y,j,m,v,R,B]);const F=A(T.current,i);return Sr(g,{...k,children:e,className:t,id:o,style:{...F,...p},"data-panel":"","data-panel-collapsible":r||void 0,"data-panel-group-id":C,"data-panel-id":R,"data-panel-size":parseFloat(""+F.flexGrow).toFixed(1)})}const sp=tp((e,t)=>Sr(ip,{...e,forwardedRef:t}));ip.displayName="Panel";sp.displayName="forwardRef(Panel)";let Xo=null,Pn=null;function gv(e,t){if(t){const n=(t&up)!==0,r=(t&dp)!==0,i=(t&fp)!==0,s=(t&pp)!==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 xv(){Pn!==null&&(document.head.removeChild(Pn),Xo=null,Pn=null)}function ao(e,t){const n=gv(e,t);Xo!==n&&(Xo=n,Pn===null&&(Pn=document.createElement("style"),document.head.appendChild(Pn)),Pn.innerHTML=`*{cursor: ${n}!important;}`)}function op(e){return e.type==="keydown"}function ap(e){return e.type.startsWith("pointer")}function lp(e){return e.type.startsWith("mouse")}function Fs(e){if(ap(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(lp(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function yv(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function bv(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 vv(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:tc(e),b:tc(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;Ce(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:ec(Ql(n.a)),b:ec(Ql(n.b))};if(i.a===i.b){const s=r.childNodes,o={a:n.a.at(-1),b:n.b.at(-1)};let a=s.length;for(;a--;){const l=s[a];if(l===o.a)return 1;if(l===o.b)return-1}}return Math.sign(i.a-i.b)}const wv=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function kv(e){var t;const n=getComputedStyle((t=cp(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function Sv(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||kv(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"||wv.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function Ql(e){let t=e.length;for(;t--;){const n=e[t];if(Ce(n,"Missing node"),Sv(n))return n}return null}function ec(e){return e&&Number(getComputedStyle(e).zIndex)||0}function tc(e){const t=[];for(;e;)t.push(e),e=cp(e);return t}function cp(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const up=1,dp=2,fp=4,pp=8,jv=yv()==="coarse";let Ht=[],pr=!1,yn=new Map,Ls=new Map;const gi=new Set;function _v(e,t,n,r,i){var s;const{ownerDocument:o}=t,a={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:i},l=(s=yn.get(o))!==null&&s!==void 0?s:0;return yn.set(o,l+1),gi.add(a),fs(),function(){var d;Ls.delete(e),gi.delete(a);const f=(d=yn.get(o))!==null&&d!==void 0?d:1;if(yn.set(o,f-1),fs(),f===1&&yn.delete(o),Ht.includes(a)){const h=Ht.indexOf(a);h>=0&&Ht.splice(h,1),Va(),i("up",!0,null)}}}function nc(e){const{target:t}=e,{x:n,y:r}=Fs(e);pr=!0,Ba({target:t,x:n,y:r}),fs(),Ht.length>0&&(ps("down",e),e.preventDefault(),e.stopPropagation())}function Zr(e){const{x:t,y:n}=Fs(e);if(pr&&e.buttons===0&&(pr=!1,ps("up",e)),!pr){const{target:r}=e;Ba({target:r,x:t,y:n})}ps("move",e),Va(),Ht.length>0&&e.preventDefault()}function Gn(e){const{target:t}=e,{x:n,y:r}=Fs(e);Ls.clear(),pr=!1,Ht.length>0&&e.preventDefault(),ps("up",e),Ba({target:t,x:n,y:r}),Va(),fs()}function Ba({target:e,x:t,y:n}){Ht.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),gi.forEach(i=>{const{element:s,hitAreaMargins:o}=i,a=s.getBoundingClientRect(),{bottom:l,left:u,right:d,top:f}=a,h=jv?o.coarse:o.fine;if(t>=u-h&&t<=d+h&&n>=f-h&&n<=l+h){if(r!==null&&document.contains(r)&&s!==r&&!s.contains(r)&&!r.contains(s)&&vv(r,s)>0){let g=r,k=!1;for(;g&&!g.contains(s);){if(bv(g.getBoundingClientRect(),a)){k=!0;break}g=g.parentElement}if(k)return}Ht.push(i)}})}function lo(e,t){Ls.set(e,t)}function Va(){let e=!1,t=!1;Ht.forEach(r=>{const{direction:i}=r;i==="horizontal"?e=!0:t=!0});let n=0;Ls.forEach(r=>{n|=r}),e&&t?ao("intersection",n):e?ao("horizontal",n):t?ao("vertical",n):xv()}function fs(){yn.forEach((e,t)=>{const{body:n}=t;n.removeEventListener("contextmenu",Gn),n.removeEventListener("pointerdown",nc),n.removeEventListener("pointerleave",Zr),n.removeEventListener("pointermove",Zr)}),window.removeEventListener("pointerup",Gn),window.removeEventListener("pointercancel",Gn),gi.size>0&&(pr?(Ht.length>0&&yn.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("contextmenu",Gn),n.addEventListener("pointerleave",Zr),n.addEventListener("pointermove",Zr))}),window.addEventListener("pointerup",Gn),window.addEventListener("pointercancel",Gn)):yn.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("pointerdown",nc,{capture:!0}),n.addEventListener("pointermove",Zr))}))}function ps(e,t){gi.forEach(n=>{const{setResizeHandlerState:r}=n,i=Ht.includes(n);r(e,i,t)})}function Nv(){const[e,t]=fr(0);return bt(()=>t(n=>n+1),[])}function Ce(e,t){if(!e)throw console.error(t),Error(t)}const Za=10;function Ln(e,t,n=Za){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function ln(e,t,n=Za){return Ln(e,t,n)===0}function Tt(e,t,n){return Ln(e,t,n)===0}function Ev(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(!Tt(i,s,n))return!1}return!0}function ar({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];Ce(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:s,maxSize:o=100,minSize:a=0}=r;if(Ln(n,a)<0)if(s){const l=(i+a)/2;Ln(n,l)<0?n=i:n=a}else n=a;return n=Math.min(o,n),n=parseFloat(n.toFixed(Za)),n}function Kr({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(Tt(e,0))return t;const o=[...t],[a,l]=r;Ce(a!=null,"Invalid first pivot index"),Ce(l!=null,"Invalid second pivot index");let u=0;if(s==="keyboard"){{const f=e<0?l:a,h=n[f];Ce(h,`Panel constraints not found for index ${f}`);const{collapsedSize:p=0,collapsible:g,minSize:k=0}=h;if(g){const S=t[f];if(Ce(S!=null,`Previous layout not found for panel index ${f}`),Tt(S,p)){const y=k-S;Ln(y,Math.abs(e))>0&&(e=e<0?0-y:y)}}}{const f=e<0?a:l,h=n[f];Ce(h,`No panel constraints found for index ${f}`);const{collapsedSize:p=0,collapsible:g,minSize:k=0}=h;if(g){const S=t[f];if(Ce(S!=null,`Previous layout not found for panel index ${f}`),Tt(S,k)){const y=S-p;Ln(y,Math.abs(e))>0&&(e=e<0?0-y:y)}}}}{const f=e<0?1:-1;let h=e<0?l:a,p=0;for(;;){const k=t[h];Ce(k!=null,`Previous layout not found for panel index ${h}`);const y=ar({panelConstraints:n,panelIndex:h,size:100})-k;if(p+=y,h+=f,h<0||h>=n.length)break}const g=Math.min(Math.abs(e),Math.abs(p));e=e<0?0-g:g}{let h=e<0?a:l;for(;h>=0&&h<n.length;){const p=Math.abs(e)-Math.abs(u),g=t[h];Ce(g!=null,`Previous layout not found for panel index ${h}`);const k=g-p,S=ar({panelConstraints:n,panelIndex:h,size:k});if(!Tt(g,S)&&(u+=g-S,o[h]=S,u.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?h--:h++}}if(Ev(i,o))return i;{const f=e<0?l:a,h=t[f];Ce(h!=null,`Previous layout not found for panel index ${f}`);const p=h+u,g=ar({panelConstraints:n,panelIndex:f,size:p});if(o[f]=g,!Tt(g,p)){let k=p-g,y=e<0?l:a;for(;y>=0&&y<n.length;){const j=o[y];Ce(j!=null,`Previous layout not found for panel index ${y}`);const m=j+k,A=ar({panelConstraints:n,panelIndex:y,size:m});if(Tt(j,A)||(k-=A-j,o[y]=A),Tt(k,0))break;e>0?y--:y++}}}const d=o.reduce((f,h)=>h+f,0);return Tt(d,100)?o:i}function Cv({layout:e,panelsArray:t,pivotIndices:n}){let r=0,i=100,s=0,o=0;const a=n[0];Ce(a!=null,"No pivot index found"),t.forEach((f,h)=>{const{constraints:p}=f,{maxSize:g=100,minSize:k=0}=p;h===a?(r=k,i=g):(s+=k,o+=g)});const l=Math.min(i,100-s),u=Math.max(r,100-o),d=e[a];return{valueMax:l,valueMin:u,valueNow:d}}function xi(e,t=document){return Array.from(t.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${e}"]`))}function hp(e,t,n=document){const i=xi(e,n).findIndex(s=>s.getAttribute("data-panel-resize-handle-id")===t);return i??null}function mp(e,t,n){const r=hp(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function gp(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 Bs(e,t=document){const n=t.querySelector(`[data-panel-resize-handle-id="${e}"]`);return n||null}function Tv(e,t,n,r=document){var i,s,o,a;const l=Bs(t,r),u=xi(e,r),d=l?u.indexOf(l):-1,f=(i=(s=n[d])===null||s===void 0?void 0:s.id)!==null&&i!==void 0?i:null,h=(o=(a=n[d+1])===null||a===void 0?void 0:a.id)!==null&&o!==void 0?o:null;return[f,h]}function Iv({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:i,panelGroupElement:s,setLayout:o}){jt({didWarnAboutMissingResizeHandle:!1}),$n(()=>{if(!s)return;const a=xi(n,s);for(let l=0;l<i.length-1;l++){const{valueMax:u,valueMin:d,valueNow:f}=Cv({layout:r,panelsArray:i,pivotIndices:[l,l+1]}),h=a[l];if(h!=null){const p=i[l];Ce(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(d)),h.setAttribute("aria-valuenow",f!=null?""+Math.round(f):"")}}return()=>{a.forEach((l,u)=>{l.removeAttribute("aria-controls"),l.removeAttribute("aria-valuemax"),l.removeAttribute("aria-valuemin"),l.removeAttribute("aria-valuenow")})}},[n,r,i,s]),Rn(()=>{if(!s)return;const a=t.current;Ce(a,"Eager values not found");const{panelDataArray:l}=a,u=gp(n,s);Ce(u!=null,`No group found for id "${n}"`);const d=xi(n,s);Ce(d,`No resize handles found for group id "${n}"`);const f=d.map(h=>{const p=h.getAttribute("data-panel-resize-handle-id");Ce(p,"Resize handle element has no handle id attribute");const[g,k]=Tv(n,p,l,s);if(g==null||k==null)return()=>{};const S=y=>{if(!y.defaultPrevented)switch(y.key){case"Enter":{y.preventDefault();const j=l.findIndex(m=>m.id===g);if(j>=0){const m=l[j];Ce(m,`No panel data found for index ${j}`);const A=r[j],{collapsedSize:C=0,collapsible:v,minSize:w=0}=m.constraints;if(A!=null&&v){const O=Kr({delta:Tt(A,C)?w-C:C-A,initialLayout:r,panelConstraints:l.map(B=>B.constraints),pivotIndices:mp(n,p,s),prevLayout:r,trigger:"keyboard"});r!==O&&o(O)}}break}}};return h.addEventListener("keydown",S),()=>{h.removeEventListener("keydown",S)}});return()=>{f.forEach(h=>h())}},[s,e,t,n,r,i,o])}function rc(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 xp(e,t){const n=e==="horizontal",{x:r,y:i}=Fs(t);return n?r:i}function Av(e,t,n,r,i){const s=n==="horizontal",o=Bs(t,i);Ce(o,`No resize handle element found for id "${t}"`);const a=o.getAttribute("data-panel-group-id");Ce(a,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=r;const u=xp(n,e),d=gp(a,i);Ce(d,`No group element found for id "${a}"`);const f=d.getBoundingClientRect(),h=s?f.width:f.height;return(u-l)/h*100}function zv(e,t,n,r,i,s){if(op(e)){const o=n==="horizontal";let a=0;e.shiftKey?a=100:i!=null?a=i:a=10;let l=0;switch(e.key){case"ArrowDown":l=o?0:a;break;case"ArrowLeft":l=o?-a:0;break;case"ArrowRight":l=o?a:0;break;case"ArrowUp":l=o?0:-a;break;case"End":l=100;break;case"Home":l=-100;break}return l}else return r==null?0:Av(e,t,n,r,s)}function Ov({panelDataArray:e}){const t=Array(e.length),n=e.map(s=>s.constraints);let r=0,i=100;for(let s=0;s<e.length;s++){const o=n[s];Ce(o,`Panel constraints not found for index ${s}`);const{defaultSize:a}=o;a!=null&&(r++,t[s]=a,i-=a)}for(let s=0;s<e.length;s++){const o=n[s];Ce(o,`Panel constraints not found for index ${s}`);const{defaultSize:a}=o;if(a!=null)continue;const l=e.length-r,u=i/l;r++,t[s]=u,i-=u}return t}function Kn(e,t,n){t.forEach((r,i)=>{const s=e[i];Ce(s,`Panel data not found for index ${i}`);const{callbacks:o,constraints:a,id:l}=s,{collapsedSize:u=0,collapsible:d}=a,f=n[l];if(f==null||r!==f){n[l]=r;const{onCollapse:h,onExpand:p,onResize:g}=o;g&&g(r,f),d&&(h||p)&&(p&&(f==null||ln(f,u))&&!ln(r,u)&&p(),h&&(f==null||!ln(f,u))&&ln(r,u)&&h())}})}function Li(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 Pv({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:i,precision:s=3}){const o=n[i];let a;return o==null?a=e!=null?e.toPrecision(s):"1":r.length===1?a="1":a=o.toPrecision(s),{flexBasis:0,flexGrow:a,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function Dv(e,t=10){let n=null;return(...i)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...i)},t)}}function ic(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 yp(e){return`react-resizable-panels:${e}`}function bp(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 vp(e,t){try{const n=yp(e),r=t.getItem(n);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function Rv(e,t,n){var r,i;const s=(r=vp(e,n))!==null&&r!==void 0?r:{},o=bp(t);return(i=s[o])!==null&&i!==void 0?i:null}function $v(e,t,n,r,i){var s;const o=yp(e),a=bp(t),l=(s=vp(e,i))!==null&&s!==void 0?s:{};l[a]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{i.setItem(o,JSON.stringify(l))}catch(u){console.error(u)}}function sc({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((s,o)=>s+o,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(s=>`${s}%`).join(", ")}`);if(!Tt(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const o=n[s];Ce(o!=null,`No layout data found for index ${s}`);const a=100/r*o;n[s]=a}let i=0;for(let s=0;s<t.length;s++){const o=n[s];Ce(o!=null,`No layout data found for index ${s}`);const a=ar({panelConstraints:t,panelIndex:s,size:o});o!=a&&(i+=o-a,n[s]=a)}if(!Tt(i,0))for(let s=0;s<t.length;s++){const o=n[s];Ce(o!=null,`No layout data found for index ${s}`);const a=o+i,l=ar({panelConstraints:t,panelIndex:s,size:a});if(o!==l&&(i-=l-o,n[s]=l,Tt(i,0)))break}return n}const Mv=100,Yr={getItem:e=>(ic(Yr),Yr.getItem(e)),setItem:(e,t)=>{ic(Yr),Yr.setItem(e,t)}},oc={};function wp({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:i,id:s=null,onLayout:o=null,keyboardResizeBy:a=null,storage:l=Yr,style:u,tagName:d="div",...f}){const h=La(s),p=jt(null),[g,k]=fr(null),[S,y]=fr([]),j=Nv(),m=jt({}),A=jt(new Map),C=jt(0),v=jt({autoSaveId:e,direction:r,dragState:g,id:h,keyboardResizeBy:a,onLayout:o,storage:l}),w=jt({layout:S,panelDataArray:[],panelDataArrayChanged:!1});jt({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),rp(i,()=>({getId:()=>v.current.id,getLayout:()=>{const{layout:b}=w.current;return b},setLayout:b=>{const{onLayout:G}=v.current,{layout:ne,panelDataArray:Q}=w.current,oe=sc({layout:b,panelConstraints:Q.map(I=>I.constraints)});rc(ne,oe)||(y(oe),w.current.layout=oe,G&&G(oe),Kn(Q,oe,m.current))}}),[]),$n(()=>{v.current.autoSaveId=e,v.current.direction=r,v.current.dragState=g,v.current.id=h,v.current.onLayout=o,v.current.storage=l}),Iv({committedValuesRef:v,eagerValuesRef:w,groupId:h,layout:S,panelDataArray:w.current.panelDataArray,setLayout:y,panelGroupElement:p.current}),Rn(()=>{const{panelDataArray:b}=w.current;if(e){if(S.length===0||S.length!==b.length)return;let G=oc[e];G==null&&(G=Dv($v,Mv),oc[e]=G);const ne=[...b],Q=new Map(A.current);G(e,ne,Q,S,l)}},[e,S,l]),Rn(()=>{});const O=bt(b=>{const{onLayout:G}=v.current,{layout:ne,panelDataArray:Q}=w.current;if(b.constraints.collapsible){const oe=Q.map(H=>H.constraints),{collapsedSize:I=0,panelSize:re,pivotIndices:ae}=Cn(Q,b,ne);if(Ce(re!=null,`Panel size not found for panel "${b.id}"`),!ln(re,I)){A.current.set(b.id,re);const K=rr(Q,b)===Q.length-1?re-I:I-re,pe=Kr({delta:K,initialLayout:ne,panelConstraints:oe,pivotIndices:ae,prevLayout:ne,trigger:"imperative-api"});Li(ne,pe)||(y(pe),w.current.layout=pe,G&&G(pe),Kn(Q,pe,m.current))}}},[]),B=bt((b,G)=>{const{onLayout:ne}=v.current,{layout:Q,panelDataArray:oe}=w.current;if(b.constraints.collapsible){const I=oe.map(fe=>fe.constraints),{collapsedSize:re=0,panelSize:ae=0,minSize:H=0,pivotIndices:K}=Cn(oe,b,Q),pe=G??H;if(ln(ae,re)){const fe=A.current.get(b.id),Re=fe!=null&&fe>=pe?fe:pe,$e=rr(oe,b)===oe.length-1?ae-Re:Re-ae,E=Kr({delta:$e,initialLayout:Q,panelConstraints:I,pivotIndices:K,prevLayout:Q,trigger:"imperative-api"});Li(Q,E)||(y(E),w.current.layout=E,ne&&ne(E),Kn(oe,E,m.current))}}},[]),N=bt(b=>{const{layout:G,panelDataArray:ne}=w.current,{panelSize:Q}=Cn(ne,b,G);return Ce(Q!=null,`Panel size not found for panel "${b.id}"`),Q},[]),R=bt((b,G)=>{const{panelDataArray:ne}=w.current,Q=rr(ne,b);return Pv({defaultSize:G,dragState:g,layout:S,panelData:ne,panelIndex:Q})},[g,S]),T=bt(b=>{const{layout:G,panelDataArray:ne}=w.current,{collapsedSize:Q=0,collapsible:oe,panelSize:I}=Cn(ne,b,G);return Ce(I!=null,`Panel size not found for panel "${b.id}"`),oe===!0&&ln(I,Q)},[]),F=bt(b=>{const{layout:G,panelDataArray:ne}=w.current,{collapsedSize:Q=0,collapsible:oe,panelSize:I}=Cn(ne,b,G);return Ce(I!=null,`Panel size not found for panel "${b.id}"`),!oe||Ln(I,Q)>0},[]),z=bt(b=>{const{panelDataArray:G}=w.current;G.push(b),G.sort((ne,Q)=>{const oe=ne.order,I=Q.order;return oe==null&&I==null?0:oe==null?-1:I==null?1:oe-I}),w.current.panelDataArrayChanged=!0,j()},[j]);$n(()=>{if(w.current.panelDataArrayChanged){w.current.panelDataArrayChanged=!1;const{autoSaveId:b,onLayout:G,storage:ne}=v.current,{layout:Q,panelDataArray:oe}=w.current;let I=null;if(b){const ae=Rv(b,oe,ne);ae&&(A.current=new Map(Object.entries(ae.expandToSizes)),I=ae.layout)}I==null&&(I=Ov({panelDataArray:oe}));const re=sc({layout:I,panelConstraints:oe.map(ae=>ae.constraints)});rc(Q,re)||(y(re),w.current.layout=re,G&&G(re),Kn(oe,re,m.current))}}),$n(()=>{const b=w.current;return()=>{b.layout=[]}},[]);const M=bt(b=>{let G=!1;const ne=p.current;return ne&&window.getComputedStyle(ne,null).getPropertyValue("direction")==="rtl"&&(G=!0),function(oe){oe.preventDefault();const I=p.current;if(!I)return()=>null;const{direction:re,dragState:ae,id:H,keyboardResizeBy:K,onLayout:pe}=v.current,{layout:fe,panelDataArray:Re}=w.current,{initialLayout:Oe}=ae??{},$e=mp(H,b,I);let E=zv(oe,b,re,ae,K,I);const P=re==="horizontal";P&&G&&(E=-E);const V=Re.map(ee=>ee.constraints),se=Kr({delta:E,initialLayout:Oe??fe,panelConstraints:V,pivotIndices:$e,prevLayout:fe,trigger:op(oe)?"keyboard":"mouse-or-touch"}),ie=!Li(fe,se);(ap(oe)||lp(oe))&&C.current!=E&&(C.current=E,!ie&&E!==0?P?lo(b,E<0?up:dp):lo(b,E<0?fp:pp):lo(b,0)),ie&&(y(se),w.current.layout=se,pe&&pe(se),Kn(Re,se,m.current))}},[]),D=bt((b,G)=>{const{onLayout:ne}=v.current,{layout:Q,panelDataArray:oe}=w.current,I=oe.map(fe=>fe.constraints),{panelSize:re,pivotIndices:ae}=Cn(oe,b,Q);Ce(re!=null,`Panel size not found for panel "${b.id}"`);const K=rr(oe,b)===oe.length-1?re-G:G-re,pe=Kr({delta:K,initialLayout:Q,panelConstraints:I,pivotIndices:ae,prevLayout:Q,trigger:"imperative-api"});Li(Q,pe)||(y(pe),w.current.layout=pe,ne&&ne(pe),Kn(oe,pe,m.current))},[]),J=bt((b,G)=>{const{layout:ne,panelDataArray:Q}=w.current,{collapsedSize:oe=0,collapsible:I}=G,{collapsedSize:re=0,collapsible:ae,maxSize:H=100,minSize:K=0}=b.constraints,{panelSize:pe}=Cn(Q,b,ne);pe!=null&&(I&&ae&&ln(pe,oe)?ln(oe,re)||D(b,re):pe<K?D(b,K):pe>H&&D(b,H))},[D]),Z=bt((b,G)=>{const{direction:ne}=v.current,{layout:Q}=w.current;if(!p.current)return;const oe=Bs(b,p.current);Ce(oe,`Drag handle element not found for id "${b}"`);const I=xp(ne,G);k({dragHandleId:b,dragHandleRect:oe.getBoundingClientRect(),initialCursorPosition:I,initialLayout:Q})},[]),X=bt(()=>{k(null)},[]),_=bt(b=>{const{panelDataArray:G}=w.current,ne=rr(G,b);ne>=0&&(G.splice(ne,1),delete m.current[b.id],w.current.panelDataArrayChanged=!0,j())},[j]),ye=fv(()=>({collapsePanel:O,direction:r,dragState:g,expandPanel:B,getPanelSize:N,getPanelStyle:R,groupId:h,isPanelCollapsed:T,isPanelExpanded:F,reevaluatePanelConstraints:J,registerPanel:z,registerResizeHandle:M,resizePanel:D,startDragging:Z,stopDragging:X,unregisterPanel:_,panelGroupElement:p.current}),[O,g,r,B,N,R,h,T,F,J,z,M,D,Z,X,_]),ce={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return Sr(Ms.Provider,{value:ye},Sr(d,{...f,children:t,className:n,id:s,ref:p,style:{...ce,...u},"data-panel-group":"","data-panel-group-direction":r,"data-panel-group-id":h}))}const kp=tp((e,t)=>Sr(wp,{...e,forwardedRef:t}));wp.displayName="PanelGroup";kp.displayName="forwardRef(PanelGroup)";function rr(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function Cn(e,t,n){const r=rr(e,t),s=r===e.length-1?[r-1,r]:[r,r+1],o=n[r];return{...t.constraints,panelSize:o,pivotIndices:s}}function Fv({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){Rn(()=>{if(e||n==null||r==null)return;const i=Bs(t,r);if(i==null)return;const s=o=>{if(!o.defaultPrevented)switch(o.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{o.preventDefault(),n(o);break}case"F6":{o.preventDefault();const a=i.getAttribute("data-panel-group-id");Ce(a,`No group element found for id "${a}"`);const l=xi(a,r),u=hp(a,t,r);Ce(u!==null,`No resize element found for id "${t}"`);const d=o.shiftKey?u>0?u-1:l.length-1:u+1<l.length?u+1:0;l[d].focus();break}}};return i.addEventListener("keydown",s),()=>{i.removeEventListener("keydown",s)}},[r,e,t,n])}function Sp({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:i,onBlur:s,onDragging:o,onFocus:a,style:l={},tabIndex:u=0,tagName:d="div",...f}){var h,p;const g=jt(null),k=jt({onDragging:o});Rn(()=>{k.current.onDragging=o});const S=np(Ms);if(S===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:y,groupId:j,registerResizeHandle:m,startDragging:A,stopDragging:C,panelGroupElement:v}=S,w=La(i),[O,B]=fr("inactive"),[N,R]=fr(!1),[T,F]=fr(null),z=jt({state:O});$n(()=>{z.current.state=O}),Rn(()=>{if(n)F(null);else{const Z=m(w);F(()=>Z)}},[n,w,m]);const M=(h=r==null?void 0:r.coarse)!==null&&h!==void 0?h:15,D=(p=r==null?void 0:r.fine)!==null&&p!==void 0?p:5;return Rn(()=>{if(n||T==null)return;const Z=g.current;return Ce(Z,"Element ref not attached"),_v(w,Z,y,{coarse:M,fine:D},(_,ye,ce)=>{if(ye)switch(_){case"down":{B("drag"),Ce(ce,'Expected event to be defined for "down" action'),A(w,ce);const{onDragging:b}=k.current;b&&b(!0);break}case"move":{const{state:b}=z.current;b!=="drag"&&B("hover"),Ce(ce,'Expected event to be defined for "move" action'),T(ce);break}case"up":{B("hover"),C();const{onDragging:b}=k.current;b&&b(!1);break}}else B("inactive")})},[M,y,n,D,m,w,T,A,C]),Fv({disabled:n,handleId:w,resizeHandler:T,panelGroupElement:v}),Sr(d,{...f,children:e,className:t,id:i,onBlur:()=>{R(!1),s==null||s()},onFocus:()=>{R(!0),a==null||a()},ref:g,role:"separator",style:{...{touchAction:"none",userSelect:"none"},...l},tabIndex:u,"data-panel-group-direction":y,"data-panel-group-id":j,"data-resize-handle":"","data-resize-handle-active":O==="drag"?"pointer":N?"keyboard":void 0,"data-resize-handle-state":O,"data-panel-resize-handle-enabled":!n,"data-panel-resize-handle-id":w})}Sp.displayName="PanelResizeHandle";const Lv=({className:e,...t})=>c.jsx(kp,{className:W("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),co=sp,ac=({withHandle:e,className:t,...n})=>c.jsx(Sp,{className:W("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(zx,{className:"h-2.5 w-2.5"})})}),jp=x.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{className:W("flex min-h-[80px] w-full rounded-sm border border-input bg-background px-3 py-2 text-sm shadow-xs","placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));jp.displayName="Textarea";class Bv{constructor(t){Rr(this,"client");this.client=Hx.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 Vv=new Bv;class Zv extends Error{constructor(n,r){super(n);Rr(this,"quality");this.name="QualityGateFailedError",this.quality=r}}function Uv(e,t){return e??t}function Jv(e){var n;const t=(n=e==null?void 0:e.split(";",1)[0])==null?void 0:n.trim().toLowerCase();return t?t==="application/json"||t.startsWith("application/")&&t.endsWith("+json"):!1}async function Hv(e){if(Jv(e.headers.get("content-type")))try{return await e.json()}catch{return}}function lc(e,t){if(t!=null&&t.error)return t.error;if(t!=null&&t.message)return t.message;if(e.ok)return`The server answered ${e.status} but not with a document. This usually means a proxy or extension replaced the response.`;switch(e.status){case 502:case 503:case 504:return`The server did not finish generating (${e.status}). It usually ran out of memory or restarted mid-request — documents with many full-page images or inline SVGs are the common cause. Try again, or split the document and generate it in parts.`;case 413:return"The document is too large for the server to accept (413). Remove or shrink its largest embedded assets.";case 429:return"Too many requests (429). Wait a moment before generating again.";default:return`Generation failed (${e.status}${e.statusText?` ${e.statusText}`:""}).`}}function Wv(){const e=x.useRef(null),t=yr(s=>s.generationBackend),n=pd(),r=x.useCallback(async(s,o,a,l,u)=>{e.current&&e.current.abort();const d=new AbortController;e.current=d;const f=Uv(u==null?void 0:u.renderer,t);try{l==null||l("parsing","Validating JSON structure...");let h;try{h=JSON.parse(o)}catch(B){throw new Error(`Invalid JSON: ${B instanceof Error?B.message:"Unknown parse error"}`)}l==null||l("building",`Building ${$i.toLowerCase()} structure...`);const p={jsonDefinition:h,options:{...u,sourceName:n(s),...f?{renderer:f}:{}}};p.customThemes=a??{},l==null||l("rendering",`Generating ${at.toUpperCase()} content...`);const g={"Content-Type":"application/json"};u!=null&&u.bypassCache&&(g["X-Bypass-Cache"]="true");const k=await fetch(ui.generate,{method:"POST",headers:g,body:JSON.stringify(p),signal:d.signal}),S=await Hv(k);if(k.status===400&&(S==null?void 0:S.code)==="QUALITY_GATE_FAILED")throw new Zv(lc(k,S),S.quality);if(!k.ok||!(S!=null&&S.success))throw new Error(lc(k,S));const{data:y,cache:j,warnings:m}=S,A=j.status==="HIT"?"HIT":j.status==="MISS"?"MISS":"UNKNOWN",C=A==="HIT"?`Served from cache (Hit rate: ${j.hitRate})`:`Generated fresh ${$i.toLowerCase()}`;l==null||l("finalizing",C);const v=globalThis.atob(y.document),w=new Uint8Array(v.length);for(let B=0;B<v.length;B++)w[B]=v.charCodeAt(B);const O=new Blob([w],{type:y.contentType});if(O.size===0)throw new Error(`Received empty ${$i.toLowerCase()} from API`);return{name:s,text:o,blob:O,...f?{renderer:f}:{},filename:y.filename,fileId:y.fileId,cacheStatus:A,cacheHitRate:j.hitRate,warnings:m}}catch(h){throw h instanceof Error&&h.name==="AbortError"?new Error(`${$i} generation was cancelled`):h}finally{e.current===d&&(e.current=null)}},[t,n]),i=x.useCallback(()=>{e.current&&(e.current.abort(),e.current=null)},[]);return{generatePresentation:r,generateDocument:r,cancelGeneration:i}}const Yi={ids:[],default:null};let cc;function qv(){return cc??(cc=(async()=>{var e;try{const t=await fetch(ui.renderers);if(!t.ok)return Yi;const n=await t.json();return!(n!=null&&n.success)||!Array.isArray((e=n.data)==null?void 0:e.ids)?Yi:n.data}catch{return Yi}})()),cc}function Gv(){const[e,t]=x.useState(Yi);return x.useEffect(()=>{let n=!1;return qv().then(r=>{n||t(r)}),()=>{n=!0}},[]),e}function Kv(e){if(!e||e.length===0)return null;const t=[{name:"heading",props:{level:1,text:"Document Generation Warnings"}},{name:"paragraph",props:{text:`${e.length} warning(s) were generated during document processing.`,spacing:{after:240}}}],n=new Map;for(const r of e){const i=n.get(r.component)||[];i.push(r),n.set(r.component,i)}for(const[r,i]of n.entries()){t.push({name:"heading",props:{level:2,text:`Component: ${r}`}});const s=[];for(const o of i){let a=o.message;if(o.context&&Object.keys(o.context).length>0){const l=Object.entries(o.context).map(([u,d])=>`${u}: ${JSON.stringify(d)}`).join(", ");a+=` (${l})`}s.push(a)}t.push({name:"list",props:{items:s,spacing:{after:120}}})}return{name:"docx",props:{metadata:{title:"Generation Warnings"},theme:"minimal"},children:t}}function Yv({open:e,onClose:t,nonSafeFonts:n,onChoose:r}){const[i,s]=je.useState("custom");je.useEffect(()=>{e&&s("custom")},[e]);const o=n.length===1?n[0]:n.slice(0,3).join(", ")+(n.length>3?` +${n.length-3} more`:""),a=[{value:"custom",title:"Keep custom fonts",desc:"Recipients with the font installed see the authored typeface. Others get a generic fallback."},{value:"substitute",title:"Convert to safe fonts",desc:"Rewrite non-safe families to Calibri / Georgia / Consolas so every recipient sees the same glyphs."}];return c.jsx(ct,{open:e,onOpenChange:l=>!l&&t(),children:c.jsxs(lt,{className:"max-w-md",children:[c.jsxs(qt,{children:[c.jsx(Gt,{children:"Non-safe fonts in this document"}),c.jsxs(dn,{children:[o," ",n.length===1?"is":"are"," not in the built-in safe list. Choose how to export."]})]}),c.jsx("div",{className:"grid gap-2 py-2",children:a.map(l=>{const u=i===l.value;return c.jsxs("button",{type:"button",onClick:()=>s(l.value),className:`text-left rounded-md border px-3 py-2 transition-colors ${u?"border-primary bg-primary/5":"border-border hover:bg-muted/40"}`,children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:`h-3.5 w-3.5 rounded-full border flex items-center justify-center ${u?"border-primary":"border-muted-foreground/50"}`,children:u&&c.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary"})}),c.jsx("span",{className:"text-sm font-medium",children:l.title})]}),c.jsx("p",{className:"mt-1 text-xs text-muted-foreground pl-6",children:l.desc})]},l.value)})}),c.jsxs(kn,{children:[c.jsx(Ee,{variant:"outline",size:"sm",onClick:t,children:"Cancel"}),c.jsx(Ee,{size:"sm",onClick:()=>{r(i),t()},children:"Download"})]})]})})}function Xv(e){const t=e.hasPendingDiff?"Review the proposed change first":e.parses?void 0:"The visual view needs the JSON to parse";return{view:t?"json":e.preferred??"visual",forcedReason:t}}function Qv(e){try{const t=JSON.parse(e);return!!t&&typeof t=="object"&&!Array.isArray(t)}catch{return!1}}function ew(){const e=yr(l=>l.setSettings),t=yr(l=>l.themeEditorView),n=ke(l=>l.activeTab&&l.documentTypes[l.activeTab]==="application/json+theme"?l.activeTab:""),r=ke(l=>{if(!n)return!0;const u=l.documents.find(d=>d.name===n);return u?Qv(u.text):!0}),i=ke(l=>!!n&&l.pendingDiffs[n]!==void 0),s=x.useCallback(l=>e({themeEditorView:l}),[e]);if(!n)return null;const{view:o,forcedReason:a}=Xv({preferred:t,parses:r,hasPendingDiff:i});return c.jsxs("div",{role:"tablist","aria-label":"Theme editor view",title:a,className:"flex h-7 shrink-0 items-center rounded-sm border border-border/70 bg-muted/60 p-0.5",children:[c.jsx(uc,{active:o==="visual",disabled:a!==void 0,onClick:()=>s("visual"),icon:Ox,label:"Visual"}),c.jsx(uc,{active:o==="json",onClick:()=>s("json"),icon:ns,label:"JSON"})]})}function uc({active:e,disabled:t,onClick:n,icon:r,label:i}){return c.jsxs("button",{type:"button",role:"tab","aria-selected":e,"aria-label":i,disabled:t,onClick:n,className:W("flex h-6 cursor-pointer items-center gap-1.5 rounded-[3px] px-2 text-xs transition-colors","focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none","disabled:cursor-not-allowed disabled:opacity-50",e?"bg-background text-foreground shadow-xs":"text-muted-foreground hover:text-foreground"),children:[c.jsx(r,{className:"size-3.5"}),c.jsx("span",{className:"hidden md:inline",children:i})]})}const tw=je.memo(ew);function uo(){return c.jsx("span",{className:"rounded-sm bg-warning/15 px-1 py-px text-[10px] font-semibold uppercase leading-none tracking-wide text-warning",children:"experimental"})}function dc(){return c.jsx("span",{className:"rounded-sm bg-muted px-1 py-px text-[10px] font-semibold uppercase leading-none tracking-wide text-muted-foreground",children:"default"})}function nw({name:e,blob:t,onManualRender:n,isGenerating:r,isRendering:i,onShowCacheMetrics:s,onShowSchemas:o,onShowFonts:a,documentText:l,editorDocumentText:u,editorDocumentName:d,warnings:f,onToggleChat:h,chatOpen:p,onTogglePreview:g,previewOpen:k}){const[S,y]=x.useState(!1),[j,m]=x.useState(!1),[A,C]=x.useState(!1),[v,w]=x.useState(!1),[O,B]=x.useState(!1),[N,R]=x.useState(null),{toast:T}=Cr(),F=pd(),{generateDocument:z}=Wv(),M=x.useContext(ka),D=Gv(),J=yr(K=>K.generationBackend),Z=yr(K=>K.setSettings),X=J??D.default??void 0,_=x.useCallback(()=>{const K={},{customThemes:pe}=M.getState();return Object.values(pe).forEach(fe=>{fe.valid&&fe.parsed&&(K[fe.name]=fe.parsed)}),K},[M]),ye=je.useMemo(()=>{if(!l)return[];try{const K=JSON.parse(l);return[...(at==="pptx"?$g:Mg)(K)].filter(fe=>!Fg(fe))}catch{return[]}},[l]),[ce,b]=x.useState(!1),G=x.useCallback(async()=>{if(t){y(!0);try{await new Promise(K=>setTimeout(K,100)),oi(`${e}${$r}`,t)}finally{setTimeout(()=>y(!1),500)}}},[t,e]),ne=x.useCallback(async()=>{if(t){if(ye.length===0){await G();return}b(!0)}},[t,ye.length,G]),Q=x.useCallback(async K=>{var pe;if(l){y(!0);try{const fe=await z(e,l,_(),void 0,{bypassCache:!0,fonts:{mode:K}});if(fe.blob.size===0)T({title:"Export failed",description:"The server returned an empty document.",variant:"destructive"});else{oi(`${e}${$r}`,fe.blob);const Re=(pe=fe.warnings)==null?void 0:pe.find(Oe=>{var $e,E;return(($e=Oe.context)==null?void 0:$e.code)==="FONT_MODE_SUBSTITUTED"||((E=Oe.context)==null?void 0:E.code)==="FONT_MODE_CUSTOM"});Re&&T({title:K==="substitute"?"Fonts substituted":"Non-safe fonts kept",description:Re.message})}}catch(fe){T({title:"Export failed",description:fe instanceof Error?fe.message:String(fe),variant:"destructive"})}finally{setTimeout(()=>y(!1),500)}}},[l,e,z,T,_]),oe=x.useCallback(async()=>{if(!(!f||f.length===0)){m(!0);try{const K=Kv(f);if(!K){T({title:"No warnings",description:"There are no warnings to download.",variant:"destructive"});return}const pe=await z("warnings",JSON.stringify(K,null,2),{});pe&&typeof pe=="object"&&"blob"in pe&&pe.blob&&(oi(`${e}-warnings${$r}`,pe.blob),T({title:"Warnings downloaded",description:`Downloaded warnings document with ${f.length} warning(s).`}))}catch(K){console.error("Failed to generate warnings document:",K),T({title:"Download failed",description:K instanceof Error?K.message:"Failed to generate warnings document",variant:"destructive"})}finally{setTimeout(()=>m(!1),500)}}},[f,e,z,T]),I=x.useCallback(async()=>{C(!0);try{await Vv.delete(`/${at}/cache`),window.dispatchEvent(new CustomEvent("cache:cleared")),T({title:"Cache Cleared",description:"All active caches have been successfully cleared.",variant:"default"})}catch(K){console.error("Failed to clear cache:",K),T({title:"Cache Clear Failed",description:"Failed to clear caches. Please try again.",variant:"destructive"})}finally{C(!1)}},[T]),re=u??l,ae=x.useCallback(()=>{var fe,Re;if(!re){T({title:"No document available",description:"Please select a document to copy standard components",variant:"destructive"});return}try{JSON.parse(re)}catch{T({title:"Document is not valid JSON",description:"Fix the JSON errors in the editor, then copy again",variant:"destructive"});return}B(!0);const K=(async()=>{const Oe=_(),$e=await Bo(re,{customThemes:Oe}),E=await fetch(`/api/${at}/standard-components`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonDefinition:$e.text,customThemes:Oe,options:{sourceName:F(d??e)}})});if(!E.ok){let V=`Request failed with status ${E.status}`;try{const se=await E.json(),ie=se.error??se.message;typeof ie=="string"&&ie&&(V=ie)}catch{}throw new Error(V)}const P=await E.json();return JSON.stringify(P.data,null,2)})();let pe;typeof ClipboardItem<"u"&&((fe=navigator.clipboard)!=null&&fe.write)?pe=navigator.clipboard.write([new ClipboardItem({"text/plain":K.then(Oe=>new Blob([Oe],{type:"text/plain"}))})]):(Re=navigator.clipboard)!=null&&Re.writeText?pe=K.then(Oe=>navigator.clipboard.writeText(Oe)):pe=Promise.reject(new Error("Clipboard is not available in this context")),(async()=>{try{await pe,T({title:"Copied to clipboard",description:"Standard components JSON has been copied"})}catch(Oe){let $e=null;try{$e=await K}catch(E){console.error("Error fetching standard components:",E),T({title:"Failed to get standard components",description:E instanceof Error?E.message:"Request failed",variant:"destructive"});return}console.error("Clipboard write failed:",Oe),R($e)}finally{B(!1)}})()},[re,e,d,F,_,T]),H=x.useCallback(async()=>{if(N!=null)try{await navigator.clipboard.writeText(N),T({title:"Copied to clipboard",description:"Standard components JSON has been copied"}),R(null)}catch{T({title:"Clipboard unavailable",description:"Select the JSON in the dialog and copy it manually",variant:"destructive"})}},[N,T]);return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"bg-sidebar border-b flex flex-row flex-nowrap items-center justify-between gap-x-2 px-3 py-1.5",children:[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(Ye,{children:[c.jsx(Xe,{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-sm hover:bg-muted/60 shrink-0",children:c.jsx(nf,{className:"h-3.5 w-3.5 text-muted-foreground"})})}),c.jsx(Qe,{className:"max-w-sm",children:c.jsxs("p",{className:"text-sm",children:["Preview converts the file to a PDF with LibreOffice. Download the ",$r," to verify fidelity."]})})]})]}),c.jsxs("div",{className:"flex flex-row items-center gap-x-1 shrink-0",children:[c.jsx(tw,{}),c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsxs(Ee,{variant:"default",size:"sm",className:"gap-1.5 h-7 px-2.5",onClick:n,"aria-label":"Render preview",disabled:r||i||k===!1,children:[i?c.jsx(cn,{size:"sm"}):c.jsx(Px,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Run"})]})}),c.jsx(Qe,{children:c.jsx("p",{children:k===!1?"Open preview to run":i?"Rendering preview...":"Render preview"})})]}),c.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsxs(Ee,{variant:"outline",size:"sm",className:"gap-1.5 h-7 px-2.5",disabled:!t||S||r,onClick:ne,children:[S?c.jsx(cn,{size:"sm"}):c.jsx(Dx,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Download"})]})}),c.jsx(Qe,{children:c.jsxs("p",{children:["Download ",$r]})})]}),f&&f.length>0&&c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx(Ee,{variant:"outline",size:"icon",className:"h-7 w-7 border-transparent bg-warning/10 text-warning hover:bg-warning/20",disabled:j||r,onClick:oe,children:j?c.jsx(cn,{size:"sm"}):c.jsx(sf,{className:"h-3.5 w-3.5"})})}),c.jsx(Qe,{children:c.jsxs("p",{children:["Download warnings (",f.length,")"]})})]}),D.ids.length>1&&c.jsxs(fi,{value:X,onValueChange:K=>Z({generationBackend:K}),children:[c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsxs(br,{"aria-label":"Renderer",className:"hidden h-7 w-auto min-h-0 gap-1.5 px-2 text-xs lg:flex [&>span]:flex [&>span]:items-center [&>span]:gap-1.5 [&>span]:whitespace-nowrap",children:[c.jsx($o,{className:"h-3.5 w-3.5 shrink-0 opacity-60"}),c.jsxs(pi,{placeholder:"Renderer",children:[c.jsx("span",{className:"font-medium",children:X}),X!==D.default&&c.jsx(uo,{})]})]})}),c.jsx(Qe,{children:c.jsxs("p",{children:["Renderer that writes the ",at.toUpperCase()," file. A non-default one may refuse a document it cannot express."]})})]}),c.jsx(vr,{className:"min-w-[var(--radix-select-trigger-width)] text-sidebar-foreground",children:c.jsxs(uf,{children:[c.jsx(Ea,{className:"px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Renderer"}),D.ids.map(K=>c.jsx(Mn,{value:K,className:"text-xs",children:c.jsxs("span",{className:"flex items-center gap-1.5 whitespace-nowrap",children:[c.jsx("span",{className:"font-medium",children:K}),K===D.default?c.jsx(dc,{}):c.jsx(uo,{})]})},K))]})})]}),c.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),c.jsxs(Ti,{children:[c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx(Ii,{asChild:!0,children:c.jsx(Ee,{variant:"ghost",size:"icon",className:"h-7 w-7",children:c.jsx(ja,{className:"h-3.5 w-3.5"})})})}),c.jsx(Qe,{children:c.jsx("p",{children:"More actions"})})]}),c.jsxs(Ar,{align:"end",className:"w-52",children:[o&&c.jsxs($t,{onClick:o,children:[c.jsx(Rx,{className:"h-4 w-4 mr-2"}),"View JSON Schemas"]}),a&&c.jsxs($t,{onClick:a,children:[c.jsx(Ro,{className:"h-4 w-4 mr-2"}),"Browse fonts"]}),s&&c.jsxs($t,{onClick:s,children:[c.jsx(Mo,{className:"h-4 w-4 mr-2"}),"View cache metrics"]}),re?c.jsxs($t,{onClick:ae,disabled:O,children:[c.jsx(Fo,{className:"h-4 w-4 mr-2"}),O?"Copying...":"Copy standard components"]}):c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx("span",{className:"block",children:c.jsxs($t,{disabled:!0,children:[c.jsx(Fo,{className:"h-4 w-4 mr-2"}),"Copy standard components"]})})}),c.jsx(Qe,{side:"left",children:c.jsx("p",{children:"No document selected — open or select a document first"})})]}),c.jsx(Fn,{}),c.jsxs($t,{onClick:()=>w(!0),disabled:A,className:"text-destructive focus:text-destructive",children:[c.jsx(_a,{className:"h-4 w-4 mr-2"}),A?"Clearing...":"Clear all caches"]}),D.ids.length>1&&c.jsxs(c.Fragment,{children:[c.jsx(Fn,{className:"lg:hidden"}),c.jsx($a,{className:"lg:hidden px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Renderer"}),D.ids.map(K=>c.jsxs($t,{className:"lg:hidden gap-1.5",onClick:()=>Z({generationBackend:K}),children:[c.jsx(un,{className:`h-3.5 w-3.5 shrink-0 ${X===K?"opacity-100":"opacity-0"}`}),c.jsx("span",{className:"font-medium",children:K}),K===D.default?c.jsx(dc,{}):c.jsx(uo,{})]},K))]})]})]}),g&&c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx(Ee,{variant:k?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:g,children:k?c.jsx(of,{className:"h-3.5 w-3.5"}):c.jsx($x,{className:"h-3.5 w-3.5"})})}),c.jsx(Qe,{children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[k?"Hide":"Show"," Preview"," ",c.jsx(mi,{shortcut:"mod+shift+p"})]})})]}),h&&c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx(Ee,{variant:p?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:h,children:c.jsx(af,{className:"h-3.5 w-3.5"})})}),c.jsx(Qe,{children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[p?"Close":"Open"," AI Chat"," ",c.jsx(mi,{shortcut:"mod+shift+j"})]})})]})]})]}),c.jsx(Yv,{open:ce,onClose:()=>b(!1),nonSafeFonts:ye,onChoose:Q}),c.jsx(ct,{open:N!=null,onOpenChange:K=>{K||R(null)},children:c.jsxs(lt,{className:"max-w-lg",children:[c.jsxs(qt,{children:[c.jsx(Gt,{children:"Standard components"}),c.jsx(dn,{children:"The browser blocked the automatic clipboard write. Copy the JSON from here instead."})]}),c.jsx(jp,{readOnly:!0,value:N??"",className:"h-64 font-mono text-xs",onFocus:K=>K.currentTarget.select()}),c.jsxs(kn,{children:[c.jsx(Ee,{variant:"outline",size:"sm",onClick:()=>R(null),children:"Close"}),c.jsx(Ee,{size:"sm",onClick:H,children:"Copy to clipboard"})]})]})}),c.jsx(ct,{open:v,onOpenChange:w,children:c.jsxs(lt,{className:"max-w-sm",children:[c.jsxs(qt,{children:[c.jsx(Gt,{children:"Clear all caches?"}),c.jsx(dn,{children:"This will clear the document, component, and rasterized-visual caches. Next generation will be uncached."})]}),c.jsxs(kn,{children:[c.jsx(Ee,{variant:"outline",size:"sm",onClick:()=>w(!1),children:"Cancel"}),c.jsx(Ee,{variant:"destructive",size:"sm",disabled:A,onClick:async()=>{await I(),w(!1)},children:A?c.jsx(cn,{size:"sm"}):"Clear"})]})]})})]})}const rw=je.memo(nw),_p=ox,Ua=x.forwardRef(({className:e,...t},n)=>c.jsx(qd,{ref:n,className:W("bg-muted text-muted-foreground inline-flex h-9 items-center justify-center rounded-sm p-1",e),...t}));Ua.displayName=qd.displayName;const hr=x.forwardRef(({className:e,...t},n)=>c.jsx(Gd,{ref:n,className:W("ring-offset-background focus-visible:ring-ring data-[state=active]:bg-background data-[state=active]:text-foreground inline-flex cursor-pointer items-center justify-center rounded-sm px-3 py-1 text-sm font-medium whitespace-nowrap transition-all focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50",e),...t}));hr.displayName=Gd.displayName;const mr=x.forwardRef(({className:e,...t},n)=>c.jsx(Kd,{ref:n,className:W("ring-offset-background focus-visible:ring-ring mt-2 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",e),...t}));mr.displayName=Kd.displayName;async function iw(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 sw(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 ow(e){const t=sw(e);return iw(t)}const aw=({open:e,onOpenChange:t,defaultTab:n="document"})=>{const[r,i]=x.useState(n),[s,o]=x.useState(null),[a,l]=x.useState(null),[u,d]=x.useState(!1),[f,h]=x.useState(!1),[p,g]=x.useState(null),[k,S]=x.useState(null),[y,j]=x.useState(!1),{toast:m}=Cr(),A=Jt(D=>D.selectedPlugins),C=Array.from(A),v=vn(jg);x.useEffect(()=>{n&&i(n)},[n]);const w=x.useCallback(async()=>{d(!0),g(null);try{const D=await Qs.fetchDocumentSchema(C,_g(vn.getState()));o(D)}catch(D){const J=D instanceof Error?D.message:"Failed to load document schema";g(J),m({variant:"destructive",title:"Error loading schema",description:J})}finally{d(!1)}},[C,v,m]),O=x.useCallback(async()=>{if(!a){h(!0),S(null);try{const D=await Qs.fetchThemeSchema();l(D)}catch(D){const J=D instanceof Error?D.message:"Failed to load theme schema";S(J),m({variant:"destructive",title:"Error loading schema",description:J})}finally{h(!1)}}},[a,m]),[B,N]=x.useState([]),[R,T]=x.useState(v);x.useEffect(()=>{e||(o(null),g(null))},[e]),x.useEffect(()=>{if(!e)return;const D=C.length!==B.length||C.some((Z,X)=>Z!==B[X]),J=v!==R;r==="document"?(!s||D||J)&&((D||J)&&(Qs.clearPluginSchemaCache(),N([...C]),T(v)),u||w()):r==="theme"&&!a&&!f&&O()},[r,e,s,a,u,f,C,B,v,R,w,O]);const F=C.length,z=r==="document"?s:a,M=async()=>{if(z)try{await ow(z)&&(j(!0),m({title:"Schema copied",description:"The JSON schema has been copied to your clipboard"}),setTimeout(()=>j(!1),2e3))}catch(D){console.error("Copy failed:",D)}};return c.jsx(ct,{open:e,onOpenChange:t,children:c.jsxs(lt,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[c.jsx(qt,{children:c.jsx(Gt,{children:"Schema Viewer"})}),c.jsxs(_p,{value:r,onValueChange:D=>i(D),className:"flex-1 overflow-hidden flex flex-col",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Ua,{children:[c.jsxs(hr,{value:"document",className:"flex items-center gap-1",children:["Document",F>0&&c.jsxs(tn,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:["+",F]})]}),c.jsx(hr,{value:"theme",children:"Theme"})]}),c.jsx("div",{className:"ml-auto",children:c.jsx(Ee,{variant:"ghost",size:"icon",onClick:M,disabled:y||!z,"aria-label":"Copy schema",children:y?c.jsx(un,{className:"h-4 w-4"}):c.jsx(zs,{className:"h-4 w-4"})})})]}),c.jsxs("div",{className:"flex-1 overflow-auto mt-4",children:[c.jsx(mr,{value:"document",className:"h-full",children:c.jsx(ds,{schema:s,loading:u,error:p||void 0})}),c.jsx(mr,{value:"theme",className:"h-full",children:c.jsx(ds,{schema:a,loading:f,error:k||void 0})})]})]})]})})};function Ja(e,t){var r;const n=lf.getState().getEditor(e);return(r=n==null?void 0:n.flushPendingSave)==null||r.call(n),n?n.toStorageValue(n.editor.getValue()):t}function Np(e,t,n){if(t.length===0)return n;const r=fc(e,t[0]);let i=r;for(let s=0;s<t.length-1;s++){const o=t[s],a=t[s+1],l=i[o],u=fc(l,a);i[o]=u,i=u}return i[t[t.length-1]]=n,r}function fc(e,t){return typeof t=="number"?Array.isArray(e)?[...e]:[]:e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{}}const pc=2*1024*1024,hc=12*1024*1024;function lw(e){if(e.length<4)return"unknown";const[t,n,r,i]=e;return t===0&&n===1&&r===0&&i===0||t===116&&n===114&&r===117&&i===101||t===116&&n===116&&r===99&&i===102?"ttf":t===79&&n===84&&r===84&&i===79?"otf":t===119&&n===79&&r===70&&i===70?"woff":t===119&&n===79&&r===70&&i===50?"woff2":"unknown"}function cw(e){let n="";for(let r=0;r<e.length;r+=32768)n+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(n)}function hs(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${Math.round(e/1024)} KB`}function uw(e,t){if(t.length===0)return{ok:!1,message:`"${e}" is empty.`};if(t.length>pc)return{ok:!1,message:`"${e}" is ${hs(t.length)}. The limit is ${hs(pc)} per font, because the bytes travel inside the document JSON.`};const n=lw(t);return n==="woff"||n==="woff2"?{ok:!1,message:`"${e}" is a ${n.toUpperCase()} file. Upload the TTF or OTF instead — the preview renderer cannot register web font formats.`}:n!=="ttf"&&n!=="otf"?{ok:!1,message:`"${e}" does not look like a TTF or OTF font file.`}:{ok:!0,format:n,base64:cw(t)}}const dw=new Set(["italic","oblique"]);function fw(e){const t=e.replace(/\.[^.]+$/,""),n=t.split(/[-_\s]+/).filter(Boolean),r=new Map;for(const[o,a]of Object.entries(gd))r.set(a.toLowerCase(),Number(o));let i=400,s=!1;for(;n.length>1;){const o=n[n.length-1].toLowerCase();if(dw.has(o)){s=!0,n.pop();continue}const a=r.get(o);if(a!==void 0){i=a,n.pop();continue}break}return{family:n.join(" ")||t,weight:i,italic:s}}function pw(e,t){const n=Array.isArray(e)?[...e]:[],r=n.findIndex(i=>{var s;return((s=i==null?void 0:i.family)==null?void 0:s.toLowerCase())===t.family.toLowerCase()});return r>=0?n[r]=t:n.push(t),n}function hw(e){return e.kind==="safe"||e.kind==="google"?null:{weight:"weight"in e&&e.weight?e.weight:400,italic:"italic"in e?!!e.italic:!1}}function mw(e,t,n,r){const i=((e==null?void 0:e.sources)??[]).filter(a=>{const l=hw(a);return l?!n.some(u=>u.weight===l.weight&&u.italic===l.italic):!0}),s=n.map(a=>({kind:"data",data:a.data,weight:a.weight,italic:a.italic})),o=r??(e==null?void 0:e.category);return{id:(e==null?void 0:e.id)??t,family:t,...o?{category:o}:{},sources:[...i,...s]}}function gw(e,t){let n=Array.isArray(e)?[...e]:[];for(const r of t){const i=r.sources.filter(o=>o.kind==="data").map(o=>({data:o.data,weight:o.weight??400,italic:o.italic??!1}));if(i.length===0)continue;const s=n.find(o=>{var a;return((a=o==null?void 0:o.family)==null?void 0:a.toLowerCase())===r.family.toLowerCase()});n=pw(n,mw(s,r.family,i,r.category))}return n}function xw(e,t){const n=(e.sources??[]).filter(r=>r.format==="ttf"||r.format==="otf").map(r=>({kind:"data",data:r.data,weight:r.weight,italic:r.italic}));return n.length===0?null:{id:e.family,family:e.family,...t?{category:t}:{},sources:n}}function yw(e){const t=new TextEncoder().encode(e).length;return t<=hc?null:`Adding this font would push the document to ${hs(t)}, past the ${hs(hc)} limit. Remove a font from props.fontRegistry, or use fewer weights.`}const mc=new Set,bw=(e,t,n)=>`${e.toLowerCase()}|${t}|${n?"i":"r"}`;function gc(e,t){var d;if(typeof document>"u"||!e.trim())return;const n=`gf-${e.replace(/\s+/g,"-")}`,r=document.getElementById(n),i=new Set(t&&t.length>0?t:[400,700]),s=new Set(((d=r==null?void 0:r.dataset.weights)==null?void 0:d.split(",").map(Number).filter(f=>!Number.isNaN(f)))??[]),o=new Set([...s,...i]);if(r&&o.size===s.size)return;const a=[...o].sort((f,h)=>f-h).join(";"),l=`https://fonts.googleapis.com/css2?family=${encodeURIComponent(e)}:wght@${a}&display=swap`,u=r??document.createElement("link");r||(u.id=n,u.rel="stylesheet",document.head.appendChild(u)),u.href=l,u.dataset.weights=[...o].sort((f,h)=>f-h).join(",")}function vw(e){const t=e.startsWith("data:")?e.slice(e.indexOf(",")+1):e,n=atob(t),r=new Uint8Array(n.length);for(let i=0;i<n.length;i++)r[i]=n.charCodeAt(i);return r}async function ww(e,t,n,r){const i=bw(e,n,r);if(!mc.has(i))try{if(typeof FontFace>"u"||!(document!=null&&document.fonts))return;const s=vw(t),o=new FontFace(e,s.buffer,{weight:String(n),style:r?"italic":"normal"});await o.load(),document.fonts.add(o),mc.add(i)}catch{}}const kw={safe:[],google:[]};function Sw(){const e=ke(i=>i.activeTab),t=ke(i=>i.documents),n=ke(i=>i.documentTypes),r=ke(i=>i.saveDocument);return x.useCallback(i=>{if(!e)return{ok:!1,error:"No active file"};if(n[e]!=="application/json+theme")return{ok:!1,error:"Fonts are registered on themes, not documents. Open a .theme.json file and try again."};const s=t.find(u=>u.name===e);if(!s)return{ok:!1,error:"Active theme not found"};const o=Ja(e,s.text);let a;try{a=JSON.parse(o)}catch(u){return{ok:!1,error:`Active theme is not valid JSON: ${u.message}`}}const l=i(a);return r(e,JSON.stringify(l,null,2)),{ok:!0,name:e}},[e,t,n,r])}function jw(){const e=ke(r=>r.activeTab),t=ke(r=>r.documents),n=ke(r=>r.saveDocument);return x.useCallback((r,i)=>{if(!e)return{ok:!1,error:"No active file"};const s=t.find(u=>u.name===e);if(!s)return{ok:!1,error:"Active document not found"};const o=Ja(e,s.text);let a;try{a=JSON.parse(o)}catch(u){return{ok:!1,error:`Active document is not valid JSON: ${u.message}`}}const l=Np(a,r,i);return n(e,JSON.stringify(l,null,2)),{ok:!0,name:e}},[e,t,n])}function _w(){const e=ke(i=>i.activeTab),t=ke(i=>i.documents),n=ke(i=>i.documentTypes),r=ke(i=>i.saveDocument);return x.useCallback(i=>{var h;if(i.length===0)return{ok:!0,name:e};if(!e)return{ok:!1,error:"No active file"};if(n[e]==="application/json+theme")return{ok:!1,error:"Custom fonts are registered on the document, not the theme. Open the .docx.json / .pptx.json tab and try again."};const s=t.find(p=>p.name===e);if(!s)return{ok:!1,error:"Active document not found"};const o=Ja(e,s.text);let a;try{a=JSON.parse(o)}catch(p){return{ok:!1,error:`Active document is not valid JSON: ${p.message}`}}const l=gw((h=a==null?void 0:a.props)==null?void 0:h.fontRegistry,i),u=Np(a,["props","fontRegistry"],l),d=JSON.stringify(u,null,2),f=yw(d);return f?{ok:!1,error:f}:(r(e,d),{ok:!0,name:e})},[e,t,n,r])}function Nw(e,t,n){(!e.fonts||typeof e.fonts!="object")&&(e.fonts={});const r=e.fonts[t];r&&typeof r=="object"?e.fonts[t]={...r,family:n}:e.fonts[t]=n}function xc(e){return e.map((t,n)=>typeof t=="number"?`[${t}]`:n===0?t:`.${t}`).join("")}const Ew=({open:e,onOpenChange:t})=>{const n=Gi(I=>I.open),r=Gi(I=>I.contextual),i=Gi(I=>I.close),s=e??n,o=r,a=x.useCallback(I=>{t&&t(I),I||i()},[t,i]),[l,u]=x.useState(kw),[d,f]=x.useState(!1),[h,p]=x.useState(""),[g,k]=x.useState("safe"),[S,y]=x.useState(null),[j,m]=x.useState(null),[A,C]=x.useState(!1),[v,w]=x.useState(!1),[O,B]=x.useState(""),[N,R]=x.useState([]),T=x.useRef(null),{toast:F}=Cr(),z=Sw(),M=jw(),D=_w(),J=ke(I=>I.activeTab),Z=ke(I=>I.documentTypes),X=J&&Z[J]==="application/json+theme",_=!!o||X;x.useEffect(()=>{s&&(l.safe.length>0||l.google.length>0||(f(!0),fetch(ui.fonts.catalog).then(I=>I.json()).then(I=>u(I)).catch(I=>{F({variant:"destructive",title:"Font catalog unavailable",description:I.message})}).finally(()=>f(!1))))},[s,l,F]),x.useEffect(()=>{if(!(g!=="google"||l.google.length===0))for(const I of l.google)gc(I.family,I.weights)},[g,l]);const ye=x.useMemo(()=>l.safe.filter(I=>I.toLowerCase().includes(h.toLowerCase())),[l.safe,h]),ce=x.useMemo(()=>l.google.filter(I=>I.family.toLowerCase().includes(h.toLowerCase())),[l.google,h]),b=x.useCallback(async I=>{try{await navigator.clipboard.writeText(I),m(I),setTimeout(()=>m(null),1500)}catch{F({variant:"destructive",title:"Copy failed",description:"Your browser blocked clipboard write."})}},[F]),G=x.useCallback(async(I,re,ae)=>{y(I);try{const H=z(K=>(Nw(K,ae,I),K));if(!H.ok){F({variant:"destructive",title:"Could not insert font",description:H.error});return}F({title:"Font inserted",description:`${I} set as ${ae} font in "${H.name}".`})}finally{y(null)}},[z,F]),ne=x.useCallback(async I=>{if(o){y(I);try{const re=M(o.jsonPath,I);if(!re.ok){F({variant:"destructive",title:"Could not insert font",description:re.error});return}F({title:"Font inserted",description:`${I} set at ${xc(o.jsonPath)}.`}),a(!1)}finally{y(null)}}},[o,M,F,a]),Q=x.useCallback(async I=>{if(!(!I||I.length===0)){C(!0);try{const re=[];for(const H of Array.from(I)){const K=new Uint8Array(await H.arrayBuffer()),pe=uw(H.name,K);if(!pe.ok){F({variant:"destructive",title:"Font rejected",description:pe.message});continue}re.push({identity:fw(H.name),base64:pe.base64})}if(re.length===0)return;const ae=D(re.map(({identity:H,base64:K})=>({id:H.family,family:H.family,sources:[{kind:"data",data:K,weight:H.weight,italic:H.italic}]})));if(!ae.ok){F({variant:"destructive",title:"Could not register font",description:ae.error});return}for(const{identity:H,base64:K}of re)ww(H.family,K,H.weight,H.italic),F({title:`Added ${H.family}`,description:`Registered at weight ${H.weight}${H.italic?" italic":""} in props.fontRegistry. Reference it as "${H.family}".`})}catch(re){F({variant:"destructive",title:"Upload failed",description:re.message})}finally{C(!1),T.current&&(T.current.value="")}}},[D,F]),oe=x.useCallback(async()=>{var re,ae;const I=O.trim();if(I){w(!0),R([]);try{const H=await fetch(ui.fonts.materialize,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({family:I,weights:[400,700],italics:!1})});if(H.status===429)throw new Error("Too many font fetches — the playground allows 20 every 15 minutes. Try again shortly.");if(!H.ok){const Oe=await H.json().catch(()=>({}));throw new Error(Oe.error??`Materialize failed (${H.status})`)}const K=await H.json();R(K.warnings??[]);const pe=(re=l.google.find(Oe=>Oe.family.toLowerCase()===K.family.toLowerCase()))==null?void 0:re.category,fe=xw(K,pe);if(!fe){F({variant:"destructive",title:"Nothing to embed",description:((ae=K.warnings)==null?void 0:ae.join(" · "))||`Google Fonts has no family named "${I}".`});return}const Re=D([fe]);if(!Re.ok){F({variant:"destructive",title:"Could not register font",description:Re.error});return}gc(K.family,[400,700]),F({title:`Added ${K.family}`,description:`Embedded ${fe.sources.length} weight(s) in props.fontRegistry.`})}catch(H){F({variant:"destructive",title:"Google Fonts fetch failed",description:H.message})}finally{w(!1)}}},[O,l.google,D,F]);return c.jsx(ct,{open:s,onOpenChange:a,children:c.jsxs(lt,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[c.jsx(qt,{children:c.jsx(Gt,{children:o?`Font for ${xc(o.jsonPath)}`:"Fonts"})}),!o&&!X&&g!=="custom"&&c.jsx(ur,{children:c.jsxs(dr,{children:["Fonts are registered on themes. Open a ",c.jsx("code",{children:".theme.json"})," ","file to apply a font — the buttons below are disabled until you do."]})}),c.jsxs(_p,{value:g,onValueChange:I=>k(I),className:"flex-1 overflow-hidden flex flex-col",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Ua,{children:[c.jsxs(hr,{value:"safe",children:["Safe",c.jsx(tn,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:l.safe.length})]}),c.jsxs(hr,{value:"google",children:["Google",c.jsx(tn,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:l.google.length})]}),c.jsx(hr,{value:"custom",children:"Custom"})]}),c.jsx(wr,{type:"search",placeholder:"Search fonts...",value:h,onChange:I=>p(I.target.value),className:"ml-auto max-w-xs"})]}),c.jsxs("div",{className:"flex-1 overflow-auto mt-4 pr-2",children:[c.jsx(mr,{value:"safe",className:"m-0",children:d&&ye.length===0?c.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[c.jsx(Gr,{className:"animate-spin mr-2"})," Loading catalog..."]}):c.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:ye.map(I=>c.jsx(yc,{family:I,meta:c.jsx("span",{className:"text-xs",children:"Installed with Office"}),previewStyle:{fontFamily:`"${I}", sans-serif`},onCopy:()=>b(I),copied:j===I,contextual:!!o,onUseThis:()=>ne(I),onInsertHeading:()=>G(I,"safe","heading"),onInsertBody:()=>G(I,"safe","body"),applying:S===I,disabled:!_},I))})}),c.jsx(mr,{value:"google",className:"m-0",children:d&&ce.length===0?c.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[c.jsx(Gr,{className:"animate-spin mr-2"})," Loading catalog..."]}):c.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:ce.map(I=>c.jsx(yc,{family:I.family,meta:c.jsxs("span",{className:"text-xs",children:[I.category," · ",I.weights.length," weights"]}),previewStyle:{fontFamily:`"${I.family}", sans-serif`},onCopy:()=>b(I.family),copied:j===I.family,contextual:!!o,onUseThis:()=>ne(I.family),onInsertHeading:()=>G(I.family,"google","heading"),onInsertBody:()=>G(I.family,"google","body"),applying:S===I.family,disabled:!_,extraAction:c.jsx(Tw,{family:I.family,weights:I.weights,hasItalic:I.hasItalic})},I.family))})}),c.jsx(mr,{value:"custom",className:"m-0 flex flex-col gap-6",children:X?c.jsx(ur,{children:c.jsxs(dr,{children:["Custom fonts are stored on the document (",c.jsx("code",{children:"props.fontRegistry"}),"), because the bytes travel with the JSON. Open a document tab to add one."]})}):c.jsxs(c.Fragment,{children:[c.jsxs("section",{className:"flex flex-col gap-2",children:[c.jsx("h3",{className:"text-sm font-medium",children:"Upload a font file"}),c.jsxs("p",{className:"text-xs text-muted-foreground",children:["TTF or OTF, up to 2 MB each. The font is embedded in the document as base64, so it survives export and re-import — and renders in the preview. The family and weight are guessed from the filename (e.g."," ",c.jsx("code",{children:"Geist-SemiBold.ttf"}),")."]}),c.jsxs("div",{onDragOver:I=>I.preventDefault(),onDrop:I=>{I.preventDefault(),Q(I.dataTransfer.files)},className:"rounded-md border border-dashed p-6 text-center",children:[c.jsx("input",{ref:T,type:"file",accept:".ttf,.otf,font/ttf,font/otf",multiple:!0,className:"hidden",onChange:I=>void Q(I.target.files)}),c.jsxs(Ee,{variant:"secondary",disabled:A,onClick:()=>{var I;return(I=T.current)==null?void 0:I.click()},children:[A?c.jsx(Gr,{className:"animate-spin mr-2 h-4 w-4"}):c.jsx(Mx,{className:"mr-2 h-4 w-4"}),"Choose font files"]}),c.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"or drop them here"})]})]}),c.jsxs("section",{className:"flex flex-col gap-2",children:[c.jsx("h3",{className:"text-sm font-medium",children:"Embed any Google font"}),c.jsxs("p",{className:"text-xs text-muted-foreground",children:["Not limited to the ",l.google.length," curated families — type any Google Fonts family name and its regular and bold weights are fetched and embedded."]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(wr,{placeholder:"e.g. Geist",value:O,onChange:I=>B(I.target.value),onKeyDown:I=>{I.key==="Enter"&&oe()}}),c.jsxs(Ee,{onClick:()=>void oe(),disabled:v||O.trim()==="",children:[v&&c.jsx(Gr,{className:"animate-spin mr-2 h-4 w-4"}),"Embed"]})]}),N.length>0&&c.jsx(ur,{children:c.jsx(dr,{className:"text-xs",children:N.join(" · ")})})]})]})})]})]})]})})},Cw="The quick brown fox jumps over the lazy dog",Tw=({family:e,weights:t,hasItalic:n})=>{const r=x.useMemo(()=>[...t].sort((i,s)=>i-s),[t]);return c.jsxs(Ti,{children:[c.jsx(Ii,{asChild:!0,children:c.jsx(Ee,{size:"sm",variant:"ghost","aria-label":"Show variants",children:"Variants"})}),c.jsxs(Ar,{align:"end",className:"min-w-[260px]",children:[c.jsxs($a,{className:"text-xs text-muted-foreground",children:[r.length," weight",r.length===1?"":"s",n?" · italic available":""]}),c.jsx(Fn,{}),r.map(i=>{const s=gd[i]??String(i);return c.jsxs("div",{className:"flex flex-col gap-0.5 px-2 py-1.5",children:[c.jsx("span",{className:"truncate",style:{fontFamily:`"${e}", sans-serif`,fontWeight:i},children:s}),c.jsxs("span",{className:"text-xs text-muted-foreground font-mono",children:["fontWeight: ",i]})]},i)})]})]})},yc=({family:e,meta:t,previewStyle:n,onCopy:r,copied:i,contextual:s,onUseThis:o,onInsertHeading:a,onInsertBody:l,applying:u,disabled:d,extraAction:f})=>c.jsxs("div",{className:"border rounded-md p-3 flex flex-col gap-2 bg-card",children:[c.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[c.jsx("div",{className:"font-medium truncate",children:e}),c.jsx("div",{className:"text-muted-foreground",children:t})]}),c.jsx("div",{className:"text-lg truncate",style:n,"aria-hidden":!0,children:Cw}),c.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s?c.jsx(Ee,{size:"sm",onClick:o,disabled:u||d,"aria-label":`Use ${e} at the target path`,children:"Use this font"}):c.jsxs(c.Fragment,{children:[c.jsx(Ee,{size:"sm",variant:"secondary",onClick:a,disabled:u||d,"aria-label":`Set ${e} as heading font`,children:"Set heading"}),c.jsx(Ee,{size:"sm",variant:"secondary",onClick:l,disabled:u||d,"aria-label":`Set ${e} as body font`,children:"Set body"})]}),f,c.jsx(Ee,{size:"sm",variant:"ghost",className:"ml-auto",onClick:r,"aria-label":`Copy ${e}`,children:i?c.jsx(un,{className:"h-4 w-4"}):c.jsx(zs,{className:"h-4 w-4"})})]})]});function bc({previewOpen:e,onTogglePreview:t}){const n=an(v=>v.name||""),r=an(v=>v.blob),i=an(v=>v.isGenerating),s=an(v=>v.text),o=an(v=>v.warnings),a=an(v=>v.isRendering),l=yr(v=>v.useGlobalPreviewHeader??!0),u=ke(v=>v.activeTab),d=ke(v=>v.documentTypes),f=u&&d[u]==="application/json+theme"?"theme":"document",h=ke(v=>{var w;return v.activeTab&&(v.documentTypes[v.activeTab]??"application/json+report")==="application/json+report"?(w=v.documents.find(O=>O.name===v.activeTab))==null?void 0:w.text:void 0}),p=ke(v=>v.activeTab&&(v.documentTypes[v.activeTab]??"application/json+report")==="application/json+report"?v.activeTab:void 0),g=De(v=>v.chatOpen),k=De(v=>v.toggleChat),[S,y]=je.useState(!1),j=Gi(v=>v.openFor);if(!l)return null;const m=x.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:manualRender"))},[]),A=x.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:showCacheMetrics"))},[]),C=(n==null?void 0:n.trim())||"Preview";return c.jsxs("div",{className:"sticky top-0 z-20",children:[c.jsx(rw,{name:C,blob:r,onManualRender:m,isGenerating:i,isRendering:!!a,onShowCacheMetrics:A,onShowSchemas:()=>y(!0),onShowFonts:()=>j(),documentText:s,editorDocumentText:h,editorDocumentName:p,warnings:o,onToggleChat:k,chatOpen:g,onTogglePreview:t,previewOpen:e}),c.jsx(aw,{open:S,onOpenChange:y,defaultTab:f==="theme"?"theme":"document"}),c.jsx(Ew,{})]})}function Iw(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Aw=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,zw=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ow={};function vc(e,t){return(Ow.jsx?zw:Aw).test(e)}const Pw=/[ \t\n\f\r]/g;function Dw(e){return typeof e=="object"?e.type==="text"?wc(e.value):!1:wc(e)}function wc(e){return e.replace(Pw,"")===""}class Ai{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Ai.prototype.normal={};Ai.prototype.property={};Ai.prototype.space=void 0;function Ep(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Ai(n,r,t)}function Qo(e){return e.toLowerCase()}class _t{constructor(t,n){this.attribute=n,this.property=t}}_t.prototype.attribute="";_t.prototype.booleanish=!1;_t.prototype.boolean=!1;_t.prototype.commaOrSpaceSeparated=!1;_t.prototype.commaSeparated=!1;_t.prototype.defined=!1;_t.prototype.mustUseProperty=!1;_t.prototype.number=!1;_t.prototype.overloadedBoolean=!1;_t.prototype.property="";_t.prototype.spaceSeparated=!1;_t.prototype.space=void 0;let Rw=0;const Ne=Zn(),rt=Zn(),ea=Zn(),te=Zn(),Ze=Zn(),gr=Zn(),Et=Zn();function Zn(){return 2**++Rw}const ta=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ne,booleanish:rt,commaOrSpaceSeparated:Et,commaSeparated:gr,number:te,overloadedBoolean:ea,spaceSeparated:Ze},Symbol.toStringTag,{value:"Module"})),fo=Object.keys(ta);class Ha extends _t{constructor(t,n,r,i){let s=-1;if(super(t,n),kc(this,"space",i),typeof r=="number")for(;++s<fo.length;){const o=fo[s];kc(this,fo[s],(r&ta[o])===ta[o])}}}Ha.prototype.defined=!0;function kc(e,t,n){n&&(e[t]=n)}function zr(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new Ha(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Qo(r)]=r,n[Qo(s.attribute)]=r}return new Ai(t,n,e.space)}const Cp=zr({properties:{ariaActiveDescendant:null,ariaAtomic:rt,ariaAutoComplete:null,ariaBusy:rt,ariaChecked:rt,ariaColCount:te,ariaColIndex:te,ariaColSpan:te,ariaControls:Ze,ariaCurrent:null,ariaDescribedBy:Ze,ariaDetails:null,ariaDisabled:rt,ariaDropEffect:Ze,ariaErrorMessage:null,ariaExpanded:rt,ariaFlowTo:Ze,ariaGrabbed:rt,ariaHasPopup:null,ariaHidden:rt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ze,ariaLevel:te,ariaLive:null,ariaModal:rt,ariaMultiLine:rt,ariaMultiSelectable:rt,ariaOrientation:null,ariaOwns:Ze,ariaPlaceholder:null,ariaPosInSet:te,ariaPressed:rt,ariaReadOnly:rt,ariaRelevant:null,ariaRequired:rt,ariaRoleDescription:Ze,ariaRowCount:te,ariaRowIndex:te,ariaRowSpan:te,ariaSelected:rt,ariaSetSize:te,ariaSort:null,ariaValueMax:te,ariaValueMin:te,ariaValueNow:te,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Tp(e,t){return t in e?e[t]:t}function Ip(e,t){return Tp(e,t.toLowerCase())}const $w=zr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:gr,acceptCharset:Ze,accessKey:Ze,action:null,allow:null,allowFullScreen:Ne,allowPaymentRequest:Ne,allowUserMedia:Ne,alt:null,as:null,async:Ne,autoCapitalize:null,autoComplete:Ze,autoFocus:Ne,autoPlay:Ne,blocking:Ze,capture:null,charSet:null,checked:Ne,cite:null,className:Ze,cols:te,colSpan:null,content:null,contentEditable:rt,controls:Ne,controlsList:Ze,coords:te|gr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ne,defer:Ne,dir:null,dirName:null,disabled:Ne,download:ea,draggable:rt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ne,formTarget:null,headers:Ze,height:te,hidden:ea,high:te,href:null,hrefLang:null,htmlFor:Ze,httpEquiv:Ze,id:null,imageSizes:null,imageSrcSet:null,inert:Ne,inputMode:null,integrity:null,is:null,isMap:Ne,itemId:null,itemProp:Ze,itemRef:Ze,itemScope:Ne,itemType:Ze,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ne,low:te,manifest:null,max:null,maxLength:te,media:null,method:null,min:null,minLength:te,multiple:Ne,muted:Ne,name:null,nonce:null,noModule:Ne,noValidate:Ne,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:Ne,optimum:te,pattern:null,ping:Ze,placeholder:null,playsInline:Ne,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ne,referrerPolicy:null,rel:Ze,required:Ne,reversed:Ne,rows:te,rowSpan:te,sandbox:Ze,scope:null,scoped:Ne,seamless:Ne,selected:Ne,shadowRootClonable:Ne,shadowRootDelegatesFocus:Ne,shadowRootMode:null,shape:null,size:te,sizes:null,slot:null,span:te,spellCheck:rt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:te,step:null,style:null,tabIndex:te,target:null,title:null,translate:null,type:null,typeMustMatch:Ne,useMap:null,value:rt,width:te,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ze,axis:null,background:null,bgColor:null,border:te,borderColor:null,bottomMargin:te,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ne,declare:Ne,event:null,face:null,frame:null,frameBorder:null,hSpace:te,leftMargin:te,link:null,longDesc:null,lowSrc:null,marginHeight:te,marginWidth:te,noResize:Ne,noHref:Ne,noShade:Ne,noWrap:Ne,object:null,profile:null,prompt:null,rev:null,rightMargin:te,rules:null,scheme:null,scrolling:rt,standby:null,summary:null,text:null,topMargin:te,valueType:null,version:null,vAlign:null,vLink:null,vSpace:te,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ne,disableRemotePlayback:Ne,prefix:null,property:null,results:te,security:null,unselectable:null},space:"html",transform:Ip}),Mw=zr({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:Et,accentHeight:te,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:te,amplitude:te,arabicForm:null,ascent:te,attributeName:null,attributeType:null,azimuth:te,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:te,by:null,calcMode:null,capHeight:te,className:Ze,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:te,diffuseConstant:te,direction:null,display:null,dur:null,divisor:te,dominantBaseline:null,download:Ne,dx:null,dy:null,edgeMode:null,editable:null,elevation:te,enableBackground:null,end:null,event:null,exponent:te,externalResourcesRequired:null,fill:null,fillOpacity:te,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:gr,g2:gr,glyphName:gr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:te,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:te,horizOriginX:te,horizOriginY:te,id:null,ideographic:te,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:te,k:te,k1:te,k2:te,k3:te,k4:te,kernelMatrix:Et,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:te,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:te,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:te,overlineThickness:te,paintOrder:null,panose1:null,path:null,pathLength:te,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ze,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:te,pointsAtY:te,pointsAtZ:te,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Et,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Et,rev:Et,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Et,requiredFeatures:Et,requiredFonts:Et,requiredFormats:Et,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:te,specularExponent:te,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:te,strikethroughThickness:te,string:null,stroke:null,strokeDashArray:Et,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:te,strokeOpacity:te,strokeWidth:null,style:null,surfaceScale:te,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Et,tabIndex:te,tableValues:null,target:null,targetX:te,targetY:te,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Et,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:te,underlineThickness:te,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:te,values:null,vAlphabetic:te,vMathematical:te,vectorEffect:null,vHanging:te,vIdeographic:te,version:null,vertAdvY:te,vertOriginX:te,vertOriginY:te,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:te,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Tp}),Ap=zr({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()}}),zp=zr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Ip}),Op=zr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Fw={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"},Lw=/[A-Z]/g,Sc=/-[a-z]/g,Bw=/^data[-\w.:]+$/i;function Vw(e,t){const n=Qo(t);let r=t,i=_t;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Bw.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(Sc,Uw);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!Sc.test(s)){let o=s.replace(Lw,Zw);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=Ha}return new i(r,t)}function Zw(e){return"-"+e.toLowerCase()}function Uw(e){return e.charAt(1).toUpperCase()}const Jw=Ep([Cp,$w,Ap,zp,Op],"html"),Wa=Ep([Cp,Mw,Ap,zp,Op],"svg");function Hw(e){return e.join(" ").trim()}var Yn={},po,jc;function Ww(){if(jc)return po;jc=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,a=/^\s+|\s+$/g,l=`
|
|
155
155
|
`,u="/",d="*",f="",h="comment",p="declaration";function g(S,y){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];y=y||{};var j=1,m=1;function A(z){var M=z.match(t);M&&(j+=M.length);var D=z.lastIndexOf(l);m=~D?z.length-D:m+z.length}function C(){var z={line:j,column:m};return function(M){return M.position=new v(z),B(),M}}function v(z){this.start=z,this.end={line:j,column:m},this.source=y.source}v.prototype.content=S;function w(z){var M=new Error(y.source+":"+j+":"+m+": "+z);if(M.reason=z,M.filename=y.source,M.line=j,M.column=m,M.source=S,!y.silent)throw M}function O(z){var M=z.exec(S);if(M){var D=M[0];return A(D),S=S.slice(D.length),M}}function B(){O(n)}function N(z){var M;for(z=z||[];M=R();)M!==!1&&z.push(M);return z}function R(){var z=C();if(!(u!=S.charAt(0)||d!=S.charAt(1))){for(var M=2;f!=S.charAt(M)&&(d!=S.charAt(M)||u!=S.charAt(M+1));)++M;if(M+=2,f===S.charAt(M-1))return w("End of comment missing");var D=S.slice(2,M-2);return m+=2,A(D),S=S.slice(M),m+=2,z({type:h,comment:D})}}function T(){var z=C(),M=O(r);if(M){if(R(),!O(i))return w("property missing ':'");var D=O(s),J=z({type:p,property:k(M[0].replace(e,f)),value:D?k(D[0].replace(e,f)):f});return O(o),J}}function F(){var z=[];N(z);for(var M;M=T();)M!==!1&&(z.push(M),N(z));return z}return B(),F()}function k(S){return S?S.replace(a,f):f}return po=g,po}var _c;function qw(){if(_c)return Yn;_c=1;var e=Yn&&Yn.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Yn,"__esModule",{value:!0}),Yn.default=n;const t=e(Ww());function n(r,i){let s=null;if(!r||typeof r!="string")return s;const o=(0,t.default)(r),a=typeof i=="function";return o.forEach(l=>{if(l.type!=="declaration")return;const{property:u,value:d}=l;a?i(u,d,l):d&&(s=s||{},s[u]=d)}),s}return Yn}var Ur={},Nc;function Gw(){if(Nc)return Ur;Nc=1,Object.defineProperty(Ur,"__esModule",{value:!0}),Ur.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)},o=function(u,d){return d.toUpperCase()},a=function(u,d){return"".concat(d,"-")},l=function(u,d){return d===void 0&&(d={}),s(u)?u:(u=u.toLowerCase(),d.reactCompat?u=u.replace(i,a):u=u.replace(r,a),u.replace(t,o))};return Ur.camelCase=l,Ur}var Jr,Ec;function Kw(){if(Ec)return Jr;Ec=1;var e=Jr&&Jr.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(qw()),n=Gw();function r(i,s){var o={};return!i||typeof i!="string"||(0,t.default)(i,function(a,l){a&&l&&(o[(0,n.camelCase)(a,s)]=l)}),o}return r.default=r,Jr=r,Jr}var Yw=Kw();const Xw=wa(Yw),Pp=Dp("end"),qa=Dp("start");function Dp(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 Qw(e){const t=qa(e),n=Pp(e);if(t&&n)return{start:t,end:n}}function ai(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Cc(e.position):"start"in e||"end"in e?Cc(e):"line"in e||"column"in e?na(e):""}function na(e){return Tc(e&&e.line)+":"+Tc(e&&e.column)}function Cc(e){return na(e&&e.start)+"-"+na(e&&e.end)}function Tc(e){return e&&typeof e=="number"?e:1}class dt extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(o=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=ai(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}dt.prototype.file="";dt.prototype.name="";dt.prototype.reason="";dt.prototype.message="";dt.prototype.stack="";dt.prototype.column=void 0;dt.prototype.line=void 0;dt.prototype.ancestors=void 0;dt.prototype.cause=void 0;dt.prototype.fatal=void 0;dt.prototype.place=void 0;dt.prototype.ruleId=void 0;dt.prototype.source=void 0;const Ga={}.hasOwnProperty,e0=new Map,t0=/[A-Z]/g,n0=new Set(["table","tbody","thead","tfoot","tr"]),r0=new Set(["td","th"]),Rp="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function i0(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=f0(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=d0(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Wa:Jw,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=$p(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function $p(e,t,n){if(t.type==="element")return s0(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return o0(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return l0(e,t,n);if(t.type==="mdxjsEsm")return a0(e,t);if(t.type==="root")return c0(e,t,n);if(t.type==="text")return u0(e,t)}function s0(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Wa,e.schema=i),e.ancestors.push(t);const s=Fp(e,t.tagName,!1),o=p0(e,t);let a=Ya(e,t);return n0.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!Dw(l):!0})),Mp(e,o,s,t),Ka(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function o0(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)}yi(e,t.position)}function a0(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);yi(e,t.position)}function l0(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Wa,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:Fp(e,t.name,!0),o=h0(e,t),a=Ya(e,t);return Mp(e,o,s,t),Ka(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function c0(e,t,n){const r={};return Ka(r,Ya(e,t)),e.create(t,e.Fragment,r,n)}function u0(e,t){return t.value}function Mp(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Ka(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function d0(e,t,n){return r;function r(i,s,o,a){const u=Array.isArray(o.children)?n:t;return a?u(s,o,a):u(s,o)}}function f0(e,t){return n;function n(r,i,s,o){const a=Array.isArray(s.children),l=qa(r);return t(i,s,o,a,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function p0(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Ga.call(t.properties,i)){const s=m0(e,i,t.properties[i]);if(s){const[o,a]=s;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&r0.has(t.tagName)?r=a:n[o]=a}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function h0(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const o=s.expression;o.type;const a=o.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else yi(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,s=e.evaluater.evaluateExpression(a.expression)}else yi(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function Ya(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:e0;for(;++r<t.children.length;){const s=t.children[r];let o;if(e.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const u=i.get(l)||0;o=l+"-"+u,i.set(l,u+1)}}const a=$p(e,s,o);a!==void 0&&n.push(a)}return n}function m0(e,t,n){const r=Vw(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Iw(n):Hw(n)),r.property==="style"){let i=typeof n=="object"?n:g0(e,String(n));return e.stylePropertyNameCase==="css"&&(i=x0(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?Fw[r.property]||r.property:r.attribute,n]}}function g0(e,t){try{return Xw(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new dt("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=Rp+"#cannot-parse-style-attribute",i}}function Fp(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,o;for(;++s<i.length;){const a=vc(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};o=o?{type:"MemberExpression",object:o,property:a,computed:!!(s&&a.type==="Literal"),optional:!1}:a}r=o}else r=vc(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Ga.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);yi(e)}function yi(e,t){const n=new dt("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=Rp+"#cannot-handle-mdx-estrees-without-createevaluater",n}function x0(e){const t={};let n;for(n in e)Ga.call(e,n)&&(t[y0(n)]=e[n]);return t}function y0(e){let t=e.replace(t0,b0);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function b0(e){return"-"+e.toLowerCase()}const ho={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"]},v0={};function Xa(e,t){const n=v0,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Lp(e,r,i)}function Lp(e,t,n){if(w0(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 Ic(e.children,t,n)}return Array.isArray(e)?Ic(e,t,n):""}function Ic(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=Lp(e[i],t,n);return r.join("")}function w0(e){return!!(e&&typeof e=="object")}const Ac=document.createElement("i");function Qa(e){const t="&"+e+";";Ac.innerHTML=t;const n=Ac.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function At(e,t,n,r){const i=e.length;let s=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);s<r.length;)o=r.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function Mt(e,t){return e.length>0?(At(e,e.length,0,t),e):t}const zc={}.hasOwnProperty;function Bp(e){const t={};let n=-1;for(;++n<e.length;)k0(t,e[n]);return t}function k0(e,t){let n;for(n in t){const i=(zc.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){zc.call(i,o)||(i[o]=[]);const a=s[o];S0(i[o],Array.isArray(a)?a:a?[a]:[])}}}function S0(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);At(e,0,0,r)}function Vp(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 Wt(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const xt=_n(/[A-Za-z]/),ut=_n(/[\dA-Za-z]/),j0=_n(/[#-'*+\--9=?A-Z^-~]/);function ms(e){return e!==null&&(e<32||e===127)}const ra=_n(/\d/),_0=_n(/[\dA-Fa-f]/),N0=_n(/[!-/:-@[-`{-~]/);function be(e){return e!==null&&e<-2}function Ve(e){return e!==null&&(e<0||e===32)}function Ie(e){return e===-2||e===-1||e===32}const Vs=_n(new RegExp("\\p{P}|\\p{S}","u")),Bn=_n(/\s/);function _n(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Or(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&ut(e.charCodeAt(n+1))&&ut(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const a=e.charCodeAt(n+1);s<56320&&a>56319&&a<57344?(o=String.fromCharCode(s,a),i=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function Pe(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(l){return Ie(l)?(e.enter(n),a(l)):t(l)}function a(l){return Ie(l)&&s++<i?(e.consume(l),a):(e.exit(n),t(l))}}const E0={tokenize:C0};function C0(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Pe(e,t,"linePrefix")}function i(a){return e.enter("paragraph"),s(a)}function s(a){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(a)}function o(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return be(a)?(e.consume(a),e.exit("chunkText"),s):(e.consume(a),o)}}const T0={tokenize:I0},Oc={tokenize:A0};function I0(e){const t=this,n=[];let r=0,i,s,o;return a;function a(m){if(r<n.length){const A=n[r];return t.containerState=A[1],e.attempt(A[0].continuation,l,u)(m)}return u(m)}function l(m){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&j();const A=t.events.length;let C=A,v;for(;C--;)if(t.events[C][0]==="exit"&&t.events[C][1].type==="chunkFlow"){v=t.events[C][1].end;break}y(r);let w=A;for(;w<t.events.length;)t.events[w][1].end={...v},w++;return At(t.events,C+1,0,t.events.slice(A)),t.events.length=w,u(m)}return a(m)}function u(m){if(r===n.length){if(!i)return h(m);if(i.currentConstruct&&i.currentConstruct.concrete)return g(m);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Oc,d,f)(m)}function d(m){return i&&j(),y(r),h(m)}function f(m){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,g(m)}function h(m){return t.containerState={},e.attempt(Oc,p,g)(m)}function p(m){return r++,n.push([t.currentConstruct,t.containerState]),h(m)}function g(m){if(m===null){i&&j(),y(0),e.consume(m);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),k(m)}function k(m){if(m===null){S(e.exit("chunkFlow"),!0),y(0),e.consume(m);return}return be(m)?(e.consume(m),S(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(m),k)}function S(m,A){const C=t.sliceStream(m);if(A&&C.push(null),m.previous=s,s&&(s.next=m),s=m,i.defineSkip(m.start),i.write(C),t.parser.lazy[m.start.line]){let v=i.events.length;for(;v--;)if(i.events[v][1].start.offset<o&&(!i.events[v][1].end||i.events[v][1].end.offset>o))return;const w=t.events.length;let O=w,B,N;for(;O--;)if(t.events[O][0]==="exit"&&t.events[O][1].type==="chunkFlow"){if(B){N=t.events[O][1].end;break}B=!0}for(y(r),v=w;v<t.events.length;)t.events[v][1].end={...N},v++;At(t.events,O+1,0,t.events.slice(w)),t.events.length=v}}function y(m){let A=n.length;for(;A-- >m;){const C=n[A];t.containerState=C[1],C[0].exit.call(t,e)}n.length=m}function j(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function A0(e,t,n){return Pe(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function jr(e){if(e===null||Ve(e)||Bn(e))return 1;if(Vs(e))return 2}function Zs(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 ia={name:"attention",resolveAll:z0,tokenize:O0};function z0(e,t){let n=-1,r,i,s,o,a,l,u,d;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},h={...e[n][1].start};Pc(f,-l),Pc(h,l),o={type:l>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:h},s={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[r][1].end={...o.start},e[n][1].start={...a.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=Mt(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Mt(u,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),u=Mt(u,Zs(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Mt(u,[["exit",s,t],["enter",a,t],["exit",a,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,u=Mt(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,At(e,r-1,n-r+3,u),n=r+u.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function O0(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=jr(r);let s;return o;function o(l){return s=l,e.enter("attentionSequence"),a(l)}function a(l){if(l===s)return e.consume(l),a;const u=e.exit("attentionSequence"),d=jr(l),f=!d||d===2&&i||n.includes(l),h=!i||i===2&&d||n.includes(r);return u._open=!!(s===42?f:f&&(i||!h)),u._close=!!(s===42?h:h&&(d||!f)),t(l)}}function Pc(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const P0={name:"autolink",tokenize:D0};function D0(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 xt(p)?(e.consume(p),o):p===64?n(p):u(p)}function o(p){return p===43||p===45||p===46||ut(p)?(r=1,a(p)):u(p)}function a(p){return p===58?(e.consume(p),r=0,l):(p===43||p===45||p===46||ut(p))&&r++<32?(e.consume(p),a):(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||ms(p)?n(p):(e.consume(p),l)}function u(p){return p===64?(e.consume(p),d):j0(p)?(e.consume(p),u):n(p)}function d(p){return ut(p)?f(p):n(p)}function f(p){return p===46?(e.consume(p),r=0,d):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):h(p)}function h(p){if((p===45||ut(p))&&r++<63){const g=p===45?h:f;return e.consume(p),g}return n(p)}}const zi={partial:!0,tokenize:R0};function R0(e,t,n){return r;function r(s){return Ie(s)?Pe(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||be(s)?t(s):n(s)}}const Zp={continuation:{tokenize:M0},exit:F0,name:"blockQuote",tokenize:$0};function $0(e,t,n){const r=this;return i;function i(o){if(o===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),s}return n(o)}function s(o){return Ie(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function M0(e,t,n){const r=this;return i;function i(o){return Ie(o)?Pe(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(Zp,t,n)(o)}}function F0(e){e.exit("blockQuote")}const Up={name:"characterEscape",tokenize:L0};function L0(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 N0(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const Jp={name:"characterReference",tokenize:B0};function B0(e,t,n){const r=this;let i=0,s,o;return a;function a(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),l}function l(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),s=31,o=ut,d(f))}function u(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=_0,d):(e.enter("characterReferenceValue"),s=7,o=ra,d(f))}function d(f){if(f===59&&i){const h=e.exit("characterReferenceValue");return o===ut&&!Qa(r.sliceSerialize(h))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(f)&&i++<s?(e.consume(f),d):n(f)}}const Dc={partial:!0,tokenize:Z0},Rc={concrete:!0,name:"codeFenced",tokenize:V0};function V0(e,t,n){const r=this,i={partial:!0,tokenize:C};let s=0,o=0,a;return l;function l(v){return u(v)}function u(v){const w=r.events[r.events.length-1];return s=w&&w[1].type==="linePrefix"?w[2].sliceSerialize(w[1],!0).length:0,a=v,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(v)}function d(v){return v===a?(o++,e.consume(v),d):o<3?n(v):(e.exit("codeFencedFenceSequence"),Ie(v)?Pe(e,f,"whitespace")(v):f(v))}function f(v){return v===null||be(v)?(e.exit("codeFencedFence"),r.interrupt?t(v):e.check(Dc,k,A)(v)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),h(v))}function h(v){return v===null||be(v)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(v)):Ie(v)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Pe(e,p,"whitespace")(v)):v===96&&v===a?n(v):(e.consume(v),h)}function p(v){return v===null||be(v)?f(v):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(v))}function g(v){return v===null||be(v)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(v)):v===96&&v===a?n(v):(e.consume(v),g)}function k(v){return e.attempt(i,A,S)(v)}function S(v){return e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),y}function y(v){return s>0&&Ie(v)?Pe(e,j,"linePrefix",s+1)(v):j(v)}function j(v){return v===null||be(v)?e.check(Dc,k,A)(v):(e.enter("codeFlowValue"),m(v))}function m(v){return v===null||be(v)?(e.exit("codeFlowValue"),j(v)):(e.consume(v),m)}function A(v){return e.exit("codeFenced"),t(v)}function C(v,w,O){let B=0;return N;function N(M){return v.enter("lineEnding"),v.consume(M),v.exit("lineEnding"),R}function R(M){return v.enter("codeFencedFence"),Ie(M)?Pe(v,T,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(M):T(M)}function T(M){return M===a?(v.enter("codeFencedFenceSequence"),F(M)):O(M)}function F(M){return M===a?(B++,v.consume(M),F):B>=o?(v.exit("codeFencedFenceSequence"),Ie(M)?Pe(v,z,"whitespace")(M):z(M)):O(M)}function z(M){return M===null||be(M)?(v.exit("codeFencedFence"),w(M)):O(M)}}}function Z0(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const mo={name:"codeIndented",tokenize:J0},U0={partial:!0,tokenize:H0};function J0(e,t,n){const r=this;return i;function i(u){return e.enter("codeIndented"),Pe(e,s,"linePrefix",5)(u)}function s(u){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?o(u):n(u)}function o(u){return u===null?l(u):be(u)?e.attempt(U0,o,l)(u):(e.enter("codeFlowValue"),a(u))}function a(u){return u===null||be(u)?(e.exit("codeFlowValue"),o(u)):(e.consume(u),a)}function l(u){return e.exit("codeIndented"),t(u)}}function H0(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):be(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):Pe(e,s,"linePrefix",5)(o)}function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):be(o)?i(o):n(o)}}const W0={name:"codeText",previous:G0,resolve:q0,tokenize:K0};function q0(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 G0(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function K0(e,t,n){let r=0,i,s;return o;function o(f){return e.enter("codeText"),e.enter("codeTextSequence"),a(f)}function a(f){return f===96?(e.consume(f),r++,a):(e.exit("codeTextSequence"),l(f))}function l(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),l):f===96?(s=e.enter("codeTextSequence"),i=0,d(f)):be(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),l):(e.enter("codeTextData"),u(f))}function u(f){return f===null||f===32||f===96||be(f)?(e.exit("codeTextData"),l(f)):(e.consume(f),u)}function d(f){return f===96?(e.consume(f),i++,d):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(s.type="codeTextData",u(f))}}class Y0{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&&Hr(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),Hr(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Hr(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);Hr(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Hr(this.left,n.reverse())}}}function Hr(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 Hp(e){const t={};let n=-1,r,i,s,o,a,l,u;const d=new Y0(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type==="chunkFlow"&&d.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,X0(d,n)),n=t[n],u=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(o=d.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(d.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...d.get(i)[1].start},a=d.slice(i,n),a.unshift(r),d.splice(i,n-i+1,a))}}return At(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function X0(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,l=[],u={};let d,f,h=-1,p=n,g=0,k=0;const S=[k];for(;p;){for(;e.get(++i)[1]!==p;);s.push(i),p._tokenizer||(d=r.sliceStream(p),p.next||d.push(null),f&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(d),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),f=p,p=p.next}for(p=n;++h<a.length;)a[h][0]==="exit"&&a[h-1][0]==="enter"&&a[h][1].type===a[h-1][1].type&&a[h][1].start.line!==a[h][1].end.line&&(k=h+1,S.push(k),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):S.pop(),h=S.length;h--;){const y=a.slice(S[h],S[h+1]),j=s.pop();l.push([j,j+y.length-1]),e.splice(j,2,y)}for(l.reverse(),h=-1;++h<l.length;)u[g+l[h][0]]=g+l[h][1],g+=l[h][1]-l[h][0]-1;return u}const Q0={resolve:tk,tokenize:nk},ek={partial:!0,tokenize:rk};function tk(e){return Hp(e),e}function nk(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?s(a):be(a)?e.check(ek,o,s)(a):(e.consume(a),i)}function s(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function o(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function rk(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),Pe(e,s,"linePrefix")}function s(o){if(o===null||be(o))return n(o);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function Wp(e,t,n,r,i,s,o,a,l){const u=l||Number.POSITIVE_INFINITY;let d=0;return f;function f(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||ms(y)?n(y):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),k(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(a),e.enter("chunkString",{contentType:"string"}),p(y))}function p(y){return y===62?(e.exit("chunkString"),e.exit(a),h(y)):y===null||y===60||be(y)?n(y):(e.consume(y),y===92?g:p)}function g(y){return y===60||y===62||y===92?(e.consume(y),p):p(y)}function k(y){return!d&&(y===null||y===41||Ve(y))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(y)):d<u&&y===40?(e.consume(y),d++,k):y===41?(e.consume(y),d--,k):y===null||y===32||y===40||ms(y)?n(y):(e.consume(y),y===92?S:k)}function S(y){return y===40||y===41||y===92?(e.consume(y),k):k(y)}}function qp(e,t,n,r,i,s){const o=this;let a=0,l;return u;function u(p){return e.enter(r),e.enter(i),e.consume(p),e.exit(i),e.enter(s),d}function d(p){return a>999||p===null||p===91||p===93&&!l||p===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(p):p===93?(e.exit(s),e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):be(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===null||p===91||p===93||be(p)||a++>999?(e.exit("chunkString"),d(p)):(e.consume(p),l||(l=!Ie(p)),p===92?h:f)}function h(p){return p===91||p===92||p===93?(e.consume(p),a++,f):f(p)}}function Gp(e,t,n,r,i,s){let o;return a;function a(h){return h===34||h===39||h===40?(e.enter(r),e.enter(i),e.consume(h),e.exit(i),o=h===40?41:h,l):n(h)}function l(h){return h===o?(e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):(e.enter(s),u(h))}function u(h){return h===o?(e.exit(s),l(o)):h===null?n(h):be(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),Pe(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(h))}function d(h){return h===o||h===null||be(h)?(e.exit("chunkString"),u(h)):(e.consume(h),h===92?f:d)}function f(h){return h===o||h===92?(e.consume(h),d):d(h)}}function li(e,t){let n;return r;function r(i){return be(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Ie(i)?Pe(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const ik={name:"definition",tokenize:ok},sk={partial:!0,tokenize:ak};function ok(e,t,n){const r=this;let i;return s;function s(p){return e.enter("definition"),o(p)}function o(p){return qp.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return i=Wt(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 Ve(p)?li(e,u)(p):u(p)}function u(p){return Wp(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function d(p){return e.attempt(sk,f,f)(p)}function f(p){return Ie(p)?Pe(e,h,"whitespace")(p):h(p)}function h(p){return p===null||be(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function ak(e,t,n){return r;function r(a){return Ve(a)?li(e,i)(a):n(a)}function i(a){return Gp(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return Ie(a)?Pe(e,o,"whitespace")(a):o(a)}function o(a){return a===null||be(a)?t(a):n(a)}}const lk={name:"hardBreakEscape",tokenize:ck};function ck(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return be(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const uk={name:"headingAtx",resolve:dk,tokenize:fk};function dk(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"},At(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function fk(e,t,n){let r=0;return i;function i(d){return e.enter("atxHeading"),s(d)}function s(d){return e.enter("atxHeadingSequence"),o(d)}function o(d){return d===35&&r++<6?(e.consume(d),o):d===null||Ve(d)?(e.exit("atxHeadingSequence"),a(d)):n(d)}function a(d){return d===35?(e.enter("atxHeadingSequence"),l(d)):d===null||be(d)?(e.exit("atxHeading"),t(d)):Ie(d)?Pe(e,a,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function l(d){return d===35?(e.consume(d),l):(e.exit("atxHeadingSequence"),a(d))}function u(d){return d===null||d===35||Ve(d)?(e.exit("atxHeadingText"),a(d)):(e.consume(d),u)}}const pk=["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"],$c=["pre","script","style","textarea"],hk={concrete:!0,name:"htmlFlow",resolveTo:xk,tokenize:yk},mk={partial:!0,tokenize:vk},gk={partial:!0,tokenize:bk};function xk(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 yk(e,t,n){const r=this;let i,s,o,a,l;return u;function u(b){return d(b)}function d(b){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(b),f}function f(b){return b===33?(e.consume(b),h):b===47?(e.consume(b),s=!0,k):b===63?(e.consume(b),i=3,r.interrupt?t:_):xt(b)?(e.consume(b),o=String.fromCharCode(b),S):n(b)}function h(b){return b===45?(e.consume(b),i=2,p):b===91?(e.consume(b),i=5,a=0,g):xt(b)?(e.consume(b),i=4,r.interrupt?t:_):n(b)}function p(b){return b===45?(e.consume(b),r.interrupt?t:_):n(b)}function g(b){const G="CDATA[";return b===G.charCodeAt(a++)?(e.consume(b),a===G.length?r.interrupt?t:T:g):n(b)}function k(b){return xt(b)?(e.consume(b),o=String.fromCharCode(b),S):n(b)}function S(b){if(b===null||b===47||b===62||Ve(b)){const G=b===47,ne=o.toLowerCase();return!G&&!s&&$c.includes(ne)?(i=1,r.interrupt?t(b):T(b)):pk.includes(o.toLowerCase())?(i=6,G?(e.consume(b),y):r.interrupt?t(b):T(b)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(b):s?j(b):m(b))}return b===45||ut(b)?(e.consume(b),o+=String.fromCharCode(b),S):n(b)}function y(b){return b===62?(e.consume(b),r.interrupt?t:T):n(b)}function j(b){return Ie(b)?(e.consume(b),j):N(b)}function m(b){return b===47?(e.consume(b),N):b===58||b===95||xt(b)?(e.consume(b),A):Ie(b)?(e.consume(b),m):N(b)}function A(b){return b===45||b===46||b===58||b===95||ut(b)?(e.consume(b),A):C(b)}function C(b){return b===61?(e.consume(b),v):Ie(b)?(e.consume(b),C):m(b)}function v(b){return b===null||b===60||b===61||b===62||b===96?n(b):b===34||b===39?(e.consume(b),l=b,w):Ie(b)?(e.consume(b),v):O(b)}function w(b){return b===l?(e.consume(b),l=null,B):b===null||be(b)?n(b):(e.consume(b),w)}function O(b){return b===null||b===34||b===39||b===47||b===60||b===61||b===62||b===96||Ve(b)?C(b):(e.consume(b),O)}function B(b){return b===47||b===62||Ie(b)?m(b):n(b)}function N(b){return b===62?(e.consume(b),R):n(b)}function R(b){return b===null||be(b)?T(b):Ie(b)?(e.consume(b),R):n(b)}function T(b){return b===45&&i===2?(e.consume(b),D):b===60&&i===1?(e.consume(b),J):b===62&&i===4?(e.consume(b),ye):b===63&&i===3?(e.consume(b),_):b===93&&i===5?(e.consume(b),X):be(b)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(mk,ce,F)(b)):b===null||be(b)?(e.exit("htmlFlowData"),F(b)):(e.consume(b),T)}function F(b){return e.check(gk,z,ce)(b)}function z(b){return e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),M}function M(b){return b===null||be(b)?F(b):(e.enter("htmlFlowData"),T(b))}function D(b){return b===45?(e.consume(b),_):T(b)}function J(b){return b===47?(e.consume(b),o="",Z):T(b)}function Z(b){if(b===62){const G=o.toLowerCase();return $c.includes(G)?(e.consume(b),ye):T(b)}return xt(b)&&o.length<8?(e.consume(b),o+=String.fromCharCode(b),Z):T(b)}function X(b){return b===93?(e.consume(b),_):T(b)}function _(b){return b===62?(e.consume(b),ye):b===45&&i===2?(e.consume(b),_):T(b)}function ye(b){return b===null||be(b)?(e.exit("htmlFlowData"),ce(b)):(e.consume(b),ye)}function ce(b){return e.exit("htmlFlow"),t(b)}}function bk(e,t,n){const r=this;return i;function i(o){return be(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):n(o)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function vk(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(zi,t,n)}}const wk={name:"htmlText",tokenize:kk};function kk(e,t,n){const r=this;let i,s,o;return a;function a(_){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(_),l}function l(_){return _===33?(e.consume(_),u):_===47?(e.consume(_),C):_===63?(e.consume(_),m):xt(_)?(e.consume(_),O):n(_)}function u(_){return _===45?(e.consume(_),d):_===91?(e.consume(_),s=0,g):xt(_)?(e.consume(_),j):n(_)}function d(_){return _===45?(e.consume(_),p):n(_)}function f(_){return _===null?n(_):_===45?(e.consume(_),h):be(_)?(o=f,J(_)):(e.consume(_),f)}function h(_){return _===45?(e.consume(_),p):f(_)}function p(_){return _===62?D(_):_===45?h(_):f(_)}function g(_){const ye="CDATA[";return _===ye.charCodeAt(s++)?(e.consume(_),s===ye.length?k:g):n(_)}function k(_){return _===null?n(_):_===93?(e.consume(_),S):be(_)?(o=k,J(_)):(e.consume(_),k)}function S(_){return _===93?(e.consume(_),y):k(_)}function y(_){return _===62?D(_):_===93?(e.consume(_),y):k(_)}function j(_){return _===null||_===62?D(_):be(_)?(o=j,J(_)):(e.consume(_),j)}function m(_){return _===null?n(_):_===63?(e.consume(_),A):be(_)?(o=m,J(_)):(e.consume(_),m)}function A(_){return _===62?D(_):m(_)}function C(_){return xt(_)?(e.consume(_),v):n(_)}function v(_){return _===45||ut(_)?(e.consume(_),v):w(_)}function w(_){return be(_)?(o=w,J(_)):Ie(_)?(e.consume(_),w):D(_)}function O(_){return _===45||ut(_)?(e.consume(_),O):_===47||_===62||Ve(_)?B(_):n(_)}function B(_){return _===47?(e.consume(_),D):_===58||_===95||xt(_)?(e.consume(_),N):be(_)?(o=B,J(_)):Ie(_)?(e.consume(_),B):D(_)}function N(_){return _===45||_===46||_===58||_===95||ut(_)?(e.consume(_),N):R(_)}function R(_){return _===61?(e.consume(_),T):be(_)?(o=R,J(_)):Ie(_)?(e.consume(_),R):B(_)}function T(_){return _===null||_===60||_===61||_===62||_===96?n(_):_===34||_===39?(e.consume(_),i=_,F):be(_)?(o=T,J(_)):Ie(_)?(e.consume(_),T):(e.consume(_),z)}function F(_){return _===i?(e.consume(_),i=void 0,M):_===null?n(_):be(_)?(o=F,J(_)):(e.consume(_),F)}function z(_){return _===null||_===34||_===39||_===60||_===61||_===96?n(_):_===47||_===62||Ve(_)?B(_):(e.consume(_),z)}function M(_){return _===47||_===62||Ve(_)?B(_):n(_)}function D(_){return _===62?(e.consume(_),e.exit("htmlTextData"),e.exit("htmlText"),t):n(_)}function J(_){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),Z}function Z(_){return Ie(_)?Pe(e,X,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(_):X(_)}function X(_){return e.enter("htmlTextData"),o(_)}}const el={name:"labelEnd",resolveAll:Nk,resolveTo:Ek,tokenize:Ck},Sk={tokenize:Tk},jk={tokenize:Ik},_k={tokenize:Ak};function Nk(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&&At(e,0,e.length,n),e}function Ek(e,t){let n=e.length,r=0,i,s,o,a;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=n);const l={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[s][1].start},end:{...e[o][1].end}},d={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[o-2][1].start}};return a=[["enter",l,t],["enter",u,t]],a=Mt(a,e.slice(s+1,s+r+3)),a=Mt(a,[["enter",d,t]]),a=Mt(a,Zs(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),a=Mt(a,[["exit",d,t],e[o-2],e[o-1],["exit",u,t]]),a=Mt(a,e.slice(o+1)),a=Mt(a,[["exit",l,t]]),At(e,s,e.length,a),e}function Ck(e,t,n){const r=this;let i=r.events.length,s,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return a;function a(h){return s?s._inactive?f(h):(o=r.parser.defined.includes(Wt(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(Sk,d,o?d:f)(h):h===91?e.attempt(jk,d,o?u:f)(h):o?d(h):f(h)}function u(h){return e.attempt(_k,d,f)(h)}function d(h){return t(h)}function f(h){return s._balanced=!0,n(h)}}function Tk(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),i}function i(f){return Ve(f)?li(e,s)(f):s(f)}function s(f){return f===41?d(f):Wp(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function o(f){return Ve(f)?li(e,l)(f):d(f)}function a(f){return n(f)}function l(f){return f===34||f===39||f===40?Gp(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):d(f)}function u(f){return Ve(f)?li(e,d)(f):d(f)}function d(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function Ik(e,t,n){const r=this;return i;function i(a){return qp.call(r,e,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(Wt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function Ak(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 zk={name:"labelStartImage",resolveAll:el.resolveAll,tokenize:Ok};function Ok(e,t,n){const r=this;return i;function i(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),s}function s(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),o):n(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const Pk={name:"labelStartLink",resolveAll:el.resolveAll,tokenize:Dk};function Dk(e,t,n){const r=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const go={name:"lineEnding",tokenize:Rk};function Rk(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Pe(e,t,"linePrefix")}}const Xi={name:"thematicBreak",tokenize:$k};function $k(e,t,n){let r=0,i;return s;function s(u){return e.enter("thematicBreak"),o(u)}function o(u){return i=u,a(u)}function a(u){return u===i?(e.enter("thematicBreakSequence"),l(u)):r>=3&&(u===null||be(u))?(e.exit("thematicBreak"),t(u)):n(u)}function l(u){return u===i?(e.consume(u),r++,l):(e.exit("thematicBreakSequence"),Ie(u)?Pe(e,a,"whitespace")(u):a(u))}}const vt={continuation:{tokenize:Bk},exit:Zk,name:"list",tokenize:Lk},Mk={partial:!0,tokenize:Uk},Fk={partial:!0,tokenize:Vk};function Lk(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return a;function a(p){const g=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:ra(p)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(Xi,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 ra(p)&&++o<10?(e.consume(p),l):(!r.interrupt||o<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(zi,r.interrupt?n:d,e.attempt(Mk,h,f))}function d(p){return r.containerState.initialBlankLine=!0,s++,h(p)}function f(p){return Ie(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 Bk(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(zi,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Pe(e,t,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!Ie(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Fk,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Pe(e,e.attempt(vt,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function Vk(e,t,n){const r=this;return Pe(e,i,"listItemIndent",r.containerState.size+1);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(s):n(s)}}function Zk(e){e.exit(this.containerState.type)}function Uk(e,t,n){const r=this;return Pe(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=r.events[r.events.length-1];return!Ie(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const Mc={name:"setextUnderline",resolveTo:Jk,tokenize:Hk};function Jk(e,t){let n=e.length,r,i,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",o,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function Hk(e,t,n){const r=this;let i;return s;function s(u){let d=r.events.length,f;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){f=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),i=u,o(u)):n(u)}function o(u){return e.enter("setextHeadingLineSequence"),a(u)}function a(u){return u===i?(e.consume(u),a):(e.exit("setextHeadingLineSequence"),Ie(u)?Pe(e,l,"lineSuffix")(u):l(u))}function l(u){return u===null||be(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const Wk={tokenize:qk};function qk(e){const t=this,n=e.attempt(zi,r,e.attempt(this.parser.constructs.flowInitial,i,Pe(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Q0,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 Gk={resolveAll:Yp()},Kk=Kp("string"),Yk=Kp("text");function Kp(e){return{resolveAll:Yp(e==="text"?Xk:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,o,a);return o;function o(d){return u(d)?s(d):a(d)}function a(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),l}function l(d){return u(d)?(n.exit("data"),s(d)):(n.consume(d),l)}function u(d){if(d===null)return!0;const f=i[d];let h=-1;if(f)for(;++h<f.length;){const p=f[h];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function Yp(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 Xk(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,o=-1,a=0,l;for(;s--;){const u=i[s];if(typeof u=="string"){for(o=u.length;u.charCodeAt(o-1)===32;)a++,o--;if(o)break;o=-1}else if(u===-2)l=!0,a++;else if(u!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const u={type:n===e.length||l||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:r.start._bufferIndex+o,_index:r.start._index+s,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...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 Qk={42:vt,43:vt,45:vt,48:vt,49:vt,50:vt,51:vt,52:vt,53:vt,54:vt,55:vt,56:vt,57:vt,62:Zp},e1={91:ik},t1={[-2]:mo,[-1]:mo,32:mo},n1={35:uk,42:Xi,45:[Mc,Xi],60:hk,61:Mc,95:Xi,96:Rc,126:Rc},r1={38:Jp,92:Up},i1={[-5]:go,[-4]:go,[-3]:go,33:zk,38:Jp,42:ia,60:[P0,wk],91:Pk,92:[lk,Up],93:el,95:ia,96:W0},s1={null:[ia,Gk]},o1={null:[42,95]},a1={null:[]},l1=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:o1,contentInitial:e1,disable:a1,document:Qk,flow:n1,flowInitial:t1,insideSpan:s1,string:r1,text:i1},Symbol.toStringTag,{value:"Module"}));function c1(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let o=[],a=[];const l={attempt:w(C),check:w(v),consume:j,enter:m,exit:A,interrupt:w(v,{interrupt:!0})},u={code:null,containerState:{},defineSkip:k,events:[],now:g,parser:e,previous:null,sliceSerialize:h,sliceStream:p,write:f};let d=t.tokenize.call(u,l);return t.resolveAll&&s.push(t),u;function f(R){return o=Mt(o,R),S(),o[o.length-1]!==null?[]:(O(t,0),u.events=Zs(s,u.events,u),u.events)}function h(R,T){return d1(p(R),T)}function p(R){return u1(o,R)}function g(){const{_bufferIndex:R,_index:T,line:F,column:z,offset:M}=r;return{_bufferIndex:R,_index:T,line:F,column:z,offset:M}}function k(R){i[R.line]=R.column,N()}function S(){let R;for(;r._index<o.length;){const T=o[r._index];if(typeof T=="string")for(R=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===R&&r._bufferIndex<T.length;)y(T.charCodeAt(r._bufferIndex));else y(T)}}function y(R){d=d(R)}function j(R){be(R)?(r.line++,r.column=1,r.offset+=R===-3?2:1,N()):R!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=R}function m(R,T){const F=T||{};return F.type=R,F.start=g(),u.events.push(["enter",F,u]),a.push(F),F}function A(R){const T=a.pop();return T.end=g(),u.events.push(["exit",T,u]),T}function C(R,T){O(R,T.from)}function v(R,T){T.restore()}function w(R,T){return F;function F(z,M,D){let J,Z,X,_;return Array.isArray(z)?ce(z):"tokenize"in z?ce([z]):ye(z);function ye(Q){return oe;function oe(I){const re=I!==null&&Q[I],ae=I!==null&&Q.null,H=[...Array.isArray(re)?re:re?[re]:[],...Array.isArray(ae)?ae:ae?[ae]:[]];return ce(H)(I)}}function ce(Q){return J=Q,Z=0,Q.length===0?D:b(Q[Z])}function b(Q){return oe;function oe(I){return _=B(),X=Q,Q.partial||(u.currentConstruct=Q),Q.name&&u.parser.constructs.disable.null.includes(Q.name)?ne():Q.tokenize.call(T?Object.assign(Object.create(u),T):u,l,G,ne)(I)}}function G(Q){return R(X,_),M}function ne(Q){return _.restore(),++Z<J.length?b(J[Z]):D}}}function O(R,T){R.resolveAll&&!s.includes(R)&&s.push(R),R.resolve&&At(u.events,T,u.events.length-T,R.resolve(u.events.slice(T),u)),R.resolveTo&&(u.events=R.resolveTo(u.events,u))}function B(){const R=g(),T=u.previous,F=u.currentConstruct,z=u.events.length,M=Array.from(a);return{from:z,restore:D};function D(){r=R,u.previous=T,u.currentConstruct=F,u.events.length=z,a=M,N()}}function N(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function u1(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,s)];else{if(o=e.slice(n,i),r>-1){const a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}s>0&&o.push(e[i].slice(0,s))}return o}function d1(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
|
|
156
156
|
`;break}case-3:{o=`\r
|
|
157
157
|
`;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,r.push(o)}return r.join("")}function f1(e){const r={constructs:Bp([l1,...(e||{}).extensions||[]]),content:i(E0),defined:[],document:i(T0),flow:i(Wk),lazy:{},string:i(Kk),text:i(Yk)};return r;function i(s){return o;function o(a){return c1(r,s,a)}}}function p1(e){for(;!Hp(e););return e}const Fc=/[\0\t\n\r]/g;function h1(){let e=1,t="",n=!0,r;return i;function i(s,o,a){const l=[];let u,d,f,h,p;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),f=0,t="",n&&(s.charCodeAt(0)===65279&&f++,n=void 0);f<s.length;){if(Fc.lastIndex=f,u=Fc.exec(s),h=u&&u.index!==void 0?u.index:s.length,p=s.charCodeAt(h),!u){t=s.slice(f);break}if(p===10&&f===h&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),f<h&&(l.push(s.slice(f,h)),e+=h-f),p){case 0:{l.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,l.push(-2);e++<d;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}f=h+1}return a&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const m1=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function g1(e){return e.replace(m1,x1)}function x1(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return Vp(n.slice(s?2:1),s?16:10)}return Qa(n)||e}const Xp={}.hasOwnProperty;function y1(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),b1(n)(p1(f1(n).document().write(h1()(e,t,!0))))}function b1(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(P),autolinkProtocol:B,autolinkEmail:B,atxHeading:s(Re),blockQuote:s(ae),characterEscape:B,characterReference:B,codeFenced:s(H),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(H,o),codeText:s(K,o),codeTextData:B,data:B,codeFlowValue:B,definition:s(pe),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(fe),hardBreakEscape:s(Oe),hardBreakTrailing:s(Oe),htmlFlow:s($e,o),htmlFlowData:B,htmlText:s($e,o),htmlTextData:B,image:s(E),label:o,link:s(P),listItem:s(se),listItemValue:h,listOrdered:s(V,f),listUnordered:s(V),paragraph:s(ie),reference:b,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(Re),strong:s(ee),thematicBreak:s(we)},exit:{atxHeading:l(),atxHeadingSequence:C,autolink:l(),autolinkEmail:re,autolinkProtocol:I,blockQuote:l(),characterEscapeValue:N,characterReferenceMarkerHexadecimal:ne,characterReferenceMarkerNumeric:ne,characterReferenceValue:Q,characterReference:oe,codeFenced:l(S),codeFencedFence:k,codeFencedFenceInfo:p,codeFencedFenceMeta:g,codeFlowValue:N,codeIndented:l(y),codeText:l(M),codeTextData:N,data:N,definition:l(),definitionDestinationString:A,definitionLabelString:j,definitionTitleString:m,emphasis:l(),hardBreakEscape:l(T),hardBreakTrailing:l(T),htmlFlow:l(F),htmlFlowData:N,htmlText:l(z),htmlTextData:N,image:l(J),label:X,labelText:Z,lineEnding:R,link:l(D),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:G,resourceDestinationString:_,resourceTitleString:ye,resource:ce,setextHeading:l(O),setextHeadingLineSequence:w,setextHeadingText:v,strong:l(),thematicBreak:l()}};Qp(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(U){let Y={type:"root",children:[]};const ge={stack:[Y],tokenStack:[],config:t,enter:a,exit:u,buffer:o,resume:d,data:n},_e=[];let L=-1;for(;++L<U.length;)if(U[L][1].type==="listOrdered"||U[L][1].type==="listUnordered")if(U[L][0]==="enter")_e.push(L);else{const $=_e.pop();L=i(U,$,L)}for(L=-1;++L<U.length;){const $=t[U[L][0]];Xp.call($,U[L][1].type)&&$[U[L][1].type].call(Object.assign({sliceSerialize:U[L][2].sliceSerialize},ge),U[L][1])}if(ge.tokenStack.length>0){const $=ge.tokenStack[ge.tokenStack.length-1];($[1]||Lc).call(ge,void 0,$[0])}for(Y.position={start:pn(U.length>0?U[0][1].start:{line:1,column:1,offset:0}),end:pn(U.length>0?U[U.length-2][1].end:{line:1,column:1,offset:0})},L=-1;++L<t.transforms.length;)Y=t.transforms[L](Y)||Y;return Y}function i(U,Y,ge){let _e=Y-1,L=-1,$=!1,xe,de,Me,Je;for(;++_e<=ge;){const it=U[_e];switch(it[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{it[0]==="enter"?L++:L--,Je=void 0;break}case"lineEndingBlank":{it[0]==="enter"&&(xe&&!Je&&!L&&!Me&&(Me=_e),Je=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Je=void 0}if(!L&&it[0]==="enter"&&it[1].type==="listItemPrefix"||L===-1&&it[0]==="exit"&&(it[1].type==="listUnordered"||it[1].type==="listOrdered")){if(xe){let Lt=_e;for(de=void 0;Lt--;){const Ot=U[Lt];if(Ot[1].type==="lineEnding"||Ot[1].type==="lineEndingBlank"){if(Ot[0]==="exit")continue;de&&(U[de][1].type="lineEndingBlank",$=!0),Ot[1].type="lineEnding",de=Lt}else if(!(Ot[1].type==="linePrefix"||Ot[1].type==="blockQuotePrefix"||Ot[1].type==="blockQuotePrefixWhitespace"||Ot[1].type==="blockQuoteMarker"||Ot[1].type==="listItemIndent"))break}Me&&(!de||Me<de)&&(xe._spread=!0),xe.end=Object.assign({},de?U[de][1].start:it[1].end),U.splice(de||_e,0,["exit",xe,it[2]]),_e++,ge++}if(it[1].type==="listItemPrefix"){const Lt={type:"listItem",_spread:!1,start:Object.assign({},it[1].start),end:void 0};xe=Lt,U.splice(_e,0,["enter",Lt,it[2]]),_e++,ge++,Me=void 0,Je=!0}}}return U[Y][1]._spread=$,ge}function s(U,Y){return ge;function ge(_e){a.call(this,U(_e),_e),Y&&Y.call(this,_e)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(U,Y,ge){this.stack[this.stack.length-1].children.push(U),this.stack.push(U),this.tokenStack.push([Y,ge||void 0]),U.position={start:pn(Y.start),end:void 0}}function l(U){return Y;function Y(ge){U&&U.call(this,ge),u.call(this,ge)}}function u(U,Y){const ge=this.stack.pop(),_e=this.tokenStack.pop();if(_e)_e[0].type!==U.type&&(Y?Y.call(this,U,_e[0]):(_e[1]||Lc).call(this,U,_e[0]));else throw new Error("Cannot close `"+U.type+"` ("+ai({start:U.start,end:U.end})+"): it’s not open");ge.position.end=pn(U.end)}function d(){return Xa(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function h(U){if(this.data.expectingFirstListItemValue){const Y=this.stack[this.stack.length-2];Y.start=Number.parseInt(this.sliceSerialize(U),10),this.data.expectingFirstListItemValue=void 0}}function p(){const U=this.resume(),Y=this.stack[this.stack.length-1];Y.lang=U}function g(){const U=this.resume(),Y=this.stack[this.stack.length-1];Y.meta=U}function k(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const U=this.resume(),Y=this.stack[this.stack.length-1];Y.value=U.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const U=this.resume(),Y=this.stack[this.stack.length-1];Y.value=U.replace(/(\r?\n|\r)$/g,"")}function j(U){const Y=this.resume(),ge=this.stack[this.stack.length-1];ge.label=Y,ge.identifier=Wt(this.sliceSerialize(U)).toLowerCase()}function m(){const U=this.resume(),Y=this.stack[this.stack.length-1];Y.title=U}function A(){const U=this.resume(),Y=this.stack[this.stack.length-1];Y.url=U}function C(U){const Y=this.stack[this.stack.length-1];if(!Y.depth){const ge=this.sliceSerialize(U).length;Y.depth=ge}}function v(){this.data.setextHeadingSlurpLineEnding=!0}function w(U){const Y=this.stack[this.stack.length-1];Y.depth=this.sliceSerialize(U).codePointAt(0)===61?1:2}function O(){this.data.setextHeadingSlurpLineEnding=void 0}function B(U){const ge=this.stack[this.stack.length-1].children;let _e=ge[ge.length-1];(!_e||_e.type!=="text")&&(_e=me(),_e.position={start:pn(U.start),end:void 0},ge.push(_e)),this.stack.push(_e)}function N(U){const Y=this.stack.pop();Y.value+=this.sliceSerialize(U),Y.position.end=pn(U.end)}function R(U){const Y=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ge=Y.children[Y.children.length-1];ge.position.end=pn(U.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Y.type)&&(B.call(this,U),N.call(this,U))}function T(){this.data.atHardBreak=!0}function F(){const U=this.resume(),Y=this.stack[this.stack.length-1];Y.value=U}function z(){const U=this.resume(),Y=this.stack[this.stack.length-1];Y.value=U}function M(){const U=this.resume(),Y=this.stack[this.stack.length-1];Y.value=U}function D(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const Y=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=Y,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function J(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const Y=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=Y,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function Z(U){const Y=this.sliceSerialize(U),ge=this.stack[this.stack.length-2];ge.label=g1(Y),ge.identifier=Wt(Y).toLowerCase()}function X(){const U=this.stack[this.stack.length-1],Y=this.resume(),ge=this.stack[this.stack.length-1];if(this.data.inReference=!0,ge.type==="link"){const _e=U.children;ge.children=_e}else ge.alt=Y}function _(){const U=this.resume(),Y=this.stack[this.stack.length-1];Y.url=U}function ye(){const U=this.resume(),Y=this.stack[this.stack.length-1];Y.title=U}function ce(){this.data.inReference=void 0}function b(){this.data.referenceType="collapsed"}function G(U){const Y=this.resume(),ge=this.stack[this.stack.length-1];ge.label=Y,ge.identifier=Wt(this.sliceSerialize(U)).toLowerCase(),this.data.referenceType="full"}function ne(U){this.data.characterReferenceType=U.type}function Q(U){const Y=this.sliceSerialize(U),ge=this.data.characterReferenceType;let _e;ge?(_e=Vp(Y,ge==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):_e=Qa(Y);const L=this.stack[this.stack.length-1];L.value+=_e}function oe(U){const Y=this.stack.pop();Y.position.end=pn(U.end)}function I(U){N.call(this,U);const Y=this.stack[this.stack.length-1];Y.url=this.sliceSerialize(U)}function re(U){N.call(this,U);const Y=this.stack[this.stack.length-1];Y.url="mailto:"+this.sliceSerialize(U)}function ae(){return{type:"blockquote",children:[]}}function H(){return{type:"code",lang:null,meta:null,value:""}}function K(){return{type:"inlineCode",value:""}}function pe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function fe(){return{type:"emphasis",children:[]}}function Re(){return{type:"heading",depth:0,children:[]}}function Oe(){return{type:"break"}}function $e(){return{type:"html",value:""}}function E(){return{type:"image",title:null,url:"",alt:null}}function P(){return{type:"link",title:null,url:"",children:[]}}function V(U){return{type:"list",ordered:U.type==="listOrdered",start:null,spread:U._spread,children:[]}}function se(U){return{type:"listItem",spread:U._spread,checked:null,children:[]}}function ie(){return{type:"paragraph",children:[]}}function ee(){return{type:"strong",children:[]}}function me(){return{type:"text",value:""}}function we(){return{type:"thematicBreak"}}}function pn(e){return{line:e.line,column:e.column,offset:e.offset}}function Qp(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Qp(e,r):v1(e,r)}}function v1(e,t){let n;for(n in t)if(Xp.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 Lc(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+ai({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+ai({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+ai({start:t.start,end:t.end})+") is still open")}function w1(e){const t=this;t.parser=n;function n(r){return y1(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function k1(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 S1(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
@@ -248,4 +248,4 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
248
248
|
`;)t++;return!0}return!1}function u(Z){if(d(Z)){if(Xu(e[t]))for(;t<e.length&&Qu(e[t]);)t++;return o(),!0}return!1}function d(Z){a(!0);for(const X of Z){const _=t+X.length;if(e.slice(t,_)===X)return t=_,!0}return!1}function f(Z){return e[t]===Z?(n+=e[t],t++,!0):!1}function h(Z){return e[t]===Z?(t++,!0):!1}function p(){return h("\\")}function g(){return o(),e[t]==="."&&e[t+1]==="."&&e[t+2]==="."?(t+=3,o(),h(","),!0):!1}function k(){if(e[t]==="{"){n+="{",t++,o(),h(",")&&o();let Z=!0;for(;t<e.length&&e[t]!=="}";){let X;if(Z?(X=!0,Z=!1):(X=f(","),X||(n=Zt(n,",")),o()),g(),!(j()||w(!0))){e[t]==="}"||e[t]==="{"||e[t]==="]"||e[t]==="["||e[t]===void 0?n=qr(n,","):M();break}o();const ye=f(":"),ce=t>=e.length;ye||(rd(e[t])||ce?n=Zt(n,":"):D()),s()||(ye||ce?n+="null":D())}return e[t]==="}"?(n+="}",t++):n=Zt(n,"}"),!0}return!1}function S(){if(e[t]==="["){n+="[",t++,o(),h(",")&&o();let Z=!0;for(;t<e.length&&e[t]!=="]";)if(Z?Z=!1:f(",")||(n=Zt(n,",")),g(),!s()){n=qr(n,",");break}return e[t]==="]"?(n+="]",t++):n=Zt(n,"]"),!0}return!1}function y(){let Z=!0,X=!0;for(;X;)Z?Z=!1:f(",")||(n=Zt(n,",")),X=s();X||(n=qr(n,",")),n=`[
|
|
249
249
|
${n}
|
|
250
250
|
]`}function j(){let Z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,X=arguments.length>1&&arguments[1]!==void 0?arguments[1]:-1,_=e[t]==="\\";if(_&&(t++,_=!0),ts(e[t])){const ye=id(e[t])?id:sd(e[t])?sd:va(e[t])?va:hg,ce=t,b=n.length;let G='"';for(t++;;){if(t>=e.length){const ne=B(t-1);return!Z&&qi(e.charAt(ne))?(t=ce,n=n.substring(0,b),j(!0)):(G=Zt(G,'"'),n+=G,!0)}if(t===X)return G=Zt(G,'"'),n+=G,!0;if(ye(e[t])){const ne=t,Q=G.length;if(G+='"',t++,n+=G,o(!1),Z||t>=e.length||qi(e[t])||ts(e[t])||An(e[t]))return m(),!0;const oe=B(ne-1),I=e.charAt(oe);if(I===",")return t=ce,n=n.substring(0,b),j(!1,oe);if(qi(I))return t=ce,n=n.substring(0,b),j(!0);n=n.substring(0,b),t=ne+1,G=`${G.substring(0,Q)}\\${G.substring(Q)}`}else if(Z&&nd(e[t])){if(e[t-1]===":"&&ed.test(e.substring(ce+1,t+2)))for(;t<e.length&&td.test(e[t]);)G+=e[t],t++;return G=Zt(G,'"'),n+=G,m(),!0}else if(e[t]==="\\"){const ne=e.charAt(t+1);if(sO[ne]!==void 0)G+=e.slice(t,t+2),t+=2;else if(ne==="u"){let oe=2;for(;oe<6&&Kz(e[t+oe]);)oe++;oe===6?(G+=e.slice(t,t+6),t+=6):t+oe>=e.length?t=e.length:J()}else G+=ne,t+=2}else{const ne=e.charAt(t);ne==='"'&&e[t-1]!=="\\"?(G+=`\\${ne}`,t++):Qz(ne)?(G+=iO[ne],t++):(Yz(ne)||T(ne),G+=ne,t++)}_&&p()}}return!1}function m(){let Z=!1;for(o();e[t]==="+";){Z=!0,t++,o(),n=qr(n,'"',!0);const X=n.length;j()?n=nO(n,X,1):n=Zt(n,'"')}return Z}function A(){const Z=t;if(e[t]==="-"){if(t++,N())return R(Z),!0;if(!An(e[t]))return t=Z,!1}for(;An(e[t]);)t++;if(e[t]==="."){if(t++,N())return R(Z),!0;if(!An(e[t]))return t=Z,!1;for(;An(e[t]);)t++}if(e[t]==="e"||e[t]==="E"){if(t++,(e[t]==="-"||e[t]==="+")&&t++,N())return R(Z),!0;if(!An(e[t]))return t=Z,!1;for(;An(e[t]);)t++}if(!N())return t=Z,!1;if(t>Z){const X=e.slice(Z,t),_=/^0\d/.test(X);return n+=_?`"${X}"`:X,!0}return!1}function C(){return v("true","true")||v("false","false")||v("null","null")||v("True","true")||v("False","false")||v("None","null")}function v(Z,X){return e.slice(t,t+Z.length)===Z?(n+=X,t+=Z.length,!0):!1}function w(Z){const X=t;if(Xu(e[t])){for(;t<e.length&&Qu(e[t]);)t++;let _=t;for(;zn(e,_);)_++;if(e[_]==="(")return t=_+1,s(),e[t]===")"&&(t++,e[t]===";"&&t++),!0}for(;t<e.length&&!nd(e[t])&&!ts(e[t])&&(!Z||e[t]!==":");)t++;if(e[t-1]===":"&&ed.test(e.substring(X,t+2)))for(;t<e.length&&td.test(e[t]);)t++;if(t>X){for(;zn(e,t-1)&&t>0;)t--;const _=e.slice(X,t);return n+=_==="undefined"?"null":JSON.stringify(_),e[t]==='"'&&t++,!0}}function O(){if(e[t]==="/"){const Z=t;for(t++;t<e.length&&(e[t]!=="/"||e[t-1]==="\\");)t++;return t++,n+=JSON.stringify(e.substring(Z,t)),!0}}function B(Z){let X=Z;for(;X>0&&zn(e,X);)X--;return X}function N(){return t>=e.length||qi(e[t])||zn(e,t)}function R(Z){n+=`${e.slice(Z,t)}0`}function T(Z){throw new tr(`Invalid character ${JSON.stringify(Z)}`,t)}function F(){throw new tr(`Unexpected character ${JSON.stringify(e[t])}`,t)}function z(){throw new tr("Unexpected end of json string",e.length)}function M(){throw new tr("Object key expected",t)}function D(){throw new tr("Colon expected",t)}function J(){const Z=e.slice(t,t+6);throw new tr(`Invalid unicode character "${Z}"`,t)}}function oO(e,t){return e[t]==="*"&&e[t+1]==="/"}function aO({json:e,context:t,scope:n}){const[r,i]=x.useState(!1),[s,o]=x.useState(null),a=x.useMemo(()=>{try{return JSON.parse(e),e}catch{}try{return od(e)}catch{}const y=`{${e}}`;try{return JSON.parse(y),y}catch{}try{return od(y)}catch{return null}},[e]),l=x.useMemo(()=>ag(a||e),[a,e]),u=ke(y=>y.activeTab),d=ke(y=>y.documents),f=ke(y=>(y.acceptedApplyIds||[]).includes(l)),h=ke(y=>y.setPendingDiff),p=ke(y=>y.createDocument),g=ke(y=>y.openDocument),k=x.useCallback(()=>{if(a){o(null);try{if(u){const y=d.find(v=>v.name===u),j=(y==null?void 0:y.text)||"";if(n==="templates")try{const v=JSON.parse(j),w=JSON.parse(a);if(Array.isArray(w.templates)){v.props||(v.props={}),v.props.templates=og(v.props.templates||[],w.templates);const O=JSON.stringify(v,null,2);h(u,j,O,l);return}}catch{}const m=t==null?void 0:t[0],{original:A,modified:C}=lg(j,a,m);h(u,A,C,l)}else{const y=`ai-generated-${Date.now()}`;p(y,a),g(y)}}catch(y){o(y instanceof Error?y.message:"Merge failed")}}},[a,u,d,h,p,g,t,n,l]),S=x.useCallback(async()=>{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),1500)},[e]);return c.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2 border-t",children:[c.jsxs("div",{className:"flex gap-1.5",children:[c.jsx(Ee,{variant:"secondary",size:"sm",onClick:k,disabled:f||!a,children:f?"Applied":a?"Apply to Editor":"Invalid JSON"}),c.jsx(Ee,{variant:"ghost",size:"sm",onClick:S,children:r?c.jsx(un,{className:"h-3.5 w-3.5"}):c.jsx(zs,{className:"h-3.5 w-3.5"})})]}),s&&c.jsx("p",{className:"text-xs text-destructive m-0",children:s})]})}function lO({threads:e,activeThread:t,disabled:n,onSwitch:r,onCreate:i,onDelete:s,onRename:o}){const[a,l]=x.useState(null),[u,d]=x.useState(""),[f,h]=x.useState(null),p=x.useRef(null),g=(t==null?void 0:t.title)||"New Chat",k=g.length>24?g.slice(0,24)+"...":g;x.useEffect(()=>{a&&requestAnimationFrame(()=>{var w;return(w=p.current)==null?void 0:w.focus()})},[a]);const S=x.useCallback((w,O)=>{O.stopPropagation(),O.preventDefault(),l(w.id),d(w.title),h(null)},[]),y=x.useCallback(()=>{a&&u.trim()&&o(a,u.trim()),l(null),d("")},[a,u,o]),j=x.useCallback(()=>{l(null),d("")},[]),m=x.useCallback(w=>{w.stopPropagation(),w.key==="Enter"?(w.preventDefault(),y()):w.key==="Escape"&&(w.preventDefault(),j())},[y,j]),A=x.useCallback((w,O)=>{O.stopPropagation(),O.preventDefault(),h(w),l(null)},[]),C=x.useCallback(w=>{w.stopPropagation(),w.preventDefault(),f&&(s(f),h(null))},[f,s]),v=x.useCallback(w=>{w.stopPropagation(),w.preventDefault(),h(null)},[]);return c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsxs(Ti,{onOpenChange:w=>{w||(l(null),h(null))},children:[c.jsx(Ii,{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:k}),c.jsx(Ni,{className:"h-3 w-3 shrink-0 opacity-60"})]})}),c.jsxs(Ar,{align:"start",className:"w-64",children:[e.map(w=>{const O=a===w.id;return f===w.id?c.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 text-sm",children:[c.jsx("span",{className:"text-destructive text-xs flex-1 truncate",children:"Delete this thread?"}),c.jsx("button",{className:"shrink-0 text-destructive hover:text-destructive/80 transition-colors cursor-pointer",onClick:C,children:c.jsx(un,{className:"h-3.5 w-3.5"})}),c.jsx("button",{className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onClick:v,children:c.jsx(wn,{className:"h-3.5 w-3.5"})})]},w.id):O?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=>d(N.target.value),onKeyDown:m,onBlur:y,className:"flex-1 min-w-0 text-sm rounded-sm border border-border bg-background px-1.5 py-0.5 outline-none focus:ring-1 focus:ring-primary/40"}),c.jsx("button",{className:"shrink-0 text-primary hover:text-primary/80 transition-colors cursor-pointer",onMouseDown:N=>{N.preventDefault(),y()},children:c.jsx(un,{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(),j()},children:c.jsx(wn,{className:"h-3.5 w-3.5"})})]},w.id):c.jsxs($t,{onSelect:()=>r(w.id),className:`group ${w.id===(t==null?void 0:t.id)?"bg-accent":""}`,children:[c.jsx("span",{className:"truncate flex-1",children:w.title.length>30?w.title.slice(0,30)+"...":w.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(w,N),children:c.jsx(Lx,{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=>A(w.id,N),children:c.jsx(_a,{className:"h-3 w-3"})})]})]},w.id)}),c.jsx(Fn,{}),c.jsxs($t,{onSelect:w=>{w.preventDefault();const O=i();O&&(l(O),d(Oa()),h(null))},children:[c.jsx(Dt,{className:"h-3.5 w-3.5 mr-1.5"}),"New Chat"]})]})]}),c.jsx(Ee,{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(Dt,{className:"h-3.5 w-3.5"})})]})}const mg=new Set(["image/png","image/jpeg","image/gif","image/webp","application/pdf","text/plain","text/markdown","text/csv","text/html"]),cO=Array.from(mg).join(","),uO=20*1024*1024,ad=10;function dO(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 ld(e){return Array.from(e).filter(t=>mg.has(t.type)&&t.size<=uO)}function gg(e){return e.startsWith("image/")}function cd(){var Y,ge,_e;const e=De(L=>L.contextAttachments),t=De(L=>L.addContext),n=De(L=>L.removeContext),r=De(L=>L.scope),i=De(L=>L.setScope),s=De(L=>L.model),o=De(L=>L.setModel),a=De(L=>L.openChat),l=De(L=>L.closeChat),u=De(L=>L.threads),d=De(L=>L.activeThreadId),f=De(L=>L.createThread),h=De(L=>L.deleteThread),p=De(L=>L.switchThread),g=De(L=>L.updateThreadMessages),k=De(L=>L.updateThreadTitle),S=De(L=>L.deleteThreadsForDocument),y=ke(L=>L.activeTab),j=ke(L=>L.documents),{messages:m,sendMessage:A,status:C,error:v,setMessages:w,stop:O,getMessageContext:B,getMessageScope:N}=Mz(),[R,T]=x.useState(""),[F,z]=x.useState([]),[M,D]=x.useState(!1),[J,Z]=x.useState(!1),X=x.useRef(null),_=x.useRef(null),ye=x.useRef(null),ce=x.useCallback(async L=>{const $=ld(L);if($.length===0)return;const xe=await Promise.all($.map(dO));z(de=>{const Me=[...de,...xe];return Me.length>ad?Me.slice(0,ad):Me})},[]),b=x.useCallback(L=>{z($=>$.filter((xe,de)=>de!==L))},[]),G=x.useCallback(L=>{var xe;const $=(xe=L.clipboardData)==null?void 0:xe.files;if($&&$.length>0){const de=ld($);de.length>0&&(L.preventDefault(),ce(de))}},[ce]),ne=x.useCallback(L=>{var xe;L.preventDefault(),Z(!1);const $=(xe=L.dataTransfer)==null?void 0:xe.files;$&&$.length>0&&ce(Array.from($))},[ce]),Q=x.useCallback(L=>{L.preventDefault(),Z(!0)},[]),oe=x.useCallback(()=>Z(!1),[]),I=y?d[y]:void 0,re=I?u[I]:void 0,ae=x.useMemo(()=>y?Object.values(u).filter(L=>L.documentName===y).sort((L,$)=>$.updatedAt-L.updatedAt):[],[u,y]);x.useEffect(()=>{y&&ae.length===0&&f(y)},[y,ae.length,f]);const H=x.useRef(u);H.current=u,x.useEffect(()=>{const L=new Set(j.map(xe=>xe.name)),$=new Set;for(const xe of Object.values(H.current))!L.has(xe.documentName)&&xe.documentName!=="__migrated__"&&$.add(xe.documentName);for(const xe of $)S(xe)},[j,S]);const K=x.useRef(null);x.useEffect(()=>{K.current!==I&&(K.current=I,w((re==null?void 0:re.messages)??[]))},[I,re,w]),x.useEffect(()=>{var L;(L=X.current)==null||L.scrollIntoView({behavior:"smooth"})},[m,C]),x.useEffect(()=>{const L=$=>{var Me;const{documentName:xe,selection:de}=$.detail;t({...de,documentName:xe}),a(),(Me=_.current)==null||Me.focus()};return window.addEventListener("monaco-selection-to-ai",L),()=>window.removeEventListener("monaco-selection-to-ai",L)},[t,a]);const pe=C==="streaming",fe=C==="submitted"||pe,Re=x.useCallback(L=>{L.preventDefault(),!(!R.trim()&&F.length===0||fe)&&(A(R,F.length>0?F:void 0),T(""),z([]))},[R,F,fe,A]),Oe=x.useCallback(L=>{L.key==="Enter"&&!L.shiftKey&&(L.preventDefault(),Re(L))},[Re]),$e=x.useCallback(()=>{m.length!==0&&D(!0)},[m.length]),E=x.useCallback(()=>{D(!1),w([]),I&&(g(I,[]),k(I,Oa()))},[w,I,g,k]),[P,V]=x.useState(null),se=x.useCallback(L=>{V(L)},[]),ie=x.useCallback(()=>{var Me,Je;if(!P)return;const L=m.findIndex(it=>it.id===P);if(L===-1){V(null);return}const $=m[L],xe=new Set([L]);$.role==="user"&&((Me=m[L+1])==null?void 0:Me.role)==="assistant"?xe.add(L+1):$.role==="assistant"&&L>0&&((Je=m[L-1])==null?void 0:Je.role)==="user"&&xe.add(L-1);const de=m.filter((it,Lt)=>!xe.has(Lt));w(de),I&&g(I,de),V(null)},[P,m,w,I,g]),ee=x.useCallback(L=>{if(!fe){if(ae.length<=1){$e();return}h(L)}},[fe,ae.length,$e,h]),me=x.useCallback(()=>{if(!(!y||fe))return f(y)},[y,fe,f]),we=x.useCallback(L=>{fe||L===I||p(L)},[fe,I,p]),U=x.useCallback((L,$)=>{k(L,$)},[k]);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(lO,{threads:ae,activeThread:re,disabled:fe,onSwitch:we,onCreate:me,onDelete:ee,onRename:U}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(Ee,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:$e,disabled:fe||m.length===0,children:"Clear"}),c.jsx(Ee,{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(hi,{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:[m.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(wl,{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(mi,{shortcut:"mod+k"}),c.jsx("span",{className:"text-xs text-muted-foreground",children:"to send a selection"})]})]}),m.map((L,$)=>{let xe;if(L.role==="user"){const Je=B(L.id);Je&&Je.length>0&&(xe=Je)}else if(L.role==="assistant"){for(let Je=$-1;Je>=0;Je--)if(m[Je].role==="user"){xe=B(m[Je].id);break}}const de=pe&&$===m.length-1&&L.role==="assistant",Me=L.role==="user"?N(L.id):void 0;return c.jsx(fO,{msg:L,isStreaming:de,context:xe,scope:Me,onDelete:fe?void 0:se},L.id)}),fe&&((Y=m[m.length-1])==null?void 0:Y.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(Gr,{className:"h-3.5 w-3.5 animate-spin text-primary"}),c.jsx("span",{children:"Thinking..."})]})})}),v&&!fe&&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:v.message||"Something went wrong"})}),c.jsx("div",{ref:X})]})}),c.jsxs("div",{className:`border-t border-border/60 p-2.5 space-y-2 bg-surface-chat transition-colors ${J?"ring-2 ring-primary/40 bg-primary/5":""}`,onDrop:ne,onDragOver:Q,onDragLeave:oe,children:[e.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.map((L,$)=>c.jsx(ug,{context:L,onRemove:()=>n($)},$))}),c.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[c.jsx(mO,{model:s,setModel:o}),at==="pptx"&&y&&c.jsx(xO,{scope:r,setScope:i,docSize:((_e=(ge=j.find(L=>L.name===y))==null?void 0:ge.text)==null?void 0:_e.length)??0})]}),F.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1.5",children:F.map((L,$)=>c.jsxs("div",{className:"relative group",children:[gg(L.mediaType)?c.jsx("img",{src:L.url,alt:L.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(Lo,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),c.jsx("span",{className:"text-xs truncate text-muted-foreground",children:L.filename||"file"})]}),c.jsx("button",{type:"button",onClick:()=>b($),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"})})]},$))}),c.jsxs("form",{onSubmit:Re,className:"flex items-end gap-2",children:[c.jsx("input",{ref:ye,type:"file",accept:cO,multiple:!0,className:"hidden",onChange:L=>{L.target.files&&ce(Array.from(L.target.files)),L.target.value=""}}),c.jsx(Ee,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 h-9 w-9 rounded-lg text-muted-foreground hover:text-foreground",onClick:()=>{var L;return(L=ye.current)==null?void 0:L.click()},title:"Attach file",children:c.jsx(Lo,{className:"h-4 w-4"})}),c.jsx("textarea",{ref:_,value:R,onChange:L=>{T(L.target.value);const $=L.target;$.style.height="auto",$.style.height=`${Math.min($.scrollHeight,128)}px`},onKeyDown:Oe,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}),fe?c.jsx(Ee,{type:"button",size:"icon",variant:"destructive",className:"shrink-0 h-9 w-9 rounded-lg",onClick:O,title:"Stop generating",children:c.jsx(tf,{className:"h-4 w-4"})}):c.jsx(Ee,{type:"submit",size:"icon",disabled:!R.trim()&&F.length===0,className:"shrink-0 h-9 w-9 rounded-lg",children:c.jsx(wl,{className:"h-4 w-4"})})]})]}),c.jsx(ct,{open:M,onOpenChange:D,children:c.jsxs(lt,{className:"max-w-sm",children:[c.jsxs(qt,{children:[c.jsx(Gt,{children:"Clear thread"}),c.jsx(dn,{children:"This will delete all messages in this thread. This action cannot be undone."})]}),c.jsxs(kn,{children:[c.jsx(Nl,{asChild:!0,children:c.jsx(Ee,{variant:"ghost",size:"sm",children:"Cancel"})}),c.jsx(Ee,{variant:"destructive",size:"sm",onClick:E,children:"Clear"})]})]})}),c.jsx(ct,{open:P!==null,onOpenChange:L=>{L||V(null)},children:c.jsxs(lt,{className:"max-w-sm",children:[c.jsxs(qt,{children:[c.jsx(Gt,{children:"Delete message"}),c.jsx(dn,{children:"This will delete the message and its paired response. This action cannot be undone."})]}),c.jsxs(kn,{children:[c.jsx(Nl,{asChild:!0,children:c.jsx(Ee,{variant:"ghost",size:"sm",children:"Cancel"})}),c.jsx(Ee,{variant:"destructive",size:"sm",onClick:ie,children:"Delete"})]})]})})]})}const fO=x.memo(function({msg:t,isStreaming:n,context:r,scope:i,onDelete:s}){var l,u;const o=((l=t.parts)==null?void 0:l.filter(d=>d.type==="text").map(d=>d.text).join(""))||"",a=((u=t.parts)==null?void 0:u.filter(d=>d.type==="file"))||[];return c.jsx("div",{className:`group/msg flex ${t.role==="user"?"justify-end":"justify-start"}`,children:c.jsxs("div",{className:`rounded-lg px-3 py-2 max-w-[90%] overflow-hidden min-w-0 ${t.role==="user"?"bg-primary text-primary-foreground":"bg-muted/60 border border-border/40"}`,children:[t.role==="user"?c.jsxs("div",{children:[a.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1 mb-1.5",children:a.map((d,f)=>gg(d.mediaType)?c.jsx("img",{src:d.url,alt:d.filename||"image",className:"h-20 max-w-[160px] rounded-sm object-cover"},f):c.jsxs("div",{className:"flex items-center gap-1.5 rounded-sm bg-primary-foreground/20 px-2 py-1",children:[c.jsx(Lo,{className:"h-3 w-3 shrink-0"}),c.jsx("span",{className:"text-xs truncate max-w-[120px]",children:d.filename||"file"})]},f))}),r&&r.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1 mb-1.5",children:r.map((d,f)=>c.jsx(ug,{context:d,variant:"sent"},f))}),o&&c.jsx("div",{className:"whitespace-pre-wrap text-sm break-words",children:o}),i&&i!=="global"&&c.jsx("span",{className:"text-[10px] text-primary-foreground/60 mt-0.5 block text-right",children:i})]}):c.jsx(pO,{text:o,isStreaming:n,context:r,scope:i}),s&&!n&&c.jsx("div",{className:"opacity-0 transition-opacity group-hover/msg:opacity-100 focus-within:opacity-100 mt-1",children:c.jsx("button",{type:"button","aria-label":"Delete message",onClick:()=>s(t.id),className:`p-0.5 rounded-sm cursor-pointer focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring ${t.role==="user"?"text-primary-foreground/50 hover:text-primary-foreground/80":"text-muted-foreground hover:text-destructive"}`,children:c.jsx(_a,{className:"h-3 w-3"})})})]})})},(e,t)=>e.msg.id===t.msg.id&&e.msg===t.msg&&e.isStreaming===t.isStreaming&&e.scope===t.scope&&e.onDelete===t.onDelete&&e.context===t.context);function pO({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(LS,{remarkPlugins:[Q_],components:{pre:({children:i})=>c.jsx(c.Fragment,{children:i}),code:({className:i,children:s})=>{const o=i==null?void 0:i.startsWith("language-"),a=(i==null?void 0:i.replace("language-",""))||"",l=String(s).replace(/\n$/,"");if(!o)return c.jsx("code",{className:"rounded-sm bg-muted px-1 py-0.5 text-xs font-mono",children:s});const u=a==="json"||a==="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:a||"code"}),!u&&c.jsx(yO,{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(aO,{json:l,context:n,scope:r})]})}},children:e})})}const hO=[{value:"opus",label:"Opus"},{value:"sonnet",label:"Sonnet"},{value:"haiku",label:"Haiku"}];function mO({model:e,setModel:t}){return c.jsxs(fi,{value:e,onValueChange:n=>t(n),children:[c.jsx(br,{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(pi,{})}),c.jsx(vr,{children:hO.map(n=>c.jsx(Mn,{value:n.value,className:"text-xs",children:n.label},n.value))})]})}const ud={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"},gO=1e5;function xO({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(ud).map(r=>c.jsxs(Ye,{children:[c.jsx(Xe,{asChild:!0,children:c.jsx("button",{type:"button",onClick:()=>t(r),className:`px-2 py-0.5 rounded-sm text-[10px] cursor-pointer transition-colors ${e===r?"bg-background text-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:r})}),c.jsx(Qe,{side:"top",className:"text-xs max-w-[200px]",children:ud[r]})]},r))})]}),e==="global"&&n>gO&&c.jsxs("div",{className:"text-[10px] text-warning flex items-center gap-1",children:[c.jsx(sf,{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-warning/80",children:"slides"})," ","or"," ",c.jsx("button",{type:"button",onClick:()=>t("templates"),className:"underline cursor-pointer hover:text-warning/80",children:"templates"})]})]})]})}function yO({text:e}){const[t,n]=x.useState(!1),r=x.useCallback(async()=>{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)},[e]);return c.jsx("button",{onClick:r,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:t?"Copied!":"Copy"})}function bO({discoveryData:e}){const t=Vf(),n=ib(),r=De(N=>N.chatOpen),i=De(N=>N.toggleChat),[s,o]=x.useState(()=>{try{const N=localStorage.getItem("dev-env.sidebar-open");return n?!1:N?N==="true":!0}catch{return!n}}),[a,l]=x.useState(()=>{try{const N=localStorage.getItem("dev-env.preview-open");return N?N==="true":!0}catch{return!0}}),[u,d]=x.useState("editor"),[f,h]=x.useState(!1),p=150,[g,k]=x.useState(!s),[S,y]=x.useState(!1);x.useEffect(()=>{try{localStorage.setItem("dev-env.sidebar-open",String(s))}catch{}},[s]),x.useEffect(()=>{try{localStorage.setItem("dev-env.preview-open",String(a))}catch{}},[a]);const j=x.useRef(n);x.useEffect(()=>{n&&!j.current&&s&&(y(!0),o(!1),setTimeout(()=>{k(!0),y(!1)},p)),!n&&j.current&&!s&&(y(!0),o(!0),setTimeout(()=>{k(!1),y(!1)},p)),j.current=n},[n,s]);const m=x.useCallback(()=>{if(t){h(N=>!N);return}y(!0),o(N=>!N),setTimeout(()=>{k(N=>!N),y(!1)},p)},[t]),A=x.useCallback(()=>l(N=>!N),[]),C=x.useRef(i),v=x.useRef(m),w=x.useRef(A);x.useEffect(()=>{C.current=i}),x.useEffect(()=>{v.current=m}),x.useEffect(()=>{w.current=A}),x.useEffect(()=>{const N=R=>{(R.metaKey||R.ctrlKey)&&(R.code==="KeyB"&&!R.shiftKey&&(R.preventDefault(),v.current()),R.code==="KeyJ"&&R.shiftKey&&(R.preventDefault(),R.stopPropagation(),C.current()),R.code==="KeyP"&&R.shiftKey&&(R.preventDefault(),w.current()))};return window.addEventListener("keydown",N,!0),()=>window.removeEventListener("keydown",N,!0)},[]);const O=$z,B=[{key:"editor",icon:Fo,label:"Editor"},{key:"preview",icon:of,label:"Preview"},{key:"chat",icon:af,label:"Chat"}];return t?c.jsx(O,{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(Ff,{open:f,onOpenChange:h,children:[c.jsx(Qy,{asChild:!0,children:c.jsx(Ee,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:c.jsx(rf,{className:"h-4 w-4"})})}),c.jsx(Ma,{side:"left",className:"p-0 w-72",children:c.jsx(Gl,{discoveryData:e,onToggleSidebar:()=>h(!1),isCollapsed:!1})})]}),c.jsx("div",{className:"flex gap-0.5 flex-1 min-w-0",children:B.map(({key:N,icon:R,label:T})=>c.jsxs(Ee,{variant:u===N?"default":"ghost",size:"sm",className:"h-7 gap-1.5 text-xs flex-1",onClick:()=>d(N),children:[c.jsx(R,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"hidden xs:inline",children:T})]},N))})]}),u!=="chat"&&c.jsx(bc,{previewOpen:a,onTogglePreview:A}),c.jsxs("div",{className:"flex-1 min-h-0",children:[u==="editor"&&c.jsx("div",{className:"h-full bg-surface-editor",children:c.jsx(Kl,{})}),u==="preview"&&c.jsx("div",{className:"h-full bg-surface-preview",children:c.jsx(Yl,{})}),u==="chat"&&c.jsx(cd,{})]})]})}):c.jsx(O,{children:c.jsxs("div",{className:"flex h-full w-full overflow-hidden",children:[c.jsx("div",{className:W("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(Gl,{discoveryData:e,onToggleSidebar:m,isCollapsed:g,isAnimating:S})}),c.jsxs("div",{className:"flex-1 min-w-0 flex flex-col h-full",children:[c.jsx(bc,{previewOpen:a,onTogglePreview:A}),c.jsxs(Lv,{direction:"horizontal",autoSaveId:"layout-main",className:"flex-1 min-h-0",children:[c.jsx(co,{defaultSize:a?50:100,minSize:20,id:"editor",order:1,children:c.jsx("div",{className:"h-full bg-surface-editor",children:c.jsx(Kl,{})})}),a&&c.jsxs(c.Fragment,{children:[c.jsx(ac,{withHandle:!0}),c.jsx(co,{defaultSize:50,minSize:20,id:"preview",order:2,children:c.jsx("div",{className:"h-full bg-surface-preview",children:c.jsx(Yl,{})})})]}),r&&c.jsxs(c.Fragment,{children:[c.jsx(ac,{withHandle:!0}),c.jsx(co,{defaultSize:30,minSize:25,maxSize:50,id:"chat",order:3,children:c.jsx(cd,{})})]})]})]})]})})}function vO(){const[e,t]=x.useState(null),[n,r]=x.useState(!0),[i,s]=x.useState(null),o=x.useCallback(async()=>{r(!0),s(null);try{const a=await fetch("/api/discovery/all");if(!a.ok)throw new Error(`Discovery failed: ${a.statusText}`);const l=await a.json();if(!l.success)throw new Error(l.error||"Discovery failed");t({pluginAutoload:!0,...l.data})}catch(a){console.error("Discovery error:",a),s(a instanceof Error?a.message:"Failed to fetch discovered items"),t({plugins:[],documents:[],themes:[],pluginAutoload:!0})}finally{r(!1)}},[]);return x.useEffect(()=>{o()},[o]),{data:e,loading:n,error:i,refetch:o}}function wO(){const{data:e,loading:t,error:n}=vO(),r=Jt(s=>s.applyPluginsWithValidation),i=x.useMemo(()=>(e==null?void 0:e.plugins.map(s=>s.name))??[],[e]);return x.useEffect(()=>{if(!e)return;Jt.getState().selectedPlugins.size>0&&r()},[e,r]),t?c.jsx("div",{className:"flex items-center justify-center h-screen",children:c.jsxs("div",{className:"text-center",children:[c.jsx("div",{className:"text-lg font-medium",children:"Discovering project resources..."}),c.jsx("div",{className:"text-sm text-muted-foreground mt-2",children:"Searching for documents, themes, and plugins"})]})}):n?c.jsx("div",{className:"flex items-center justify-center h-screen",children:c.jsxs("div",{className:"text-center",children:[c.jsx("div",{className:"text-lg font-medium text-destructive",children:"Discovery failed"}),c.jsx("div",{className:"text-sm text-muted-foreground mt-2",children:n}),c.jsx("div",{className:"text-xs text-muted-foreground mt-4",children:"The playground will work with limited functionality."})]})}):c.jsx(Ng,{children:c.jsx(Eg,{children:c.jsx(Cg,{children:c.jsx(Tg,{children:c.jsx(Ig,{children:c.jsx(Ag,{diskPluginNames:i,children:c.jsx(zy,{children:c.jsx(Uf,{children:c.jsx("section",{className:"flex h-screen w-full flex-col",children:c.jsx("div",{className:"grow overflow-hidden",children:c.jsx(bO,{discoveryData:e})})})})})})})})})})})}const zO=Object.freeze(Object.defineProperty({__proto__:null,HomePage:wO},Symbol.toStringTag,{value:"Module"}));export{Gt as A,tn as B,Np as C,Ti as D,Jv as E,zO as H,wr as I,ni as L,rw as P,Zv as Q,fi as S,jp as T,br as a,pi as b,vr as c,Mn as d,hi as e,Ii as f,Ar as g,$a as h,Fn as i,$t as j,Fa as k,oi as l,mr as m,Bo as n,_p as o,si as p,Ob as q,AO as r,gc as s,Xv as t,Wv as u,Ja as v,Mf as w,ct as x,lt as y,qt as z};
|
|
251
|
-
//# sourceMappingURL=HomePage-
|
|
251
|
+
//# sourceMappingURL=HomePage-mtUb6jxc.js.map
|