pagepilot-visual-editor 1.0.43 → 1.0.44

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.
@@ -1321,7 +1321,7 @@ ${Ws} { ${a} { width: ${c} !important; max-width: 100% !important; } }
1321
1321
  `).replace(/\n+$/,"");if(t==="")return null;const n=t.split(`
1322
1322
  `),r=n.some(o=>o.includes(" "))?" ":n.some(o=>o.includes(","))?",":null;return r?Xm(n.map(o=>A3e(o,r))):null}function h3e(e){const t=e.replace(/\r\n?/g,`
1323
1323
  `).split(`
1324
- `).map(a=>a.trim()).filter(a=>a.length>0);if(t.length<2||!t[0].includes("|")||!/^\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?$/.test(t[1]))return null;const r=a=>{const l=a.replace(/^\|/,"").replace(/\|$/,""),s=[];let c="";for(let u=0;u<l.length;u++)l[u]==="\\"&&l[u+1]==="|"?(c+="|",u++):l[u]==="|"?(s.push(c.trim()),c=""):c+=l[u];return s.push(c.trim()),s},o=[t[0],...t.slice(2)];return Xm(o.map(r))}function Xm(e){const t=e.filter(o=>o!==void 0);for(;t.length>0&&t[t.length-1].every(o=>(o??"").trim()==="");)t.pop();if(t.length===0)return null;const n=t.reduce((o,a)=>Math.max(o,a.length),0);if(n===0)return null;const r=[];for(let o=0;o<t.length;o++)for(let a=0;a<n;a++)r.push(t[o][a]??"");return{rows:t.length,columns:n,cells:r}}function fR(e){return h3e(e)??p3e(e)}function f3e(e){if(!e)return null;const t=e.getData("text/html");if(t){const r=hR(t);if(r&&(r.rows>1||r.columns>1))return r}const n=e.getData("text/plain");if(n){const r=fR(n);if(r&&(r.rows>1||r.columns>1))return r}return null}function g3e(e){const t=e.trim();if(!t)return null;if(/<table[\s>]/i.test(t)||/<tr[\s>]/i.test(t)){const n=hR(t);if(n)return n}return fR(t)}async function m3e(e){const t=await Promise.resolve().then(()=>require("./xlsx-BsoVkcdE.cjs")).then(a=>a.xlsx),n=await e.arrayBuffer(),r=t.read(new Uint8Array(n),{type:"array",cellDates:!0}),o=[];for(const a of r.SheetNames){const l=r.Sheets[a],c=t.utils.sheet_to_json(l,{header:1,blankrows:!1,raw:!1}).map(d=>d.map(A=>A==null?"":String(A))),u=Xm(c);u&&o.push({name:a,table:u})}return o}async function b3e(e){const t=await Promise.resolve().then(()=>require("./index-DEnWBBqj.cjs")).then(o=>o.index),n=await e.arrayBuffer(),{value:r}=await t.convertToHtml({arrayBuffer:n});return r?d3e(r).map((o,a)=>({name:`Table ${a+1}`,table:o})):[]}function x3e(e,t,n,r,o,a,l=50,s=20){const c=Math.min(l,Math.max(t,o+r.rows)),u=Math.min(s,Math.max(n,a+r.columns)),d=new Array(c*u).fill("");for(let A=0;A<Math.min(t,c);A++)for(let p=0;p<Math.min(n,u);p++)d[A*u+p]=e[A*n+p]??"";for(let A=0;A<r.rows;A++){const p=o+A;if(p>=c)break;for(let h=0;h<r.columns;h++){const f=a+h;if(f>=u)break;d[p*u+f]=r.cells[A*r.columns+h]??""}}return{rows:c,columns:u,cells:d}}const C3e={width:16,height:16,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,"& > svg":{width:"100%",height:"100%",display:"block"}};function $l({children:e}){return i.jsx(m.Box,{sx:C3e,children:e})}function Zh(e,t,n,r,o,a,l){const s=new Array(r*o).fill("");for(let c=0;c<r;c++)for(let u=0;u<o;u++){const d=l(c,u);d&&d.oldR>=0&&d.oldR<t&&d.oldC>=0&&d.oldC<n&&a(d.oldR,d.oldC,c,u)&&(s[c*o+u]=e[d.oldR*n+d.oldC]??"")}return s}function y3e(e){var k,I,F,T;const t=Cn(),[n,r]=y.useState(null),o=y.useRef(!1),a=Math.max(1,Math.min(50,((k=e==null?void 0:e.props)==null?void 0:k.rows)??gn.rows)),l=Math.max(1,Math.min(20,((I=e==null?void 0:e.props)==null?void 0:I.columns)??gn.columns)),s=((F=e==null?void 0:e.props)==null?void 0:F.hasHeader)??gn.hasHeader,c=y.useCallback((D,L,P)=>{var Z;if(o.current)return;const M=At()[t];if(!M||M.type!=="Table")return;const z=((Z=M.data)==null?void 0:Z.props)??{},G=Math.max(1,Math.min(50,z.rows??gn.rows)),V=Math.max(1,Math.min(20,z.columns??gn.columns)),_=G*V,W=Array.isArray(z.cells)?[...z.cells]:[];for(;W.length<_;)W.push("");W.length=_;const q=D*V+L;W[q]!==P&&(W[q]=P,pt({[t]:{...M,data:{...M.data,props:{...z,cells:W}}}}))},[t]),u=y.useCallback(D=>{var q;const L=document.activeElement;L&&typeof L.blur=="function"&&L.isContentEditable&&L.blur(),o.current=!0,setTimeout(()=>{o.current=!1},0);const P=At()[t];if(!P||P.type!=="Table")return;const M=((q=P.data)==null?void 0:q.props)??{},z=Math.max(1,Math.min(50,M.rows??gn.rows)),G=Math.max(1,Math.min(20,M.columns??gn.columns)),V=z*G,_=Array.isArray(M.cells)?[...M.cells]:[];for(;_.length<V;)_.push("");_.length=V;const W=D(P,z,G,_);W&&pt({[t]:{...P,data:{...P.data,props:{...M,...W.props??{}},...W.extra??{}}}})},[t]),d=y.useCallback((D,L)=>{u((P,M,z,G)=>{if(M>=50)return null;const V=L==="above"?D:D+1,_=M+1,W=Zh(G,M,z,_,z,()=>!0,(q,Z)=>q===V?null:{oldR:q<V?q:q-1,oldC:Z});return{props:{rows:_,cells:W}}})},[u]),A=y.useCallback((D,L)=>{u((P,M,z,G)=>{if(z>=20)return null;const V=L==="left"?D:D+1,_=z+1,W=Zh(G,M,z,M,_,()=>!0,(q,Z)=>{if(Z===V)return null;const R=Z<V?Z:Z-1;return{oldR:q,oldC:R}});return{props:{columns:_,cells:W}}})},[u]),p=y.useCallback(D=>{u((L,P,M,z)=>{if(P<=1)return null;const G=P-1,V=Zh(z,P,M,G,M,()=>!0,(_,W)=>({oldR:_<D?_:_+1,oldC:W}));return{props:{rows:G,cells:V}}})},[u]),h=y.useCallback(D=>{u((L,P,M,z)=>{if(M<=1)return null;const G=M-1,V=Zh(z,P,M,P,G,()=>!0,(_,W)=>({oldR:_,oldC:W<D?W:W+1}));return{props:{columns:G,cells:V}}})},[u]),f=y.useCallback(()=>{var P,M;const D=At(),L={};for(const[z,G]of Object.entries(D)){if(z===t)continue;const V=G,_=R=>Array.isArray(R)?R.filter(H=>H!==t):R,W=((P=V.data)==null?void 0:P.props)??{};let q=W;Array.isArray(W.childrenIds)&&(q={...W,childrenIds:_(W.childrenIds)}),Array.isArray(W.columns)&&(q={...q,columns:W.columns.map(R=>({...R,childrenIds:_(R.childrenIds)}))}),Array.isArray(W.cells)&&W.cells.some(R=>Array.isArray(R==null?void 0:R.childrenIds))&&(q={...q,cells:W.cells.map(R=>Array.isArray(R==null?void 0:R.childrenIds)?{...R,childrenIds:_(R.childrenIds)}:R)}),Array.isArray(W.items)&&(q={...q,items:W.items.map(R=>({...R,...Array.isArray(R==null?void 0:R.titleChildrenIds)?{titleChildrenIds:_(R.titleChildrenIds)}:{},...Array.isArray(R==null?void 0:R.contentChildrenIds)?{contentChildrenIds:_(R.contentChildrenIds)}:{},...Array.isArray(R==null?void 0:R.cardChildrenIds)?{cardChildrenIds:_(R.cardChildrenIds)}:{},...Array.isArray(R==null?void 0:R.detailChildrenIds)?{detailChildrenIds:_(R.detailChildrenIds)}:{}}))});const Z={...V.data,props:q};Array.isArray((M=V.data)==null?void 0:M.childrenIds)&&(Z.childrenIds=_(V.data.childrenIds)),L[z]={...V,data:Z}}pt(L)},[t]),b=y.useCallback(()=>r(null),[]),C=y.useCallback((D,L,P)=>{D.preventDefault(),D.stopPropagation(),Vt(t),r({x:D.clientX,y:D.clientY,row:L,col:P})},[t]),w=y.useCallback((D,L,P)=>{var R;const M=f3e(D.clipboardData);if(!M)return!1;D.preventDefault();const z=At()[t];if(!z||z.type!=="Table")return!1;const G=((R=z.data)==null?void 0:R.props)??{},V=Math.max(1,Math.min(50,G.rows??gn.rows)),_=Math.max(1,Math.min(20,G.columns??gn.columns)),W=V*_,q=Array.isArray(G.cells)?[...G.cells]:[];for(;q.length<W;)q.push("");q.length=W;const Z=x3e(q,V,_,M,L,P);return pt({[t]:{...z,data:{...z.data,props:{...G,rows:Z.rows,columns:Z.columns,cells:Z.cells}}}}),!0},[t]),v=y.useCallback(({row:D,col:L,value:P,isHeader:M})=>i.jsx(s3e,{html:P,row:D,col:L,isHeader:M,onCommit:z=>c(D,L,z),onContextMenu:C,onPaste:w}),[c,C,w]),B=a*l,S=((T=e==null?void 0:e.props)==null?void 0:T.cells)??[],E=S.length===B?S:(()=>{const D=[...S];if(D.length<B){const L=k5(a,l,s);for(let P=D.length;P<B;P++)D.push(L[P]??"")}return D.length=B,D})();return i.jsxs(i.Fragment,{children:[i.jsx(aP,{style:e==null?void 0:e.style,props:{...(e==null?void 0:e.props)??{},rows:a,columns:l,hasHeader:s,cells:E},renderCell:v}),i.jsxs(m.Menu,{open:n!==null,onClose:b,anchorReference:"anchorPosition",anchorPosition:n?{top:n.y,left:n.x}:void 0,MenuListProps:{dense:!0},children:[i.jsxs(m.MenuItem,{onClick:()=>{n&&d(n.row,"above"),b()},children:[i.jsx(m.ListItemIcon,{children:i.jsx($l,{children:i.jsx(ct.KeyboardArrowUp,{})})}),i.jsx(m.ListItemText,{children:"Insert row above"})]}),i.jsxs(m.MenuItem,{onClick:()=>{n&&d(n.row,"below"),b()},children:[i.jsx(m.ListItemIcon,{children:i.jsx($l,{children:i.jsx(ct.KeyboardArrowDown,{})})}),i.jsx(m.ListItemText,{children:"Insert row below"})]}),i.jsxs(m.MenuItem,{onClick:()=>{n&&A(n.col,"left"),b()},children:[i.jsx(m.ListItemIcon,{children:i.jsx($l,{children:i.jsx(ct.KeyboardArrowLeft,{})})}),i.jsx(m.ListItemText,{children:"Insert column left"})]}),i.jsxs(m.MenuItem,{onClick:()=>{n&&A(n.col,"right"),b()},children:[i.jsx(m.ListItemIcon,{children:i.jsx($l,{children:i.jsx(ct.KeyboardArrowRight,{})})}),i.jsx(m.ListItemText,{children:"Insert column right"})]}),i.jsx(m.Divider,{}),i.jsxs(m.MenuItem,{disabled:a<=1,onClick:()=>{n&&p(n.row),b()},sx:{color:"#dc2626"},children:[i.jsx(m.ListItemIcon,{children:i.jsx($l,{children:i.jsx(Yc,{htmlColor:"#dc2626"})})}),i.jsx(m.ListItemText,{sx:{"& .MuiListItemText-primary":{color:"#dc2626"}},children:"Delete row"})]}),i.jsxs(m.MenuItem,{disabled:l<=1,onClick:()=>{n&&h(n.col),b()},sx:{color:"#dc2626"},children:[i.jsx(m.ListItemIcon,{children:i.jsx($l,{children:i.jsx(Yc,{htmlColor:"#dc2626"})})}),i.jsx(m.ListItemText,{sx:{"& .MuiListItemText-primary":{color:"#dc2626"}},children:"Delete column"})]}),i.jsxs(m.MenuItem,{onClick:()=>{f(),b()},sx:{color:"#dc2626"},children:[i.jsx(m.ListItemIcon,{children:i.jsx($l,{children:i.jsx(Yc,{htmlColor:"#dc2626"})})}),i.jsx(m.ListItemText,{sx:{"& .MuiListItemText-primary":{color:"#dc2626"}},children:"Delete table"})]})]})]})}const v3e=({value:e,onChange:t,readOnly:n,placeholder:r})=>i.jsx(m.TextField,{value:e??"",onChange:o=>t(o.target.value),placeholder:r,multiline:!0,minRows:4,fullWidth:!0,autoFocus:!0,InputProps:{readOnly:!!n,sx:{fontFamily:"monospace",fontSize:13}}}),w3e=["[data-inline-text-toolbar]","[data-inline-editor-fullscreen]","[data-inline-code-view]","[data-inline-image-popover]","[data-inline-table-resize]",".MuiDialog-root",".MuiPopover-root",".react-media-library",'[role="presentation"]'];function q7(e){return!e||!(e instanceof Element)?!1:w3e.some(t=>e.closest(t))}function c4(e){if(!e)return;const t=o=>{let a=o.parentElement;for(;a&&a!==e;){const l=a.tagName;if(l==="LI"||l==="OL"||l==="UL")return!0;a=a.parentElement}return!1};let n=0,r=!1;e.querySelectorAll("ol").forEach(o=>{if(t(o)){o.removeAttribute("start"),o.style.removeProperty("counter-reset");return}const a=o.querySelectorAll(":scope > li").length,l=o.getAttribute("data-mll"),s=l?The[l]:null;if(!r)o.removeAttribute("start"),s&&o.style.removeProperty("counter-reset"),r=!0;else{const c=n+1;c>1?(o.setAttribute("start",String(c)),s&&o.style.setProperty("counter-reset",`${s} ${c-1}`)):(o.removeAttribute("start"),s&&o.style.removeProperty("counter-reset"))}n+=a})}function B3e({open:e,onClose:t,onInsert:n}){const[r,o]=y.useState(""),[a,l]=y.useState(""),s=y.useRef(!1);y.useEffect(()=>{e&&!s.current?(s.current=!0,o(""),l("")):!e&&s.current&&(s.current=!1)},[e]);const c=()=>{const u=r.trim();u&&(n(u,a.trim()||void 0),t())};return i.jsxs(m.Dialog,{open:e,onClose:t,maxWidth:"sm",fullWidth:!0,sx:{zIndex:gy},children:[i.jsx(m.DialogTitle,{sx:{fontSize:16,fontWeight:600},children:"Insert image"}),i.jsxs(m.DialogContent,{sx:{display:"flex",flexDirection:"column",gap:2,pt:1},children:[i.jsxs("div",{children:[i.jsx(m.Typography,{variant:"body2",sx:{mb:.5,fontWeight:500},children:"Image URL"}),i.jsx(m.TextField,{autoFocus:!0,fullWidth:!0,size:"small",placeholder:"https://example.com/image.png",value:r,onChange:u=>o(u.target.value),onKeyDown:u=>{u.key==="Enter"&&r.trim()&&(u.preventDefault(),c())},sx:vr()})]}),i.jsxs("div",{children:[i.jsxs(m.Typography,{variant:"body2",sx:{mb:.5,fontWeight:500},children:["Alt text"," ",i.jsx(m.Typography,{component:"span",variant:"caption",sx:{color:"text.secondary",fontWeight:400},children:"(for screen readers)"})]}),i.jsx(m.TextField,{fullWidth:!0,size:"small",placeholder:"Describe the image",value:a,onChange:u=>l(u.target.value),onKeyDown:u=>{u.key==="Enter"&&r.trim()&&(u.preventDefault(),c())},sx:vr()})]})]}),i.jsxs(m.DialogActions,{children:[i.jsx(m.Button,{onClick:t,children:"Cancel"}),i.jsx(m.Button,{variant:"contained",onClick:c,disabled:!r.trim(),children:"Insert"})]})]})}function S3e({open:e,onClose:t,onInsert:n}){const[r,o]=y.useState("");y.useEffect(()=>{e&&o("")},[e]);const a=()=>{const l=r.trim();l&&(n(l),t())};return i.jsxs(m.Dialog,{open:e,onClose:t,maxWidth:"sm",fullWidth:!0,sx:{zIndex:gy},onMouseDown:l=>l.stopPropagation(),onClick:l=>l.stopPropagation(),children:[i.jsx(m.DialogTitle,{sx:{fontWeight:600},children:"Insert Video"}),i.jsxs(m.DialogContent,{dividers:!0,sx:{pt:2},children:[i.jsxs(m.Typography,{variant:"body2",sx:{fontWeight:600,mb:.5},children:["Video URL"," ",i.jsx(m.Typography,{component:"span",variant:"caption",sx:{color:"text.secondary"},children:"(YouTube, Vimeo, Loom, Wistia, or direct .mp4)"})]}),i.jsx(m.TextField,{fullWidth:!0,size:"small",autoFocus:!0,value:r,placeholder:"https://www.youtube.com/embed/...",onChange:l=>o(l.target.value),onKeyDown:l=>{l.key==="Enter"&&a()},sx:vr()})]}),i.jsxs(m.DialogActions,{children:[i.jsx(m.Button,{onClick:t,children:"Cancel"}),i.jsx(m.Button,{variant:"contained",disabled:!r.trim(),onClick:a,children:"Insert Video"})]})]})}const k3e=/<(\/?)(\b(?!!)[^>\s]*)(.*?)(\s*\/?>)/g;function E3e(e){return e.replace(k3e,(t,n,r)=>{const o=(r||"").toUpperCase(),a=/^DIV|^TD|^TH|^P|^LI|^H[1-7]/.test(o)&&!!n,l=/^BLOCKQUOTE|^TABLE|^TBODY|^TR|^HR|^UL|^OL/.test(o);return t+(a||l?`
1324
+ `).map(a=>a.trim()).filter(a=>a.length>0);if(t.length<2||!t[0].includes("|")||!/^\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?$/.test(t[1]))return null;const r=a=>{const l=a.replace(/^\|/,"").replace(/\|$/,""),s=[];let c="";for(let u=0;u<l.length;u++)l[u]==="\\"&&l[u+1]==="|"?(c+="|",u++):l[u]==="|"?(s.push(c.trim()),c=""):c+=l[u];return s.push(c.trim()),s},o=[t[0],...t.slice(2)];return Xm(o.map(r))}function Xm(e){const t=e.filter(o=>o!==void 0);for(;t.length>0&&t[t.length-1].every(o=>(o??"").trim()==="");)t.pop();if(t.length===0)return null;const n=t.reduce((o,a)=>Math.max(o,a.length),0);if(n===0)return null;const r=[];for(let o=0;o<t.length;o++)for(let a=0;a<n;a++)r.push(t[o][a]??"");return{rows:t.length,columns:n,cells:r}}function fR(e){return h3e(e)??p3e(e)}function f3e(e){if(!e)return null;const t=e.getData("text/html");if(t){const r=hR(t);if(r&&(r.rows>1||r.columns>1))return r}const n=e.getData("text/plain");if(n){const r=fR(n);if(r&&(r.rows>1||r.columns>1))return r}return null}function g3e(e){const t=e.trim();if(!t)return null;if(/<table[\s>]/i.test(t)||/<tr[\s>]/i.test(t)){const n=hR(t);if(n)return n}return fR(t)}async function m3e(e){const t=await Promise.resolve().then(()=>require("./xlsx-BK0uTaY1.cjs")).then(a=>a.xlsx),n=await e.arrayBuffer(),r=t.read(new Uint8Array(n),{type:"array",cellDates:!0}),o=[];for(const a of r.SheetNames){const l=r.Sheets[a],c=t.utils.sheet_to_json(l,{header:1,blankrows:!1,raw:!1}).map(d=>d.map(A=>A==null?"":String(A))),u=Xm(c);u&&o.push({name:a,table:u})}return o}async function b3e(e){const t=await Promise.resolve().then(()=>require("./index-CFRx296W.cjs")).then(o=>o.index),n=await e.arrayBuffer(),{value:r}=await t.convertToHtml({arrayBuffer:n});return r?d3e(r).map((o,a)=>({name:`Table ${a+1}`,table:o})):[]}function x3e(e,t,n,r,o,a,l=50,s=20){const c=Math.min(l,Math.max(t,o+r.rows)),u=Math.min(s,Math.max(n,a+r.columns)),d=new Array(c*u).fill("");for(let A=0;A<Math.min(t,c);A++)for(let p=0;p<Math.min(n,u);p++)d[A*u+p]=e[A*n+p]??"";for(let A=0;A<r.rows;A++){const p=o+A;if(p>=c)break;for(let h=0;h<r.columns;h++){const f=a+h;if(f>=u)break;d[p*u+f]=r.cells[A*r.columns+h]??""}}return{rows:c,columns:u,cells:d}}const C3e={width:16,height:16,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,"& > svg":{width:"100%",height:"100%",display:"block"}};function $l({children:e}){return i.jsx(m.Box,{sx:C3e,children:e})}function Zh(e,t,n,r,o,a,l){const s=new Array(r*o).fill("");for(let c=0;c<r;c++)for(let u=0;u<o;u++){const d=l(c,u);d&&d.oldR>=0&&d.oldR<t&&d.oldC>=0&&d.oldC<n&&a(d.oldR,d.oldC,c,u)&&(s[c*o+u]=e[d.oldR*n+d.oldC]??"")}return s}function y3e(e){var k,I,F,T;const t=Cn(),[n,r]=y.useState(null),o=y.useRef(!1),a=Math.max(1,Math.min(50,((k=e==null?void 0:e.props)==null?void 0:k.rows)??gn.rows)),l=Math.max(1,Math.min(20,((I=e==null?void 0:e.props)==null?void 0:I.columns)??gn.columns)),s=((F=e==null?void 0:e.props)==null?void 0:F.hasHeader)??gn.hasHeader,c=y.useCallback((D,L,P)=>{var Z;if(o.current)return;const M=At()[t];if(!M||M.type!=="Table")return;const z=((Z=M.data)==null?void 0:Z.props)??{},G=Math.max(1,Math.min(50,z.rows??gn.rows)),V=Math.max(1,Math.min(20,z.columns??gn.columns)),_=G*V,W=Array.isArray(z.cells)?[...z.cells]:[];for(;W.length<_;)W.push("");W.length=_;const q=D*V+L;W[q]!==P&&(W[q]=P,pt({[t]:{...M,data:{...M.data,props:{...z,cells:W}}}}))},[t]),u=y.useCallback(D=>{var q;const L=document.activeElement;L&&typeof L.blur=="function"&&L.isContentEditable&&L.blur(),o.current=!0,setTimeout(()=>{o.current=!1},0);const P=At()[t];if(!P||P.type!=="Table")return;const M=((q=P.data)==null?void 0:q.props)??{},z=Math.max(1,Math.min(50,M.rows??gn.rows)),G=Math.max(1,Math.min(20,M.columns??gn.columns)),V=z*G,_=Array.isArray(M.cells)?[...M.cells]:[];for(;_.length<V;)_.push("");_.length=V;const W=D(P,z,G,_);W&&pt({[t]:{...P,data:{...P.data,props:{...M,...W.props??{}},...W.extra??{}}}})},[t]),d=y.useCallback((D,L)=>{u((P,M,z,G)=>{if(M>=50)return null;const V=L==="above"?D:D+1,_=M+1,W=Zh(G,M,z,_,z,()=>!0,(q,Z)=>q===V?null:{oldR:q<V?q:q-1,oldC:Z});return{props:{rows:_,cells:W}}})},[u]),A=y.useCallback((D,L)=>{u((P,M,z,G)=>{if(z>=20)return null;const V=L==="left"?D:D+1,_=z+1,W=Zh(G,M,z,M,_,()=>!0,(q,Z)=>{if(Z===V)return null;const R=Z<V?Z:Z-1;return{oldR:q,oldC:R}});return{props:{columns:_,cells:W}}})},[u]),p=y.useCallback(D=>{u((L,P,M,z)=>{if(P<=1)return null;const G=P-1,V=Zh(z,P,M,G,M,()=>!0,(_,W)=>({oldR:_<D?_:_+1,oldC:W}));return{props:{rows:G,cells:V}}})},[u]),h=y.useCallback(D=>{u((L,P,M,z)=>{if(M<=1)return null;const G=M-1,V=Zh(z,P,M,P,G,()=>!0,(_,W)=>({oldR:_,oldC:W<D?W:W+1}));return{props:{columns:G,cells:V}}})},[u]),f=y.useCallback(()=>{var P,M;const D=At(),L={};for(const[z,G]of Object.entries(D)){if(z===t)continue;const V=G,_=R=>Array.isArray(R)?R.filter(H=>H!==t):R,W=((P=V.data)==null?void 0:P.props)??{};let q=W;Array.isArray(W.childrenIds)&&(q={...W,childrenIds:_(W.childrenIds)}),Array.isArray(W.columns)&&(q={...q,columns:W.columns.map(R=>({...R,childrenIds:_(R.childrenIds)}))}),Array.isArray(W.cells)&&W.cells.some(R=>Array.isArray(R==null?void 0:R.childrenIds))&&(q={...q,cells:W.cells.map(R=>Array.isArray(R==null?void 0:R.childrenIds)?{...R,childrenIds:_(R.childrenIds)}:R)}),Array.isArray(W.items)&&(q={...q,items:W.items.map(R=>({...R,...Array.isArray(R==null?void 0:R.titleChildrenIds)?{titleChildrenIds:_(R.titleChildrenIds)}:{},...Array.isArray(R==null?void 0:R.contentChildrenIds)?{contentChildrenIds:_(R.contentChildrenIds)}:{},...Array.isArray(R==null?void 0:R.cardChildrenIds)?{cardChildrenIds:_(R.cardChildrenIds)}:{},...Array.isArray(R==null?void 0:R.detailChildrenIds)?{detailChildrenIds:_(R.detailChildrenIds)}:{}}))});const Z={...V.data,props:q};Array.isArray((M=V.data)==null?void 0:M.childrenIds)&&(Z.childrenIds=_(V.data.childrenIds)),L[z]={...V,data:Z}}pt(L)},[t]),b=y.useCallback(()=>r(null),[]),C=y.useCallback((D,L,P)=>{D.preventDefault(),D.stopPropagation(),Vt(t),r({x:D.clientX,y:D.clientY,row:L,col:P})},[t]),w=y.useCallback((D,L,P)=>{var R;const M=f3e(D.clipboardData);if(!M)return!1;D.preventDefault();const z=At()[t];if(!z||z.type!=="Table")return!1;const G=((R=z.data)==null?void 0:R.props)??{},V=Math.max(1,Math.min(50,G.rows??gn.rows)),_=Math.max(1,Math.min(20,G.columns??gn.columns)),W=V*_,q=Array.isArray(G.cells)?[...G.cells]:[];for(;q.length<W;)q.push("");q.length=W;const Z=x3e(q,V,_,M,L,P);return pt({[t]:{...z,data:{...z.data,props:{...G,rows:Z.rows,columns:Z.columns,cells:Z.cells}}}}),!0},[t]),v=y.useCallback(({row:D,col:L,value:P,isHeader:M})=>i.jsx(s3e,{html:P,row:D,col:L,isHeader:M,onCommit:z=>c(D,L,z),onContextMenu:C,onPaste:w}),[c,C,w]),B=a*l,S=((T=e==null?void 0:e.props)==null?void 0:T.cells)??[],E=S.length===B?S:(()=>{const D=[...S];if(D.length<B){const L=k5(a,l,s);for(let P=D.length;P<B;P++)D.push(L[P]??"")}return D.length=B,D})();return i.jsxs(i.Fragment,{children:[i.jsx(aP,{style:e==null?void 0:e.style,props:{...(e==null?void 0:e.props)??{},rows:a,columns:l,hasHeader:s,cells:E},renderCell:v}),i.jsxs(m.Menu,{open:n!==null,onClose:b,anchorReference:"anchorPosition",anchorPosition:n?{top:n.y,left:n.x}:void 0,MenuListProps:{dense:!0},children:[i.jsxs(m.MenuItem,{onClick:()=>{n&&d(n.row,"above"),b()},children:[i.jsx(m.ListItemIcon,{children:i.jsx($l,{children:i.jsx(ct.KeyboardArrowUp,{})})}),i.jsx(m.ListItemText,{children:"Insert row above"})]}),i.jsxs(m.MenuItem,{onClick:()=>{n&&d(n.row,"below"),b()},children:[i.jsx(m.ListItemIcon,{children:i.jsx($l,{children:i.jsx(ct.KeyboardArrowDown,{})})}),i.jsx(m.ListItemText,{children:"Insert row below"})]}),i.jsxs(m.MenuItem,{onClick:()=>{n&&A(n.col,"left"),b()},children:[i.jsx(m.ListItemIcon,{children:i.jsx($l,{children:i.jsx(ct.KeyboardArrowLeft,{})})}),i.jsx(m.ListItemText,{children:"Insert column left"})]}),i.jsxs(m.MenuItem,{onClick:()=>{n&&A(n.col,"right"),b()},children:[i.jsx(m.ListItemIcon,{children:i.jsx($l,{children:i.jsx(ct.KeyboardArrowRight,{})})}),i.jsx(m.ListItemText,{children:"Insert column right"})]}),i.jsx(m.Divider,{}),i.jsxs(m.MenuItem,{disabled:a<=1,onClick:()=>{n&&p(n.row),b()},sx:{color:"#dc2626"},children:[i.jsx(m.ListItemIcon,{children:i.jsx($l,{children:i.jsx(Yc,{htmlColor:"#dc2626"})})}),i.jsx(m.ListItemText,{sx:{"& .MuiListItemText-primary":{color:"#dc2626"}},children:"Delete row"})]}),i.jsxs(m.MenuItem,{disabled:l<=1,onClick:()=>{n&&h(n.col),b()},sx:{color:"#dc2626"},children:[i.jsx(m.ListItemIcon,{children:i.jsx($l,{children:i.jsx(Yc,{htmlColor:"#dc2626"})})}),i.jsx(m.ListItemText,{sx:{"& .MuiListItemText-primary":{color:"#dc2626"}},children:"Delete column"})]}),i.jsxs(m.MenuItem,{onClick:()=>{f(),b()},sx:{color:"#dc2626"},children:[i.jsx(m.ListItemIcon,{children:i.jsx($l,{children:i.jsx(Yc,{htmlColor:"#dc2626"})})}),i.jsx(m.ListItemText,{sx:{"& .MuiListItemText-primary":{color:"#dc2626"}},children:"Delete table"})]})]})]})}const v3e=({value:e,onChange:t,readOnly:n,placeholder:r})=>i.jsx(m.TextField,{value:e??"",onChange:o=>t(o.target.value),placeholder:r,multiline:!0,minRows:4,fullWidth:!0,autoFocus:!0,InputProps:{readOnly:!!n,sx:{fontFamily:"monospace",fontSize:13}}}),w3e=["[data-inline-text-toolbar]","[data-inline-editor-fullscreen]","[data-inline-code-view]","[data-inline-image-popover]","[data-inline-table-resize]",".MuiDialog-root",".MuiPopover-root",".react-media-library",'[role="presentation"]'];function q7(e){return!e||!(e instanceof Element)?!1:w3e.some(t=>e.closest(t))}function c4(e){if(!e)return;const t=o=>{let a=o.parentElement;for(;a&&a!==e;){const l=a.tagName;if(l==="LI"||l==="OL"||l==="UL")return!0;a=a.parentElement}return!1};let n=0,r=!1;e.querySelectorAll("ol").forEach(o=>{if(t(o)){o.removeAttribute("start"),o.style.removeProperty("counter-reset");return}const a=o.querySelectorAll(":scope > li").length,l=o.getAttribute("data-mll"),s=l?The[l]:null;if(!r)o.removeAttribute("start"),s&&o.style.removeProperty("counter-reset"),r=!0;else{const c=n+1;c>1?(o.setAttribute("start",String(c)),s&&o.style.setProperty("counter-reset",`${s} ${c-1}`)):(o.removeAttribute("start"),s&&o.style.removeProperty("counter-reset"))}n+=a})}function B3e({open:e,onClose:t,onInsert:n}){const[r,o]=y.useState(""),[a,l]=y.useState(""),s=y.useRef(!1);y.useEffect(()=>{e&&!s.current?(s.current=!0,o(""),l("")):!e&&s.current&&(s.current=!1)},[e]);const c=()=>{const u=r.trim();u&&(n(u,a.trim()||void 0),t())};return i.jsxs(m.Dialog,{open:e,onClose:t,maxWidth:"sm",fullWidth:!0,sx:{zIndex:gy},children:[i.jsx(m.DialogTitle,{sx:{fontSize:16,fontWeight:600},children:"Insert image"}),i.jsxs(m.DialogContent,{sx:{display:"flex",flexDirection:"column",gap:2,pt:1},children:[i.jsxs("div",{children:[i.jsx(m.Typography,{variant:"body2",sx:{mb:.5,fontWeight:500},children:"Image URL"}),i.jsx(m.TextField,{autoFocus:!0,fullWidth:!0,size:"small",placeholder:"https://example.com/image.png",value:r,onChange:u=>o(u.target.value),onKeyDown:u=>{u.key==="Enter"&&r.trim()&&(u.preventDefault(),c())},sx:vr()})]}),i.jsxs("div",{children:[i.jsxs(m.Typography,{variant:"body2",sx:{mb:.5,fontWeight:500},children:["Alt text"," ",i.jsx(m.Typography,{component:"span",variant:"caption",sx:{color:"text.secondary",fontWeight:400},children:"(for screen readers)"})]}),i.jsx(m.TextField,{fullWidth:!0,size:"small",placeholder:"Describe the image",value:a,onChange:u=>l(u.target.value),onKeyDown:u=>{u.key==="Enter"&&r.trim()&&(u.preventDefault(),c())},sx:vr()})]})]}),i.jsxs(m.DialogActions,{children:[i.jsx(m.Button,{onClick:t,children:"Cancel"}),i.jsx(m.Button,{variant:"contained",onClick:c,disabled:!r.trim(),children:"Insert"})]})]})}function S3e({open:e,onClose:t,onInsert:n}){const[r,o]=y.useState("");y.useEffect(()=>{e&&o("")},[e]);const a=()=>{const l=r.trim();l&&(n(l),t())};return i.jsxs(m.Dialog,{open:e,onClose:t,maxWidth:"sm",fullWidth:!0,sx:{zIndex:gy},onMouseDown:l=>l.stopPropagation(),onClick:l=>l.stopPropagation(),children:[i.jsx(m.DialogTitle,{sx:{fontWeight:600},children:"Insert Video"}),i.jsxs(m.DialogContent,{dividers:!0,sx:{pt:2},children:[i.jsxs(m.Typography,{variant:"body2",sx:{fontWeight:600,mb:.5},children:["Video URL"," ",i.jsx(m.Typography,{component:"span",variant:"caption",sx:{color:"text.secondary"},children:"(YouTube, Vimeo, Loom, Wistia, or direct .mp4)"})]}),i.jsx(m.TextField,{fullWidth:!0,size:"small",autoFocus:!0,value:r,placeholder:"https://www.youtube.com/embed/...",onChange:l=>o(l.target.value),onKeyDown:l=>{l.key==="Enter"&&a()},sx:vr()})]}),i.jsxs(m.DialogActions,{children:[i.jsx(m.Button,{onClick:t,children:"Cancel"}),i.jsx(m.Button,{variant:"contained",disabled:!r.trim(),onClick:a,children:"Insert Video"})]})]})}const k3e=/<(\/?)(\b(?!!)[^>\s]*)(.*?)(\s*\/?>)/g;function E3e(e){return e.replace(k3e,(t,n,r)=>{const o=(r||"").toUpperCase(),a=/^DIV|^TD|^TH|^P|^LI|^H[1-7]/.test(o)&&!!n,l=/^BLOCKQUOTE|^TABLE|^TBODY|^TR|^HR|^UL|^OL/.test(o);return t+(a||l?`
1325
1325
  `:"")}).trim()}const I3e=/<\/*(?:applet|b(?:ase|gsound|link)|embed|frame(?:set)?|ilayer|l(?:ayer|ink)|meta|object|s(?:cript|tyle)|t(?:itle|extarea)|xml)[^>]*?>/gi,T3e="<p><br></p>";function D3e(e){return e.replace(I3e,"").trim()||T3e}function j3e(e,t){return["width: 100%",e?"min-height: calc(100vh - 120px)":`min-height: ${Math.max(t,120)}px`,"padding: 10px","background: #222","color: #ccc","font-family: Menlo, Monaco, monospace, sans-serif","font-size: 14px","line-height: 1.5","border: none","border-radius: 0","box-shadow: none","box-sizing: border-box","resize: none","outline: none","white-space: pre","overflow: auto","margin: 0"].join(";")}function F3e({enabled:e,editorEl:t,fullscreen:n,fullscreenEditorEl:r,onRequestExit:o}){const[a,l]=y.useState(null),s=y.useRef(o);return s.current=o,y.useEffect(()=>{var f;if(!e||!t)return;const c=n?r:t;if(!c)return;const u=c.getBoundingClientRect().height,d=c.style.display;c.style.display="none";const A=document.createElement("textarea");A.setAttribute("data-inline-code-view","true"),A.value=E3e(c.innerHTML),A.spellcheck=!1,A.style.cssText=j3e(n,u);const p=()=>{t.innerHTML=A.value,n&&r&&r!==t&&(r.innerHTML=A.value),t.dispatchEvent(new Event("input",{bubbles:!0}))},h=b=>{b.key==="Escape"&&(b.stopPropagation(),b.preventDefault(),s.current())};return A.addEventListener("input",p),A.addEventListener("keydown",h),(f=c.parentNode)==null||f.insertBefore(A,c),l(A),A.focus(),()=>{A.removeEventListener("input",p),A.removeEventListener("keydown",h);const b=D3e(A.value);document.body.contains(t)&&(t.innerHTML=b,t.dispatchEvent(new Event("input",{bubbles:!0}))),n&&r&&r!==t&&document.body.contains(r)&&(r.innerHTML=b),A.remove(),c.style.display=d,l(null),document.body.contains(c)&&c.focus({preventScroll:!0})}},[e,t,n,r]),{textareaEl:a}}const M3e=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE","LI","UL","OL","TD","TH","TR","TABLE","SECTION","ARTICLE","HEADER","FOOTER","NAV","MAIN"]),L3e=new Set(["","transparent","rgba(0, 0, 0, 0)"]),df=e=>{if(!e)return null;const t=e.trim();return L3e.has(t)?null:t},gR=(e,t)=>{let n=e&&e.nodeType===Node.TEXT_NODE?e.parentElement:e;for(;n&&n!==t;){if(M3e.has(n.tagName))return n;n=n.parentElement}return t},P3e=(e,t)=>{const n=gR(e,t);let r=e;for(;r&&r!==n&&r!==t.parentElement;){const o=window.getComputedStyle(r).backgroundColor,a=df(o);if(a)return a;r=r.parentElement}return null},R3e=(e,t)=>{const n=gR(e,t),r=window.getComputedStyle(e).color,o=window.getComputedStyle(n).color;return df(r)===df(o)?null:df(r)};function _3e(e){if(!e)return null;const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);if(!zA(n,e)||n.collapsed)return null;let r=n.startContainer;r&&r.nodeType===Node.TEXT_NODE&&(r=r.parentElement);const o=r??e,a=window.getComputedStyle(o),l=(a.fontFamily||"").replace(/['"]/g,"").split(",")[0].trim()||null,s=Math.round(parseFloat(a.fontSize||"0"));return{bold:document.queryCommandState("bold"),italic:document.queryCommandState("italic"),underline:document.queryCommandState("underline"),strike:document.queryCommandState("strikeThrough"),sup:document.queryCommandState("superscript"),sub:document.queryCommandState("subscript"),foreColor:R3e(o,e),backColor:P3e(o,e),fontName:l,fontSizePx:Number.isFinite(s)&&s>0?s:null}}function O3e(e,t,n){const[r,o]=y.useState(!1),[a,l]=y.useState(!1),s=y.useRef(null),c=y.useCallback(()=>{s.current=null,o(!1),l(!1)},[]),u=y.useCallback(h=>{const f=n.savedRangeRef.current,b=window.getSelection();if(!f||f.collapsed||!zA(f,e)||!b)return;b.removeAllRanges(),b.addRange(f);const C=_3e(e);C&&(s.current=C,l(h),o(!0))},[e,n]),d=y.useCallback(h=>{const f=s.current;if(!f||!e)return;const b=window.getSelection();if(!b)return;const C=document.createElement("span");C.setAttribute("data-painter-mark","start");const w=document.createElement("span");w.setAttribute("data-painter-mark","end");const v=h.cloneRange();v.collapse(!1),v.insertNode(w);const B=h.cloneRange();B.collapse(!0),B.insertNode(C);const S=()=>{const D=e.querySelector('span[data-painter-mark="start"]'),L=e.querySelector('span[data-painter-mark="end"]');if(!D||!L)return!1;const P=document.createRange();return P.setStartAfter(D),P.setEndBefore(L),b.removeAllRanges(),b.addRange(P),!0},E=(D,L)=>{S()&&document.queryCommandState(D)!==L&&document.execCommand(D,!1)};E("bold",f.bold),E("italic",f.italic),E("underline",f.underline),E("strikeThrough",f.strike),E("superscript",f.sup),E("subscript",f.sub);const k=(D,L)=>{S()&&document.execCommand(D,!1,L)};k("foreColor",f.foreColor??"inherit"),k("hiliteColor",f.backColor??"transparent"),f.fontName&&k("fontName",f.fontName),f.fontSizePx&&S()&&(document.execCommand("fontSize",!1,"7"),e.querySelectorAll('font[size="7"]').forEach(D=>{const L=D;L.removeAttribute("size"),L.style.fontSize=`${f.fontSizePx}px`}),e.dispatchEvent(new Event("input",{bubbles:!0})));const I=e.querySelector('span[data-painter-mark="start"]'),F=e.querySelector('span[data-painter-mark="end"]');if(I&&F){const D=document.createRange();D.setStartAfter(I),D.setEndBefore(F),I.remove(),F.remove(),b.removeAllRanges(),b.addRange(D)}const T=qn(e);T&&(n.savedRangeRef.current=T),Mt()},[e,n]);y.useEffect(()=>{if(!r||!e||!t)return;const h=f=>{var C;const b=f.target;b&&((C=b.closest)!=null&&C.call(b,'[data-inline-text-toolbar="true"]'))||setTimeout(()=>{const w=window.getSelection();if(!w||w.rangeCount===0)return;const v=w.getRangeAt(0);v.collapsed||!zA(v,e)||(d(v.cloneRange()),a||c())},0)};return document.addEventListener("mouseup",h,!0),()=>document.removeEventListener("mouseup",h,!0)},[r,a,e,t,d,c]),y.useEffect(()=>{if(!r)return;const h=f=>{f.key==="Escape"&&c()};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[r,c]),y.useEffect(()=>{if(!r||!e)return;const h=e.style.cursor;return e.style.cursor="copy",()=>{e.style.cursor=h}},[r,e]);const A=y.useCallback(()=>{if(r){c();return}u(!1)},[r,c,u]),p=y.useCallback(()=>{u(!0)},[u]);return{active:r,sticky:a,onClick:A,onDoubleClick:p,cancel:c}}function N3e(e){return e?e.split(/[_-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" "):"Inter"}function Xh(e,t){if(!e)return null;const n=e.nodeType===Node.TEXT_NODE?e.parentElement:e;return!n||!t.contains(n)?null:n}function Jh(e){const t=window.getComputedStyle(e),n=Math.round(parseFloat(t.fontSize||"16")),r=(t.fontFamily||"").replace(/['"]/g,"").split(",")[0].trim()||"Inter";return{size:Number.isFinite(n)?n:16,family:r}}function $3e(e){if(!e)return{};const t=window.getSelection();if(!t||t.rangeCount===0)return{};const n=t.getRangeAt(0);if(!e.contains(n.commonAncestorContainer))return{};const r=Xh(t.focusNode,e)||Xh(n.endContainer,e)||Xh(n.startContainer,e)||Xh(n.commonAncestorContainer,e);if(!r)return{};let o="Normal",a=null,l=null,s=r;for(;s&&s!==e&&s!==document.body;){const w=s.tagName;if(w==="PRE"||w==="BLOCKQUOTE"){o=dg[w]??"Normal",a=s;break}!l&&Wc.has(w)&&(l=s),s=s.parentElement}!a&&l&&(o=dg[l.tagName]??"Normal",a=l);const c=a??e,u=(c==null?void 0:c.style.lineHeight)??"",d=new Set,A=new Set;if(n.collapsed){const{size:w,family:v}=Jh(r);d.add(w),A.add(v)}else{const w=n.commonAncestorContainer,v=w.nodeType===Node.TEXT_NODE&&w.parentNode||w,B=document.createTreeWalker(v,NodeFilter.SHOW_TEXT,{acceptNode(E){return n.intersectsNode(E)?!E.nodeValue||!E.nodeValue.replace(/\s/g,"")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}});let S;for(;S=B.nextNode();){const E=S.parentElement;if(!E||!e.contains(E))continue;const{size:k,family:I}=Jh(E);d.add(k),A.add(I)}if(d.size===0){const{size:E,family:k}=Jh(r);d.add(E),A.add(k)}}const p=Jh(r),h=d.size===1?[...d][0]:p.size,f=A.size===1?[...A][0]:p.family,C=(()=>{const w={desktop:"",tablet:"",mobile:""},v={desktop:"data-fs-desktop",tablet:"data-fs-tablet",mobile:"data-fs-mobile"};let B=r;for(;B&&B!==e&&(["desktop","tablet","mobile"].forEach(S=>{if(w[S])return;const E=B.getAttribute(v[S]);E&&(w[S]=E)}),!(w.desktop&&w.tablet&&w.mobile));)B=B.parentElement;return w})();return{blockLabel:o,fontName:N3e(f),fontSize:String(h),fontSizeDesktop:C.desktop,fontSizeTablet:C.tablet,fontSizeMobile:C.mobile,lineHeight:u}}function H3e(e,t){const[n,r]=y.useState(Kxe);return y.useEffect(()=>{if(!e)return;const o=()=>{const a=window.getSelection();if(!a||a.rangeCount===0||!zA(a.getRangeAt(0),t))return;let l="";try{let c=a.getRangeAt(0).startContainer;for(;c&&c!==t&&c!==document.body;){if(c.nodeType===Node.ELEMENT_NODE){const u=c;(u.tagName==="OL"||u.tagName==="UL")&&u.hasAttribute("data-mll")&&(l=u.getAttribute("data-mll")||"")}c=c.parentNode}}catch{}try{r(s=>({...s,bold:document.queryCommandState("bold"),italic:document.queryCommandState("italic"),underline:document.queryCommandState("underline"),strike:document.queryCommandState("strikeThrough"),sup:document.queryCommandState("superscript"),sub:document.queryCommandState("subscript"),ul:document.queryCommandState("insertUnorderedList"),ol:document.queryCommandState("insertOrderedList"),alignLeft:document.queryCommandState("justifyLeft"),alignCenter:document.queryCommandState("justifyCenter"),alignRight:document.queryCommandState("justifyRight"),alignJustify:document.queryCommandState("justifyFull"),mllScheme:l,...$3e(t)}))}catch{}};return o(),document.addEventListener("selectionchange",o),t==null||t.addEventListener("input",o),()=>{document.removeEventListener("selectionchange",o),t==null||t.removeEventListener("input",o)}},[e,t]),n}function U3e({editorEl:e}){const[t,n]=y.useState(!1),[r,o]=y.useState(null);return y.useEffect(()=>{if(!t){e&&document.body.contains(e)&&e.focus({preventScroll:!0});return}if(!r||!e)return;r.innerHTML=e.innerHTML,r.focus({preventScroll:!0});const a=document.createRange();a.selectNodeContents(r),a.collapse(!1);const l=window.getSelection();l==null||l.removeAllRanges(),l==null||l.addRange(a)},[t,r,e]),y.useEffect(()=>{if(!t)return;const a=l=>{l.key==="Escape"&&(l.stopPropagation(),n(!1))};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[t]),{fullscreen:t,setFullscreen:n,fullscreenEditorEl:r,setFullscreenEditorEl:o}}const Hl={desktop:"data-fs-desktop",tablet:"data-fs-tablet",mobile:"data-fs-mobile"},zi=["data-fs-desktop","data-fs-tablet","data-fs-mobile"],Y7=["background-image","background-clip","-webkit-background-clip","-webkit-text-fill-color"],z3e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Q3e=e=>e.replace(/[&<>"']/g,t=>z3e[t]),lb=e=>e.replace(/"/g,"&quot;"),e1=(e,t)=>{const n=e.isConnected?e:t,r=document.createRange();return r.selectNodeContents(n),r.collapse(!1),r};function V3e(e,t){const n=y.useRef(null);y.useEffect(()=>{if(!e||!t)return;const R=()=>{const H=qn(e);H&&(n.current=H)};return R(),document.addEventListener("selectionchange",R),()=>document.removeEventListener("selectionchange",R)},[e,t]);const r=y.useCallback((R,H)=>{mo(n.current,e),document.execCommand(R,!1,H),R==="insertOrderedList"&&c4(e);const N=qn(e);N&&(n.current=N),Mt()},[e]),o=y.useCallback(R=>{if(!e)return;mo(n.current,e);const H=R.toUpperCase(),N=window.getSelection();if(N&&N.rangeCount>0){const ie=N.getRangeAt(0);let ae=ie.startContainer,ne=null;for(;ae&&ae!==e;){if(ae.nodeType===Node.ELEMENT_NODE){const te=ae.tagName;(te==="PRE"||te==="BLOCKQUOTE")&&(ne=ae)}ae=ae.parentNode}if(ne&&ne.tagName!==H){const te=ie.cloneRange(),fe=ne.parentNode;if(fe){for(;ne.firstChild;)fe.insertBefore(ne.firstChild,ne);fe.removeChild(ne)}const Ae=window.getSelection();Ae&&(Ae.removeAllRanges(),Ae.addRange(te))}}document.execCommand("formatBlock",!1,`<${R}>`);const $=["border-left","font-style","color"],ee=["background","background-color","color","border-radius","border","font-family","line-height","white-space","overflow-x","tab-size"],K=["margin","padding","font-size"],X=ie=>{ie.style.margin||(ie.style.margin="8px 0"),ie.style.padding||(ie.style.padding="8px 16px"),ie.style.borderLeft||(ie.style.borderLeft="4px solid #cbd5e1"),ie.style.fontStyle||(ie.style.fontStyle="italic"),ie.style.color||(ie.style.color="rgba(71, 85, 105, 0.9)")},Y=ie=>{if(ie.children.length===0)return;ie.querySelectorAll("br").forEach(te=>te.replaceWith(document.createTextNode(`
1326
1326
  `)));const ae=ie.innerHTML,ne=document.createElement("textarea");ne.innerHTML=ae,ie.textContent=ne.value},ue=ie=>{ie.style.margin||(ie.style.margin="12px 0"),ie.style.padding||(ie.style.padding="16px 20px"),ie.style.background||(ie.style.background="#1e1e1e"),ie.style.color||(ie.style.color="#e6e6e6"),ie.style.borderRadius||(ie.style.borderRadius="10px"),ie.style.fontFamily||(ie.style.fontFamily='"Fira Code", "JetBrains Mono", Menlo, Consolas, "SF Mono", monospace'),ie.style.fontSize||(ie.style.fontSize="13.5px"),ie.style.lineHeight||(ie.style.lineHeight="1.6"),ie.style.whiteSpace||(ie.style.whiteSpace="pre-wrap"),ie.style.overflowX||(ie.style.overflowX="auto"),ie.style.tabSize||(ie.style.tabSize="2")},ce=(ie,ae)=>{const ne=[];ae!=="BLOCKQUOTE"&&ne.push(...$),ae!=="PRE"&&ne.push(...ee),ae===null&&ne.push(...K),ne.forEach(te=>ie.style.removeProperty(te)),ie.getAttribute("style")===""&&ie.removeAttribute("style")},re=Array.from(Wc).join(","),pe=window.getSelection(),Q=pe&&pe.rangeCount>0?pe.getRangeAt(0):null,U=ie=>!Q||!Q.intersectsNode(ie)?!1:ie.tagName.toUpperCase()===H?!0:!Array.from(ie.querySelectorAll(re)).some(ae=>Q.intersectsNode(ae));Array.from(e.querySelectorAll(re)).filter(U).forEach(ie=>{const ae=ie.tagName.toUpperCase();if(ae==="BLOCKQUOTE")ce(ie,"BLOCKQUOTE"),X(ie);else if(ae==="PRE")ce(ie,"PRE"),Y(ie),ue(ie);else{if(ce(ie,null),ae===H){const ne=/^H[1-6]$/.test(ae),te=ne?$A(ae.toLowerCase()):void 0,fe=(te==null?void 0:te.fontSize)??Sw[ae];if(fe!=null&&!ie.querySelector("[data-fs-desktop],[data-fs-tablet],[data-fs-mobile]")&&(ie.style.fontSize=`${fe}px`,zi.forEach(Ae=>ie.removeAttribute(Ae)),ie.setAttribute("data-fs-desktop",String(fe)),(te==null?void 0:te.fontSizeTablet)!=null&&ie.setAttribute("data-fs-tablet",String(te.fontSizeTablet)),(te==null?void 0:te.fontSizeMobile)!=null&&ie.setAttribute("data-fs-mobile",String(te.fontSizeMobile))),ne&&ie.querySelectorAll('[style*="background-clip"]').forEach(Ae=>{Y7.forEach(xe=>Ae.style.removeProperty(xe)),Ae.style.color==="transparent"&&Ae.style.removeProperty("color"),Ae.getAttribute("style")===""&&Ae.removeAttribute("style")}),te!=null&&te.color)if(/gradient\(/.test(te.color)){const Ae=ie.ownerDocument.createElement("span");for(Ae.setAttribute("style",[`background-image:${te.color}`,"-webkit-background-clip:text","background-clip:text","color:transparent","-webkit-text-fill-color:transparent"].join(";"));ie.firstChild;)Ae.appendChild(ie.firstChild);ie.appendChild(Ae)}else ie.style.color=te.color}ae===H&&Sw[ae]!=null&&!ie.style.fontWeight&&(ie.style.fontWeight="bold")}}),e.dispatchEvent(new Event("input",{bubbles:!0}));const O=qn(e);O&&(n.current=O),Mt()},[e]),a=y.useCallback((R,H)=>{var ue,ce;const N=n.current;if(!N||!e)return;const $=window.getSelection();if(!$)return;if($.removeAllRanges(),$.addRange(N),/gradient\(/.test(H)){const re=document.createElement("span");R==="foreColor"?(re.style.setProperty("background-image",H),re.style.setProperty("background-clip","text"),re.style.setProperty("-webkit-background-clip","text"),re.style.setProperty("color","transparent"),re.style.setProperty("-webkit-text-fill-color","transparent")):re.style.setProperty("background-image",H);try{N.surroundContents(re)}catch{re.appendChild(N.extractContents()),N.insertNode(re)}const pe=document.createRange();pe.selectNodeContents(re),$.removeAllRanges(),$.addRange(pe);const Q=qn(e);Q&&(n.current=Q),Mt();return}if(R==="foreColor"){const re=Q=>{Y7.forEach(U=>Q.style.removeProperty(U)),Q.style.color==="transparent"&&Q.style.removeProperty("color"),Q.getAttribute("style")||Q.removeAttribute("style")};e.querySelectorAll('[style*="background-clip"]').forEach(Q=>{N.intersectsNode(Q)&&re(Q)});let pe=N.commonAncestorContainer.nodeType===Node.TEXT_NODE?N.commonAncestorContainer.parentElement:N.commonAncestorContainer;for(;pe&&pe!==e;)((ue=pe.style)!=null&&ue.backgroundClip||(ce=pe.style)!=null&&ce.webkitBackgroundClip)&&re(pe),pe=pe.parentElement}const K=[];R==="foreColor"&&Array.from(e.querySelectorAll("li")).forEach((pe,Q)=>{N.intersectsNode(pe)&&K.push(Q)});const X=[];if(R==="foreColor"&&Array.from(e.querySelectorAll("a")).forEach((pe,Q)=>{N.intersectsNode(pe)&&X.push(Q)}),document.execCommand(R,!1,H),H.startsWith("rgba(")){const re=R==="foreColor"?"color":"bgcolor",pe=R==="foreColor"?"color":"background-color",Q=$.rangeCount>0?$.getRangeAt(0):null;Q&&e.querySelectorAll(`font[${re}]`).forEach(U=>{Q.intersectsNode(U)&&(U.style.setProperty(pe,H),U.removeAttribute(re))})}if(R==="foreColor"&&K.length){const re=Array.from(e.querySelectorAll("li"));K.forEach(pe=>{const Q=re[pe];!Q||!(Q.textContent??"").trim()||Q.style.setProperty("color",H,"important")})}if(R==="foreColor"&&X.length){const re=Array.from(e.querySelectorAll("a"));X.forEach(pe=>{const Q=re[pe];!Q||!(Q.textContent??"").trim()||Q.style.setProperty("color",H,"important")})}const Y=qn(e);Y&&(n.current=Y),Mt()},[e]),l=y.useCallback((R,H)=>{if(!e)return;mo(n.current,e);const N=window.getSelection(),$=ae=>{let ne=ae&&ae.nodeType===Node.TEXT_NODE?ae.parentElement:ae;for(;ne&&ne!==e;){if(Wc.has(ne.tagName))return ne;ne=ne.parentElement}return null},ee=N&&N.rangeCount>0?$(N.getRangeAt(0).startContainer):null,K=ee?{desktop:ee.getAttribute("data-fs-desktop"),tablet:ee.getAttribute("data-fs-tablet"),mobile:ee.getAttribute("data-fs-mobile"),inlineFontSize:ee.style.fontSize||null}:null,X=()=>{!ee||!K||!ee.isConnected||(["desktop","tablet","mobile"].forEach(ae=>{const ne=Hl[ae],te=K[ae];ae!==H&&te&&!ee.hasAttribute(ne)&&ee.setAttribute(ne,te)}),K.inlineFontSize&&!ee.style.fontSize&&(ee.style.fontSize=K.inlineFontSize))},Y=ae=>{let ne=ae&&ae.nodeType===Node.TEXT_NODE?ae.parentElement:ae;for(;ne&&ne!==e;){if(ne.tagName==="SPAN"&&zi.some(te=>ne.hasAttribute(te)))return ne;ne=ne.parentElement}return null},ue=window.getSelection(),ce=ue&&ue.rangeCount>0?ue.getRangeAt(0):null;if(ce&&e.contains(ce.commonAncestorContainer)){const ae=Y(ce.startContainer),ne=Y(ce.endContainer);if(ae&&ae===ne){const te=ae.contains(ce.startContainer)&&ae.contains(ce.endContainer),fe=(()=>{if(ce.collapsed)return!0;const Ae=document.createRange();Ae.selectNodeContents(ae);const xe=ce.compareBoundaryPoints(Range.START_TO_START,Ae)<=0||!/\S/.test((()=>{const se=Ae.cloneRange();return se.setEnd(ce.startContainer,ce.startOffset),se.toString()})()),le=ce.compareBoundaryPoints(Range.END_TO_END,Ae)>=0||!/\S/.test((()=>{const se=Ae.cloneRange();return se.setStart(ce.endContainer,ce.endOffset),se.toString()})());return xe&&le})();if(te&&fe){ae.setAttribute(Hl[H],String(R));const Ae=Hl[H];ae.querySelectorAll(`span[${Ae}]`).forEach(le=>{if(le.removeAttribute(Ae),!zi.some(he=>le.hasAttribute(he))&&!le.hasAttribute("style")&&!le.hasAttribute("class")){const he=le.parentNode;if(!he)return;for(;le.firstChild;)he.insertBefore(le.firstChild,le);he.removeChild(le)}}),X(),e.dispatchEvent(new Event("input",{bubbles:!0}));const xe=qn(e);n.current=xe??e1(ae,e),Mt();return}}}if(ce&&ce.collapsed&&e.contains(ce.commonAncestorContainer)){const ae=document.createElement("span");ae.setAttribute(Hl[H],String(R));const ne=document.createTextNode("​");ae.appendChild(ne),ce.insertNode(ae);const te=document.createRange();te.setStart(ne,1),te.collapse(!0),ue==null||ue.removeAllRanges(),ue==null||ue.addRange(te),X(),e.dispatchEvent(new Event("input",{bubbles:!0})),n.current=qn(e)??te,Mt();return}document.execCommand("fontSize",!1,"7");const re=[];e.querySelectorAll('font[size="7"]').forEach(ae=>{const ne=ae,te=document.createElement("span");zi.forEach(le=>{const se=ne.getAttribute(le);se&&te.setAttribute(le,se)});const fe=ne.getAttribute("style");fe&&te.setAttribute("style",fe),te.style.removeProperty("font-size");const Ae=ne.getAttribute("color");Ae&&!te.style.color&&(te.style.color=Ae);const xe=ne.getAttribute("face");for(xe&&!te.style.fontFamily&&(te.style.fontFamily=xe),te.setAttribute(Hl[H],String(R));ne.firstChild;)te.appendChild(ne.firstChild);ne.replaceWith(te),re.push(te)});const pe=ae=>!!ae&&ae.tagName==="SPAN"&&zi.some(ne=>ae.hasAttribute(ne)),Q=(ae,ne)=>{if(ne.children.length!==1||ne.firstElementChild!==ae)return!1;for(let te=ne.firstChild;te;te=te.nextSibling)if(te!==ae&&te.nodeType===Node.TEXT_NODE&&/\S/.test(te.textContent??""))return!1;return!0};re.forEach(ae=>{for(;;){const ne=ae.parentElement;if(!ne||ne===e||!pe(ne)||!Q(ae,ne))break;zi.forEach(fe=>{const Ae=ne.getAttribute(fe);Ae&&!ae.hasAttribute(fe)&&ae.setAttribute(fe,Ae)}),LM(ne,ae);const te=ne.parentNode;if(!te)break;for(;ne.firstChild;)te.insertBefore(ne.firstChild,ne);te.removeChild(ne)}});const U=Hl[H];re.forEach(ae=>{ae.querySelectorAll(`span[${U}]`).forEach(te=>{if(te.removeAttribute(U),!zi.some(Ae=>te.hasAttribute(Ae))&&!te.hasAttribute("style")&&!te.hasAttribute("class")){const Ae=te.parentNode;if(!Ae)return;for(;te.firstChild;)Ae.insertBefore(te.firstChild,te);Ae.removeChild(te)}})}),Ag(e),X(),e.dispatchEvent(new Event("input",{bubbles:!0}));const O=qn(e),ie=re[re.length-1];n.current=O??(ie?e1(ie,e):n.current),Mt()},[e]),s=y.useCallback(R=>{if(!e)return;mo(n.current,e);const H=window.getSelection();if(!H||H.rangeCount===0)return;const N=H.getRangeAt(0);if(!e.contains(N.commonAncestorContainer))return;const $=Hl[R],ee=new Set,K=ce=>{let re=ce&&ce.nodeType===Node.TEXT_NODE?ce.parentElement:ce;for(;re&&re!==e;)re.hasAttribute($)&&ee.add(re),re=re.parentElement};K(N.startContainer),K(N.endContainer);const X=N.commonAncestorContainer.nodeType===Node.ELEMENT_NODE?N.commonAncestorContainer:N.commonAncestorContainer.parentElement;X==null||X.querySelectorAll(`[${$}]`).forEach(ce=>{e.contains(ce)&&N.intersectsNode(ce)&&ee.add(ce)});const Y=N.commonAncestorContainer;ee.forEach(ce=>{ce.removeAttribute($);const re=zi.some(pe=>ce.hasAttribute(pe));if(ce.tagName==="SPAN"&&!re&&!ce.hasAttribute("style")){const pe=ce.parentNode;for(;ce.firstChild;)pe==null||pe.insertBefore(ce.firstChild,ce);pe==null||pe.removeChild(ce)}}),e.dispatchEvent(new Event("input",{bubbles:!0}));const ue=qn(e);n.current=ue??e1(Y,e),Mt()},[e]),c=y.useCallback(R=>{if(!e)return;if(!mo(n.current,e)){const ce=e1(e,e);mo(ce,e)}const N=window.getSelection();if(!N||N.rangeCount===0)return;const $=N.getRangeAt(0);if(!e.contains($.commonAncestorContainer))return;const ee=ce=>{let re=ce&&ce.nodeType===Node.TEXT_NODE?ce.parentElement:ce;for(;re&&re!==e;){if(re.tagName==="SPAN"&&zi.some(pe=>re.hasAttribute(pe)))return re;re=re.parentElement}return null},K=ee($.startContainer),X=ee($.endContainer);if(K&&K===X&&K.contains($.startContainer)&&K.contains($.endContainer)){K.style.fontFamily=R,e.dispatchEvent(new Event("input",{bubbles:!0}));const ce=qn(e);ce&&(n.current=ce),Mt();return}if($.collapsed)return;const Y=document.createElement("span");Y.style.fontFamily=R;try{const ce=$.extractContents();Y.appendChild(ce),$.insertNode(Y);const re=document.createRange();re.selectNodeContents(Y),N.removeAllRanges(),N.addRange(re)}catch(ce){console.warn("[applyFontFamily] Range wrap failed, falling back to execCommand",ce),document.execCommand("fontName",!1,R)}Ag(e),e.dispatchEvent(new Event("input",{bubbles:!0}));const ue=qn(e);ue&&(n.current=ue),Mt()},[e]),u=y.useCallback(R=>{if(!e)return;mo(n.current,e);const H=window.getSelection();if(!H||H.rangeCount===0)return;const N=H.getRangeAt(0);if(!e.contains(N.commonAncestorContainer))return;const $=X=>{let Y=X&&X.nodeType===Node.TEXT_NODE?X.parentElement:X;for(;Y&&Y!==e&&Y!==document.body;){if(Wc.has(Y.tagName))return Y;Y=Y.parentElement}return null},ee=new Set;if(N.collapsed){const X=$(N.startContainer);X&&ee.add(X)}else{const X=$(N.startContainer),Y=$(N.endContainer);X&&ee.add(X),Y&&ee.add(Y);const ue=N.commonAncestorContainer,ce=ue.nodeType===Node.ELEMENT_NODE?ue:ue.parentElement;ce&&ce.querySelectorAll(Array.from(Wc).join(",")).forEach(pe=>{e.contains(pe)&&N.intersectsNode(pe)&&ee.add(pe)})}if(ee.size===0&&e.firstChild){const X=document.createElement("div");for(;e.firstChild;)X.appendChild(e.firstChild);e.appendChild(X),ee.add(X)}ee.forEach(X=>{R?X.style.lineHeight=R:X.style.removeProperty("line-height")}),e.style.lineHeight&&e.style.removeProperty("line-height"),e.dispatchEvent(new Event("input",{bubbles:!0}));const K=qn(e);K&&(n.current=K),Mt()},[e]),d=y.useCallback(R=>{mo(n.current,e),document.execCommand("insertHTML",!1,R);const H=qn(e);H&&(n.current=H),Mt()},[e]),A=y.useCallback(()=>{if(!e)return null;const R=$=>$?$.nodeType===Node.ELEMENT_NODE?$:$.parentElement:null,H=$=>{if(!$||!e.contains($.commonAncestorContainer))return null;const ee=R($.startContainer),K=ee==null?void 0:ee.closest("a");if(K&&e.contains(K))return K;const X=R($.endContainer),Y=X==null?void 0:X.closest("a");if(Y&&e.contains(Y))return Y;const ue=R($.commonAncestorContainer);if(ue){const ce=ue.querySelectorAll("a");for(let re=0;re<ce.length;re++){const pe=ce[re];if(e.contains(pe)&&$.intersectsNode(pe))return pe}}return null},N=window.getSelection();if(N&&N.rangeCount>0){const $=H(N.getRangeAt(0));if($)return $}return H(n.current)},[e]),p=y.useCallback(({text:R,url:H,newWindow:N,underline:$})=>{if(!e)return;mo(n.current,e);const ee=A();if(ee){const U=window.getSelection();if(U){const O=document.createRange();O.selectNode(ee),U.removeAllRanges(),U.addRange(O)}}const K=N?' target="_blank" rel="noopener noreferrer"':"",X=(ee==null?void 0:ee.style.getPropertyValue("color"))??"",Y=Array.from(e.querySelectorAll("a")).length,ue=`<a href="${lb(H)}"${K}>${Q3e(R)}</a>`;document.execCommand("insertHTML",!1,ue);const ce=window.getSelection(),re=Array.from(e.querySelectorAll("a"));let pe=null;if(ce&&ce.rangeCount>0){const U=ce.getRangeAt(0);pe=re.find(O=>U.intersectsNode(O))??null}!pe&&re.length>Y&&(pe=re[re.length-1]),pe&&(X&&pe.style.setProperty("color",X,"important"),$?pe.style.removeProperty("text-decoration"):pe.style.setProperty("text-decoration","none","important"));const Q=qn(e);Q&&(n.current=Q),Mt()},[e,A]),h=y.useCallback(()=>{if(!e)return;mo(n.current,e);const R=A();if(!R)return;const H=R.parentNode;if(!H)return;const N=document.createRange();for(N.setStartBefore(R.firstChild??R);R.firstChild;)H.insertBefore(R.firstChild,R);N.setEndBefore(R),H.removeChild(R);const $=window.getSelection();$&&($.removeAllRanges(),$.addRange(N)),e.dispatchEvent(new Event("input",{bubbles:!0}));const ee=qn(e);ee&&(n.current=ee),Mt()},[e,A]),f=y.useCallback((R,H)=>{if(!e)return;const N=document.createElement("img");N.src=R,N.alt=H??"",N.style.maxWidth="100%",N.style.height="auto",e.focus({preventScroll:!0}),mo(n.current,e);const $=window.getSelection();let ee=$!=null&&$.rangeCount?$.getRangeAt(0):null;(!ee||!e.contains(ee.commonAncestorContainer))&&(ee=document.createRange(),ee.selectNodeContents(e),ee.collapse(!1),$==null||$.removeAllRanges(),$==null||$.addRange(ee)),ee.deleteContents(),ee.insertNode(N),ee.setStartAfter(N),ee.setEndAfter(N),$==null||$.removeAllRanges(),$==null||$.addRange(ee),e.dispatchEvent(new Event("input",{bubbles:!0}));const K=qn(e);K&&(n.current=K),Mt()},[e]),b=y.useCallback(R=>{const H=R.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([A-Za-z0-9_-]{6,})/),N=H?`https://www.youtube.com/embed/${H[1]}`:R,ee=/youtube|vimeo|loom|wistia|youku|dailymotion/i.test(N)?`<p><iframe src="${lb(N)}" style="width:100%;aspect-ratio:16/9;border:0" allowfullscreen></iframe></p>`:`<p><video src="${lb(N)}" controls style="width:100%"></video></p>`;d(ee)},[d]),C=y.useCallback((R,H)=>{const N=Math.max(1,Math.min(8,R)),$=Math.max(1,Math.min(8,H)),X=`<table style="border-collapse:collapse;width:100%"><tbody>${`<tr>${'<td style="border:1px solid #d1d5db;padding:6px;min-width:40px">&nbsp;</td>'.repeat($)}</tr>`.repeat(N)}</tbody></table><p></p>`;d(X)},[d]),w=y.useCallback(()=>{if(!e)return null;const R=ee=>{let K=ee;for(;K&&K!==e;){if(K.nodeType===Node.ELEMENT_NODE&&(K.tagName==="TD"||K.tagName==="TH"))return K;K=K.parentNode}return null},H=window.getSelection(),N=H&&H.rangeCount>0?H.getRangeAt(0).startContainer:null;if(N&&e.contains(N)){const ee=R(N);if(ee)return ee}const $=n.current;if($&&e.contains($.startContainer)){const ee=R($.startContainer);if(ee)return ee}return null},[e]),v=R=>{const H=document.createElement("td");return H.setAttribute("style",(R==null?void 0:R.getAttribute("style"))||"border:1px solid #d1d5db;padding:6px;min-width:40px"),H.innerHTML="&nbsp;",H},B=R=>{if(!R||!e){n.current=null;return}const H=document.createRange();H.selectNodeContents(R),H.collapse(!0);const N=window.getSelection();N&&(N.removeAllRanges(),N.addRange(H));const $=qn(e);$&&(n.current=$)},S=y.useCallback(()=>!!w(),[w]),E=y.useCallback(R=>{var Y;const H=w(),N=H==null?void 0:H.parentElement;if(!H||!N)return;const $=N.children.length,ee=document.createElement("tr"),K=N.getAttribute("style");K&&ee.setAttribute("style",K);let X=null;for(let ue=0;ue<$;ue++){const ce=N.children[ue],re=v(ce);ue===0&&(X=re),ee.appendChild(re)}(Y=N.parentNode)==null||Y.insertBefore(ee,R==="above"?N:N.nextSibling),B(X),Mt()},[w]),k=y.useCallback(R=>{const H=w(),N=H==null?void 0:H.parentElement,$=N==null?void 0:N.closest("table");if(!H||!N||!$)return;const ee=Array.prototype.indexOf.call(N.children,H);let K=null;$.querySelectorAll("tr").forEach(X=>{const Y=X.children[ee],ue=v(Y);R==="left"?X.insertBefore(ue,Y??null):X.insertBefore(ue,Y?Y.nextSibling:null),X===N&&(K=ue)}),B(K),Mt()},[w]),I=y.useCallback(()=>{const R=w(),H=R==null?void 0:R.parentElement,N=H==null?void 0:H.closest("table");if(!(!R||!H||!N)){if(N.querySelectorAll("tr").length<=1)N.remove(),B(null);else{const $=Array.prototype.indexOf.call(H.children,R),ee=H.nextElementSibling||H.previousElementSibling;H.remove();const K=(ee==null?void 0:ee.children[$])||(ee==null?void 0:ee.children[0]);B(K??null)}Mt()}},[w]),F=y.useCallback(()=>{const R=w(),H=R==null?void 0:R.parentElement,N=H==null?void 0:H.closest("table");if(!R||!H||!N)return;const $=Array.prototype.indexOf.call(H.children,R);if(H.children.length<=1)N.remove(),B(null);else{N.querySelectorAll("tr").forEach(K=>{const X=K.children[$];X&&K.removeChild(X)});const ee=H.children[$]||H.children[$-1];B(ee??null)}Mt()},[w]),T=y.useCallback(()=>{const R=w(),H=R==null?void 0:R.closest("table");H&&(H.remove(),B(null),Mt())},[w]),D=y.useCallback(R=>{const H=w(),N=H==null?void 0:H.parentElement;N&&(N.querySelectorAll("th, td").forEach($=>{$.style.backgroundColor=R}),e==null||e.dispatchEvent(new Event("input",{bubbles:!0})),Mt())},[w,e]),L=y.useCallback(()=>{o("PRE")},[o]),P=y.useCallback(()=>{r("insertHorizontalRule")},[r]),M=y.useCallback(R=>{mo(n.current,e),qxe(R);const H=qn(e);H&&(n.current=H),e==null||e.dispatchEvent(new Event("input",{bubbles:!0})),Mt()},[e]),z=y.useCallback(R=>{if(!e)return;const H=n.current;if(!H)return;const N=window.getSelection();N&&(N.removeAllRanges(),N.addRange(H));const ee=(X=>{let Y=X&&X.nodeType===Node.TEXT_NODE?X.parentElement:X;for(;Y&&Y!==e;){if(Y.tagName==="PRE")return Y;Y=Y.parentElement}return null})(H.startContainer);if(!ee)return;R?ee.style.background=R:(ee.style.removeProperty("background"),ee.style.removeProperty("background-color"),ee.style.background="#1e1e1e"),e.dispatchEvent(new Event("input",{bubbles:!0}));const K=qn(e);K&&(n.current=K),Mt()},[e]),G=y.useCallback(()=>{var ee;if(!e)return null;const R=window.getSelection();let N=(R&&R.rangeCount>0&&e.contains(R.getRangeAt(0).startContainer)?R.getRangeAt(0).startContainer:null)??((ee=n.current)==null?void 0:ee.startContainer)??null,$=null;for(;N&&N!==e;){if(N.nodeType===Node.ELEMENT_NODE){const K=N.tagName;(K==="OL"||K==="UL")&&($=N)}N=N.parentNode}return $},[e]),V=y.useCallback(()=>{r("indent")},[r]),_=y.useCallback(()=>{r("outdent")},[r]),W=y.useCallback(R=>{if(!e)return;mo(n.current,e);const H=PM.find(K=>K.id===R),N=(H==null?void 0:H.listTag)??null;let $=G();if((!$||N&&$.tagName.toLowerCase()!==N)&&(N==="ol"?document.execCommand("insertOrderedList"):N==="ul"&&document.execCommand("insertUnorderedList"),$=G()),!$){Mt();return}H?$.setAttribute("data-mll",H.id):$.removeAttribute("data-mll"),$.querySelectorAll("ol[data-mll], ul[data-mll]").forEach(K=>{K.removeAttribute("data-mll")}),$.tagName==="OL"&&c4(e);const ee=qn(e);ee&&(n.current=ee),e.dispatchEvent(new Event("input",{bubbles:!0})),Mt()},[e,G]),q=y.useCallback(()=>{const R=n.current;if(!R)return"";if(!R.collapsed)return R.toString();const H=A();return(H==null?void 0:H.textContent)??""},[A]),Z=y.useCallback(()=>{const R=A();return R?{text:R.textContent??"",url:R.getAttribute("href")??"",newWindow:R.getAttribute("target")==="_blank",underline:R.style.getPropertyValue("text-decoration")!=="none"}:null},[A]);return{savedRangeRef:n,runCommand:r,applyBlockStyle:o,applyColor:a,applyFontSize:l,clearFontSize:s,applyFontFamily:c,applyLineHeight:u,applyCodeBackground:z,insertHtml:d,handleInsertLink:p,handleRemoveLink:h,handleInsertImage:f,handleInsertVideo:b,handleInsertTable:C,isInTableCell:S,handleTableInsertRow:E,handleTableInsertColumn:k,handleTableDeleteRow:I,handleTableDeleteColumn:F,handleTableDelete:T,handleTableRowBackground:D,handleInsertCode:L,handleInsertHorizontalRule:P,handleSpeechResult:M,runIndent:V,runOutdent:_,applyMultilevelList:W,getSavedSelectionText:q,getSavedSelectionLink:Z}}function W3e(e,t){const[n,r]=y.useState(null),[o,a]=y.useState(!1),l=y.useRef(null);return y.useEffect(()=>{r(null)},[t]),y.useEffect(()=>{if(!o)return;const c=d=>{const A=l.current;if(!A||!e)return;d.preventDefault();const p=A.startLeft+(d.clientX-A.pointerX),h=A.startTop+(d.clientY-A.pointerY),f=e.getBoundingClientRect(),b=Math.max(8,Math.min(window.innerWidth-f.width-8,p)),C=Math.max(8,Math.min(window.innerHeight-f.height-8,h));r({top:C,left:b})},u=()=>{a(!1),l.current=null};return document.addEventListener("mousemove",c),document.addEventListener("mouseup",u),()=>{document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",u)}},[o,e]),{manualOffset:n,dragging:o,reset:()=>r(null),handleDragStart:c=>{if(!e)return;c.preventDefault(),c.stopPropagation();const u=e.getBoundingClientRect();l.current={pointerX:c.clientX,pointerY:c.clientY,startTop:u.top,startLeft:u.left},a(!0)}}}function G3e(e){let t=(e==null?void 0:e.parentElement)??null;for(;t&&t!==document.body;){const n=window.getComputedStyle(t),r=(n.overflow||"")+(n.overflowY||"")+(n.overflowX||"");if(/(auto|scroll|overlay)/.test(r))return t;t=t.parentElement}return null}function K3e(e,t,n,r){const[o,a]=y.useState(null);return y.useLayoutEffect(()=>{if(!t||!e||!n){a(null);return}if(r){a(r);return}const l=G3e(e);let s=0;const c=()=>{s=0;const A=e.getBoundingClientRect(),p=n.getBoundingClientRect(),h=8,f=window.innerHeight,b=l?l.getBoundingClientRect():null,C=b?b.top:0,w=b?b.bottom:f,v=A.top-Math.max(0,C),B=Math.min(f,w)-A.bottom;let S;v>=p.height+h?S=A.top-p.height-h:B>=p.height+h?S=A.bottom+h:S=C-p.height-h,S=Math.max(h,Math.min(f-p.height-h,S));const E=Math.max(8,Math.min(window.innerWidth-p.width-8,A.left));a({top:S,left:E})},u=()=>{s||(s=window.requestAnimationFrame(c))};c(),window.addEventListener("scroll",u,!0),window.addEventListener("resize",u);const d=new ResizeObserver(u);return d.observe(e),l&&d.observe(l),()=>{window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u),d.disconnect(),s&&cancelAnimationFrame(s)}},[e,n,t,r]),o}function q3e({editorEl:e,open:t,onMutate:n}){const r=tt.useTheme();Il(r);const[o,a]=y.useState(null),[l,s]=y.useState(null),[c,u]=y.useState(null);y.useEffect(()=>{if(!e||!t){a(null);return}const b=C=>{var v;const w=C.target;if(w){if(w instanceof HTMLImageElement&&e.contains(w)){a(w);return}(v=w.closest)!=null&&v.call(w,"[data-inline-image-popover]")||a(null)}};return document.addEventListener("mousedown",b,!0),()=>document.removeEventListener("mousedown",b,!0)},[e,t]),y.useEffect(()=>{o&&(document.body.contains(o)||a(null))},[o]),y.useLayoutEffect(()=>{if(!o){s(null),u(null);return}const b=()=>{const v=o.getBoundingClientRect();s({top:v.top-8,left:v.left+v.width/2}),u({w:v.width,h:v.height,nw:o.naturalWidth,nh:o.naturalHeight})};b();const C=new ResizeObserver(b);C.observe(o);const w=uR(b);return window.addEventListener("scroll",w,{capture:!0,passive:!0}),window.addEventListener("resize",w),()=>{w.cancel(),C.disconnect(),window.removeEventListener("scroll",w,!0),window.removeEventListener("resize",w)}},[o]);const d=y.useCallback(()=>{e==null||e.dispatchEvent(new Event("input",{bubbles:!0})),n()},[e,n]),A=y.useCallback(b=>{o&&(o.style.width=b,o.style.height="auto",o.removeAttribute("width"),o.removeAttribute("height"),d())},[o,d]),p=y.useCallback(()=>{o&&(o.style.width="",o.style.height="",o.removeAttribute("width"),o.removeAttribute("height"),d())},[o,d]),h=y.useCallback(b=>{o&&(o.style.float=b,b==="left"?o.style.margin="0 10px 10px 0":b==="right"?o.style.margin="0 0 10px 10px":o.style.margin="",d())},[o,d]),f=y.useCallback(()=>{var b;o&&((b=o.parentNode)==null||b.removeChild(o),a(null),d())},[o,d]);return!t||!o||!l?null:oa.createPortal(i.jsxs("div",{"data-inline-image-popover":"true",onMouseDown:sr,style:{position:"fixed",top:l.top,left:l.left,transform:"translate(-50%, -100%)",zIndex:1500,background:"linear-gradient(180deg, rgba(255,255,255,0.99) 0%, rgba(247,249,252,0.99) 100%)",border:"1px solid rgba(15,23,42,0.08)",borderRadius:10,boxShadow:"0 14px 32px -10px rgba(15,23,42,0.22), 0 2px 8px rgba(15,23,42,0.08)",padding:6,display:"flex",flexDirection:"column",gap:4,color:"rgba(17,24,39,0.92)",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontSize:12,userSelect:"none"},children:[i.jsxs("div",{style:{display:"flex",gap:4},children:[i.jsx(La,{onClick:()=>A("100%"),children:"100%"}),i.jsx(La,{onClick:()=>A("50%"),children:"50%"}),i.jsx(La,{onClick:()=>A("25%"),children:"25%"}),i.jsx(La,{title:"Original size",onClick:p,children:i.jsx(ct.RestartAlt,{sx:{fontSize:16}})})]}),i.jsxs("div",{style:{display:"flex",gap:4},children:[i.jsx(La,{title:"Float left",onClick:()=>h("left"),children:i.jsx(ct.FormatAlignLeft,{sx:{fontSize:16}})}),i.jsx(La,{title:"Float right",onClick:()=>h("right"),children:i.jsx(ct.FormatAlignRight,{sx:{fontSize:16}})}),i.jsx(La,{title:"Remove float",onClick:()=>h(""),children:i.jsx(ct.FormatClear,{sx:{fontSize:16}})}),i.jsx(La,{title:"Remove image",onClick:f,children:i.jsx(ct.Delete,{sx:{fontSize:16}})})]}),c&&i.jsxs("div",{style:{textAlign:"center",color:"rgba(55,65,81,0.92)",fontSize:11,paddingTop:2},children:[c.w.toFixed(1),"x",c.h.toFixed(1)," (Original: ",c.nw,"x",c.nh,")"]})]}),document.body)}function La({title:e,onClick:t,children:n}){const r=Il(tt.useTheme());return i.jsx("button",{type:"button",title:e,onMouseDown:sr,onClick:o=>{o.preventDefault(),t()},onMouseEnter:o=>o.currentTarget.style.background=r,onMouseLeave:o=>o.currentTarget.style.background="transparent",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",height:28,minWidth:40,padding:"0 8px",border:"1px solid rgba(15,23,42,0.1)",borderRadius:6,background:"transparent",color:"inherit",cursor:"pointer",font:"inherit",fontSize:12},children:n})}const Z7=8,t1=6,Y3e=120;function Z3e({children:e}){const t=tt.useTheme(),n=Il(t),[r,o]=y.useState(!1),a=y.useRef(null),l=y.useRef(null),[s,c]=y.useState(null);return y.useLayoutEffect(()=>{if(!r||!a.current){c(null);return}const u=()=>{var b;const d=a.current.getBoundingClientRect(),A=window.innerHeight-d.bottom-t1-Z7,p=d.top-t1-Z7,h=((b=l.current)==null?void 0:b.scrollHeight)??Y3e,f=A<h&&p>A;c({placement:f?"top":"bottom"})};return u(),window.addEventListener("resize",u),window.addEventListener("scroll",u,!0),()=>{window.removeEventListener("resize",u),window.removeEventListener("scroll",u,!0)}},[r]),y.useEffect(()=>{if(!r)return;const u=d=>{var p,h;const A=d.target;(p=l.current)!=null&&p.contains(A)||(h=a.current)!=null&&h.contains(A)||o(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[r]),i.jsxs("div",{style:{position:"relative"},children:[i.jsx("button",{ref:a,type:"button",title:"More","aria-label":"More tools","aria-haspopup":"true","aria-expanded":r,"data-codeview-keep":"true",onMouseDown:sr,onClick:u=>{u.preventDefault(),o(d=>!d)},style:ma,onMouseEnter:u=>{u.currentTarget.style.background=n},onMouseLeave:u=>{u.currentTarget.style.background="transparent"},children:i.jsx(ct.MoreHoriz,{sx:{fontSize:20}})}),r&&i.jsx("div",{ref:l,onMouseDown:sr,style:{...qm,left:"auto",right:0,top:(s==null?void 0:s.placement)==="top"?"auto":`calc(100% + ${t1}px)`,bottom:(s==null?void 0:s.placement)==="top"?`calc(100% + ${t1}px)`:"auto",overflow:"visible",padding:6,display:"flex",flexWrap:"wrap",gap:2,maxWidth:360,alignItems:"center",visibility:s?"visible":"hidden"},children:e})]})}function Qa({style:e,onSelect:t,children:n}){return i.jsx("button",{type:"button",onMouseDown:sr,onClick:r=>{r.preventDefault(),t()},style:{...Gxe,...e},children:n})}function Zl({style:e,selected:t,onSelect:n,children:r}){return i.jsxs(Qa,{style:{paddingLeft:8,...e},onSelect:n,children:[i.jsx("span",{style:{width:18,display:"inline-flex",alignItems:"center",justifyContent:"center",marginRight:4},children:t&&i.jsx(ct.Check,{sx:{fontSize:14}})}),r]})}const X7=8,n1=6,sb=220,X3e=["h1","h2","h3","h4","h5","h6","p"],J3e=e=>{const t=new Set(cA.map(n=>n.px));return X3e.forEach(n=>{const r=$A();[r.fontSize,r.fontSizeTablet,r.fontSizeMobile].forEach(o=>{o!=null&&Number.isFinite(o)&&o>0&&t.add(o)})}),e.forEach(n=>{const r=n?parseInt(n,10):NaN;Number.isFinite(r)&&r>0&&t.add(r)}),Array.from(t).sort((n,r)=>n-r).map(n=>({label:String(n),px:n}))},e5e=[{key:"desktop",label:"Desktop",Icon:ct.DesktopMac},{key:"tablet",label:"Tablet",Icon:ct.TabletMac},{key:"mobile",label:"Mobile",Icon:ct.PhoneIphone}];function t5e({values:e,fallbackSize:t,initialDevice:n,onApply:r,onClear:o}){const a=tt.useTheme(),l=Il(a),[s,c]=y.useState(!1),[u,d]=y.useState(n),A=y.useRef(null),p=y.useRef(null),[h,f]=y.useState(null),[b,C]=y.useState({});y.useEffect(()=>{C(T=>{const D={...T};return["desktop","tablet","mobile"].forEach(L=>{D[L]!==void 0&&D[L]===e[L]&&delete D[L]}),D})},[e.desktop,e.tablet,e.mobile]);const w={desktop:b.desktop??e.desktop,tablet:b.tablet??e.tablet,mobile:b.mobile??e.mobile},B=!w.desktop&&!w.tablet&&!w.mobile&&t?{desktop:t,tablet:t,mobile:t}:w;y.useEffect(()=>{s||(d(n),C({}))},[n,s]),y.useLayoutEffect(()=>{if(!s||!A.current){f(null);return}const T=()=>{var W;const D=A.current.getBoundingClientRect(),L=window.innerHeight-D.bottom-n1-X7,P=D.top-n1-X7,M=((W=p.current)==null?void 0:W.scrollHeight)??sb,z=L<M&&P>L,G=z?P:L,_=M>0&&M<=G?null:Math.min(Math.max(sb,M||sb),G);f({placement:z?"top":"bottom",maxHeight:_})};return T(),window.addEventListener("resize",T),window.addEventListener("scroll",T,!0),()=>{window.removeEventListener("resize",T),window.removeEventListener("scroll",T,!0)}},[s]),y.useEffect(()=>{if(!s)return;const T=D=>{var P,M;const L=D.target;(P=p.current)!=null&&P.contains(L)||(M=A.current)!=null&&M.contains(L)||c(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[s]);const S=B[u],E=!!(w.desktop||w.tablet||w.mobile),k=S||t,I=S?parseInt(S,10):NaN,F=y.useMemo(()=>J3e([B.desktop,B.tablet,B.mobile,t]),[B.desktop,B.tablet,B.mobile,t]);return i.jsxs("div",{style:{position:"relative"},children:[i.jsxs("button",{ref:A,type:"button","aria-label":"Font size (per device)",title:"Font size (per device)","aria-haspopup":"true","aria-expanded":s,onMouseDown:sr,onClick:T=>{T.preventDefault(),c(D=>!D)},style:{...ma,padding:"0 8px",minWidth:76,justifyContent:"space-between",gap:4,fontWeight:500,background:"rgba(255,255,255,0.85)",border:"1px solid rgba(15,23,42,0.14)",color:"rgba(17,24,39,0.92)",position:"relative"},onMouseEnter:T=>{T.currentTarget.style.background="#fff"},onMouseLeave:T=>{T.currentTarget.style.background="rgba(255,255,255,0.85)"},children:[i.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[k,E&&i.jsx("span",{"aria-hidden":"true",title:"This block has per-device font-size overrides",style:{display:"inline-block",width:5,height:5,borderRadius:"50%",background:"rgb(99,102,241)"}})]}),i.jsx(ct.KeyboardArrowDown,{sx:{fontSize:16,opacity:.7}})]}),s&&i.jsx("div",{ref:p,onMouseDown:sr,style:{...qm,top:(h==null?void 0:h.placement)==="top"?"auto":`calc(100% + ${n1}px)`,bottom:(h==null?void 0:h.placement)==="top"?`calc(100% + ${n1}px)`:"auto",maxHeight:(h==null?void 0:h.maxHeight)??void 0,overflowY:(h==null?void 0:h.maxHeight)!=null?"auto":void 0,visibility:h?"visible":"hidden",minWidth:220,padding:6},children:i.jsxs("div",{style:{...Rc,gap:4},children:[e5e.map(({key:T,label:D,Icon:L})=>{const P=u===T,M=B[T],z=!!w[T];return i.jsxs("div",{onMouseDown:sr,onClick:G=>{G.preventDefault(),d(T)},style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",borderRadius:6,cursor:"pointer",background:P?l:"transparent",border:P?`1px solid ${a.palette.primary.main}`:"1px solid transparent"},children:[i.jsx(L,{sx:{fontSize:16,opacity:.8}}),i.jsx("span",{style:{fontSize:12,fontWeight:600,flex:1},children:D}),i.jsx("span",{style:{fontSize:12,color:M?"rgba(17,24,39,0.92)":"rgba(17,24,39,0.4)",fontVariantNumeric:"tabular-nums",minWidth:32,textAlign:"right"},children:M?`${M}px`:"Not set"}),z&&i.jsx("button",{type:"button",title:`Clear ${D} size`,"aria-label":`Clear ${D} size`,onMouseDown:sr,onClick:G=>{G.preventDefault(),G.stopPropagation(),C(V=>({...V,[T]:""})),o(T)},style:{...ma,height:22,minWidth:22,padding:0,borderRadius:4},onMouseEnter:G=>{G.currentTarget.style.background=l},onMouseLeave:G=>{G.currentTarget.style.background="transparent"},children:i.jsx(ct.Close,{sx:{fontSize:14,opacity:.7}})})]},T)}),i.jsx("div",{style:{borderTop:"1px solid rgba(15,23,42,0.08)",margin:"4px 0 2px"}}),i.jsx("div",{style:{maxHeight:220,overflowY:"auto",display:"flex",flexDirection:"column",gap:2},children:F.map(T=>i.jsx(Zl,{selected:I===T.px,onSelect:()=>{C(D=>({...D,[u]:String(T.px)})),r(T.px,u)},children:T.label},T.px))})]})})]})}function n5e({onPick:e}){const[n,r]=y.useState({r:0,c:0});return i.jsxs("div",{onMouseLeave:()=>r({r:0,c:0}),style:{padding:8,minWidth:0},children:[i.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(8, 16px)",gridAutoRows:16,gap:3},children:Array.from({length:8*8}).map((o,a)=>{const l=Math.floor(a/8)+1,s=a%8+1,c=l<=n.r&&s<=n.c;return i.jsx("div",{onMouseEnter:()=>r({r:l,c:s}),onMouseDown:sr,onClick:u=>{u.preventDefault(),e(l,s)},style:{width:16,height:16,borderRadius:3,border:"1px solid rgba(15,23,42,0.18)",background:c?"rgba(99,102,241,0.55)":"rgba(15,23,42,0.02)",cursor:"pointer",transition:"background 80ms ease"}},a)})}),i.jsx("div",{style:{fontSize:11,color:"rgba(71,85,105,0.9)",marginTop:6,textAlign:"center",minHeight:14},children:n.r>0?`${n.r} × ${n.c}`:"Pick size"})]})}const J7=30,eB=80,u4=8,AA=12,xc=(e,t)=>`${(e/t*100).toFixed(2)}%`;function r5e(e){const t=d=>{const A=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let p=null,h;for(;(h=A.nextNode())&&!((h.textContent??"").replace(/[\s ]/g,"")&&(p=h,!d)););return p};if(!(e.textContent??"").replace(/[\s ]/g,""))return;const n=t(!1),r=t(!0),o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),a=[];let l;for(;l=o.nextNode();)a.push(l);const s=n?a.indexOf(n):-1,c=r?a.indexOf(r):-1;a.forEach((d,A)=>{(A<s||A>c)&&(d.textContent="")}),n&&(n.textContent=(n.textContent??"").replace(/^[\s ]+/,"")),r&&(r.textContent=(r.textContent??"").replace(/[\s ]+$/,""));let u=e.lastChild;for(;u&&(u.nodeName==="BR"||u.nodeType===Node.TEXT_NODE&&!u.textContent);){const d=u.previousSibling;e.removeChild(u),u=d}}const r1=e=>{const t=e.rows[0];return t?Array.from(t.cells):[]};function o5e({editorEl:e,open:t,onMutate:n}){const[r,o]=y.useState(null),[a,l]=y.useState(null),[s,c]=y.useState(!1),u=y.useRef(null);y.useEffect(()=>{if(!e||!t){o(null);return}const _=Z=>{var N;const R=Z&&(Z.nodeType===Node.ELEMENT_NODE?Z:Z.parentElement),H=(N=R==null?void 0:R.closest)==null?void 0:N.call(R,"table");return H&&e.contains(H)?H:null},W=Z=>{var H;const R=Z.target;R&&((H=R.closest)!=null&&H.call(R,"[data-inline-table-resize]")||o(_(R)))},q=()=>{const Z=window.getSelection();if(!Z||Z.rangeCount===0)return;const R=Z.getRangeAt(0).startContainer;e.contains(R)&&o(_(R))};return document.addEventListener("mousedown",W,!0),document.addEventListener("selectionchange",q),()=>{document.removeEventListener("mousedown",W,!0),document.removeEventListener("selectionchange",q)}},[e,t]);const d=y.useCallback(()=>{if(!r||!document.body.contains(r)){l(null);return}const _=r1(r);l({table:r.getBoundingClientRect(),boundaries:_.slice(0,-1).map(W=>W.getBoundingClientRect().right)})},[r]);y.useLayoutEffect(()=>{if(!r){l(null);return}d();const _=new ResizeObserver(d);return _.observe(r),e==null||e.addEventListener("input",d),window.addEventListener("scroll",d,!0),window.addEventListener("resize",d),()=>{_.disconnect(),e==null||e.removeEventListener("input",d),window.removeEventListener("scroll",d,!0),window.removeEventListener("resize",d)}},[r,e,d]),y.useEffect(()=>()=>{var _;return(_=u.current)==null?void 0:_.call(u)},[]);const A=y.useCallback(()=>{e==null||e.dispatchEvent(new Event("input",{bubbles:!0})),n()},[e,n]),p=_=>{var W;return((W=_.parentElement)==null?void 0:W.clientWidth)||_.getBoundingClientRect().width},h=_=>{const W=r1(_),q=W.map(R=>R.getBoundingClientRect().width),Z=_.getBoundingClientRect().width;return _.style.tableLayout="fixed",_.style.width||(_.style.width=xc(Z,p(_))),W.forEach((R,H)=>{R.style.width=xc(q[H],Z)}),q},f=(_,W,q="col-resize")=>{sr(_),_.stopPropagation();const Z=_.clientX,R=_.clientY;c(!0);const H=ee=>{W(ee.clientX-Z,ee.clientY-R),d()},N=()=>{window.removeEventListener("mousemove",H),window.removeEventListener("mouseup",$),document.body.style.cursor="",document.body.style.userSelect="",u.current=null},$=()=>{N(),c(!1),A()};document.body.style.cursor=q,document.body.style.userSelect="none",window.addEventListener("mousemove",H),window.addEventListener("mouseup",$),u.current=N},b=_=>W=>{if(!r)return;const q=r,Z=h(q),R=Z.reduce(($,ee)=>$+ee,0)||1,H=Z[_]+Z[_+1],N=r1(q);f(W,$=>{const ee=Math.min(Math.max(Z[_]+$,J7),H-J7);N[_].style.width=xc(ee,R),N[_+1].style.width=xc(H-ee,R)})},C=_=>{if(!r)return;const W=r;h(W);const q=W.getBoundingClientRect().width,Z=p(W);f(_,R=>{const H=Math.min(Math.max(q+R,eB),Z);W.style.width=xc(H,Z)})},w=_=>{if(!r)return;const W=r;h(W);const q=W.getBoundingClientRect(),Z=p(W),R=W.style.height;W.style.height="";const H=W.getBoundingClientRect().height;W.style.height=R,f(_,(N,$)=>{const ee=Math.min(Math.max(q.width+N,eB),Z);W.style.width=xc(ee,Z);const K=Math.max(q.height+$,H);K<=H+1?W.style.removeProperty("height"):W.style.height=`${Math.round(K)}px`},"nwse-resize")},v=_=>{const W=_.style.marginLeft,q=_.style.marginRight;return W==="auto"&&q==="auto"?"center":W==="auto"?"right":q==="auto"?"left":null},B=_=>{r&&(r.style.marginLeft=_==="left"?"0px":"auto",r.style.marginRight=_==="right"?"0px":"auto",A(),d())},S=_=>{const W=new Set(Array.from(_.querySelectorAll("th, td")).map(Z=>{const R=window.getComputedStyle(Z).textAlign;return R==="start"?"left":R==="end"?"right":R}));if(W.size!==1)return null;const q=Array.from(W)[0];return q==="left"||q==="center"||q==="right"?q:null},E=_=>{r&&(r.querySelectorAll("th, td").forEach(W=>{W.style.textAlign=_,W.removeAttribute("align"),r5e(W);const q=Array.from(W.querySelectorAll("*"));q.forEach(Z=>{Z.removeAttribute("align"),Z.style.float&&Z.style.removeProperty("float"),Z.style.marginLeft==="auto"&&Z.style.removeProperty("margin-left"),Z.style.marginRight==="auto"&&Z.style.removeProperty("margin-right"),Z.style.textAlign&&(Z.style.removeProperty("text-align"),Z.getAttribute("style")===""&&Z.removeAttribute("style"))}),q.forEach(Z=>{const R=window.getComputedStyle(Z).textAlign;(R==="start"?"left":R==="end"?"right":R)!==_&&(Z.style.textAlign=_)})}),A(),d())},k=_=>{r&&(r.style.width=_,A(),d())},I=()=>{if(!r)return;const _=r1(r);_.length!==0&&(r.style.tableLayout="fixed",_.forEach(W=>{W.style.width=`${(100/_.length).toFixed(2)}%`}),A(),d())},F=()=>{r&&(r.style.tableLayout="",r.style.width="100%",r.style.removeProperty("height"),r.querySelectorAll("th, td").forEach(_=>{_.style.removeProperty("width"),_.getAttribute("style")===""&&_.removeAttribute("style")}),r.removeAttribute("width"),A(),d())},T=_=>Array.from(_.querySelectorAll("th, td")),D=_=>T(_).some(W=>{const q=window.getComputedStyle(W);return["Top","Right","Bottom","Left"].some(Z=>parseFloat(q[`border${Z}Width`])>0&&q[`border${Z}Style`]!=="none")}),L=()=>{if(!r)return;!D(r)?(r.style.borderCollapse="collapse",T(r).forEach(W=>{W.style.border="1px solid #d1d5db",W.style.padding||(W.style.padding="6px")})):T(r).forEach(W=>{W.style.border="none",W.style.padding==="6px"&&W.style.removeProperty("padding")}),A(),d()};if(!t||!r||!a)return null;const{table:P,boundaries:M}=a,z=D(r),G=v(r),V=S(r);return oa.createPortal(i.jsxs("div",{"data-inline-table-resize":"true",children:[i.jsx("div",{style:{position:"fixed",top:P.top-1,left:P.left-1,width:P.width+2,height:P.height+2,border:`1px dashed ${s?"#1976d2":"rgba(25,118,210,0.55)"}`,pointerEvents:"none",zIndex:1499}}),M.map((_,W)=>i.jsx(tB,{title:"Drag to resize columns",top:P.top,left:_-u4/2,height:P.height,onMouseDown:b(W)},W)),i.jsx(tB,{title:"Drag to resize table width",top:P.top,left:P.right-u4/2,height:Math.max(P.height-AA,8),onMouseDown:C,strong:!0}),i.jsx(i5e,{top:P.bottom-AA/2,left:P.right-AA/2,onMouseDown:w}),i.jsxs("div",{onMouseDown:sr,style:{position:"fixed",top:P.bottom+6,left:Math.max(P.left,8),zIndex:1500,display:s?"none":"flex",alignItems:"center",gap:4,padding:4,background:"rgba(255,255,255,0.99)",border:"1px solid rgba(15,23,42,0.08)",borderRadius:8,boxShadow:"0 8px 20px -8px rgba(15,23,42,0.25)",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontSize:12,color:"rgba(17,24,39,0.92)",userSelect:"none"},children:[i.jsx("span",{style:{padding:"0 4px",color:"rgba(55,65,81,0.8)"},children:"Width"}),i.jsx(So,{onClick:()=>k("100%"),children:"100%"}),i.jsx(So,{onClick:()=>k("75%"),children:"75%"}),i.jsx(So,{onClick:()=>k("50%"),children:"50%"}),i.jsx("div",{style:{width:1,alignSelf:"stretch",background:"rgba(15,23,42,0.08)"}}),i.jsx("span",{style:{padding:"0 4px",color:"rgba(55,65,81,0.8)"},children:"Table"}),i.jsx(So,{title:"Align table left",onClick:()=>B("left"),active:G==="left",children:i.jsx(ct.FormatAlignLeft,{sx:{fontSize:16,verticalAlign:"middle"}})}),i.jsx(So,{title:"Align table center",onClick:()=>B("center"),active:G==="center",children:i.jsx(ct.FormatAlignCenter,{sx:{fontSize:16,verticalAlign:"middle"}})}),i.jsx(So,{title:"Align table right",onClick:()=>B("right"),active:G==="right",children:i.jsx(ct.FormatAlignRight,{sx:{fontSize:16,verticalAlign:"middle"}})}),i.jsx("div",{style:{width:1,alignSelf:"stretch",background:"rgba(15,23,42,0.08)"}}),i.jsx("span",{style:{padding:"0 4px",color:"rgba(55,65,81,0.8)"},children:"Text"}),i.jsx(So,{title:"Align cell text left",onClick:()=>E("left"),active:V==="left",children:i.jsx(ct.FormatAlignLeft,{sx:{fontSize:16,verticalAlign:"middle"}})}),i.jsx(So,{title:"Align cell text center",onClick:()=>E("center"),active:V==="center",children:i.jsx(ct.FormatAlignCenter,{sx:{fontSize:16,verticalAlign:"middle"}})}),i.jsx(So,{title:"Align cell text right",onClick:()=>E("right"),active:V==="right",children:i.jsx(ct.FormatAlignRight,{sx:{fontSize:16,verticalAlign:"middle"}})}),i.jsx("div",{style:{width:1,alignSelf:"stretch",background:"rgba(15,23,42,0.08)"}}),i.jsx(So,{title:"Make all columns the same width",onClick:I,children:"Equal columns"}),i.jsx(So,{title:"Clear custom sizes",onClick:F,children:"Reset"}),i.jsx("div",{style:{width:1,alignSelf:"stretch",background:"rgba(15,23,42,0.08)"}}),i.jsx(So,{title:z?"Hide table borders":"Show table borders",onClick:L,active:z,children:"Borders"})]})]}),document.body)}function tB({title:e,top:t,left:n,height:r,onMouseDown:o,strong:a=!1}){const[l,s]=y.useState(!1);return i.jsxs("div",{title:e,onMouseDown:o,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{position:"fixed",top:t,left:n,width:u4,height:r,cursor:"col-resize",zIndex:1500,display:"flex",justifyContent:"center"},children:[i.jsx("div",{style:{width:l||a?2:1,height:"100%",background:l?"#1976d2":"rgba(25,118,210,0.45)"}}),i.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:6,height:Math.min(24,Math.max(r-4,8)),borderRadius:3,background:l?"#1976d2":"#ffffff",border:"1px solid #1976d2",boxSizing:"border-box",pointerEvents:"none"}})]})}function i5e({top:e,left:t,onMouseDown:n}){const[r,o]=y.useState(!1);return i.jsx("div",{title:"Drag to resize table width and height",onMouseDown:n,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{position:"fixed",top:e,left:t,width:AA,height:AA,cursor:"nwse-resize",zIndex:1501,borderRadius:2,background:r?"#1976d2":"#ffffff",border:"1px solid #1976d2",boxSizing:"border-box"}})}function So({title:e,onClick:t,children:n,active:r=!1}){const[o,a]=y.useState(!1);return i.jsx("button",{type:"button",title:e,onMouseDown:sr,onClick:l=>{l.preventDefault(),t()},onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),"aria-pressed":r||void 0,style:{height:26,padding:"0 8px",border:`1px solid ${r?"rgba(25,118,210,0.6)":"rgba(15,23,42,0.1)"}`,borderRadius:6,background:r?"rgba(25,118,210,0.14)":o?"rgba(25,118,210,0.08)":"transparent",color:r?"#1565c0":"inherit",cursor:"pointer",font:"inherit",fontSize:12,whiteSpace:"nowrap"},children:n})}const nB=8,o1=6,cb=120;function Cc({label:e,icon:t,ariaLabel:n,width:r,children:o}){const a=tt.useTheme(),l=Il(a),[s,c]=y.useState(!1),u=y.useRef(null),d=y.useRef(null),[A,p]=y.useState(null);y.useLayoutEffect(()=>{if(!s||!u.current){p(null);return}const b=()=>{var F;const C=u.current.getBoundingClientRect(),w=window.innerHeight-C.bottom-o1-nB,v=C.top-o1-nB,B=((F=d.current)==null?void 0:F.scrollHeight)??cb,S=w<B&&v>w,E=S?v:w,I=B>0&&B<=E?null:Math.min(Math.max(cb,B||cb),E);p({placement:S?"top":"bottom",maxHeight:I})};return b(),window.addEventListener("resize",b),window.addEventListener("scroll",b,!0),()=>{window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0)}},[s]),y.useEffect(()=>{if(!s)return;const b=C=>{var v,B;const w=C.target;(v=d.current)!=null&&v.contains(w)||(B=u.current)!=null&&B.contains(w)||c(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[s]),y.useEffect(()=>s?dR(()=>c(!1)):void 0,[s]);const h=!!t,f=n||e||"";return i.jsxs("div",{style:{position:"relative"},children:[i.jsxs("button",{ref:u,type:"button","aria-label":f,title:f,"aria-haspopup":"true","aria-expanded":s,onMouseDown:sr,onClick:b=>{b.preventDefault(),c(C=>{const w=!C;return w&&AR(),w})},style:h?{...ma,gap:2,paddingRight:4}:{...ma,padding:"0 8px",minWidth:r??88,justifyContent:"space-between",gap:4,fontWeight:500,background:"rgba(255,255,255,0.85)",border:"1px solid rgba(15,23,42,0.14)",color:"rgba(17,24,39,0.92)"},onMouseEnter:b=>{b.currentTarget.style.background=h?l:"#fff"},onMouseLeave:b=>{b.currentTarget.style.background=h?"transparent":"rgba(255,255,255,0.85)"},children:[h?t:i.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e}),i.jsx(ct.KeyboardArrowDown,{sx:{fontSize:h?14:16,opacity:.7,ml:h?"-2px":0}})]}),s&&i.jsx("div",{ref:d,onMouseDown:sr,style:{...qm,top:(A==null?void 0:A.placement)==="top"?"auto":`calc(100% + ${o1}px)`,bottom:(A==null?void 0:A.placement)==="top"?`calc(100% + ${o1}px)`:"auto",maxHeight:(A==null?void 0:A.maxHeight)??void 0,overflowY:(A==null?void 0:A.maxHeight)!=null?"auto":void 0,visibility:A?"visible":"hidden"},children:o(()=>c(!1))})]})}function rB({title:e,ariaLabel:t,active:n,style:r,cursor:o,onClick:a,onMouseDown:l,children:s}){const c=tt.useTheme(),u=Il(c);return i.jsx("button",{type:"button",title:e,"aria-label":t??e,"aria-pressed":n||void 0,onMouseDown:d=>{sr(d),l==null||l(d)},onClick:d=>{d.preventDefault(),a==null||a(d)},style:{...ma,...n?SP(c):null,...o?{cursor:o}:null,...r},onMouseEnter:d=>{n||(d.currentTarget.style.background=u)},onMouseLeave:d=>{n||(d.currentTarget.style.background="transparent")},children:s})}function mR(e,t=!0){return{supported:!1,listening:!1,interim:"",toggle:()=>{}}}const bR=e=>null;function a5e({editorEl:e,fullscreenEditorEl:t,registerEditor:n}){return i.jsxs("div",{"data-inline-editor-fullscreen":"true",style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"#ffffff",zIndex:1398,overflow:"auto",padding:"56px 0 0",boxSizing:"border-box"},children:[i.jsx("style",{dangerouslySetInnerHTML:{__html:'[data-inline-editor-fullscreen="true"] a{color:#2563eb;text-decoration:underline;cursor:pointer}'}}),i.jsx("div",{ref:n,contentEditable:!0,suppressContentEditableWarning:!0,onInput:()=>{!e||!t||(e.innerHTML=t.innerHTML,e.dispatchEvent(new Event("input",{bubbles:!0})))},style:{minHeight:"calc(100vh - 56px)",width:"100%",padding:"32px 48px 64px",boxSizing:"border-box",outline:"none",color:"#0f172a",fontSize:16,lineHeight:1.6,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'}})]})}const l5e='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';function s5e({editorEl:e,open:t}){var R;const[n,r]=y.useState(null),o=`${!!e}-${t}-${((R=e==null?void 0:e.dataset)==null?void 0:R.blockId)??""}`,{manualOffset:a,dragging:l,handleDragStart:s}=W3e(n,o),{fullscreen:c,setFullscreen:u,fullscreenEditorEl:d,setFullscreenEditorEl:A}=U3e({editorEl:e}),[p,h]=y.useState(!1),{textareaEl:f}=F3e({enabled:p,editorEl:e,fullscreen:c,fullscreenEditorEl:d,onRequestExit:()=>h(!1)}),b=c?d:e,w=K3e(p?f:e,t,n,a),v=H3e(t,b),B=V3e(b,t),S=bn(),E=O3e(b,t,B),[k,I]=y.useState(!1),[F,T]=y.useState(!1),[D,L]=y.useState(!1),[P,M]=y.useState({text:"",url:"",newWindow:!0,underline:!0}),[z,G]=y.useState(!1),V=y.useCallback(()=>{const H=B.getSavedSelectionLink();H?(M(H),G(!0)):(M({text:B.getSavedSelectionText(),url:"",newWindow:!0,underline:!0}),G(!1)),I(!0)},[B]);y.useEffect(()=>{if(!t||!b)return;const H=N=>{var K,X;const $=(X=(K=N.target)==null?void 0:K.closest)==null?void 0:X.call(K,"a");if(!$||!b.contains($))return;N.preventDefault(),N.stopPropagation();const ee=window.getSelection();if(ee){const Y=document.createRange();Y.selectNodeContents($),ee.removeAllRanges(),ee.addRange(Y),B.savedRangeRef.current=Y.cloneRange()}V()};return b.addEventListener("click",H),()=>b.removeEventListener("click",H)},[t,b,B,V]),y.useEffect(()=>{if(!t||!b)return;const H=N=>{if(N.key!=="Tab")return;const $=window.getSelection();if(!$||$.rangeCount===0)return;const ee=$.getRangeAt(0);if(!b.contains(ee.startContainer))return;let K=ee.startContainer,X=!1;for(;K&&K!==b;){if(K.nodeType===Node.ELEMENT_NODE&&K.tagName==="LI"){X=!0;break}K=K.parentNode}X&&(N.preventDefault(),N.stopPropagation(),N.stopImmediatePropagation(),N.shiftKey?B.runOutdent():B.runIndent())};return b.addEventListener("keydown",H,!0),()=>b.removeEventListener("keydown",H,!0)},[t,b,B]);const _=mR(y.useCallback(H=>B.handleSpeechResult(H),[B]),t),W=y.useMemo(()=>typeof document>"u"?null:document.body,[]);if(!t||!W)return null;const q=i.jsxs(i.Fragment,{children:[i.jsx(pn,{title:"Superscript",active:v.sup,onClick:()=>B.runCommand("superscript"),children:i.jsx(Wt,{name:"superscript"})}),i.jsx(pn,{title:"Subscript",active:v.sub,onClick:()=>B.runCommand("subscript"),children:i.jsx(Wt,{name:"subscript"})}),i.jsx(Cc,{ariaLabel:"Line spacing",icon:i.jsx(ct.FormatLineSpacing,{sx:{fontSize:16}}),children:H=>i.jsxs("div",{style:{...Rc,minWidth:140},children:[i.jsx(Zl,{selected:!v.lineHeight,onSelect:()=>{B.applyLineHeight(""),H()},children:"Default"}),whe.map(N=>i.jsx(Zl,{selected:v.lineHeight===N.value,onSelect:()=>{B.applyLineHeight(N.value),H()},children:N.label},N.value))]})}),i.jsx(Cc,{ariaLabel:"Insert table",icon:i.jsx(Wt,{name:"table"}),children:H=>B.isInTableCell()?i.jsxs("div",{style:Rc,children:[i.jsx(Qa,{onSelect:()=>{B.handleTableInsertRow("above"),H()},children:"Insert row above"}),i.jsx(Qa,{onSelect:()=>{B.handleTableInsertRow("below"),H()},children:"Insert row below"}),i.jsx(Qa,{onSelect:()=>{B.handleTableInsertColumn("left"),H()},children:"Insert column left"}),i.jsx(Qa,{onSelect:()=>{B.handleTableInsertColumn("right"),H()},children:"Insert column right"}),i.jsx(xo,{horizontal:!0}),i.jsx(Qa,{onSelect:()=>{B.handleTableDeleteRow(),H()},children:"Delete row"}),i.jsx(Qa,{onSelect:()=>{B.handleTableDeleteColumn(),H()},children:"Delete column"}),i.jsx(Qa,{onSelect:()=>{B.handleTableDelete(),H()},children:"Delete table"}),i.jsx(xo,{horizontal:!0}),i.jsx(Kc,{label:"Row background",icon:i.jsx(ct.FormatColorFill,{sx:{fontSize:18}}),title:"Row Background",noneLabel:"No background",noneValue:"transparent",solidOnly:!0,onPick:N=>B.handleTableRowBackground(N)})]}):i.jsx(n5e,{onPick:(N,$)=>{B.handleInsertTable(N,$),H()}})}),i.jsx(pn,{title:"Insert image",onClick:()=>T(!0),children:i.jsx(Wt,{name:"picture"})}),i.jsx(pn,{title:"Insert video",onClick:()=>L(!0),children:i.jsx(Wt,{name:"video"})}),i.jsx(pn,{title:"Horizontal rule",onClick:B.handleInsertHorizontalRule,children:i.jsx(Wt,{name:"minus"})}),_.supported,i.jsx(pn,{title:E.active?E.sticky?"Format painter (sticky) — click to cancel":"Format painter — click to cancel":"Format painter (double-click to keep on)",active:E.active,onClick:E.onClick,onDoubleClick:E.onDoubleClick,children:i.jsx(ct.FormatPaint,{sx:{fontSize:16}})}),i.jsx(pn,{title:"Clear formatting",onClick:()=>B.runCommand("removeFormat"),children:i.jsx(Wt,{name:"eraser"})}),i.jsx(pn,{title:p?"Exit code view":"Code view",active:p,onClick:()=>h(H=>!H),"data-codeview-keep":"true",children:i.jsx(Wt,{name:"code"})}),c?i.jsx(pn,{title:"Exit fullscreen",active:!0,onClick:()=>u(!1),"data-codeview-keep":"true",children:i.jsx(Wt,{name:"arrows-alt"})}):i.jsx(pn,{title:"Fullscreen",onClick:()=>u(!0),"data-codeview-keep":"true",children:i.jsx(Wt,{name:"arrows-alt"})})]}),Z=i.jsxs("div",{ref:r,"data-inline-text-toolbar":"true","data-codeview":p?"true":void 0,role:"toolbar","aria-label":"Text formatting",onMouseDown:sr,style:{position:"fixed",top:c?8:(w==null?void 0:w.top)??-9999,left:c?"50%":(w==null?void 0:w.left)??-9999,transform:c?"translateX(-50%)":void 0,visibility:F?"hidden":c||w?"visible":"hidden",pointerEvents:F?"none":"auto",zIndex:1400,display:"flex",alignItems:"center",gap:2,padding:"4px 6px",borderRadius:10,background:"linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(247,249,252,0.98) 100%)",color:"rgba(17,24,39,0.92)",boxShadow:"0 1px 0 rgba(255,255,255,0.9) inset, 0 18px 40px -12px rgba(15,23,42,0.18), 0 2px 8px rgba(15,23,42,0.06)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(18px) saturate(140%)",border:"1px solid rgba(15,23,42,0.08)",fontFamily:l5e,fontSize:13,userSelect:"none",animation:"inlineToolbarIn 140ms cubic-bezier(0.2, 0.8, 0.2, 1)"},children:[i.jsx("style",{children:`
1327
1327
  @keyframes inlineToolbarIn {
@@ -1490,4 +1490,4 @@ ${h}`),o.reset(h)}function Oje(e,t,n={}){return _je(e,t,n)}async function Nje(e,
1490
1490
  `);n-=s(n),r-=s(r),o-=s(o),e=tTe(e)}return{hasBOM:l,text:e,options:Ik(e,{...t,cursorOffset:n,rangeStart:r,rangeEnd:o,endOfLine:a})}}async function Tk(e,t){let n=await y6(t);return!n.hasPragma||n.hasPragma(e)}async function rFe(e,t){var n,r;return(r=(n=await y6(t)).hasIgnorePragma)==null?void 0:r.call(n,e)}async function zN(e,t){let{hasBOM:n,text:r,options:o}=UN(e,await Xu(t));if(o.rangeStart>=o.rangeEnd&&r!==""||o.requirePragma&&!await Tk(r,o)||o.checkIgnorePragma&&await rFe(r,o))return{formatted:e,cursorOffset:t.cursorOffset,comments:[]};let a;return o.rangeStart>0||o.rangeEnd<r.length?a=await nFe(r,o):(!o.requirePragma&&o.insertPragma&&o.printer.insertPragma&&!await Tk(r,o)&&(r=o.printer.insertPragma(r)),a=await HN(r,o)),n&&(a.formatted=$N+a.formatted,a.cursorOffset>=0&&a.cursorOffset++),a}async function oFe(e,t,n){let{text:r,options:o}=UN(e,await Xu(t)),a=await zp(r,o);return n&&(n.preprocessForPrint&&(a.ast=await _N(a.ast,o)),n.massage&&(a.ast=Gje(a.ast,o))),a}async function iFe(e,t){t=await Xu(t);let n=await C0(e,t);return m0(n,t)}async function aFe(e,t){let n=jTe(e),{formatted:r}=await zN(n,{...t,parser:"__js_expression"});return r}async function lFe(e,t){t=await Xu(t);let{ast:n}=await zp(e,t);return t.cursorOffset>=0&&(t={...t,...ON(n,t)}),C0(n,t)}async function sFe(e,t){return m0(e,await Xu(t))}var v6={};s6(v6,{builders:()=>cFe,printer:()=>uFe,utils:()=>dFe});var cFe={join:nN,line:rN,softline:ITe,hardline:la,literalline:iN,group:tN,conditionalGroup:BTe,fill:wTe,lineSuffix:O4,lineSuffixBoundary:TTe,cursor:ds,breakParent:g0,ifBreak:STe,trim:DTe,indent:Pg,indentIfBreak:kTe,align:Tu,addAlignmentToDoc:eN,markAsRoot:JO,dedentToRoot:yTe,dedent:vTe,hardlineWithoutBreakParent:h6,literallineWithoutBreakParent:oN,label:ETe,concat:e=>e},uFe={printDocToString:m0},dFe={willBreak:dTe,traverseDoc:A6,findInDoc:p6,mapDoc:f0,removeLines:hTe,stripTrailingHardline:XO,replaceEndOfLine:mTe,canBreak:xTe},QN="3.9.4",w6={};s6(w6,{addDanglingComment:()=>Xl,addLeadingComment:()=>vA,addTrailingComment:()=>wA,getAlignmentSize:()=>g6,getIndentSize:()=>mFe,getMaxContinuousCount:()=>CFe,getNextNonSpaceNonCommentCharacter:()=>vFe,getNextNonSpaceNonCommentCharacterIndex:()=>jFe,getPreferredQuote:()=>SFe,getStringWidth:()=>f6,hasNewline:()=>Al,hasNewlineInRange:()=>EFe,hasSpaces:()=>TFe,isNextLineEmpty:()=>RFe,isNextLineEmptyAfterIndex:()=>E6,isPreviousLineEmpty:()=>MFe,makeString:()=>PFe,skip:()=>Up,skipEverythingButNewLine:()=>pN,skipInlineComment:()=>B6,skipNewline:()=>$s,skipSpaces:()=>ml,skipToLineEnd:()=>AN,skipTrailingComment:()=>S6,skipWhitespace:()=>iDe});function AFe(e,t){if(t===!1)return!1;if(e.charAt(t)==="/"&&e.charAt(t+1)==="*"){for(let n=t+2;n<e.length;++n)if(e.charAt(n)==="*"&&e.charAt(n+1)==="/")return n+2}return t}var B6=AFe;function pFe(e,t){return t===!1?!1:e.charAt(t)==="/"&&e.charAt(t+1)==="/"?pN(e,t):t}var S6=pFe;function hFe(e,t){let n=null,r=t;for(;r!==n;)n=r,r=ml(e,r),r=B6(e,r),r=S6(e,r),r=$s(e,r);return r}var k6=hFe;function fFe(e,t){let n=null,r=t;for(;r!==n;)n=r,r=AN(e,r),r=B6(e,r),r=ml(e,r);return r=S6(e,r),r=$s(e,r),r!==!1&&Al(e,r)}var E6=fFe;function gFe(e,t){let n=e.lastIndexOf(`
1491
1491
  `);return n===-1?0:g6(e.slice(n+1).match(/^[\t ]*/)[0],t)}var mFe=gFe;function bFe(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function xFe(e,t){let n=e.matchAll(new RegExp(`(?:${bFe(t)})+`,"g"));return n.reduce||(n=[...n]),n.reduce((r,[o])=>Math.max(r,o.length),0)/t.length}var CFe=xFe;function yFe(e,t){let n=k6(e,t);return n===!1?"":e.charAt(n)}var vFe=yFe,VN=Object.freeze({character:"'",codePoint:39}),WN=Object.freeze({character:'"',codePoint:34}),wFe=Object.freeze({preferred:VN,alternate:WN}),BFe=Object.freeze({preferred:WN,alternate:VN});function SFe(e,t){let{preferred:n,alternate:r}=t===!0||t==="'"?wFe:BFe,{length:o}=e,a=0,l=0;for(let s=0;s<o;s++){let c=e.charCodeAt(s);c===n.codePoint?a++:c===r.codePoint&&l++}return(a>l?r:n).character}function kFe(e,t,n){for(let r=t;r<n;++r)if(e.charAt(r)===`
1492
1492
  `)return!0;return!1}var EFe=kFe;function IFe(e,t,n={}){return ml(e,n.backwards?t-1:t,n)!==t}var TFe=IFe;function DFe(e,t,n){return k6(e,n(t))}function jFe(e,t){return arguments.length===2||typeof t=="number"?k6(e,t):DFe(...arguments)}function FFe(e,t,n){return x6(e,n(t))}function MFe(e,t){return arguments.length===2||typeof t=="number"?x6(e,t):FFe(...arguments)}function LFe(e,t,n){return E6(e,n(t))}function PFe(e,t,n){let r=t==='"'?"'":'"',o=A0(0,e,/\\(.)|(["'])/gs,(a,l,s)=>l===r?l:s===t?"\\"+s:s||(n&&/^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/.test(l)?l:"\\"+l));return t+o+t}function RFe(e,t){return arguments.length===2||typeof t=="number"?E6(e,t):LFe(...arguments)}function as(e,t=1){return async(...n)=>{let r=n[t]??{},o=r.plugins??[];return n[t]={...r,plugins:Array.isArray(o)?o:Object.values(o)},await e(...n)}}var I6=as(zN);async function y0(e,t){let{formatted:n}=await I6(e,{...t,cursorOffset:-1});return n}async function GN(e,t){return await y0(e,t)===e}var KN=as(vN,0),qN={parse:as(oFe),formatAST:as(iFe),formatDoc:as(aFe),printToDoc:as(lFe),printDocToString:as(sFe)};const _Fe=Object.freeze(Object.defineProperty({__proto__:null,__debug:qN,check:GN,default:WO,doc:v6,format:y0,formatWithCursor:I6,getSupportInfo:KN,util:w6,version:QN},Symbol.toStringTag,{value:"Module"})),OFe={minHeight:"100vh",backgroundColor:"background.default"},NFe={height:70,borderBottom:"1px solid",borderColor:"divider",backgroundColor:"background.paper",position:"fixed",width:"100%",zIndex:1200,px:2,display:"flex",alignItems:"center"},$Fe={textTransform:"none",fontWeight:500,color:"text.primary",backgroundColor:"action.hover",border:"1px solid",borderColor:"divider",borderRadius:2,px:1.5,py:1,fontSize:16,boxShadow:"none","&:hover":{backgroundColor:"action.selected"}},HFe={pt:"72px"},Dk={maxWidth:960,mx:"auto",px:3,py:4},jk={display:"flex",alignItems:"center",justifyContent:"space-between",mb:2},UFe={display:"flex",alignItems:"center",gap:1},zFe={fontSize:"24px",fontWeight:600,color:"text.primary"},QFe={fontSize:18,color:"text.secondary"},VFe={textTransform:"none",fontWeight:500,borderRadius:2,px:2,py:.75,fontSize:14},WFe={backgroundColor:"background.paper",borderRadius:2,border:"1px solid",borderColor:"divider",overflowY:"auto",overflowX:"hidden",minHeight:"calc(100vh - 220px)","& pre[class*='language-']":{margin:0,borderRadius:2,fontSize:16,lineHeight:1.8,background:"transparent",padding:"20px 24px",whiteSpace:"pre-wrap",wordBreak:"break-word",overflowX:"hidden"},"& code[class*='language-']":{fontFamily:'"Fira Code", "Consolas", "Monaco", monospace',fontSize:16,background:"transparent",whiteSpace:"pre-wrap",wordBreak:"break-word",color:e=>e.palette.text.primary},"& code[class*='language-'], & pre[class*='language-']":{textShadow:"none"}},GFe={color:"#999",fontSize:14,p:3},KFe={width:"100%",minHeight:"calc(100vh - 220px)",borderRadius:2};function qFe({record:e,onBack:t}){const[n,r]=y.useState(!1),[o,a]=y.useState(""),[l,s]=y.useState(!0),[c,u]=y.useState(""),d=y.useRef(null),A=zr();y.useEffect(()=>{var f,b;let h="";if(A)try{h=Ro(A,{rootBlockId:"root",includePageCSS:!0})}catch{}h||(h=((b=(f=e==null?void 0:e.sections)==null?void 0:f[0])==null?void 0:b.content)||(e==null?void 0:e.content)||""),u(h)},[A,e]),y.useEffect(()=>{if(!c){a(""),s(!1);return}s(!0),y0(c,{parser:"html",plugins:[VO],printWidth:100,tabWidth:2}).then(h=>{a(h),s(!1)}).catch(()=>{a(c),s(!1)})},[c]),y.useEffect(()=>{!l&&o&&d.current&&(d.current.textContent=o,y4.highlightElement(d.current))},[l,o]);const p=()=>{c&&navigator.clipboard.writeText(o||c).then(()=>{r(!0),setTimeout(()=>r(!1),2e3)})};return i.jsxs(m.Box,{sx:OFe,children:[i.jsx(m.Box,{sx:NFe,children:i.jsx(m.Button,{variant:"outlined",startIcon:i.jsx(_g,{fontSize:"small"}),onClick:t,sx:$Fe,children:"Back"})}),i.jsx(m.Box,{sx:HFe,children:l?i.jsxs(m.Box,{sx:Dk,children:[i.jsxs(m.Box,{sx:jk,children:[i.jsx(m.Skeleton,{variant:"text",width:160,height:36}),i.jsx(m.Skeleton,{variant:"rounded",width:100,height:36})]}),i.jsx(m.Skeleton,{variant:"rounded",sx:KFe})]}):i.jsxs(m.Box,{sx:Dk,children:[i.jsxs(m.Box,{sx:jk,children:[i.jsxs(m.Box,{sx:UFe,children:[i.jsx(m.Typography,{sx:zFe,children:"Page Code"}),i.jsx(W4,{sx:QFe})]}),i.jsx(m.Tooltip,{title:n?"Copied!":"Copy",children:i.jsx("span",{children:i.jsx(m.Button,{variant:"outlined",startIcon:i.jsx(np,{fontSize:"small"}),onClick:p,disabled:!c,sx:VFe,children:n?"Copied!":"Copy"})})})]}),i.jsx(m.Box,{sx:WFe,children:c?i.jsx("pre",{className:"language-html",children:i.jsx("code",{ref:d,className:"language-html"})}):i.jsx(m.Typography,{sx:GFe,children:"No code available for this page yet."})})]})})]})}const YFe=/<!--\s*ahd-integration-start\s*-->[\s\S]*?<!--\s*ahd-integration-end\s*-->/gi,Ub=e=>(e||"").replace(YFe,""),ZFe=e=>{if(!e)return"";const t=e.match(/<!--\s*ahd-integration-start\s*-->[\s\S]*?<!--\s*ahd-integration-end\s*-->/i);return t?t[0]:""};function Fk(e){var n;const t=e==null?void 0:e.trim();if(!t)return"";if(typeof DOMParser>"u")return t;try{return((n=new DOMParser().parseFromString(t,"text/html").body)==null?void 0:n.innerHTML)??t}catch{return t}}function YN(e){return((e==null?void 0:e.type)??"page")==="page"}function XFe(e){const t=Date.now();return e.map((n,r)=>({...n,sectionType:(n==null?void 0:n.sectionType)||"internal",identifier:(n==null?void 0:n.identifier)||`section-${t+r}`}))}function JFe({record:e,sections:t,activeSectionIndex:n,liveDocument:r,...o}){var I,F;const a=YN(e),l=Pu(r??{}),s=Tx(l),c=aG(l,s),u=Fv(l,s),d=((I=u==null?void 0:u.root)==null?void 0:I.data)??{},A={rootBlockId:"root",rootOverrides:{lang:d.lang||(e==null?void 0:e.lang)||void 0,skipLink:d.skipLink||void 0,accessibilityTools:d.accessibilityTools||void 0},headHtml:a||e==null?void 0:e.head,bodyBottomHtml:e==null?void 0:e.bodyBottom,injectTabsScrollSyncScript:o.injectTabsScrollSyncScript,injectCarouselScript:o.injectCarouselScript,injectPaginationScript:o.injectPaginationScript,injectAnimationScript:o.injectAnimationScript,injectPostMessageScript:a,injectFontAssets:!0,seo:a?void 0:{title:(e==null?void 0:e.title)||(e==null?void 0:e.name),metaTitle:e==null?void 0:e.metaTitle,metaDescription:e==null?void 0:e.metaDescription,metaKeywords:e==null?void 0:e.metaKeywords,metaImageUrl:e==null?void 0:e.metaImageUrl,slug:e==null?void 0:e.slug}},p=T=>{const D=k4(T,A);return Ub(a?Fk(D):D)},h=k4(u,A),f=Ub(a?Fk(h):h),b=Array.isArray(t)?t:[],C=ZFe(((F=b.find(T=>!su(T)))==null?void 0:F.content)||""),w=a&&b.length===0?[{title:(e==null?void 0:e.name)||"Section 1",sectionType:"internal"}]:b,B=Xb(XFe(w),n,c).map((T,D)=>{var M;if(su(T))return{...T,content:zy(T)};const L=D===n?c:(M=T.contentMetadata)==null?void 0:M.document,P=D===n?f:L?p(Fv(L,Tx(L))):Ub(T.content||"");return{...T,content:P,...L?{contentMetadata:{...T.contentMetadata||{},document:L}}:{}}}),S=B.findIndex(T=>!su(T)),E=C&&S!==-1?B.map((T,D)=>{if(D!==S)return T;const L=T.content||"",P=L.includes("</body>")?L.replace("</body>",`${C}</body>`):`${L}${C}`;return{...T,content:P}}):B,k=b.length===0?h:$_(E.map(T=>T.content||"").filter(Boolean).join(`
1493
- `),E);return{document:c,renderSource:u,activeHtml:h,sections:E,html:k}}const eMe=["metaTitle","metaDescription","metaImageUrl","metaKeywords","tags","author","head","bodyBottom","schemaMarkup"],tMe=(e,t)=>e==="author"?(t==null?void 0:t.id)??t??null:e==="schemaMarkup"?Array.isArray(t)?t.map(n=>n&&typeof n=="object"?n.id:n).filter(n=>n!=null).sort():[]:t??null;function ZN(e){try{return JSON.stringify(eMe.map(t=>tMe(t,e==null?void 0:e[t])))}catch{return""}}function XN(e,t){var n,r,o;return JSON.stringify([(e==null?void 0:e.title)||((n=e==null?void 0:e.metadata)==null?void 0:n.title)||`Section ${t+1}`,(e==null?void 0:e.identifier)||((r=e==null?void 0:e.metadata)==null?void 0:r.identifier)||"",(e==null?void 0:e.sectionType)||((o=e==null?void 0:e.metadata)==null?void 0:o.sectionType)||"internal"])}function JN(e){if(!e)return"";try{return mp({document:e,pageType:Ge.Page})}catch{return""}}function zb(e,t){return{fields:ZN(e),sections:(t??[]).map((n,r)=>{var o;return{meta:XN(n,r),snapshot:JN((o=n==null?void 0:n.contentMetadata)==null?void 0:o.document)}})}}function nMe(e,t,n){var o,a;if(!e)return!1;const r=n??[];if(r.length!==e.sections.length)return!0;for(let l=0;l<r.length;l++){const s=e.sections[l];if(XN(r[l],l)!==s.meta||JN((a=(o=r[l])==null?void 0:o.contentMetadata)==null?void 0:a.document)!==s.snapshot)return!0}return ZN(t)!==e.fields}const rMe={back:!0,title:!0,status:!0,sectionsDropdown:!0,undo:!0,redo:!0,unselect:!0,save:!0,autoSave:!1,screenSize:!0,themeToggle:!0,fullscreen:!0,preview:!0,moreMenu:!1,publish:!1};function oMe(e){return{...rMe,...e??{}}}const iMe=["desktop","tablet","mobile"],Or=e=>Array.isArray(e==null?void 0:e.sections)?e.sections:[],Ai=(e,t)=>t>0?Math.min(Math.max(e,0),t-1):0;function aMe(e){if(!e||typeof e!="object")return null;const t=n=>n&&typeof n=="object"&&!Array.isArray(n)&&(Array.isArray(n.sections)||n.id!=null||n._id!=null);return t(e)?e:t(e.data)?e.data:null}function lMe(e,t,n){const r=aMe(t);if(!r)return e;const{sections:o,...a}=r,l={...e,...a,id:e.id??a.id??a._id};if(n)return{...l,contentMetadata:e.contentMetadata};const s=Or(e);return Array.isArray(o)&&o.length===s.length?l.sections=s.map((c,u)=>{var d,A,p,h;return{...c,...o[u],contentMetadata:{...(c==null?void 0:c.contentMetadata)??{},...((d=o[u])==null?void 0:d.contentMetadata)??{},document:((p=(A=o[u])==null?void 0:A.contentMetadata)==null?void 0:p.document)??((h=c==null?void 0:c.contentMetadata)==null?void 0:h.document)}}}):l.sections=s,l}function sMe({record:e,contentMetadata:t,behaviour:n,steps:r,sections:o,activeStepIndex:a=0,panels:l,title:s="Back",recordTitle:c,recordStatus:u,headerExtra:d,children:A,onUpdateRecord:p,onChange:h,onSaveChanges:f,onPublish:b,onPublishMenu:C,renderPublish:w,onBack:v,onTogglePreview:B,onBackgroundChange:S,onNavigateBranding:E,onAddSection:k,onOpenPageCode:I,onApiError:F,topbar:T,mode:D,onToggleMode:L,autoSaveEnabled:P,onAutoSaveChange:M,autoSaveIntervalMs:z}){const G=y.useMemo(()=>oMe(T),[T]),V=y.useMemo(()=>({id:"doc-1",type:"page",...e,contentMetadata:t??(e==null?void 0:e.contentMetadata),behaviour:n??(e==null?void 0:e.behaviour),steps:r??(e==null?void 0:e.steps),sections:o??(e==null?void 0:e.sections)}),[e,t,n,r,o]),_=y.useRef(V),W=y.useRef(V);W.current!==V&&(W.current=V,_.current=V);const q=y.useCallback(Re=>{_.current=Re,p==null||p(Re)},[p]),Z=Us(),{currentTenant:R}=Ip(),H=(R==null?void 0:R.id)??(Z==null?void 0:Z.tenantId)??null,N=fp()??0,$=y.useMemo(()=>Or(V),[V.sections]),ee=Ai(N,$.length),K=$[ee],X=Ka(K),Y=YN(V);y.useEffect(()=>{CT(X)},[X]);const ue=y.useRef([]),ce=()=>{ue.current.forEach(Re=>window.clearTimeout(Re)),ue.current=[]},re=y.useCallback(()=>{ce(),Gl(),queueMicrotask(()=>Gl()),ue.current.push(window.setTimeout(()=>Gl(),0),window.setTimeout(()=>Gl(),400))},[]);y.useEffect(()=>()=>ce(),[]);const[pe,Q]=y.useState(null),U=y.useRef(!1),O=y.useRef(!1);y.useEffect(()=>{var kt,yn,cn,Jt,fr,Qr;if(U.current)return;const Re=Or(V),dt=Ai(a,Re.length);let vt=Re.length>0?(yn=(kt=Re[dt])==null?void 0:kt.contentMetadata)==null?void 0:yn.document:((cn=V.contentMetadata)==null?void 0:cn.document)??((Qr=(fr=(Jt=V.steps)==null?void 0:Jt[a])==null?void 0:fr.contentMetadata)==null?void 0:Qr.document);if(!vt&&Re.length>0&&(vt=jc("")),!vt){O.current||(O.current=!0,Q(zb(V,Re)),re());return}const Et=aa(vt);PT(),Wl(dt,{skipHistory:!0}),wn(Et,{skipHistory:!0}),U.current=!0,Q(zb(V,Re)),re()},[V]);const ie=zr();y.useEffect(()=>{if(!U.current||ie!==Ee.getState().document)return;h==null||h(ie);const Re=_.current;q({...Re,contentMetadata:{...Re.contentMetadata??{},document:ie}})},[ie]);const ae=ET(),ne=y.useRef(null),te=iMe.includes(V.device)?V.device:"desktop";y.useEffect(()=>{const Re=String(V.id??"");if(ne.current!==Re){ne.current=Re,IT(),jx(te),Ss(te);return}ae||(jx(te),Ss(te))},[V.id,te]);const{inspectorWidth:fe,handleMouseDown:Ae,isPanelCollapsed:xe,toggleCollapsed:le,handleOpenPanel:se}=T7e(),he=Ee(Re=>{var dt;return((dt=Re==null?void 0:Re.undoStack)==null?void 0:dt.length)??0}),ge=y.useMemo(()=>nMe(pe,V,$),[pe,V,$]),be=pe!==null&&(he>0||ge),[Te,Le]=y.useState(!1),[Me,Fe]=y.useState(!1),Ve=Ct.useRef(!1),Oe=Ct.useRef(null);Ct.useEffect(()=>()=>{Oe.current&&clearTimeout(Oe.current)},[]),Ct.useEffect(()=>{be&&Me&&(Oe.current&&clearTimeout(Oe.current),Fe(!1))},[be]);const at=y.useCallback(()=>{Fe(!0),Oe.current&&clearTimeout(Oe.current),Oe.current=setTimeout(()=>Fe(!1),5e3)},[]);y.useEffect(()=>{if(!be||Me)return;const Re=dt=>(dt.preventDefault(),dt.returnValue="","");return window.addEventListener("beforeunload",Re),()=>window.removeEventListener("beforeunload",Re)},[be,Me]),y.useEffect(()=>{const Re=vt=>{if(!(vt instanceof HTMLElement))return!1;const Et=vt.tagName;return Et==="INPUT"||Et==="TEXTAREA"||Et==="SELECT"?!0:vt.isContentEditable?!vt.closest('[data-inline-edit-target="true"]'):!1},dt=vt=>{var Jt,fr,Qr;if(!(vt.ctrlKey||vt.metaKey))return;const Et=vt.key.toLowerCase(),kt=Et==="z"&&!vt.shiftKey,yn=Et==="y"||Et==="z"&&vt.shiftKey,cn=Et==="b";if(!(!kt&&!yn&&!cn)&&!Re(vt.target)){if(cn){const Pr=Ee.getState(),fo=Pr.selectedBlockId;if(!fo)return;const Ko=Pr.document[fo];if(!Ko||Ko.type!=="Heading")return;const ro=x5((fr=(Jt=Ko.data)==null?void 0:Jt.style)==null?void 0:fr.fontWeight)===jr.BOLD?jr.REGULAR:jr.BOLD;vt.preventDefault(),pt({[fo]:{...Ko,data:{...Ko.data,style:{...((Qr=Ko.data)==null?void 0:Qr.style)??{},fontWeight:ro}}}});return}vt.preventDefault(),kt?M3():L3()}};return window.addEventListener("keydown",dt),()=>window.removeEventListener("keydown",dt)},[]);const ke=y.useCallback(Re=>{const dt={..._.current,sections:Re};q(dt);const vt=dt!=null&&dt.id?`page_${dt.id}`:null;if(vt)try{Id(vt,JSON.stringify(dt))}catch{}return dt},[q]),Ke=y.useCallback(()=>{var kt;const Re=_.current,dt=Or(Re);if(dt.length===0)return Re;const vt=Ee.getState();if((((kt=vt.undoStack)==null?void 0:kt.length)??0)===0)return Re;const Et=Ai(vt.activeStepIndex??0,dt.length);return ke(Xb(dt,Et,vt.document))},[ke]),_e=y.useCallback((Re={},dt,vt)=>{const Et=_.current,kt=Or(Et),yn=Ee.getState(),cn=Ai(yn.activeStepIndex??0,kt.length),Jt=JFe({record:Et,sections:kt,activeSectionIndex:cn,liveDocument:yn.document,...Re}),fr={sections:Jt.sections,...dt!==void 0?{status:dt}:{},...vt?{schedule:vt}:{}};if(kt.length===0)return{renderSource:Jt.renderSource,payload:{record:{...Et,contentMetadata:{...Et.contentMetadata??{},document:Jt.document,html:Jt.html}},document:Jt.document,html:Jt.html,...fr}};const{contentMetadata:Qr,behaviour:Pr,steps:fo,...Ko}=Et,nd=Pr&&typeof Pr=="object"&&Object.keys(Pr).length>0,ro=Array.isArray(fo)&&fo.length>0;return{renderSource:Jt.renderSource,payload:{record:{...Ko,...nd?{behaviour:Pr}:{},...ro?{steps:fo}:{},sections:Jt.sections},html:Jt.html,...fr}}},[]),Ue=y.useCallback((Re,dt,vt,Et)=>{const{contentMetadata:kt,html:yn,...cn}=Re.record,Jt={...cn,pageId:cn.id,status:dt,sections:Re.sections};return vt&&(Jt.startDate=vt.startDate??null,Jt.endDate=vt.endDate??null),Et!==void 0&&(Jt.ttlMinutes=Et),Jt},[]),[Ze,$e]=y.useState(null),Pe=y.useCallback(async(Re,dt,vt={})=>{var P6;Mt();const{schedule:Et,ttlMinutes:kt,...yn}=vt,{payload:cn,renderSource:Jt}=_e(yn,dt,Et),fr=Re==="publish"?"publish":"save",Qr=Or(_.current).length===0;let Pr,fo=!1;const Ko=(P6=cn.record)==null?void 0:P6.id;if(Z&&Ko&&Ko!=="doc-1")try{await j7e(Jt),Pr=await Z.upsertPage(Ue(cn,dt,Et,kt)),fo=!0}catch(Yp){const R6=Yp instanceof Error?Yp:new Error(String(Yp));return console.error(`[PagePilotEditor] apiClient.upsertPage failed (${fr}):`,R6),F==null||F(R6,fr),!1}else if(!Z&&Re!=="publish"&&!f)return!1;const nd=Pr!==void 0?{...cn,response:Pr}:cn;if(Re==="publish")await(b==null?void 0:b(nd));else if(f&&await f(nd)===!1)return!1;let ro=lMe(cn.record,Pr,Qr);return dt&&(ro={...ro,status:dt}),Et&&(ro={...ro,startDate:Et.startDate??null,endDate:Et.endDate??null}),kt!==void 0&&(ro={...ro,ttlMinutes:kt}),q(ro),Q(zb(ro,Or(ro))),Gl(),at(),Re==="publish"&&fo&&H&&$e(String(ro.slug??"")),!0},[Z,_e,Ue,q,F,b,f,at,H]),De=y.useCallback(async()=>{if(Ve.current)return!1;Ve.current=!0,Le(!0);try{return await Pe("save",_.current.status??null)}finally{Le(!1),Ve.current=!1}},[Pe]),[Xe,rt]=y.useState(!1),nt=y.useCallback(()=>{if(v){if(be){rt(!0);return}v()}},[v,be]),Ce=y.useCallback(()=>{rt(!1),v==null||v()},[v]),Be=y.useCallback(async()=>{await De()&&(rt(!1),v==null||v())},[De,v]),qe="pagepilot.editor.autoSave.v1",lt=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(qe)==="1"}catch{return!1}},[me,ye]=y.useState(()=>lt()),We=P!==void 0?P:me,Je=y.useCallback(Re=>{if(P===void 0&&(ye(Re),typeof window<"u"))try{window.localStorage.setItem(qe,Re?"1":"0")}catch{}M==null||M(Re)},[P,M]),[ut,Ie]=y.useState(!1),[ht,Tn]=y.useState(null);E7e({isDirty:be,onSave:De,isSaving:Te,enabled:We&&!ut,intervalMs:z??6e4});const er=y.useCallback(()=>{if(B){const{payload:kt}=_e();B(kt.html,kt.document);return}Mt();const Re=Ke(),dt=Ee.getState().document,vt=Or(Re),Et=Ai(Ee.getState().activeStepIndex??0,vt.length);Tn(vt.length>0?{...Re,sections:Xb(vt,Et,dt)}:{...Re,contentMetadata:{...Re.contentMetadata??{},document:dt}}),Ie(!0)},[_e,B,Ke]),[qt,hn]=y.useState(!1),[Ft,jt]=y.useState(null),Sn=y.useCallback(async()=>{if(jt(null),Z){hn(!0);return}if(!b)return;const{payload:Re}=_e({},S1.LIVE);await b(Re)},[Z,b,_e]),Lr=y.useCallback(async(Re,dt)=>{if(Ve.current)return!1;Ve.current=!0,Le(!0);try{return Re==="publish"?await Pe("publish",S1.LIVE,dt):await Pe("draft",S1.DRAFT,dt)}finally{Le(!1),Ve.current=!1}},[Pe]),Go=y.useCallback(async()=>{jt(null),await Lr("save")},[Lr]),tc=y.useCallback(Re=>{if(C){C(Re.currentTarget,_e().payload);return}jt(Re.currentTarget)},[C,_e]),_i=V.slug||"",Ju=V.status===S1.LIVE,nc=y.useMemo(()=>!_i||!H?null:O_(R??H,_i,V.updatedAt||new Date),[_i,H,R,V.updatedAt]),Qp=y.useMemo(()=>_i?N_(R,_i):null,[R,_i]),Vp=y.useMemo(()=>w?w({payload:_e().payload,onPublish:()=>void Sn()}):null,[w,Sn,ie]),Wp=y.useRef(null),[rc,Gp]=y.useState(!1),[Kp,Qe]=y.useState(!1);y.useEffect(()=>{const Re=()=>{Gp(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",Re),()=>document.removeEventListener("fullscreenchange",Re)},[]);const Bt=y.useCallback(()=>{var dt,vt;const Re=document.documentElement;Re&&(document.fullscreenElement?(vt=document.exitFullscreen)==null||vt.call(document):(dt=Re.requestFullscreen)==null||dt.call(Re))},[]),[Dn,tr]=y.useState(null),qp=T3(),[no,Da]=y.useState(null),ed=y.useCallback(()=>{if(k){k();return}Da({mode:"add"})},[k]),Fl=y.useCallback(Re=>{var Et;if(!Re||Ka(Re))return;const dt=((Et=Re.contentMetadata)==null?void 0:Et.document)??jc(""),vt=aa(dt);kT(vt),re()},[re]),td=y.useCallback((Re,dt,vt,Et,kt,yn,cn)=>({undo:()=>{kt&&(yn===null?Rz(kt):Id(kt,yn)),q(Re),Wl(dt,{skipHistory:!0})},redo:()=>{kt&&cn!==null&&Id(kt,cn),q(vt),Wl(Et,{skipHistory:!0})}}),[q]),Ml=y.useCallback((Re,dt,vt)=>{var fo;const Et=Ai(Ee.getState().activeStepIndex??0,Or(Re).length),kt=Re!=null&&Re.id?`page_${Re.id}`:null;let yn=null;try{yn=kt?Zc(kt):null}catch{yn=null}const cn={...Re,sections:dt},Jt=kt?JSON.stringify(cn):null;if(q(cn),kt&&Jt!==null)try{Id(kt,Jt)}catch{}const fr=td(Re,Et,cn,vt,kt,yn,Jt),Qr=dt[vt],Pr=Ka(Qr)?Ee.getState().document:aa(((fo=Qr==null?void 0:Qr.contentMetadata)==null?void 0:fo.document)??jc(""));wn(Pr,{sideEffect:fr}),Wl(vt,{skipHistory:!0})},[td,q]),L6=y.useCallback((Re,dt)=>{var fr;Mt();const vt=Or(Ke()),Et=vt[Re];if(!Et)return;const kt=dt.sectionType==="internal"&&Ka(Et),yn=dt.sectionType==="internal"&&!((fr=Et.contentMetadata)!=null&&fr.document),cn={...Et,title:dt.title,sectionType:dt.sectionType,...yn?{contentMetadata:{...Et.contentMetadata??{},document:jc("")}}:{}};ke(vt.map((Qr,Pr)=>Pr===Re?cn:Qr)),Da(null);const Jt=Ai(Ee.getState().activeStepIndex??0,vt.length);kt&&Re===Jt&&Fl(cn)},[ke,Fl,Ke]),c$=y.useCallback(Re=>{if((no==null?void 0:no.mode)==="edit"){L6(no.index,Re);return}Mt();const dt=Ke(),vt=Or(dt),Et=az(Re,jc("")),kt=[...vt,Et];Da(null),Ml(dt,kt,kt.length-1)},[no,L6,Ke,Ml]),u$=y.useCallback(Re=>{const dt=Or(_.current);if(Re<0||Re>=dt.length)return;const vt=Ai(Ee.getState().activeStepIndex??0,dt.length);if(Re===vt)return;Mt();const Et=Ke(),kt=Or(Et)[Re];Wl(Re,{skipHistory:!0}),Ka(kt)?re():Fl(kt)},[Ke,Fl,re]),d$=y.useCallback(Re=>{const dt=Or(_.current);if(Re===0||dt.length<=1||Re>=dt.length)return;Mt();const vt=Ke(),Et=Or(vt),kt=Ai(Ee.getState().activeStepIndex??0,Et.length),yn=Et.filter((Jt,fr)=>fr!==Re),cn=kt>=yn.length?yn.length-1:kt>Re?kt-1:kt;Ml(vt,yn,cn)},[Ke,Ml]),A$=y.useCallback(Re=>{Da({mode:"edit",index:Re})},[]),p$=y.useCallback((Re,dt)=>{if(Re===dt)return;Mt();const vt=Ke(),Et=Or(vt);if(Re<0||dt<0||Re>=Et.length||dt>=Et.length)return;const kt=Ai(Ee.getState().activeStepIndex??0,Et.length),yn=Et.slice(),[cn]=yn.splice(Re,1);yn.splice(dt,0,cn);let Jt=kt;kt===Re?Jt=dt:Re<kt&&dt>=kt?Jt=kt-1:Re>kt&&dt<=kt&&(Jt=kt+1),ke(yn),Jt!==kt&&Wl(Jt,{skipHistory:!0}),Gl()},[Ke,ke]),h$=y.useMemo(()=>{if((no==null?void 0:no.mode)!=="edit")return;const Re=$[no.index];if(Re)return{title:Re.title??"",sectionType:Re.sectionType??"internal"}},[no,$]),f$=!!(Z||f);return i.jsxs(m.Box,{ref:Wp,sx:{display:"flex",flexDirection:"column",height:"100%",width:"100%",overflow:"hidden",bgcolor:"background.default"},children:[i.jsx(_7e,{toggles:G,title:s,recordTitle:c??(V==null?void 0:V.title)??(V==null?void 0:V.name),recordStatus:u??(V==null?void 0:V.status),onBack:nt,onSave:De,onPublish:Sn,onPublishMenu:tc,publishSlot:Vp,onPreview:er,onToggleFullscreen:Bt,isFullscreen:rc,mode:D,onToggleMode:L,isDirty:be,isSaving:Te,changesSaved:Me,autoSaveEnabled:We,onAutoSaveChange:Je,isPageRecord:Y,onOpenMoreMenu:G.moreMenu?Re=>tr(Re.currentTarget):void 0,sectionsDropdown:G.sectionsDropdown&&$.length>1?i.jsx(iz,{sections:$,activeSectionIndex:ee,onSelectSection:u$,onDeleteSection:d$,onEditSection:A$,onReorderSections:p$}):null}),d,i.jsxs(m.Box,{sx:{display:"flex",flex:1,minHeight:0},children:[i.jsx(V8e,{record:V,activeStepIndex:N,onTogglePreview:er,onBackgroundChange:S??(()=>{}),onUpdateRecord:q,onSaveChanges:De,isExternalSection:X,onNavigateBranding:E,panels:l,inspectorWidth:fe,handleMouseDown:Ae,isPanelCollapsed:xe,handleOpenPanel:se,toggleCollapsed:le}),i.jsx(m.Box,{sx:{flex:1,minWidth:0,overflow:"auto"},children:i.jsx(w7e,{record:V,isPreviewOpen:ut,activeStepIndex:N,fetchTooltip:()=>{},loading:!1,activeSection:K,activeSectionIndex:ee,onAddSection:ed})})]}),A,i.jsx(aBe,{open:ut,onClose:()=>Ie(!1),record:ht,liveUrl:Ju?nc:null,domainPreviewUrl:Qp}),Kp&&i.jsx(m.Box,{sx:{position:"fixed",inset:0,zIndex:1300,bgcolor:"background.default",overflow:"auto"},children:i.jsx(qFe,{record:V,onBack:()=>Qe(!1)})}),Z&&i.jsx(Q7e,{open:qt,onClose:()=>hn(!1),record:V,apiClient:Z,onSubmit:(Re,dt)=>Lr(Re,dt)}),Ze!==null&&H&&i.jsx(J7e,{open:!0,onClose:()=>$e(null),tenantId:H,tenant:R,slug:Ze}),!C&&i.jsxs(m.Menu,{anchorEl:Ft,open:!!Ft,onClose:()=>jt(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{mt:1,minWidth:180,bgcolor:"background.paper",backgroundImage:"none",border:1,borderColor:"divider",borderRadius:1,boxShadow:"0px 10px 20px rgba(33, 36, 67, 0.08), 0px 2px 6px rgba(33, 36, 67, 0.04)"}}},children:[i.jsxs(m.MenuItem,{onClick:()=>void Sn(),disabled:Te,children:[i.jsx(m.ListItemIcon,{children:i.jsx(V4,{sx:{fontSize:20}})}),i.jsx(m.ListItemText,{children:"Publish"})]}),Ju&&Y&&nc&&i.jsxs(m.MenuItem,{onClick:()=>{jt(null),window.open(nc,"_blank","noopener,noreferrer")},children:[i.jsx(m.ListItemIcon,{children:i.jsx(Qk,{sx:{fontSize:20}})}),i.jsx(m.ListItemText,{children:"Live URL"})]}),f$&&i.jsxs(m.MenuItem,{onClick:()=>void Go(),disabled:Te,children:[i.jsx(m.ListItemIcon,{children:Te?i.jsx(m.CircularProgress,{size:20}):i.jsx(Vk,{sx:{fontSize:20}})}),i.jsx(m.ListItemText,{children:"Save as Draft"})]})]}),G.moreMenu&&i.jsx(m.Menu,{anchorEl:Dn,open:!!Dn,onClose:()=>tr(null),anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},slotProps:{paper:{sx:{mt:1,p:.5,bgcolor:"background.paper",backgroundImage:"none",border:1,borderColor:"divider",borderRadius:1,boxShadow:"0 0 6px rgba(0,0,0,.06), 2px 2px 8px rgba(0,0,0,.06)"}},list:{disablePadding:!0}},children:[{key:"addSection",show:!0,label:"Add Section",icon:i.jsx(w$,{sx:{fontSize:20}}),onClick:ed},{key:"pageCode",show:!0,label:"Page Code",icon:i.jsx(S$,{sx:{fontSize:20}}),onClick:I??(()=>Qe(!0))},{key:"minimap",show:!0,label:qp?"Hide Minimap":"Show Minimap",icon:i.jsx(B$,{sx:{fontSize:20}}),onClick:dT},{key:"fullscreen",show:!0,label:rc?"Exit Fullscreen":"Fullscreen Editor",icon:rc?i.jsx(Hk,{sx:{fontSize:20}}):i.jsx($k,{sx:{fontSize:20}}),onClick:Bt},{key:"autoSave",show:G.autoSave,label:"Auto Save",icon:i.jsx(k$,{sx:{fontSize:20}}),keepOpen:!0,onClick:()=>Je(!We),trailing:i.jsx(m.Switch,{size:"small",checked:!!We,onChange:Re=>Je(Re.target.checked),onClick:Re=>Re.stopPropagation()})},{key:"themeMode",show:!!L,divider:!0,label:D==="dark"?"Light Mode":"Dark Mode",icon:D==="dark"?i.jsx(Uk,{sx:{fontSize:20}}):i.jsx(zk,{sx:{fontSize:20}}),onClick:L}].filter(Re=>Re.show).map(Re=>[Re.divider?i.jsx(m.Divider,{sx:{my:.5}},`${Re.key}-divider`):null,i.jsxs(m.MenuItem,{onClick:()=>{var dt;Re.keepOpen||tr(null),(dt=Re.onClick)==null||dt.call(Re)},sx:{gap:1.75,px:1.5,py:1,borderRadius:1},children:[i.jsx(m.ListItemIcon,{sx:{minWidth:"0 !important",color:"text.secondary"},children:Re.icon}),i.jsx(m.ListItemText,{primary:Re.label,primaryTypographyProps:{fontSize:14,fontWeight:500},sx:{m:0,flex:1,minWidth:0}}),Re.trailing&&i.jsx(m.Box,{sx:{ml:1.5,display:"inline-flex",alignItems:"center"},children:Re.trailing})]},Re.key)])}),i.jsx(ez,{open:!!no,onClose:()=>Da(null),onAdd:c$,initialValues:h$}),i.jsxs(m.Dialog,{open:Xe,onClose:()=>{Te||rt(!1)},maxWidth:"xs",PaperProps:{sx:{gap:"8px","&&":{borderRadius:"14px"},padding:"28px 0px",width:428,backgroundColor:"background.paper",backgroundImage:"none"}},children:[i.jsx(m.IconButton,{onClick:()=>{Te||rt(!1)},disableRipple:!0,sx:{position:"absolute",top:8,right:8,justifyContent:"flex-end"},children:i.jsx(Ti,{})}),i.jsx(m.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"8px",width:50,height:50,margin:"0 auto 8px auto"},children:i.jsx(Q4,{sx:{color:"#F79009"}})}),i.jsxs(m.DialogContent,{sx:{textAlign:"center",margin:"0 45px",padding:"10px 20px !important",backgroundColor:"inherit"},children:[i.jsx(m.Typography,{sx:{fontSize:18,fontWeight:600,color:"text.primary"},children:"Unsaved changes"}),i.jsx(m.Typography,{sx:{marginTop:"0.5rem",fontWeight:400,fontSize:"14px",lineHeight:"20px",letterSpacing:"0%",whiteSpace:"pre-line",color:"text.secondary"},children:"You have unsaved changes. Do you want to save them before leaving?"})]}),i.jsxs(m.DialogActions,{sx:{justifyContent:"center",gap:1,paddingBottom:0,paddingTop:0,borderTop:"none",marginTop:0,paddingInline:4,backgroundColor:"inherit"},children:[i.jsx(m.Button,{onClick:Ce,variant:"outlined",fullWidth:!0,disableRipple:!0,disabled:Te,sx:{height:"40px",borderRadius:"8px",textTransform:"none",lineHeight:"normal",fontWeight:600,fontSize:"16px",border:Re=>`1px solid ${Re.palette.divider}`,color:"text.primary",backgroundColor:"background.paper"},children:"Discard"}),i.jsx(m.Button,{onClick:Be,variant:"contained",fullWidth:!0,disableRipple:!0,disabled:Te,startIcon:Te?i.jsx(m.CircularProgress,{size:16,color:"inherit"}):null,sx:{height:"40px",borderRadius:"8px",textTransform:"none",lineHeight:"normal",fontWeight:600,fontSize:"16px",backgroundColor:"#F79009",color:"#FFFFFF","&:hover":{backgroundColor:"#F79009"}},children:"Save"})]})]})]})}const cMe={performanceHeader:{main:"#e6e7eb"},moduleIcon:{main:"#e6e7eb"},moduleListComponentName:{main:"#e6e7eb"},grayCloseIcon:{main:"#8a8f9c"},codeBlock:{main:"#1c2030"},brand:{blue:"#6366f1"}},uMe={performanceHeader:{main:"#111827"},moduleIcon:{main:"#111827"},moduleListComponentName:{main:"#111827"},grayCloseIcon:{main:"#6b7280"},codeBlock:{main:"#f3f4f6"},brand:{blue:"#4f46e5"}},e$={shape:{borderRadius:8},typography:{fontFamily:'Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',button:{textTransform:"none"}},components:{MuiTab:{styleOverrides:{root:{textTransform:"none",fontWeight:500}}}}},t$=tt.createTheme({...e$,palette:{mode:"dark",primary:{main:"#6366f1"},background:{default:"#0f1115",paper:"#161922"},divider:"#262a36",...cMe}}),n$=tt.createTheme({...e$,palette:{mode:"light",primary:{main:"#4f46e5"},background:{default:"#f8f9fb",paper:"#ffffff"},divider:"#e5e7eb",...uMe}});function dMe(e){return e.theme?e.theme:e.mode==="light"?n$:t$}const r$="pagepilot.editor.mode.v1",Mk="pagepilot-editor-google-fonts";function AMe(){if(typeof document>"u"||document.getElementById(Mk))return;const e=document.createElement("link");e.id=Mk,e.rel="stylesheet",e.href=$U,document.head.appendChild(e)}function Lk(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(r$);return e==="light"||e==="dark"?e:null}catch{return null}}function pMe(e){if(!(typeof window>"u"))try{window.localStorage.setItem(r$,e)}catch{}}function hMe(e){const[t,n]=y.useState(()=>Lk());y.useEffect(()=>{Lk()==null&&n(null)},[e.mode]);const r=t??e.mode??"dark",o=y.useCallback(()=>{n(s=>{const u=(s??e.mode??"dark")==="dark"?"light":"dark";return pMe(u),u})},[e.mode]),a=y.useMemo(()=>dMe({theme:e.theme,mode:r}),[e.theme,r]);y.useEffect(()=>{AMe()},[]),y.useEffect(()=>{CE(e.translations)},[e.translations]),y.useEffect(()=>{fU(e.blocks)},[e.blocks]),y.useEffect(()=>{xU(e.onUpgrade)},[e.onUpgrade]);const l={mode:r,onToggleMode:e.theme?void 0:o};return i.jsx(m.ThemeProvider,{theme:a,children:i.jsx(m.ScopedCssBaseline,{sx:{width:"100%",height:"100%",minHeight:480,display:"flex",flexDirection:"column",overflow:"hidden"},children:i.jsx(m.Box,{sx:{flex:1,minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:i.jsx(_H,{initialEntries:["/page/visual-editor/preview"],future:{v7_startTransition:!0,v7_relativeSplatPath:!0},children:i.jsxs(bU,{config:e.apiConfig,globalTemplatesBaseUrl:e.globalTemplatesBaseUrl,children:[i.jsx(sMe,{...e,...l}),i.jsx(_U,{})]})})})})})}function Pk(e,t){return t.split(".").map(n=>n.trim()).filter(Boolean).reduce((n,r)=>n==null?n:n[r],e)}function T6(e,t){if(t){const n=Pk(e,t);if(Array.isArray(n))return n;const r=T6(e);if(r){const o=r.map(a=>Pk(a,t)).filter(a=>a&&typeof a=="object");if(o.length>0)return o}}if(Array.isArray(e))return e;if(e&&typeof e=="object"){for(const n of["data","rows","results","items","records"])if(Array.isArray(e[n]))return e[n]}return null}function fMe(e,t){if(!t||t.length===0){const r={};for(const[o,a]of Object.entries(e))a!=null&&(r[o]=String(a));return r}const n={};for(const r of t){const o=e[r.id];o!=null&&o!==""&&(n[r.id]=String(o))}return e.id!==void 0&&n.id===void 0&&(n.id=String(e.id)),n}async function gMe(e,t,n,r){if(typeof AbortController>"u")return n(e,t);const o=new AbortController,a=setTimeout(()=>o.abort(),r);try{return await n(e,{...t,signal:o.signal})}finally{clearTimeout(a)}}async function o$(e,t={}){var A;const n=Array.isArray(e)?e:[],r=n.filter(p=>{var h,f;return((h=p==null?void 0:p.dataSource)==null?void 0:h.type)==="api"&&((f=p==null?void 0:p.dataSource)==null?void 0:f.apiUrl)});if(r.length===0)return{fields:n,attempted:0,refreshed:0,errors:{}};const o=t.fetchFn??(typeof fetch<"u"?fetch:void 0);if(!o){const p=new Error("[pagepilot-visual-editor] refreshApiDataSources: global fetch is not available — pass `fetchFn`.");for(const h of r)(A=t.onError)==null||A.call(t,h,p);return{fields:n,attempted:r.length,refreshed:0,errors:Object.fromEntries(r.map(h=>[h.id,p.message]))}}const a=t.timeoutMs??1e4,l={};let s=0;const c=await Promise.all(r.map(async p=>{var C;const{apiUrl:h,apiMethod:f="GET",apiItemPath:b}=p.dataSource;try{const w=await gMe(h,{method:f,headers:{Accept:"application/json",...t.headers}},o,a);if(!w.ok)throw new Error(`GET ${h} → HTTP ${w.status}`);const v=await w.json(),B=T6(v,b);if(!B)throw new Error(`GET ${h} → response had no array of rows`);const S=B.map(E=>fMe(E,p.itemFields));return s+=1,{id:p.id,value:S}}catch(w){const v=w instanceof Error?w:new Error(String(w));return l[p.id]=v.message,(C=t.onError)==null||C.call(t,p,v),null}}));if(s===0)return{fields:n,attempted:r.length,refreshed:0,errors:l};const u=new Map(c.filter(Boolean).map(p=>[p.id,p.value]));return{fields:n.map(p=>u.has(p.id)?{...p,value:u.get(p.id)}:p),attempted:r.length,refreshed:s,errors:l}}async function i$(e,t={}){var r,o;const n=(o=(r=e==null?void 0:e.root)==null?void 0:r.data)==null?void 0:o.formFields;return o$(Array.isArray(n)?n:[],t)}function a$(e,t){if(!e)return t();try{return t()}finally{}}function mMe(e){const t=e;return!!(t.pageId&&t.baseUrl&&t.tenantId)}function bMe(e){const t=e;return!!(t.pagePath&&t.baseUrl&&t.tenantId)}function xMe(e){const t=e;return!!(t.templateId&&t.baseUrl)}function CMe(e){if(!e||typeof e!="object")return e;const t=py(e);return!t||t.length===0?e:hy(e,t)}async function Rk(e,t){if(!e||typeof e!="object")return{document:e,apiRefresh:null};const n=py(e);if(!n||n.length===0)return{document:e,apiRefresh:null};let r=n,o=null;return t.refreshApiDataSources&&(o=await i$(e,{fetchFn:t.fetchFn,headers:t.apiDataSourceHeaders,timeoutMs:t.apiDataSourceTimeoutMs,onError:t.onApiDataSourceError}),r=o.fields),{document:hy(e,r),apiRefresh:o}}const yMe=new Set(["ColumnsContainer","FlexColumns","Grid","ButtonGroup","Container","EmailLayout","PagePilotLayout","Accordion","PricingAccordion","TabsBlock","Carousel","Rating","Progress","Marquee","Timer","Pagination","Table","DemoPicker","MenuPicker","Breadcrumb","FormsPicker","AppBannerPicker","FaqPicker","Avatar","Button","Divider","Heading","Html","Image","Logo","Video","IFrame","Calendly","YouTubeUrl","Spacer","SkipLink","AccessibilityTools","Stepper","List","Text","Mdx","QuillBlock"]);function vMe(e){var r,o,a;const t=((r=e==null?void 0:e.data)==null?void 0:r.props)??{};return{type:"Text",data:{props:{text:typeof t.html=="string"&&t.html||typeof t.text=="string"&&t.text||typeof t.markdown=="string"&&t.markdown||""},style:((o=e==null?void 0:e.data)==null?void 0:o.style)??{},hidden:(a=e==null?void 0:e.data)==null?void 0:a.hidden}}}function l$(e){if(!e||typeof e!="object")return e;let t=!1;const n={};for(const[r,o]of Object.entries(e)){const a=o==null?void 0:o.type;a&&!yMe.has(a)?(n[r]=vMe(o),t=!0,console.warn(`[pagepilot-visual-editor] renderToStaticHtml: block "${r}" has unsupported type "${a}" — coerced to Text.`)):n[r]=o}return t?n:e}function D6(e,t){var l;if(!e)return"";const n=t.rootBlockId??"root",r=CMe(e),o=l$(r),a=((l=o==null?void 0:o[n])==null?void 0:l.data)??{};return a$(t.recordType,()=>Ro(o,{rootBlockId:n,injectElementIds:t.injectElementIds??!0,minifyCss:t.minifyCss??!0,includePageCSS:t.includePageCSS??!0,lang:t.lang??a.lang,skipLink:t.skipLink??a.skipLink,accessibilityTools:t.accessibilityTools??a.accessibilityTools,injectTabsScrollSyncScript:t.injectTabsScrollSyncScript,injectCarouselScript:t.injectCarouselScript,injectFontAssets:t.injectFontAssets,seo:t.seo,headHtml:t.headHtml,bodyBottomHtml:t.bodyBottomHtml,isBanner:t.isBanner}))}function j6(e){const t=e.fetchFn??(typeof fetch<"u"?fetch:void 0);if(!t)throw new Error("[pagepilot-visual-editor] renderToStaticHtml: global fetch is not available — pass `fetchFn`.");return t}function F6(e){const t={"Content-Type":"application/json"};return e.authToken&&(t.Authorization=`Bearer ${e.authToken}`),t}async function M6(e,t,n){const r=await n(e,t);if(!r.ok){const o=await r.text().catch(()=>"");return{ok:!1,body:null,status:r.status,text:o}}return{ok:!0,body:await r.json(),status:r.status,text:""}}async function s$(e,t,n){var u;const{wrapInDocumentShell:r=!0,headHtml:o,bodyBottomHtml:a}=n,l=Array.isArray(t==null?void 0:t.sections)?t.sections:[];if(l.length===0){const{document:d}=await Rk(((u=t==null?void 0:t.contentMetadata)==null?void 0:u.document)??e,n);return D6(d,{...n,recordType:n.recordType??"page"})}const s=await Promise.all(l.map(async d=>{var f;const A=(f=d==null?void 0:d.contentMetadata)==null?void 0:f.document;if(!A)return d;const{document:p}=await Rk(A,n),h=l$(p);return{...d,contentMetadata:{...d.contentMetadata??{},document:h}}})),{html:c}=a$(n.recordType??"page",()=>tBe(s,{rootBlockId:n.rootBlockId,injectTabsScrollSyncScript:n.injectTabsScrollSyncScript,injectCarouselScript:n.injectCarouselScript,injectFontAssets:n.injectFontAssets,isBanner:n.isBanner,seo:n.seo,wrapInDocumentShell:r,seoTitle:(t==null?void 0:t.metaTitle)??(t==null?void 0:t.title)??(t==null?void 0:t.name),seoDescription:t==null?void 0:t.metaDescription,lang:n.lang??(t==null?void 0:t.lang),extraHead:o??(t==null?void 0:t.head)??"",extraBodyBottom:a??(t==null?void 0:t.bodyBottom)??""}));return c}async function wMe(e,t){const{baseUrl:n,tenantId:r,pageId:o}=t,l=`${n.replace(/\/+$/,"")}/tenant/${r}/page/${o}`,s=j6(t),c=await M6(l,{method:"GET",headers:F6(t)},s);if(!c.ok)throw new Error(`[pagepilot-visual-editor] renderToStaticHtml: GET ${l} → ${c.status}${c.text?`: ${c.text}`:""}`);return s$(e,c.body,{...t,fetchFn:s})}async function BMe(e,t){var p,h;const{baseUrl:n,tenantId:r,pagePath:o,cache:a=!1,update:l=!0}=t,c=`${n.replace(/\/+$/,"")}/tenant/${r}/pagebypath/${encodeURIComponent(o)}?cache=${a}&update=${l}`,u=j6(t),d=await M6(c,{method:"GET",headers:F6(t)},u);if(!d.ok)throw new Error(`[pagepilot-visual-editor] renderToStaticHtml: GET ${c} → ${d.status}${d.text?`: ${d.text}`:""}`);const A=((p=d.body)==null?void 0:p.data)??((h=d.body)==null?void 0:h.payload)??d.body;return s$(e,A,{...t,fetchFn:u})}async function SMe(e){const{baseUrl:t,tenantId:n,templateId:r,isGlobal:o=!1}=e,a=t.replace(/\/+$/,""),l=j6(e),s=o?`${a}/global-template/${r}`:`${a}/tenant/${n}/template/${r}`,c=o?{"Content-Type":"application/json"}:F6(e),u=await M6(s,{method:"GET",headers:c},l);if(u.ok)return u.body;throw new Error(`[pagepilot-visual-editor] renderToStaticHtml: GET ${s} → ${u.status}${u.text?`: ${u.text}`:""}`)}function kMe(e,t){if(!t)return e;const n=new Map;for(const o of e)o!=null&&o.id&&n.set(o.id,o);if(Array.isArray(t)){for(const o of t){if(!(o!=null&&o.id))continue;const l={...n.get(o.id)??{id:o.id,name:o.id,type:"text"},...o};n.set(o.id,l)}return Array.from(n.values())}const r=Object.entries(t).filter(([,o])=>o!=null);if(r.length===0)return e;for(const[o,a]of r){const l=String(a),s=n.get(o);s?n.set(o,{...s,value:l}):n.set(o,{id:o,name:o,type:"text",value:l})}return Array.from(n.values())}async function EMe(e,t){const n=await SMe(t),r=u4e(n)??(e&&Object.keys(e).length>0?e:null);if(!r)return"";const o=By(n),a=kMe(o,t.variables),l=hy(r,a);return D6(l,t)}function IMe(e,t){return xMe(t)?EMe(e,t):bMe(t)?BMe(e,t):mMe(t)?wMe(e,t):D6(e,t)}exports.EditorContext=UG;exports.PagePilotEditor=hMe;exports.PagepilotApiClient=vE;exports.Reader=ga;exports.ReaderBlock=Wn;exports.ReaderBlockSchema=fP;exports.ReaderDocumentSchema=Jbe;exports.applyFieldPatches=Lm;exports.buildChangeTemplateDocument=b5;exports.commonjsGlobal=Ir;exports.extractApiRows=T6;exports.getAugmentedNamespace=cz;exports.getDefaultExportFromCjs=yl;exports.normalizeTemplateForLocalEditor=aa;exports.pagePilotEditorDarkTheme=t$;exports.pagePilotEditorLightTheme=n$;exports.parseTemplateConfiguration=is;exports.refreshApiDataSources=o$;exports.refreshDocumentApiDataSources=i$;exports.renderToStaticHtml=IMe;exports.renderToStaticMarkup=Ro;exports.resetDocument=wn;exports.resetPagePilotEditorTranslations=AU;exports.setDocument=pt;exports.setPagePilotEditorTranslations=CE;
1493
+ `),E);return{document:c,renderSource:u,activeHtml:h,sections:E,html:k}}const eMe=["metaTitle","metaDescription","metaImageUrl","metaKeywords","tags","author","head","bodyBottom","schemaMarkup"],tMe=(e,t)=>e==="author"?(t==null?void 0:t.id)??t??null:e==="schemaMarkup"?Array.isArray(t)?t.map(n=>n&&typeof n=="object"?n.id:n).filter(n=>n!=null).sort():[]:t??null;function ZN(e){try{return JSON.stringify(eMe.map(t=>tMe(t,e==null?void 0:e[t])))}catch{return""}}function XN(e,t){var n,r,o;return JSON.stringify([(e==null?void 0:e.title)||((n=e==null?void 0:e.metadata)==null?void 0:n.title)||`Section ${t+1}`,(e==null?void 0:e.identifier)||((r=e==null?void 0:e.metadata)==null?void 0:r.identifier)||"",(e==null?void 0:e.sectionType)||((o=e==null?void 0:e.metadata)==null?void 0:o.sectionType)||"internal"])}function JN(e){if(!e)return"";try{return mp({document:e,pageType:Ge.Page})}catch{return""}}function zb(e,t){return{fields:ZN(e),sections:(t??[]).map((n,r)=>{var o;return{meta:XN(n,r),snapshot:JN((o=n==null?void 0:n.contentMetadata)==null?void 0:o.document)}})}}function nMe(e,t,n){var o,a;if(!e)return!1;const r=n??[];if(r.length!==e.sections.length)return!0;for(let l=0;l<r.length;l++){const s=e.sections[l];if(XN(r[l],l)!==s.meta||JN((a=(o=r[l])==null?void 0:o.contentMetadata)==null?void 0:a.document)!==s.snapshot)return!0}return ZN(t)!==e.fields}const rMe={back:!0,title:!0,status:!0,sectionsDropdown:!0,undo:!0,redo:!0,unselect:!0,save:!0,autoSave:!1,screenSize:!0,themeToggle:!0,fullscreen:!0,preview:!0,moreMenu:!1,publish:!1};function oMe(e){return{...rMe,...e??{}}}const iMe=["desktop","tablet","mobile"],Or=e=>Array.isArray(e==null?void 0:e.sections)?e.sections:[],Ai=(e,t)=>t>0?Math.min(Math.max(e,0),t-1):0;function aMe(e){if(!e||typeof e!="object")return null;const t=n=>n&&typeof n=="object"&&!Array.isArray(n)&&(Array.isArray(n.sections)||n.id!=null||n._id!=null);return t(e)?e:t(e.data)?e.data:null}function lMe(e,t,n){const r=aMe(t);if(!r)return e;const{sections:o,...a}=r,l={...e,...a,id:e.id??a.id??a._id};if(n)return{...l,contentMetadata:e.contentMetadata};const s=Or(e);return Array.isArray(o)&&o.length===s.length?l.sections=s.map((c,u)=>{var d,A,p,h;return{...c,...o[u],contentMetadata:{...(c==null?void 0:c.contentMetadata)??{},...((d=o[u])==null?void 0:d.contentMetadata)??{},document:((p=(A=o[u])==null?void 0:A.contentMetadata)==null?void 0:p.document)??((h=c==null?void 0:c.contentMetadata)==null?void 0:h.document)}}}):l.sections=s,l}function sMe({record:e,contentMetadata:t,behaviour:n,steps:r,sections:o,activeStepIndex:a=0,panels:l,title:s="Back",recordTitle:c,recordStatus:u,headerExtra:d,children:A,onUpdateRecord:p,onChange:h,onSaveChanges:f,onPublish:b,onPublishMenu:C,renderPublish:w,onBack:v,onTogglePreview:B,onBackgroundChange:S,onNavigateBranding:E,onAddSection:k,onOpenPageCode:I,onApiError:F,topbar:T,mode:D,onToggleMode:L,autoSaveEnabled:P,onAutoSaveChange:M,autoSaveIntervalMs:z}){const G=y.useMemo(()=>oMe(T),[T]),V=y.useMemo(()=>({id:"doc-1",type:"page",...e,contentMetadata:t??(e==null?void 0:e.contentMetadata),behaviour:n??(e==null?void 0:e.behaviour),steps:r??(e==null?void 0:e.steps),sections:o??(e==null?void 0:e.sections)}),[e,t,n,r,o]),_=y.useRef(V),W=y.useRef(V);W.current!==V&&(W.current=V,_.current=V);const q=y.useCallback(Re=>{_.current=Re,p==null||p(Re)},[p]),Z=Us(),{currentTenant:R}=Ip(),H=(R==null?void 0:R.id)??(Z==null?void 0:Z.tenantId)??null,N=fp()??0,$=y.useMemo(()=>Or(V),[V.sections]),ee=Ai(N,$.length),K=$[ee],X=Ka(K),Y=YN(V);y.useEffect(()=>{CT(X)},[X]);const ue=y.useRef([]),ce=()=>{ue.current.forEach(Re=>window.clearTimeout(Re)),ue.current=[]},re=y.useCallback(()=>{ce(),Gl(),queueMicrotask(()=>Gl()),ue.current.push(window.setTimeout(()=>Gl(),0),window.setTimeout(()=>Gl(),400))},[]);y.useEffect(()=>()=>ce(),[]);const[pe,Q]=y.useState(null),U=y.useRef(!1),O=y.useRef(!1);y.useEffect(()=>{var kt,yn,cn,Jt,fr,Qr;if(U.current)return;const Re=Or(V),dt=Ai(a,Re.length);let vt=Re.length>0?(yn=(kt=Re[dt])==null?void 0:kt.contentMetadata)==null?void 0:yn.document:((cn=V.contentMetadata)==null?void 0:cn.document)??((Qr=(fr=(Jt=V.steps)==null?void 0:Jt[a])==null?void 0:fr.contentMetadata)==null?void 0:Qr.document);if(!vt&&Re.length>0&&(vt=jc("")),!vt){O.current||(O.current=!0,Q(zb(V,Re)),re());return}const Et=aa(vt);PT(),Wl(dt,{skipHistory:!0}),wn(Et,{skipHistory:!0}),U.current=!0,Q(zb(V,Re)),re()},[V]);const ie=zr();y.useEffect(()=>{if(!U.current||ie!==Ee.getState().document)return;h==null||h(ie);const Re=_.current;q({...Re,contentMetadata:{...Re.contentMetadata??{},document:ie}})},[ie]);const ae=ET(),ne=y.useRef(null),te=iMe.includes(V.device)?V.device:"desktop";y.useEffect(()=>{const Re=String(V.id??"");if(ne.current!==Re){ne.current=Re,IT(),jx(te),Ss(te);return}ae||(jx(te),Ss(te))},[V.id,te]);const{inspectorWidth:fe,handleMouseDown:Ae,isPanelCollapsed:xe,toggleCollapsed:le,handleOpenPanel:se}=T7e(),he=Ee(Re=>{var dt;return((dt=Re==null?void 0:Re.undoStack)==null?void 0:dt.length)??0}),ge=y.useMemo(()=>nMe(pe,V,$),[pe,V,$]),be=pe!==null&&(he>0||ge),[Te,Le]=y.useState(!1),[Me,Fe]=y.useState(!1),Ve=Ct.useRef(!1),Oe=Ct.useRef(null);Ct.useEffect(()=>()=>{Oe.current&&clearTimeout(Oe.current)},[]),Ct.useEffect(()=>{be&&Me&&(Oe.current&&clearTimeout(Oe.current),Fe(!1))},[be]);const at=y.useCallback(()=>{Fe(!0),Oe.current&&clearTimeout(Oe.current),Oe.current=setTimeout(()=>Fe(!1),5e3)},[]);y.useEffect(()=>{if(!be||Me)return;const Re=dt=>(dt.preventDefault(),dt.returnValue="","");return window.addEventListener("beforeunload",Re),()=>window.removeEventListener("beforeunload",Re)},[be,Me]),y.useEffect(()=>{const Re=vt=>{if(!(vt instanceof HTMLElement))return!1;const Et=vt.tagName;return Et==="INPUT"||Et==="TEXTAREA"||Et==="SELECT"?!0:vt.isContentEditable?!vt.closest('[data-inline-edit-target="true"]'):!1},dt=vt=>{var Jt,fr,Qr;if(!(vt.ctrlKey||vt.metaKey))return;const Et=vt.key.toLowerCase(),kt=Et==="z"&&!vt.shiftKey,yn=Et==="y"||Et==="z"&&vt.shiftKey,cn=Et==="b";if(!(!kt&&!yn&&!cn)&&!Re(vt.target)){if(cn){const Pr=Ee.getState(),fo=Pr.selectedBlockId;if(!fo)return;const Ko=Pr.document[fo];if(!Ko||Ko.type!=="Heading")return;const ro=x5((fr=(Jt=Ko.data)==null?void 0:Jt.style)==null?void 0:fr.fontWeight)===jr.BOLD?jr.REGULAR:jr.BOLD;vt.preventDefault(),pt({[fo]:{...Ko,data:{...Ko.data,style:{...((Qr=Ko.data)==null?void 0:Qr.style)??{},fontWeight:ro}}}});return}vt.preventDefault(),kt?M3():L3()}};return window.addEventListener("keydown",dt),()=>window.removeEventListener("keydown",dt)},[]);const ke=y.useCallback(Re=>{const dt={..._.current,sections:Re};q(dt);const vt=dt!=null&&dt.id?`page_${dt.id}`:null;if(vt)try{Id(vt,JSON.stringify(dt))}catch{}return dt},[q]),Ke=y.useCallback(()=>{var kt;const Re=_.current,dt=Or(Re);if(dt.length===0)return Re;const vt=Ee.getState();if((((kt=vt.undoStack)==null?void 0:kt.length)??0)===0)return Re;const Et=Ai(vt.activeStepIndex??0,dt.length);return ke(Xb(dt,Et,vt.document))},[ke]),_e=y.useCallback((Re={},dt,vt)=>{const Et=_.current,kt=Or(Et),yn=Ee.getState(),cn=Ai(yn.activeStepIndex??0,kt.length),Jt=JFe({record:Et,sections:kt,activeSectionIndex:cn,liveDocument:yn.document,...Re}),fr={sections:Jt.sections,...dt!==void 0?{status:dt}:{},...vt?{schedule:vt}:{}};if(kt.length===0)return{renderSource:Jt.renderSource,payload:{record:{...Et,contentMetadata:{...Et.contentMetadata??{},document:Jt.document,html:Jt.html}},document:Jt.document,html:Jt.html,...fr}};const{contentMetadata:Qr,behaviour:Pr,steps:fo,...Ko}=Et,nd=Pr&&typeof Pr=="object"&&Object.keys(Pr).length>0,ro=Array.isArray(fo)&&fo.length>0;return{renderSource:Jt.renderSource,payload:{record:{...Ko,...nd?{behaviour:Pr}:{},...ro?{steps:fo}:{},sections:Jt.sections},html:Jt.html,...fr}}},[]),Ue=y.useCallback((Re,dt,vt,Et)=>{const{contentMetadata:kt,html:yn,...cn}=Re.record,Jt={...cn,pageId:cn.id,status:dt,sections:Re.sections};return vt&&(Jt.startDate=vt.startDate??null,Jt.endDate=vt.endDate??null),Et!==void 0&&(Jt.ttlMinutes=Et),Jt},[]),[Ze,$e]=y.useState(null),Pe=y.useCallback(async(Re,dt,vt={})=>{var P6;Mt();const{schedule:Et,ttlMinutes:kt,...yn}=vt,{payload:cn,renderSource:Jt}=_e(yn,dt,Et),fr=Re==="publish"?"publish":"save",Qr=Or(_.current).length===0;let Pr,fo=!1;const Ko=(P6=cn.record)==null?void 0:P6.id;if(Z&&Ko&&Ko!=="doc-1")try{await j7e(Jt),Pr=await Z.upsertPage(Ue(cn,dt,Et,kt)),fo=!0}catch(Yp){const R6=Yp instanceof Error?Yp:new Error(String(Yp));return console.error(`[PagePilotEditor] apiClient.upsertPage failed (${fr}):`,R6),F==null||F(R6,fr),!1}else if(!Z&&Re!=="publish"&&!f)return!1;const nd=Pr!==void 0?{...cn,response:Pr}:cn;if(Re==="publish")await(b==null?void 0:b(nd));else if(f&&await f(nd)===!1)return!1;let ro=lMe(cn.record,Pr,Qr);return dt&&(ro={...ro,status:dt}),Et&&(ro={...ro,startDate:Et.startDate??null,endDate:Et.endDate??null}),kt!==void 0&&(ro={...ro,ttlMinutes:kt}),q(ro),Q(zb(ro,Or(ro))),Gl(),at(),Re==="publish"&&fo&&H&&$e(String(ro.slug??"")),!0},[Z,_e,Ue,q,F,b,f,at,H]),De=y.useCallback(async()=>{if(Ve.current)return!1;Ve.current=!0,Le(!0);try{return await Pe("save",_.current.status??null)}finally{Le(!1),Ve.current=!1}},[Pe]),[Xe,rt]=y.useState(!1),nt=y.useCallback(()=>{if(v){if(be){rt(!0);return}v()}},[v,be]),Ce=y.useCallback(()=>{rt(!1),v==null||v()},[v]),Be=y.useCallback(async()=>{await De()&&(rt(!1),v==null||v())},[De,v]),qe="pagepilot.editor.autoSave.v1",lt=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(qe)==="1"}catch{return!1}},[me,ye]=y.useState(()=>lt()),We=P!==void 0?P:me,Je=y.useCallback(Re=>{if(P===void 0&&(ye(Re),typeof window<"u"))try{window.localStorage.setItem(qe,Re?"1":"0")}catch{}M==null||M(Re)},[P,M]),[ut,Ie]=y.useState(!1),[ht,Tn]=y.useState(null);E7e({isDirty:be,onSave:De,isSaving:Te,enabled:We&&!ut,intervalMs:z??6e4});const er=y.useCallback(()=>{if(B){const{payload:kt}=_e();B(kt.html,kt.document);return}Mt();const Re=Ke(),dt=Ee.getState().document,vt=Or(Re),Et=Ai(Ee.getState().activeStepIndex??0,vt.length);Tn(vt.length>0?{...Re,sections:Xb(vt,Et,dt)}:{...Re,contentMetadata:{...Re.contentMetadata??{},document:dt}}),Ie(!0)},[_e,B,Ke]),[qt,hn]=y.useState(!1),[Ft,jt]=y.useState(null),Sn=y.useCallback(async()=>{if(jt(null),Z){hn(!0);return}if(!b)return;const{payload:Re}=_e({},S1.LIVE);await b(Re)},[Z,b,_e]),Lr=y.useCallback(async(Re,dt)=>{if(Ve.current)return!1;Ve.current=!0,Le(!0);try{return Re==="publish"?await Pe("publish",S1.LIVE,dt):await Pe("draft",S1.DRAFT,dt)}finally{Le(!1),Ve.current=!1}},[Pe]),Go=y.useCallback(async()=>{jt(null),await Lr("save")},[Lr]),tc=y.useCallback(Re=>{if(C){C(Re.currentTarget,_e().payload);return}jt(Re.currentTarget)},[C,_e]),_i=V.slug||"",Ju=V.status===S1.LIVE,nc=y.useMemo(()=>!_i||!H?null:O_(R??H,_i,V.updatedAt||new Date),[_i,H,R,V.updatedAt]),Qp=y.useMemo(()=>_i?N_(R,_i):null,[R,_i]),Vp=y.useMemo(()=>w?w({payload:_e().payload,onPublish:()=>void Sn()}):null,[w,Sn,ie]),Wp=y.useRef(null),[rc,Gp]=y.useState(!1),[Kp,Qe]=y.useState(!1);y.useEffect(()=>{const Re=()=>{Gp(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",Re),()=>document.removeEventListener("fullscreenchange",Re)},[]);const Bt=y.useCallback(()=>{var dt,vt;const Re=document.documentElement;Re&&(document.fullscreenElement?(vt=document.exitFullscreen)==null||vt.call(document):(dt=Re.requestFullscreen)==null||dt.call(Re))},[]),[Dn,tr]=y.useState(null),qp=T3(),[no,Da]=y.useState(null),ed=y.useCallback(()=>{if(k){k();return}Da({mode:"add"})},[k]),Fl=y.useCallback(Re=>{var Et;if(!Re||Ka(Re))return;const dt=((Et=Re.contentMetadata)==null?void 0:Et.document)??jc(""),vt=aa(dt);kT(vt),re()},[re]),td=y.useCallback((Re,dt,vt,Et,kt,yn,cn)=>({undo:()=>{kt&&(yn===null?Rz(kt):Id(kt,yn)),q(Re),Wl(dt,{skipHistory:!0})},redo:()=>{kt&&cn!==null&&Id(kt,cn),q(vt),Wl(Et,{skipHistory:!0})}}),[q]),Ml=y.useCallback((Re,dt,vt)=>{var fo;const Et=Ai(Ee.getState().activeStepIndex??0,Or(Re).length),kt=Re!=null&&Re.id?`page_${Re.id}`:null;let yn=null;try{yn=kt?Zc(kt):null}catch{yn=null}const cn={...Re,sections:dt},Jt=kt?JSON.stringify(cn):null;if(q(cn),kt&&Jt!==null)try{Id(kt,Jt)}catch{}const fr=td(Re,Et,cn,vt,kt,yn,Jt),Qr=dt[vt],Pr=Ka(Qr)?Ee.getState().document:aa(((fo=Qr==null?void 0:Qr.contentMetadata)==null?void 0:fo.document)??jc(""));wn(Pr,{sideEffect:fr}),Wl(vt,{skipHistory:!0})},[td,q]),L6=y.useCallback((Re,dt)=>{var fr;Mt();const vt=Or(Ke()),Et=vt[Re];if(!Et)return;const kt=dt.sectionType==="internal"&&Ka(Et),yn=dt.sectionType==="internal"&&!((fr=Et.contentMetadata)!=null&&fr.document),cn={...Et,title:dt.title,sectionType:dt.sectionType,...yn?{contentMetadata:{...Et.contentMetadata??{},document:jc("")}}:{}};ke(vt.map((Qr,Pr)=>Pr===Re?cn:Qr)),Da(null);const Jt=Ai(Ee.getState().activeStepIndex??0,vt.length);kt&&Re===Jt&&Fl(cn)},[ke,Fl,Ke]),c$=y.useCallback(Re=>{if((no==null?void 0:no.mode)==="edit"){L6(no.index,Re);return}Mt();const dt=Ke(),vt=Or(dt),Et=az(Re,jc("")),kt=[...vt,Et];Da(null),Ml(dt,kt,kt.length-1)},[no,L6,Ke,Ml]),u$=y.useCallback(Re=>{const dt=Or(_.current);if(Re<0||Re>=dt.length)return;const vt=Ai(Ee.getState().activeStepIndex??0,dt.length);if(Re===vt)return;Mt();const Et=Ke(),kt=Or(Et)[Re];Wl(Re,{skipHistory:!0}),Ka(kt)?re():Fl(kt)},[Ke,Fl,re]),d$=y.useCallback(Re=>{const dt=Or(_.current);if(Re===0||dt.length<=1||Re>=dt.length)return;Mt();const vt=Ke(),Et=Or(vt),kt=Ai(Ee.getState().activeStepIndex??0,Et.length),yn=Et.filter((Jt,fr)=>fr!==Re),cn=kt>=yn.length?yn.length-1:kt>Re?kt-1:kt;Ml(vt,yn,cn)},[Ke,Ml]),A$=y.useCallback(Re=>{Da({mode:"edit",index:Re})},[]),p$=y.useCallback((Re,dt)=>{if(Re===dt)return;Mt();const vt=Ke(),Et=Or(vt);if(Re<0||dt<0||Re>=Et.length||dt>=Et.length)return;const kt=Ai(Ee.getState().activeStepIndex??0,Et.length),yn=Et.slice(),[cn]=yn.splice(Re,1);yn.splice(dt,0,cn);let Jt=kt;kt===Re?Jt=dt:Re<kt&&dt>=kt?Jt=kt-1:Re>kt&&dt<=kt&&(Jt=kt+1),ke(yn),Jt!==kt&&Wl(Jt,{skipHistory:!0}),Gl()},[Ke,ke]),h$=y.useMemo(()=>{if((no==null?void 0:no.mode)!=="edit")return;const Re=$[no.index];if(Re)return{title:Re.title??"",sectionType:Re.sectionType??"internal"}},[no,$]),f$=!!(Z||f);return i.jsxs(m.Box,{ref:Wp,sx:{display:"flex",flexDirection:"column",height:"100%",width:"100%",overflow:"hidden",bgcolor:"background.default"},children:[i.jsx(_7e,{toggles:G,title:s,recordTitle:c??(V==null?void 0:V.title)??(V==null?void 0:V.name),recordStatus:u??(V==null?void 0:V.status),onBack:nt,onSave:De,onPublish:Sn,onPublishMenu:tc,publishSlot:Vp,onPreview:er,onToggleFullscreen:Bt,isFullscreen:rc,mode:D,onToggleMode:L,isDirty:be,isSaving:Te,changesSaved:Me,autoSaveEnabled:We,onAutoSaveChange:Je,isPageRecord:Y,onOpenMoreMenu:G.moreMenu?Re=>tr(Re.currentTarget):void 0,sectionsDropdown:G.sectionsDropdown&&$.length>1?i.jsx(iz,{sections:$,activeSectionIndex:ee,onSelectSection:u$,onDeleteSection:d$,onEditSection:A$,onReorderSections:p$}):null}),d,i.jsxs(m.Box,{sx:{display:"flex",flex:1,minHeight:0},children:[i.jsx(V8e,{record:V,activeStepIndex:N,onTogglePreview:er,onBackgroundChange:S??(()=>{}),onUpdateRecord:q,onSaveChanges:De,isExternalSection:X,onNavigateBranding:E,panels:l,inspectorWidth:fe,handleMouseDown:Ae,isPanelCollapsed:xe,handleOpenPanel:se,toggleCollapsed:le}),i.jsx(m.Box,{sx:{flex:1,minWidth:0,overflow:"auto"},children:i.jsx(w7e,{record:V,isPreviewOpen:ut,activeStepIndex:N,fetchTooltip:()=>{},loading:!1,activeSection:K,activeSectionIndex:ee,onAddSection:ed})})]}),A,i.jsx(aBe,{open:ut,onClose:()=>Ie(!1),record:ht,liveUrl:Ju?nc:null,domainPreviewUrl:Qp}),Kp&&i.jsx(m.Box,{sx:{position:"fixed",inset:0,zIndex:1300,bgcolor:"background.default",overflow:"auto"},children:i.jsx(qFe,{record:V,onBack:()=>Qe(!1)})}),Z&&i.jsx(Q7e,{open:qt,onClose:()=>hn(!1),record:V,apiClient:Z,onSubmit:(Re,dt)=>Lr(Re,dt)}),Ze!==null&&H&&i.jsx(J7e,{open:!0,onClose:()=>$e(null),tenantId:H,tenant:R,slug:Ze}),!C&&i.jsxs(m.Menu,{anchorEl:Ft,open:!!Ft,onClose:()=>jt(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{mt:1,minWidth:180,bgcolor:"background.paper",backgroundImage:"none",border:1,borderColor:"divider",borderRadius:1,boxShadow:"0px 10px 20px rgba(33, 36, 67, 0.08), 0px 2px 6px rgba(33, 36, 67, 0.04)"}}},children:[i.jsxs(m.MenuItem,{onClick:()=>void Sn(),disabled:Te,children:[i.jsx(m.ListItemIcon,{children:i.jsx(V4,{sx:{fontSize:20}})}),i.jsx(m.ListItemText,{children:"Publish"})]}),Ju&&Y&&nc&&i.jsxs(m.MenuItem,{onClick:()=>{jt(null),window.open(nc,"_blank","noopener,noreferrer")},children:[i.jsx(m.ListItemIcon,{children:i.jsx(Qk,{sx:{fontSize:20}})}),i.jsx(m.ListItemText,{children:"Live URL"})]}),f$&&i.jsxs(m.MenuItem,{onClick:()=>void Go(),disabled:Te,children:[i.jsx(m.ListItemIcon,{children:Te?i.jsx(m.CircularProgress,{size:20}):i.jsx(Vk,{sx:{fontSize:20}})}),i.jsx(m.ListItemText,{children:"Save as Draft"})]})]}),G.moreMenu&&i.jsx(m.Menu,{anchorEl:Dn,open:!!Dn,onClose:()=>tr(null),anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},slotProps:{paper:{sx:{mt:1,p:.5,bgcolor:"background.paper",backgroundImage:"none",border:1,borderColor:"divider",borderRadius:1,boxShadow:"0 0 6px rgba(0,0,0,.06), 2px 2px 8px rgba(0,0,0,.06)"}},list:{disablePadding:!0}},children:[{key:"addSection",show:!0,label:"Add Section",icon:i.jsx(w$,{sx:{fontSize:20}}),onClick:ed},{key:"pageCode",show:!0,label:"Page Code",icon:i.jsx(S$,{sx:{fontSize:20}}),onClick:I??(()=>Qe(!0))},{key:"minimap",show:!0,label:qp?"Hide Minimap":"Show Minimap",icon:i.jsx(B$,{sx:{fontSize:20}}),onClick:dT},{key:"fullscreen",show:!0,label:rc?"Exit Fullscreen":"Fullscreen Editor",icon:rc?i.jsx(Hk,{sx:{fontSize:20}}):i.jsx($k,{sx:{fontSize:20}}),onClick:Bt},{key:"autoSave",show:G.autoSave,label:"Auto Save",icon:i.jsx(k$,{sx:{fontSize:20}}),keepOpen:!0,onClick:()=>Je(!We),trailing:i.jsx(m.Switch,{size:"small",checked:!!We,onChange:Re=>Je(Re.target.checked),onClick:Re=>Re.stopPropagation()})},{key:"themeMode",show:!!L,divider:!0,label:D==="dark"?"Light Mode":"Dark Mode",icon:D==="dark"?i.jsx(Uk,{sx:{fontSize:20}}):i.jsx(zk,{sx:{fontSize:20}}),onClick:L}].filter(Re=>Re.show).map(Re=>[Re.divider?i.jsx(m.Divider,{sx:{my:.5}},`${Re.key}-divider`):null,i.jsxs(m.MenuItem,{onClick:()=>{var dt;Re.keepOpen||tr(null),(dt=Re.onClick)==null||dt.call(Re)},sx:{gap:1.75,px:1.5,py:1,borderRadius:1},children:[i.jsx(m.ListItemIcon,{sx:{minWidth:"0 !important",color:"text.secondary"},children:Re.icon}),i.jsx(m.ListItemText,{primary:Re.label,primaryTypographyProps:{fontSize:14,fontWeight:500},sx:{m:0,flex:1,minWidth:0}}),Re.trailing&&i.jsx(m.Box,{sx:{ml:1.5,display:"inline-flex",alignItems:"center"},children:Re.trailing})]},Re.key)])}),i.jsx(ez,{open:!!no,onClose:()=>Da(null),onAdd:c$,initialValues:h$}),i.jsxs(m.Dialog,{open:Xe,onClose:()=>{Te||rt(!1)},maxWidth:"xs",PaperProps:{sx:{gap:"8px","&&":{borderRadius:"14px"},padding:"28px 0px",width:428,backgroundColor:"background.paper",backgroundImage:"none"}},children:[i.jsx(m.IconButton,{onClick:()=>{Te||rt(!1)},disableRipple:!0,sx:{position:"absolute",top:8,right:8,justifyContent:"flex-end"},children:i.jsx(Ti,{})}),i.jsx(m.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"8px",width:50,height:50,margin:"0 auto 8px auto"},children:i.jsx(Q4,{sx:{color:"#F79009"}})}),i.jsxs(m.DialogContent,{sx:{textAlign:"center",margin:"0 45px",padding:"10px 20px !important",backgroundColor:"inherit"},children:[i.jsx(m.Typography,{sx:{fontSize:18,fontWeight:600,color:"text.primary"},children:"Unsaved changes"}),i.jsx(m.Typography,{sx:{marginTop:"0.5rem",fontWeight:400,fontSize:"14px",lineHeight:"20px",letterSpacing:"0%",whiteSpace:"pre-line",color:"text.secondary"},children:"You have unsaved changes. Do you want to save them before leaving?"})]}),i.jsxs(m.DialogActions,{sx:{justifyContent:"center",gap:1,paddingBottom:0,paddingTop:0,borderTop:"none",marginTop:0,paddingInline:4,backgroundColor:"inherit"},children:[i.jsx(m.Button,{onClick:Ce,variant:"outlined",fullWidth:!0,disableRipple:!0,disabled:Te,sx:{height:"40px",borderRadius:"8px",textTransform:"none",lineHeight:"normal",fontWeight:600,fontSize:"16px",border:Re=>`1px solid ${Re.palette.divider}`,color:"text.primary",backgroundColor:"background.paper"},children:"Discard"}),i.jsx(m.Button,{onClick:Be,variant:"contained",fullWidth:!0,disableRipple:!0,disabled:Te,startIcon:Te?i.jsx(m.CircularProgress,{size:16,color:"inherit"}):null,sx:{height:"40px",borderRadius:"8px",textTransform:"none",lineHeight:"normal",fontWeight:600,fontSize:"16px",backgroundColor:"#F79009",color:"#FFFFFF","&:hover":{backgroundColor:"#F79009"}},children:"Save"})]})]})]})}const cMe={performanceHeader:{main:"#e6e7eb"},moduleIcon:{main:"#e6e7eb"},moduleListComponentName:{main:"#e6e7eb"},grayCloseIcon:{main:"#8a8f9c"},codeBlock:{main:"#1c2030"},brand:{blue:"#6366f1"}},uMe={performanceHeader:{main:"#111827"},moduleIcon:{main:"#111827"},moduleListComponentName:{main:"#111827"},grayCloseIcon:{main:"#6b7280"},codeBlock:{main:"#f3f4f6"},brand:{blue:"#4f46e5"}},e$={shape:{borderRadius:8},typography:{fontFamily:'Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',button:{textTransform:"none"}},components:{MuiTab:{styleOverrides:{root:{textTransform:"none",fontWeight:500}}}}},t$=tt.createTheme({...e$,palette:{mode:"dark",primary:{main:"#6366f1"},background:{default:"#0f1115",paper:"#161922"},divider:"#262a36",...cMe}}),n$=tt.createTheme({...e$,palette:{mode:"light",primary:{main:"#4f46e5"},background:{default:"#f8f9fb",paper:"#ffffff"},divider:"#e5e7eb",...uMe}});function dMe(e){return e.theme?e.theme:e.mode==="light"?n$:t$}const r$="pagepilot.editor.mode.v1",Mk="pagepilot-editor-google-fonts";function AMe(){if(typeof document>"u"||document.getElementById(Mk))return;const e=document.createElement("link");e.id=Mk,e.rel="stylesheet",e.href=$U,document.head.appendChild(e)}function Lk(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(r$);return e==="light"||e==="dark"?e:null}catch{return null}}function pMe(e){if(!(typeof window>"u"))try{window.localStorage.setItem(r$,e)}catch{}}function hMe(e){const[t,n]=y.useState(()=>Lk());y.useEffect(()=>{Lk()==null&&n(null)},[e.mode]);const r=t??e.mode??"dark",o=y.useCallback(()=>{n(s=>{const u=(s??e.mode??"dark")==="dark"?"light":"dark";return pMe(u),u})},[e.mode]),a=y.useMemo(()=>dMe({theme:e.theme,mode:r}),[e.theme,r]);y.useEffect(()=>{AMe()},[]),y.useEffect(()=>{CE(e.translations)},[e.translations]),y.useEffect(()=>{fU(e.blocks)},[e.blocks]),y.useEffect(()=>{xU(e.onUpgrade)},[e.onUpgrade]);const l={mode:r,onToggleMode:e.theme?void 0:o};return i.jsx(m.ThemeProvider,{theme:a,children:i.jsx(m.ScopedCssBaseline,{sx:{width:"100%",height:"100%",minHeight:480,display:"flex",flexDirection:"column",overflow:"hidden"},children:i.jsx(m.Box,{sx:{flex:1,minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:i.jsx(_H,{initialEntries:["/page/visual-editor/preview"],future:{v7_startTransition:!0,v7_relativeSplatPath:!0},children:i.jsxs(bU,{config:e.apiConfig,globalTemplatesBaseUrl:e.globalTemplatesBaseUrl,children:[i.jsx(sMe,{...e,...l}),i.jsx(_U,{})]})})})})})}function Pk(e,t){return t.split(".").map(n=>n.trim()).filter(Boolean).reduce((n,r)=>n==null?n:n[r],e)}function T6(e,t){if(t){const n=Pk(e,t);if(Array.isArray(n))return n;const r=T6(e);if(r){const o=r.map(a=>Pk(a,t)).filter(a=>a&&typeof a=="object");if(o.length>0)return o}}if(Array.isArray(e))return e;if(e&&typeof e=="object"){for(const n of["data","rows","results","items","records"])if(Array.isArray(e[n]))return e[n]}return null}function fMe(e,t){if(!t||t.length===0){const r={};for(const[o,a]of Object.entries(e))a!=null&&(r[o]=String(a));return r}const n={};for(const r of t){const o=e[r.id];o!=null&&o!==""&&(n[r.id]=String(o))}return e.id!==void 0&&n.id===void 0&&(n.id=String(e.id)),n}async function gMe(e,t,n,r){if(typeof AbortController>"u")return n(e,t);const o=new AbortController,a=setTimeout(()=>o.abort(),r);try{return await n(e,{...t,signal:o.signal})}finally{clearTimeout(a)}}async function o$(e,t={}){var A;const n=Array.isArray(e)?e:[],r=n.filter(p=>{var h,f;return((h=p==null?void 0:p.dataSource)==null?void 0:h.type)==="api"&&((f=p==null?void 0:p.dataSource)==null?void 0:f.apiUrl)});if(r.length===0)return{fields:n,attempted:0,refreshed:0,errors:{}};const o=t.fetchFn??(typeof fetch<"u"?fetch:void 0);if(!o){const p=new Error("[pagepilot-visual-editor] refreshApiDataSources: global fetch is not available — pass `fetchFn`.");for(const h of r)(A=t.onError)==null||A.call(t,h,p);return{fields:n,attempted:r.length,refreshed:0,errors:Object.fromEntries(r.map(h=>[h.id,p.message]))}}const a=t.timeoutMs??1e4,l={};let s=0;const c=await Promise.all(r.map(async p=>{var C;const{apiUrl:h,apiMethod:f="GET",apiItemPath:b}=p.dataSource;try{const w=await gMe(h,{method:f,headers:{Accept:"application/json",...t.headers}},o,a);if(!w.ok)throw new Error(`GET ${h} → HTTP ${w.status}`);const v=await w.json(),B=T6(v,b);if(!B)throw new Error(`GET ${h} → response had no array of rows`);const S=B.map(E=>fMe(E,p.itemFields));return s+=1,{id:p.id,value:S}}catch(w){const v=w instanceof Error?w:new Error(String(w));return l[p.id]=v.message,(C=t.onError)==null||C.call(t,p,v),null}}));if(s===0)return{fields:n,attempted:r.length,refreshed:0,errors:l};const u=new Map(c.filter(Boolean).map(p=>[p.id,p.value]));return{fields:n.map(p=>u.has(p.id)?{...p,value:u.get(p.id)}:p),attempted:r.length,refreshed:s,errors:l}}async function i$(e,t={}){var r,o;const n=(o=(r=e==null?void 0:e.root)==null?void 0:r.data)==null?void 0:o.formFields;return o$(Array.isArray(n)?n:[],t)}function a$(e,t){if(!e)return t();try{return t()}finally{}}function mMe(e){const t=e;return!!(t.pageId&&t.baseUrl&&t.tenantId)}function bMe(e){const t=e;return!!(t.pagePath&&t.baseUrl&&t.tenantId)}function xMe(e){const t=e;return!!(t.templateId&&t.baseUrl)}function CMe(e){if(!e||typeof e!="object")return e;const t=py(e);return!t||t.length===0?e:hy(e,t)}async function Rk(e,t){if(!e||typeof e!="object")return{document:e,apiRefresh:null};const n=py(e);if(!n||n.length===0)return{document:e,apiRefresh:null};let r=n,o=null;return t.refreshApiDataSources&&(o=await i$(e,{fetchFn:t.fetchFn,headers:t.apiDataSourceHeaders,timeoutMs:t.apiDataSourceTimeoutMs,onError:t.onApiDataSourceError}),r=o.fields),{document:hy(e,r),apiRefresh:o}}const yMe=new Set(["ColumnsContainer","FlexColumns","Grid","ButtonGroup","Container","EmailLayout","PagePilotLayout","Accordion","PricingAccordion","TabsBlock","Carousel","Rating","Progress","Marquee","Timer","Pagination","Table","DemoPicker","MenuPicker","Breadcrumb","FormsPicker","AppBannerPicker","FaqPicker","Avatar","Button","Divider","Heading","Html","Image","Logo","Video","IFrame","Calendly","YouTubeUrl","Spacer","SkipLink","AccessibilityTools","Stepper","List","Text","Mdx","QuillBlock"]);function vMe(e){var r,o,a;const t=((r=e==null?void 0:e.data)==null?void 0:r.props)??{};return{type:"Text",data:{props:{text:typeof t.html=="string"&&t.html||typeof t.text=="string"&&t.text||typeof t.markdown=="string"&&t.markdown||""},style:((o=e==null?void 0:e.data)==null?void 0:o.style)??{},hidden:(a=e==null?void 0:e.data)==null?void 0:a.hidden}}}function l$(e){if(!e||typeof e!="object")return e;let t=!1;const n={};for(const[r,o]of Object.entries(e)){const a=o==null?void 0:o.type;a&&!yMe.has(a)?(n[r]=vMe(o),t=!0,console.warn(`[pagepilot-visual-editor] renderToStaticHtml: block "${r}" has unsupported type "${a}" — coerced to Text.`)):n[r]=o}return t?n:e}function D6(e,t){var l;if(!e)return"";const n=t.rootBlockId??"root",r=CMe(e),o=l$(r),a=((l=o==null?void 0:o[n])==null?void 0:l.data)??{};return a$(t.recordType,()=>Ro(o,{rootBlockId:n,injectElementIds:t.injectElementIds??!0,minifyCss:t.minifyCss??!0,includePageCSS:t.includePageCSS??!0,lang:t.lang??a.lang,skipLink:t.skipLink??a.skipLink,accessibilityTools:t.accessibilityTools??a.accessibilityTools,injectTabsScrollSyncScript:t.injectTabsScrollSyncScript,injectCarouselScript:t.injectCarouselScript,injectPaginationScript:t.injectPaginationScript,injectAnimationScript:t.injectAnimationScript,injectPostMessageScript:t.injectPostMessageScript,injectFontAssets:t.injectFontAssets,seo:t.seo,headHtml:t.headHtml,bodyBottomHtml:t.bodyBottomHtml,isBanner:t.isBanner}))}function j6(e){const t=e.fetchFn??(typeof fetch<"u"?fetch:void 0);if(!t)throw new Error("[pagepilot-visual-editor] renderToStaticHtml: global fetch is not available — pass `fetchFn`.");return t}function F6(e){const t={"Content-Type":"application/json"};return e.authToken&&(t.Authorization=`Bearer ${e.authToken}`),t}async function M6(e,t,n){const r=await n(e,t);if(!r.ok){const o=await r.text().catch(()=>"");return{ok:!1,body:null,status:r.status,text:o}}return{ok:!0,body:await r.json(),status:r.status,text:""}}async function s$(e,t,n){var u;const{wrapInDocumentShell:r=!0,headHtml:o,bodyBottomHtml:a}=n,l=Array.isArray(t==null?void 0:t.sections)?t.sections:[];if(l.length===0){const{document:d}=await Rk(((u=t==null?void 0:t.contentMetadata)==null?void 0:u.document)??e,n);return D6(d,{...n,recordType:n.recordType??"page"})}const s=await Promise.all(l.map(async d=>{var f;const A=(f=d==null?void 0:d.contentMetadata)==null?void 0:f.document;if(!A)return d;const{document:p}=await Rk(A,n),h=l$(p);return{...d,contentMetadata:{...d.contentMetadata??{},document:h}}})),{html:c}=a$(n.recordType??"page",()=>tBe(s,{rootBlockId:n.rootBlockId,injectTabsScrollSyncScript:n.injectTabsScrollSyncScript,injectCarouselScript:n.injectCarouselScript,injectFontAssets:n.injectFontAssets,isBanner:n.isBanner,seo:n.seo,wrapInDocumentShell:r,seoTitle:(t==null?void 0:t.metaTitle)??(t==null?void 0:t.title)??(t==null?void 0:t.name),seoDescription:t==null?void 0:t.metaDescription,lang:n.lang??(t==null?void 0:t.lang),extraHead:o??(t==null?void 0:t.head)??"",extraBodyBottom:a??(t==null?void 0:t.bodyBottom)??""}));return c}async function wMe(e,t){const{baseUrl:n,tenantId:r,pageId:o}=t,l=`${n.replace(/\/+$/,"")}/tenant/${r}/page/${o}`,s=j6(t),c=await M6(l,{method:"GET",headers:F6(t)},s);if(!c.ok)throw new Error(`[pagepilot-visual-editor] renderToStaticHtml: GET ${l} → ${c.status}${c.text?`: ${c.text}`:""}`);return s$(e,c.body,{...t,fetchFn:s})}async function BMe(e,t){var p,h;const{baseUrl:n,tenantId:r,pagePath:o,cache:a=!1,update:l=!0}=t,c=`${n.replace(/\/+$/,"")}/tenant/${r}/pagebypath/${encodeURIComponent(o)}?cache=${a}&update=${l}`,u=j6(t),d=await M6(c,{method:"GET",headers:F6(t)},u);if(!d.ok)throw new Error(`[pagepilot-visual-editor] renderToStaticHtml: GET ${c} → ${d.status}${d.text?`: ${d.text}`:""}`);const A=((p=d.body)==null?void 0:p.data)??((h=d.body)==null?void 0:h.payload)??d.body;return s$(e,A,{...t,fetchFn:u})}async function SMe(e){const{baseUrl:t,tenantId:n,templateId:r,isGlobal:o=!1}=e,a=t.replace(/\/+$/,""),l=j6(e),s=o?`${a}/global-template/${r}`:`${a}/tenant/${n}/template/${r}`,c=o?{"Content-Type":"application/json"}:F6(e),u=await M6(s,{method:"GET",headers:c},l);if(u.ok)return u.body;throw new Error(`[pagepilot-visual-editor] renderToStaticHtml: GET ${s} → ${u.status}${u.text?`: ${u.text}`:""}`)}function kMe(e,t){if(!t)return e;const n=new Map;for(const o of e)o!=null&&o.id&&n.set(o.id,o);if(Array.isArray(t)){for(const o of t){if(!(o!=null&&o.id))continue;const l={...n.get(o.id)??{id:o.id,name:o.id,type:"text"},...o};n.set(o.id,l)}return Array.from(n.values())}const r=Object.entries(t).filter(([,o])=>o!=null);if(r.length===0)return e;for(const[o,a]of r){const l=String(a),s=n.get(o);s?n.set(o,{...s,value:l}):n.set(o,{id:o,name:o,type:"text",value:l})}return Array.from(n.values())}async function EMe(e,t){const n=await SMe(t),r=u4e(n)??(e&&Object.keys(e).length>0?e:null);if(!r)return"";const o=By(n),a=kMe(o,t.variables),l=hy(r,a);return D6(l,t)}function IMe(e,t){return xMe(t)?EMe(e,t):bMe(t)?BMe(e,t):mMe(t)?wMe(e,t):D6(e,t)}exports.EditorContext=UG;exports.PagePilotEditor=hMe;exports.PagepilotApiClient=vE;exports.Reader=ga;exports.ReaderBlock=Wn;exports.ReaderBlockSchema=fP;exports.ReaderDocumentSchema=Jbe;exports.applyFieldPatches=Lm;exports.buildChangeTemplateDocument=b5;exports.commonjsGlobal=Ir;exports.extractApiRows=T6;exports.getAugmentedNamespace=cz;exports.getDefaultExportFromCjs=yl;exports.normalizeTemplateForLocalEditor=aa;exports.pagePilotEditorDarkTheme=t$;exports.pagePilotEditorLightTheme=n$;exports.parseTemplateConfiguration=is;exports.refreshApiDataSources=o$;exports.refreshDocumentApiDataSources=i$;exports.renderToStaticHtml=IMe;exports.renderToStaticMarkup=Ro;exports.resetDocument=wn;exports.resetPagePilotEditorTranslations=AU;exports.setDocument=pt;exports.setPagePilotEditorTranslations=CE;
@@ -1,4 +1,4 @@
1
- "use strict";const fe=require("./index-C-4OVLjk.cjs"),It=require("./_commonjs-dynamic-modules-DMkBISW1.cjs");function zl(e,n){for(var t=0;t<n.length;t++){const i=n[t];if(typeof i!="string"&&!Array.isArray(i)){for(const r in i)if(r!=="default"&&!(r in e)){const a=Object.getOwnPropertyDescriptor(i,r);a&&Object.defineProperty(e,r,a.get?a:{enumerable:!0,get:()=>i[r]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var nn={},da="1.13.8",Ro=typeof self=="object"&&self.self===self&&self||typeof global=="object"&&global.global===global&&global||Function("return this")()||{},ui=Array.prototype,la=Object.prototype,No=typeof Symbol<"u"?Symbol.prototype:null,Xl=ui.push,Ft=ui.slice,mt=la.toString,Vl=la.hasOwnProperty,ku=typeof ArrayBuffer<"u",Hl=typeof DataView<"u",$l=Array.isArray,Io=Object.keys,Lo=Object.create,Mo=ku&&ArrayBuffer.isView,Gl=isNaN,Zl=isFinite,Wu=!{toString:null}.propertyIsEnumerable("toString"),qo=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],Yl=Math.pow(2,53)-1;function Me(e,n){return n=n==null?e.length-1:+n,function(){for(var t=Math.max(arguments.length-n,0),i=Array(t),r=0;r<t;r++)i[r]=arguments[r+n];switch(n){case 0:return e.call(this,i);case 1:return e.call(this,arguments[0],i);case 2:return e.call(this,arguments[0],arguments[1],i)}var a=Array(n+1);for(r=0;r<n;r++)a[r]=arguments[r];return a[n]=i,e.apply(this,a)}}function An(e){var n=typeof e;return n==="function"||n==="object"&&!!e}function Ou(e){return e===null}function fa(e){return e===void 0}function ha(e){return e===!0||e===!1||mt.call(e)==="[object Boolean]"}function Ru(e){return!!(e&&e.nodeType===1)}function Ie(e){var n="[object "+e+"]";return function(t){return mt.call(t)===n}}const si=Ie("String"),pa=Ie("Number"),Nu=Ie("Date"),Iu=Ie("RegExp"),Lu=Ie("Error"),ga=Ie("Symbol"),ma=Ie("ArrayBuffer");var Mu=Ie("Function"),Kl=Ro.document&&Ro.document.childNodes;typeof/./!="function"&&typeof Int8Array!="object"&&typeof Kl!="function"&&(Mu=function(e){return typeof e=="function"||!1});const Ne=Mu,qu=Ie("Object");var Pu=Hl&&(!/\[native code\]/.test(String(DataView))||qu(new DataView(new ArrayBuffer(8)))),ba=typeof Map<"u"&&qu(new Map),Ql=Ie("DataView");function Jl(e){return e!=null&&Ne(e.getInt8)&&ma(e.buffer)}const bt=Pu?Jl:Ql,Fn=$l||Ie("Array");function Cn(e,n){return e!=null&&Vl.call(e,n)}var aa=Ie("Arguments");(function(){aa(arguments)||(aa=function(e){return Cn(e,"callee")})})();const di=aa;function ju(e){return!ga(e)&&Zl(e)&&!isNaN(parseFloat(e))}function ya(e){return pa(e)&&Gl(e)}function Da(e){return function(){return e}}function zu(e){return function(n){var t=e(n);return typeof t=="number"&&t>=0&&t<=Yl}}function Xu(e){return function(n){return n==null?void 0:n[e]}}const Zt=Xu("byteLength"),ef=zu(Zt);var nf=/\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;function tf(e){return Mo?Mo(e)&&!bt(e):ef(e)&&nf.test(mt.call(e))}const va=ku?tf:Da(!1),Re=Xu("length");function rf(e){for(var n={},t=e.length,i=0;i<t;++i)n[e[i]]=!0;return{contains:function(r){return n[r]===!0},push:function(r){return n[r]=!0,e.push(r)}}}function Vu(e,n){n=rf(n);var t=qo.length,i=e.constructor,r=Ne(i)&&i.prototype||la,a="constructor";for(Cn(e,a)&&!n.contains(a)&&n.push(a);t--;)a=qo[t],a in e&&e[a]!==r[a]&&!n.contains(a)&&n.push(a)}function Ee(e){if(!An(e))return[];if(Io)return Io(e);var n=[];for(var t in e)Cn(e,t)&&n.push(t);return Wu&&Vu(e,n),n}function Hu(e){if(e==null)return!0;var n=Re(e);return typeof n=="number"&&(Fn(e)||si(e)||di(e))?n===0:Re(Ee(e))===0}function xa(e,n){var t=Ee(n),i=t.length;if(e==null)return!i;for(var r=Object(e),a=0;a<i;a++){var o=t[a];if(n[o]!==r[o]||!(o in r))return!1}return!0}function ye(e){if(e instanceof ye)return e;if(!(this instanceof ye))return new ye(e);this._wrapped=e}ye.VERSION=da;ye.prototype.value=function(){return this._wrapped};ye.prototype.valueOf=ye.prototype.toJSON=ye.prototype.value;ye.prototype.toString=function(){return String(this._wrapped)};function Po(e){return new Uint8Array(e.buffer||e,e.byteOffset||0,Zt(e))}var jo="[object DataView]";function $u(e,n){for(var t=[{a:e,b:n}],i=[],r=[];t.length;){var a=t.pop();if(a===!0){i.pop(),r.pop();continue}if(e=a.a,n=a.b,e===n){if(e!==0||1/e===1/n)continue;return!1}if(e==null||n==null)return!1;if(e!==e){if(n!==n)continue;return!1}var o=typeof e;if(o!=="function"&&o!=="object"&&typeof n!="object")return!1;e instanceof ye&&(e=e._wrapped),n instanceof ye&&(n=n._wrapped);var c=mt.call(e);if(c!==mt.call(n))return!1;if(Pu&&c=="[object Object]"&&bt(e)){if(!bt(n))return!1;c=jo}switch(c){case"[object RegExp]":case"[object String]":if(""+e==""+n)continue;return!1;case"[object Number]":t.push({a:+e,b:+n});continue;case"[object Date]":case"[object Boolean]":if(+e==+n)continue;return!1;case"[object Symbol]":if(No.valueOf.call(e)===No.valueOf.call(n))continue;return!1;case"[object ArrayBuffer]":case jo:t.push({a:Po(e),b:Po(n)});continue}var u=c==="[object Array]";if(!u&&va(e)){var s=Zt(e);if(s!==Zt(n))return!1;if(e.buffer===n.buffer&&e.byteOffset===n.byteOffset)continue;u=!0}if(!u){if(typeof e!="object"||typeof n!="object")return!1;var d=e.constructor,p=n.constructor;if(d!==p&&!(Ne(d)&&d instanceof d&&Ne(p)&&p instanceof p)&&"constructor"in e&&"constructor"in n)return!1}for(var b=i.length;b--;)if(i[b]===e){if(r[b]===n)break;return!1}if(!(b>=0))if(i.push(e),r.push(n),t.push(!0),u){if(b=e.length,b!==n.length)return!1;for(;b--;)t.push({a:e[b],b:n[b]})}else{var m=Ee(e),y;if(b=m.length,Ee(n).length!==b)return!1;for(;b--;){if(y=m[b],!Cn(n,y))return!1;t.push({a:e[y],b:n[y]})}}}return!0}function it(e){if(!An(e))return[];var n=[];for(var t in e)n.push(t);return Wu&&Vu(e,n),n}function _a(e){var n=Re(e);return function(t){if(t==null)return!1;var i=it(t);if(Re(i))return!1;for(var r=0;r<n;r++)if(!Ne(t[e[r]]))return!1;return e!==Yu||!Ne(t[Ua])}}var Ua="forEach",Gu="has",Ta=["clear","delete"],Zu=["get",Gu,"set"],af=Ta.concat(Ua,Zu),Yu=Ta.concat(Zu),of=["add"].concat(Ta,Ua,Gu);const Ku=ba?_a(af):Ie("Map"),Qu=ba?_a(Yu):Ie("WeakMap"),Ju=ba?_a(of):Ie("Set"),es=Ie("WeakSet");function Ln(e){for(var n=Ee(e),t=n.length,i=Array(t),r=0;r<t;r++)i[r]=e[n[r]];return i}function ns(e){for(var n=Ee(e),t=n.length,i=Array(t),r=0;r<t;r++)i[r]=[n[r],e[n[r]]];return i}function wa(e){for(var n={},t=Ee(e),i=0,r=t.length;i<r;i++)n[e[t[i]]]=t[i];return n}function yt(e){var n=[];for(var t in e)Ne(e[t])&&n.push(t);return n.sort()}function Ea(e,n){return function(t){var i=arguments.length;if(n&&(t=Object(t)),i<2||t==null)return t;for(var r=1;r<i;r++)for(var a=arguments[r],o=e(a),c=o.length,u=0;u<c;u++){var s=o[u];(!n||t[s]===void 0)&&(t[s]=a[s])}return t}}const Aa=Ea(it),Yn=Ea(Ee),Fa=Ea(it,!0);function cf(){return function(){}}function ts(e){if(!An(e))return{};if(Lo)return Lo(e);var n=cf();n.prototype=e;var t=new n;return n.prototype=null,t}function is(e,n){var t=ts(e);return n&&Yn(t,n),t}function rs(e){return An(e)?Fn(e)?e.slice():Aa({},e):e}function as(e,n){return n(e),e}function Ca(e){return Fn(e)?e:[e]}ye.toPath=Ca;function Ct(e){return ye.toPath(e)}function Sa(e,n){for(var t=n.length,i=0;i<t;i++){if(e==null)return;e=e[n[i]]}return t?e:void 0}function Ba(e,n,t){var i=Sa(e,Ct(n));return fa(i)?t:i}function os(e,n){n=Ct(n);for(var t=n.length,i=0;i<t;i++){var r=n[i];if(!Cn(e,r))return!1;e=e[r]}return!!t}function li(e){return e}function On(e){return e=Yn({},e),function(n){return xa(n,e)}}function fi(e){return e=Ct(e),function(n){return Sa(n,e)}}function St(e,n,t){if(n===void 0)return e;switch(t??3){case 1:return function(i){return e.call(n,i)};case 3:return function(i,r,a){return e.call(n,i,r,a)};case 4:return function(i,r,a,o){return e.call(n,i,r,a,o)}}return function(){return e.apply(n,arguments)}}function cs(e,n,t){return e==null?li:Ne(e)?St(e,n,t):An(e)&&!Fn(e)?On(e):fi(e)}function hi(e,n){return cs(e,n,1/0)}ye.iteratee=hi;function ze(e,n,t){return ye.iteratee!==hi?ye.iteratee(e,n):cs(e,n,t)}function us(e,n,t){n=ze(n,t);for(var i=Ee(e),r=i.length,a={},o=0;o<r;o++){var c=i[o];a[c]=n(e[c],c,e)}return a}function ka(){}function ss(e){return e==null?ka:function(n){return Ba(e,n)}}function ds(e,n,t){var i=Array(Math.max(0,e));n=St(n,t,1);for(var r=0;r<e;r++)i[r]=n(r);return i}function Yt(e,n){return n==null&&(n=e,e=0),e+Math.floor(Math.random()*(n-e+1))}const Kn=Date.now||function(){return new Date().getTime()};function ls(e){var n=function(a){return e[a]},t="(?:"+Ee(e).join("|")+")",i=RegExp(t),r=RegExp(t,"g");return function(a){return a=a==null?"":""+a,i.test(a)?a.replace(r,n):a}}const fs={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},hs=ls(fs),uf=wa(fs),ps=ls(uf),gs=ye.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var Yi=/(.)^/,sf={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},df=/\\|'|\r|\n|\u2028|\u2029/g;function lf(e){return"\\"+sf[e]}var ff=/^\s*(\w|\$)+\s*$/;function ms(e,n,t){!n&&t&&(n=t),n=Fa({},n,ye.templateSettings);var i=RegExp([(n.escape||Yi).source,(n.interpolate||Yi).source,(n.evaluate||Yi).source].join("|")+"|$","g"),r=0,a="__p+='";e.replace(i,function(s,d,p,b,m){return a+=e.slice(r,m).replace(df,lf),r=m+s.length,d?a+=`'+
1
+ "use strict";const fe=require("./index-BO4IFeAW.cjs"),It=require("./_commonjs-dynamic-modules-DMkBISW1.cjs");function zl(e,n){for(var t=0;t<n.length;t++){const i=n[t];if(typeof i!="string"&&!Array.isArray(i)){for(const r in i)if(r!=="default"&&!(r in e)){const a=Object.getOwnPropertyDescriptor(i,r);a&&Object.defineProperty(e,r,a.get?a:{enumerable:!0,get:()=>i[r]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var nn={},da="1.13.8",Ro=typeof self=="object"&&self.self===self&&self||typeof global=="object"&&global.global===global&&global||Function("return this")()||{},ui=Array.prototype,la=Object.prototype,No=typeof Symbol<"u"?Symbol.prototype:null,Xl=ui.push,Ft=ui.slice,mt=la.toString,Vl=la.hasOwnProperty,ku=typeof ArrayBuffer<"u",Hl=typeof DataView<"u",$l=Array.isArray,Io=Object.keys,Lo=Object.create,Mo=ku&&ArrayBuffer.isView,Gl=isNaN,Zl=isFinite,Wu=!{toString:null}.propertyIsEnumerable("toString"),qo=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],Yl=Math.pow(2,53)-1;function Me(e,n){return n=n==null?e.length-1:+n,function(){for(var t=Math.max(arguments.length-n,0),i=Array(t),r=0;r<t;r++)i[r]=arguments[r+n];switch(n){case 0:return e.call(this,i);case 1:return e.call(this,arguments[0],i);case 2:return e.call(this,arguments[0],arguments[1],i)}var a=Array(n+1);for(r=0;r<n;r++)a[r]=arguments[r];return a[n]=i,e.apply(this,a)}}function An(e){var n=typeof e;return n==="function"||n==="object"&&!!e}function Ou(e){return e===null}function fa(e){return e===void 0}function ha(e){return e===!0||e===!1||mt.call(e)==="[object Boolean]"}function Ru(e){return!!(e&&e.nodeType===1)}function Ie(e){var n="[object "+e+"]";return function(t){return mt.call(t)===n}}const si=Ie("String"),pa=Ie("Number"),Nu=Ie("Date"),Iu=Ie("RegExp"),Lu=Ie("Error"),ga=Ie("Symbol"),ma=Ie("ArrayBuffer");var Mu=Ie("Function"),Kl=Ro.document&&Ro.document.childNodes;typeof/./!="function"&&typeof Int8Array!="object"&&typeof Kl!="function"&&(Mu=function(e){return typeof e=="function"||!1});const Ne=Mu,qu=Ie("Object");var Pu=Hl&&(!/\[native code\]/.test(String(DataView))||qu(new DataView(new ArrayBuffer(8)))),ba=typeof Map<"u"&&qu(new Map),Ql=Ie("DataView");function Jl(e){return e!=null&&Ne(e.getInt8)&&ma(e.buffer)}const bt=Pu?Jl:Ql,Fn=$l||Ie("Array");function Cn(e,n){return e!=null&&Vl.call(e,n)}var aa=Ie("Arguments");(function(){aa(arguments)||(aa=function(e){return Cn(e,"callee")})})();const di=aa;function ju(e){return!ga(e)&&Zl(e)&&!isNaN(parseFloat(e))}function ya(e){return pa(e)&&Gl(e)}function Da(e){return function(){return e}}function zu(e){return function(n){var t=e(n);return typeof t=="number"&&t>=0&&t<=Yl}}function Xu(e){return function(n){return n==null?void 0:n[e]}}const Zt=Xu("byteLength"),ef=zu(Zt);var nf=/\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;function tf(e){return Mo?Mo(e)&&!bt(e):ef(e)&&nf.test(mt.call(e))}const va=ku?tf:Da(!1),Re=Xu("length");function rf(e){for(var n={},t=e.length,i=0;i<t;++i)n[e[i]]=!0;return{contains:function(r){return n[r]===!0},push:function(r){return n[r]=!0,e.push(r)}}}function Vu(e,n){n=rf(n);var t=qo.length,i=e.constructor,r=Ne(i)&&i.prototype||la,a="constructor";for(Cn(e,a)&&!n.contains(a)&&n.push(a);t--;)a=qo[t],a in e&&e[a]!==r[a]&&!n.contains(a)&&n.push(a)}function Ee(e){if(!An(e))return[];if(Io)return Io(e);var n=[];for(var t in e)Cn(e,t)&&n.push(t);return Wu&&Vu(e,n),n}function Hu(e){if(e==null)return!0;var n=Re(e);return typeof n=="number"&&(Fn(e)||si(e)||di(e))?n===0:Re(Ee(e))===0}function xa(e,n){var t=Ee(n),i=t.length;if(e==null)return!i;for(var r=Object(e),a=0;a<i;a++){var o=t[a];if(n[o]!==r[o]||!(o in r))return!1}return!0}function ye(e){if(e instanceof ye)return e;if(!(this instanceof ye))return new ye(e);this._wrapped=e}ye.VERSION=da;ye.prototype.value=function(){return this._wrapped};ye.prototype.valueOf=ye.prototype.toJSON=ye.prototype.value;ye.prototype.toString=function(){return String(this._wrapped)};function Po(e){return new Uint8Array(e.buffer||e,e.byteOffset||0,Zt(e))}var jo="[object DataView]";function $u(e,n){for(var t=[{a:e,b:n}],i=[],r=[];t.length;){var a=t.pop();if(a===!0){i.pop(),r.pop();continue}if(e=a.a,n=a.b,e===n){if(e!==0||1/e===1/n)continue;return!1}if(e==null||n==null)return!1;if(e!==e){if(n!==n)continue;return!1}var o=typeof e;if(o!=="function"&&o!=="object"&&typeof n!="object")return!1;e instanceof ye&&(e=e._wrapped),n instanceof ye&&(n=n._wrapped);var c=mt.call(e);if(c!==mt.call(n))return!1;if(Pu&&c=="[object Object]"&&bt(e)){if(!bt(n))return!1;c=jo}switch(c){case"[object RegExp]":case"[object String]":if(""+e==""+n)continue;return!1;case"[object Number]":t.push({a:+e,b:+n});continue;case"[object Date]":case"[object Boolean]":if(+e==+n)continue;return!1;case"[object Symbol]":if(No.valueOf.call(e)===No.valueOf.call(n))continue;return!1;case"[object ArrayBuffer]":case jo:t.push({a:Po(e),b:Po(n)});continue}var u=c==="[object Array]";if(!u&&va(e)){var s=Zt(e);if(s!==Zt(n))return!1;if(e.buffer===n.buffer&&e.byteOffset===n.byteOffset)continue;u=!0}if(!u){if(typeof e!="object"||typeof n!="object")return!1;var d=e.constructor,p=n.constructor;if(d!==p&&!(Ne(d)&&d instanceof d&&Ne(p)&&p instanceof p)&&"constructor"in e&&"constructor"in n)return!1}for(var b=i.length;b--;)if(i[b]===e){if(r[b]===n)break;return!1}if(!(b>=0))if(i.push(e),r.push(n),t.push(!0),u){if(b=e.length,b!==n.length)return!1;for(;b--;)t.push({a:e[b],b:n[b]})}else{var m=Ee(e),y;if(b=m.length,Ee(n).length!==b)return!1;for(;b--;){if(y=m[b],!Cn(n,y))return!1;t.push({a:e[y],b:n[y]})}}}return!0}function it(e){if(!An(e))return[];var n=[];for(var t in e)n.push(t);return Wu&&Vu(e,n),n}function _a(e){var n=Re(e);return function(t){if(t==null)return!1;var i=it(t);if(Re(i))return!1;for(var r=0;r<n;r++)if(!Ne(t[e[r]]))return!1;return e!==Yu||!Ne(t[Ua])}}var Ua="forEach",Gu="has",Ta=["clear","delete"],Zu=["get",Gu,"set"],af=Ta.concat(Ua,Zu),Yu=Ta.concat(Zu),of=["add"].concat(Ta,Ua,Gu);const Ku=ba?_a(af):Ie("Map"),Qu=ba?_a(Yu):Ie("WeakMap"),Ju=ba?_a(of):Ie("Set"),es=Ie("WeakSet");function Ln(e){for(var n=Ee(e),t=n.length,i=Array(t),r=0;r<t;r++)i[r]=e[n[r]];return i}function ns(e){for(var n=Ee(e),t=n.length,i=Array(t),r=0;r<t;r++)i[r]=[n[r],e[n[r]]];return i}function wa(e){for(var n={},t=Ee(e),i=0,r=t.length;i<r;i++)n[e[t[i]]]=t[i];return n}function yt(e){var n=[];for(var t in e)Ne(e[t])&&n.push(t);return n.sort()}function Ea(e,n){return function(t){var i=arguments.length;if(n&&(t=Object(t)),i<2||t==null)return t;for(var r=1;r<i;r++)for(var a=arguments[r],o=e(a),c=o.length,u=0;u<c;u++){var s=o[u];(!n||t[s]===void 0)&&(t[s]=a[s])}return t}}const Aa=Ea(it),Yn=Ea(Ee),Fa=Ea(it,!0);function cf(){return function(){}}function ts(e){if(!An(e))return{};if(Lo)return Lo(e);var n=cf();n.prototype=e;var t=new n;return n.prototype=null,t}function is(e,n){var t=ts(e);return n&&Yn(t,n),t}function rs(e){return An(e)?Fn(e)?e.slice():Aa({},e):e}function as(e,n){return n(e),e}function Ca(e){return Fn(e)?e:[e]}ye.toPath=Ca;function Ct(e){return ye.toPath(e)}function Sa(e,n){for(var t=n.length,i=0;i<t;i++){if(e==null)return;e=e[n[i]]}return t?e:void 0}function Ba(e,n,t){var i=Sa(e,Ct(n));return fa(i)?t:i}function os(e,n){n=Ct(n);for(var t=n.length,i=0;i<t;i++){var r=n[i];if(!Cn(e,r))return!1;e=e[r]}return!!t}function li(e){return e}function On(e){return e=Yn({},e),function(n){return xa(n,e)}}function fi(e){return e=Ct(e),function(n){return Sa(n,e)}}function St(e,n,t){if(n===void 0)return e;switch(t??3){case 1:return function(i){return e.call(n,i)};case 3:return function(i,r,a){return e.call(n,i,r,a)};case 4:return function(i,r,a,o){return e.call(n,i,r,a,o)}}return function(){return e.apply(n,arguments)}}function cs(e,n,t){return e==null?li:Ne(e)?St(e,n,t):An(e)&&!Fn(e)?On(e):fi(e)}function hi(e,n){return cs(e,n,1/0)}ye.iteratee=hi;function ze(e,n,t){return ye.iteratee!==hi?ye.iteratee(e,n):cs(e,n,t)}function us(e,n,t){n=ze(n,t);for(var i=Ee(e),r=i.length,a={},o=0;o<r;o++){var c=i[o];a[c]=n(e[c],c,e)}return a}function ka(){}function ss(e){return e==null?ka:function(n){return Ba(e,n)}}function ds(e,n,t){var i=Array(Math.max(0,e));n=St(n,t,1);for(var r=0;r<e;r++)i[r]=n(r);return i}function Yt(e,n){return n==null&&(n=e,e=0),e+Math.floor(Math.random()*(n-e+1))}const Kn=Date.now||function(){return new Date().getTime()};function ls(e){var n=function(a){return e[a]},t="(?:"+Ee(e).join("|")+")",i=RegExp(t),r=RegExp(t,"g");return function(a){return a=a==null?"":""+a,i.test(a)?a.replace(r,n):a}}const fs={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},hs=ls(fs),uf=wa(fs),ps=ls(uf),gs=ye.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var Yi=/(.)^/,sf={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},df=/\\|'|\r|\n|\u2028|\u2029/g;function lf(e){return"\\"+sf[e]}var ff=/^\s*(\w|\$)+\s*$/;function ms(e,n,t){!n&&t&&(n=t),n=Fa({},n,ye.templateSettings);var i=RegExp([(n.escape||Yi).source,(n.interpolate||Yi).source,(n.evaluate||Yi).source].join("|")+"|$","g"),r=0,a="__p+='";e.replace(i,function(s,d,p,b,m){return a+=e.slice(r,m).replace(df,lf),r=m+s.length,d?a+=`'+
2
2
  ((__t=(`+d+`))==null?'':_.escape(__t))+
3
3
  '`:p?a+=`'+
4
4
  ((__t=(`+p+`))==null?'':__t)+
@@ -1,4 +1,4 @@
1
- import { g as jl, c as fe } from "./index-DvEcR48I.js";
1
+ import { g as jl, c as fe } from "./index-LXr2Pc6N.js";
2
2
  import { c as It } from "./_commonjs-dynamic-modules-BpilXLfW.js";
3
3
  function Xl(e, n) {
4
4
  for (var t = 0; t < n.length; t++) {
@@ -62076,7 +62076,7 @@ function Lye(e) {
62076
62076
  return $O(t);
62077
62077
  }
62078
62078
  async function Pye(e) {
62079
- const t = await import("./xlsx-D_Hwvvx2.js").then((i) => i.x), n = await e.arrayBuffer(), r = t.read(new Uint8Array(n), { type: "array", cellDates: !0 }), o = [];
62079
+ const t = await import("./xlsx-BTBqP-DW.js").then((i) => i.x), n = await e.arrayBuffer(), r = t.read(new Uint8Array(n), { type: "array", cellDates: !0 }), o = [];
62080
62080
  for (const i of r.SheetNames) {
62081
62081
  const l = r.Sheets[i], c = t.utils.sheet_to_json(l, {
62082
62082
  header: 1,
@@ -62090,7 +62090,7 @@ async function Pye(e) {
62090
62090
  return o;
62091
62091
  }
62092
62092
  async function Rye(e) {
62093
- const t = await import("./index-BUtnK58L.js").then((o) => o.i), n = await e.arrayBuffer(), { value: r } = await t.convertToHtml({ arrayBuffer: n });
62093
+ const t = await import("./index-CnLfsbws.js").then((o) => o.i), n = await e.arrayBuffer(), { value: r } = await t.convertToHtml({ arrayBuffer: n });
62094
62094
  return r ? Iye(r).map((o, i) => ({ name: `Table ${i + 1}`, table: o })) : [];
62095
62095
  }
62096
62096
  function _ye(e, t, n, r, o, i, l = 50, s = 20) {
@@ -106157,6 +106157,9 @@ function R9(e, t) {
106157
106157
  accessibilityTools: t.accessibilityTools ?? i.accessibilityTools,
106158
106158
  injectTabsScrollSyncScript: t.injectTabsScrollSyncScript,
106159
106159
  injectCarouselScript: t.injectCarouselScript,
106160
+ injectPaginationScript: t.injectPaginationScript,
106161
+ injectAnimationScript: t.injectAnimationScript,
106162
+ injectPostMessageScript: t.injectPostMessageScript,
106160
106163
  injectFontAssets: t.injectFontAssets,
106161
106164
  seo: t.seo,
106162
106165
  headHtml: t.headHtml,
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-C-4OVLjk.cjs");exports.EditorContext=e.EditorContext;exports.PagePilotEditor=e.PagePilotEditor;exports.PagepilotApiClient=e.PagepilotApiClient;exports.Reader=e.Reader;exports.ReaderBlock=e.ReaderBlock;exports.ReaderBlockSchema=e.ReaderBlockSchema;exports.ReaderDocumentSchema=e.ReaderDocumentSchema;exports.applyFieldPatches=e.applyFieldPatches;exports.buildChangeTemplateDocument=e.buildChangeTemplateDocument;exports.extractApiRows=e.extractApiRows;exports.normalizeTemplateForLocalEditor=e.normalizeTemplateForLocalEditor;exports.pagePilotEditorDarkTheme=e.pagePilotEditorDarkTheme;exports.pagePilotEditorLightTheme=e.pagePilotEditorLightTheme;exports.parseTemplateConfiguration=e.parseTemplateConfiguration;exports.refreshApiDataSources=e.refreshApiDataSources;exports.refreshDocumentApiDataSources=e.refreshDocumentApiDataSources;exports.renderToStaticHtml=e.renderToStaticHtml;exports.renderToStaticMarkup=e.renderToStaticMarkup;exports.resetDocument=e.resetDocument;exports.resetPagePilotEditorTranslations=e.resetPagePilotEditorTranslations;exports.setDocument=e.setDocument;exports.setPagePilotEditorTranslations=e.setPagePilotEditorTranslations;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BO4IFeAW.cjs");exports.EditorContext=e.EditorContext;exports.PagePilotEditor=e.PagePilotEditor;exports.PagepilotApiClient=e.PagepilotApiClient;exports.Reader=e.Reader;exports.ReaderBlock=e.ReaderBlock;exports.ReaderBlockSchema=e.ReaderBlockSchema;exports.ReaderDocumentSchema=e.ReaderDocumentSchema;exports.applyFieldPatches=e.applyFieldPatches;exports.buildChangeTemplateDocument=e.buildChangeTemplateDocument;exports.extractApiRows=e.extractApiRows;exports.normalizeTemplateForLocalEditor=e.normalizeTemplateForLocalEditor;exports.pagePilotEditorDarkTheme=e.pagePilotEditorDarkTheme;exports.pagePilotEditorLightTheme=e.pagePilotEditorLightTheme;exports.parseTemplateConfiguration=e.parseTemplateConfiguration;exports.refreshApiDataSources=e.refreshApiDataSources;exports.refreshDocumentApiDataSources=e.refreshDocumentApiDataSources;exports.renderToStaticHtml=e.renderToStaticHtml;exports.renderToStaticMarkup=e.renderToStaticMarkup;exports.resetDocument=e.resetDocument;exports.resetPagePilotEditorTranslations=e.resetPagePilotEditorTranslations;exports.setDocument=e.setDocument;exports.setPagePilotEditorTranslations=e.setPagePilotEditorTranslations;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { E as t, P as s, b as o, R as r, d as i, e as l, f as n, h as c, i as d, j as m, n as p, p as u, k as P, l as h, r as g, m as T, o as D, q as E, s as R, t as S, u as f, v as k } from "./index-DvEcR48I.js";
1
+ import { E as t, P as s, b as o, R as r, d as i, e as l, f as n, h as c, i as d, j as m, n as p, p as u, k as P, l as h, r as g, m as T, o as D, q as E, s as R, t as S, u as f, v as k } from "./index-LXr2Pc6N.js";
2
2
  export {
3
3
  t as EditorContext,
4
4
  s as PagePilotEditor,
package/dist/render.cjs CHANGED
@@ -1029,4 +1029,4 @@ ${e}
1029
1029
  ${h}
1030
1030
  </body>
1031
1031
  </html>`}function tI(e,t={}){const n=t.includeExternalSections??!0,r=t.wrapInDocumentShell??!0,o=[],a=e.map(l=>{var c;if($d(l)){const h=Xy(l);return n&&h&&o.push(h),{...l,content:h}}const s=(c=l==null?void 0:l.contentMetadata)==null?void 0:c.document;if(!s)return l!=null&&l.content&&o.push(String(l.content)),l;const u=Qy(s,t);return u&&o.push(u),{...l,content:u,contentMetadata:{...l.contentMetadata??{},document:s}}}),i=o.join(`
1032
- `);return r?{html:eI(i,e,t),sectionHtml:o,flushedSections:a}:{html:i,sectionHtml:o,flushedSections:a}}function nI(e){var a,i,l,s,u,c,h,d,f,p,b;if(!e)return[];const t=e.configuration??{},n=(i=(a=t==null?void 0:t.root)==null?void 0:a.data)==null?void 0:i.formFields;if(Array.isArray(n)&&n.length>0)return n;if(t!=null&&t.isIndividualBlock&&Array.isArray(t.formFields)&&t.formFields.length>0)return t.formFields;const r=Array.isArray(t==null?void 0:t.steps)?t.steps:Array.isArray(t==null?void 0:t.slides)?t.slides:null;if(r){const x=new Set,w=[];for(const k of r){const S=(c=(u=(s=(l=k==null?void 0:k.contentMetadata)==null?void 0:l.document)==null?void 0:s.root)==null?void 0:u.data)==null?void 0:c.formFields;if(Array.isArray(S))for(const v of S)!(v!=null&&v.id)||x.has(v.id)||(x.add(v.id),w.push(v))}if(w.length>0)return w}const o=(b=(p=(f=(d=(h=t==null?void 0:t.step)==null?void 0:h.contentMetadata)==null?void 0:d.document)==null?void 0:f.root)==null?void 0:p.data)==null?void 0:b.formFields;return Array.isArray(o)&&o.length>0?o:Array.isArray(e.formFields)?e.formFields:[]}function rI(e){var n,r,o,a,i,l,s;if(!e||typeof e!="object")return null;const t=e.configuration;if(!t||typeof t!="object")return null;if(t.root)return t;if(t.isIndividualBlock&&typeof t.rootBlockId=="string"&&t.blocks&&typeof t.blocks=="object"&&t.blocks[t.rootBlockId]){const u=Array.isArray(t.formFields)?t.formFields:[];return{...t.blocks,root:{type:"PagePilotLayout",data:{backdropColor:"#FFFFFF",canvasColor:"#FFFFFF",textColor:"#262626",fontFamily:"MODERN_SANS",childrenIds:[t.rootBlockId],maxWidth:"100%",formFields:u}}}}return(o=(r=(n=t.content)==null?void 0:n.contentMetadata)==null?void 0:r.document)!=null&&o.root?t.content.contentMetadata.document:(i=(a=t.contentMetadata)==null?void 0:a.document)!=null&&i.root?t.contentMetadata.document:(s=(l=e.contentMetadata)==null?void 0:l.document)!=null&&s.root?e.contentMetadata.document:null}function ac(e,t){return t.split(".").map(n=>n.trim()).filter(Boolean).reduce((n,r)=>n==null?n:n[r],e)}function Di(e,t){if(t){const n=ac(e,t);if(Array.isArray(n))return n;const r=Di(e);if(r){const o=r.map(a=>ac(a,t)).filter(a=>a&&typeof a=="object");if(o.length>0)return o}}if(Array.isArray(e))return e;if(e&&typeof e=="object"){for(const n of["data","rows","results","items","records"])if(Array.isArray(e[n]))return e[n]}return null}function oI(e,t){if(!t||t.length===0){const r={};for(const[o,a]of Object.entries(e))a!=null&&(r[o]=String(a));return r}const n={};for(const r of t){const o=e[r.id];o!=null&&o!==""&&(n[r.id]=String(o))}return e.id!==void 0&&n.id===void 0&&(n.id=String(e.id)),n}async function aI(e,t,n,r){if(typeof AbortController>"u")return n(e,t);const o=new AbortController,a=setTimeout(()=>o.abort(),r);try{return await n(e,{...t,signal:o.signal})}finally{clearTimeout(a)}}async function _d(e,t={}){var h;const n=Array.isArray(e)?e:[],r=n.filter(d=>{var f,p;return((f=d==null?void 0:d.dataSource)==null?void 0:f.type)==="api"&&((p=d==null?void 0:d.dataSource)==null?void 0:p.apiUrl)});if(r.length===0)return{fields:n,attempted:0,refreshed:0,errors:{}};const o=t.fetchFn??(typeof fetch<"u"?fetch:void 0);if(!o){const d=new Error("[pagepilot-visual-editor] refreshApiDataSources: global fetch is not available — pass `fetchFn`.");for(const f of r)(h=t.onError)==null||h.call(t,f,d);return{fields:n,attempted:r.length,refreshed:0,errors:Object.fromEntries(r.map(f=>[f.id,d.message]))}}const a=t.timeoutMs??1e4,i={};let l=0;const s=await Promise.all(r.map(async d=>{var x;const{apiUrl:f,apiMethod:p="GET",apiItemPath:b}=d.dataSource;try{const w=await aI(f,{method:p,headers:{Accept:"application/json",...t.headers}},o,a);if(!w.ok)throw new Error(`GET ${f} → HTTP ${w.status}`);const k=await w.json(),S=Di(k,b);if(!S)throw new Error(`GET ${f} → response had no array of rows`);const v=S.map(_=>oI(_,d.itemFields));return l+=1,{id:d.id,value:v}}catch(w){const k=w instanceof Error?w:new Error(String(w));return i[d.id]=k.message,(x=t.onError)==null||x.call(t,d,k),null}}));if(l===0)return{fields:n,attempted:r.length,refreshed:0,errors:i};const u=new Map(s.filter(Boolean).map(d=>[d.id,d.value]));return{fields:n.map(d=>u.has(d.id)?{...d,value:u.get(d.id)}:d),attempted:r.length,refreshed:l,errors:i}}async function Cd(e,t={}){var r,o;const n=(o=(r=e==null?void 0:e.root)==null?void 0:r.data)==null?void 0:o.formFields;return _d(Array.isArray(n)?n:[],t)}function Ad(e,t){if(!e)return t();El(e);try{return t()}finally{El(null)}}function iI(e){const t=e;return!!(t.pageId&&t.baseUrl&&t.tenantId)}function lI(e){const t=e;return!!(t.pagePath&&t.baseUrl&&t.tenantId)}function sI(e){const t=e;return!!(t.templateId&&t.baseUrl)}function cI(e){if(!e||typeof e!="object")return e;const t=Oi(e);return!t||t.length===0?e:zi(e,t)}async function ic(e,t){if(!e||typeof e!="object")return{document:e,apiRefresh:null};const n=Oi(e);if(!n||n.length===0)return{document:e,apiRefresh:null};let r=n,o=null;return t.refreshApiDataSources&&(o=await Cd(e,{fetchFn:t.fetchFn,headers:t.apiDataSourceHeaders,timeoutMs:t.apiDataSourceTimeoutMs,onError:t.onApiDataSourceError}),r=o.fields),{document:zi(e,r),apiRefresh:o}}const uI=new Set(["ColumnsContainer","FlexColumns","Grid","ButtonGroup","Container","EmailLayout","PagePilotLayout","Accordion","PricingAccordion","TabsBlock","Carousel","Rating","Progress","Marquee","Timer","Pagination","Table","DemoPicker","MenuPicker","Breadcrumb","FormsPicker","AppBannerPicker","FaqPicker","Avatar","Button","Divider","Heading","Html","Image","Logo","Video","IFrame","Calendly","YouTubeUrl","Spacer","SkipLink","AccessibilityTools","Stepper","List","Text","Mdx","QuillBlock"]);function dI(e){var r,o,a;const t=((r=e==null?void 0:e.data)==null?void 0:r.props)??{};return{type:"Text",data:{props:{text:typeof t.html=="string"&&t.html||typeof t.text=="string"&&t.text||typeof t.markdown=="string"&&t.markdown||""},style:((o=e==null?void 0:e.data)==null?void 0:o.style)??{},hidden:(a=e==null?void 0:e.data)==null?void 0:a.hidden}}}function yd(e){if(!e||typeof e!="object")return e;let t=!1;const n={};for(const[r,o]of Object.entries(e)){const a=o==null?void 0:o.type;a&&!uI.has(a)?(n[r]=dI(o),t=!0,console.warn(`[pagepilot-visual-editor] renderToStaticHtml: block "${r}" has unsupported type "${a}" — coerced to Text.`)):n[r]=o}return t?n:e}function Fi(e,t){var i;if(!e)return"";const n=t.rootBlockId??"root",r=cI(e),o=yd(r),a=((i=o==null?void 0:o[n])==null?void 0:i.data)??{};return Ad(t.recordType,()=>Bi(o,{rootBlockId:n,injectElementIds:t.injectElementIds??!0,minifyCss:t.minifyCss??!0,includePageCSS:t.includePageCSS??!0,lang:t.lang??a.lang,skipLink:t.skipLink??a.skipLink,accessibilityTools:t.accessibilityTools??a.accessibilityTools,injectTabsScrollSyncScript:t.injectTabsScrollSyncScript,injectCarouselScript:t.injectCarouselScript,injectFontAssets:t.injectFontAssets,seo:t.seo,headHtml:t.headHtml,bodyBottomHtml:t.bodyBottomHtml,isBanner:t.isBanner}))}function Hi(e){const t=e.fetchFn??(typeof fetch<"u"?fetch:void 0);if(!t)throw new Error("[pagepilot-visual-editor] renderToStaticHtml: global fetch is not available — pass `fetchFn`.");return t}function Gi(e){const t={"Content-Type":"application/json"};return e.authToken&&(t.Authorization=`Bearer ${e.authToken}`),t}async function Wi(e,t,n){const r=await n(e,t);if(!r.ok){const o=await r.text().catch(()=>"");return{ok:!1,body:null,status:r.status,text:o}}return{ok:!0,body:await r.json(),status:r.status,text:""}}async function Id(e,t,n){var u;const{wrapInDocumentShell:r=!0,headHtml:o,bodyBottomHtml:a}=n,i=Array.isArray(t==null?void 0:t.sections)?t.sections:[];if(i.length===0){const{document:c}=await ic(((u=t==null?void 0:t.contentMetadata)==null?void 0:u.document)??e,n);return Fi(c,{...n,recordType:n.recordType??"page"})}const l=await Promise.all(i.map(async c=>{var p;const h=(p=c==null?void 0:c.contentMetadata)==null?void 0:p.document;if(!h)return c;const{document:d}=await ic(h,n),f=yd(d);return{...c,contentMetadata:{...c.contentMetadata??{},document:f}}})),{html:s}=Ad(n.recordType??"page",()=>tI(l,{rootBlockId:n.rootBlockId,injectTabsScrollSyncScript:n.injectTabsScrollSyncScript,injectCarouselScript:n.injectCarouselScript,injectFontAssets:n.injectFontAssets,isBanner:n.isBanner,seo:n.seo,wrapInDocumentShell:r,seoTitle:(t==null?void 0:t.metaTitle)??(t==null?void 0:t.title)??(t==null?void 0:t.name),seoDescription:t==null?void 0:t.metaDescription,lang:n.lang??(t==null?void 0:t.lang),extraHead:o??(t==null?void 0:t.head)??"",extraBodyBottom:a??(t==null?void 0:t.bodyBottom)??""}));return s}async function hI(e,t){const{baseUrl:n,tenantId:r,pageId:o}=t,i=`${n.replace(/\/+$/,"")}/tenant/${r}/page/${o}`,l=Hi(t),s=await Wi(i,{method:"GET",headers:Gi(t)},l);if(!s.ok)throw new Error(`[pagepilot-visual-editor] renderToStaticHtml: GET ${i} → ${s.status}${s.text?`: ${s.text}`:""}`);return Id(e,s.body,{...t,fetchFn:l})}async function fI(e,t){var d,f;const{baseUrl:n,tenantId:r,pagePath:o,cache:a=!1,update:i=!0}=t,s=`${n.replace(/\/+$/,"")}/tenant/${r}/pagebypath/${encodeURIComponent(o)}?cache=${a}&update=${i}`,u=Hi(t),c=await Wi(s,{method:"GET",headers:Gi(t)},u);if(!c.ok)throw new Error(`[pagepilot-visual-editor] renderToStaticHtml: GET ${s} → ${c.status}${c.text?`: ${c.text}`:""}`);const h=((d=c.body)==null?void 0:d.data)??((f=c.body)==null?void 0:f.payload)??c.body;return Id(e,h,{...t,fetchFn:u})}async function pI(e){const{baseUrl:t,tenantId:n,templateId:r,isGlobal:o=!1}=e,a=t.replace(/\/+$/,""),i=Hi(e),l=o?`${a}/global-template/${r}`:`${a}/tenant/${n}/template/${r}`,s=o?{"Content-Type":"application/json"}:Gi(e),u=await Wi(l,{method:"GET",headers:s},i);if(u.ok)return u.body;throw new Error(`[pagepilot-visual-editor] renderToStaticHtml: GET ${l} → ${u.status}${u.text?`: ${u.text}`:""}`)}function gI(e,t){if(!t)return e;const n=new Map;for(const o of e)o!=null&&o.id&&n.set(o.id,o);if(Array.isArray(t)){for(const o of t){if(!(o!=null&&o.id))continue;const i={...n.get(o.id)??{id:o.id,name:o.id,type:"text"},...o};n.set(o.id,i)}return Array.from(n.values())}const r=Object.entries(t).filter(([,o])=>o!=null);if(r.length===0)return e;for(const[o,a]of r){const i=String(a),l=n.get(o);l?n.set(o,{...l,value:i}):n.set(o,{id:o,name:o,type:"text",value:i})}return Array.from(n.values())}async function mI(e,t){const n=await pI(t),r=rI(n)??(e&&Object.keys(e).length>0?e:null);if(!r)return"";const o=nI(n),a=gI(o,t.variables),i=zi(r,a);return Fi(i,t)}function bI(e,t){return sI(t)?mI(e,t):lI(t)?fI(e,t):iI(t)?hI(e,t):Fi(e,t)}function xI(){return`block-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function vI(e,t){e.data&&(Array.isArray(e.data.childrenIds)&&(e.data.childrenIds=e.data.childrenIds.map(n=>t[n]??n)),e.data.props&&(Array.isArray(e.data.props.childrenIds)&&(e.data.props.childrenIds=e.data.props.childrenIds.map(n=>t[n]??n)),Array.isArray(e.data.props.startChildrenIds)&&(e.data.props.startChildrenIds=e.data.props.startChildrenIds.map(n=>t[n]??n)),Array.isArray(e.data.props.endChildrenIds)&&(e.data.props.endChildrenIds=e.data.props.endChildrenIds.map(n=>t[n]??n)),Array.isArray(e.data.props.columns)&&(e.data.props.columns=e.data.props.columns.map(n=>({...n,childrenIds:(n.childrenIds||[]).map(r=>t[r]??r)}))),Array.isArray(e.data.props.cells)&&(e.data.props.cells=e.data.props.cells.map(n=>n===null||typeof n!="object"?n:{...n,childrenIds:(n.childrenIds||[]).map(r=>t[r]??r)})),Array.isArray(e.data.props.items)&&(e.data.props.items=e.data.props.items.map(n=>({...n,...n.titleChildrenIds!==void 0?{titleChildrenIds:(n.titleChildrenIds||[]).map(r=>t[r]??r)}:{},...n.contentChildrenIds!==void 0?{contentChildrenIds:(n.contentChildrenIds||[]).map(r=>t[r]??r)}:{},...n.cardChildrenIds!==void 0?{cardChildrenIds:(n.cardChildrenIds||[]).map(r=>t[r]??r)}:{},...n.detailChildrenIds!==void 0?{detailChildrenIds:(n.detailChildrenIds||[]).map(r=>t[r]??r)}:{}})))))}function en(e,t){const n=oo(e,t),r={};n.forEach(a=>{r[a]=xI()});const o={};return n.forEach(a=>{const i=JSON.parse(JSON.stringify(e[a]));vI(i,r),o[r[a]]=i}),{newBlocks:o,idMap:r,newRootId:r[t]}}function kI(e,t,n){var r,o,a,i;for(const[l,s]of Object.entries(e)){if(!s||typeof s!="object")continue;const u=s;if(u.data&&Array.isArray(u.data.childrenIds)&&u.data.childrenIds.includes(t)){const c=u.data.childrenIds.indexOf(t),h=[...u.data.childrenIds];return h.splice(c+1,0,n),{parentId:l,updatedParent:{...u,data:{...u.data,childrenIds:h}}}}if(u.data&&u.data.props&&Array.isArray(u.data.props.childrenIds)&&u.data.props.childrenIds.includes(t)){const c=u.data.props.childrenIds.indexOf(t),h=[...u.data.props.childrenIds];return h.splice(c+1,0,n),{parentId:l,updatedParent:{...u,data:{...u.data,props:{...u.data.props,childrenIds:h}}}}}if(u.data&&u.data.props&&Array.isArray(u.data.props.columns)){const c=u.data.props.columns;for(let h=0;h<c.length;h++){const d=c[h];if(Array.isArray(d.childrenIds)&&d.childrenIds.includes(t)){const f=d.childrenIds.indexOf(t),p=c.map(b=>({...b,childrenIds:Array.isArray(b.childrenIds)?[...b.childrenIds]:[]}));return p[h].childrenIds.splice(f+1,0,n),{parentId:l,updatedParent:{...u,data:{...u.data,props:{...u.data.props,columns:p}}}}}}}if(u.data&&u.data.props&&Array.isArray(u.data.props.cells)){const c=u.data.props.cells;for(let h=0;h<c.length;h++){const d=c[h];if(Array.isArray(d.childrenIds)&&d.childrenIds.includes(t)){const f=d.childrenIds.indexOf(t),p=c.map(b=>({...b,childrenIds:Array.isArray(b.childrenIds)?[...b.childrenIds]:[]}));return p[h].childrenIds.splice(f+1,0,n),{parentId:l,updatedParent:{...u,data:{...u.data,props:{...u.data.props,cells:p}}}}}}}if(u.type==="PricingAccordion"&&((r=u.data)!=null&&r.props)&&Array.isArray(u.data.props.items)){const c=u.data.props.items;for(let h=0;h<c.length;h++){const d=Array.isArray(c[h].cardChildrenIds)?c[h].cardChildrenIds:[],f=Array.isArray(c[h].detailChildrenIds)?c[h].detailChildrenIds:[];for(const[p,b]of[[d,"cardChildrenIds"],[f,"detailChildrenIds"]])if(p.includes(t)){const x=p.indexOf(t),w=c.map(k=>({...k,cardChildrenIds:Array.isArray(k.cardChildrenIds)?[...k.cardChildrenIds]:[],detailChildrenIds:Array.isArray(k.detailChildrenIds)?[...k.detailChildrenIds]:[]}));return w[h][b].splice(x+1,0,n),{parentId:l,updatedParent:{...u,data:{...u.data,props:{...u.data.props,items:w}}}}}}}if((u.type==="TabsBlock"||u.type==="VerticalAccordion"||u.type==="Carousel"||u.type==="Marquee"||u.type==="Pagination")&&((o=u.data)!=null&&o.props)&&Array.isArray(u.data.props.items)){const c=u.data.props.items;for(let h=0;h<c.length;h++){const d=Array.isArray(c[h].contentChildrenIds)?c[h].contentChildrenIds:[];if(d.includes(t)){const f=d.indexOf(t),p=c.map(b=>({...b,contentChildrenIds:Array.isArray(b.contentChildrenIds)?[...b.contentChildrenIds]:[]}));return p[h].contentChildrenIds.splice(f+1,0,n),{parentId:l,updatedParent:{...u,data:{...u.data,props:{...u.data.props,items:p}}}}}}}if(u.type==="MenuPicker"&&((a=u.data)!=null&&a.props))for(const c of["startChildrenIds","endChildrenIds"]){const h=Array.isArray(u.data.props[c])?u.data.props[c]:[];if(h.includes(t)){const d=h.indexOf(t),f=[...h];return f.splice(d+1,0,n),{parentId:l,updatedParent:{...u,data:{...u.data,props:{...u.data.props,[c]:f}}}}}}if(u.type==="Accordion"&&((i=u.data)!=null&&i.props)&&Array.isArray(u.data.props.items)){const c=u.data.props.items;for(let h=0;h<c.length;h++){const d=c[h],f=Array.isArray(d.titleChildrenIds)?d.titleChildrenIds:[],p=Array.isArray(d.contentChildrenIds)?d.contentChildrenIds:[];if(f.includes(t)){const b=f.indexOf(t),x=c.map(w=>({...w,titleChildrenIds:Array.isArray(w.titleChildrenIds)?[...w.titleChildrenIds]:[],contentChildrenIds:Array.isArray(w.contentChildrenIds)?[...w.contentChildrenIds]:[]}));return x[h].titleChildrenIds.splice(b+1,0,n),{parentId:l,updatedParent:{...u,data:{...u.data,props:{...u.data.props,items:x}}}}}if(p.includes(t)){const b=p.indexOf(t),x=c.map(w=>({...w,titleChildrenIds:Array.isArray(w.titleChildrenIds)?[...w.titleChildrenIds]:[],contentChildrenIds:Array.isArray(w.contentChildrenIds)?[...w.contentChildrenIds]:[]}));return x[h].contentChildrenIds.splice(b+1,0,n),{parentId:l,updatedParent:{...u,data:{...u.data,props:{...u.data.props,items:x}}}}}}}}return null}function wI(e,t){var n,r,o;for(const[a,i]of Object.entries(e)){if((i==null?void 0:i.type)!=="FlexColumns")continue;const l=(r=(n=i==null?void 0:i.data)==null?void 0:n.props)==null?void 0:r.columns;if(Array.isArray(l)){for(let s=0;s<l.length;s++)if(Array.isArray((o=l[s])==null?void 0:o.childrenIds)&&l[s].childrenIds.includes(t))return{flexId:a,columnIndex:s}}}return null}function SI(e,t){var n,r,o;for(const[a,i]of Object.entries(e)){const l=(r=(n=i==null?void 0:i.data)==null?void 0:n.props)==null?void 0:r.cells;if(!((i==null?void 0:i.type)!=="Grid"||!Array.isArray(l))){for(let s=0;s<l.length;s++)if(Array.isArray((o=l[s])==null?void 0:o.childrenIds)&&l[s].childrenIds.includes(t))return{gridId:a,cellIndex:s}}}return null}function $I(e,t){var n,r,o;for(const[a,i]of Object.entries(e)){if((i==null?void 0:i.type)!=="Pagination")continue;const l=(r=(n=i==null?void 0:i.data)==null?void 0:n.props)==null?void 0:r.cells;if(Array.isArray(l)){for(let s=0;s<l.length;s++)if(Array.isArray((o=l[s])==null?void 0:o.childrenIds)&&l[s].childrenIds.includes(t))return{paginationId:a,cellIndex:s}}}return null}function _I(e,t){var n,r,o;for(const[a,i]of Object.entries(e)){const l=i==null?void 0:i.type;if(l!=="Carousel"&&l!=="Marquee"&&l!=="TabsBlock")continue;const s=(r=(n=i==null?void 0:i.data)==null?void 0:n.props)==null?void 0:r.items;if(Array.isArray(s)){for(let u=0;u<s.length;u++)if(Array.isArray((o=s[u])==null?void 0:o.contentChildrenIds)&&s[u].contentChildrenIds.includes(t))return{parentId:a,itemIndex:u,parentType:l}}}return null}function lc(e,t,n){var d,f,p;if(!e[t])return null;const r=e[t];if((r==null?void 0:r.type)==="TabsBlock"){const x=Array.isArray((f=(d=r.data)==null?void 0:d.props)==null?void 0:f.items)?r.data.props.items:[];if(x.length>=10)return null;const w=x[0]??{},k=Array.isArray(w.contentChildrenIds)?w.contentChildrenIds:[];let S={...e};const v=[];let _=null;for(const I of k){if(!S[I])continue;const{newBlocks:R,newRootId:E}=en(S,I);S={...S,...R},v.push(E),_||(_=E)}const y=_??t,C=[...x,{label:w.label??`Tab ${x.length+1}`,contentChildrenIds:v}];return S={...S,[t]:{...r,data:{...r.data,props:{...r.data.props,items:C}}}},{updatedDocument:S,newRootId:y}}const o=SI(e,n);if(o){const b=e[o.gridId],x=b.data.props??{},w=x.columnsCount??2,k=x.rowsCount??2,S=Array.isArray(x.cells)?x.cells:[],_=S.some(M=>(M==null?void 0:M.colStart)!=null||(M==null?void 0:M.rowStart)!=null||(M==null?void 0:M.colSpan)!=null||(M==null?void 0:M.rowSpan)!=null)?S.length:w*k,y=Array.from({length:_},(M,P)=>S[P]??{childrenIds:[]});let C=y.findIndex((M,P)=>P>o.cellIndex&&(!Array.isArray(M==null?void 0:M.childrenIds)||M.childrenIds.length===0));if(C===-1&&(C=y.findIndex(M=>!Array.isArray(M==null?void 0:M.childrenIds)||M.childrenIds.length===0)),C===-1)return null;const{newBlocks:I,newRootId:R}=en(e,t),E=y.map((M,P)=>P===C?{...M,childrenIds:[...(M==null?void 0:M.childrenIds)??[],R]}:M);return{updatedDocument:{...e,...I,[o.gridId]:{...b,data:{...b.data,props:{...b.data.props,cells:E}}}},newRootId:R}}const a=$I(e,n);if(a){const b=e[a.paginationId],x=b.data.props??{},w=x.columnsCount??2,k=x.rowsCount??2,S=Array.isArray(x.cells)?x.cells:[],v=Math.max(w*k,S.length),_=Array.from({length:v},(L,M)=>S[M]??{childrenIds:[]});let y=_.findIndex((L,M)=>M>a.cellIndex&&(!Array.isArray(L==null?void 0:L.childrenIds)||L.childrenIds.length===0));y===-1&&(y=_.findIndex(L=>!Array.isArray(L==null?void 0:L.childrenIds)||L.childrenIds.length===0)),y===-1&&(_.push({childrenIds:[]}),y=_.length-1);const{newBlocks:C,newRootId:I}=en(e,t),R=_.map((L,M)=>M===y?{...L,childrenIds:[...(L==null?void 0:L.childrenIds)??[],I]}:L);return{updatedDocument:{...e,...C,[a.paginationId]:{...b,data:{...b.data,props:{...b.data.props,cells:R}}}},newRootId:I}}const i=wI(e,n);if(i){const b=e[i.flexId],x=b.data.props??{},w=x.columnsCount??2,k=Array.isArray(x.columns)?x.columns:[],S=Array.from({length:w},(R,E)=>k[E]??{childrenIds:[]});let v=S.findIndex((R,E)=>E>i.columnIndex&&(!Array.isArray(R==null?void 0:R.childrenIds)||R.childrenIds.length===0));if(v===-1&&(v=S.findIndex(R=>!Array.isArray(R==null?void 0:R.childrenIds)||R.childrenIds.length===0)),v===-1)return null;const{newBlocks:_,newRootId:y}=en(e,t),C=S.map((R,E)=>E===v?{...R,childrenIds:[...(R==null?void 0:R.childrenIds)??[],y]}:R);return{updatedDocument:{...e,..._,[i.flexId]:{...b,data:{...b.data,props:{...b.data.props,columns:C}}}},newRootId:y}}const l=_I(e,n);if(l){let b=e[l.parentId],x=Array.isArray((p=b.data.props)==null?void 0:p.items)?b.data.props.items:[],w=e,k=x.findIndex((C,I)=>I>l.itemIndex&&(!Array.isArray(C==null?void 0:C.contentChildrenIds)||C.contentChildrenIds.length===0));if(k===-1&&(k=x.findIndex(C=>!Array.isArray(C==null?void 0:C.contentChildrenIds)||C.contentChildrenIds.length===0)),k===-1)if(l.parentType==="TabsBlock"&&x.length<10){const C=[...x,{label:`Tab ${x.length+1}`,contentChildrenIds:[]}];w={...w,[l.parentId]:{...b,data:{...b.data,props:{...b.data.props,items:C}}}},b=w[l.parentId],x=C,k=x.length-1}else return null;const{newBlocks:S,newRootId:v}=en(w,t),_=x.map((C,I)=>I===k?{...C,...l.parentType==="TabsBlock"&&!(C!=null&&C.label)?{label:`Tab ${I+1}`}:{},contentChildrenIds:[...(C==null?void 0:C.contentChildrenIds)??[],v]}:C);return{updatedDocument:{...w,...S,[l.parentId]:{...b,data:{...b.data,props:{...b.data.props,items:_}}}},newRootId:v}}const{newBlocks:s,newRootId:u}=en(e,t),c={...e,...s},h=kI(c,n,u);return h&&(c[h.parentId]=h.updatedParent),{updatedDocument:c,newRootId:u}}function Rd(e,t){const n=o=>Array.isArray(o)?o.filter(a=>!t.has(a)):o,r={};for(const[o,a]of Object.entries(e)){if(t.has(o))continue;const i=a;if(!(i!=null&&i.data)){r[o]=i;continue}const l={...i.data};if(Array.isArray(l.childrenIds)&&(l.childrenIds=n(l.childrenIds)),l.props){const s={...l.props};Array.isArray(s.childrenIds)&&(s.childrenIds=n(s.childrenIds)),Array.isArray(s.startChildrenIds)&&(s.startChildrenIds=n(s.startChildrenIds)),Array.isArray(s.endChildrenIds)&&(s.endChildrenIds=n(s.endChildrenIds)),Array.isArray(s.columns)&&(s.columns=s.columns.map(u=>({...u,childrenIds:n(u.childrenIds)}))),Array.isArray(s.cells)&&(s.cells=s.cells.map(u=>u===null||typeof u!="object"?u:{...u,childrenIds:n(u.childrenIds)})),Array.isArray(s.items)&&(s.items=s.items.map(u=>({...u,...u.titleChildrenIds!==void 0?{titleChildrenIds:n(u.titleChildrenIds)}:{},...u.contentChildrenIds!==void 0?{contentChildrenIds:n(u.contentChildrenIds)}:{},...u.cardChildrenIds!==void 0?{cardChildrenIds:n(u.cardChildrenIds)}:{},...u.detailChildrenIds!==void 0?{detailChildrenIds:n(u.detailChildrenIds)}:{}}))),l.props=s}r[o]={...i,data:l}}return r}function CI(e){var r;const t=e==null?void 0:e.type,n=((r=e==null?void 0:e.data)==null?void 0:r.props)??{};if(t==="Grid"){const o=n.columnsCount??2,a=n.rowsCount??2,i=Array.isArray(n.cells)?n.cells:[],s=i.some(c=>(c==null?void 0:c.colStart)!=null||(c==null?void 0:c.rowStart)!=null||(c==null?void 0:c.colSpan)!=null||(c==null?void 0:c.rowSpan)!=null)?i.length:o*a,u=Array.from({length:s},(c,h)=>{var d;return{childrenIds:Array.isArray((d=i[h])==null?void 0:d.childrenIds)?i[h].childrenIds:[]}});return{slotCount:s,slots:u}}if(t==="FlexColumns"){const o=n.columnsCount??(Array.isArray(n.columns)?n.columns.length:2),a=Array.isArray(n.columns)?n.columns:[],i=Array.from({length:o},(l,s)=>{var u;return{childrenIds:Array.isArray((u=a[s])==null?void 0:u.childrenIds)?a[s].childrenIds:[]}});return{slotCount:o,slots:i}}if(t==="Carousel"||t==="Marquee"){const o=Array.isArray(n.items)?n.items:[],a=o.length,i=o.map(l=>({childrenIds:Array.isArray(l==null?void 0:l.contentChildrenIds)?l.contentChildrenIds:[]}));return{slotCount:a,slots:i}}if(t==="TabsBlock"){const o=Array.isArray(n.items)?n.items:[],a=o.length,i=o.map(l=>({childrenIds:Array.isArray(l==null?void 0:l.contentChildrenIds)?l.contentChildrenIds:[]}));return{slotCount:a,slots:i}}if(t==="Pagination"){const o=n.columnsCount??2,a=n.rowsCount??2,i=Array.isArray(n.cells)?n.cells:[],l=Math.max(o*a,i.length),s=Array.from({length:l},(u,c)=>{var h;return{childrenIds:Array.isArray((h=i[c])==null?void 0:h.childrenIds)?i[c].childrenIds:[]}});return{slotCount:l,slots:s}}return null}function hr(e){return e==="Grid"||e==="FlexColumns"||e==="Carousel"||e==="Marquee"||e==="Pagination"||e==="TabsBlock"}const Tr=new WeakMap;function xo(e,t){const n=e[t];if(!n||typeof n!="object")return null;const r=Tr.get(n);if(r!==void 0)return r&&r.containerId===t?r:r&&{...r,containerId:t};if(!hr(n.type))return Tr.set(n,null),null;const o=CI(n);if(!o)return Tr.set(n,null),null;const{slotCount:a,slots:i}=o,l=i.findIndex(c=>c.childrenIds.length>0),s=i.filter(c=>c.childrenIds.length===0).length,u={containerId:t,type:n.type,slotCount:a,slots:i,firstFilledSlot:l,emptySlotCount:s};return Tr.set(n,u),u}function oi(e,t){for(const[n,r]of Object.entries(e)){if(!hr(r==null?void 0:r.type))continue;const o=xo(e,n);if(o!=null&&o.slots.some(a=>a.childrenIds.includes(t)))return n}return null}function Td(e,t,n,r){var u;const o=e[t];if(!o||!hr(o.type))return e;const a=((u=o.data)==null?void 0:u.props)??{};if(o.type==="Grid"){let c=a.columnsCount??2,h=a.rowsCount??2;if(c*h>=n)return e;r==="columns"?c=Math.max(c,Math.ceil(n/Math.max(1,h))):h=Math.max(h,Math.ceil(n/Math.max(1,c)));const d=c*h,f=Array.isArray(a.cells)?a.cells:[],p=Array.from({length:d},(b,x)=>f[x]??{childrenIds:[]});return{...e,[t]:{...o,data:{...o.data,props:{...a,columnsCount:c,rowsCount:h,cells:p}}}}}if(o.type==="Carousel"){const h=Array.isArray(a.items)?a.items:[];if(h.length>=n)return e;const d=Math.min(n,20),f=Array.from({length:d},(p,b)=>h[b]??{contentChildrenIds:[]});return{...e,[t]:{...o,data:{...o.data,props:{...a,items:f}}}}}if(o.type==="Marquee"){const h=Array.isArray(a.items)?a.items:[];if(h.length>=n)return e;const d=Math.min(n,30),f=Array.from({length:d},(p,b)=>h[b]??{contentChildrenIds:[]});return{...e,[t]:{...o,data:{...o.data,props:{...a,items:f}}}}}if(o.type==="TabsBlock"){const h=Array.isArray(a.items)?a.items:[];if(h.length>=n)return e;const d=Math.min(n,10),f=Array.from({length:d},(p,b)=>h[b]??{label:`Tab ${b+1}`,contentChildrenIds:[]});return{...e,[t]:{...o,data:{...o.data,props:{...a,items:f}}}}}if(o.type==="Pagination"){const c=a.columnsCount??2,h=a.rowsCount??2,d=Array.isArray(a.cells)?a.cells:[];if(Math.max(c*h,d.length)>=n)return e;const p=Array.from({length:n},(b,x)=>d[x]??{childrenIds:[]});return{...e,[t]:{...o,data:{...o.data,props:{...a,cells:p}}}}}if((a.columnsCount??(Array.isArray(a.columns)?a.columns.length:2))>=n)return e;const l=Array.isArray(a.columns)?a.columns:[],s=Array.from({length:n},(c,h)=>l[h]??{childrenIds:[]});return{...e,[t]:{...o,data:{...o.data,props:{...a,columnsCount:n,columns:s}}}}}function Ed(e,t,n){var u;const r=e[t];if(!r||!hr(r.type))return e;const o=xo(e,t);if(!o)return e;let a=-1;o.slots.forEach((c,h)=>{c.childrenIds.length>0&&(a=h)});const i=Math.max(n,a+1,1);if(i>=o.slotCount)return e;const l=((u=r.data)==null?void 0:u.props)??{};if(r.type==="Pagination"){const c=(l.columnsCount??2)*(l.rowsCount??2),h=Math.max(i,c);if(h>=o.slotCount)return e;const d=Array.isArray(l.cells)?l.cells:[];return{...e,[t]:{...r,data:{...r.data,props:{...l,cells:d.slice(0,h)}}}}}if(r.type==="Carousel"||r.type==="Marquee"||r.type==="TabsBlock"){const c=Array.isArray(l.items)?l.items:[];return{...e,[t]:{...r,data:{...r.data,props:{...l,items:c.slice(0,i)}}}}}if(r.type==="Grid"){const c=l.columnsCount??2,h=l.rowsCount??2,d=Math.max(1,Math.ceil(i/Math.max(1,c)));if(d>=h)return e;const f=Array.isArray(l.cells)?l.cells:[];return{...e,[t]:{...r,data:{...r.data,props:{...l,rowsCount:d,cells:f.slice(0,c*d)}}}}}const s=Array.isArray(l.columns)?l.columns:[];return{...e,[t]:{...r,data:{...r.data,props:{...l,columnsCount:i,columns:s.slice(0,i)}}}}}function AI(e,t,n,r="columns"){const o=t==null?void 0:t.sourceBlockId;if(!o||!e[o])return null;const a=Math.max(1,n);let i=e,l=Array.isArray(t.rowIds)?[...t.rowIds]:[],s=1+l.length;if(s===a)return{document:i,sourceBlockId:o,rowIds:l,achievedRowCount:s,capacityLimited:!1};if(s<a){let h=!1;for(;s<a;){const d=l.length>0?l[l.length-1]:o;let f=lc(i,o,d);if(!f){const p=oi(i,o);if(!p){h=!0;break}const b=xo(i,p),x=((b==null?void 0:b.slotCount)??0)+(a-s),w=Td(i,p,x,r);if(w===i){h=!0;break}if(i=w,f=lc(i,o,d),!f){h=!0;break}}i=f.updatedDocument,l=[...l,f.newRootId],s=1+l.length}return{document:i,sourceBlockId:o,rowIds:l,achievedRowCount:s,capacityLimited:h}}const u=a,c=l.slice(u-1);if(c.length>0){const h=new Set;for(const f of c)for(const p of oo(i,f))h.add(p);i=Rd(i,h);const d=oi(i,o);d&&(i=Ed(i,d,u)),l=l.slice(0,u-1),s=1+l.length}return{document:i,sourceBlockId:o,rowIds:l,achievedRowCount:s,capacityLimited:!1}}exports.Reader=or;exports.ReaderBlock=Me;exports.ReaderBlockSchema=kd;exports.ReaderDocumentSchema=Ay;exports.cloneSubtree=en;exports.extractApiRows=Di;exports.findRepeatableContainerOf=oi;exports.getRepeatableContainerInfo=xo;exports.growContainerToFit=Td;exports.isRepeatableContainerType=hr;exports.reconcileRepeatFieldRowCount=AI;exports.refreshApiDataSources=_d;exports.refreshDocumentApiDataSources=Cd;exports.removeSubtree=Rd;exports.renderToStaticHtml=bI;exports.renderToStaticMarkup=Bi;exports.shrinkContainerToFit=Ed;
1032
+ `);return r?{html:eI(i,e,t),sectionHtml:o,flushedSections:a}:{html:i,sectionHtml:o,flushedSections:a}}function nI(e){var a,i,l,s,u,c,h,d,f,p,b;if(!e)return[];const t=e.configuration??{},n=(i=(a=t==null?void 0:t.root)==null?void 0:a.data)==null?void 0:i.formFields;if(Array.isArray(n)&&n.length>0)return n;if(t!=null&&t.isIndividualBlock&&Array.isArray(t.formFields)&&t.formFields.length>0)return t.formFields;const r=Array.isArray(t==null?void 0:t.steps)?t.steps:Array.isArray(t==null?void 0:t.slides)?t.slides:null;if(r){const x=new Set,w=[];for(const k of r){const S=(c=(u=(s=(l=k==null?void 0:k.contentMetadata)==null?void 0:l.document)==null?void 0:s.root)==null?void 0:u.data)==null?void 0:c.formFields;if(Array.isArray(S))for(const v of S)!(v!=null&&v.id)||x.has(v.id)||(x.add(v.id),w.push(v))}if(w.length>0)return w}const o=(b=(p=(f=(d=(h=t==null?void 0:t.step)==null?void 0:h.contentMetadata)==null?void 0:d.document)==null?void 0:f.root)==null?void 0:p.data)==null?void 0:b.formFields;return Array.isArray(o)&&o.length>0?o:Array.isArray(e.formFields)?e.formFields:[]}function rI(e){var n,r,o,a,i,l,s;if(!e||typeof e!="object")return null;const t=e.configuration;if(!t||typeof t!="object")return null;if(t.root)return t;if(t.isIndividualBlock&&typeof t.rootBlockId=="string"&&t.blocks&&typeof t.blocks=="object"&&t.blocks[t.rootBlockId]){const u=Array.isArray(t.formFields)?t.formFields:[];return{...t.blocks,root:{type:"PagePilotLayout",data:{backdropColor:"#FFFFFF",canvasColor:"#FFFFFF",textColor:"#262626",fontFamily:"MODERN_SANS",childrenIds:[t.rootBlockId],maxWidth:"100%",formFields:u}}}}return(o=(r=(n=t.content)==null?void 0:n.contentMetadata)==null?void 0:r.document)!=null&&o.root?t.content.contentMetadata.document:(i=(a=t.contentMetadata)==null?void 0:a.document)!=null&&i.root?t.contentMetadata.document:(s=(l=e.contentMetadata)==null?void 0:l.document)!=null&&s.root?e.contentMetadata.document:null}function ac(e,t){return t.split(".").map(n=>n.trim()).filter(Boolean).reduce((n,r)=>n==null?n:n[r],e)}function Di(e,t){if(t){const n=ac(e,t);if(Array.isArray(n))return n;const r=Di(e);if(r){const o=r.map(a=>ac(a,t)).filter(a=>a&&typeof a=="object");if(o.length>0)return o}}if(Array.isArray(e))return e;if(e&&typeof e=="object"){for(const n of["data","rows","results","items","records"])if(Array.isArray(e[n]))return e[n]}return null}function oI(e,t){if(!t||t.length===0){const r={};for(const[o,a]of Object.entries(e))a!=null&&(r[o]=String(a));return r}const n={};for(const r of t){const o=e[r.id];o!=null&&o!==""&&(n[r.id]=String(o))}return e.id!==void 0&&n.id===void 0&&(n.id=String(e.id)),n}async function aI(e,t,n,r){if(typeof AbortController>"u")return n(e,t);const o=new AbortController,a=setTimeout(()=>o.abort(),r);try{return await n(e,{...t,signal:o.signal})}finally{clearTimeout(a)}}async function _d(e,t={}){var h;const n=Array.isArray(e)?e:[],r=n.filter(d=>{var f,p;return((f=d==null?void 0:d.dataSource)==null?void 0:f.type)==="api"&&((p=d==null?void 0:d.dataSource)==null?void 0:p.apiUrl)});if(r.length===0)return{fields:n,attempted:0,refreshed:0,errors:{}};const o=t.fetchFn??(typeof fetch<"u"?fetch:void 0);if(!o){const d=new Error("[pagepilot-visual-editor] refreshApiDataSources: global fetch is not available — pass `fetchFn`.");for(const f of r)(h=t.onError)==null||h.call(t,f,d);return{fields:n,attempted:r.length,refreshed:0,errors:Object.fromEntries(r.map(f=>[f.id,d.message]))}}const a=t.timeoutMs??1e4,i={};let l=0;const s=await Promise.all(r.map(async d=>{var x;const{apiUrl:f,apiMethod:p="GET",apiItemPath:b}=d.dataSource;try{const w=await aI(f,{method:p,headers:{Accept:"application/json",...t.headers}},o,a);if(!w.ok)throw new Error(`GET ${f} → HTTP ${w.status}`);const k=await w.json(),S=Di(k,b);if(!S)throw new Error(`GET ${f} → response had no array of rows`);const v=S.map(_=>oI(_,d.itemFields));return l+=1,{id:d.id,value:v}}catch(w){const k=w instanceof Error?w:new Error(String(w));return i[d.id]=k.message,(x=t.onError)==null||x.call(t,d,k),null}}));if(l===0)return{fields:n,attempted:r.length,refreshed:0,errors:i};const u=new Map(s.filter(Boolean).map(d=>[d.id,d.value]));return{fields:n.map(d=>u.has(d.id)?{...d,value:u.get(d.id)}:d),attempted:r.length,refreshed:l,errors:i}}async function Cd(e,t={}){var r,o;const n=(o=(r=e==null?void 0:e.root)==null?void 0:r.data)==null?void 0:o.formFields;return _d(Array.isArray(n)?n:[],t)}function Ad(e,t){if(!e)return t();El(e);try{return t()}finally{El(null)}}function iI(e){const t=e;return!!(t.pageId&&t.baseUrl&&t.tenantId)}function lI(e){const t=e;return!!(t.pagePath&&t.baseUrl&&t.tenantId)}function sI(e){const t=e;return!!(t.templateId&&t.baseUrl)}function cI(e){if(!e||typeof e!="object")return e;const t=Oi(e);return!t||t.length===0?e:zi(e,t)}async function ic(e,t){if(!e||typeof e!="object")return{document:e,apiRefresh:null};const n=Oi(e);if(!n||n.length===0)return{document:e,apiRefresh:null};let r=n,o=null;return t.refreshApiDataSources&&(o=await Cd(e,{fetchFn:t.fetchFn,headers:t.apiDataSourceHeaders,timeoutMs:t.apiDataSourceTimeoutMs,onError:t.onApiDataSourceError}),r=o.fields),{document:zi(e,r),apiRefresh:o}}const uI=new Set(["ColumnsContainer","FlexColumns","Grid","ButtonGroup","Container","EmailLayout","PagePilotLayout","Accordion","PricingAccordion","TabsBlock","Carousel","Rating","Progress","Marquee","Timer","Pagination","Table","DemoPicker","MenuPicker","Breadcrumb","FormsPicker","AppBannerPicker","FaqPicker","Avatar","Button","Divider","Heading","Html","Image","Logo","Video","IFrame","Calendly","YouTubeUrl","Spacer","SkipLink","AccessibilityTools","Stepper","List","Text","Mdx","QuillBlock"]);function dI(e){var r,o,a;const t=((r=e==null?void 0:e.data)==null?void 0:r.props)??{};return{type:"Text",data:{props:{text:typeof t.html=="string"&&t.html||typeof t.text=="string"&&t.text||typeof t.markdown=="string"&&t.markdown||""},style:((o=e==null?void 0:e.data)==null?void 0:o.style)??{},hidden:(a=e==null?void 0:e.data)==null?void 0:a.hidden}}}function yd(e){if(!e||typeof e!="object")return e;let t=!1;const n={};for(const[r,o]of Object.entries(e)){const a=o==null?void 0:o.type;a&&!uI.has(a)?(n[r]=dI(o),t=!0,console.warn(`[pagepilot-visual-editor] renderToStaticHtml: block "${r}" has unsupported type "${a}" — coerced to Text.`)):n[r]=o}return t?n:e}function Fi(e,t){var i;if(!e)return"";const n=t.rootBlockId??"root",r=cI(e),o=yd(r),a=((i=o==null?void 0:o[n])==null?void 0:i.data)??{};return Ad(t.recordType,()=>Bi(o,{rootBlockId:n,injectElementIds:t.injectElementIds??!0,minifyCss:t.minifyCss??!0,includePageCSS:t.includePageCSS??!0,lang:t.lang??a.lang,skipLink:t.skipLink??a.skipLink,accessibilityTools:t.accessibilityTools??a.accessibilityTools,injectTabsScrollSyncScript:t.injectTabsScrollSyncScript,injectCarouselScript:t.injectCarouselScript,injectPaginationScript:t.injectPaginationScript,injectAnimationScript:t.injectAnimationScript,injectPostMessageScript:t.injectPostMessageScript,injectFontAssets:t.injectFontAssets,seo:t.seo,headHtml:t.headHtml,bodyBottomHtml:t.bodyBottomHtml,isBanner:t.isBanner}))}function Hi(e){const t=e.fetchFn??(typeof fetch<"u"?fetch:void 0);if(!t)throw new Error("[pagepilot-visual-editor] renderToStaticHtml: global fetch is not available — pass `fetchFn`.");return t}function Gi(e){const t={"Content-Type":"application/json"};return e.authToken&&(t.Authorization=`Bearer ${e.authToken}`),t}async function Wi(e,t,n){const r=await n(e,t);if(!r.ok){const o=await r.text().catch(()=>"");return{ok:!1,body:null,status:r.status,text:o}}return{ok:!0,body:await r.json(),status:r.status,text:""}}async function Id(e,t,n){var u;const{wrapInDocumentShell:r=!0,headHtml:o,bodyBottomHtml:a}=n,i=Array.isArray(t==null?void 0:t.sections)?t.sections:[];if(i.length===0){const{document:c}=await ic(((u=t==null?void 0:t.contentMetadata)==null?void 0:u.document)??e,n);return Fi(c,{...n,recordType:n.recordType??"page"})}const l=await Promise.all(i.map(async c=>{var p;const h=(p=c==null?void 0:c.contentMetadata)==null?void 0:p.document;if(!h)return c;const{document:d}=await ic(h,n),f=yd(d);return{...c,contentMetadata:{...c.contentMetadata??{},document:f}}})),{html:s}=Ad(n.recordType??"page",()=>tI(l,{rootBlockId:n.rootBlockId,injectTabsScrollSyncScript:n.injectTabsScrollSyncScript,injectCarouselScript:n.injectCarouselScript,injectFontAssets:n.injectFontAssets,isBanner:n.isBanner,seo:n.seo,wrapInDocumentShell:r,seoTitle:(t==null?void 0:t.metaTitle)??(t==null?void 0:t.title)??(t==null?void 0:t.name),seoDescription:t==null?void 0:t.metaDescription,lang:n.lang??(t==null?void 0:t.lang),extraHead:o??(t==null?void 0:t.head)??"",extraBodyBottom:a??(t==null?void 0:t.bodyBottom)??""}));return s}async function hI(e,t){const{baseUrl:n,tenantId:r,pageId:o}=t,i=`${n.replace(/\/+$/,"")}/tenant/${r}/page/${o}`,l=Hi(t),s=await Wi(i,{method:"GET",headers:Gi(t)},l);if(!s.ok)throw new Error(`[pagepilot-visual-editor] renderToStaticHtml: GET ${i} → ${s.status}${s.text?`: ${s.text}`:""}`);return Id(e,s.body,{...t,fetchFn:l})}async function fI(e,t){var d,f;const{baseUrl:n,tenantId:r,pagePath:o,cache:a=!1,update:i=!0}=t,s=`${n.replace(/\/+$/,"")}/tenant/${r}/pagebypath/${encodeURIComponent(o)}?cache=${a}&update=${i}`,u=Hi(t),c=await Wi(s,{method:"GET",headers:Gi(t)},u);if(!c.ok)throw new Error(`[pagepilot-visual-editor] renderToStaticHtml: GET ${s} → ${c.status}${c.text?`: ${c.text}`:""}`);const h=((d=c.body)==null?void 0:d.data)??((f=c.body)==null?void 0:f.payload)??c.body;return Id(e,h,{...t,fetchFn:u})}async function pI(e){const{baseUrl:t,tenantId:n,templateId:r,isGlobal:o=!1}=e,a=t.replace(/\/+$/,""),i=Hi(e),l=o?`${a}/global-template/${r}`:`${a}/tenant/${n}/template/${r}`,s=o?{"Content-Type":"application/json"}:Gi(e),u=await Wi(l,{method:"GET",headers:s},i);if(u.ok)return u.body;throw new Error(`[pagepilot-visual-editor] renderToStaticHtml: GET ${l} → ${u.status}${u.text?`: ${u.text}`:""}`)}function gI(e,t){if(!t)return e;const n=new Map;for(const o of e)o!=null&&o.id&&n.set(o.id,o);if(Array.isArray(t)){for(const o of t){if(!(o!=null&&o.id))continue;const i={...n.get(o.id)??{id:o.id,name:o.id,type:"text"},...o};n.set(o.id,i)}return Array.from(n.values())}const r=Object.entries(t).filter(([,o])=>o!=null);if(r.length===0)return e;for(const[o,a]of r){const i=String(a),l=n.get(o);l?n.set(o,{...l,value:i}):n.set(o,{id:o,name:o,type:"text",value:i})}return Array.from(n.values())}async function mI(e,t){const n=await pI(t),r=rI(n)??(e&&Object.keys(e).length>0?e:null);if(!r)return"";const o=nI(n),a=gI(o,t.variables),i=zi(r,a);return Fi(i,t)}function bI(e,t){return sI(t)?mI(e,t):lI(t)?fI(e,t):iI(t)?hI(e,t):Fi(e,t)}function xI(){return`block-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function vI(e,t){e.data&&(Array.isArray(e.data.childrenIds)&&(e.data.childrenIds=e.data.childrenIds.map(n=>t[n]??n)),e.data.props&&(Array.isArray(e.data.props.childrenIds)&&(e.data.props.childrenIds=e.data.props.childrenIds.map(n=>t[n]??n)),Array.isArray(e.data.props.startChildrenIds)&&(e.data.props.startChildrenIds=e.data.props.startChildrenIds.map(n=>t[n]??n)),Array.isArray(e.data.props.endChildrenIds)&&(e.data.props.endChildrenIds=e.data.props.endChildrenIds.map(n=>t[n]??n)),Array.isArray(e.data.props.columns)&&(e.data.props.columns=e.data.props.columns.map(n=>({...n,childrenIds:(n.childrenIds||[]).map(r=>t[r]??r)}))),Array.isArray(e.data.props.cells)&&(e.data.props.cells=e.data.props.cells.map(n=>n===null||typeof n!="object"?n:{...n,childrenIds:(n.childrenIds||[]).map(r=>t[r]??r)})),Array.isArray(e.data.props.items)&&(e.data.props.items=e.data.props.items.map(n=>({...n,...n.titleChildrenIds!==void 0?{titleChildrenIds:(n.titleChildrenIds||[]).map(r=>t[r]??r)}:{},...n.contentChildrenIds!==void 0?{contentChildrenIds:(n.contentChildrenIds||[]).map(r=>t[r]??r)}:{},...n.cardChildrenIds!==void 0?{cardChildrenIds:(n.cardChildrenIds||[]).map(r=>t[r]??r)}:{},...n.detailChildrenIds!==void 0?{detailChildrenIds:(n.detailChildrenIds||[]).map(r=>t[r]??r)}:{}})))))}function en(e,t){const n=oo(e,t),r={};n.forEach(a=>{r[a]=xI()});const o={};return n.forEach(a=>{const i=JSON.parse(JSON.stringify(e[a]));vI(i,r),o[r[a]]=i}),{newBlocks:o,idMap:r,newRootId:r[t]}}function kI(e,t,n){var r,o,a,i;for(const[l,s]of Object.entries(e)){if(!s||typeof s!="object")continue;const u=s;if(u.data&&Array.isArray(u.data.childrenIds)&&u.data.childrenIds.includes(t)){const c=u.data.childrenIds.indexOf(t),h=[...u.data.childrenIds];return h.splice(c+1,0,n),{parentId:l,updatedParent:{...u,data:{...u.data,childrenIds:h}}}}if(u.data&&u.data.props&&Array.isArray(u.data.props.childrenIds)&&u.data.props.childrenIds.includes(t)){const c=u.data.props.childrenIds.indexOf(t),h=[...u.data.props.childrenIds];return h.splice(c+1,0,n),{parentId:l,updatedParent:{...u,data:{...u.data,props:{...u.data.props,childrenIds:h}}}}}if(u.data&&u.data.props&&Array.isArray(u.data.props.columns)){const c=u.data.props.columns;for(let h=0;h<c.length;h++){const d=c[h];if(Array.isArray(d.childrenIds)&&d.childrenIds.includes(t)){const f=d.childrenIds.indexOf(t),p=c.map(b=>({...b,childrenIds:Array.isArray(b.childrenIds)?[...b.childrenIds]:[]}));return p[h].childrenIds.splice(f+1,0,n),{parentId:l,updatedParent:{...u,data:{...u.data,props:{...u.data.props,columns:p}}}}}}}if(u.data&&u.data.props&&Array.isArray(u.data.props.cells)){const c=u.data.props.cells;for(let h=0;h<c.length;h++){const d=c[h];if(Array.isArray(d.childrenIds)&&d.childrenIds.includes(t)){const f=d.childrenIds.indexOf(t),p=c.map(b=>({...b,childrenIds:Array.isArray(b.childrenIds)?[...b.childrenIds]:[]}));return p[h].childrenIds.splice(f+1,0,n),{parentId:l,updatedParent:{...u,data:{...u.data,props:{...u.data.props,cells:p}}}}}}}if(u.type==="PricingAccordion"&&((r=u.data)!=null&&r.props)&&Array.isArray(u.data.props.items)){const c=u.data.props.items;for(let h=0;h<c.length;h++){const d=Array.isArray(c[h].cardChildrenIds)?c[h].cardChildrenIds:[],f=Array.isArray(c[h].detailChildrenIds)?c[h].detailChildrenIds:[];for(const[p,b]of[[d,"cardChildrenIds"],[f,"detailChildrenIds"]])if(p.includes(t)){const x=p.indexOf(t),w=c.map(k=>({...k,cardChildrenIds:Array.isArray(k.cardChildrenIds)?[...k.cardChildrenIds]:[],detailChildrenIds:Array.isArray(k.detailChildrenIds)?[...k.detailChildrenIds]:[]}));return w[h][b].splice(x+1,0,n),{parentId:l,updatedParent:{...u,data:{...u.data,props:{...u.data.props,items:w}}}}}}}if((u.type==="TabsBlock"||u.type==="VerticalAccordion"||u.type==="Carousel"||u.type==="Marquee"||u.type==="Pagination")&&((o=u.data)!=null&&o.props)&&Array.isArray(u.data.props.items)){const c=u.data.props.items;for(let h=0;h<c.length;h++){const d=Array.isArray(c[h].contentChildrenIds)?c[h].contentChildrenIds:[];if(d.includes(t)){const f=d.indexOf(t),p=c.map(b=>({...b,contentChildrenIds:Array.isArray(b.contentChildrenIds)?[...b.contentChildrenIds]:[]}));return p[h].contentChildrenIds.splice(f+1,0,n),{parentId:l,updatedParent:{...u,data:{...u.data,props:{...u.data.props,items:p}}}}}}}if(u.type==="MenuPicker"&&((a=u.data)!=null&&a.props))for(const c of["startChildrenIds","endChildrenIds"]){const h=Array.isArray(u.data.props[c])?u.data.props[c]:[];if(h.includes(t)){const d=h.indexOf(t),f=[...h];return f.splice(d+1,0,n),{parentId:l,updatedParent:{...u,data:{...u.data,props:{...u.data.props,[c]:f}}}}}}if(u.type==="Accordion"&&((i=u.data)!=null&&i.props)&&Array.isArray(u.data.props.items)){const c=u.data.props.items;for(let h=0;h<c.length;h++){const d=c[h],f=Array.isArray(d.titleChildrenIds)?d.titleChildrenIds:[],p=Array.isArray(d.contentChildrenIds)?d.contentChildrenIds:[];if(f.includes(t)){const b=f.indexOf(t),x=c.map(w=>({...w,titleChildrenIds:Array.isArray(w.titleChildrenIds)?[...w.titleChildrenIds]:[],contentChildrenIds:Array.isArray(w.contentChildrenIds)?[...w.contentChildrenIds]:[]}));return x[h].titleChildrenIds.splice(b+1,0,n),{parentId:l,updatedParent:{...u,data:{...u.data,props:{...u.data.props,items:x}}}}}if(p.includes(t)){const b=p.indexOf(t),x=c.map(w=>({...w,titleChildrenIds:Array.isArray(w.titleChildrenIds)?[...w.titleChildrenIds]:[],contentChildrenIds:Array.isArray(w.contentChildrenIds)?[...w.contentChildrenIds]:[]}));return x[h].contentChildrenIds.splice(b+1,0,n),{parentId:l,updatedParent:{...u,data:{...u.data,props:{...u.data.props,items:x}}}}}}}}return null}function wI(e,t){var n,r,o;for(const[a,i]of Object.entries(e)){if((i==null?void 0:i.type)!=="FlexColumns")continue;const l=(r=(n=i==null?void 0:i.data)==null?void 0:n.props)==null?void 0:r.columns;if(Array.isArray(l)){for(let s=0;s<l.length;s++)if(Array.isArray((o=l[s])==null?void 0:o.childrenIds)&&l[s].childrenIds.includes(t))return{flexId:a,columnIndex:s}}}return null}function SI(e,t){var n,r,o;for(const[a,i]of Object.entries(e)){const l=(r=(n=i==null?void 0:i.data)==null?void 0:n.props)==null?void 0:r.cells;if(!((i==null?void 0:i.type)!=="Grid"||!Array.isArray(l))){for(let s=0;s<l.length;s++)if(Array.isArray((o=l[s])==null?void 0:o.childrenIds)&&l[s].childrenIds.includes(t))return{gridId:a,cellIndex:s}}}return null}function $I(e,t){var n,r,o;for(const[a,i]of Object.entries(e)){if((i==null?void 0:i.type)!=="Pagination")continue;const l=(r=(n=i==null?void 0:i.data)==null?void 0:n.props)==null?void 0:r.cells;if(Array.isArray(l)){for(let s=0;s<l.length;s++)if(Array.isArray((o=l[s])==null?void 0:o.childrenIds)&&l[s].childrenIds.includes(t))return{paginationId:a,cellIndex:s}}}return null}function _I(e,t){var n,r,o;for(const[a,i]of Object.entries(e)){const l=i==null?void 0:i.type;if(l!=="Carousel"&&l!=="Marquee"&&l!=="TabsBlock")continue;const s=(r=(n=i==null?void 0:i.data)==null?void 0:n.props)==null?void 0:r.items;if(Array.isArray(s)){for(let u=0;u<s.length;u++)if(Array.isArray((o=s[u])==null?void 0:o.contentChildrenIds)&&s[u].contentChildrenIds.includes(t))return{parentId:a,itemIndex:u,parentType:l}}}return null}function lc(e,t,n){var d,f,p;if(!e[t])return null;const r=e[t];if((r==null?void 0:r.type)==="TabsBlock"){const x=Array.isArray((f=(d=r.data)==null?void 0:d.props)==null?void 0:f.items)?r.data.props.items:[];if(x.length>=10)return null;const w=x[0]??{},k=Array.isArray(w.contentChildrenIds)?w.contentChildrenIds:[];let S={...e};const v=[];let _=null;for(const I of k){if(!S[I])continue;const{newBlocks:R,newRootId:E}=en(S,I);S={...S,...R},v.push(E),_||(_=E)}const y=_??t,C=[...x,{label:w.label??`Tab ${x.length+1}`,contentChildrenIds:v}];return S={...S,[t]:{...r,data:{...r.data,props:{...r.data.props,items:C}}}},{updatedDocument:S,newRootId:y}}const o=SI(e,n);if(o){const b=e[o.gridId],x=b.data.props??{},w=x.columnsCount??2,k=x.rowsCount??2,S=Array.isArray(x.cells)?x.cells:[],_=S.some(M=>(M==null?void 0:M.colStart)!=null||(M==null?void 0:M.rowStart)!=null||(M==null?void 0:M.colSpan)!=null||(M==null?void 0:M.rowSpan)!=null)?S.length:w*k,y=Array.from({length:_},(M,P)=>S[P]??{childrenIds:[]});let C=y.findIndex((M,P)=>P>o.cellIndex&&(!Array.isArray(M==null?void 0:M.childrenIds)||M.childrenIds.length===0));if(C===-1&&(C=y.findIndex(M=>!Array.isArray(M==null?void 0:M.childrenIds)||M.childrenIds.length===0)),C===-1)return null;const{newBlocks:I,newRootId:R}=en(e,t),E=y.map((M,P)=>P===C?{...M,childrenIds:[...(M==null?void 0:M.childrenIds)??[],R]}:M);return{updatedDocument:{...e,...I,[o.gridId]:{...b,data:{...b.data,props:{...b.data.props,cells:E}}}},newRootId:R}}const a=$I(e,n);if(a){const b=e[a.paginationId],x=b.data.props??{},w=x.columnsCount??2,k=x.rowsCount??2,S=Array.isArray(x.cells)?x.cells:[],v=Math.max(w*k,S.length),_=Array.from({length:v},(L,M)=>S[M]??{childrenIds:[]});let y=_.findIndex((L,M)=>M>a.cellIndex&&(!Array.isArray(L==null?void 0:L.childrenIds)||L.childrenIds.length===0));y===-1&&(y=_.findIndex(L=>!Array.isArray(L==null?void 0:L.childrenIds)||L.childrenIds.length===0)),y===-1&&(_.push({childrenIds:[]}),y=_.length-1);const{newBlocks:C,newRootId:I}=en(e,t),R=_.map((L,M)=>M===y?{...L,childrenIds:[...(L==null?void 0:L.childrenIds)??[],I]}:L);return{updatedDocument:{...e,...C,[a.paginationId]:{...b,data:{...b.data,props:{...b.data.props,cells:R}}}},newRootId:I}}const i=wI(e,n);if(i){const b=e[i.flexId],x=b.data.props??{},w=x.columnsCount??2,k=Array.isArray(x.columns)?x.columns:[],S=Array.from({length:w},(R,E)=>k[E]??{childrenIds:[]});let v=S.findIndex((R,E)=>E>i.columnIndex&&(!Array.isArray(R==null?void 0:R.childrenIds)||R.childrenIds.length===0));if(v===-1&&(v=S.findIndex(R=>!Array.isArray(R==null?void 0:R.childrenIds)||R.childrenIds.length===0)),v===-1)return null;const{newBlocks:_,newRootId:y}=en(e,t),C=S.map((R,E)=>E===v?{...R,childrenIds:[...(R==null?void 0:R.childrenIds)??[],y]}:R);return{updatedDocument:{...e,..._,[i.flexId]:{...b,data:{...b.data,props:{...b.data.props,columns:C}}}},newRootId:y}}const l=_I(e,n);if(l){let b=e[l.parentId],x=Array.isArray((p=b.data.props)==null?void 0:p.items)?b.data.props.items:[],w=e,k=x.findIndex((C,I)=>I>l.itemIndex&&(!Array.isArray(C==null?void 0:C.contentChildrenIds)||C.contentChildrenIds.length===0));if(k===-1&&(k=x.findIndex(C=>!Array.isArray(C==null?void 0:C.contentChildrenIds)||C.contentChildrenIds.length===0)),k===-1)if(l.parentType==="TabsBlock"&&x.length<10){const C=[...x,{label:`Tab ${x.length+1}`,contentChildrenIds:[]}];w={...w,[l.parentId]:{...b,data:{...b.data,props:{...b.data.props,items:C}}}},b=w[l.parentId],x=C,k=x.length-1}else return null;const{newBlocks:S,newRootId:v}=en(w,t),_=x.map((C,I)=>I===k?{...C,...l.parentType==="TabsBlock"&&!(C!=null&&C.label)?{label:`Tab ${I+1}`}:{},contentChildrenIds:[...(C==null?void 0:C.contentChildrenIds)??[],v]}:C);return{updatedDocument:{...w,...S,[l.parentId]:{...b,data:{...b.data,props:{...b.data.props,items:_}}}},newRootId:v}}const{newBlocks:s,newRootId:u}=en(e,t),c={...e,...s},h=kI(c,n,u);return h&&(c[h.parentId]=h.updatedParent),{updatedDocument:c,newRootId:u}}function Rd(e,t){const n=o=>Array.isArray(o)?o.filter(a=>!t.has(a)):o,r={};for(const[o,a]of Object.entries(e)){if(t.has(o))continue;const i=a;if(!(i!=null&&i.data)){r[o]=i;continue}const l={...i.data};if(Array.isArray(l.childrenIds)&&(l.childrenIds=n(l.childrenIds)),l.props){const s={...l.props};Array.isArray(s.childrenIds)&&(s.childrenIds=n(s.childrenIds)),Array.isArray(s.startChildrenIds)&&(s.startChildrenIds=n(s.startChildrenIds)),Array.isArray(s.endChildrenIds)&&(s.endChildrenIds=n(s.endChildrenIds)),Array.isArray(s.columns)&&(s.columns=s.columns.map(u=>({...u,childrenIds:n(u.childrenIds)}))),Array.isArray(s.cells)&&(s.cells=s.cells.map(u=>u===null||typeof u!="object"?u:{...u,childrenIds:n(u.childrenIds)})),Array.isArray(s.items)&&(s.items=s.items.map(u=>({...u,...u.titleChildrenIds!==void 0?{titleChildrenIds:n(u.titleChildrenIds)}:{},...u.contentChildrenIds!==void 0?{contentChildrenIds:n(u.contentChildrenIds)}:{},...u.cardChildrenIds!==void 0?{cardChildrenIds:n(u.cardChildrenIds)}:{},...u.detailChildrenIds!==void 0?{detailChildrenIds:n(u.detailChildrenIds)}:{}}))),l.props=s}r[o]={...i,data:l}}return r}function CI(e){var r;const t=e==null?void 0:e.type,n=((r=e==null?void 0:e.data)==null?void 0:r.props)??{};if(t==="Grid"){const o=n.columnsCount??2,a=n.rowsCount??2,i=Array.isArray(n.cells)?n.cells:[],s=i.some(c=>(c==null?void 0:c.colStart)!=null||(c==null?void 0:c.rowStart)!=null||(c==null?void 0:c.colSpan)!=null||(c==null?void 0:c.rowSpan)!=null)?i.length:o*a,u=Array.from({length:s},(c,h)=>{var d;return{childrenIds:Array.isArray((d=i[h])==null?void 0:d.childrenIds)?i[h].childrenIds:[]}});return{slotCount:s,slots:u}}if(t==="FlexColumns"){const o=n.columnsCount??(Array.isArray(n.columns)?n.columns.length:2),a=Array.isArray(n.columns)?n.columns:[],i=Array.from({length:o},(l,s)=>{var u;return{childrenIds:Array.isArray((u=a[s])==null?void 0:u.childrenIds)?a[s].childrenIds:[]}});return{slotCount:o,slots:i}}if(t==="Carousel"||t==="Marquee"){const o=Array.isArray(n.items)?n.items:[],a=o.length,i=o.map(l=>({childrenIds:Array.isArray(l==null?void 0:l.contentChildrenIds)?l.contentChildrenIds:[]}));return{slotCount:a,slots:i}}if(t==="TabsBlock"){const o=Array.isArray(n.items)?n.items:[],a=o.length,i=o.map(l=>({childrenIds:Array.isArray(l==null?void 0:l.contentChildrenIds)?l.contentChildrenIds:[]}));return{slotCount:a,slots:i}}if(t==="Pagination"){const o=n.columnsCount??2,a=n.rowsCount??2,i=Array.isArray(n.cells)?n.cells:[],l=Math.max(o*a,i.length),s=Array.from({length:l},(u,c)=>{var h;return{childrenIds:Array.isArray((h=i[c])==null?void 0:h.childrenIds)?i[c].childrenIds:[]}});return{slotCount:l,slots:s}}return null}function hr(e){return e==="Grid"||e==="FlexColumns"||e==="Carousel"||e==="Marquee"||e==="Pagination"||e==="TabsBlock"}const Tr=new WeakMap;function xo(e,t){const n=e[t];if(!n||typeof n!="object")return null;const r=Tr.get(n);if(r!==void 0)return r&&r.containerId===t?r:r&&{...r,containerId:t};if(!hr(n.type))return Tr.set(n,null),null;const o=CI(n);if(!o)return Tr.set(n,null),null;const{slotCount:a,slots:i}=o,l=i.findIndex(c=>c.childrenIds.length>0),s=i.filter(c=>c.childrenIds.length===0).length,u={containerId:t,type:n.type,slotCount:a,slots:i,firstFilledSlot:l,emptySlotCount:s};return Tr.set(n,u),u}function oi(e,t){for(const[n,r]of Object.entries(e)){if(!hr(r==null?void 0:r.type))continue;const o=xo(e,n);if(o!=null&&o.slots.some(a=>a.childrenIds.includes(t)))return n}return null}function Td(e,t,n,r){var u;const o=e[t];if(!o||!hr(o.type))return e;const a=((u=o.data)==null?void 0:u.props)??{};if(o.type==="Grid"){let c=a.columnsCount??2,h=a.rowsCount??2;if(c*h>=n)return e;r==="columns"?c=Math.max(c,Math.ceil(n/Math.max(1,h))):h=Math.max(h,Math.ceil(n/Math.max(1,c)));const d=c*h,f=Array.isArray(a.cells)?a.cells:[],p=Array.from({length:d},(b,x)=>f[x]??{childrenIds:[]});return{...e,[t]:{...o,data:{...o.data,props:{...a,columnsCount:c,rowsCount:h,cells:p}}}}}if(o.type==="Carousel"){const h=Array.isArray(a.items)?a.items:[];if(h.length>=n)return e;const d=Math.min(n,20),f=Array.from({length:d},(p,b)=>h[b]??{contentChildrenIds:[]});return{...e,[t]:{...o,data:{...o.data,props:{...a,items:f}}}}}if(o.type==="Marquee"){const h=Array.isArray(a.items)?a.items:[];if(h.length>=n)return e;const d=Math.min(n,30),f=Array.from({length:d},(p,b)=>h[b]??{contentChildrenIds:[]});return{...e,[t]:{...o,data:{...o.data,props:{...a,items:f}}}}}if(o.type==="TabsBlock"){const h=Array.isArray(a.items)?a.items:[];if(h.length>=n)return e;const d=Math.min(n,10),f=Array.from({length:d},(p,b)=>h[b]??{label:`Tab ${b+1}`,contentChildrenIds:[]});return{...e,[t]:{...o,data:{...o.data,props:{...a,items:f}}}}}if(o.type==="Pagination"){const c=a.columnsCount??2,h=a.rowsCount??2,d=Array.isArray(a.cells)?a.cells:[];if(Math.max(c*h,d.length)>=n)return e;const p=Array.from({length:n},(b,x)=>d[x]??{childrenIds:[]});return{...e,[t]:{...o,data:{...o.data,props:{...a,cells:p}}}}}if((a.columnsCount??(Array.isArray(a.columns)?a.columns.length:2))>=n)return e;const l=Array.isArray(a.columns)?a.columns:[],s=Array.from({length:n},(c,h)=>l[h]??{childrenIds:[]});return{...e,[t]:{...o,data:{...o.data,props:{...a,columnsCount:n,columns:s}}}}}function Ed(e,t,n){var u;const r=e[t];if(!r||!hr(r.type))return e;const o=xo(e,t);if(!o)return e;let a=-1;o.slots.forEach((c,h)=>{c.childrenIds.length>0&&(a=h)});const i=Math.max(n,a+1,1);if(i>=o.slotCount)return e;const l=((u=r.data)==null?void 0:u.props)??{};if(r.type==="Pagination"){const c=(l.columnsCount??2)*(l.rowsCount??2),h=Math.max(i,c);if(h>=o.slotCount)return e;const d=Array.isArray(l.cells)?l.cells:[];return{...e,[t]:{...r,data:{...r.data,props:{...l,cells:d.slice(0,h)}}}}}if(r.type==="Carousel"||r.type==="Marquee"||r.type==="TabsBlock"){const c=Array.isArray(l.items)?l.items:[];return{...e,[t]:{...r,data:{...r.data,props:{...l,items:c.slice(0,i)}}}}}if(r.type==="Grid"){const c=l.columnsCount??2,h=l.rowsCount??2,d=Math.max(1,Math.ceil(i/Math.max(1,c)));if(d>=h)return e;const f=Array.isArray(l.cells)?l.cells:[];return{...e,[t]:{...r,data:{...r.data,props:{...l,rowsCount:d,cells:f.slice(0,c*d)}}}}}const s=Array.isArray(l.columns)?l.columns:[];return{...e,[t]:{...r,data:{...r.data,props:{...l,columnsCount:i,columns:s.slice(0,i)}}}}}function AI(e,t,n,r="columns"){const o=t==null?void 0:t.sourceBlockId;if(!o||!e[o])return null;const a=Math.max(1,n);let i=e,l=Array.isArray(t.rowIds)?[...t.rowIds]:[],s=1+l.length;if(s===a)return{document:i,sourceBlockId:o,rowIds:l,achievedRowCount:s,capacityLimited:!1};if(s<a){let h=!1;for(;s<a;){const d=l.length>0?l[l.length-1]:o;let f=lc(i,o,d);if(!f){const p=oi(i,o);if(!p){h=!0;break}const b=xo(i,p),x=((b==null?void 0:b.slotCount)??0)+(a-s),w=Td(i,p,x,r);if(w===i){h=!0;break}if(i=w,f=lc(i,o,d),!f){h=!0;break}}i=f.updatedDocument,l=[...l,f.newRootId],s=1+l.length}return{document:i,sourceBlockId:o,rowIds:l,achievedRowCount:s,capacityLimited:h}}const u=a,c=l.slice(u-1);if(c.length>0){const h=new Set;for(const f of c)for(const p of oo(i,f))h.add(p);i=Rd(i,h);const d=oi(i,o);d&&(i=Ed(i,d,u)),l=l.slice(0,u-1),s=1+l.length}return{document:i,sourceBlockId:o,rowIds:l,achievedRowCount:s,capacityLimited:!1}}exports.Reader=or;exports.ReaderBlock=Me;exports.ReaderBlockSchema=kd;exports.ReaderDocumentSchema=Ay;exports.cloneSubtree=en;exports.extractApiRows=Di;exports.findRepeatableContainerOf=oi;exports.getRepeatableContainerInfo=xo;exports.growContainerToFit=Td;exports.isRepeatableContainerType=hr;exports.reconcileRepeatFieldRowCount=AI;exports.refreshApiDataSources=_d;exports.refreshDocumentApiDataSources=Cd;exports.removeSubtree=Rd;exports.renderToStaticHtml=bI;exports.renderToStaticMarkup=Bi;exports.shrinkContainerToFit=Ed;
package/dist/render.js CHANGED
@@ -19633,6 +19633,9 @@ function Wi(e, t) {
19633
19633
  accessibilityTools: t.accessibilityTools ?? a.accessibilityTools,
19634
19634
  injectTabsScrollSyncScript: t.injectTabsScrollSyncScript,
19635
19635
  injectCarouselScript: t.injectCarouselScript,
19636
+ injectPaginationScript: t.injectPaginationScript,
19637
+ injectAnimationScript: t.injectAnimationScript,
19638
+ injectPostMessageScript: t.injectPostMessageScript,
19636
19639
  injectFontAssets: t.injectFontAssets,
19637
19640
  seo: t.seo,
19638
19641
  headHtml: t.headHtml,
@@ -12,6 +12,9 @@ interface BaseRenderOptions {
12
12
  accessibilityTools?: any;
13
13
  injectTabsScrollSyncScript?: boolean;
14
14
  injectCarouselScript?: boolean;
15
+ injectPaginationScript?: boolean;
16
+ injectAnimationScript?: boolean;
17
+ injectPostMessageScript?: boolean;
15
18
  injectFontAssets?: boolean;
16
19
  seo?: any;
17
20
  headHtml?: string;
@@ -1,4 +1,4 @@
1
- "use strict";const $0=require("./index-C-4OVLjk.cjs"),B0=require("./_commonjs-dynamic-modules-DMkBISW1.cjs");function op(i0,Wr){for(var l=0;l<Wr.length;l++){const x=Wr[l];if(typeof x!="string"&&!Array.isArray(x)){for(const a in x)if(a!=="default"&&!(a in i0)){const e=Object.getOwnPropertyDescriptor(x,a);e&&Object.defineProperty(i0,a,e.get?e:{enumerable:!0,get:()=>x[a]})}}}return Object.freeze(Object.defineProperty(i0,Symbol.toStringTag,{value:"Module"}))}var gi={exports:{}},xi={exports:{}},Ef;function Cf(){return Ef||(Ef=1,function(i0){var Wr={version:"1.14.0"};Wr[437]=function(){for(var l=`\0\x07\b
1
+ "use strict";const $0=require("./index-BO4IFeAW.cjs"),B0=require("./_commonjs-dynamic-modules-DMkBISW1.cjs");function op(i0,Wr){for(var l=0;l<Wr.length;l++){const x=Wr[l];if(typeof x!="string"&&!Array.isArray(x)){for(const a in x)if(a!=="default"&&!(a in i0)){const e=Object.getOwnPropertyDescriptor(x,a);e&&Object.defineProperty(i0,a,e.get?e:{enumerable:!0,get:()=>x[a]})}}}return Object.freeze(Object.defineProperty(i0,Symbol.toStringTag,{value:"Module"}))}var gi={exports:{}},xi={exports:{}},Ef;function Cf(){return Ef||(Ef=1,function(i0){var Wr={version:"1.14.0"};Wr[437]=function(){for(var l=`\0\x07\b
2
2
  \v\f\r\x1B !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\`abcdefghijklmnopqrstuvwxyz{|}~ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ `,x=[],a={},e=0;e!=l.length;++e)l.charCodeAt(e)!==65533&&(a[l.charAt(e)]=e),x[e]=l.charAt(e);return{enc:a,dec:x}}(),Wr[620]=function(){for(var l=`\0\x07\b
3
3
  \v\f\r\x1B !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\`abcdefghijklmnopqrstuvwxyz{|}~ÇüéâäàąçêëèïîćÄĄĘęłôöĆûùŚÖܢ٥śƒŹŻóÓńŃźż¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ `,x=[],a={},e=0;e!=l.length;++e)l.charCodeAt(e)!==65533&&(a[l.charAt(e)]=e),x[e]=l.charAt(e);return{enc:a,dec:x}}(),Wr[737]=function(){for(var l=`\0\x07\b
4
4
  \v\f\r\x1B !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\`abcdefghijklmnopqrstuvwxyz{|}~ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρσςτυφχψ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ωάέήϊίόύϋώΆΈΉΊΌΎΏ±≥≤ΪΫ÷≈°∙·√ⁿ²■ `,x=[],a={},e=0;e!=l.length;++e)l.charCodeAt(e)!==65533&&(a[l.charAt(e)]=e),x[e]=l.charAt(e);return{enc:a,dec:x}}(),Wr[850]=function(){for(var l=`\0\x07\b
@@ -1,4 +1,4 @@
1
- import { c as Ln, g as lp, a as op } from "./index-DvEcR48I.js";
1
+ import { c as Ln, g as lp, a as op } from "./index-LXr2Pc6N.js";
2
2
  import { c as B0 } from "./_commonjs-dynamic-modules-BpilXLfW.js";
3
3
  function up(i0, Wr) {
4
4
  for (var o = 0; o < Wr.length; o++) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pagepilot-visual-editor",
3
- "version": "1.0.43",
3
+ "version": "1.0.44",
4
4
  "description": "Standalone visual editor — drop <PagePilotEditor> into any React app and get Style/Layout/Inspect/Layers panels, drag-and-drop blocks, undo/redo, dirty-tracked save, multi-section pages, and light/dark themes",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",