@base44/vite-plugin 1.0.35 → 1.0.37

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.
@@ -1,16 +1,16 @@
1
- function ge(e,t){let n=t.top<27,r=t.height>=54,i=t.width>=window.innerWidth-4,a=i?"8px":"-2px",m=i?"8px":"4px";n&&r?(e.style.top="2px",e.style.left=m):n?(e.style.top=`${t.height+2}px`,e.style.left=a):(e.style.top="-27px",e.style.left=a)}function j(e){let t=e;return!!(t.dataset?.sourceLocation||t.dataset?.visualSelectorId)}function _(e){let t=e;return t.dataset?.sourceLocation||t.dataset?.visualSelectorId||null}var Z=["src"],C="data-vite-plugin-element";function x(e){if(!e)return[];let t=Array.from(document.querySelectorAll(`[data-source-location="${e}"]`));return t.length>0?t:Array.from(document.querySelectorAll(`[data-visual-selector-id="${e}"]`))}function he(e,t){e.forEach(n=>{n.setAttribute("class",t)})}function ve(e,t,n,r){if(!Z.includes(t))return;let i=r!=null?String(r):null;e.forEach(a=>{(i===null||a.dataset.arrIndex===i)&&a.setAttribute(t,n)})}function $(e){return e.getAttribute("class")??""}function ye(e,t){let n={};for(let r of t){let i=e.getAttribute(r);i!==null&&(n[r]=i)}return n}function be(){if(document.getElementById("freeze-animations"))return;document.documentElement.setAttribute("data-visual-edit-active","");let e=document.createElement("style");e.id="freeze-animations",e.textContent=`
2
- [data-visual-edit-active] *:not([${C}]):not([${C}] *),
3
- [data-visual-edit-active] *:not([${C}]):not([${C}] *)::before,
4
- [data-visual-edit-active] *:not([${C}]):not([${C}] *)::after {
1
+ function be(e,t){let n=t.top<27,o=t.height>=54,i=t.width>=window.innerWidth-4,a=i?"8px":"-2px",m=i?"8px":"4px";n&&o?(e.style.top="2px",e.style.left=m):n?(e.style.top=`${t.height+2}px`,e.style.left=a):(e.style.top="-27px",e.style.left=a)}function ee(e){let t=e;return!!(t.dataset?.sourceLocation||t.dataset?.visualSelectorId)}function _(e){let t=e;return t.dataset?.sourceLocation||t.dataset?.visualSelectorId||null}function te(e){return e.hasAttribute("data-base44-image")}function O(e){return te(e)?"IMG":e.tagName}var ne=["src"],A="data-vite-plugin-element";function x(e){if(!e)return[];let t=Array.from(document.querySelectorAll(`[data-source-location="${e}"]`));return t.length>0?t:Array.from(document.querySelectorAll(`[data-visual-selector-id="${e}"]`))}function Le(e,t){e.forEach(n=>{n.setAttribute("class",t)})}function Te(e,t,n,o){if(!ne.includes(t))return;let i=o!=null?String(o):null;e.forEach(a=>{(i===null||a.dataset.arrIndex===i)&&(t==="src"&&te(a)?a.dispatchEvent(new CustomEvent("base44:image-replace",{detail:{src:n}})):a.setAttribute(t,n))})}function z(e){return e.getAttribute("class")??""}function we(e,t){let n={};for(let o of t){let i=o==="src"&&te(e)?e.getAttribute("data-base44-image-src"):e.getAttribute(o);i!==null&&(n[o]=i)}return n}function Ie(){if(document.getElementById("freeze-animations"))return;document.documentElement.setAttribute("data-visual-edit-active","");let e=document.createElement("style");e.id="freeze-animations",e.textContent=`
2
+ [data-visual-edit-active] *:not([${A}]):not([${A}] *),
3
+ [data-visual-edit-active] *:not([${A}]):not([${A}] *)::before,
4
+ [data-visual-edit-active] *:not([${A}]):not([${A}] *)::after {
5
5
  animation-play-state: paused !important;
6
6
  transition: none !important;
7
7
  }
8
8
  `;let t=document.createElement("style");t.id="freeze-pointer-events",t.textContent=`
9
9
  [data-visual-edit-active] * { pointer-events: none !important; }
10
- [${C}], [${C}] * { pointer-events: auto !important; }
11
- `;let n=document.head||document.documentElement;n.appendChild(e),n.appendChild(t),document.getAnimations().forEach(r=>{let i=r.effect?.target;if(!(i instanceof Element&&i.closest(`[${C}]`)))try{r.finish()}catch{r.pause()}})}function Le(){let e=document.getElementById("freeze-animations");e&&(e.remove(),document.getElementById("freeze-pointer-events")?.remove(),document.documentElement.removeAttribute("data-visual-edit-active"),document.getAnimations().forEach(t=>{if(t.playState==="paused")try{t.play()}catch{}}))}function J(e,t){let n=document.getElementById("freeze-pointer-events");n&&(n.disabled=!0);let r=document.elementFromPoint(e,t);return n&&(n.disabled=!1),r?.closest("[data-source-location], [data-visual-selector-id]")??null}function Te(e,t,n){let r=J(e,t);if(!r)return null;let i=_(r);return i===n?null:i}var dt="visual-edit-font-face-";function ct(e){let t=e.trim();if(!t.startsWith("@font-face")||t.includes("\\"))return!1;let n=(t.match(/{/g)||[]).length,r=(t.match(/}/g)||[]).length;if(n!==1||r!==1||!t.endsWith("}"))return!1;let i=t.split(/url\(/i);for(let a=1;a<i.length;a++){let m=i[a].indexOf(")");if(m===-1)return!1;let u=i[a].slice(0,m).trim().replace(/^['"]|['"]$/g,"").trim();if(!/^https:\/\//i.test(u))return!1}return!0}function we(e,t){if(typeof e!="string"||!e.trim()||typeof t!="string"||!ct(t))return;let n=`${dt}${e}`;if(document.getElementById(n))return;let r=document.createElement("style");r.id=n,r.dataset.visualEditFontFace="true",r.textContent=t,document.head.appendChild(r)}var Se={position:"absolute",backgroundColor:"#ffffff",border:"1px solid #e2e8f0",borderRadius:"6px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",fontSize:"12px",minWidth:"120px",maxHeight:"200px",overflowY:"auto",zIndex:"10001",padding:"4px 0",pointerEvents:"auto"},Ie={padding:"4px 12px",cursor:"pointer",color:"#334155",backgroundColor:"transparent",whiteSpace:"nowrap",lineHeight:"1.5",fontWeight:"400"},X="#526cff",Me="#DBEAFE",Ce="600",Q="#f1f5f9",Ae=10,ee='<svg width="12" height="12" viewBox="0 0 24 24" style="vertical-align:middle;margin-left:4px"><path d="M6 9l6 6 6-6" stroke="currentColor" stroke-width="2" fill="none"/></svg>',_e='<svg width="12" height="12" viewBox="0 0 24 24" style="vertical-align:middle;margin-left:4px"><path d="M18 15l-6-6-6 6" stroke="currentColor" stroke-width="2" fill="none"/></svg>',B="data-chevron",De=12,k="data-layer-dropdown",xe=2,He=2;function te(e,t){for(let n of Object.keys(t))e.style.setProperty(n.replace(/[A-Z]/g,r=>`-${r.toLowerCase()}`),t[n])}function Oe(e){return e.tagName}function ne(e,t){let n={element:e,tagName:e.tagName.toLowerCase(),selectorId:_(e)};return t!==void 0&&(n.depth=t),n}function Ne(e,t,n){let r=[];function i(a,m){if(!(m>t))for(let u=0;u<a.children.length;u++){let v=a.children[u];if(j(v)){let f={element:v,tagName:v.tagName.toLowerCase(),selectorId:_(v)};n!==void 0&&(f.depth=n+m-1),r.push(f),i(v,m+1)}else i(v,m)}}return i(e,1),r}function ut(e){let t=[],n=e.parentElement;for(;n&&n!==document.documentElement&&n!==document.body&&t.length<xe;)j(n)&&t.push(ne(n)),n=n.parentElement;return t.reverse(),t}function ft(e,t){return t.forEach((n,r)=>{e.push({...n,depth:r})}),t.length}function Re(e,t,n){e.push(ne(t,n));let r=Ne(t,He,n+1);e.push(...r)}function mt(e){return e.at(-1)?.element??null}function pt(e,t){let n=Ne(e,1);return n.some(r=>r.element===t)||n.push(ne(t)),n}function Et(e,t,n,r){let i=_(n),a=new Set;for(let m of t)if(m.element===n)Re(e,n,r),i&&a.add(i);else{let u=m.selectorId;if(u!=null){if(u===i||a.has(u))continue;a.add(u)}e.push({...m,depth:r})}}function Pe(e){let t=ut(e),n=[],r=ft(n,t),i=mt(t);if(i){let a=pt(i,e);Et(n,a,e,r)}else Re(n,e,r);return n}var R=null,oe=null,V=null,Y=null,F=null;function gt(e,t,{onSelect:n,onHover:r,onHoverEnd:i}){let a=document.createElement("div");a.textContent=Oe(e),te(a,Ie);let m=e.depth??0;return m>0&&(a.style.paddingLeft=`${De+m*Ae}px`),t&&(a.style.color=X,a.style.backgroundColor=Me,a.style.fontWeight=Ce),a.addEventListener("mouseenter",()=>{t||(a.style.backgroundColor=Q),r&&r(e)}),a.addEventListener("mouseleave",()=>{t||(a.style.backgroundColor="transparent"),i&&i()}),a.addEventListener("click",u=>{u.stopPropagation(),u.preventDefault(),n(e)}),a}function ht(e,t,n){let r=document.createElement("div");return r.setAttribute(k,"true"),r.setAttribute(C,"true"),te(r,Se),e.forEach(i=>{let a=i.element===t;r.appendChild(gt(i,a,n))}),r}function Be(e){if(e.querySelector(`[${B}]`))return;let t=document.createElement("span");t.setAttribute(B,"true"),t.style.display="inline-flex",t.innerHTML=ee,e.appendChild(t),e.style.display="inline-flex",e.style.alignItems="center",e.style.cursor="pointer",e.style.userSelect="none",e.style.whiteSpace="nowrap",e.style.pointerEvents="auto",e.setAttribute(k,"true"),e.setAttribute(C,"true")}function vt(e,t,n,{onSelect:r,onHover:i,onHoverEnd:a}){let m=Array.from(e.children),u=t.findIndex(f=>f.element===n),v=f=>{if(u>=0&&u<m.length){let y=m[u];y.style.color!==X&&(y.style.backgroundColor="transparent")}if(u=f,u>=0&&u<m.length){let y=m[u];y.style.color!==X&&(y.style.backgroundColor=Q),y.scrollIntoView({block:"nearest"}),i&&u>=0&&u<t.length&&i(t[u])}};F=f=>{f.key==="ArrowDown"?(f.preventDefault(),f.stopPropagation(),v(u<m.length-1?u+1:0)):f.key==="ArrowUp"?(f.preventDefault(),f.stopPropagation(),v(u>0?u-1:m.length-1)):f.key==="Enter"&&u>=0&&u<t.length&&(f.preventDefault(),f.stopPropagation(),a&&a(),r(t[u]),H())},document.addEventListener("keydown",F,!0)}function yt(e,t){let n=!0;V=r=>{if(n){n=!1;return}let i=r.target;!e.contains(i)&&i!==t&&H()},document.addEventListener("mousedown",V,!0)}function ke(e,t,n,r){H();let i=ht(t,n,{...r,onSelect:u=>{r.onHoverEnd&&r.onHoverEnd(),r.onSelect(u),H()}}),a=e.parentElement;if(!a)return;i.style.top=`${e.offsetTop+e.offsetHeight+2}px`,i.style.left=`${e.offsetLeft}px`,a.appendChild(i),R=i,oe=e;let m=e.querySelector(`[${B}]`);m&&(m.innerHTML=_e),Y=r.onHoverEnd??null,vt(i,t,n,r),yt(i,e)}function H(){let e=oe?.querySelector(`[${B}]`);e&&(e.innerHTML=ee),oe=null,Y&&(Y(),Y=null),R&&R.parentNode&&R.remove(),R=null,V&&(document.removeEventListener("mousedown",V,!0),V=null),F&&(document.removeEventListener("keydown",F,!0),F=null)}function Ve(){return R!==null}function Fe(e){let t=null,n=null,r=null,i=()=>{t&&t.parentNode&&t.remove(),t=null},a=b=>{i(),_(b.element)!==e.getSelectedElementId()&&(t=e.createPreviewOverlay(b.element))},m=b=>{i(),H(),n&&(document.removeEventListener("keydown",n,!0),n=null),r=null;let s=e.selectElement(b.element);f(s,b.element)},u=()=>{n&&(document.removeEventListener("keydown",n,!0),n=null),r&&(m(r),r=null)},v=(b,s,c,I,w)=>{b.stopPropagation(),b.preventDefault(),Ve()?(H(),u()):(r={element:c,tagName:c.tagName.toLowerCase(),selectorId:w},e.onDeselect(),n=S=>{S.key==="Escape"&&(S.stopPropagation(),H(),u())},document.addEventListener("keydown",n,!0),ke(s,I,c,{onSelect:m,onHover:a,onHoverEnd:i}))},f=(b,s)=>{if(!b)return;let c=b.querySelector("div");if(!c)return;let I=Pe(s);if(I.length<=1)return;let w=_(s);Be(c),c.addEventListener("click",S=>{v(S,c,s,I,w)})};return{attachToOverlay:f,cleanup:()=>{i(),H()}}}var re="visual-edit-focus-styles",bt=["div","p","h1","h2","h3","h4","h5","h6","span","li","td","a","button","label"],ie=e=>!!e.dataset.arrField,Lt=e=>!(!bt.includes(e.tagName.toLowerCase())||!e.textContent?.trim()||e.querySelector("img, video, canvas, svg")||e.children?.length>0),We=()=>{if(document.getElementById(re))return;let e=document.createElement("style");e.id=re,e.textContent=`
10
+ [${A}], [${A}] * { pointer-events: auto !important; }
11
+ `;let n=document.head||document.documentElement;n.appendChild(e),n.appendChild(t),document.getAnimations().forEach(o=>{let i=o.effect?.target;if(!(i instanceof Element&&i.closest(`[${A}]`)))try{o.finish()}catch{o.pause()}})}function Se(){let e=document.getElementById("freeze-animations");e&&(e.remove(),document.getElementById("freeze-pointer-events")?.remove(),document.documentElement.removeAttribute("data-visual-edit-active"),document.getAnimations().forEach(t=>{if(t.playState==="paused")try{t.play()}catch{}}))}function oe(e,t){let n=document.getElementById("freeze-pointer-events");n&&(n.disabled=!0);let o=document.elementFromPoint(e,t);return n&&(n.disabled=!1),o?.closest("[data-source-location], [data-visual-selector-id]")??null}function Me(e,t,n){let o=oe(e,t);if(!o)return null;let i=_(o);return i===n?null:i}var ut="visual-edit-font-face-";function ft(e){let t=e.trim();if(!t.startsWith("@font-face")||t.includes("\\"))return!1;let n=(t.match(/{/g)||[]).length,o=(t.match(/}/g)||[]).length;if(n!==1||o!==1||!t.endsWith("}"))return!1;let i=t.split(/url\(/i);for(let a=1;a<i.length;a++){let m=i[a].indexOf(")");if(m===-1)return!1;let u=i[a].slice(0,m).trim().replace(/^['"]|['"]$/g,"").trim();if(!/^https:\/\//i.test(u))return!1}return!0}function Ce(e,t){if(typeof e!="string"||!e.trim()||typeof t!="string"||!ft(t))return;let n=`${ut}${e}`;if(document.getElementById(n))return;let o=document.createElement("style");o.id=n,o.dataset.visualEditFontFace="true",o.textContent=t,document.head.appendChild(o)}var Ae={position:"absolute",backgroundColor:"#ffffff",border:"1px solid #e2e8f0",borderRadius:"6px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",fontSize:"12px",minWidth:"120px",maxHeight:"200px",overflowY:"auto",zIndex:"10001",padding:"4px 0",pointerEvents:"auto"},_e={padding:"4px 12px",cursor:"pointer",color:"#334155",backgroundColor:"transparent",whiteSpace:"nowrap",lineHeight:"1.5",fontWeight:"400"},K="#526cff",xe="#DBEAFE",De="600",re="#f1f5f9",He=10,ie='<svg width="12" height="12" viewBox="0 0 24 24" style="vertical-align:middle;margin-left:4px"><path d="M6 9l6 6 6-6" stroke="currentColor" stroke-width="2" fill="none"/></svg>',Oe='<svg width="12" height="12" viewBox="0 0 24 24" style="vertical-align:middle;margin-left:4px"><path d="M18 15l-6-6-6 6" stroke="currentColor" stroke-width="2" fill="none"/></svg>',F="data-chevron",Ne=12,W="data-layer-dropdown",Re=2,Pe=2;function se(e,t){for(let n of Object.keys(t))e.style.setProperty(n.replace(/[A-Z]/g,o=>`-${o.toLowerCase()}`),t[n])}function Be(e){return e.tagName}function le(e,t){let n={element:e,tagName:O(e).toLowerCase(),selectorId:_(e)};return t!==void 0&&(n.depth=t),n}function ke(e,t,n){let o=[];function i(a,m){if(!(m>t))for(let u=0;u<a.children.length;u++){let v=a.children[u];if(ee(v)){let f={element:v,tagName:O(v).toLowerCase(),selectorId:_(v)};n!==void 0&&(f.depth=n+m-1),o.push(f),i(v,m+1)}else i(v,m)}}return i(e,1),o}function mt(e){let t=[],n=e.parentElement;for(;n&&n!==document.documentElement&&n!==document.body&&t.length<Re;)ee(n)&&t.push(le(n)),n=n.parentElement;return t.reverse(),t}function pt(e,t){return t.forEach((n,o)=>{e.push({...n,depth:o})}),t.length}function Ve(e,t,n){e.push(le(t,n));let o=ke(t,Pe,n+1);e.push(...o)}function Et(e){return e.at(-1)?.element??null}function gt(e,t){let n=ke(e,1);return n.some(o=>o.element===t)||n.push(le(t)),n}function ht(e,t,n,o){let i=_(n),a=new Set;for(let m of t)if(m.element===n)Ve(e,n,o),i&&a.add(i);else{let u=m.selectorId;if(u!=null){if(u===i||a.has(u))continue;a.add(u)}e.push({...m,depth:o})}}function Fe(e){let t=mt(e),n=[],o=pt(n,t),i=Et(t);if(i){let a=gt(i,e);ht(n,a,e,o)}else Ve(n,e,o);return n}var B=null,ae=null,$=null,q=null,X=null;function vt(e,t,{onSelect:n,onHover:o,onHoverEnd:i}){let a=document.createElement("div");a.textContent=Be(e),se(a,_e);let m=e.depth??0;return m>0&&(a.style.paddingLeft=`${Ne+m*He}px`),t&&(a.style.color=K,a.style.backgroundColor=xe,a.style.fontWeight=De),a.addEventListener("mouseenter",()=>{t||(a.style.backgroundColor=re),o&&o(e)}),a.addEventListener("mouseleave",()=>{t||(a.style.backgroundColor="transparent"),i&&i()}),a.addEventListener("click",u=>{u.stopPropagation(),u.preventDefault(),n(e)}),a}function yt(e,t,n){let o=document.createElement("div");return o.setAttribute(W,"true"),o.setAttribute(A,"true"),se(o,Ae),e.forEach(i=>{let a=i.element===t;o.appendChild(vt(i,a,n))}),o}function We(e){if(e.querySelector(`[${F}]`))return;let t=document.createElement("span");t.setAttribute(F,"true"),t.style.display="inline-flex",t.innerHTML=ie,e.appendChild(t),e.style.display="inline-flex",e.style.alignItems="center",e.style.cursor="pointer",e.style.userSelect="none",e.style.whiteSpace="nowrap",e.style.pointerEvents="auto",e.setAttribute(W,"true"),e.setAttribute(A,"true")}function bt(e,t,n,{onSelect:o,onHover:i,onHoverEnd:a}){let m=Array.from(e.children),u=t.findIndex(f=>f.element===n),v=f=>{if(u>=0&&u<m.length){let g=m[u];g.style.color!==K&&(g.style.backgroundColor="transparent")}if(u=f,u>=0&&u<m.length){let g=m[u];g.style.color!==K&&(g.style.backgroundColor=re),g.scrollIntoView({block:"nearest"}),i&&u>=0&&u<t.length&&i(t[u])}};X=f=>{f.key==="ArrowDown"?(f.preventDefault(),f.stopPropagation(),v(u<m.length-1?u+1:0)):f.key==="ArrowUp"?(f.preventDefault(),f.stopPropagation(),v(u>0?u-1:m.length-1)):f.key==="Enter"&&u>=0&&u<t.length&&(f.preventDefault(),f.stopPropagation(),a&&a(),o(t[u]),N())},document.addEventListener("keydown",X,!0)}function Lt(e,t){let n=!0;$=o=>{if(n){n=!1;return}let i=o.target;!e.contains(i)&&i!==t&&N()},document.addEventListener("mousedown",$,!0)}function $e(e,t,n,o){N();let i=yt(t,n,{...o,onSelect:u=>{o.onHoverEnd&&o.onHoverEnd(),o.onSelect(u),N()}}),a=e.parentElement;if(!a)return;i.style.top=`${e.offsetTop+e.offsetHeight+2}px`,i.style.left=`${e.offsetLeft}px`,a.appendChild(i),B=i,ae=e;let m=e.querySelector(`[${F}]`);m&&(m.innerHTML=Oe),q=o.onHoverEnd??null,bt(i,t,n,o),Lt(i,e)}function N(){let e=ae?.querySelector(`[${F}]`);e&&(e.innerHTML=ie),ae=null,q&&(q(),q=null),B&&B.parentNode&&B.remove(),B=null,$&&(document.removeEventListener("mousedown",$,!0),$=null),X&&(document.removeEventListener("keydown",X,!0),X=null)}function Xe(){return B!==null}function Ye(e){let t=null,n=null,o=null,i=()=>{t&&t.parentNode&&t.remove(),t=null},a=L=>{i(),_(L.element)!==e.getSelectedElementId()&&(t=e.createPreviewOverlay(L.element))},m=L=>{i(),N(),n&&(document.removeEventListener("keydown",n,!0),n=null),o=null;let s=e.selectElement(L.element);f(s,L.element)},u=()=>{n&&(document.removeEventListener("keydown",n,!0),n=null),o&&(m(o),o=null)},v=(L,s,c,S,w)=>{L.stopPropagation(),L.preventDefault(),Xe()?(N(),u()):(o={element:c,tagName:O(c).toLowerCase(),selectorId:w},e.onDeselect(),n=I=>{I.key==="Escape"&&(I.stopPropagation(),N(),u())},document.addEventListener("keydown",n,!0),$e(s,S,c,{onSelect:m,onHover:a,onHoverEnd:i}))},f=(L,s)=>{if(!L)return;let c=L.querySelector("div");if(!c)return;let S=Fe(s);if(S.length<=1)return;let w=_(s);We(c),c.addEventListener("click",I=>{v(I,c,s,S,w)})};return{attachToOverlay:f,cleanup:()=>{i(),N()}}}var de="visual-edit-focus-styles",Tt=["div","p","h1","h2","h3","h4","h5","h6","span","li","td","a","button","label"],ce=e=>!!e.dataset.arrField,wt=e=>!(!Tt.includes(e.tagName.toLowerCase())||!e.textContent?.trim()||e.querySelector("img, video, canvas, svg")||e.children?.length>0),Ue=()=>{if(document.getElementById(de))return;let e=document.createElement("style");e.id=de,e.textContent=`
12
12
  [data-selected="true"][contenteditable="true"]:focus {
13
13
  outline: none !important;
14
14
  }
15
- `,document.head.appendChild(e)},$e=()=>{document.getElementById(re)?.remove()},Xe=e=>{let t=document.createRange();t.selectNodeContents(e);let n=window.getSelection();n?.removeAllRanges(),n?.addRange(t)},Tt=e=>!(e instanceof HTMLElement)||!Lt(e)?!1:ie(e)?!0:e.dataset.dynamicContent!=="true",se=e=>!(e instanceof HTMLElement)||e.dataset.selected!=="true"?!1:Tt(e);var wt=500;function le(e){let t=null,n=null,r=!1,i=new WeakMap,a=()=>{let s=e.getSelectedElementId();if(!s)return;let c=e.findElementsById(s);e.getSelectedOverlays().forEach((w,S)=>{S<c.length&&c[S]&&e.positionOverlay(w,c[S])})},m=s=>{let c=s.dataset.originalTextContent,I=s.textContent,w=s.getBoundingClientRect(),S={type:"inline-edit",elementInfo:{tagName:s.tagName,classes:$(s),visualSelectorId:e.getSelectedElementId(),content:I,dataSourceLocation:s.dataset.sourceLocation,isDynamicContent:s.dataset.dynamicContent==="true",linenumber:s.dataset.linenumber,filename:s.dataset.filename,position:{top:w.top,left:w.left,right:w.right,bottom:w.bottom,width:w.width,height:w.height,centerX:w.left+w.width/2,centerY:w.top+w.height/2}},originalContent:c,newContent:I};ie(s)&&(S.arrIndex=s.dataset.arrIndex,S.arrVariableName=s.dataset.arrVariableName,S.arrField=s.dataset.arrField),window.parent.postMessage(S,"*"),s.dataset.originalTextContent=I||""},u=s=>{n&&clearTimeout(n),n=setTimeout(()=>m(s),wt)},v=s=>{a(),u(s)},f=function(){v(this)},y=s=>{We(),s.dataset.originalTextContent=s.textContent||"",s.dataset.originalCursor=s.style.cursor,s.contentEditable="true",s.setAttribute(C,"true");let c=new AbortController;i.set(s,c),s.addEventListener("input",f,{signal:c.signal}),s.style.cursor="text",Xe(s),setTimeout(()=>{s.isConnected&&s.focus()},0)},b=s=>{let c=i.get(s);c&&(c.abort(),i.delete(s)),s.isConnected&&($e(),s.contentEditable="false",s.removeAttribute(C),delete s.dataset.originalTextContent,s.dataset.originalCursor!==void 0&&(s.style.cursor=s.dataset.originalCursor,delete s.dataset.originalCursor))};return{get enabled(){return r},set enabled(s){r=s},isEditing(){return t!==null},getCurrentElement(){return t},canEdit(s){return se(s)},startEditing(s){t=s,e.getSelectedOverlays().forEach(c=>{c.style.display="none"}),y(s),window.parent.postMessage({type:"content-editing-started",visualSelectorId:e.getSelectedElementId()},"*")},stopEditing(){if(!t)return;n&&(clearTimeout(n),n=null),b(t),e.getSelectedOverlays().forEach(c=>{c.style.display=""}),a(),window.parent.postMessage({type:"content-editing-ended",visualSelectorId:e.getSelectedElementId()},"*"),t=null},markElementsSelected(s){s.forEach(c=>{c instanceof HTMLElement&&(c.dataset.selected="true")})},clearSelectedMarks(s){s&&e.findElementsById(s).forEach(c=>{c instanceof HTMLElement&&delete c.dataset.selected})},handleToggleMessage(s){if(!r)return;let c=e.findElementsById(s.dataSourceLocation);if(c.length===0||!(c[0]instanceof HTMLElement))return;let I=c[0];if(s.inlineEditingMode){if(!se(I))return;e.getSelectedElementId()!==s.dataSourceLocation&&(this.stopEditing(),e.clearSelection(),this.markElementsSelected(c),e.createSelectionOverlays(c,s.dataSourceLocation)),this.startEditing(I)}else t===I&&this.stopEditing()},cleanup(){this.stopEditing()}}}var ae="__theme-font-preview";function St(e){return e instanceof Element?e:e instanceof Node?e.parentElement:null}function It(e){return St(e)?.closest(`[${C}]`)!=null}function Ye(){let e=!1,t=i=>{if(It(i.target))return;if(i.preventDefault(),i.ctrlKey||i.metaKey){window.parent.postMessage({type:"canvas-wheel-zoom",data:{deltaY:i.deltaY,deltaMode:i.deltaMode,clientX:i.clientX,clientY:i.clientY,ctrlKey:i.ctrlKey,metaKey:i.metaKey}},"*");return}let a={deltaX:i.deltaX,deltaY:i.deltaY,deltaMode:i.deltaMode,clientX:i.clientX,clientY:i.clientY,shiftKey:i.shiftKey,ctrlKey:!1,metaKey:!1};window.parent.postMessage({type:"canvas-wheel-pan",data:a},"*")};return{enable:()=>{e||(e=!0,window.addEventListener("wheel",t,{capture:!0,passive:!1}))},disable:()=>{e&&(e=!1,window.removeEventListener("wheel",t,!0))}}}var de="--base44-reference-vh-base";function Ke(){let e=null,t=null,n,r,i="*",a=()=>{n!==void 0&&(window.clearTimeout(n),n=void 0),r!==void 0&&(window.clearTimeout(r),r=void 0)};return{freezeVhUnits:m=>{let u=Mt(m);if(Ct(u),e){t?.();return}e=[],t=At(e)},measurePageHeight:(m,u=2e3)=>{i=m,a(),n=window.setTimeout(()=>{n=void 0,t?.();let v=Ue()+1500,f=-1,y=0,b=c=>{r=void 0,window.parent.postMessage({type:"page-height-measured",height:c},i)},s=()=>{r=void 0;let c=Dt();if(c===f?y++:(y=1,f=c),y>=3||Ue()>=v){b(c);return}r=window.setTimeout(s,16)};s()},u)},teardown:()=>{if(e){for(let m of e)m();e=null,t=null}a()}}}function Ue(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function Mt(e){if(e!==void 0)return e;let t=window.innerHeight||0;return t>=400?t:900}function Ct(e){document.documentElement.style.setProperty(de,`${e}px`)}function At(e){let t=/(\d+(?:\.\d+)?)(?:d|s|l)?vh\b/g,n=new WeakSet,r=new WeakMap,i=new WeakSet,a=new Set,m=new WeakSet,u=p=>p.replace(t,(g,T)=>`calc(var(${de}) * ${_t(T)})`),v=p=>{if(m.has(p))return;let T=window.getComputedStyle(p).overflowY;T!=="auto"&&T!=="scroll"||(m.add(p),p.style.setProperty("overflow-y","visible","important"))},f=p=>{v(p),p.querySelectorAll("*").forEach(v)},y=p=>{let g=p.style;if(!g||g.length===0)return;let T=[];for(let M=0;M<g.length;M++){let D=g[M];D&&T.push(D)}for(let M of T){let D=g.getPropertyValue(M);if(!D||D.indexOf("vh")===-1)continue;let P=u(D);P!==D&&g.setProperty(M,P,g.getPropertyPriority(M))}},s=kt(()=>{document.querySelectorAll("style").forEach(p=>{if(I(p),n.has(p))return;n.add(p);let g=p.textContent;if(!g||g.indexOf("vh")===-1)return;let T=u(g);T!==g&&(p.textContent=T)});for(let p=0;p<document.styleSheets.length;p++){let g=document.styleSheets[p];if(!g)continue;let T;try{T=g.cssRules}catch{continue}r.get(g)!==T.length&&(qe(T,u),r.set(g,T.length))}document.querySelectorAll('[style*="vh"]').forEach(y),document.body&&f(document.body)},16),c=s.trigger;e.push(s.cancel);let I=p=>{if(i.has(p))return;i.add(p);let g=new MutationObserver(()=>{n.delete(p),c()});g.observe(p,{characterData:!0,childList:!0,subtree:!0}),a.add(g)};e.push(()=>{for(let p of a)p.disconnect();a.clear()}),c(),document.readyState==="loading"&&(document.addEventListener("DOMContentLoaded",c),e.push(()=>document.removeEventListener("DOMContentLoaded",c))),window.addEventListener("load",c),e.push(()=>window.removeEventListener("load",c));let w=new MutationObserver(p=>{for(let g of p)if(ze(g.addedNodes)||ze(g.removedNodes)){c();return}});e.push(()=>w.disconnect());let S=()=>{document.head&&w.observe(document.head,{childList:!0,subtree:!1})};document.head?S():(document.addEventListener("DOMContentLoaded",S),e.push(()=>document.removeEventListener("DOMContentLoaded",S)));let z=p=>{if(!(p instanceof Element))return;let g=p.getAttribute("style");g&&g.indexOf("vh")!==-1&&y(p),p.querySelectorAll('[style*="vh"]').forEach(y),f(p)},W=new MutationObserver(p=>{for(let g of p)if(g.type==="attributes"){let T=g.target;if(!(T instanceof Element))continue;let M=T.getAttribute("style");if(!M||M.indexOf("vh")===-1)continue;y(T)}else if(g.type==="childList")for(let T=0;T<g.addedNodes.length;T++){let M=g.addedNodes[T];M&&z(M)}});return e.push(()=>W.disconnect()),(()=>{let p=document.documentElement;p&&W.observe(p,{attributes:!0,attributeFilter:["style"],childList:!0,subtree:!0})})(),c}function _t(e){return String(Number((parseFloat(e)/100).toFixed(6)))}function qe(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(!r)continue;r.cssRules&&qe(r.cssRules,t);let i=r.style;if(i)for(let a=0;a<i.length;a++){let m=i[a];if(!m)continue;let u=i.getPropertyValue(m);if(!u||u.indexOf("vh")===-1)continue;let v=t(u);v!==u&&i.setProperty(m,v,i.getPropertyPriority(m))}}}function ze(e){for(let t=0;t<e.length;t++){let n=e[t];if(n instanceof HTMLStyleElement||n instanceof HTMLLinkElement)return!0}return!1}function Dt(){let e=Math.max(document.documentElement.scrollHeight,document.body?.scrollHeight??0),t=xt(),n=Math.max(window.innerHeight||0,document.documentElement.clientHeight,t),r=Ht(n);return r>0?Math.ceil(Math.max(r,t)):Math.ceil(Math.max(e,t))}function xt(){let e=document.documentElement.style.getPropertyValue(de),t=parseFloat(e);return Number.isFinite(t)?t:0}function Ht(e){if(!document.body)return 0;let t=[document.body,...Array.from(document.body.querySelectorAll("*"))],n=new WeakMap,r=window.scrollY+e;for(let i=t.length-1;i>=0;i--){let a=t[i];if(!a)continue;let m=Ot(a,n),u=Nt(a),v=Bt(u,m,e,r)?0:u.bottom;n.set(a,Math.max(m,v))}return n.get(document.body)??0}function Ot(e,t){let n=0;for(let r=0;r<e.children.length;r++){let i=e.children[r];i&&(n=Math.max(n,t.get(i)??0))}return n}function Nt(e){let t=window.getComputedStyle(e);if(Pt(t))return{bottom:0,height:0};let n=e.getBoundingClientRect();return n.width===0&&n.height===0?{bottom:0,height:0}:{bottom:n.bottom+window.scrollY+Rt(t),height:n.height}}function Rt(e){let t=parseFloat(e.marginBottom);return Number.isFinite(t)?t:0}function Pt(e){return e.position==="fixed"?!0:e.position==="absolute"&&e.pointerEvents==="none"}function Bt(e,t,n,r){return t>0&&Math.abs(e.bottom-r)<=1&&Math.abs(e.height-n)<=1&&e.bottom-t>8}function kt(e,t){let n;return{trigger:()=>{n!==void 0&&window.clearTimeout(n),n=window.setTimeout(e,t)},cancel:()=>{n!==void 0&&(window.clearTimeout(n),n=void 0)}}}var N="data-base44-suppressed-popup",Vt="--base44-reference-vh-base";function je(){let e=null,t=null,n=!1,r=!1,i=(f,y)=>{if(!(f instanceof HTMLElement)||f.hasAttribute(N))return;let b=window.getComputedStyle(f);if(b.position==="fixed"&&fe(b)){if($t(f,y)&&Xt(f,b)){a(f);return}r&&Ze(f,y)&&ue(f)}},a=f=>{f.hasAttribute(N)||(ue(f),r=!0,Ft(ce()))},m=(f,y)=>{i(f,y);let b=f.querySelectorAll(`*:not([${N}])`);for(let s=0;s<b.length;s++){let c=b[s];c&&i(c,y)}},u=()=>{e||(e=new MutationObserver(f=>{let y=ce();for(let b of f)if(b.type==="childList")for(let s=0;s<b.addedNodes.length;s++){let c=b.addedNodes[s];c instanceof Element&&m(c,y)}}),e.observe(document.documentElement,{childList:!0,subtree:!0}))},v=()=>{document.body&&(m(document.body,ce()),u())};return{suppress:()=>{n||(n=!0,document.body?v():(t=()=>{t=null,v()},document.addEventListener("DOMContentLoaded",t)))},teardown:()=>{n=!1,r=!1,e&&(e.disconnect(),e=null),t&&(document.removeEventListener("DOMContentLoaded",t),t=null)}}}function Ft(e){if(!document.body||e.vw<=0||e.vh<=0)return;let t=document.body.querySelectorAll(`*:not([${N}])`);for(let n=0;n<t.length;n++){let r=t[n];r&&Wt(r,e)&&ue(r)}}function Wt(e,t){if(e.hasAttribute(N))return!1;let n=window.getComputedStyle(e);return n.position!=="fixed"||!fe(n)?!1:Ze(e,t)}function $t(e,t){if(t.vw<=0||t.vh<=0)return!1;let n=e.getBoundingClientRect();return n.width>=t.vw*.9&&n.height>=t.vh*.9}function Ze(e,t){let n=e.getBoundingClientRect();return n.width>=t.vw*.15&&n.height>=t.vh*.15&&n.width<=t.vw*.95&&n.height<=t.vh*.95}function fe(e){let t=parseInt(e.zIndex,10);return Number.isFinite(t)&&t>=40}function Xt(e,t){if(Ge(t.backgroundColor)||t.backdropFilter&&t.backdropFilter!=="none")return!0;let n=e.querySelectorAll("*");for(let r=0;r<n.length;r++){let i=n[r];if(!i)continue;let a=window.getComputedStyle(i);if(!(a.position!=="fixed"&&a.position!=="absolute")&&fe(a)&&(Ge(a.backgroundColor)||a.backdropFilter&&a.backdropFilter!=="none"))return!0}return!1}function Ge(e){let t=Yt(e);return t!==null&&t>0&&t<1}function Yt(e){if(!e)return null;let t=/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*([0-9.]+)\s*)?\)$/.exec(e);if(t)return t[1]===void 0?1:parseFloat(t[1]);let n=/\/\s*([0-9.]+)(%?)\s*\)$/.exec(e);if(n){let r=parseFloat(n[1]);return n[2]==="%"?r/100:r}return/^[a-z]+\s*\(/.test(e)?1:null}function ce(){let e=window.innerWidth||document.documentElement.clientWidth||0,t=document.documentElement.style.getPropertyValue(Vt),n=parseFloat(t),r=Number.isFinite(n)&&n>0?n:window.innerHeight||document.documentElement.clientHeight||0;return{vw:e,vh:r}}function ue(e){e.hasAttribute(N)||(e.setAttribute(N,"1"),e.style.setProperty("display","none","important"))}var U=50;function Ut(){let e=Ye(),t=Ke(),n=je(),r=!1,i=!1,a=!1,m=[],u=[],v=[],f=null,y=null,b=(l=!1)=>{let o=document.createElement("div");return o.style.position="absolute",o.style.pointerEvents="none",o.style.transition="all 0.1s ease-in-out",o.style.zIndex="9999",l?o.style.border="2px solid #2563EB":(o.style.border="2px solid #95a5fc",o.style.backgroundColor="rgba(99, 102, 241, 0.05)"),o},s=(l,o,d=!1)=>{if(!o||!r)return;o.offsetWidth;let h=o.getBoundingClientRect();l.style.top=`${h.top+window.scrollY}px`,l.style.left=`${h.left+window.scrollX}px`,l.style.width=`${h.width}px`,l.style.height=`${h.height}px`;let L=l.querySelector("div");L||(L=document.createElement("div"),L.textContent=o.tagName.toLowerCase(),L.style.position="absolute",L.style.left="-2px",L.style.padding="2px 8px",L.style.fontSize="11px",L.style.fontWeight=d?"500":"400",L.style.color=d?"#ffffff":"#526cff",L.style.backgroundColor=d?"#2563EB":"#DBEAFE",L.style.borderRadius="3px",L.style.minWidth="24px",L.style.textAlign="center",l.appendChild(L)),ge(L,h)},c=le({findElementsById:x,getSelectedElementId:()=>f,getSelectedOverlays:()=>u,positionOverlay:s,clearSelection:()=>{c.clearSelectedMarks(f),S(),f=null,y=null},createSelectionOverlays:(l,o)=>{l.forEach(d=>{let E=b(!0);document.body.appendChild(E),u.push(E),s(E,d,!0)}),f=o}}),I=()=>{c.clearSelectedMarks(f),S(),f=null,y=null},w=()=>{m.forEach(l=>{l&&l.parentNode&&l.remove()}),m=[],v=[]},S=()=>{u.forEach(l=>{l&&l.parentNode&&l.remove()}),u=[]},z=["p","h1","h2","h3","h4","h5","h6","span","a","label"],W=l=>{let o=l,d=l.getBoundingClientRect(),E=z.includes(l.tagName?.toLowerCase()),h=o.closest("[data-arr-variable-name]"),L=h?.dataset?.arrVariableName||null,A=h?.dataset?.arrIndex,O=A!=null?parseInt(A,10):null,it=o.dataset?.arrField||null,st=o.closest("[data-collection-id]"),lt=o.closest("[data-collection-item-field]"),at=o.closest("[data-collection-item-id]");window.parent.postMessage({type:"element-selected",tagName:l.tagName,classes:$(l),visualSelectorId:_(l),content:E?o.innerText:void 0,dataSourceLocation:o.dataset.sourceLocation,isDynamicContent:o.dataset.dynamicContent==="true",linenumber:o.dataset.linenumber,filename:o.dataset.filename,position:{top:d.top,left:d.left,right:d.right,bottom:d.bottom,width:d.width,height:d.height,centerX:d.left+d.width/2,centerY:d.top+d.height/2},attributes:ye(l,Z),isTextElement:E,staticArrayName:L,staticArrayIndex:O,staticArrayField:it,collectionId:st?.dataset?.collectionId||null,collectionItemField:lt?.dataset?.collectionItemField||null,collectionItemId:at?.dataset?.collectionItemId||null},"*")},K=l=>{let o=_(l);return S(),x(o||null).forEach(E=>{let h=b(!0);document.body.appendChild(h),u.push(h),s(h,E,!0)}),f=o||null,y=l,w(),W(l),u[0]},p=()=>{f=null,window.parent.postMessage({type:"unselect-element"},"*")},g=null,T=null,M=()=>{w(),g=null},D=l=>{let o=x(l);w(),o.forEach(d=>{let E=b(!1);document.body.appendChild(E),m.push(E),s(E,d)}),v=o,g=l},P=l=>{!r||i||c.isEditing()||T===null&&(T=requestAnimationFrame(()=>{if(T=null,a){M();return}let o=Te(l.clientX,l.clientY,f);if(!o){M();return}g!==o&&D(o)}))},q=()=>{T!==null&&(cancelAnimationFrame(T),T=null),M()},me=l=>{if(!r)return;let o=l.target;if(o.closest(`[${k}]`)||c.enabled&&o instanceof HTMLElement&&o.contentEditable==="true")return;if(c.isEditing()){l.preventDefault(),l.stopPropagation(),l.stopImmediatePropagation(),c.stopEditing();return}if(a){l.preventDefault(),l.stopPropagation(),l.stopImmediatePropagation(),window.parent.postMessage({type:"close-dropdowns"},"*");return}l.preventDefault(),l.stopPropagation(),l.stopImmediatePropagation();let d=J(l.clientX,l.clientY);if(!d)return;let E=d,h=_(d);if(f===h&&E.dataset.selected==="true"&&c.enabled&&c.canEdit(E)){c.startEditing(E);return}c.stopEditing(),c.enabled&&c.markElementsSelected(x(h));let A=K(d);pe.attachToOverlay(A,d)},Je=()=>{c.stopEditing(),I()},Qe=(l,o)=>{let d=x(l);d.length!==0&&(he(d,o),setTimeout(()=>{f===l&&u.forEach((E,h)=>{h<d.length&&s(E,d[h])}),v.length>0&&v[0]?.dataset?.visualSelectorId===l&&m.forEach((L,A)=>{A<v.length&&s(L,v[A])})},U))},et=(l,o,d,E)=>{let h=x(l);if(h.length===0)return;let L=E??(f===l?y?.dataset.arrIndex:void 0);ve(h,o,d,L),setTimeout(()=>{f===l&&u.forEach((A,O)=>{O<h.length&&s(A,h[O])})},U)},tt=(l,o,d)=>{let E=x(l);E.length!==0&&(d!=null&&(E=E.filter(h=>h.dataset.arrIndex===String(d))),E.forEach(h=>{h.innerText=o}),setTimeout(()=>{f===l&&u.forEach((h,L)=>{L<E.length&&s(h,E[L])})},U))},pe=Fe({createPreviewOverlay:l=>{let o=b(!1);return o.style.zIndex="9998",document.body.appendChild(o),s(o,l),o},getSelectedElementId:()=>f,selectElement:K,onDeselect:p}),nt=l=>{r=l,l?(document.body.style.cursor="crosshair",be(),document.addEventListener("mousemove",P),document.addEventListener("mouseleave",q),document.addEventListener("click",me,!0)):(e.disable(),Le(),c.stopEditing(),I(),pe.cleanup(),q(),document.body.style.cursor="default",document.removeEventListener("mousemove",P),document.removeEventListener("mouseleave",q),document.removeEventListener("click",me,!0))},Ee=()=>{if(f){let l=y;if(l&&l.isConnected){let o=l.getBoundingClientRect(),d=window.innerHeight,E=window.innerWidth,h=o.top<d&&o.bottom>0&&o.left<E&&o.right>0,L={top:o.top,left:o.left,right:o.right,bottom:o.bottom,width:o.width,height:o.height,centerX:o.left+o.width/2,centerY:o.top+o.height/2};window.parent.postMessage({type:"element-position-update",position:L,isInViewport:h,visualSelectorId:f},"*")}}},ot=l=>{let o=l.data;switch(o.type){case"toggle-visual-edit-mode":nt(o.data.enabled),o.data.specs?.newInlineEditEnabled!==void 0&&(c.enabled=o.data.specs.newInlineEditEnabled);break;case"update-classes":o.data&&o.data.classes!==void 0?Qe(o.data.visualSelectorId,o.data.classes):console.warn("[VisualEditAgent] Invalid update-classes message:",o);break;case"update-attribute":o.data&&o.data.visualSelectorId&&o.data.attribute!==void 0&&o.data.value!==void 0?et(o.data.visualSelectorId,o.data.attribute,o.data.value,o.data.arrIndex):console.warn("[VisualEditAgent] Invalid update-attribute message:",o);break;case"unselect-element":Je();break;case"refresh-page":window.location.reload();break;case"update-content":o.data&&o.data.content!==void 0?tt(o.data.visualSelectorId,o.data.content,o.data.arrIndex):console.warn("[VisualEditAgent] Invalid update-content message:",o);break;case"request-element-position":if(f&&y&&y.isConnected){let d=y.getBoundingClientRect(),E=window.innerHeight,h=window.innerWidth,L=d.top<E&&d.bottom>0&&d.left<h&&d.right>0,A={top:d.top,left:d.left,right:d.right,bottom:d.bottom,width:d.width,height:d.height,centerX:d.left+d.width/2,centerY:d.top+d.height/2};window.parent.postMessage({type:"element-position-update",position:A,isInViewport:L,visualSelectorId:f},"*")}break;case"popover-drag-state":o.data&&o.data.isDragging!==void 0&&(i=o.data.isDragging,o.data.isDragging&&w());break;case"dropdown-state":o.data&&o.data.isOpen!==void 0&&(a=o.data.isOpen,o.data.isOpen&&w());break;case"update-theme-variables":if(o.data?.variables){let d=o.data.mode==="dark"?document.querySelector(".dark"):document.documentElement;if(d)for(let[E,h]of Object.entries(o.data.variables))d.style.setProperty(E,h)}break;case"inject-font-import":if(o.data?.fontUrl){let d=document.getElementById(ae);d||(d=document.createElement("style"),d.id=ae,document.head.appendChild(d)),d.textContent=`@import url('${o.data.fontUrl}');`}break;case"inject-font-face":o.data&&we(o.data.id,o.data.css);break;case"toggle-inline-edit-mode":o.data&&c.handleToggleMessage(o.data);break;case"freeze-vh-units":t.freezeVhUnits(typeof o.referenceVhBase=="number"?o.referenceVhBase:void 0);break;case"measure-page-height":t.measurePageHeight(l.origin&&l.origin!=="null"?l.origin:"*",typeof o.settleMs=="number"?o.settleMs:void 0);break;case"suppress-auto-popups":n.suppress();break;case"toggle-canvas-wheel-zoom-bridge":e.enable();break;default:break}},G=()=>{if(f){let l=x(f);u.forEach((o,d)=>{d<l.length&&s(o,l[d])})}v.length>0&&m.forEach((l,o)=>{o<v.length&&s(l,v[o])})};document.querySelectorAll("[data-linenumber]:not([data-visual-selector-id])").forEach((l,o)=>{let d=l,E=`visual-id-${d.dataset.filename}-${d.dataset.linenumber}-${o}`;d.dataset.visualSelectorId=E});let rt=new MutationObserver(l=>{l.some(d=>{let E=L=>{if(L.nodeType===Node.ELEMENT_NODE){let A=L;if(A.dataset&&A.dataset.visualSelectorId)return!0;for(let O=0;O<A.children.length;O++)if(E(A.children[O]))return!0}return!1};return d.type==="attributes"&&(d.attributeName==="style"||d.attributeName==="class"||d.attributeName==="width"||d.attributeName==="height")&&E(d.target)})&&setTimeout(G,U)});window.addEventListener("message",ot),window.addEventListener("scroll",Ee,!0),document.addEventListener("scroll",Ee,!0),window.addEventListener("resize",G),window.addEventListener("scroll",G),rt.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class","width","height"]}),window.parent.postMessage({type:"visual-edit-agent-ready"},"*")}export{Ut as setupVisualEditAgent};
15
+ `,document.head.appendChild(e)},ze=()=>{document.getElementById(de)?.remove()},Ke=e=>{let t=document.createRange();t.selectNodeContents(e);let n=window.getSelection();n?.removeAllRanges(),n?.addRange(t)},It=e=>!(e instanceof HTMLElement)||!wt(e)?!1:ce(e)?!0:e.dataset.dynamicContent!=="true",ue=e=>!(e instanceof HTMLElement)||e.dataset.selected!=="true"?!1:It(e);var St=500;function fe(e){let t=null,n=null,o=!1,i=new WeakMap,a=()=>{let s=e.getSelectedElementId();if(!s)return;let c=e.findElementsById(s);e.getSelectedOverlays().forEach((w,I)=>{I<c.length&&c[I]&&e.positionOverlay(w,c[I])})},m=s=>{let c=s.dataset.originalTextContent,S=s.textContent,w=s.getBoundingClientRect(),I={type:"inline-edit",elementInfo:{tagName:s.tagName,classes:z(s),visualSelectorId:e.getSelectedElementId(),content:S,dataSourceLocation:s.dataset.sourceLocation,isDynamicContent:s.dataset.dynamicContent==="true",linenumber:s.dataset.linenumber,filename:s.dataset.filename,position:{top:w.top,left:w.left,right:w.right,bottom:w.bottom,width:w.width,height:w.height,centerX:w.left+w.width/2,centerY:w.top+w.height/2}},originalContent:c,newContent:S};ce(s)&&(I.arrIndex=s.dataset.arrIndex,I.arrVariableName=s.dataset.arrVariableName,I.arrField=s.dataset.arrField),window.parent.postMessage(I,"*"),s.dataset.originalTextContent=S||""},u=s=>{n&&clearTimeout(n),n=setTimeout(()=>m(s),St)},v=s=>{a(),u(s)},f=function(){v(this)},g=s=>{Ue(),s.dataset.originalTextContent=s.textContent||"",s.dataset.originalCursor=s.style.cursor,s.contentEditable="true",s.setAttribute(A,"true");let c=new AbortController;i.set(s,c),s.addEventListener("input",f,{signal:c.signal}),s.style.cursor="text",Ke(s),setTimeout(()=>{s.isConnected&&s.focus()},0)},L=s=>{let c=i.get(s);c&&(c.abort(),i.delete(s)),s.isConnected&&(ze(),s.contentEditable="false",s.removeAttribute(A),delete s.dataset.originalTextContent,s.dataset.originalCursor!==void 0&&(s.style.cursor=s.dataset.originalCursor,delete s.dataset.originalCursor))};return{get enabled(){return o},set enabled(s){o=s},isEditing(){return t!==null},getCurrentElement(){return t},canEdit(s){return ue(s)},startEditing(s){t=s,e.getSelectedOverlays().forEach(c=>{c.style.display="none"}),g(s),window.parent.postMessage({type:"content-editing-started",visualSelectorId:e.getSelectedElementId()},"*")},stopEditing(){if(!t)return;n&&(clearTimeout(n),n=null),L(t),e.getSelectedOverlays().forEach(c=>{c.style.display=""}),a(),window.parent.postMessage({type:"content-editing-ended",visualSelectorId:e.getSelectedElementId()},"*"),t=null},markElementsSelected(s){s.forEach(c=>{c instanceof HTMLElement&&(c.dataset.selected="true")})},clearSelectedMarks(s){s&&e.findElementsById(s).forEach(c=>{c instanceof HTMLElement&&delete c.dataset.selected})},handleToggleMessage(s){if(!o)return;let c=e.findElementsById(s.dataSourceLocation);if(c.length===0||!(c[0]instanceof HTMLElement))return;let S=c[0];if(s.inlineEditingMode){if(!ue(S))return;e.getSelectedElementId()!==s.dataSourceLocation&&(this.stopEditing(),e.clearSelection(),this.markElementsSelected(c),e.createSelectionOverlays(c,s.dataSourceLocation)),this.startEditing(S)}else t===S&&this.stopEditing()},cleanup(){this.stopEditing()}}}var me="__theme-font-preview";function Mt(e){return e instanceof Element?e:e instanceof Node?e.parentElement:null}function Ct(e){return Mt(e)?.closest(`[${A}]`)!=null}function qe(){let e=!1,t=i=>{if(Ct(i.target))return;if(i.preventDefault(),i.ctrlKey||i.metaKey){window.parent.postMessage({type:"canvas-wheel-zoom",data:{deltaY:i.deltaY,deltaMode:i.deltaMode,clientX:i.clientX,clientY:i.clientY,ctrlKey:i.ctrlKey,metaKey:i.metaKey}},"*");return}let a={deltaX:i.deltaX,deltaY:i.deltaY,deltaMode:i.deltaMode,clientX:i.clientX,clientY:i.clientY,shiftKey:i.shiftKey,ctrlKey:!1,metaKey:!1};window.parent.postMessage({type:"canvas-wheel-pan",data:a},"*")};return{enable:()=>{e||(e=!0,window.addEventListener("wheel",t,{capture:!0,passive:!1}))},disable:()=>{e&&(e=!1,window.removeEventListener("wheel",t,!0))}}}var pe="--base44-reference-vh-base";function Ze(){let e=null,t=null,n,o,i="*",a=()=>{n!==void 0&&(window.clearTimeout(n),n=void 0),o!==void 0&&(window.clearTimeout(o),o=void 0)};return{freezeVhUnits:m=>{let u=At(m);if(_t(u),e){t?.();return}e=[],t=xt(e)},measurePageHeight:(m,u=2e3)=>{i=m,a(),n=window.setTimeout(()=>{n=void 0,t?.();let v=Ge()+1500,f=-1,g=0,L=c=>{o=void 0,window.parent.postMessage({type:"page-height-measured",height:c},i)},s=()=>{o=void 0;let c=Ht();if(c===f?g++:(g=1,f=c),g>=3||Ge()>=v){L(c);return}o=window.setTimeout(s,16)};s()},u)},teardown:()=>{if(e){for(let m of e)m();e=null,t=null}a()}}}function Ge(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function At(e){if(e!==void 0)return e;let t=window.innerHeight||0;return t>=400?t:900}function _t(e){document.documentElement.style.setProperty(pe,`${e}px`)}function xt(e){let t=/(\d+(?:\.\d+)?)(?:d|s|l)?vh\b/g,n=new WeakSet,o=new WeakMap,i=new WeakSet,a=new Set,m=new WeakSet,u=p=>p.replace(t,(h,T)=>`calc(var(${pe}) * ${Dt(T)})`),v=p=>{if(m.has(p))return;let T=window.getComputedStyle(p).overflowY;T!=="auto"&&T!=="scroll"||(m.add(p),p.style.setProperty("overflow-y","visible","important"))},f=p=>{v(p),p.querySelectorAll("*").forEach(v)},g=p=>{let h=p.style;if(!h||h.length===0)return;let T=[];for(let C=0;C<h.length;C++){let D=h[C];D&&T.push(D)}for(let C of T){let D=h.getPropertyValue(C);if(!D||D.indexOf("vh")===-1)continue;let k=u(D);k!==D&&h.setProperty(C,k,h.getPropertyPriority(C))}},s=Ft(()=>{document.querySelectorAll("style").forEach(p=>{if(S(p),n.has(p))return;n.add(p);let h=p.textContent;if(!h||h.indexOf("vh")===-1)return;let T=u(h);T!==h&&(p.textContent=T)});for(let p=0;p<document.styleSheets.length;p++){let h=document.styleSheets[p];if(!h)continue;let T;try{T=h.cssRules}catch{continue}o.get(h)!==T.length&&(Je(T,u),o.set(h,T.length))}document.querySelectorAll('[style*="vh"]').forEach(g),document.body&&f(document.body)},16),c=s.trigger;e.push(s.cancel);let S=p=>{if(i.has(p))return;i.add(p);let h=new MutationObserver(()=>{n.delete(p),c()});h.observe(p,{characterData:!0,childList:!0,subtree:!0}),a.add(h)};e.push(()=>{for(let p of a)p.disconnect();a.clear()}),c(),document.readyState==="loading"&&(document.addEventListener("DOMContentLoaded",c),e.push(()=>document.removeEventListener("DOMContentLoaded",c))),window.addEventListener("load",c),e.push(()=>window.removeEventListener("load",c));let w=new MutationObserver(p=>{for(let h of p)if(je(h.addedNodes)||je(h.removedNodes)){c();return}});e.push(()=>w.disconnect());let I=()=>{document.head&&w.observe(document.head,{childList:!0,subtree:!1})};document.head?I():(document.addEventListener("DOMContentLoaded",I),e.push(()=>document.removeEventListener("DOMContentLoaded",I)));let j=p=>{if(!(p instanceof Element))return;let h=p.getAttribute("style");h&&h.indexOf("vh")!==-1&&g(p),p.querySelectorAll('[style*="vh"]').forEach(g),f(p)},Y=new MutationObserver(p=>{for(let h of p)if(h.type==="attributes"){let T=h.target;if(!(T instanceof Element))continue;let C=T.getAttribute("style");if(!C||C.indexOf("vh")===-1)continue;g(T)}else if(h.type==="childList")for(let T=0;T<h.addedNodes.length;T++){let C=h.addedNodes[T];C&&j(C)}});return e.push(()=>Y.disconnect()),(()=>{let p=document.documentElement;p&&Y.observe(p,{attributes:!0,attributeFilter:["style"],childList:!0,subtree:!0})})(),c}function Dt(e){return String(Number((parseFloat(e)/100).toFixed(6)))}function Je(e,t){for(let n=0;n<e.length;n++){let o=e[n];if(!o)continue;o.cssRules&&Je(o.cssRules,t);let i=o.style;if(i)for(let a=0;a<i.length;a++){let m=i[a];if(!m)continue;let u=i.getPropertyValue(m);if(!u||u.indexOf("vh")===-1)continue;let v=t(u);v!==u&&i.setProperty(m,v,i.getPropertyPriority(m))}}}function je(e){for(let t=0;t<e.length;t++){let n=e[t];if(n instanceof HTMLStyleElement||n instanceof HTMLLinkElement)return!0}return!1}function Ht(){let e=Math.max(document.documentElement.scrollHeight,document.body?.scrollHeight??0),t=Ot(),n=Math.max(window.innerHeight||0,document.documentElement.clientHeight,t),o=Nt(n);return o>0?Math.ceil(Math.max(o,t)):Math.ceil(Math.max(e,t))}function Ot(){let e=document.documentElement.style.getPropertyValue(pe),t=parseFloat(e);return Number.isFinite(t)?t:0}function Nt(e){if(!document.body)return 0;let t=[document.body,...Array.from(document.body.querySelectorAll("*"))],n=new WeakMap,o=window.scrollY+e;for(let i=t.length-1;i>=0;i--){let a=t[i];if(!a)continue;let m=Rt(a,n),u=Pt(a),v=Vt(u,m,e,o)?0:u.bottom;n.set(a,Math.max(m,v))}return n.get(document.body)??0}function Rt(e,t){let n=0;for(let o=0;o<e.children.length;o++){let i=e.children[o];i&&(n=Math.max(n,t.get(i)??0))}return n}function Pt(e){let t=window.getComputedStyle(e);if(kt(t))return{bottom:0,height:0};let n=e.getBoundingClientRect();return n.width===0&&n.height===0?{bottom:0,height:0}:{bottom:n.bottom+window.scrollY+Bt(t),height:n.height}}function Bt(e){let t=parseFloat(e.marginBottom);return Number.isFinite(t)?t:0}function kt(e){return e.position==="fixed"?!0:e.position==="absolute"&&e.pointerEvents==="none"}function Vt(e,t,n,o){return t>0&&Math.abs(e.bottom-o)<=1&&Math.abs(e.height-n)<=1&&e.bottom-t>8}function Ft(e,t){let n;return{trigger:()=>{n!==void 0&&window.clearTimeout(n),n=window.setTimeout(e,t)},cancel:()=>{n!==void 0&&(window.clearTimeout(n),n=void 0)}}}var P="data-base44-suppressed-popup",Wt="--base44-reference-vh-base";function et(){let e=null,t=null,n=!1,o=!1,i=(f,g)=>{if(!(f instanceof HTMLElement)||f.hasAttribute(P))return;let L=window.getComputedStyle(f);if(L.position==="fixed"&&he(L)){if(Yt(f,g)&&Ut(f,L)){a(f);return}o&&tt(f,g)&&ge(f)}},a=f=>{f.hasAttribute(P)||(ge(f),o=!0,$t(Ee()))},m=(f,g)=>{i(f,g);let L=f.querySelectorAll(`*:not([${P}])`);for(let s=0;s<L.length;s++){let c=L[s];c&&i(c,g)}},u=()=>{e||(e=new MutationObserver(f=>{let g=Ee();for(let L of f)if(L.type==="childList")for(let s=0;s<L.addedNodes.length;s++){let c=L.addedNodes[s];c instanceof Element&&m(c,g)}}),e.observe(document.documentElement,{childList:!0,subtree:!0}))},v=()=>{document.body&&(m(document.body,Ee()),u())};return{suppress:()=>{n||(n=!0,document.body?v():(t=()=>{t=null,v()},document.addEventListener("DOMContentLoaded",t)))},teardown:()=>{n=!1,o=!1,e&&(e.disconnect(),e=null),t&&(document.removeEventListener("DOMContentLoaded",t),t=null)}}}function $t(e){if(!document.body||e.vw<=0||e.vh<=0)return;let t=document.body.querySelectorAll(`*:not([${P}])`);for(let n=0;n<t.length;n++){let o=t[n];o&&Xt(o,e)&&ge(o)}}function Xt(e,t){if(e.hasAttribute(P))return!1;let n=window.getComputedStyle(e);return n.position!=="fixed"||!he(n)?!1:tt(e,t)}function Yt(e,t){if(t.vw<=0||t.vh<=0)return!1;let n=e.getBoundingClientRect();return n.width>=t.vw*.9&&n.height>=t.vh*.9}function tt(e,t){let n=e.getBoundingClientRect();return n.width>=t.vw*.15&&n.height>=t.vh*.15&&n.width<=t.vw*.95&&n.height<=t.vh*.95}function he(e){let t=parseInt(e.zIndex,10);return Number.isFinite(t)&&t>=40}function Ut(e,t){if(Qe(t.backgroundColor)||t.backdropFilter&&t.backdropFilter!=="none")return!0;let n=e.querySelectorAll("*");for(let o=0;o<n.length;o++){let i=n[o];if(!i)continue;let a=window.getComputedStyle(i);if(!(a.position!=="fixed"&&a.position!=="absolute")&&he(a)&&(Qe(a.backgroundColor)||a.backdropFilter&&a.backdropFilter!=="none"))return!0}return!1}function Qe(e){let t=zt(e);return t!==null&&t>0&&t<1}function zt(e){if(!e)return null;let t=/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*([0-9.]+)\s*)?\)$/.exec(e);if(t)return t[1]===void 0?1:parseFloat(t[1]);let n=/\/\s*([0-9.]+)(%?)\s*\)$/.exec(e);if(n){let o=parseFloat(n[1]);return n[2]==="%"?o/100:o}return/^[a-z]+\s*\(/.test(e)?1:null}function Ee(){let e=window.innerWidth||document.documentElement.clientWidth||0,t=document.documentElement.style.getPropertyValue(Wt),n=parseFloat(t),o=Number.isFinite(n)&&n>0?n:window.innerHeight||document.documentElement.clientHeight||0;return{vw:e,vh:o}}function ge(e){e.hasAttribute(P)||(e.setAttribute(P,"1"),e.style.setProperty("display","none","important"))}var G=50;function Kt(){let e=qe(),t=Ze(),n=et(),o=!1,i=!1,a=!1,m=[],u=[],v=[],f=null,g=null,L=(l=!1)=>{let r=document.createElement("div");return r.style.position="absolute",r.style.pointerEvents="none",r.style.transition="all 0.1s ease-in-out",r.style.zIndex="9999",l?r.style.border="2px solid #2563EB":(r.style.border="2px solid #95a5fc",r.style.backgroundColor="rgba(99, 102, 241, 0.05)"),r},s=(l,r,d=!1)=>{if(!r||!o)return;r.offsetWidth;let b=r.getBoundingClientRect();l.style.top=`${b.top+window.scrollY}px`,l.style.left=`${b.left+window.scrollX}px`,l.style.width=`${b.width}px`,l.style.height=`${b.height}px`;let y=l.querySelector("div");y||(y=document.createElement("div"),y.textContent=O(r).toLowerCase(),y.style.position="absolute",y.style.left="-2px",y.style.padding="2px 8px",y.style.fontSize="11px",y.style.fontWeight=d?"500":"400",y.style.color=d?"#ffffff":"#526cff",y.style.backgroundColor=d?"#2563EB":"#DBEAFE",y.style.borderRadius="3px",y.style.minWidth="24px",y.style.textAlign="center",l.appendChild(y)),be(y,b)},c=fe({findElementsById:x,getSelectedElementId:()=>f,getSelectedOverlays:()=>u,positionOverlay:s,clearSelection:()=>{c.clearSelectedMarks(f),I(),f=null,g=null},createSelectionOverlays:(l,r)=>{l.forEach(d=>{let E=L(!0);document.body.appendChild(E),u.push(E),s(E,d,!0)}),f=r}}),S=()=>{c.clearSelectedMarks(f),I(),f=null,g=null},w=()=>{m.forEach(l=>{l&&l.parentNode&&l.remove()}),m=[],v=[]},I=()=>{u.forEach(l=>{l&&l.parentNode&&l.remove()}),u=[]},j=["p","h1","h2","h3","h4","h5","h6","span","a","label"],Y=l=>{let r=l,d=l.getBoundingClientRect(),E=j.includes(O(l).toLowerCase()),b=r.closest("[data-arr-variable-name]"),y=b?.dataset?.arrVariableName||null,M=b?.dataset?.arrIndex,H=M!=null?parseInt(M,10):null,R=r.dataset?.arrField||null,V=r.closest("[data-collection-id]"),dt=r.closest("[data-collection-item-field]"),ct=r.closest("[data-collection-item-id]");window.parent.postMessage({type:"element-selected",tagName:O(l),classes:z(l),visualSelectorId:_(l),content:E?r.innerText:void 0,dataSourceLocation:r.dataset.sourceLocation,isDynamicContent:r.dataset.dynamicContent==="true",linenumber:r.dataset.linenumber,filename:r.dataset.filename,position:{top:d.top,left:d.left,right:d.right,bottom:d.bottom,width:d.width,height:d.height,centerX:d.left+d.width/2,centerY:d.top+d.height/2},attributes:we(l,ne),isTextElement:E,staticArrayName:y,staticArrayIndex:H,staticArrayField:R,collectionId:V?.dataset?.collectionId||null,collectionItemField:dt?.dataset?.collectionItemField||null,collectionItemId:ct?.dataset?.collectionItemId||null},"*")},U=(l,r=!0)=>{let d=_(l);return I(),x(d||null).forEach(b=>{let y=L(!0);document.body.appendChild(y),u.push(y),s(y,b,!0)}),f=d||null,g=l,w(),r&&Y(l),u[0]},p=()=>{f=null,window.parent.postMessage({type:"unselect-element"},"*")},h=null,T=null,C=()=>{w(),h=null},D=l=>{let r=x(l);w(),r.forEach(d=>{let E=L(!1);document.body.appendChild(E),m.push(E),s(E,d)}),v=r,h=l},k=l=>{!o||i||c.isEditing()||T===null&&(T=requestAnimationFrame(()=>{if(T=null,a){C();return}let r=Me(l.clientX,l.clientY,f);if(!r){C();return}h!==r&&D(r)}))},Z=()=>{T!==null&&(cancelAnimationFrame(T),T=null),C()},ve=l=>{if(!o)return;let r=l.target;if(r.closest(`[${W}]`)||c.enabled&&r instanceof HTMLElement&&r.contentEditable==="true")return;if(c.isEditing()){l.preventDefault(),l.stopPropagation(),l.stopImmediatePropagation(),c.stopEditing();return}if(a){l.preventDefault(),l.stopPropagation(),l.stopImmediatePropagation(),window.parent.postMessage({type:"close-dropdowns"},"*");return}l.preventDefault(),l.stopPropagation(),l.stopImmediatePropagation();let d=oe(l.clientX,l.clientY);if(!d)return;let E=d,b=_(d);if(f===b&&E.dataset.selected==="true"&&c.enabled&&c.canEdit(E)){c.startEditing(E);return}c.stopEditing(),c.enabled&&c.markElementsSelected(x(b));let M=U(d);J.attachToOverlay(M,d)},nt=()=>{c.stopEditing(),S()},ot=(l,r)=>{let d=x(l);d.length!==0&&(Le(d,r),setTimeout(()=>{f===l&&u.forEach((E,b)=>{b<d.length&&s(E,d[b])}),v.length>0&&v[0]?.dataset?.visualSelectorId===l&&m.forEach((y,M)=>{M<v.length&&s(y,v[M])})},G))},rt=(l,r,d,E)=>{let b=x(l);if(b.length===0)return;let y=E??(f===l?g?.dataset.arrIndex:void 0);Te(b,r,d,y),setTimeout(()=>{if(f===l){let M=x(l);if(g&&!g.isConnected){let H=g.dataset.arrIndex,R=M.find(V=>V.dataset.arrIndex===H);if(R){let V=U(R,!1);J.attachToOverlay(V,R)}}u.forEach((H,R)=>{R<M.length&&s(H,M[R])})}},G)},it=(l,r,d)=>{let E=x(l);E.length!==0&&(d!=null&&(E=E.filter(b=>b.dataset.arrIndex===String(d))),E.forEach(b=>{b.innerText=r}),setTimeout(()=>{f===l&&u.forEach((b,y)=>{y<E.length&&s(b,E[y])})},G))},J=Ye({createPreviewOverlay:l=>{let r=L(!1);return r.style.zIndex="9998",document.body.appendChild(r),s(r,l),r},getSelectedElementId:()=>f,selectElement:U,onDeselect:p}),st=l=>{o=l,l?(document.body.style.cursor="crosshair",Ie(),document.addEventListener("mousemove",k),document.addEventListener("mouseleave",Z),document.addEventListener("click",ve,!0)):(e.disable(),Se(),c.stopEditing(),S(),J.cleanup(),Z(),document.body.style.cursor="default",document.removeEventListener("mousemove",k),document.removeEventListener("mouseleave",Z),document.removeEventListener("click",ve,!0))},ye=()=>{if(f){let l=g;if(l&&l.isConnected){let r=l.getBoundingClientRect(),d=window.innerHeight,E=window.innerWidth,b=r.top<d&&r.bottom>0&&r.left<E&&r.right>0,y={top:r.top,left:r.left,right:r.right,bottom:r.bottom,width:r.width,height:r.height,centerX:r.left+r.width/2,centerY:r.top+r.height/2};window.parent.postMessage({type:"element-position-update",position:y,isInViewport:b,visualSelectorId:f},"*")}}},lt=l=>{let r=l.data;switch(r.type){case"toggle-visual-edit-mode":st(r.data.enabled),r.data.specs?.newInlineEditEnabled!==void 0&&(c.enabled=r.data.specs.newInlineEditEnabled);break;case"update-classes":r.data&&r.data.classes!==void 0?ot(r.data.visualSelectorId,r.data.classes):console.warn("[VisualEditAgent] Invalid update-classes message:",r);break;case"update-attribute":r.data&&r.data.visualSelectorId&&r.data.attribute!==void 0&&r.data.value!==void 0?rt(r.data.visualSelectorId,r.data.attribute,r.data.value,r.data.arrIndex):console.warn("[VisualEditAgent] Invalid update-attribute message:",r);break;case"unselect-element":nt();break;case"refresh-page":window.location.reload();break;case"update-content":r.data&&r.data.content!==void 0?it(r.data.visualSelectorId,r.data.content,r.data.arrIndex):console.warn("[VisualEditAgent] Invalid update-content message:",r);break;case"request-element-position":if(f&&g&&g.isConnected){let d=g.getBoundingClientRect(),E=window.innerHeight,b=window.innerWidth,y=d.top<E&&d.bottom>0&&d.left<b&&d.right>0,M={top:d.top,left:d.left,right:d.right,bottom:d.bottom,width:d.width,height:d.height,centerX:d.left+d.width/2,centerY:d.top+d.height/2};window.parent.postMessage({type:"element-position-update",position:M,isInViewport:y,visualSelectorId:f},"*")}break;case"popover-drag-state":r.data&&r.data.isDragging!==void 0&&(i=r.data.isDragging,r.data.isDragging&&w());break;case"dropdown-state":r.data&&r.data.isOpen!==void 0&&(a=r.data.isOpen,r.data.isOpen&&w());break;case"update-theme-variables":if(r.data?.variables){let d=r.data.mode==="dark"?document.querySelector(".dark"):document.documentElement;if(d)for(let[E,b]of Object.entries(r.data.variables))d.style.setProperty(E,b)}break;case"inject-font-import":if(r.data?.fontUrl){let d=document.getElementById(me);d||(d=document.createElement("style"),d.id=me,document.head.appendChild(d)),d.textContent=`@import url('${r.data.fontUrl}');`}break;case"inject-font-face":r.data&&Ce(r.data.id,r.data.css);break;case"toggle-inline-edit-mode":r.data&&c.handleToggleMessage(r.data);break;case"freeze-vh-units":t.freezeVhUnits(typeof r.referenceVhBase=="number"?r.referenceVhBase:void 0);break;case"measure-page-height":t.measurePageHeight(l.origin&&l.origin!=="null"?l.origin:"*",typeof r.settleMs=="number"?r.settleMs:void 0);break;case"suppress-auto-popups":n.suppress();break;case"toggle-canvas-wheel-zoom-bridge":e.enable();break;default:break}},Q=()=>{if(f){let l=x(f);u.forEach((r,d)=>{d<l.length&&s(r,l[d])})}v.length>0&&m.forEach((l,r)=>{r<v.length&&s(l,v[r])})};document.querySelectorAll("[data-linenumber]:not([data-visual-selector-id])").forEach((l,r)=>{let d=l,E=`visual-id-${d.dataset.filename}-${d.dataset.linenumber}-${r}`;d.dataset.visualSelectorId=E});let at=new MutationObserver(l=>{l.some(d=>{let E=y=>{if(y.nodeType===Node.ELEMENT_NODE){let M=y;if(M.dataset&&M.dataset.visualSelectorId)return!0;for(let H=0;H<M.children.length;H++)if(E(M.children[H]))return!0}return!1};return d.type==="attributes"&&(d.attributeName==="style"||d.attributeName==="class"||d.attributeName==="width"||d.attributeName==="height")&&E(d.target)})&&setTimeout(Q,G)});window.addEventListener("message",lt),window.addEventListener("scroll",ye,!0),document.addEventListener("scroll",ye,!0),window.addEventListener("resize",Q),window.addEventListener("scroll",Q),at.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class","width","height"]}),window.parent.postMessage({type:"visual-edit-agent-ready"},"*")}export{Kt as setupVisualEditAgent};
16
16
  //# sourceMappingURL=index.mjs.map