efficient-easel 10.3.0 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +11 -6
  2. package/dist/{chunk-FCLW4LEN.js → chunk-47RGVCPH.js} +7 -7
  3. package/dist/{chunk-YMEN4KVE.js → chunk-6FFSDH62.js} +1 -1
  4. package/dist/chunk-77DQCEEF.js +5 -0
  5. package/dist/chunk-7LP3OD2E.js +56 -0
  6. package/dist/{chunk-P4CL4YQI.js → chunk-AFSSKGTD.js} +1 -1
  7. package/dist/{chunk-74ZFATLG.js → chunk-BGY4Q2SL.js} +1 -1
  8. package/dist/{chunk-OGCROOTI.js → chunk-DGAXQTDW.js} +1 -1
  9. package/dist/{chunk-JSPZU7X2.js → chunk-FAAZZXIS.js} +1 -1
  10. package/dist/chunk-GCCBEY2W.js +2 -0
  11. package/dist/chunk-GG4FGBFR.js +1 -0
  12. package/dist/{chunk-ERA3XM2U.js → chunk-GJC6SNQC.js} +1 -1
  13. package/dist/{chunk-BRDCD4LK.js → chunk-IFS5P7CO.js} +1 -1
  14. package/dist/{chunk-A5OEGP7B.js → chunk-ISZI4T6A.js} +4 -4
  15. package/dist/{chunk-IZ2QRXSE.js → chunk-JTOZJXD7.js} +1 -1
  16. package/dist/{chunk-M32O2WRM.js → chunk-PE6ZY5IW.js} +11 -11
  17. package/dist/chunk-PPHUWGLZ.js +1 -0
  18. package/dist/{chunk-TROOTMAD.js → chunk-PZHQVOTU.js} +1 -1
  19. package/dist/chunk-QOYOE5CU.js +1 -0
  20. package/dist/{chunk-IL6QCPO6.js → chunk-TJ6NRHYF.js} +1 -1
  21. package/dist/chunk-VWXUMVCD.js +1 -0
  22. package/dist/chunk-XZDHQ4DN.js +5 -0
  23. package/dist/copy/index.js +12 -12
  24. package/dist/drag/drag.css +11 -1
  25. package/dist/drag/index.d.ts +9 -3
  26. package/dist/drag/index.js +1 -1
  27. package/dist/easel/index.js +1 -1
  28. package/dist/screen/components/AddBlockRow.js +1 -1
  29. package/dist/screen/components/AddChildRow.js +4 -1
  30. package/dist/screen/components/AddSidePanel.d.ts +13 -17
  31. package/dist/screen/components/AddSidePanel.js +1 -1
  32. package/dist/screen/components/MediaSidePanel.js +1 -1
  33. package/dist/screen/components/NodeContextMenu.d.ts +3 -15
  34. package/dist/screen/components/NodeContextMenu.js +1 -1
  35. package/dist/screen/components/PageEditGuardNotices.js +1 -1
  36. package/dist/screen/components/ScreenChrome.js +1 -1
  37. package/dist/screen/components/ScreenDocumentContext.js +1 -1
  38. package/dist/screen/components/ScreenMount.js +1 -1
  39. package/dist/screen/components/ScreenStoreProvider.js +1 -1
  40. package/dist/screen/components/SectionScreenShell.js +16 -16
  41. package/dist/screen/components/usePartBridge.js +1 -1
  42. package/dist/screen/index.d.ts +1 -1
  43. package/dist/screen/index.js +1 -1
  44. package/dist/screen/lib/key-scope.js +1 -1
  45. package/dist/screen/lib/puck/device-fields.js +1 -1
  46. package/dist/screen/lib/puck/style-clipboard.js +1 -1
  47. package/dist/screen/lib/puck/use-section-ops.js +1 -1
  48. package/dist/screen/lib/screen-parts.d.ts +6 -62
  49. package/dist/screen/lib/screen-parts.js +1 -1
  50. package/dist/screen/screen.css +2 -8
  51. package/dist/screen/words.d.ts +16 -23
  52. package/dist/screen/words.js +1 -1
  53. package/dist/strings/catalogue.js +1 -1
  54. package/dist/strings/index.js +1 -1
  55. package/package.json +1 -1
  56. package/dist/chunk-5545A3PC.js +0 -4
  57. package/dist/chunk-7O6MDCDU.js +0 -5
  58. package/dist/chunk-D6N77AOS.js +0 -1
  59. package/dist/chunk-FJ3ZJJ5Z.js +0 -57
  60. package/dist/chunk-ICN6COBK.js +0 -5
  61. package/dist/chunk-JTUUIVBZ.js +0 -1
  62. package/dist/chunk-O2NLQBFX.js +0 -1
  63. package/dist/chunk-OWK7DGWG.js +0 -1
  64. package/dist/chunk-THZ46DC5.js +0 -2
package/README.md CHANGED
@@ -889,7 +889,7 @@ const drag = useTreeDrag({ …, session }); // the tree
889
889
  </div>
890
890
 
891
891
  <AddPanel groups={blocks} session={session} itemFor={(type) => ({ kind: 'new', type })}
892
- onInsert={insertAtOpenPlace} at={openPlace && { label: 'Adding to Column 2', onClear }} />
892
+ onInsert={openPlace ? insertAtOpenPlace : undefined} at={openPlace && { label: 'Adding to Column 2', onClear }} />
893
893
  ```
894
894
 
895
895
  - **The canvas measures itself:** `measureCanvas` reads the canvas's lists and
@@ -1188,11 +1188,16 @@ and confirms. `ScreenInspector.select(selector, mode)` moves the selection and
1188
1188
  shows a panel in one step, the mode kept through the reset a change of
1189
1189
  selection makes.
1190
1190
 
1191
- Add, the clipboard, the menu and the keys are the layer's where it says so
1192
- (0.105.0). `add.railTarget(data, selection)` aims the rail's "+" at a place
1193
- of the layer's (the campaign designer's column), and `add.blocksFirst` makes a
1194
- container's blocks the whole panel and leaves a gap between sections to the
1195
- catalogue; a category marked `visible: false` is not offered; Add's words are
1191
+ Add has TWO ways in, and no other (11.0.0, owner ruling A1 amended
1192
+ 2026-10-14): a tile DRAGGED out of Add to its place, or a tile PRESSED after a
1193
+ canvas ➕ opened Add at that place, where it lands. The Layers head's "+" opens
1194
+ Add at no place — every tile is only dragged; the rail has no "+", the tree's
1195
+ gaps no "+", and no menu an add row. Add is ONE list wherever it opens: the
1196
+ catalogue's groups in their order, the blank section (`blockLook.firstSection`)
1197
+ leading its own, then the blocks the catalogue does not hold, from the
1198
+ registry (`canAddTo`), each once. At a place, what it cannot take is dimmed
1199
+ and says why. (`add.railTarget` and `add.blocksFirst`, 0.105.0, went with the
1200
+ rail's "+".) A category marked `visible: false` is not offered; Add's words are
1196
1201
  `screen.add`. `styleClipboard` is Copy style / Paste style's scope and a
1197
1202
  node's look (`scope`, `rows`, `copy`, `plan`); the bridges' `menuRows` are the
1198
1203
  layer's own rows in a node's menu; ⌘C / ⌘X / ⌘V copy, cut and paste the
@@ -1,10 +1,10 @@
1
- import{DEFAULT_DRAG_WORDS as e}from"./chunk-O2NLQBFX.js";import{dropEffectFor as t,scrollBoxOf as n,frameScrollBox as l,startAutoScroll as a,isNoOpDrop as r}from"./chunk-67GNT6PF.js";import{useCanvasLayout as o,useCanvasEvent as s,CANVAS_TYPING_EVENT as i,framePointToHost as c,elementScale as d,frameRectToLayer as u,clientPointToLayer as h}from"./chunk-ILXP5VX5.js";import{withTip as f}from"./chunk-P2VEMZH5.js";import{parseZoneKey as p}from"./chunk-KRXQM65X.js";import{useRef as m,useEffect as g,useState as b,useCallback as x,useMemo as y,useSyncExternalStore as v,useId as w,useLayoutEffect as k}from"react";import{Tooltip as N,IconButton as z,Input as A}from"efficient-shell/ui";import{AddIcon as D,CloseIcon as T,SearchIcon as $}from"efficient-shell/icons/efficient";import{jsxs as C,jsx as M}from"react/jsx-runtime";function S({label:e,onInsert:t,style:n,axis:l="y",className:a,index:r}){const o=["es-canvas-insert","x"===l?"is-x":"",a??""].filter(Boolean).join(" ");/* @__PURE__ */
1
+ import{DEFAULT_DRAG_WORDS as e}from"./chunk-GG4FGBFR.js";import{dropEffectFor as t,scrollBoxOf as n,frameScrollBox as l,startAutoScroll as a,isNoOpDrop as r}from"./chunk-67GNT6PF.js";import{useCanvasLayout as o,useCanvasEvent as s,CANVAS_TYPING_EVENT as i,framePointToHost as c,elementScale as d,frameRectToLayer as u,clientPointToLayer as h}from"./chunk-ILXP5VX5.js";import{withTip as f}from"./chunk-P2VEMZH5.js";import{parseZoneKey as p}from"./chunk-KRXQM65X.js";import{useRef as m,useEffect as g,useState as b,useCallback as x,useMemo as y,useSyncExternalStore as v,useId as w,useLayoutEffect as k}from"react";import{Tooltip as N,IconButton as z,Input as A}from"efficient-shell/ui";import{AddIcon as D,CloseIcon as T,SearchIcon as $}from"efficient-shell/icons/efficient";import{jsxs as C,jsx as M}from"react/jsx-runtime";function S({label:e,onInsert:t,style:n,axis:l="y",className:a,index:r}){const o=["es-canvas-insert","x"===l?"is-x":"",a??""].filter(Boolean).join(" ");/* @__PURE__ */
2
2
  return C("div",{className:o,style:n,"data-index":r,children:[
3
3
  /* @__PURE__ */M("span",{className:"es-canvas-insert-line","aria-hidden":"true"}),
4
- /* @__PURE__ */M("span",{className:"es-canvas-insert-chip",children:/* @__PURE__ */M(N,{content:e,children:/* @__PURE__ */M(z,{variant:"ghost",size:"sm","aria-label":e,onClick:t,children:/* @__PURE__ */M(D,{})})})})]})}var E=(e,t,n)=>t>=e.left&&t<=e.left+e.width&&n>=e.top&&n<=e.top+e.height,L=e=>e.width*e.height;function j(e,t,n){return e.map((e,t)=>({s:e,at:t})).filter(({s:e})=>E(e.box,t,n)).sort((e,t)=>L(t.s.box)-L(e.s.box)||e.at-t.at).map(({s:e})=>e)}function B(e,t,n){return j(e,t,n).at(-1)??null}function X(e,t,n){const l="x"===e.axis?t:n;let a=0;for(const t of e.children){l>("x"===e.axis?t.left+t.width/2:t.top+t.height/2)&&(a+=1)}return a}function K(e,t){const n=e.children;if("x"===e.axis){const l=n[t-1],a=n[t],r=l&&a?(l.left+l.width+a.left)/2:l?l.left+l.width:a?a.left:e.box.left,o=a??l??e.box;return{left:r-1,top:o.top,width:2,height:o.height}}const l=n[t-1],a=n[t],r=l&&a?(l.top+l.height+a.top)/2:l?l.top+l.height:a?a.top:e.box.top;return{left:e.box.left,top:r-1,width:e.box.width,height:2}}function q(e,t,n,l,a=()=>!1,r=()=>!0){const o=e.filter(e=>E(e.box,t,n)).sort((e,t)=>L(e.box)-L(t.box));for(const e of o){const o=X(e,t,n),s={...e.list,index:o};if(a(s))return null;if(l(s))return{zone:e,to:s,line:K(e,o)};if(!r(s))return null}return null}function I(e,t,n=12){const l=e.children;if(0===l.length)return[];const a=e.box,r="x"===e.axis,o=r?a.left:a.top,s=o+(r?a.width:a.height),i=e=>r?e.left:e.top,c=e=>r?e.left+e.width:e.top+e.height,d=[];for(let u=0;u<=l.length;u++){const h=l[u-1],f=l[u];let p,m;if(h&&f)p=c(h),m=Math.max(i(f)-p,0);else{const e=h?(c(h)+s)/2:(o+i(f))/2;p=Math.min(Math.max(e,o+n),s-n),m=0}const g=r?{left:p,top:a.top,width:m,height:a.height}:{left:a.left,top:p,width:a.width,height:m};d.push({key:`${e.key}:+${u}`,place:{...e.list,index:u},box:g,axis:e.axis,label:t})}return d}function O(e,t=e.key){const n=[];for(let l=1;l<e.children.length;l++){const a=e.children[l-1],r=e.children[l],o=a.top+a.height;n.push({key:`${t}:${l}`,place:{...e.list,index:l},box:{left:e.box.left,top:o,width:e.box.width,height:Math.max(r.top-o,0)}})}return n}var P={nodes:[],zones:[]},F="data-puck-dropzone",R="data-puck-component";function V(e,t){if(e.length>=2){const[t,n]=e;return Math.abs(n.top-t.top)<Math.min(t.height,n.height)/2&&n.left>t.left?"x":"y"}const n=t.ownerDocument.defaultView?.getComputedStyle(t);return n&&n.display.includes("flex")&&n.flexDirection.startsWith("row")?"x":"y"}function Z(e,t){const{frame:n,document:l}=e,a=e=>u(n,function(e){const t=e.getBoundingClientRect();return{left:t.left,top:t.top,width:t.width,height:t.height}}(e),t),r=[],o=[];for(const e of l.querySelectorAll(`[${F}]`)){const t=e.getAttribute(F)??"";let n;try{n=p(t)}catch{continue}const l=[...e.querySelectorAll(`[${R}]`)].filter(t=>t.parentElement?.closest(`[${F}]`)===e),s=l.map(a);o.push({key:t,list:n,box:a(e),axis:V(s,e),children:s}),l.forEach((e,t)=>{const l=e.getAttribute(R);l&&r.push({id:l,place:{...n,index:t},box:s[t]})})}return{nodes:r,zones:o}}var Q="data-es-empty-cell",Y="data-puck-dropzone",G=140;var H=e=>({left:e.left,top:e.top,width:e.width,height:e.height});function W(u){const{canvas:f,session:p,readOnly:w,words:z=e.canvas}=u,A=m(u);g(()=>{A.current=u});const D=m(null),T=o(f),[$,E]=b(0),L=x(()=>E(e=>e+1),[]),[B,X]=b(P);g(()=>{const e=D.current;f&&e&&X((A.current.measure??Z)(f,e))},[f,T,u.revision,$]);const K=u.model,I=y(()=>K(B),[K,B]),O=v(p.subscribe,p.shown,p.shown),F=u.choose,R=(e,t)=>{const n=j(I.sources,e,t);return 0===n.length?null:F?F(n):n[n.length-1]},[V,G]=b(null),[W,J]=b(null),U=m(null),_=()=>{U.current&&clearTimeout(U.current),U.current=null},ee=()=>{_(),U.current=setTimeout(()=>{p.get()||G(null)},140)};g(()=>_,[]);const te=m(null),ne=m(!1);s(f,i,e=>{ne.current=Boolean(e.detail?.typing),ne.current&&(_(),G(null))}),s(f,"mousemove",e=>{const t=D.current;if(!f||!t)return;const n=c(f.frame,e.clientX,e.clientY,t),l=d(t),a={x:n.x/l,y:n.y/l};if(te.current=a,A.current.readOnly||p.get()||ne.current)return;_();const r=R(a.x,a.y);G(e=>e?.key===r?.key&&e?.box===r?.box?e:r)}),s(f,"mouseout",e=>{e.relatedTarget||(te.current=null,ee())}),s(f,"mouseover",e=>{e.relatedTarget||L()});const le=m(null),ae=x(()=>{le.current?.(),le.current=null,J(null)},[]);g(()=>p.subscribe(()=>{p.get()?L():ae()}),[p,ae,L]),g(()=>ae,[ae]),("undefined"==typeof document?g:k)(()=>{if(p.get())return;const e=te.current;G(t=>w||ne.current?null:e?R(e.x,e.y):t?I.sources.find(e=>e.key===t.key)??null:null)},[I,O,p,w,F]);const re=e=>{const t=p.get(),n=D.current;if(!t||!n)return null;const l=h(n,e.clientX,e.clientY);te.current=l;const a=q(I.zones,l.x,l.y,e=>A.current.canDrop(t.item,e),e=>!!t.from&&r(t.from,e),e=>A.current.fallThrough?.(t.item,e,t.from)??!0);return a?{h:t,t:a}:null},oe={onDragEnter:e=>{if(le.current)return;const t=n(e.currentTarget.parentElement?.parentElement??null),r=f?l(f.document):null,o=[];t&&o.push(a(t)),r&&f&&o.push(a(r,f.frame)),le.current=o.length?()=>o.forEach(e=>e()):null},onDragOver:e=>{const n=re(e);if(!n)return void J(null);e.preventDefault(),e.dataTransfer.dropEffect=t(e.dataTransfer.effectAllowed);const l={zoneKey:n.t.zone.key,line:n.t.line,axis:n.t.zone.axis};J(e=>e&&e.zoneKey===l.zoneKey&&e.line.left===l.line.left&&e.line.top===l.line.top?e:l)},onDragLeave:e=>{const t=e.relatedTarget;t&&e.currentTarget.contains(t)||(te.current=null,J(null))},onDrop:e=>{const t=re(e);t&&(e.preventDefault(),p.end(),ae(),A.current.onDrop(t.h.item,t.t.to))}},se={draggable:!w&&!!V,onMouseEnter:_,onMouseLeave:()=>!p.get()&&ee(),onDragStart:e=>{if(V&&!w){p.start({key:V.key,item:V.item,from:V.from}),e.dataTransfer.effectAllowed="move";try{e.dataTransfer.setData("text/plain",V.key)}catch{}}else e.preventDefault()},onDragEnd:()=>{p.end(),ae()},onClick:()=>{V&&!w&&A.current.onPick?.(V.item)}},{seams:ie=[]}=I,ce=I.zones.filter(e=>0===e.children.length),de=u.onZoneAdd&&!w?ce:[],ue=de.map(e=>e.key).join("\n");return g(()=>{const e=f?.document;if(!e)return;const t=new Set(ue?ue.split("\n"):[]);for(const n of e.querySelectorAll(`[${Y}]`))n.toggleAttribute(Q,t.has(n.getAttribute(Y)??""));return()=>{for(const t of e.querySelectorAll(`[${Q}]`))t.removeAttribute(Q)}},[f,ue,B,T,$]),/* @__PURE__ */C("div",{ref:D,className:"es-canvas-layer",children:[O||!u.onSeamAdd||w?null:ie.map(e=>
5
- /* @__PURE__ */M(S,{className:"es-canvas-seam",axis:e.axis,index:e.place.index,label:e.label??u.seamLabel??z.addSection,onInsert:()=>u.onSeamAdd?.(e.place),style:"x"===e.axis?{left:e.box.left+e.box.width/2-12,top:e.box.top,width:24,height:e.box.height}:{left:e.box.left,top:e.box.top+e.box.height/2-12,width:e.box.width,height:24}},e.key)),de.length?de.map(e=>/* @__PURE__ */M("button",{type:"button",className:["es-canvas-empty",e.addAlways?"is-always":"",W?.zoneKey===e.key?"is-over":""].filter(Boolean).join(" "),style:H(e.box),onClick:()=>u.onZoneAdd?.({...e.list,index:0}),children:/* @__PURE__ */M("span",{className:"es-canvas-empty-add",children:z.addButton({label:e.addLabel??u.zoneAddLabel??z.addBlock})})},e.key)):null,O?/* @__PURE__ */M("div",{className:"es-canvas-catch",...oe}):null,W&&!ce.some(e=>e.key===W.zoneKey)?/* @__PURE__ */M("div",{className:`es-canvas-line is-${W.axis}`,style:H(W.line)}):null,
6
- /* @__PURE__ */M("div",{className:"es-canvas-handle-spot",style:V?{"--es-handle-x":`${V.box.left+2}px`,"--es-handle-y":`${Math.max(V.box.top-11,0)}px`}:void 0,children:/* @__PURE__ */M(N,{className:"es-canvas-handle-tip",side:"top",content:!V||w||O?null:V.title??z.handle({label:V.label}),children:/* @__PURE__ */C("div",{className:["es-canvas-handle",V&&!w?"is-shown":"",O?"is-dragging":""].filter(Boolean).join(" "),...se,children:[
7
- /* @__PURE__ */M("span",{className:"es-canvas-grip","aria-hidden":"true",children:"⋮⋮"}),V?.label]})})})]})}var J=e=>e.tiles.length>0&&e.tiles.every(e=>null!=e.cover);function U({groups:t,session:n,itemFor:l,onInsert:a,at:r,hint:o,searchLabel:s,readOnly:i,words:c=e.add}){const d=o??c.hint,u=s??c.search,[h,p]=b(""),m=w(),g=h.trim().toLowerCase(),x=function(e){const t=/* @__PURE__ */new Map;return e.map(e=>{const n=e.key??e.title,l=t.get(n)??0;return t.set(n,l+1),0===l?n:`${n}\0${l}`})}(t),y=t.map((e,t)=>({...e,key:x[t],tiles:g?e.tiles.filter(e=>((e,t)=>e.label.toLowerCase().includes(t)||(e.keywords??[]).some(e=>e.toLowerCase().includes(t)))(e,g)):e.tiles})).filter(e=>e.tiles.length>0),v=(e,t)=>a=>{if(t)a.preventDefault();else{n.start({key:`new:${e}`,item:l(e)}),a.dataTransfer.effectAllowed="copy";try{a.dataTransfer.setData("text/plain",e)}catch{}}};/* @__PURE__ */
4
+ /* @__PURE__ */M("span",{className:"es-canvas-insert-chip",children:/* @__PURE__ */M(N,{content:e,children:/* @__PURE__ */M(z,{variant:"ghost",size:"sm","aria-label":e,onClick:t,children:/* @__PURE__ */M(D,{})})})})]})}var E=(e,t,n)=>t>=e.left&&t<=e.left+e.width&&n>=e.top&&n<=e.top+e.height,j=e=>e.width*e.height;function L(e,t,n){return e.map((e,t)=>({s:e,at:t})).filter(({s:e})=>E(e.box,t,n)).sort((e,t)=>j(t.s.box)-j(e.s.box)||e.at-t.at).map(({s:e})=>e)}function B(e,t,n){return L(e,t,n).at(-1)??null}function K(e,t,n){const l="x"===e.axis?t:n;let a=0;for(const t of e.children){l>("x"===e.axis?t.left+t.width/2:t.top+t.height/2)&&(a+=1)}return a}function X(e,t){const n=e.children;if("x"===e.axis){const l=n[t-1],a=n[t],r=l&&a?(l.left+l.width+a.left)/2:l?l.left+l.width:a?a.left:e.box.left,o=a??l??e.box;return{left:r-1,top:o.top,width:2,height:o.height}}const l=n[t-1],a=n[t],r=l&&a?(l.top+l.height+a.top)/2:l?l.top+l.height:a?a.top:e.box.top;return{left:e.box.left,top:r-1,width:e.box.width,height:2}}function q(e,t,n,l,a=()=>!1,r=()=>!0){const o=e.filter(e=>E(e.box,t,n)).sort((e,t)=>j(e.box)-j(t.box));for(const e of o){const o=K(e,t,n),s={...e.list,index:o};if(a(s))return null;if(l(s))return{zone:e,to:s,line:X(e,o)};if(!r(s))return null}return null}function I(e,t,n=12){const l=e.children;if(0===l.length)return[];const a=e.box,r="x"===e.axis,o=r?a.left:a.top,s=o+(r?a.width:a.height),i=e=>r?e.left:e.top,c=e=>r?e.left+e.width:e.top+e.height,d=[];for(let u=0;u<=l.length;u++){const h=l[u-1],f=l[u];let p,m;if(h&&f)p=c(h),m=Math.max(i(f)-p,0);else{const e=h?(c(h)+s)/2:(o+i(f))/2;p=Math.min(Math.max(e,o+n),s-n),m=0}const g=r?{left:p,top:a.top,width:m,height:a.height}:{left:a.left,top:p,width:a.width,height:m};d.push({key:`${e.key}:+${u}`,place:{...e.list,index:u},box:g,axis:e.axis,label:t})}return d}function P(e,t=e.key){const n=[];for(let l=1;l<e.children.length;l++){const a=e.children[l-1],r=e.children[l],o=a.top+a.height;n.push({key:`${t}:${l}`,place:{...e.list,index:l},box:{left:e.box.left,top:o,width:e.box.width,height:Math.max(r.top-o,0)}})}return n}var F={nodes:[],zones:[]},G="data-puck-dropzone",O="data-puck-component";function R(e,t){if(e.length>=2){const[t,n]=e;return Math.abs(n.top-t.top)<Math.min(t.height,n.height)/2&&n.left>t.left?"x":"y"}const n=t.ownerDocument.defaultView?.getComputedStyle(t);return n&&n.display.includes("flex")&&n.flexDirection.startsWith("row")?"x":"y"}function V(e,t){const{frame:n,document:l}=e,a=e=>u(n,function(e){const t=e.getBoundingClientRect();return{left:t.left,top:t.top,width:t.width,height:t.height}}(e),t),r=[],o=[];for(const e of l.querySelectorAll(`[${G}]`)){const t=e.getAttribute(G)??"";let n;try{n=p(t)}catch{continue}const l=[...e.querySelectorAll(`[${O}]`)].filter(t=>t.parentElement?.closest(`[${G}]`)===e),s=l.map(a);o.push({key:t,list:n,box:a(e),axis:R(s,e),children:s}),l.forEach((e,t)=>{const l=e.getAttribute(O);l&&r.push({id:l,place:{...n,index:t},box:s[t]})})}return{nodes:r,zones:o}}var Z="data-es-empty-cell",Y="data-puck-dropzone",H=140;var Q=e=>({left:e.left,top:e.top,width:e.width,height:e.height});function W(u){const{canvas:f,session:p,readOnly:w,words:z=e.canvas}=u,A=m(u);g(()=>{A.current=u});const D=m(null),T=o(f),[$,E]=b(0),j=x(()=>E(e=>e+1),[]),[B,K]=b(F);g(()=>{const e=D.current;f&&e&&K((A.current.measure??V)(f,e))},[f,T,u.revision,$]);const X=u.model,I=y(()=>X(B),[X,B]),P=v(p.subscribe,p.shown,p.shown),G=u.choose,O=(e,t)=>{const n=L(I.sources,e,t);return 0===n.length?null:G?G(n):n[n.length-1]},[R,H]=b(null),[W,J]=b(null),U=m(null),_=()=>{U.current&&clearTimeout(U.current),U.current=null},ee=()=>{_(),U.current=setTimeout(()=>{p.get()||H(null)},140)};g(()=>_,[]);const te=m(null),ne=m(!1);s(f,i,e=>{ne.current=Boolean(e.detail?.typing),ne.current&&(_(),H(null))}),s(f,"mousemove",e=>{const t=D.current;if(!f||!t)return;const n=c(f.frame,e.clientX,e.clientY,t),l=d(t),a={x:n.x/l,y:n.y/l};if(te.current=a,A.current.readOnly||p.get()||ne.current)return;_();const r=O(a.x,a.y);H(e=>e?.key===r?.key&&e?.box===r?.box?e:r)}),s(f,"mouseout",e=>{e.relatedTarget||(te.current=null,ee())}),s(f,"mouseover",e=>{e.relatedTarget||j()});const le=m(null),ae=x(()=>{le.current?.(),le.current=null,J(null)},[]);g(()=>p.subscribe(()=>{p.get()?j():ae()}),[p,ae,j]),g(()=>ae,[ae]),("undefined"==typeof document?g:k)(()=>{if(p.get())return;const e=te.current;H(t=>w||ne.current?null:e?O(e.x,e.y):t?I.sources.find(e=>e.key===t.key)??null:null)},[I,P,p,w,G]);const re=e=>{const t=p.get(),n=D.current;if(!t||!n)return null;const l=h(n,e.clientX,e.clientY);te.current=l;const a=q(I.zones,l.x,l.y,e=>A.current.canDrop(t.item,e),e=>!!t.from&&r(t.from,e),e=>A.current.fallThrough?.(t.item,e,t.from)??!0);return a?{h:t,t:a}:null},oe={onDragEnter:e=>{if(le.current)return;const t=n(e.currentTarget.parentElement?.parentElement??null),r=f?l(f.document):null,o=[];t&&o.push(a(t)),r&&f&&o.push(a(r,f.frame)),le.current=o.length?()=>o.forEach(e=>e()):null},onDragOver:e=>{const n=re(e);if(!n)return void J(null);e.preventDefault(),e.dataTransfer.dropEffect=t(e.dataTransfer.effectAllowed);const l={zoneKey:n.t.zone.key,line:n.t.line,axis:n.t.zone.axis};J(e=>e&&e.zoneKey===l.zoneKey&&e.line.left===l.line.left&&e.line.top===l.line.top?e:l)},onDragLeave:e=>{const t=e.relatedTarget;t&&e.currentTarget.contains(t)||(te.current=null,J(null))},onDrop:e=>{const t=re(e);t&&(e.preventDefault(),p.end(),ae(),A.current.onDrop(t.h.item,t.t.to))}},se={draggable:!w&&!!R,onMouseEnter:_,onMouseLeave:()=>!p.get()&&ee(),onDragStart:e=>{if(R&&!w){p.start({key:R.key,item:R.item,from:R.from}),e.dataTransfer.effectAllowed="move";try{e.dataTransfer.setData("text/plain",R.key)}catch{}}else e.preventDefault()},onDragEnd:()=>{p.end(),ae()},onClick:()=>{R&&!w&&A.current.onPick?.(R.item)}},{seams:ie=[]}=I,ce=I.zones.filter(e=>0===e.children.length),de=u.onZoneAdd&&!w?ce:[],ue=de.map(e=>e.key).join("\n");return g(()=>{const e=f?.document;if(!e)return;const t=new Set(ue?ue.split("\n"):[]);for(const n of e.querySelectorAll(`[${Y}]`))n.toggleAttribute(Z,t.has(n.getAttribute(Y)??""));return()=>{for(const t of e.querySelectorAll(`[${Z}]`))t.removeAttribute(Z)}},[f,ue,B,T,$]),/* @__PURE__ */C("div",{ref:D,className:"es-canvas-layer",children:[P||!u.onSeamAdd||w?null:ie.map(e=>
5
+ /* @__PURE__ */M(S,{className:"es-canvas-seam",axis:e.axis,index:e.place.index,label:e.label??u.seamLabel??z.addSection,onInsert:()=>u.onSeamAdd?.(e.place),style:"x"===e.axis?{left:e.box.left+e.box.width/2-12,top:e.box.top,width:24,height:e.box.height}:{left:e.box.left,top:e.box.top+e.box.height/2-12,width:e.box.width,height:24}},e.key)),de.length?de.map(e=>/* @__PURE__ */M("button",{type:"button",className:["es-canvas-empty",e.addAlways?"is-always":"",W?.zoneKey===e.key?"is-over":""].filter(Boolean).join(" "),style:Q(e.box),onClick:()=>u.onZoneAdd?.({...e.list,index:0}),children:/* @__PURE__ */M("span",{className:"es-canvas-empty-add",children:z.addButton({label:e.addLabel??u.zoneAddLabel??z.addBlock})})},e.key)):null,P?/* @__PURE__ */M("div",{className:"es-canvas-catch",...oe}):null,W&&!ce.some(e=>e.key===W.zoneKey)?/* @__PURE__ */M("div",{className:`es-canvas-line is-${W.axis}`,style:Q(W.line)}):null,
6
+ /* @__PURE__ */M("div",{className:"es-canvas-handle-spot",style:R?{"--es-handle-x":`${R.box.left+2}px`,"--es-handle-y":`${Math.max(R.box.top-11,0)}px`}:void 0,children:/* @__PURE__ */M(N,{className:"es-canvas-handle-tip",side:"top",content:!R||w||P?null:R.title??z.handle({label:R.label}),children:/* @__PURE__ */C("div",{className:["es-canvas-handle",R&&!w?"is-shown":"",P?"is-dragging":""].filter(Boolean).join(" "),...se,children:[
7
+ /* @__PURE__ */M("span",{className:"es-canvas-grip","aria-hidden":"true",children:"⋮⋮"}),R?.label]})})})]})}var J=e=>e.tiles.length>0&&e.tiles.every(e=>null!=e.cover);function U({groups:t,session:n,itemFor:l,onInsert:a,at:r,hint:o,searchLabel:s,readOnly:i,words:c=e.add}){const d=o??c.hint,u=s??c.search,[h,p]=b(""),m=w(),g=h.trim().toLowerCase(),x=function(e){const t=/* @__PURE__ */new Map;return e.map(e=>{const n=e.key??e.title,l=t.get(n)??0;return t.set(n,l+1),0===l?n:`${n}\0${l}`})}(t),y=t.map((e,t)=>({...e,key:x[t],tiles:g?e.tiles.filter(e=>((e,t)=>e.label.toLowerCase().includes(t)||(e.keywords??[]).some(e=>e.toLowerCase().includes(t)))(e,g)):e.tiles})).filter(e=>e.tiles.length>0),v=(e,t)=>a=>{if(t)a.preventDefault();else{n.start({key:`new:${e}`,item:l(e)}),a.dataTransfer.effectAllowed="copy";try{a.dataTransfer.setData("text/plain",e)}catch{}}};/* @__PURE__ */
8
8
  return C("div",{className:"es-add",children:[r?/* @__PURE__ */C("div",{className:"es-add-at",role:"status",children:[
9
9
  /* @__PURE__ */M("span",{children:r.label}),f(c.stop,/* @__PURE__ */M("button",{type:"button",className:"es-add-at-clear","aria-label":c.stop,onClick:r.onClear,children:/* @__PURE__ */M(T,{size:12,"aria-hidden":"true"})}))]}):null,
10
10
  /* @__PURE__ */M("p",{className:"es-add-hint",children:d}),
@@ -14,5 +14,5 @@ return C("div",{className:"es-add",children:[r?/* @__PURE__ */C("div",{className
14
14
  /* @__PURE__ */C("div",{className:"es-add-group-head",children:[
15
15
  /* @__PURE__ */M("span",{className:"es-add-group-title",children:e.title}),
16
16
  /* @__PURE__ */M("span",{className:"es-add-group-count",children:e.tiles.length})]}),
17
- /* @__PURE__ */M("div",{className:J(e)?"es-add-grid is-cards":"es-add-grid",children:e.tiles.map(e=>{const t=Boolean(i||e.disabled),l=i?void 0:e.disabled?e.disabledReason:e.title??c.tile({label:e.label});return f(l,/* @__PURE__ */C("button",{type:"button",className:null!=e.cover?"es-add-tile has-cover":"es-add-tile",draggable:!t,"aria-disabled":t||void 0,"aria-label":c.tile({label:e.label}),onDragStart:v(e.type,t),onDragEnd:()=>n.end(),onClick:()=>!t&&a(e.type),children:[null!=e.cover?/* @__PURE__ */M("span",{className:"es-add-tile-cover","aria-hidden":"true",children:e.cover}):e.icon?/* @__PURE__ */M("span",{className:"es-add-tile-glyph","aria-hidden":"true",children:e.icon}):null,
18
- /* @__PURE__ */M("span",{className:"es-add-tile-label",children:e.label})]},e.type))})})]},e.key))]})}export{U as AddPanel,W as CanvasDragLayer,S as CanvasInsert,P as EMPTY_MEASURE,G as HANDLE_GRACE_MS,q as canvasTarget,E as contains,X as gapInZone,K as gapLine,I as insertSeams,Z as measureCanvas,B as pickSource,O as seamsBetween,j as sourcesAt};
17
+ /* @__PURE__ */M("div",{className:J(e)?"es-add-grid is-cards":"es-add-grid",children:e.tiles.map(e=>{const t=Boolean(i||e.disabled),l=i?void 0:e.disabled?e.disabledReason:e.title??c.tile({label:e.label});return f(l,/* @__PURE__ */C("button",{type:"button",className:null!=e.cover?"es-add-tile has-cover":"es-add-tile",draggable:!t,"aria-disabled":t||void 0,"aria-label":c.tile({label:e.label}),onDragStart:v(e.type,t),onDragEnd:()=>n.end(),onClick:()=>!t&&a?.(e.type),children:[null!=e.cover?/* @__PURE__ */M("span",{className:"es-add-tile-cover","aria-hidden":"true",children:e.cover}):e.icon?/* @__PURE__ */M("span",{className:"es-add-tile-glyph","aria-hidden":"true",children:e.icon}):null,
18
+ /* @__PURE__ */M("span",{className:"es-add-tile-label",children:e.label})]},e.type))})})]},e.key))]})}export{U as AddPanel,W as CanvasDragLayer,S as CanvasInsert,F as EMPTY_MEASURE,H as HANDLE_GRACE_MS,q as canvasTarget,E as contains,K as gapInZone,X as gapLine,I as insertSeams,V as measureCanvas,B as pickSource,P as seamsBetween,L as sourcesAt};
@@ -1,4 +1,4 @@
1
- import{useScreenOwnerName as e}from"./chunk-7O6MDCDU.js";import{settlePanelPick as n}from"./chunk-R6WTQWAC.js";import{MediaPanelHead as i,mediaPickKind as c}from"./chunk-IE55HNMA.js";import{jsxs as o,Fragment as r,jsx as t}from"react/jsx-runtime";function l({panel:l,pick:d,onHide:m}){const p=e();/* @__PURE__ */
1
+ import{useScreenOwnerName as e}from"./chunk-77DQCEEF.js";import{settlePanelPick as n}from"./chunk-R6WTQWAC.js";import{MediaPanelHead as i,mediaPickKind as c}from"./chunk-IE55HNMA.js";import{jsxs as o,Fragment as r,jsx as t}from"react/jsx-runtime";function l({panel:l,pick:d,onHide:m}){const p=e();/* @__PURE__ */
2
2
  return o(r,{children:[
3
3
  /* @__PURE__ */t(i,{context:p,pick:d?{kind:c(d.accept),field:d.title||void 0}:null,onCancel:()=>d&&n(d.requestId,null),onHide:m}),
4
4
  /* @__PURE__ */t("div",{className:"sf-media-panel",children:/* @__PURE__ */t(l,{pick:d,onPick:e=>d&&n(d.requestId,e)})})]})}export{l as MediaSidePanel};
@@ -0,0 +1,5 @@
1
+ import{slotFieldsOf as n}from"./chunk-PLVEGYK6.js";import{usePickFollowsSelection as e}from"./chunk-R6WTQWAC.js";import{EaselCanvas as t,useSelectedFields as r}from"./chunk-PE6ZY5IW.js";import{Inspector as i}from"./chunk-26GHWMNN.js";import{createContext as o,useContext as u}from"react";import{DesktopIcon as l}from"efficient-shell/icons/efficient";import{jsx as s}from"react/jsx-runtime";var c={kind:"puck"};function f(n,e){const t=n,r=e,i=Object.keys(t);return i.length===Object.keys(r).length&&i.every(n=>Object.is(t[n],r[n]))}function a(n){const e=n;return"string"==typeof e.nodeId&&"string"==typeof e.slot}function d(e,t,r){const i=e.slotsOf?.(r);return i||n(t,r.type).map(n=>({slot:n,label:n,rung:!1}))}function p(n,e){return n.isFirst?n.isFirst(e):e.type===n.first}function m(n,e){return n.isLast?n.isLast(e):e.type===n.last}var k={},h=()=>k,v=()=>"",g=()=>null,y=()=>{},b={isLockedBlock:()=>!1,duplicateBlocked:()=>null,nestDepth:()=>0,newSectionNode:()=>null,canAddTo:()=>null,blockIsOffered:()=>!0},O={labelAtLevel:(n,e,t)=>t,descriptions:{},categoryLabel:()=>{},firstSection:null,blockRowName:(n,e)=>e(n.type),plainText:n=>n,Icon:()=>null,Thumbnail:()=>null,useProducts:()=>null},j={options:[{id:"desktop",label:"Desktop",icon:/* @__PURE__ */s(l,{})}],initial:"desktop",fluid:"desktop",widths:{desktop:2e3}},w={read:()=>"sections",write:()=>{},forSelection:(n,e)=>n?"sections":e},L={first:null,last:null,firstGroup:null,lastGroup:null,isSectionGroup:()=>!1,sectionGroupZone:()=>"",panelOf:()=>null};function N(){/* @__PURE__ */
2
+ return s(t,{height:"fill"})}function P(){const{id:n,fields:e,values:t,readOnly:o,onChange:u}=r();/* @__PURE__ */
3
+ return s("div",{className:"es-sidepanel es-sidepanel--right",children:/* @__PURE__ */s(i,{fields:e,values:t,onChange:u,readOnly:o,idPrefix:n})})}var S=o({});function C({parts:n,children:e}){/* @__PURE__ */
4
+ return s(S.Provider,{value:n,children:e})}function G(){return u(S)}function D(){return(G().useOwnerName??v)()}function I(){return(G().useDocumentLabel??g)()}function x(n,e,t,r){return(G().useBridges??h)(n,e,t,r)}function B(n){return(G().useStandaloneBridges??h)(n)}function T(n,e){(G().useDocumentPass??y)(n,e)}function W(){return G().blockRules??b}function A(){return G().blockLook??O}function F(){return G().devices??j}function R(){return G().leftView??w}function E(){return G().pinned??L}function H(){return G().saveSwitch??!0}function K(n){e(!0===G().pickFollowsSelection,n)}function V(){return G().storageNamespace||void 0}function Y(){return G().styleClipboard??null}function Z(){return G().nodeKeys??!0}function M(){return G().notify??null}function Q(){return G().Canvas??N}function q(){return G().CanvasHead??null}function z(){return G().canvasDrag??null}var J=o(null);function U({target:n,children:e}){/* @__PURE__ */
5
+ return s(J.Provider,{value:n,children:e})}function X(){return u(J)}function $(){return G().Inspector??P}export{c as SELECTION_MODE,U as ScreenCanvasTargetProvider,C as ScreenPartsProvider,p as isPinnedFirst,m as isPinnedLast,a as isSlotMode,f as sameInspectorMode,d as screenSlotsOf,A as useScreenBlockLook,W as useScreenBlockRules,x as useScreenBridges,z as useScreenCanvasDrag,Q as useScreenCanvasFrame,q as useScreenCanvasHead,X as useScreenCanvasTarget,F as useScreenDevices,I as useScreenDocumentLabel,T as useScreenDocumentPass,$ as useScreenInspectorPanel,R as useScreenLeftView,Z as useScreenNodeKeys,M as useScreenNotify,D as useScreenOwnerName,G as useScreenParts,K as useScreenPickFollowsSelection,E as useScreenPinned,H as useScreenSaveSwitch,V as useScreenStorageNamespace,Y as useScreenStyleClipboard,B as useStandaloneScreenBridges};
@@ -0,0 +1,56 @@
1
+ import{cloneNodeWithFreshIds as e}from"./chunk-2GVCAIPX.js";import{dedupeSlotChildren as n}from"./chunk-26OOWIJJ.js";import{styleClipboardOf as t}from"./chunk-IFS5P7CO.js";import{markedTreeNodeId as o,revealSelectedTreeRow as r,sameSelector as i}from"./chunk-FGNR22NY.js";import{rootRowName as l,slotChildRowName as s,slotChildRenameProp as d,sectionRenameProp as c}from"./chunk-BHRC3ASL.js";import{scrollPreviewToSection as a,gotoPreviewSlide as p,scrollPreviewToTop as u}from"./chunk-4ES5JGGX.js";import{useEaselKeyTarget as f,useEaselUndoKeys as h,useEaselSaveKey as m,editorRootFocus as g}from"./chunk-BGY4Q2SL.js";import{SlotChildActionsProvider as y}from"./chunk-KCBEE2MC.js";import{screenStorageKeys as S,DEFAULT_PANEL_W as k,clampPanelWidth as v}from"./chunk-TZIIRGVY.js";import{usePartBridge as w}from"./chunk-QOYOE5CU.js";import{useSectionOps as b}from"./chunk-GJC6SNQC.js";import{useNodeClipboard as x,useNodeContextMenu as z}from"./chunk-PPHUWGLZ.js";import{PageEditGuardNotices as C}from"./chunk-AFSSKGTD.js";import{ScreenSaveIcon as B,ScreenMainButton as I}from"./chunk-W4U4SHKW.js";import{useBrowserOffline as O}from"./chunk-RKTF5XLP.js";import{useScreenDocument as N}from"./chunk-GCCBEY2W.js";import{requestMediaPick as P}from"./chunk-KG7RJWOK.js";import{heldStyle as $,styleShortcut as M}from"./chunk-V7U33NF2.js";import{AddSidePanel as j}from"./chunk-XZDHQ4DN.js";import{SidePanelHead as T,PanelShowStrip as A}from"./chunk-PPL7GB7D.js";import{useEaselSession as E}from"./chunk-O7Q4DDJT.js";import{MediaSidePanel as L}from"./chunk-6FFSDH62.js";import{useScreenSaveSwitch as R,useScreenNodeKeys as V,useScreenPinned as F,useScreenDocumentLabel as D,useScreenCanvasFrame as H,useScreenInspectorPanel as W,useScreenDevices as G,useScreenPickFollowsSelection as U,useScreenLeftView as J,SELECTION_MODE as Y,sameInspectorMode as X,useScreenBridges as K,useScreenBlockRules as q,useScreenBlockLook as Q,useScreenStorageNamespace as Z,useScreenNotify as _,useScreenCanvasHead as ee,isSlotMode as ne,useScreenStyleClipboard as te,useScreenDocumentPass as oe,useScreenCanvasDrag as re,ScreenCanvasTargetProvider as ie,isPinnedFirst as le,isPinnedLast as se,screenSlotsOf as de}from"./chunk-77DQCEEF.js";import{ROOT_ZONE as ce,blockNodeActions as ae,TREE_MAX_DEPTH as pe,childSlotsOf as ue,slotFieldsOf as fe,slotChildrenIn as he,nestsInTree as me,newNodeId as ge}from"./chunk-PLVEGYK6.js";import{useMediaPanel as ye,usePanelPick as Se,useCancelPanelPick as ke}from"./chunk-R6WTQWAC.js";import{useEaselHost as ve,useHostEscape as we}from"./chunk-U3JP4VGF.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as be}from"./chunk-6WY6ZXJG.js";import{DEFAULT_SCREEN_WORDS as xe}from"./chunk-VWXUMVCD.js";import{useEasel as ze,useEaselApi as Ce,CanvasPassThroughContext as Be}from"./chunk-PE6ZY5IW.js";import{TreeRow as Ie,Subtree as Oe,LayersTree as Ne,TreeGroupLabel as Pe,TreeRowAction as $e,TreeSeam as Me}from"./chunk-4JSBIW5H.js";import{DEFAULT_TREE_WORDS as je}from"./chunk-K56YDHYQ.js";import{DEFAULT_NODE_MENU_WORDS as Te}from"./chunk-WK3AFPXY.js";import{toItemSelector as Ae,useNodeOps as Ee,clickPick as Le}from"./chunk-ECM5F6JJ.js";import{LayersIcon as Re,MediaIcon as Ve}from"./chunk-4VJATVVR.js";import{EaselTopBar as Fe,TopBarRail as De,TopBarCluster as He,EaselIconButton as We,TopBarDivider as Ge,DeviceSwitch as Ue,InspectorIconButton as Je,PanelResizeHandle as Ye,MAX_PANEL_W as Xe,MIN_PANEL_W as Ke,panelWidthVars as qe}from"./chunk-IE55HNMA.js";import{DEFAULT_NOTICE_WORDS as Qe,DEFAULT_CHROME_WORDS as Ze}from"./chunk-Z6PVRXVY.js";import{holderOf as _e,nameOrSomeone as en}from"./chunk-THWO5YVZ.js";import{DEFAULT_LOCK_WORDS as nn}from"./chunk-RE4LP46F.js";import{useWords as tn}from"./chunk-MFIRYGHW.js";import{insertSeams as on,CanvasDragLayer as rn,CanvasInsert as ln}from"./chunk-47RGVCPH.js";import{DEFAULT_DRAG_WORDS as sn}from"./chunk-GG4FGBFR.js";import{createDragSession as dn,useTreeDrag as cn,gapToMoveIndex as an}from"./chunk-67GNT6PF.js";import{useCanvasFrame as pn,LIST_SELECTOR as un,BLOCK_SELECTOR as fn,useCanvasEvent as hn,nodeIdAt as mn,frameRectToHost as gn,BLOCK_ATTRIBUTE as yn,drawnBox as Sn}from"./chunk-ILXP5VX5.js";import{ROOT_ID as kn,ROOT_SLOT as vn,zoneKey as wn,parseZoneKey as bn,find as xn,DataError as zn}from"./chunk-KRXQM65X.js";import{useRef as Cn,useMemo as Bn,useState as In,useEffect as On,useCallback as Nn,useLayoutEffect as Pn,Fragment as $n}from"react";import{ColoredBadge as Mn,toast as jn,groupColors as Tn}from"efficient-shell/ui";import{UndoIcon as An,RedoIcon as En,RefreshIcon as Ln,AddIcon as Rn,TrashIcon as Vn,EyeOffIcon as Fn,EyeIcon as Dn,DuplicateIcon as Hn}from"efficient-shell/icons/efficient";import{jsx as Wn,jsxs as Gn,Fragment as Un}from"react/jsx-runtime";var Jn=/* @__PURE__ */new WeakSet;function Yn(e,n,t){const o=xn(e,n,t);if(!o)return null;const r=o.path.find(e=>"root"!==e.parentId);return r?r.parentId:t}function Xn({canvas:e,tabs:n,onSelect:t}){const o=Cn(null),[r,i]=In({}),l=n.map(e=>`${e.id}:${e.below?1:0}`).join("|");return Pn(()=>{const t=e?.document,r=e?.window,l=e?.frame;if(!t||!r||!l||0===n.length)return void i({});let s=0;const d=()=>{s=0;const e=o.current;if(!e)return;const d=gn(l,{left:0,top:0,width:r.innerWidth,height:r.innerHeight},e),c={};for(const o of n){const n=t.querySelector(`[${yn}="${r.CSS?.escape?r.CSS.escape(o.id):o.id}"]`),i=n?Sn(n):null;if(!i||0===i.height){c[o.id]=null;continue}const s=gn(l,{left:i.left,top:i.top,width:i.width,height:i.height},e),a=s.top+s.height;if(a<d.top||s.top>d.top+d.height){c[o.id]=null;continue}const p=o.below?a+4:Math.max(s.top,d.top)+6;c[o.id]={left:Math.max(s.left,d.left)+6,top:p}}i(c)},c=()=>{s||(s=r.requestAnimationFrame(d))};d(),r.addEventListener("scroll",c,!0),r.addEventListener("resize",c);const a=new r.MutationObserver(c);return a.observe(t.body,{childList:!0,subtree:!0,attributes:!0}),()=>{s&&r.cancelAnimationFrame(s),r.removeEventListener("scroll",c,!0),r.removeEventListener("resize",c),a.disconnect()}},[e,l]),/* @__PURE__ */Wn("div",{ref:o,className:"es-band-tabs","aria-hidden":"true",children:n.map(e=>{const n=r[e.id];return n?/* @__PURE__ */Wn("span",{className:"es-band-tab","data-band-tab":e.id,style:{left:n.left,top:n.top},onClick:n=>{n.stopPropagation(),t(e.id)},children:/* @__PURE__ */Wn(Mn,{colorClass:Tn("info","solid"),size:"sm",children:e.label})},e.id):null})})}function Kn({expand:e}){/* @__PURE__ */
2
+ return Wn("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round",children:/* @__PURE__ */Gn(Un,e?{children:[
3
+ /* @__PURE__ */Wn("path",{d:"M8 9l4-4 4 4"}),
4
+ /* @__PURE__ */Wn("path",{d:"M8 15l4 4 4-4"})]}:{children:[
5
+ /* @__PURE__ */Wn("path",{d:"M8 4l4 4 4-4"}),
6
+ /* @__PURE__ */Wn("path",{d:"M8 20l4-4 4 4"}),
7
+ /* @__PURE__ */Wn("path",{d:"M5 12h14"})]})})}var qn=`${un}, ${fn}`;function Qn(e,n,t){const o=t-n;if(o<6)return null;if(o<24)return{top:Math.round((n+t)/2),height:Math.round(o)};return{top:Math.round(Math.min(Math.max(e,n+12),t-12))}}var Zn="__rungs";var _n="screen:band",et={duplicate:!0,delete:!0};function nt(){const un=ve(),{target:gn,docId:yn,capabilities:Sn,currentSlug:Tn,siteId:nt,onPublish:tt,saveState:ot,saveConflict:rt,retrySave:it,toggleAutoSave:lt,flushSave:st,access:dt,saveUnreachable:ct=!1,readOnly:at,readOnlyReason:pt=null}=N(),ut=R(),ft=V(),{mediaEditing:ht,hasEditGuard:mt,hasPinnedChrome:gt}=Sn,{appState:yt,dispatch:St,history:kt,selectedItem:vt,getSelectorForId:wt,config:bt}=ze(e=>e),xt=F(),{first:zt,firstGroup:Ct,lastGroup:Bt,isSectionGroup:It,sectionGroupZone:Ot,panelOf:Nt}=xt,Pt=Nt(zt),$t=e=>le(xt,e),Mt=e=>se(xt,e),jt="node"===xt.firstRow,Tt=xt.band??null,At=tn("screen",xe),Et=tn("tree",je),Lt=tn("drag",sn),Rt=tn("notice",Qe),Vt=tn("lock",nn),Ft=tn("menu",Te),Dt=tn("styleClipboard",be),Ht=tn("chrome",Ze),Wt=D()??`/${Tn}`,Gt=H(),Ut=W(),Jt=b({readOnly:at}),Yt=b({readOnly:at,foldIntoHistory:!0}),Xt=Cn(null),Kt=Ce(),qt=Bn(()=>({...Jt,select:e=>{Xt.current=e,Jt.select(e)},commitDocument:(e,n)=>{if(void 0!==n){const t=Kt.config;Xt.current=Ae(e,t,n)}Jt.commitDocument(e,n)}}),[Jt,Kt]),Qt=yt.ui,Zt=Qt.leftSideBarVisible,_t=Qt.rightSideBarVisible,{options:eo,widths:no,initial:to,fluid:oo,fit:ro}=G(),[io,lo]=In(to),so=ye(),co=ht&&null!==so,ao=Se(),po=ke();U(vt?.props.id);const{read:uo,write:fo,forSelection:ho}=J(),[mo,go]=In(uo);On(()=>{fo(mo)},[mo]);const[yo,So]=In(0),ko=Cn(null),vo=Cn(null),wo=pn(vo,{readySelector:qn}),bo=f(vo);h(vo,wo);const xo=O(),zo=_e(dt),Co={state:ot,offline:xo||ot.failed&&ct,readOnlyReason:pt,editing:zo?Rt.editing({name:en(zo.name,Vt),noun:At.noun}):null,conflict:null!=rt,notSaving:At.bar.notSaving},Bo=()=>{at||(ot.failed?it():st())};m(vo,wo,Bo);const[Io,Oo]=In(!1),No=Cn(!1),Po=Cn(!1),[$o,Mo]=In(null),[jo,To]=In([]),[Ao,Eo]=In(Y),Lo="puck"===Ao.kind,Ro=o(Ao,vt?.props.id),[Vo,Fo]=In(null);On(()=>{Vo&&(r(),Fo(null))},[Vo]);const Do=Cn(wt);Do.current=wt;const Ho=Nn((e,{scroll:n})=>{go(n=>ho(e,n)),n&&Fo(e);const t=[];let o=e;for(let e=0;e<4;e++){const e=Do.current(o)?.zone;if(!e||!e.includes(":"))break;const n=e.split(":")[0];t.push(n),t.push(e),o=n}0!==t.length&&Sr(e=>{if(t.every(n=>!e.has(n)))return e;const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},[]),Wo=Cn(null);On(()=>{const e=Wo.current;Wo.current=null;const n=null==vt?.props.id?null:String(vt.props.id);Eo(t=>e&&e.id===n?e.mode:"part"===t.kind&&"nodeId"in t&&t.nodeId===n?t:Nt(vt?.type)??Y);const t=vt?.props.id,o=Xt.current;if(Xt.current=null,!t)return;const r=wt(t);Ho(String(t),{scroll:!i(o,r??null,ce)})},[vt?.props.id,Ho]);const Go=Nn(e=>{Eo(n=>X(n,e)?n:e),St({type:"setUi",ui:{rightSideBarVisible:!0}})},[St]),Uo=Cn(()=>{});Uo.current=(e,n)=>{const t=e?pi(e.zone??ce)[e.index]?.props.id:null,o=null==t?null:String(t),r=null==vt?.props.id?null:String(vt.props.id);Eo(e=>X(e,n)?e:n),o!==r&&(Wo.current={id:o,mode:n},qt.select(e))};const Jo=Nn((e,n)=>Uo.current(e,n),[]),Yo={kind:Ao.kind,mode:Ao,open:Go,show:e=>Eo(e),reveal:()=>{_t||St({type:"setUi",ui:{rightSideBarVisible:!0}})},select:Jo},Xo=K(Yo,{data:yt.data,selected:vt??null,zoneOf:e=>wt(e)?.zone,readOnly:Boolean(at),select:e=>{Eo(Y),qt.select({index:e})},replace:(e,n)=>qt.replaceComponent(ce,e,n),scrollTo:e=>Ei(e)},{device:io,refreshes:yo},{setView:go,reveal:()=>{Zt||St({type:"setUi",ui:{leftSideBarVisible:!0}})}}),Ko=Xo.pinnedSource??!1,qo=Xo.resolveLeftView?Xo.resolveLeftView(mo,co):"media"===mo&&co?mo:"sections",Qo=q(),{isLockedBlock:Zo,duplicateBlocked:_o,nestDepth:er,newSectionNode:nr,canAddTo:tr,blockIsOffered:or}=Qo,rr=Q(),{labelAtLevel:ir,Icon:lr,useProducts:sr}=rr,dr=rr.rowName?(e,n,t)=>rr.rowName(e,n,t):void 0,cr=Nn(e=>{St({type:"setUi",ui:{rightSideBarVisible:!0}}),a(e),Ho(e,{scroll:!0})},[St,Ho]),{selectNode:ar,openPartId:pr}=w({mode:Ao,setMode:Eo,onOpenPart:cr}),[ur,fr]=In(null);we(null!==ur,()=>fr(null));const hr=S(Z()),mr=hr.collapsed,gr=hr.panelWidths,[yr,Sr]=In(()=>{if("undefined"==typeof window)/* @__PURE__ */return new Set;try{const e=window.localStorage.getItem(mr);return new Set(e?JSON.parse(e):[])}catch{/* @__PURE__ */
8
+ return new Set}});On(()=>{try{window.localStorage.setItem(mr,JSON.stringify([...yr]))}catch{}},[yr]);const[kr,vr]=In(()=>{if("undefined"==typeof window)return{...k};try{const e=window.localStorage.getItem(gr);if(!e)return{...k};const n=JSON.parse(e);return{left:v(Number(n.left)||k.left),right:v(Number(n.right)||k.right)}}catch{return{...k}}});On(()=>{const e=setTimeout(()=>{try{window.localStorage.setItem(gr,JSON.stringify(kr))}catch{}},300);return()=>clearTimeout(e)},[kr]);const wr=Nn((e,n)=>vr(t=>{const o="function"==typeof n?n(t[e]):n;return t[e]===o?t:{...t,[e]:o}}),[]),br=Nn(e=>wr("left",e),[wr]),xr=Nn(e=>wr("right",e),[wr]),zr=e=>yr.has(e),Cr=e=>Sr(n=>{const t=new Set(n);return t.has(e)?t.delete(e):t.add(e),t}),Br=Cn(!1),Ir=Cn(null);On(()=>{if(Br.current&&!Io){const e=Ir.current,n=e&&e.isConnected&&!e.closest('[aria-hidden="true"]')?e:null;(n??vo.current?.querySelector(`button[aria-label="${CSS.escape(At.add.title)}"]`))?.focus(),Ir.current=null}Br.current=Io},[Io]),On(()=>{if(!Io||!bo)return;const e=e=>{"Escape"===e.key&&Gi()};return bo.addEventListener("keydown",e),()=>bo.removeEventListener("keydown",e)},[Io,bo]),we(Io,()=>Gi()),On(()=>{!Zt&&Io&&(Oo(!1),Mo(null),No.current=!1)},[Zt]),On(()=>{if(!ao)return Po.current&&St({type:"setUi",ui:{leftSideBarVisible:!1}}),void(Po.current=!1);Io&&(Oo(!1),Mo(null),Po.current=No.current,No.current=!1),Zt||(Po.current=!0,St({type:"setUi",ui:{leftSideBarVisible:!0}}))},[ao]),On(()=>{!Zt&&ao&&(Po.current=!1,po())},[Zt]),On(()=>{if(!ao||!bo)return;const e=e=>{"Escape"===e.key&&po()};return bo.addEventListener("keydown",e),()=>bo.removeEventListener("keydown",e)},[ao,bo]),we(null!==ao,()=>po());const Or=_(),Nr=(e,n="success",t)=>{if(Or)return void(t?Or(e,"error"===n?"error":"info",t):Or(e,"error"===n?"error":"info"));const o={sound:!1,action:t?.action,onClose:t?.onClose};"error"===n?jn.error(e,{...o,duration:t?.duration??3200}):jn.success(e,{...o,duration:t?.duration??1900})},Pr=Cn(null),[$r,Mr]=In(0),[jr,Tr]=In(0),Ar=ee(),Er=Cn(null),Lr=e=>Math.max(0,e.clientHeight-(Er.current?.offsetHeight??0));On(()=>{const e=Pr.current;if(!e)return;const n=()=>{Mr(e.clientWidth),Tr(Lr(e))};n();const t=new ResizeObserver(n);return t.observe(e),Er.current&&t.observe(Er.current),()=>t.disconnect()},[]),Pn(()=>{Pr.current&&(Mr(Pr.current.clientWidth),Tr(Lr(Pr.current)))},[kr,Zt,_t]);const Rr=io===oo?$r>0?$r:no[oo]:no[io],Vr=$r>0?Math.min($r/Rr,"shrink"===ro?1:2):1,Fr=Rr*Vr,Dr=$r>0&&Fr>$r+1,Hr={width:Fr,height:jr||"100%",flex:"none",position:"relative"},Wr={width:Rr,height:jr?jr/Vr:"100%",maxHeight:"none",transform:1!==Vr?`scale(${Vr})`:void 0,transformOrigin:"top left"},Gr=()=>St({type:"setUi",ui:{leftSideBarVisible:!Zt}}),Ur=()=>St({type:"setUi",ui:{rightSideBarVisible:!_t}}),Jr=e=>{Io&&(Oo(!1),Mo(null),No.current=!1,Zt&&mo===e)||ao&&(Po.current=!1,po(),Zt&&mo===e)||(Zt&&mo===e?Gr():(go(e),Zt||St({type:"setUi",ui:{leftSideBarVisible:!0}})))},Yr=()=>{P(un,{accept:"image/*",title:Ht.mediaLibrary})},Xr=()=>{Eo(Y),qt.select(null),u()},Kr=()=>{Eo(Pt??Y),_t||St({type:"setUi",ui:{rightSideBarVisible:!0}})},qr=yt.data.content??[],Qr=()=>{const e=qr.findIndex($t),n=qr.findIndex(Mt);return{floor:e>=0?e+1:0,cap:n>=0?n:qr.length}},Zr=bt,_r=Qo.stripCopy,ei=n=>e(n,_r),ni=x(),ti=Ee({data:yt.data,config:Zr,readOnly:Boolean(at),clipboard:ni,strip:_r?e=>_r(e):void 0,afterRemove:"none",stepBounds:(e,n)=>{if(e.parentId!==kn||e.slot!==vn)return{min:0,max:n-1};const{floor:t,cap:o}=Qr();return{min:t,max:o-1}},commit:(e,{select:n})=>{void 0!==n&&Eo(Y);const t=void 0===n||"node"===n?.kind?n:null;qt.commitDocument(e,t)}}),oi=e=>{const n=xn(yt.data,bt,e);if(!n)return!1;const t=wn(n.place),o=n.node,r=t===ce?di(o):bi(o);return!!ti.remove(e)&&(Nr(At.deleted({name:r}),"success",{duration:8e3,action:{label:At.bar.undo,onClick:()=>{ti.restore(n.node,n.place)}}}),!0)},ri={...ti,remove:oi},ii=e=>ir(e,"block",bt.components[e]?.label??e),li=Nn(e=>bt.components[e]?.defaultProps??{},[bt]),si=e=>ir(e,"section",ii(e)),di=e=>l({type:e.type,props:e.props??{}},si(e.type),dr),{nodeAddresses:ci,zoneItems:ai}=Bn(()=>{const e=/* @__PURE__ */new Map,n=/* @__PURE__ */new Map,t=(o,r,i)=>{n.set(r,o),o.forEach((n,o)=>{const l=String(n.props?.id??"");if(l&&e.set(l,{zone:r,index:o}),i>=pe)return;const s=/* @__PURE__ */new Map;for(const{child:e,zone:t}of ue(bt,n))s.set(t,[...s.get(t)??[],e]);for(const[e,n]of s)t(n,e,i+1)})};return t(qr,ce,0),{nodeAddresses:e,zoneItems:n}},[qr,bt]),pi=Nn(e=>ai.get(e)??[],[ai]),ui=e=>{const n=ci.get(e);return n?pi(n.zone)[n.index]:void 0},fi=e=>de(Qo,bt,e),hi=e=>{if(!Qo.slotsOf||e===ce)return null;const n=e.lastIndexOf(":");if(n<=0)return null;const t=ui(e.slice(0,n));if(!t)return null;const o=fi(t).filter(e=>e.rung),r=o.findIndex(t=>t.slot===e.slice(n+1));return r<0?null:{node:t,slot:o[r],position:r}},mi=(()=>{if(!ne(Ao))return null;const e=`${Ao.nodeId}:${Ao.slot}`;return hi(e)?.slot.panel===Ao.kind?e:null})(),gi=Cn(null);On(()=>{const e=gi.current;if(gi.current=null,!mi||!ne(Ao))return;const n=Ao.nodeId;Ho(n,{scroll:e!==mi}),Sr(e=>{if(!e.has(n))return e;const t=new Set(e);return t.delete(n),t})},[Ao]);const yi=(e,n,t)=>{const o=String(e.props.id);if(!n.panel)return void(e=>{const n=ci.get(e);n&&(n.zone===ce?Li(n.index):pl(n.zone,n.index,e,ui(n.zone.slice(0,n.zone.lastIndexOf(":")))?.type??""))})(o);const r={kind:n.panel,nodeId:o,slot:n.slot},i=`${o}:${n.slot}`;t&&mi!==i&&(gi.current=i),Jo(null,r),_t||St({type:"setUi",ui:{rightSideBarVisible:!0}}),Ei(o)},Si=(e,n,t)=>{const o=`${e}:${n}`;if(Sr(n=>{if(!n.has(o)&&!n.has(e))return n;const t=new Set(n);return t.delete(o),t.delete(e),t}),!t)return;mi!==o&&(gi.current=o);Jo(null,{kind:t,nodeId:e,slot:n})},ki=(e,n,t)=>{if(at||!Qo.moveSlot)return;const o=ui(e),r=o?fi(o).filter(e=>e.rung):[],i=r[n];if(!i)return;const l={parentId:e,slot:Zn,index:n},s=an(l,{...l,index:Math.min(Math.max(t,0),r.length)});if(s===n)return;const d=Qo.moveSlot(e,n,s);"string"==typeof d&&Si(e,d,i.panel)},vi=sr(),wi=Bn(()=>{const e=/* @__PURE__ */new Map;for(const n of vi??[])e.set(n.slug,n.name);return e},[vi]),bi=e=>s(e,ii,rr.plainText,e=>wi.get(e),rr.rowName),xi=(e,n)=>{const t=bt.components[e.type]?.fields,o=n===ce||Ml(n)?"section":"block",r=n===ce&&($t(e)||Mt(e)||It(e.type)),i="block"===o?d(t):r?null:c(t);return rr.renamePropOf?rr.renamePropOf(e,o,i):i},zi=(e,n,t,o)=>{if(!(!at&&ur?.zone===e&&ur.index===n))return;const r=(t,o)=>{fr(null),o&&((e,n,t)=>{const o=pi(e)[n];if(!o)return;const r=xi(o,e);r&&qt.replaceComponent(e,n,{...o,props:{...o.props,[r]:t.trim()}})})(e,n,t)};/* @__PURE__ */
9
+ return Wn("input",{className:"es-tree-rename",defaultValue:o,autoFocus:!0,"aria-label":At.rename,onClick:e=>e.stopPropagation(),onBlur:e=>r(e.currentTarget.value,!0),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),r(e.currentTarget.value,!0)):"Escape"===e.key&&(e.preventDefault(),r("",!1))}},t)},Ci=t(te(),Dt),Bi=Ci.scope({target:gn,siteId:nt,docId:yn}),Ii=bt,Oi=(e,n)=>n===ce?si(e):ii(e),Ni=(e,n,t)=>{const o=Ci.plan(Bi,t,Oi(t.type,e),Ii);o&&(o.changed&&qt.replaceComponent(e,n,{...t,props:{...o.props,id:t.props.id}}),Nr(o.message))},Pi=z({nodesIn:pi,nodeAt:(e,n)=>pi(e)[n]??null,labelOf:(e,n)=>n===ce?si(e):ii(e),renamePropOf:xi,beginRename:(e,n)=>fr({zone:e,index:n}),history:{hasPast:kt.hasPast,hasFuture:kt.hasFuture,back:()=>kt.back(),forward:()=>kt.forward()},openPageSettings:()=>{qt.select(null),Eo(Y)},pageSettingsLabel:At.pageSettings,words:{menu:Ft,styleClipboard:Dt,screen:At.menu},readOnly:Boolean(at),collapseAll:()=>Sr(new Set(pi(ce).map(e=>String(e.props.id)))),onPasteRefused:e=>Nr(e?At.pasteRefused({name:e.label}):At.menu.clipboardRefused,"error"),canPasteAt:(e,n)=>Al(e,n),menuRows:Xo.menuRows,isLocked:e=>Zo(e.type),duplicateBlocked:e=>_o(yt.data,e),permits:e=>ae(bt,e.type),nodeOps:ri,isPinned:(e,n)=>n===ce&&($t(e)||Mt(e)),sectionBand:Qr,locate:e=>ci.get(e)??null,rowNameOf:(e,n)=>n===ce?di(e):bi(e),selectAt:(e,n,t,o)=>{e===ce?Li(n):pl(e,n,t,o??"")},slotRung:e=>{const n=hi(e);return n?.slot.panel?{label:n.slot.label,select:()=>yi(n.node,n.slot,!1)}:null},style:{held:()=>$(Bi),canCopy:e=>Ci.rows(Ii,e).some(e=>!1!==e.counted),copy:(e,n)=>Ci.copy(Bi,e,Oi(e.type,n),Ii),paste:(e,n,t)=>Ni(e,n,t)},keys:ft?{target:bo,selected:()=>{const e=yt.ui.itemSelector;return e?{zone:e.zone??ce,index:e.index}:null},held:()=>ni.get(),readOnly:Boolean(at),onDone:({done:e,name:n})=>{"copied"===e&&Nr(At.copied({name:n}))}}:void 0},wo),$i=Cn({copy:(e,n)=>{},paste:(e,n,t)=>{},at:()=>null,readOnly:!1});On(()=>{$i.current={copy:(e,n)=>Ci.copy(Bi,e,Oi(e.type,n),Ii),paste:Ni,at:()=>{const e=yt.ui.itemSelector;if(!e)return null;const n=e.zone??ce,t=pi(n)[e.index];return t?{zone:n,index:e.index,node:t}:null},readOnly:Boolean(at)}});const Mi=Nn(e=>{const n=M(e);if(!n)return;const t=$i.current,o=t.at();o&&(e.preventDefault(),"copy"===n?t.copy(o.node,o.zone):t.readOnly||t.paste(o.zone,o.index,o.node))},[]);On(()=>{if(!bo)return;const e=e=>Mi(e);return bo.addEventListener("keydown",e),()=>bo.removeEventListener("keydown",e)},[Mi,bo]),hn(wo,"keydown",Mi);const ji=qr.map(e=>e.props.id).join("|");On(()=>{const e=wo?.document??null,n=wo?.window??null;let t=0;const o=[],r=()=>{if(!e)return void To(e=>e.length?[]:e);const n=qr.findIndex(Mt),t=n>=0?n:qr.length,o=n=>{const t=qr[n]?.props?.id;return null==t?null:e.querySelector(`[data-puck-component="${CSS.escape(String(t))}"]`)},r=e=>e?[...e.querySelectorAll(fn)].map(e=>e.getBoundingClientRect()).filter(e=>e.width>0||e.height>0):[],i=[];for(let e=qr.length>0&&!$t(qr[0])?0:1;e<=t;e++){const n=o(e),t=o(e-1),l=n?.getBoundingClientRect()??null,s=t?.getBoundingClientRect()??null;if(!l&&!s)continue;const d=Qn(l&&s?(s.bottom+l.top)/2:l?0===e?l.top+12:l.top:s.bottom,Math.max(0===e?0:-1/0,...r(t).map(e=>e.bottom)),Math.min(1/0,...r(n).map(e=>e.top)));d&&i.push({...d,index:e})}To(e=>function(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t].top!==n[t].top||e[t].index!==n[t].index||e[t].height!==n[t].height)return!1;return!0}(e,i)?e:i)},i=()=>{cancelAnimationFrame(t),t=requestAnimationFrame(r)};if(!e||!n)return void r();n.addEventListener("scroll",i,{passive:!0});const l=new ResizeObserver(i);return l.observe(e.documentElement),r(),o.push(setTimeout(r,150),setTimeout(r,450)),()=>{cancelAnimationFrame(t),o.forEach(clearTimeout),n.removeEventListener("scroll",i),l.disconnect()}},[wo,ji,io,Vr,Zt,_t,vt?.props.id]);const Ti=wo?.document??null,Ai=wo?.window??null;On(()=>{const e=ko.current;if(!e||!Ti||!Ai)return;const n=[],t=()=>{const n=Ti.querySelector(`[data-puck-component="${CSS.escape(e.id)}"]`);if(!n)return!1;const t=n.getBoundingClientRect().top-e.offset;return Math.abs(t)>1&&Ai.scrollTo({left:Ai.scrollX,top:Ai.scrollY+t,behavior:"instant"}),!0};return ko.current=null,t()&&n.push(setTimeout(t,150),setTimeout(t,450)),()=>n.forEach(clearTimeout)},[Ti,Ai]);const Ei=e=>{Xo.holdCanvasOn?Xo.holdCanvasOn(e):a(e)},Li=e=>{Eo(Y),qt.select({index:e}),Xo.sectionPressed?.(qr[e]);const n=qr[e]?.props?.id;n&&Ei(n)},Ri=e=>{const{floor:n,cap:t}=Qr(),o=e=>Math.min(Math.max(n,e),t);if("number"==typeof e)return o(e);const r=vt&&Ao.kind!==Pt?.kind?qr.findIndex(e=>e.props.id===vt.props.id):-1;return o(r>=0?r+1:t)},Vi=(e,n)=>{const{floor:t,cap:o}=Qr(),r=Math.min(Math.max(n,t),o),i=e<r?r-1:r;return i===e?{moved:!1,dest:e}:(qt.reorderComponent(ce,e,i),qt.select({index:i}),{moved:!0,dest:i})},Fi=(e,n,t,o)=>{Eo(Y),qt.select(o?{index:o.index,zone:o.zone}:{index:e}),a(n),Nr(At.sectionAdded({name:t}))},Di=(e,n)=>{const t=Ri(n),o=nr(e,{nodeDefaults:li,newNodeId:ge,sectionLabel:si,blockIsOffered:or}),r=o?qt.insertNode(ce,t,o):qt.insertSection(e,t);return Fi(t,r,si(e),o?((e,n,t)=>{if(e.type===t)return null;const o={at:null},r=(e,n,i)=>{const l=i.filter(n=>n===e.type).length;for(const{child:s,zone:d,index:c}of ue(bt,e)){if(s.type===t&&(!o.at||n>o.at.depth)){const r=tr(e.type,l,d.slice(d.lastIndexOf(":")+1)),i=r?.choices??(r?.spec?[{type:r.spec.childType,label:r.spec.childType}]:[]);null!==r&&"footer"!==r.source&&`${e.props.id}:${r.slot}`===d&&i.some(e=>e.type===t)&&(o.at={zone:d,index:c,depth:n})}r(s,n+1,[...i,e.type])}};return r({type:e.type,props:{...e.props,id:n}},1,[]),o.at?{zone:o.at.zone,index:o.at.index}:null})(o,r,e):null),t},Hi=e=>Wi(ce,e),Wi=(e,n)=>{Ir.current=document.activeElement??null,ao&&(No.current=Po.current,Po.current=!1,po()),Mo(null===n?null:{zone:e,index:n}),Oo(!0),Zt||(No.current=!0,St({type:"setUi",ui:{leftSideBarVisible:!0}}))},Gi=()=>{Oo(!1),Mo(null),No.current&&St({type:"setUi",ui:{leftSideBarVisible:!1}}),No.current=!1},Ui=(e,n)=>rr.rowName?n?$t(e)?rr.rowName(e,"section",At.header):Mt(e)?rr.rowName(e,"section",At.footer):It(e.type)?rr.rowName(e,"section",ii(e.type)):di(e):bi(e):n?si(e.type):ii(e.type),Ji=e=>n=>{e()},Yi=()=>Xo.editPinnedSource?.(),Xi=(e,n,t)=>{if(at)return null;const o=pi(e)[n];return o&&!ae(bt,o.type).delete?null:/* @__PURE__ */Wn($e,{kind:"delete",label:At.deleteNamed({name:t}),onClick:()=>((e,n)=>{const t=pi(e)[n]?.props?.id;null!=t&&oi(String(t))})(e,n),children:/* @__PURE__ */Wn(Vn,{size:15})})},Ki=e=>rr.rowPreview?.(e)||void 0,qi=e=>rr.rowMarks?.(e)??void 0,Qi=(e,n,t)=>rr.rowActions?.(e,n,t)??null,Zi=(e,n,t,o)=>{if(at)return null;const r=Boolean(t.props._hidden);/* @__PURE__ */
10
+ return Wn($e,{kind:"eye",label:r?At.showNamed({name:o}):At.hideNamed({name:o}),onClick:()=>el(e,n,t),children:/* @__PURE__ */Wn(r?Fn:Dn,{size:14,strokeWidth:1.8,strokeLinecap:void 0,strokeLinejoin:void 0})})},_i=e=>ps(ce,e),el=(e,n,t)=>{qt.replaceComponent(e,n,{...t,props:{...t.props,_hidden:!t.props._hidden}})},nl=e=>fe(bt,e),tl=e=>ue(bt,e),ol=e=>Qo.slotsOf?fi(e).map(n=>({slot:n.slot,rung:n.rung?n:null,kids:he(e,n.slot)})):[{slot:null,rung:null,kids:tl(e)}],rl=e=>Qo.slotsOf?ol(e).flatMap(e=>e.kids):tl(e),il=e=>Boolean(Qo.slotsOf)&&fi(e).some(e=>e.rung),ll=(e,n,t)=>null===t?void 0===n?tr(e):tr(e,n):tr(e,n,t),sl=(e,n,t)=>{const o=me(bt,e.type,n)&&(t||rl(e).length>0||il(e));return{collapsible:o,folded:o&&zr(String(e.props.id))}},dl=(e,n,t)=>ol(e).flatMap(o=>{const r=o.rung?n+1:n,i=o.kids.flatMap(({child:e})=>sl(e,r,t(e.type)).collapsible?[String(e.props.id),...dl(e,r+1,t)]:[]);return o.rung?[`${e.props.id}:${o.rung.slot}`,...i]:i}),cl=e=>rl(e).length>0||il(e)||Boolean(tr(e.type)),al=e=>Boolean(tr(e)),pl=(e,n,t,o)=>{if(Eo(Y),tr(o)?.spec?.slider){const t=e.split(":")[0];p(t,n),qt.select({index:n,zone:e}),a(t)}else qt.select({index:n,zone:e}),Ei(t)},ul=(e,n,t,o,r)=>{const i=`${e}:${n}`;qt.insertComponent(i,t,o),tr(r)?.spec?.slider?requestAnimationFrame(()=>{p(e,o),qt.select({index:o,zone:i})}):qt.select({index:o,zone:i})},fl=Cn(/* @__PURE__ */new Set);On(()=>{qr.forEach(e=>{const n=tr(e.type)?.spec;if(!n)return;const t=e.props.id;if(fl.current.has(t))return;fl.current.add(t);if((Array.isArray(e.props[n.slot])?e.props[n.slot]:[]).length>0)return;if(n.skipSeed?.(e.props))return;const o=`${t}:${n.slot}`,r=n.legacy?.(e.props)??[];(r.length?r:n.seeds(li)).forEach((e,t)=>Yt.seedChild(o,t,n.childType,e))})},[qr,Yt,li]);const hl=Cn(/* @__PURE__ */new Set);On(()=>{qr.forEach((e,t)=>{const o=e.props.id;if(hl.current.has(o))return;const r=n(e,nl(e.type));hl.current.add(o),r&&Yt.replaceComponent(ce,t,{...e,props:r})})},[qr,Yt]),oe(Yt,bt);const ml=qr.findIndex(Mt),gl=ml>=0?qr[ml]:null,yl=jt?qr.findIndex($t):-1,Sl=yl>=0?qr[yl]:null,kl=xt.groupTab,vl=Bn(()=>kl?e=>It(e.type):void 0,[kl]),wl=Boolean(xt.groupBadge),bl=xt.groupBadge?/* @__PURE__ */Wn("span",{className:"es-tree-group-badge",children:/* @__PURE__ */Wn(Mn,{tone:"info",size:"xs",children:xt.groupBadge})}):void 0,xl=qr.find(e=>e.type===Ct)??null,zl=qr.find(e=>e.type===Bt)??null,Cl=ml>=0?ml:qr.length,Bl=[];qr.forEach(e=>{Mt(e)||(cl(e)&&Bl.push(String(e.props.id)),Bl.push(...dl(e,1,al)))}),gl&&(Bl.push(String(gl.props.id)),Bl.push(...dl(gl,1,al)));const Il=Bl.length>0&&Bl.every(e=>yr.has(e)),Ol=e=>{const n=rr.blockRowName(e,ii);return rr.rowName?rr.rowName(e,"block",n):n},Nl=(e,n,t,o)=>{const r=pi(e)[t];if(!r)return;const i={...bn(e),index:t},l={...bn(n),index:Math.min(Math.max(o,0),pi(n).length)},s=an(i,l);if(e!==n||s!==t)try{ti.move(String(r.props.id),{...l,index:s})}catch(e){if(!(e instanceof zn))throw e}},Pl=e=>{const n=/* @__PURE__ */new Set,t=e=>{for(const{child:o,zone:r}of tl(e))n.add(r),t(o)};for(const t of nl(e.type))n.add(`${e.props.id}:${t}`);return t(e),n},$l=e=>{let n=e.slice(0,e.indexOf(":"));for(let e=0;e<64;e++){const e=ci.get(n);if(!e)return null;if(e.zone===ce)return n;n=e.zone.slice(0,e.zone.indexOf(":"))}return null},Ml=e=>{const n=e.slice(0,e.indexOf(":")),t=qr.find(e=>It(e.type)&&String(e.props.id)===n);return t&&Ot(n)===e?t:null},jl=(e,n)=>{const t=Ml(e);return!t||(!xt.groupAccepts||xt.groupAccepts(t.type,n,pi(e).length))},Tl=(e,n,t)=>{if(e.rung){const t=ui(e.rung.nodeId),o=t?fi(t).filter(e=>e.rung).length:0;return n.parentId===e.rung.nodeId&&n.slot===Zn&&n.index>=0&&n.index<=o}if(n.slot===Zn)return!1;if(e.add)return Ll(e.add,n);const o=wn(n);if(It(e.type))return!1;const r=Ml(o),i=Ml(e.zone);if(r||i)return!(!r||!i)&&(!(r!==i&&!jl(o,e.type))&&(n.index>=0&&n.index<=pi(o).length));if(e.zone===ce||o===ce){if(e.zone!==o)return!1;const{floor:t,cap:r}=Qr();return n.index>=t&&n.index<=r}if(n.index<0||n.index>pi(o).length)return!1;if(e.zone===o)return!0;const l=gl&&!xt.lastIsOpen?String(gl.props.id):null;return(!l||$l(e.zone)!==l&&$l(o)!==l)&&((e,n,t,o)=>{if(e===n)return!0;const r=o??pi(e)[t];if(!r)return!1;const i=n.split(":")[0],l=ci.get(i),s=l?pi(l.zone)[l.index]:void 0;if(!s)return!1;if(!o&&Pl(r).has(n))return!1;const d=tr(s.type,er(yt?.data,s.type,i),n.slice(n.lastIndexOf(":")+1));return!!d&&(!!(d.choices?d.choices.some(e=>e.type===r.type):d.spec?.childType===r.type)&&!d.spec?.addBlocked?.(pi(n),r))})(e.zone,o,e.index,t)},Al=(e,n)=>{const t=wn(e.from),o=e.node;return t===wn(n)?jl(t,o.type):Tl({id:String(o.props?.id??""),zone:t,index:-1,type:o.type},n,o)},El=e=>{const n=e.slice(0,e.indexOf(":")),t=ci.get(n),o=t?pi(t.zone)[t.index]:void 0;if(!t||!o)return null;const r=tr(o.type,er(yt?.data,o.type,n),e.slice(e.lastIndexOf(":")+1));if(!r||`${n}:${r.slot}`!==e)return null;if("footer"===r.source)return null;const i=r.choices??(r.spec?[{type:r.spec.childType,label:ii(r.spec.childType)}]:[]),l=hi(e);return{parent:o,parentId:n,target:r,choices:i,parentName:l?l.slot.label:Ui(o,t.zone===ce)}},Ll=(e,n)=>{const t=wn(n);if("block"!==e.kind){if(Ml(t)){const o="section"===e.kind?e.type:e.template.node.type;return jl(t,o)&&n.index>=0&&n.index<=pi(t).length}if(t!==ce)return!1;const{floor:o,cap:r}=Qr();return n.index>=o&&n.index<=r}if(t===ce)return!1;const o=El(t);return!(!o||!o.choices.some(n=>n.type===e.type))&&!o.target.spec?.addBlocked?.(pi(t))},Rl=(e,n)=>{if("block"!==e.kind&&Ml(wn(n)))return void((e,n,t)=>{const o="section"===e.kind?e.type:"template"===e.kind?e.template.node.type:null;if(o&&jl(n,o)){if("section"===e.kind)qt.insertComponent(n,e.type,t);else{if("template"!==e.kind)return;qt.insertNode(n,t,ei(e.template.node))}Eo(Y),qt.select({index:t,zone:n})}})(e,wn(n),n.index);if("section"===e.kind)return void Di(e.type,n.index);if("template"===e.kind)return void((e,n,t)=>{const o=Ri(t),r=qt.insertNode(ce,o,n);Fi(o,r,e)})(e.template.name,ei(e.template.node),n.index);const t=wn(n),o=El(t);o&&(o.target.spec?ul(o.parentId,o.target.slot,e.type,n.index,o.parent.type):((e,n,t)=>{qt.insertComponent(e,n,t),Eo(Y),qt.select({index:t,zone:e})})(t,e.type,n.index))},Vl=(e,n)=>{e.rung?ki(e.rung.nodeId,e.index,n.index):e.add?Rl(e.add,n):e.zone===ce?Vi(e.index,n.index):Nl(e.zone,wn(n),e.index,n.index)},[Fl]=In(()=>dn()),Dl=cn({keyOf:e=>e.id,readOnly:Boolean(at),session:Fl,canDrop:Tl,onDrop:Vl,onStep:(e,n)=>{e.rung?ki(e.rung.nodeId,e.index,n<0?e.index-1:e.index+2):e.zone===ce?((e,n)=>{const t=si(qr[e]?.type??""),o=Vi(e,n<0?e-1:e+2);if(!o.moved)return void Nr(n<0?At.sectionFirst({name:t}):At.sectionLast({name:t}));const{floor:r,cap:i}=Qr();Nr(At.sectionMoved({name:t,n:o.dest-r+1,total:i-r}))})(e.index,n):Nl(e.zone,e.zone,e.index,n<0?e.index-1:e.index+2)}}),Hl=Nn(e=>{const{floor:n,cap:t}=Qr(),o=[];for(const r of e.nodes){const e=wn(r.place),i=pi(e)[r.place.index];if(!i||String(i.props.id)!==r.id)continue;if($t(i)||Mt(i)||Zo(i.type))continue;if(It(i.type))continue;const l=Boolean(Ml(e)),s=e===ce||l;e===ce&&t-n<2||o.push({key:r.id,item:{id:r.id,zone:e,index:r.place.index,type:i.type},box:r.box,label:s?si(i.type):bi(i),from:r.place})}const r=e.zones.flatMap(e=>{const n=wn(e.list);return n===ce&&0===e.children.length?[{...e,addLabel:At.addSection,addAlways:!0}]:e.children.length>0||Boolean(El(n)?.choices.length)||Boolean(Ml(n))?[e]:[]}),i=r.flatMap(e=>{const n=wn(e.list);return n===ce||Ml(n)||!El(n)?.choices.length?[]:on(e,At.addBlockHere)});return{sources:o,zones:r,seams:i}},[yt.data]),Wl=null==vt?.props.id?null:String(vt.props.id),Gl=Nn(e=>{const n=bt,t=e=>!e.item.rung&&null!==xn(yt.data,n,e.item.id),o=e[e.length-1];if(!t(o))return o;const r=n=>e.find(e=>t(e)&&e.item.id===n),i=r(Wl);return i||(r(Le(yt.data,n,o.item.id,Wl,vl))??o)},[yt.data,bt,Wl,vl]),[Ul,Jl]=In(null);hn(wo,"mouseover",e=>{if(!kl)return;const n=mn(e.target),t=n?Yn(yt.data,bt,n):null;t!==Ul&&Jl(t)}),hn(wo,"mouseout",e=>{kl&&!e.relatedTarget&&Jl(null)});const Yl=e=>$t(e)||Mt(e)||It(e.type),Xl=[];if(kl){const e=Wl?Yn(yt.data,bt,Wl):null;for(const n of/* @__PURE__ */new Set([e,Ul])){const e=n?qr.find(e=>String(e.props.id)===n):void 0;if(!e||!Yl(e))continue;const t=kl(e);t&&Xl.push({id:String(e.props.id),label:t,below:$t(e)||e.type===Ct})}}const Kl=E(),ql=Cn(null);On(()=>{const e=xt.changeNotice;if(!e)return;const n=JSON.stringify(qr.filter(Yl)),t=ql.current;if(ql.current={doc:yn,bands:n,index:kt.index},!t||t.doc!==yn||t.bands===n)return;kt.hasPast&&kt.index>=t.index&&!Jn.has(Kl)&&(Jn.add(Kl),Nr(e,"success",{action:{label:At.bar.undo,onClick:()=>kt.back()},duration:8e3}))},[qr]);const Ql=e=>{Eo(Y),qt.select(e.zone===ce?{index:e.index}:{index:e.index,zone:e.zone})},Zl=re(),_l=()=>({data:yt.data,device:io,ops:qt,inspector:Yo}),es=Zl?.model,ns=Bn(()=>es?e=>es(e,Hl(e),_l()):Hl,[es,Hl,io]),ts=Zl?.measure,os=ts?(e,n)=>ts(e,n,_l()):void 0,rs=Zl?.canDrop,is=rs?(e,n)=>rs(e,n,Tl,_l()):Tl,ls=Zl?.drop,ss=ls?(e,n)=>ls(e,n,Vl,_l()):Vl,ds=Zl?.pick,cs=ds?e=>ds(e,Ql,_l()):Ql,as=e=>{const n=wn(e),t=hi(n);t&&yi(t.node,t.slot,!1),Wi(n,e.index)},ps=(e,n)=>/* @__PURE__ */Wn(Me,{...at?{}:Dl.seam({place:{...bn(e),index:n}})},`seam:${e}:${n}`),us={rowClick:Ji,isCollapsed:zr,toggleCollapse:Cr},fs=e=>{const n=String(e.props.id),t=qr.findIndex(e=>String(e.props.id)===n),o=Ot(n),r=pi(o),i=zr(n),l=ii(e.type),s=rr.rowName?rr.rowName(e,"section",l):l,d=e=>ps(o,e);/* @__PURE__ */
11
+ return Gn(Un,{children:[
12
+ /* @__PURE__ */Wn(Ie,{words:Et,icon:/* @__PURE__ */Wn(lr,{type:e.type,size:13}),name:s,preview:Ki(e),marks:qi(e),onSelect:()=>Li(t),nameSlot:zi(ce,t,n,s),selected:Ro===n,badge:bl,actions:Qi(e,ce,t)??void 0,rowProps:{"data-node-id":n,onClick:Ji(()=>Li(t))},fold:{open:!i,label:"section",onToggle:()=>Cr(n)}}),!i&&/* @__PURE__ */Gn(Oe,{children:[r.map((n,t)=>{const r=String(n.props.id),i=di(n),l=cl(n),s=l&&zr(r),c=()=>pl(o,t,r,e.type),{rowProps:a,...p}=Dl.row({item:{id:r,zone:o,index:t,type:n.type},place:{...bn(o),index:t}},{"data-node-id":r,onClick:Ji(c)});/* @__PURE__ */
13
+ return Gn($n,{children:[d(t),
14
+ /* @__PURE__ */Wn(Ie,{words:Et,icon:/* @__PURE__ */Wn(lr,{type:n.type,size:13}),name:i,preview:Ki(n),marks:qi(n),onSelect:c,nameSlot:zi(o,t,r,i),selected:Ro===r,hidden:Boolean(n.props._hidden),...p,fold:l?{open:!s,label:"section",onToggle:()=>Cr(r)}:void 0,actions:/* @__PURE__ */Gn(Un,{children:[Xi(o,t,i),Qi(n,o,t),Zi(o,t,n,i)]}),rowProps:a}),l&&!s&&/* @__PURE__ */Wn(Oe,{children:gs(n,2)})]},r)}),d(r.length)]})]})},hs=(e,n,t,o,r)=>{const i=String(e.props.id),l=`${i}:${n.slot}`,s=Dl.dragging,d=!zr(l)&&s?.rung?.nodeId!==i,c={...bn(l),index:0},a=s&&!s.rung&&Tl(s,c)?c:void 0,p=()=>yi(e,n,!0),{rowProps:u,...f}=Dl.row({item:{id:`rung:${l}`,zone:`${i}:${Zn}`,index:t,type:e.type,rung:{nodeId:i,slot:n.slot}},place:{parentId:i,slot:Zn,index:t},into:a,canDrag:Boolean(Qo.moveSlot)&&!1!==n.movable&&o>1},{"data-slot-zone":l,onClick:Ji(p)}),h=at?null:Qo.slotActions?.(e,n.slot);/* @__PURE__ */
15
+ return Gn($n,{children:[n.heading,
16
+ /* @__PURE__ */Wn(Ie,{words:Et,icon:n.glyph??null,name:n.label,badge:n.badge,onSelect:p,selected:mi===l,...f,dragHint:n.dragHint,fold:{open:d,label:n.label,onToggle:()=>Cr(l)},actions:h&&h.length>0?/* @__PURE__ */Wn(Un,{children:h.map((t,o)=>/* @__PURE__ */Wn($e,{kind:"delete"===t.kind?"delete":"plain",label:t.label,disabled:t.disabled,onClick:()=>((e,n,t)=>{if(at||t.disabled)return;const o=String(e.props.id),r=e=>{"string"==typeof e&&Si(o,e,n.panel)},i=t.run();i&&"function"==typeof i.then?i.then(r):r(i)})(e,n,t),children:"delete"===t.kind?/* @__PURE__ */Wn(Vn,{size:15}):/* @__PURE__ */Wn(Hn,{size:15})},`${o}:${t.kind}`))}):void 0,rowProps:u}),d&&/* @__PURE__ */Wn(Oe,{children:r})]},l)},ms=(e,n)=>{const t=ol(e),o=t.filter(e=>e.rung).length;let r=0;/* @__PURE__ */
17
+ return Wn(Un,{children:t.map(t=>{const i=t.kids,l=t.rung?n+1:n,s=ll(e.type,void 0,t.slot),d=s?`${e.props.id}:${s.slot}`:null,c=null===t.slot?null:`${e.props.id}:${t.slot}`,a=(e,n)=>ps(e,n),p=/* @__PURE__ */Gn(Un,{children:[i.map(({child:n,zone:t,index:o})=>{const r=Ro===String(n.props.id),{collapsible:i,folded:s}=sl(n,l,al(n.type)),d=String(n.props.id),c=Ol(n),p=()=>pl(t,o,d,e.type),{rowProps:u,...f}=Dl.row({item:{id:d,zone:t,index:o,type:n.type},place:{...bn(t),index:o}},{"data-node-id":d,onClick:Ji(p)});/* @__PURE__ */
18
+ return Gn($n,{children:[0===o&&a(t,0),
19
+ /* @__PURE__ */Wn(Ie,{words:Et,icon:/* @__PURE__ */Wn(lr,{type:n.type,size:13}),name:c,preview:Ki(n),marks:qi(n),onSelect:p,nameSlot:zi(t,o,d,c),selected:r,hidden:Boolean(n.props._hidden),...f,fold:i?{open:!s,label:"group",onToggle:()=>Cr(d)}:void 0,actions:/* @__PURE__ */Gn(Un,{children:[Xi(t,o,c),Qi(n,t,o),Zi(t,o,n,c)]}),rowProps:u}),i&&!s&&/* @__PURE__ */Wn(Oe,{children:ms(n,l+1)}),a(t,o+1)]},String(n.props.id??`${t}-${o}`))}),null===c?d&&!i.some(e=>e.zone===d)?a(d,0):null:0!==i.length||!t.rung&&d!==c?null:a(c,0)]});return t.rung?hs(e,t.rung,r++,o,p):/* @__PURE__ */Wn($n,{children:p},t.slot??"")})})},gs=(e,n)=>{const t=er(yt?.data,e.type,String(e.props.id)),o=ol(e),r=o.filter(e=>e.rung).length;let i=0;/* @__PURE__ */
20
+ return Wn(Un,{children:o.map(o=>{const l=o.kids,s=o.rung?n+1:n,d=ll(e.type,t,o.slot),c=d?.spec??null;!c||!Array.isArray(e.props[c.slot])||e.props[c.slot];const a=d&&d.choices?{slot:d.slot,choices:d.choices}:null,p=String(e.props.id),u=c&&!c.fixed?`${p}:${c.slot}`:null,f=a?`${p}:${a.slot}`:null,h=(e,n)=>ps(e,n),m=null===o.slot?null:`${p}:${o.slot}`,g=Boolean(c&&!c.fixed&&(null===m||m===u)),y=/* @__PURE__ */Gn(Un,{children:[l.map(({child:n,zone:t,index:o})=>{const r=Ro===String(n.props.id),i=bi(n),l=String(n.props.id),{collapsible:d,folded:c}=sl(n,s,al(n.type)),a=nl(n.type),p=1===a.length?`${l}:${a[0]}`:null,u=p?{...bn(p),index:pi(p).length}:void 0,f=Dl.dragging,m=u&&f&&Tl(f,u)?u:void 0,g=()=>pl(t,o,l,e.type),{rowProps:y,...S}=Dl.row({item:{id:l,zone:t,index:o,type:n.type},place:{...bn(t),index:o},into:m,canDrag:!Zo(n.type)},{"data-node-id":l,onClick:Ji(g)});/* @__PURE__ */
21
+ return Gn($n,{children:[0===o&&h(t,0),
22
+ /* @__PURE__ */Wn(Ie,{words:Et,icon:/* @__PURE__ */Wn(lr,{type:n.type,size:13}),name:i,preview:Ki(n),marks:qi(n),onSelect:g,nameSlot:zi(t,o,l,i),selected:r,hidden:Boolean(n.props._hidden),...S,fold:d?{open:!c,label:"group",onToggle:()=>Cr(l)}:void 0,actions:Zo(n.type)?Qi(n,t,o)??void 0:/* @__PURE__ */Gn(Un,{children:[Xi(t,o,i),Qi(n,t,o),Zi(t,o,n,i)]}),rowProps:y}),d&&!c&&/* @__PURE__ */Wn(Oe,{children:gs(n,s+1)}),h(t,o+1)]},String(n.props.id??`${t}-${o}`))}),null===m?f&&!l.some(e=>e.zone===f)?h(f,0):null:0!==l.length||(o.rung?g:m!==f)?null:h(m,0)]});return o.rung?hs(e,o.rung,i++,r,y):/* @__PURE__ */Wn($n,{children:y},o.slot??"")})})},ys=Io||null!==ao,Ss=e=>"panel"in e?{id:e.id,label:e.label,icon:e.icon,active:Zt&&!ys&&qo===e.id,onSelect:()=>Jr(e.id)}:e,ks=[...(Xo.railLead??[]).map(Ss),{id:"sections",label:At.layers,icon:/* @__PURE__ */Wn(Re,{}),active:Zt&&!ys&&"sections"===qo,onSelect:()=>Jr("sections")},...(Xo.railTrail??[]).map(Ss)];co?ks.push({id:"media",label:At.railMedia,icon:/* @__PURE__ */Wn(Ve,{}),active:Zt&&!Io&&(null!==ao||"media"===qo),onSelect:()=>Jr("media")}):ht&&ks.push({id:"media",label:At.railMedia,icon:/* @__PURE__ */Wn(Ve,{}),onSelect:Yr});const vs=[...Xo.railLead??[],...Xo.railTrail??[]].find(e=>"panel"in e&&e.id===qo),ws=Boolean(Tt?.foldable)&&!Ko,bs=Tt?.label??(mt?At.pageSections:At.templateSections),xs=ws&&zr(_n),zs=/* @__PURE__ */Gn(Un,{children:[qr.map((e,n)=>{if($t(e)||Mt(e)||It(e.type))return null;const t=Ro===String(e.props.id),o=Boolean(e.props._hidden);tl(e);const r=String(e.props.id),i=Xo.hasOwnRows?.(e)??!1,l=cl(e)||i,s=l&&zr(r),d=nl(e.type),c=1===d.length?`${r}:${d[0]}`:null,a=c?{...bn(c),index:pi(c).length}:void 0,p=Dl.dragging,u=a&&p&&Tl(p,a)?a:void 0,{rowProps:f,...h}=Dl.row({item:{id:r,zone:ce,index:n,type:e.type},place:{...bn(ce),index:n},into:u},{"data-node-id":r,onClick:Ji(()=>Li(n))});/* @__PURE__ */
23
+ return Gn($n,{children:[n>0&&_i(n),
24
+ /* @__PURE__ */Wn(Ie,{words:Et,icon:/* @__PURE__ */Wn(lr,{type:e.type,size:13}),name:di(e),preview:Ki(e),marks:qi(e),onSelect:()=>Li(n),nameSlot:zi(ce,n,r,di(e)),selected:t,hidden:o,...h,fold:l?{open:!s,label:"section",onToggle:()=>Cr(r)}:void 0,actions:/* @__PURE__ */Gn(Un,{children:[Xi(ce,n,di(e)),Qi(e,ce,n),Zi(ce,n,e,di(e))]}),rowProps:f}),cl(e)&&!s&&/* @__PURE__ */Gn(Oe,{children:[gs(e,1),Xo.partRows?.(e,us)]}),i&&!s&&/* @__PURE__ */Wn(Oe,{children:Xo.ownRows?.(e,n,us)})]},String(e.props.id??n))}),!Ko&&Cl>0&&_i(Cl)]}),Cs=(e,n,t)=>{const o=String(e.props.id),r=rl(e).length>0||il(e)||Boolean(tr(e.type)),i=r&&zr(o),l="header"===t?At.header:At.footer,s=rr.rowName?rr.rowName(e,"section",l):l;/* @__PURE__ */
25
+ return Gn(Un,{children:[
26
+ /* @__PURE__ */Wn(Ie,{words:Et,icon:/* @__PURE__ */Wn(lr,{type:t,size:13}),name:s,preview:Ki(e),marks:qi(e),badge:bl,onSelect:()=>Li(n),nameSlot:zi(ce,n,o,s),selected:Ro===String(e.props.id),fold:r?{open:!i,label:"section",onToggle:()=>Cr(o)}:void 0,actions:Qi(e,ce,n)??void 0,rowProps:{"data-node-id":o,onClick:Ji(()=>Li(n))}}),r&&!i&&/* @__PURE__ */Wn(Oe,{children:ms(e,1)})]})};return(Xo.wrap??(e=>e))(
27
+ /* @__PURE__ */Wn(ie,{target:wo,children:/* @__PURE__ */Gn("div",{ref:vo,className:"sf-editor es-editor",style:qe(kr),onContextMenu:Pi.onEditorContextMenu,...g(un),children:[
28
+ /* @__PURE__ */Gn(Fe,{children:[
29
+ /* @__PURE__ */Wn(De,{items:ks,ariaLabel:At.bar.views}),
30
+ /* @__PURE__ */Gn(He,{children:[
31
+ /* @__PURE__ */Wn(We,{label:At.bar.undo,disabled:Boolean(at)||!kt.hasPast,onClick:()=>kt.back(),children:/* @__PURE__ */Wn(An,{})}),
32
+ /* @__PURE__ */Wn(We,{label:At.bar.redo,disabled:Boolean(at)||!kt.hasFuture,onClick:()=>kt.forward(),children:/* @__PURE__ */Wn(En,{})}),
33
+ /* @__PURE__ */Wn(Ge,{}),
34
+ /* @__PURE__ */Wn(Ue,{devices:eo,value:io,onChange:lo}),
35
+ /* @__PURE__ */Wn(We,{label:At.bar.refresh,tip:At.bar.refreshTip,onClick:()=>{ko.current=(()=>{const e=wo?.document;if(!e)return null;const n=qr.findIndex(Mt),t=n>=0?n:qr.length;let o=null;for(let n=0;n<t;n++){const t=qr[n]?.props?.id;if(null==t)continue;const r=e.querySelector(`[data-puck-component="${CSS.escape(String(t))}"]`);if(!r)continue;const i=r.getBoundingClientRect().top;i<=4&&(null===o||i>o.offset)&&(o={id:String(t),offset:i})}if(!o){const e=vt?.props?.id??qr[0]?.props?.id;null!=e&&(o={id:String(e),offset:0})}return o})(),So(e=>e+1)},children:/* @__PURE__ */Wn(Ln,{})})]}),
36
+ /* @__PURE__ */Gn(He,{kind:"right",style:{minWidth:300},children:[
37
+ /* @__PURE__ */Wn(B,{input:Co,words:At.saveStatus}),Xo.barLead?.(),Xo.barTrail?.(),Xo.mainAction||!Xo.barMain?/* @__PURE__ */Wn(I,{input:Co,action:Xo.mainAction??{label:At.done,onPress:()=>{tt(yt.data)}},readOnly:Boolean(at),saveSwitch:ut,onToggleAutoSave:lt,onSaveNow:Bo,bar:At.bar,words:At.saveStatus}):Xo.barMain()]})]}),
38
+ /* @__PURE__ */Wn(C,{}),
39
+ /* @__PURE__ */Gn("div",{className:"sf-body",children:[Zt?/* @__PURE__ */Gn(Un,{children:[
40
+ /* @__PURE__ */Wn("aside",{className:"es-sidepanel es-sidepanel--left sf-panel sf-panel--left","aria-label":At.leftPanel,children:Io?/* @__PURE__ */Wn(j,{at:$o?{label:(e=>{const n=Ml(e.zone);if(n)return At.add.addingTo({name:rr.rowName?Ui(n,!0):ii(n.type)});if(e.zone===ce){const n=qr[e.index];return n&&!Mt(n)?At.add.addingBefore({name:Ui(n,!0)}):At.add.addingAtEnd}const t=El(e.zone);return t?At.add.addingTo({name:t.parentName}):At.add.addingHere})($o),onClear:()=>Mo(null)}:void 0,placeBlocks:$o&&$o.zone!==ce?El($o.zone)?.choices:void 0,canTake:$o?e=>{if(!$o)return null;const n={...bn($o.zone),index:$o.index};if(Ll(e,n))return null;const t=Ml($o.zone);if(t)return At.add.notInside({name:Ui(t,!0)});if($o.zone===ce)return At.add.onlySections;const o=El($o.zone);return o?At.add.notInside({name:o.parentName}):At.add.onlySections}:void 0,onPick:$o?e=>{if(!$o)return;const n={...bn($o.zone),index:$o.index};Ll(e,n)&&(Rl(e,n),Gi())}:void 0,itemFor:e=>({id:`new:${e.kind}:${"template"===e.kind?e.template.id:e.type}`,zone:"",index:-1,type:"template"===e.kind?e.template.node.type:e.type,add:e}),session:Fl,siteWide:Xo.addPanelRow?.(Gi),onClose:Gi,onHide:Gr,readOnly:Boolean(at)}):ao&&so?
41
+ /* @__PURE__ */Wn(L,{panel:so,pick:ao,onHide:Gr}):vs?vs.panel({onHide:Gr,notify:Nr}):"media"===qo&&so?/* @__PURE__ */Wn(L,{panel:so,pick:null,onHide:Gr}):/* @__PURE__ */Gn(Un,{children:[
42
+ /* @__PURE__ */Wn(T,{icon:/* @__PURE__ */Wn(Re,{}),title:At.layers,context:Wt,actions:/* @__PURE__ */Gn(Un,{children:[!at&&/* @__PURE__ */Wn(Je,{label:At.add.title,onClick:()=>Hi(null),children:/* @__PURE__ */Wn(Rn,{size:15})}),
43
+ /* @__PURE__ */Wn(Je,{label:Il?At.expandAll:At.collapseAll,title:0===Bl.length?At.nothingToFold:void 0,disabled:0===Bl.length,onClick:()=>Sr(e=>{const n=new Set(Bl);return Il?new Set([...e].filter(e=>!n.has(e))):/* @__PURE__ */new Set([...e,...Bl])}),children:/* @__PURE__ */Wn(Kn,{expand:Il})})]}),onHide:Gr}),
44
+ /* @__PURE__ */Gn(Ne,{className:"sf-tree sf-scroll",words:Et,children:[
45
+ /* @__PURE__ */Wn(Ie,{words:Et,icon:/* @__PURE__ */Wn(lr,{type:"page",size:13}),name:At.pageSettings,onSelect:Xr,selected:!vt&&Lo,rowProps:{onClick:Ji(Xr)}}),xl&&/* @__PURE__ */Gn(Un,{children:[!wl&&/* @__PURE__ */Wn(Pe,{children:At.header}),fs(xl)]}),!Ko&&gt&&!(wl&&xl)&&/* @__PURE__ */Gn(Un,{children:[!wl&&/* @__PURE__ */Wn(Pe,{children:At.header}),!jt&&/* @__PURE__ */Wn(Ie,{words:Et,icon:/* @__PURE__ */Wn(lr,{type:"header",size:13}),name:At.header,badge:bl,onSelect:Kr,selected:Ao.kind===Pt?.kind,rowProps:{onClick:Ji(Kr)}})]}),!Ko&&Sl&&!(wl&&xl)&&Cs(Sl,yl,"header"),!Ko&&!ws&&/* @__PURE__ */Wn(Pe,{children:bs}),ws?/* @__PURE__ */Gn(Un,{children:[
46
+ /* @__PURE__ */Wn(Ie,{words:Et,icon:null,name:bs,fold:{open:!xs,label:bs,onToggle:()=>Cr(_n)}}),!xs&&/* @__PURE__ */Wn(Oe,{children:zs})]}):zs,gt&&!wl&&/* @__PURE__ */Wn(Pe,{children:At.footer}),gl&&!(wl&&zl)&&Cs(gl,ml,"footer"),!Ko&&!gl&&gt&&!wl&&/* @__PURE__ */Wn(Ie,{words:Et,icon:/* @__PURE__ */Wn(lr,{type:"footer",size:13}),name:At.footer,onSelect:Yi,rowProps:{onClick:Ji(Yi),title:At.editFooter}}),zl&&fs(zl),Xo.treeFoot?.()]})]})}),
47
+ /* @__PURE__ */Wn(Ye,{side:"left",width:kr.left,min:Ke,max:Xe,defaultWidth:k.left,label:At.resizeLeftPanel,onResize:br})]}):/* @__PURE__ */Wn(A,{side:"left",onShow:Gr}),
48
+ /* @__PURE__ */Gn("div",{ref:Pr,className:"sf-center sf-scroll","data-sf-canvas-head":Ar?"":void 0,style:{overflowX:Dr?"auto":"hidden",overflowY:"hidden"},children:[Ar&&/* @__PURE__ */Wn("div",{ref:Er,className:"sf-canvas-head",children:/* @__PURE__ */Wn(Ar,{device:io})}),
49
+ /* @__PURE__ */Gn("div",{className:"sf-frame-scaler",style:Hr,children:[
50
+ /* @__PURE__ */Wn("div",{className:"sf-frame "+(io===oo?"":`sf-frame--${io}`),style:Wr,children:/* @__PURE__ */Gn("div",{className:"sf-preview-host",children:[
51
+ /* @__PURE__ */Wn(Be.Provider,{value:vl,children:/* @__PURE__ */Wn(Gt,{},yo)}),
52
+ /* @__PURE__ */Wn(rn,{canvas:wo,session:Fl,model:ns,measure:os,canDrop:is,onDrop:ss,choose:Gl,onPick:cs,onZoneAdd:as,onSeamAdd:as,zoneAddLabel:At.canvasAddBlock,words:Lt.canvas,readOnly:Boolean(at),revision:yt.data}),jo.length>0&&/* @__PURE__ */Wn("div",{className:"sf-preview-gaps",children:jo.map(e=>
53
+ /* @__PURE__ */Wn(ln,{index:e.index,label:At.addSectionHere,onInsert:()=>Hi(e.index),className:void 0===e.height?"sf-preview-gap":"sf-preview-gap sf-preview-gap--tight",style:void 0===e.height?{top:e.top}:{top:e.top,height:e.height}},e.index))})]})}),kl?/* @__PURE__ */Wn(Xn,{canvas:wo,tabs:Xl,onSelect:e=>{const n=qr.findIndex(n=>String(n.props.id)===e);n>=0&&Li(n)}}):null]})]}),_t?/* @__PURE__ */Gn(Un,{children:[
54
+ /* @__PURE__ */Wn(y,{value:{selectChild:pl,addChild:ul,childRowName:bi,blockRowName:Ol},children:/* @__PURE__ */Wn(Ut,{mode:Ao,onOpenWebsiteSettings:Xo.openSettings??(()=>{}),onOpenSiteStyles:Xo.openStyles,onSelectNode:ar,onNotify:Nr,onHidePanel:Ur,nodeActions:vt?ae(bt,vt.type):et})}),
55
+ /* @__PURE__ */Wn(Ye,{side:"right",width:kr.right,min:Ke,max:Xe,defaultWidth:k.right,label:At.resizeSettingsPanel,onResize:xr})]}):
56
+ /* @__PURE__ */Wn(A,{side:"right",onShow:Ur})]}),Pi.menu]})}))}export{nt as ScreenChrome};
@@ -1 +1 @@
1
- import{useScreenDocument as n}from"./chunk-THZ46DC5.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-JTUUIVBZ.js";import{EditNotice as r}from"./chunk-IE55HNMA.js";import{useWords as e}from"./chunk-MFIRYGHW.js";import{jsx as i}from"react/jsx-runtime";function t(){const{capabilities:t,access:c,takeOverEditing:a,viewReadOnly:s,saveConflict:m,reloadFromServer:u}=n(),{noun:l}=e("screen",o);return t.hasEditGuard?/* @__PURE__ */i(r,{access:c,conflict:m,noun:l,onTakeOver:a,onViewReadOnly:s,onReload:u}):null}export{t as PageEditGuardNotices};
1
+ import{useScreenDocument as n}from"./chunk-GCCBEY2W.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-VWXUMVCD.js";import{EditNotice as r}from"./chunk-IE55HNMA.js";import{useWords as e}from"./chunk-MFIRYGHW.js";import{jsx as i}from"react/jsx-runtime";function t(){const{capabilities:t,access:c,takeOverEditing:a,viewReadOnly:s,saveConflict:m,reloadFromServer:u}=n(),{noun:l}=e("screen",o);return t.hasEditGuard?/* @__PURE__ */i(r,{access:c,conflict:m,noun:l,onTakeOver:a,onViewReadOnly:s,onReload:u}):null}export{t as PageEditGuardNotices};
@@ -1 +1 @@
1
- import{useEaselHost as n}from"./chunk-U3JP4VGF.js";import{useEaselApi as e,bindUndoKeys as t}from"./chunk-M32O2WRM.js";import{useState as r,useEffect as o,useRef as u}from"react";function c(e){const t=n(),[u,c]=r(null);return o(()=>c(e.current),[e]),t.ownsDocument?"undefined"==typeof document?null:document:u}function i(r,u){const i=n(),s=e(),f=c(r);o(()=>{if(!i.ownsDocument&&f)return t(f,s,{leaveTyping:!0})},[i,s,f]);const m=u?.document??null;o(()=>{if(!i.ownsDocument&&m)return t(m,s,{leaveTyping:!0})},[i,s,m])}function s(n){return n.ownsDocument?{}:{tabIndex:-1}}function f(n){return!n.altKey&&!n.shiftKey&&(!(!n.metaKey&&!n.ctrlKey)&&("s"===n.key||"S"===n.key||"KeyS"===n.code))}function m(n,e,t){const r=c(n),i=u(t);o(()=>{i.current=t}),o(()=>{if(!r)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return r.addEventListener("keydown",n),()=>r.removeEventListener("keydown",n)},[r]);const s=e?.document??null;o(()=>{if(!s)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return s.addEventListener("keydown",n),()=>s.removeEventListener("keydown",n)},[s])}export{s as editorRootFocus,f as isSaveShortcut,c as useEaselKeyTarget,m as useEaselSaveKey,i as useEaselUndoKeys};
1
+ import{useEaselHost as n}from"./chunk-U3JP4VGF.js";import{useEaselApi as e,bindUndoKeys as t}from"./chunk-PE6ZY5IW.js";import{useState as r,useEffect as o,useRef as u}from"react";function c(e){const t=n(),[u,c]=r(null);return o(()=>c(e.current),[e]),t.ownsDocument?"undefined"==typeof document?null:document:u}function i(r,u){const i=n(),s=e(),f=c(r);o(()=>{if(!i.ownsDocument&&f)return t(f,s,{leaveTyping:!0})},[i,s,f]);const m=u?.document??null;o(()=>{if(!i.ownsDocument&&m)return t(m,s,{leaveTyping:!0})},[i,s,m])}function s(n){return n.ownsDocument?{}:{tabIndex:-1}}function f(n){return!n.altKey&&!n.shiftKey&&(!(!n.metaKey&&!n.ctrlKey)&&("s"===n.key||"S"===n.key||"KeyS"===n.code))}function m(n,e,t){const r=c(n),i=u(t);o(()=>{i.current=t}),o(()=>{if(!r)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return r.addEventListener("keydown",n),()=>r.removeEventListener("keydown",n)},[r]);const s=e?.document??null;o(()=>{if(!s)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return s.addEventListener("keydown",n),()=>s.removeEventListener("keydown",n)},[s])}export{s as editorRootFocus,f as isSaveShortcut,c as useEaselKeyTarget,m as useEaselSaveKey,i as useEaselUndoKeys};
@@ -1,2 +1,2 @@
1
- import{noControlField as e}from"./chunk-7F52SZOI.js";import{usePreviewDevice as n}from"./chunk-BSPCSC45.js";import{DEFAULT_SCREEN_WORDS as r}from"./chunk-JTUUIVBZ.js";import{useWords as t}from"./chunk-MFIRYGHW.js";import{jsx as o}from"react/jsx-runtime";function i(e){return"mobile"===e?"mobile":"desktop"}var c={desktop:null,tablet:r.deviceNote.tablet,mobile:r.deviceNote.mobile},u="data-sf-device-hidden";function d(){/* @__PURE__ */
1
+ import{noControlField as e}from"./chunk-7F52SZOI.js";import{usePreviewDevice as n}from"./chunk-BSPCSC45.js";import{DEFAULT_SCREEN_WORDS as r}from"./chunk-VWXUMVCD.js";import{useWords as t}from"./chunk-MFIRYGHW.js";import{jsx as o}from"react/jsx-runtime";function i(e){return"mobile"===e?"mobile":"desktop"}var c={desktop:null,tablet:r.deviceNote.tablet,mobile:r.deviceNote.mobile},u="data-sf-device-hidden";function d(){/* @__PURE__ */
2
2
  return o("span",{hidden:!0,[u]:""})}function s({tier:e,render:r,...t}){return i(n())===e?/* @__PURE__ */o(r,{...t}):/* @__PURE__ */o(d,{})}var m="__device";function f(e){const n=e?.[m];return n??null}function l(e){return f(e)?.inner??e}function a(e,n){const r=n.render;return{...n,[m]:{tier:e,inner:n},render:n=>/* @__PURE__ */o(s,{tier:e,render:r,...n})}}function p(){const e=t("screen",r).deviceNote,i=n(),c="desktop"===i?null:e[i];return c?/* @__PURE__ */o("div",{className:"sf-device-scope",children:c}):/* @__PURE__ */o(d,{})}function v(){return e({type:"custom",render:()=>/* @__PURE__ */o(p,{})},"always")}export{m as DEVICE_FIELD_MARKER,u as DEVICE_HIDDEN_ATTR,c as DEVICE_NOTE,a as deviceField,f as deviceMetaOf,v as deviceNote,i as shownTier,l as withoutDeviceGate};
@@ -1 +1 @@
1
- import{DEFAULT_TEXT_STYLES_WORDS as o}from"./chunk-OGH6CC3E.js";import{DEFAULT_PICK_WORDS as r}from"./chunk-ZAOM6PFH.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as t}from"./chunk-6WY6ZXJG.js";import{DEFAULT_SCREEN_WORDS as m}from"./chunk-JTUUIVBZ.js";import{DEFAULT_CANVAS_WORDS as n}from"./chunk-TBY3DFKS.js";import{DEFAULT_TREE_WORDS as c}from"./chunk-K56YDHYQ.js";import{DEFAULT_PANEL_WORDS as s}from"./chunk-KFV7N2DJ.js";import{DEFAULT_NODE_MENU_WORDS as f}from"./chunk-WK3AFPXY.js";import{DEFAULT_SAVE_WORDS as p}from"./chunk-H6DDIBQ4.js";import{DEFAULT_CHROME_WORDS as e,DEFAULT_NOTICE_WORDS as i}from"./chunk-Z6PVRXVY.js";import{DEFAULT_LOCK_WORDS as u}from"./chunk-RE4LP46F.js";import{DEFAULT_RAIL_WORDS as k}from"./chunk-2OAZYSWJ.js";import{DEFAULT_COPY_WORDS as j}from"./chunk-Q6AM43CA.js";import{DEFAULT_FIELDS_WORDS as h}from"./chunk-FFYXVAAL.js";import{DEFAULT_DRAG_WORDS as l}from"./chunk-O2NLQBFX.js";var a={notice:i,lock:u,save:p,chrome:e,rail:k,tree:c,panel:s,fields:h,pick:r,drag:l,menu:f,styleClipboard:t,copy:j,canvas:n,textStyles:o,screen:m},F=o=>"object"==typeof o&&null!==o;function Y(o,r){const t={};for(const m of Object.keys(o)){const n=o[m],c=r[m];null==c?t[m]=n:F(n)?t[m]=F(c)?Y(n,c):n:t[m]=typeof c==typeof n?c:n}return t}function y(o,r){return r?Y(o,r):o}export{a as DEFAULT_EASEL_STRINGS,y as mergeEaselStrings};
1
+ import{DEFAULT_TEXT_STYLES_WORDS as o}from"./chunk-OGH6CC3E.js";import{DEFAULT_PICK_WORDS as r}from"./chunk-ZAOM6PFH.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as t}from"./chunk-6WY6ZXJG.js";import{DEFAULT_SCREEN_WORDS as m}from"./chunk-VWXUMVCD.js";import{DEFAULT_CANVAS_WORDS as n}from"./chunk-TBY3DFKS.js";import{DEFAULT_TREE_WORDS as c}from"./chunk-K56YDHYQ.js";import{DEFAULT_PANEL_WORDS as s}from"./chunk-KFV7N2DJ.js";import{DEFAULT_NODE_MENU_WORDS as f}from"./chunk-WK3AFPXY.js";import{DEFAULT_SAVE_WORDS as p}from"./chunk-H6DDIBQ4.js";import{DEFAULT_CHROME_WORDS as e,DEFAULT_NOTICE_WORDS as i}from"./chunk-Z6PVRXVY.js";import{DEFAULT_LOCK_WORDS as u}from"./chunk-RE4LP46F.js";import{DEFAULT_RAIL_WORDS as k}from"./chunk-2OAZYSWJ.js";import{DEFAULT_COPY_WORDS as j}from"./chunk-Q6AM43CA.js";import{DEFAULT_FIELDS_WORDS as h}from"./chunk-FFYXVAAL.js";import{DEFAULT_DRAG_WORDS as l}from"./chunk-GG4FGBFR.js";var F={notice:i,lock:u,save:p,chrome:e,rail:k,tree:c,panel:s,fields:h,pick:r,drag:l,menu:f,styleClipboard:t,copy:j,canvas:n,textStyles:o,screen:m},a=o=>"object"==typeof o&&null!==o;function Y(o,r){const t={};for(const m of Object.keys(o)){const n=o[m],c=r[m];null==c?t[m]=n:a(n)?t[m]=a(c)?Y(n,c):n:t[m]=typeof c==typeof n?c:n}return t}function y(o,r){return r?Y(o,r):o}export{F as DEFAULT_EASEL_STRINGS,y as mergeEaselStrings};
@@ -0,0 +1,2 @@
1
+ import{editLockOf as e}from"./chunk-GMCZXMOV.js";import{isExpiredSession as r,readEaselFailure as n}from"./chunk-CLOS6SSX.js";import{routeSharedHostMessage as t}from"./chunk-S4AWJX4Q.js";import{describeLoadFailure as o,hostLoadRefusal as u}from"./chunk-ERR437B5.js";import{useAdminBridge as a}from"./chunk-VPFNZ7TB.js";import{NO_DOCUMENT_ADDRESSING as s}from"./chunk-RLBXE4EU.js";import{saveStatusOf as i,resetForDocumentSwitch as l}from"./chunk-HNKB2ZYR.js";import{STATUS_UNREACHABLE as c}from"./chunk-KCOBHPN6.js";import{useEaselSession as d}from"./chunk-O7Q4DDJT.js";import{backendOf as f,setSessionDocumentSite as m}from"./chunk-RSCMJIWS.js";import{useEaselHost as k}from"./chunk-U3JP4VGF.js";import{DEFAULT_SCREEN_WORDS as g}from"./chunk-VWXUMVCD.js";import{useAutosave as v}from"./chunk-NDRZP6YR.js";import{canWriteDocument as p,newEaselClientId as h,reloadIfVersionMoved as y,openUnansweredClaim as w,FAIL_OPEN_RETRY_MS as S,CLAIM_FAIL_OPEN_MS as b,holderOf as P}from"./chunk-THWO5YVZ.js";import{useWords as I}from"./chunk-MFIRYGHW.js";import{createContext as j,useContext as R,useState as B,useMemo as C,useCallback as O,useEffect as H,useRef as E}from"react";import{jsx as T}from"react/jsx-runtime";var D={content:[],root:{},zones:{}};var M=j(null);function V(){const e=R(M);if(!e)throw new Error("useStorefrontDocument must be used within StorefrontDocumentProvider");return e}function A({target:j,addressing:R=s,onHostMessage:V,children:A}){const N=R,{homeSlug:F,entryMayBounce:L,entryBounce:W,onSwitch:U,tellsHost:X,adapterFor:Y,migrateRenamedProps:Z,describeMissing:J,onLoadFailed:x}=N,[G,K]=B(j),Q=k(),z=d(),_=C(()=>f(z),[z]),q=C(()=>e(z),[z]),$="template"===G.kind,ee="template"===G.kind?G.id:null,re="template"===G.kind?G.pageSlug??F??"":"document"===G.kind?G.slug??"":G.slug,ne="page"===G.kind?G.siteId??null:null,te=z.blocks,oe=C(()=>Y(G,_,te),[Y,_,te,G.kind,"template"===G.kind?G.id:"document"===G.kind?G.record:G.siteId]),ue=oe.capabilities,ae=O(e=>z.documentHooks?.stored?.(e)??e,[z]),se="page"===G.kind?G.originSlug??null:null;H(()=>{m(z,ne)},[z,ne]);const ie=E(G);H(()=>{ie.current=G},[G]);const{token:le,tokenRef:ce,capabilities:de}=a({onMessage:e=>{if(V?.(e)||t(e))return;const r=e;if("storefront-editor:navigate"===r?.type){const r=e;r?.target&&Cr(r.target)}}}),fe=!z.usesBridgedToken||null!==le,me=oe.lock,ke=Boolean(_.lock),[ge,ve]=B(null),[pe,he]=B(null),[ye,we]=B(null),[Se,be]=B(null),Pe=I("screen",g),Ie=Se?function(e,r){if(null!==e.sentence)return e.sentence;if(!e.missing)return r.loadFailed({cause:e.cause});switch(e.target.kind){case"template":return r.missingTemplatePage;case"document":return r.missingDocument;default:return r.missingPage({slug:e.slug})}}(Se,Pe):null,[je,Re]=B(null),Be=E(null),Ce=E(null),[Oe,He]=B(!1),Ee=E(null),[Te,De]=B(null),Me=E(null),[Ve,Ae]=B(null),[Ne,Fe]=B(!1),Le=E(null);H(()=>{Le.current=Ve},[Ve]);const[We,Ue]=B(ue.hasEditLock?{kind:"checking"}:{kind:"editing"}),Xe=E(We);H(()=>{Xe.current=We},[We]);const Ye=E(()=>Promise.resolve(!1)),Ze=O(e=>{Ce.current=e,He(!0)},[]),Je=v({save:async({id:e,data:r})=>{if(p(Xe.current)){if(!await Ye.current(e,r)){if(!p(Xe.current))return void Ze({id:e,data:r});throw new Error("page save did not land")}}else Ze({id:e,data:r})},onFailure:(e,r)=>{0===r&&Q.send("storefront-editor:save-failed")}}),{state:xe,push:Ge,flush:Ke,pause:Qe,resume:ze,stop:_e,reset:qe,retryNow:$e,hasPending:er}=Je,rr=E(xe);H(()=>{rr.current=xe},[xe]);const nr=i(xe),tr=O(()=>{const e=Ce.current;e&&(Ce.current=null,He(!1),Ge(e))},[Ge]),or=E("");or.current||(or.current=h());const[ur,ar]=B(0),sr=E(!1),[ir,lr]=B(L(j)),cr=E(!1);H(()=>{if(cr.current)return;cr.current=!0;const e=Q.address.search(),r=W(j,e);r?Q.address.load(r):L(j)&&lr(!1)},[j,Q]);const dr=Q.send;H(()=>{if(!fe)return;let e=!1;const r=ie.current,n=oe.resolve(re),t=z.documentHooks?.opening?.({slug:re,isTemplate:$,capabilities:ue});return n.then(async n=>{if(e)return;if(!n)return"page"===r.kind&&null!==F&&re!==F?void Q.address.load({kind:"page",slug:F,siteId:ne??void 0}):(be({target:r,slug:re,missing:!0,sentence:J?.(r)??null}),void x?.(r,null));const o=n.readOnlyReason?n.readOnlyReason:null;Be.current=o,Re(o),ve(n.id),he(n.kind??null),Me.current=n.version??null;const u=n.layout,a=u&&Object.keys(u).length?u:D,s=Z(a),i=t?await t(s):s;e||we(i)}).catch(n=>{e||(console.error("[storefront-editor] document load failed",n),be({target:r,slug:re,missing:!1,sentence:u(n,{slug:re},z),cause:o(n,z)}),x?.(r,n))}),()=>{e=!0}},[fe,le,$,oe,re]);const fr=O(e=>new Promise(r=>{const n=Date.now(),t=setInterval(()=>{const o=ce.current;o&&o!==e?(clearInterval(t),r(o)):Date.now()-n>6e3&&(clearInterval(t),r(null))},200)}),[]),mr=O(async e=>{const n=ce.current;if(!n&&z.usesBridgedToken)return{ok:!1,error:new Error("no editor token")};try{return{ok:!0,value:await e(n??"")}}catch(t){if(r(t,z)){dr("storefront-editor:auth-expired");const r=n?await fr(n):null;if(r)try{return{ok:!0,value:await e(r)}}catch(e){return{ok:!1,error:e}}}return{ok:!1,error:t}}},[dr,fr,z]),kr=O(async e=>{const r=ce.current?await mr(e):{ok:!1};return r.ok||dr("storefront-editor:save-failed"),r.ok},[dr,mr]),gr=O(async(e,r,t=!1)=>{if(null!==Be.current)return!1;if(!p(Xe.current))return!1;if(Le.current)return!1;const o=await mr(()=>oe.saveLayout(e,r,Me.current,or.current));if(o.ok)return Me.current=o.value.version??Me.current,Fe(!1),!0;const u=q.readLockTaken(o.error);if(u){const e={kind:"takenover",holder:u};return Xe.current=e,Ue(e),!1}const a=q.readSaveConflict(o.error);if(a){if(a.savedByYou&&!t&&oe.rereadVersion){const n=await mr(()=>oe.rereadVersion(e));if(n.ok&&n.value)return Me.current=n.value,Ye.current(e,r,!0)}_e(),Le.current=a,Ae(a)}return Fe(n(o.error,z)?.status===c),!1},[oe,mr,_e,z]);H(()=>{Ye.current=gr},[gr]);const vr=O(e=>{if(null!==Be.current)return;if(dr("storefront-editor:dirty"),!ge)return;const r=ae(e);Ee.current=r,p(Xe.current)?Ge({id:ge,data:r}):Ze({id:ge,data:r})},[ge,dr,Ze,Ge,ae]),pr=O(async()=>{p(Xe.current)&&tr();return await Ke()&&null==Ce.current},[tr,Ke]),hr=E(pr);H(()=>{hr.current=pr},[pr]);const yr=E(mr);H(()=>{yr.current=mr},[mr]);const wr=O(()=>{Q.address.reload()},[Q]),Sr=E(()=>Promise.resolve(!1));H(()=>{Sr.current=()=>{const e=oe.rereadVersion;return ge&&e?y({ours:Me.current,stored:async()=>{const r=await yr.current(()=>e(ge));return r.ok?r.value:null},hasPending:()=>null!=Ce.current||er(),reload:wr}):Promise.resolve(!1)}},[oe,ge,er,wr]);const br=null!==je;H(()=>{if(!me||!ge||!fe||br)return;let e=!1,r=null,n=null;const t=or.current,o={claim:async e=>{const r=await yr.current(()=>me.claim(ge,t,e));if(r.ok)return{heartbeat_seconds:r.value.heartbeatSeconds};throw r.error},cancelled:()=>e,currentAccess:()=>Xe.current,heldWrite:()=>({pending:null!=Ce.current||er(),autoSaveEnabled:!rr.current.paused,saveConflict:null!=Le.current}),setAccess:e=>{Xe.current=e,Ue(e)},releaseHeldWrite:()=>{hr.current()},startHeartbeat:e=>{r&&clearInterval(r),r=setInterval(()=>{u(!1)},e)},stopHeartbeat:()=>{r&&(clearInterval(r),r=null)},reloadIfMoved:()=>{Sr.current()}},u=q.makeClaimBeat(o),a=sr.current;return sr.current=!1,a||(Ue({kind:"checking"}),n=setTimeout(()=>{n=null,w(o)&&o.startHeartbeat(S)},b)),u(a).finally(()=>{n&&clearTimeout(n),n=null}),()=>{e=!0,n&&clearTimeout(n),r&&clearInterval(r),me.release(ge,t).catch(()=>{})}},[ge,me,fe,le,ur,br]);const Pr=O(()=>{me&&ge&&(sr.current=!0,ar(e=>e+1))},[ge,me]),Ir=O(()=>{Ue(e=>{const r="blocked"===e.kind||"takenover"===e.kind?e.holder:null;return r?{kind:"readonly",holder:r}:e})},[]),jr=O(()=>{rr.current.paused?(p(Xe.current)&&tr(),ze()):Qe()},[tr,Qe,ze]),Rr=O(()=>{$e()},[$e]),Br=O(e=>{Ee.current=null,l("template"!==e.kind&&ke,{resetAutosave:()=>{qe(),Ce.current=null,He(!1)},setVersion:e=>{Me.current=e},setSaveConflict:Ae,setAccess:Ue}),U(e),K(e),Be.current=null,Re(null),ve(null),he(null),we(null),be(null),Q.address.show(e),"document"!==e.kind&&X(e)&&Q.send("storefront-editor:navigated",{target:e})},[qe,Q,ke,U,X]),Cr=O(e=>{if(function(e,r,n){if(e.kind!==r.kind)return!1;if("template"===e.kind){const t=r;return e.id===t.id&&(e.pageSlug??n)===(t.pageSlug??n)}if("document"===e.kind){const n=r;return e.record===n.record&&(e.slug??"")===(n.slug??"")}const t=r;return e.slug===t.slug&&e.siteId===t.siteId}(e,ie.current,F))return;const r=null!=Ce.current;if(!r&&!er())return void Br(e);const n=rr.current;r||n.paused||n.failed||n.stopped?De(e):Ke().then(r=>{r?Br(e):De(e)})},[Br,er,Ke,F]),Or=O(()=>De(null),[]),Hr=O(()=>{De(e=>(e&&Br(e),null))},[Br]),Er=O(async()=>{const e=Te;if(!e)return;await pr()&&(De(null),Br(e))},[Te,pr,Br]),Tr=O(async e=>{if(null!==Be.current)return;if(!ge)return;if(!p(Xe.current)||Le.current)return;const r=ae(e);if(!await gr(ge,r))return void(Le.current||dr("storefront-editor:save-failed"));const n=oe.publish;if(!ue.canPublish||!n)return void dr("storefront-editor:saved");const t=await mr(()=>n(ge,Me.current??void 0));t.ok?(Me.current=t.value.version??Me.current,dr("storefront-editor:published")):dr("storefront-editor:save-failed")},[ge,oe,ue.canPublish,dr,gr,mr,ae]);/* @__PURE__ */
2
+ return T(M.Provider,{value:{target:G,adapter:oe,capabilities:ue,templateId:ee,currentSlug:re,currentKind:pe,siteId:ne,ready:fe,token:le,tokenRef:ce,notifyParent:dr,bridgeCapabilities:de,runAuthed:kr,docId:ge,data:ye,getLiveData:()=>Ee.current??ye,footerOriginSlug:se,error:Ie,redirecting:ir,saveStatus:nr,saveState:xe,autoSaveEnabled:!xe.paused,autoSaveStoppedByConflict:xe.stopped,hasUnsavedEdits:xe.pending||Oe,toggleAutoSave:jr,retrySave:Rr,onChange:vr,flushSave:pr,onPublish:Tr,access:We,readOnly:null!==P(We)||null!==je||null!==Ve,readOnlyReason:je,takeOverEditing:Pr,viewReadOnly:Ir,saveConflict:Ve,saveUnreachable:Ne,reloadFromServer:wr,navigate:Cr,pendingNav:Te,cancelPendingNav:Or,discardAndNavigate:Hr,saveAndNavigate:Er},children:A})}export{M as ScreenDocumentContext,A as ScreenDocumentProvider,V as useScreenDocument};
@@ -0,0 +1 @@
1
+ var e={add:{stop:"Stop adding here",hint:"Drag onto the page.",search:"Search blocks",searchPlaceholder:({label:e})=>`${e}…`,clearSearch:"Clear search",nothing:({query:e})=>`Nothing matches “${e}”`,tryAnother:"Try another word.",tile:({label:e})=>`Add ${e}`},canvas:{addSection:"Add section",addBlock:"Add block",addButton:({label:e})=>`+ ${e}`,handle:({label:e})=>`Drag to move this ${e.toLowerCase()}`}};export{e as DEFAULT_DRAG_WORDS};
@@ -1 +1 @@
1
- import{useScreenBlockRules as e}from"./chunk-7O6MDCDU.js";import{newNodeId as t,ROOT_ZONE as n}from"./chunk-PLVEGYK6.js";import{useEasel as o,useEaselApi as r}from"./chunk-M32O2WRM.js";import{useMemo as s}from"react";function i(i={}){const{dispatch:p}=o(e=>e),d=r(),c=!0===i.readOnly,a=e().resolveOnInsert,l=!0===(i.resolveOnInsert??a),m=!0===i.foldIntoHistory;return s(()=>{const e=m?e=>p({...e,recordHistory:!1}):p,o=(n,o,r)=>{const s=t(o);return c||e({type:"insert",componentType:o,destinationZone:n,destinationIndex:r,id:s}),s},r=e=>(l&&!c&&d.resolveNode(e,{trigger:"insert"}),e),s=(t,n,o)=>{c||e({type:"replace",destinationZone:t,destinationIndex:n,data:o})},i=(e,t,n)=>r(o(e,t,n));return{insertComponent:i,insertSection:(e,t)=>i(n,e,t),replaceComponent:s,seedChild:(e,t,n,i)=>{const p=o(e,n,t);s(e,t,{type:n,props:{id:p,...i}}),r(p)},insertNode:(e,t,n)=>{const i=o(e,n.type,t);return s(e,t,{type:n.type,props:{...n.props,id:i}}),r(i)},removeComponent:(t,n)=>{c||e({type:"remove",index:n,zone:t})},reorderComponent:(t,n,o)=>{c||e({type:"reorder",sourceIndex:n,destinationIndex:o,destinationZone:t})},duplicateComponent:(t,n)=>{c||e({type:"duplicate",sourceIndex:n,sourceZone:t})},select:e=>p({type:"setUi",ui:{itemSelector:e}}),setDocument:t=>{c||e({type:"setData",data:t})},commitDocument:(t,n)=>{c||(m?d.batch(()=>{e({type:"setData",data:t}),void 0!==n&&("slot"===n?.kind?d.selectSlot({parentId:n.parentId,slot:n.slot}):d.select(n?n.id:null))}):d.run({data:t,select:n}))}}},[p,c,l,d,m])}export{i as useSectionOps};
1
+ import{useScreenBlockRules as e}from"./chunk-77DQCEEF.js";import{newNodeId as t,ROOT_ZONE as n}from"./chunk-PLVEGYK6.js";import{useEasel as o,useEaselApi as r}from"./chunk-PE6ZY5IW.js";import{useMemo as s}from"react";function i(i={}){const{dispatch:p}=o(e=>e),d=r(),c=!0===i.readOnly,a=e().resolveOnInsert,l=!0===(i.resolveOnInsert??a),m=!0===i.foldIntoHistory;return s(()=>{const e=m?e=>p({...e,recordHistory:!1}):p,o=(n,o,r)=>{const s=t(o);return c||e({type:"insert",componentType:o,destinationZone:n,destinationIndex:r,id:s}),s},r=e=>(l&&!c&&d.resolveNode(e,{trigger:"insert"}),e),s=(t,n,o)=>{c||e({type:"replace",destinationZone:t,destinationIndex:n,data:o})},i=(e,t,n)=>r(o(e,t,n));return{insertComponent:i,insertSection:(e,t)=>i(n,e,t),replaceComponent:s,seedChild:(e,t,n,i)=>{const p=o(e,n,t);s(e,t,{type:n,props:{id:p,...i}}),r(p)},insertNode:(e,t,n)=>{const i=o(e,n.type,t);return s(e,t,{type:n.type,props:{...n.props,id:i}}),r(i)},removeComponent:(t,n)=>{c||e({type:"remove",index:n,zone:t})},reorderComponent:(t,n,o)=>{c||e({type:"reorder",sourceIndex:n,destinationIndex:o,destinationZone:t})},duplicateComponent:(t,n)=>{c||e({type:"duplicate",sourceIndex:n,sourceZone:t})},select:e=>p({type:"setUi",ui:{itemSelector:e}}),setDocument:t=>{c||e({type:"setData",data:t})},commitDocument:(t,n)=>{c||(m?d.batch(()=>{e({type:"setData",data:t}),void 0!==n&&("slot"===n?.kind?d.selectSlot({parentId:n.parentId,slot:n.slot}):d.select(n?n.id:null))}):d.run({data:t,select:n}))}}},[p,c,l,d,m])}export{i as useSectionOps};
@@ -1 +1 @@
1
- import{panelFieldsOf as t}from"./chunk-ZE7I3PLX.js";import{withoutDeviceGate as o,deviceMetaOf as n}from"./chunk-OGCROOTI.js";import{DESIGN_GROUP_KEY as e,BUCKET_KEY as r}from"./chunk-MQNBD6AB.js";import{ANCHOR_FIELD_KEYS as s,foldMetaOf as c,MEDIA_FIELD_MARKER as i,TEXT_FIELD_MARKER as p,LINK_FIELD_MARKER as u}from"./chunk-DUVRZ456.js";import{STYLE_KIND as a,fieldKind as f,copyStyle as l,heldStyle as m,planPaste as h,pasteMessage as y}from"./chunk-V7U33NF2.js";var j=/* @__PURE__ */new Set([e.Size,e.Design,e.Layout,e.Position]),w=new Set(Object.values(e)),b=new Set(Object.values(r)),S=new Set(s),g=/* @__PURE__ */new Set(["focal","imageFocal"]),k=[i,p,u];function O(t){return`site:${t??""}`}function v(t){if(!t||"object"!=typeof t)return null;const n=t,e=o(t)??t,r=n[a]??e[a];if("string"==typeof r)return r;const s=n.options??e.options;if(Array.isArray(s)){return`choice:${s.map(t=>String(t?.value)).sort().join("|")}`}return f(e)}function D(t){const n=t,e=o(t);return k.some(t=>t in n||e&&t in e)}function d(o,e){const s=t(o,e)??{},i=[];let p=!0,u=!1;for(const[t,o]of Object.entries(s))b.has(t)?(p=t===r.Design,u=!1):w.has(t)?p&&(u=j.has(t)):u&&o&&"object"==typeof o&&!t.startsWith("_")&&(c(o)||S.has(t)||g.has(t)||D(o)||"slot"!==o.type&&i.push({path:[t],kind:v(o),counted:"mobile"!==n(o)?.tier}));return i}function A(t,o,n,e,r){l({scope:n,type:e.type,label:r,rows:t(o,e),props:e.props})}function I(t,o,n,e,r,s){const c=m(n);if(!c)return null;const i=h(c,{type:e.type,rows:t(o,e),props:e.props});return{...i,message:y(i,c.sourceLabel,r,s)}}function L(t,o,n,e){A(d,t,o,n,e)}function B(t,o,n,e,r){return I(d,t,o,n,e,r)}var F={scope:t=>O(t.siteId),rows:(t,o)=>d(t,o),copy:(t,o,n,e)=>L(e,t,o,n),plan:(t,o,n,e)=>B(e,t,o,n)};function N(t,o){if(!t&&!o)return F;const n=t?.rows,e=n?(t,o)=>n(t,o):d;return{scope:t?.scope??F.scope,rows:(t,o)=>e(t,o),copy:t?.copy??((t,o,n,r)=>A(e,r,t,o,n)),plan:t?.plan??((t,n,r,s)=>I(e,s,t,n,r,o))}}export{L as copyNodeStyle,d as nodeStyleRows,B as planNodePaste,v as shopFieldKind,O as siteStyleScope,N as styleClipboardOf};
1
+ import{panelFieldsOf as t}from"./chunk-ZE7I3PLX.js";import{withoutDeviceGate as o,deviceMetaOf as n}from"./chunk-DGAXQTDW.js";import{DESIGN_GROUP_KEY as e,BUCKET_KEY as r}from"./chunk-MQNBD6AB.js";import{ANCHOR_FIELD_KEYS as s,foldMetaOf as c,MEDIA_FIELD_MARKER as i,TEXT_FIELD_MARKER as p,LINK_FIELD_MARKER as u}from"./chunk-DUVRZ456.js";import{STYLE_KIND as a,fieldKind as f,copyStyle as l,heldStyle as m,planPaste as h,pasteMessage as y}from"./chunk-V7U33NF2.js";var j=/* @__PURE__ */new Set([e.Size,e.Design,e.Layout,e.Position]),w=new Set(Object.values(e)),b=new Set(Object.values(r)),S=new Set(s),g=/* @__PURE__ */new Set(["focal","imageFocal"]),k=[i,p,u];function D(t){return`site:${t??""}`}function v(t){if(!t||"object"!=typeof t)return null;const n=t,e=o(t)??t,r=n[a]??e[a];if("string"==typeof r)return r;const s=n.options??e.options;if(Array.isArray(s)){return`choice:${s.map(t=>String(t?.value)).sort().join("|")}`}return f(e)}function A(t){const n=t,e=o(t);return k.some(t=>t in n||e&&t in e)}function d(o,e){const s=t(o,e)??{},i=[];let p=!0,u=!1;for(const[t,o]of Object.entries(s))b.has(t)?(p=t===r.Design,u=!1):w.has(t)?p&&(u=j.has(t)):u&&o&&"object"==typeof o&&!t.startsWith("_")&&(c(o)||S.has(t)||g.has(t)||A(o)||"slot"!==o.type&&i.push({path:[t],kind:v(o),counted:"mobile"!==n(o)?.tier}));return i}function L(t,o,n,e,r){l({scope:n,type:e.type,label:r,rows:t(o,e),props:e.props})}function O(t,o,n,e,r,s){const c=m(n);if(!c)return null;const i=h(c,{type:e.type,rows:t(o,e),props:e.props});return{...i,message:y(i,c.sourceLabel,r,s)}}function B(t,o,n,e){L(d,t,o,n,e)}function F(t,o,n,e,r){return O(d,t,o,n,e,r)}var I={scope:t=>D(t.siteId),rows:(t,o)=>d(t,o),copy:(t,o,n,e)=>B(e,t,o,n),plan:(t,o,n,e)=>F(e,t,o,n)};function N(t,o){if(!t&&!o)return I;const n=t?.rows,e=n?(t,o)=>n(t,o):d;return{scope:t?.scope??I.scope,rows:(t,o)=>e(t,o),copy:t?.copy??((t,o,n,r)=>L(e,r,t,o,n)),plan:t?.plan??((t,n,r,s)=>O(e,s,t,n,r,o))}}export{B as copyNodeStyle,d as nodeStyleRows,F as planNodePaste,v as shopFieldKind,D as siteStyleScope,N as styleClipboardOf};
@@ -1,7 +1,7 @@
1
- import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenStoreProvider as n}from"./chunk-IZ2QRXSE.js";import{ScreenChrome as e}from"./chunk-FJ3ZJJ5Z.js";import{ScreenDocumentProvider as i,useScreenDocument as a}from"./chunk-THZ46DC5.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-JTUUIVBZ.js";import{documentPermissions as s}from"./chunk-THWO5YVZ.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{useMemo as t,useState as d,useRef as l,useEffect as m,useCallback as g}from"react";import{Dialog as h,Button as f}from"efficient-shell/ui";import{jsx as u,jsxs as p,Fragment as v}from"react/jsx-runtime";var k=r(n),C=r(e);function j({onCancel:r,onDiscard:n,onSave:e}){const i=c("screen",o).leave,[a,s]=d(!1),t=l(!0);m(()=>(t.current=!0,()=>{t.current=!1}),[]);const k=g(async()=>{s(!0);try{await e()}finally{t.current&&s(!1)}},[e]);/* @__PURE__ */
1
+ import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenStoreProvider as n}from"./chunk-JTOZJXD7.js";import{ScreenChrome as e}from"./chunk-7LP3OD2E.js";import{ScreenDocumentProvider as i,useScreenDocument as a}from"./chunk-GCCBEY2W.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-VWXUMVCD.js";import{documentPermissions as s}from"./chunk-THWO5YVZ.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{useMemo as t,useState as d,useRef as l,useEffect as m,useCallback as g}from"react";import{Dialog as h,Button as f}from"efficient-shell/ui";import{jsx as u,jsxs as p,Fragment as v}from"react/jsx-runtime";var C=r(n),k=r(e);function j({onCancel:r,onDiscard:n,onSave:e}){const i=c("screen",o).leave,[a,s]=d(!1),t=l(!0);m(()=>(t.current=!0,()=>{t.current=!1}),[]);const C=g(async()=>{s(!0);try{await e()}finally{t.current&&s(!1)}},[e]);/* @__PURE__ */
2
2
  return u(h,{open:!0,role:"alertdialog",size:"sm",title:i.title,onClose:r,footer:/* @__PURE__ */p(v,{children:[
3
3
  /* @__PURE__ */u(f,{variant:"secondary",onClick:r,children:i.cancel}),
4
4
  /* @__PURE__ */u(f,{variant:"ghost-danger",onClick:n,children:i.discard}),
5
- /* @__PURE__ */u(f,{variant:"primary",loading:a,onClick:()=>{k()},children:i.save})]}),children:i.body})}function y({target:r,addressing:n,onHostMessage:e,children:a}){/* @__PURE__ */
6
- return u(i,{target:r,addressing:n,onHostMessage:e,children:a})}var N=(r,n)=>/* @__PURE__ */p(v,{children:[r,n]});function Z({config:r,parts:n,wrap:e=N}){const{data:i,error:d,redirecting:l,ready:m,readOnly:g,onChange:h,pendingNav:f,cancelPendingNav:p,discardAndNavigate:v,saveAndNavigate:y}=a(),Z=t(()=>s(!g),[g]),H=c("screen",o);return l?/* @__PURE__ */u("div",{className:"sf-msg",children:H.loading}):d?/* @__PURE__ */u("div",{className:"sf-msg sf-msg--error",children:d}):m?i?e(
7
- /* @__PURE__ */u(k,{config:r,data:i,onChange:h,permissions:Z,parts:n,children:/* @__PURE__ */u(C,{})}),f&&/* @__PURE__ */u(j,{onCancel:p,onDiscard:v,onSave:y})):/* @__PURE__ */u("div",{className:"sf-msg",children:H.loading}):/* @__PURE__ */u("div",{className:"sf-msg",children:H.waitingForAuthorization})}export{Z as DocumentScreen,y as ScreenMount};
5
+ /* @__PURE__ */u(f,{variant:"primary",loading:a,onClick:()=>{C()},children:i.save})]}),children:i.body})}function y({target:r,addressing:n,onHostMessage:e,children:a}){/* @__PURE__ */
6
+ return u(i,{target:r,addressing:n,onHostMessage:e,children:a})}var N=(r,n)=>/* @__PURE__ */p(v,{children:[r,n]});function D({config:r,parts:n,wrap:e=N}){const{data:i,error:d,redirecting:l,ready:m,readOnly:g,onChange:h,pendingNav:f,cancelPendingNav:p,discardAndNavigate:v,saveAndNavigate:y}=a(),D=t(()=>s(!g),[g]),O=c("screen",o);return l?/* @__PURE__ */u("div",{className:"sf-msg",children:O.loading}):d?/* @__PURE__ */u("div",{className:"sf-msg sf-msg--error",children:d}):m?i?e(
7
+ /* @__PURE__ */u(C,{config:r,data:i,onChange:h,permissions:D,parts:n,children:/* @__PURE__ */u(k,{})}),f&&/* @__PURE__ */u(j,{onCancel:p,onDiscard:v,onSave:y})):/* @__PURE__ */u("div",{className:"sf-msg",children:O.loading}):/* @__PURE__ */u("div",{className:"sf-msg",children:O.waitingForAuthorization})}export{D as DocumentScreen,y as ScreenMount};
@@ -1,2 +1,2 @@
1
- import{ScreenPartsProvider as t}from"./chunk-7O6MDCDU.js";import{useEaselHost as r}from"./chunk-U3JP4VGF.js";import{createEasel as e,EaselProvider as n}from"./chunk-M32O2WRM.js";import{useState as o,useEffect as s}from"react";import{jsx as i}from"react/jsx-runtime";function a({config:a,data:c,onChange:m,permissions:p,parts:f,children:u}){const[h]=o(()=>e({config:a,data:c,permissions:p}));s(()=>{h.setConfig(a)},[h,a]),s(()=>{if(!m)return;let t=h.getState().appState.data;return h.subscribe(()=>{const r=h.getState().appState.data;r!==t&&(t=r,m(r))})},[h,m]),s(()=>{p&&h.setPermissions(p)},[h,p]);const d=r();/* @__PURE__ */
1
+ import{ScreenPartsProvider as t}from"./chunk-77DQCEEF.js";import{useEaselHost as r}from"./chunk-U3JP4VGF.js";import{createEasel as e,EaselProvider as n}from"./chunk-PE6ZY5IW.js";import{useState as o,useEffect as s}from"react";import{jsx as i}from"react/jsx-runtime";function a({config:a,data:c,onChange:m,permissions:p,parts:f,children:u}){const[h]=o(()=>e({config:a,data:c,permissions:p}));s(()=>{h.setConfig(a)},[h,a]),s(()=>{if(!m)return;let t=h.getState().appState.data;return h.subscribe(()=>{const r=h.getState().appState.data;r!==t&&(t=r,m(r))})},[h,m]),s(()=>{p&&h.setPermissions(p)},[h,p]);const d=r();/* @__PURE__ */
2
2
  return i(n,{easel:h,hotkeys:d.ownsDocument,children:/* @__PURE__ */i(t,{parts:f,children:u})})}export{a as ScreenStoreProvider};
@@ -1,11 +1,11 @@
1
- import{DEFAULT_CANVAS_WORDS as e}from"./chunk-TBY3DFKS.js";import{useResolvedFields as t}from"./chunk-YRLPFZW3.js";import{toItemSelector as n,fromItemSelector as o,useNodeOps as r,parentStep as i,clickPick as a}from"./chunk-ECM5F6JJ.js";import{startCanvasTyping as s,textMap as l}from"./chunk-IL6QCPO6.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{setCanvasNonce as d,isTypingTarget as u,frameRectToHost as p,CANVAS_TYPING_EVENT as f,drawnBox as h}from"./chunk-ILXP5VX5.js";import{find as m,ROOT_ID as g,getList as v,remove as y,parseZoneKey as w,move as k,duplicate as b,replaceNode as S,createNode as I,insert as C,normalizeData as E,createResolveCache as x,resolveNodeData as D,ROOT_SLOT as O}from"./chunk-KRXQM65X.js";import{topLevelSlotKeys as P,fieldsFrom as A,defaultsFrom as M}from"./chunk-NKB3KVAB.js";import{createContext as z,useEffect as K,useContext as N,useRef as $,useSyncExternalStore as j,useState as B,useMemo as L,useCallback as R,useLayoutEffect as Z}from"react";import{jsx as V,jsxs as F}from"react/jsx-runtime";import{createPortal as T}from"react-dom";import{FloatingBar as H,TextToolbar as Y}from"efficient-shell/ui";function W(e){return!["setData","setUi","set"].includes(e.type)}var X=(e,t,n,o)=>{const r=v(e,t,w(n));return r?.[o]??null},q=(e,t,n,o,r)=>{const i=X(e,t,n,o);if(!i)throw new Error(`${r}: nothing at ${n}[${o}]`);return i};function U(e,t){const{selection:o}=e;return{...e.ui,itemSelector:n(e.data,t,o),selectedSlot:o&&"slot"===o.kind?{parentId:o.parentId,slot:o.slot}:null}}function J(e,t,n){return n?"node"===n.kind?m(e,t,n.id)?n:null:n.parentId===g?v(e,t,n)?n:null:m(e,t,n.parentId)&&v(e,t,n)?n:null:null}function Q(e,t,n,r=!1){const{itemSelector:i,selectedSlot:a,...s}=n;let l=e.selection;var c;return"itemSelector"in n&&(l=o(e.data,t,i??null)),"selectedSlot"in n&&(a?l=(c=a)?{kind:"slot",parentId:c.parentId,slot:c.slot}:null:"slot"===l?.kind&&(l=null)),{...e,selection:l,ui:r?s:{...e.ui,...s}}}function G(e,t,n){const o=_(e,t,n);if(o===e)return e;const r=J(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function _(e,t,n){const{data:o}=e;switch(t.type){case"setData":{const n="function"==typeof t.data?t.data(o):t.data;return{...e,data:{...o,...n}}}case"setUi":return Q(e,n,"function"==typeof t.ui?t.ui(U(e,n)):t.ui);case"set":{const r={data:o,ui:U(e,n)},i="function"==typeof t.state?t.state(r):t.state;let a=i.data?{...e,data:i.data}:e;return i.ui&&(a=Q(a,n,i.ui,!0)),a}case"insert":{const r={...w(t.destinationZone),index:t.destinationIndex},i=I(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:C(o,n,r,i)}}case"replace":{const r=q(o,n,t.destinationZone,t.destinationIndex,"replace");if(r.props.id!==t.data.props.id)throw new Error("Can't change the id during a replace action. Use remove and insert for a new node.");return{...e,data:S(o,n,r.props.id,t.data)}}case"replaceRoot":{const n={...o.root,props:{...o.root.props,...t.root.props},readOnly:t.root.readOnly};return{...e,data:{...o,root:n}}}case"duplicate":{const r=q(o,n,t.sourceZone,t.sourceIndex,"duplicate"),i=b(o,n,r.props.id),a=X(i,n,t.sourceZone,t.sourceIndex+1);return{...e,data:i,selection:a?{kind:"node",id:a.props.id}:e.selection}}case"reorder":return _(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=X(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const i={...w(t.destinationZone),index:t.destinationIndex};return{...e,data:k(o,n,r.props.id,i)}}case"remove":{const r=q(o,n,t.zone,t.index,"remove");return{...e,data:y(o,n,r.props.id)}}default:return e}}var ee={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},te={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},ne=0,oe=()=>`history-${ne+=1}`;function re(e){let t=e.config;const r=e.now??(()=>Date.now()),i=e.historyCoalesceMs??250;let a=e.permissions??{};const s=E(e.data,t);let l={data:s,selection:null,ui:{...te}};if(e.ui){const{itemSelector:n,selectedSlot:r,...i}=e.ui;l={data:s,selection:r?{kind:"slot",...r}:o(s,t,n??null),ui:{...te,...i}}}let c=[{core:l,at:-1/0,sealed:!0,id:oe()}],d=0;const u=e=>{const t=c[d],n=r();!e&&d===c.length-1&&d>0&&!t.sealed&&n-t.at<i?c=[...c.slice(0,d),{...t,core:l,at:n}]:(c=[...c.slice(0,d+1),{core:l,at:n,sealed:e,id:oe()}],d=c.length-1)},p=/* @__PURE__ */new Set;let f=null,h=null,g=0,y=null,w=!1;const k=()=>{for(const e of[...p])e()},b=()=>{c=[...c.slice(0,d),{...c[d],core:l},...c.slice(d+1)]},I=(t,n)=>{g>0?w=w||n:(n?u(!1):l!==t&&b(),l.data!==t.data&&e.onChange?.(l.data),l!==t&&k())},C=e=>{const n=l;if(l=G(l,e,t),l===n)return;const o=e.recordHistory??W(e);I(n,o&&l.data!==n.data)},O=t=>{0===g&&(y=l,w=!1),g+=1;try{t()}catch(e){throw g-=1,0===g&&y&&(l=y,y=null),e}if(g-=1,g>0||!y)return;const n=y;y=null,w&&l.data!==n.data?u(!0):l!==n&&b(),l.data!==n.data&&e.onChange?.(l.data),l!==n&&k()},P=e=>{const n=l,o=J(l.data,t,e);var r,i;(r=o,i=l.selection,r===i||r&&i&&r.kind===i.kind&&("node"===r.kind&&"node"===i.kind?r.id===i.id:"slot"===r.kind&&"slot"===i.kind&&r.parentId===i.parentId&&r.slot===i.slot))||(l={...l,selection:o},I(n,!1))},A=t=>{const n=l;d=t,l=c[d].core,l.data!==n.data&&e.onChange?.(l.data),l!==n&&k()},M=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...ee,...a,...n}};let z=M();const K=x(),N={resolveCache:K,async resolveAll({trigger:e="load",metadata:n}={}){const o=l.data,r={type:"root",props:{...o.root.props??{}}},i=[...o.content,...Object.values(o.zones??{}).flat()],[a,...s]=await Promise.all([D(r,t,{cache:K,trigger:e,metadata:n}),...i.map(o=>D(o,t,{cache:K,trigger:e,metadata:n}))]);O(()=>{const e=l;let n=l.data;s.forEach((e,r)=>{if(!e.didChange)return;const a=i[r].props.id,s=m(n,t,a)?.node;s&&s===m(o,t,a)?.node&&(n=S(n,t,a,e.node))}),a.didChange&&n.root===o.root&&(n={...n,root:{...n.root,props:a.node.props,readOnly:a.node.readOnly??n.root.readOnly}}),n!==l.data&&(l={...l,data:n,selection:J(n,t,l.selection)},I(e,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=m(l.data,t,e)?.node;if(!r)return!1;const i=await D(r,t,{cache:K,trigger:n,metadata:o});if(!i.didChange)return!1;let a=!1;return O(()=>{const n=l;if(m(l.data,t,e)?.node!==r)return;const o=S(l.data,t,e,i.node);o!==l.data&&(l={...l,data:o,selection:J(o,t,l.selection)},I(n,!1),a=!0)}),a},get config(){return t},getState(){if(f&&h===l)return f;const e=l,o={data:e.data,ui:U(e,t)},r="node"===e.selection?.kind?m(e.data,t,e.selection.id)?.node??null:null;return f={appState:o,selection:e.selection,selectedItem:r,config:t,dispatch:C,history:{back:()=>N.undo(),forward:()=>N.redo(),hasPast:d>0,hasFuture:d<c.length-1,histories:c.map(e=>({id:e.id,state:{data:e.core.data,ui:U(e.core,t)}})),index:d,setHistoryIndex:e=>{e>=0&&e<c.length&&e!==d&&A(e)}},getPermissions:z,getItemById:n=>m(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return v(e,t,{parentId:o,slot:r})?.[n.index]}(e.data,t,n),getSelectorForId:o=>{const r=n(e.data,t,{kind:"node",id:o});return r?{index:r.index,zone:r.zone??"root:default-zone"}:void 0}},h=e,f},subscribe:e=>(p.add(e),()=>{p.delete(e)}),dispatch:C,batch:O,group:()=>{const e=d,t=c[e].id;let n=!0;return{close:()=>{if(!n)return;if(n=!1,c[e]?.id!==t)return;if(d<=e+1)return void(d===e+1&&(c=[...c.slice(0,d),{...c[d],sealed:!0},...c.slice(d+1)]));const o=c[d];c=[...c.slice(0,e+1),{...o,sealed:!0},...c.slice(d+1)],d=e+1}}},select:e=>P(e?{kind:"node",id:e}:null),selectSlot:e=>P(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){O(()=>{const n=l,o=void 0===e.select?l.selection:e.select;l={...l,data:e.data,selection:J(e.data,t,o)},I(n,e.data!==n.data)})},load(e,n={}){const o=l,r=E(e,t);l={...l,data:r,selection:J(r,t,n.selection??l.selection)},n.keepHistory||(c=[{core:l,at:-1/0,sealed:!0,id:oe()}],d=0),l!==o&&k()},undo(){d>0&&A(d-1)},redo(){d<c.length-1&&A(d+1)},setPermissions(e){(function(e,t){if(e===t)return!0;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])})(e,a)||(a=e,z=M(),f=null,k())},setConfig(e){e!==t&&(t=e,z=M(),f=null,k())}};return N}function ie(e,t,n={}){const o=e=>{if(e.altKey)return;if(!(e.metaKey!==e.ctrlKey))return;const o="KeyZ"===e.code,r="KeyY"===e.code&&!e.shiftKey;(o||r)&&(n.leaveTyping&&u(e.target)||!1!==t.getState?.().getPermissions().edit&&(e.preventDefault(),r||e.shiftKey?t.redo():t.undo()))};return e.addEventListener("keydown",o),()=>e.removeEventListener("keydown",o)}var ae=z(null),se=z(!0);function le({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return K(()=>{n&&e.resolveAll()},[e,n]),K(()=>{if(t&&"undefined"!=typeof document)return ie(document,e)},[e,t]),/* @__PURE__ */V(ae.Provider,{value:e,children:/* @__PURE__ */V(se.Provider,{value:t,children:o})})}function ce(){const e=N(ae);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function de(e){const t=ce(),n=$({view:null,selector:null,value:void 0,has:!1}),o=()=>{const o=t.getState(),r=n.current;if(r.has&&r.view===o&&r.selector===e)return r.value;const i=e(o);return r.has&&Object.is(r.value,i)?(n.current={view:o,selector:e,value:r.value,has:!0},r.value):(n.current={view:o,selector:e,value:i,has:!0},i)};return j(t.subscribe,o,o)}function ue(){return function(e){return de(e)}}var pe="data-puck-component",fe="data-puck-dropzone",he={},me="data-es-mirror",ge="undefined"==typeof window?K:Z;function ve(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${me}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(me,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function ye({children:t,id:n="preview-frame",title:o,className:r,style:i,mirrorStyles:a=!0,onDocument:s,height:l="auto",nonce:u}){const p=c("canvas",e),f=$(null),[h,m]=B(null);return ge(()=>{const e=f.current,t=h?.ownerDocument.defaultView;if("auto"!==l||!e||!h||!t)return;const n=()=>{e.style.height=`${Math.ceil(h.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(h),()=>r?.disconnect()},[h,l]),ge(()=>{let e=f.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=f.current?.contentDocument??e),e.body||e.documentElement.appendChild(e.createElement("body")),e.body.style.margin="0";const t=e.createElement("div");t.setAttribute("data-puck-entry",""),t.id="frame-root","fill"===l&&t.classList.add("es-frame-fill"),e.body.appendChild(t),d(e,u),m(t),s?.(e);let n=null;const o=f.current?.ownerDocument;if(a&&o){ve(o,e,u);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>ve(o,e,u)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}return()=>{n?.disconnect(),t.remove(),m(null),s?.(null)}},[]),/* @__PURE__ */V("iframe",{ref:f,id:n,title:o??p.frame,className:["es-canvas-frame","fill"===l?"is-fill":"",r??""].filter(Boolean).join(" "),style:i,children:h?T(t,h):null})}var we=z(null),ke=z(he),be=[];function Se({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:i=120}){const a=ce(),s=de(n=>v(n.appState.data,a.config,{parentId:e,slot:t})??be),l=de(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==g),c=de(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),d=N(we),u=["es-zone"];return s.length&&u.push("has-children"),e===g&&u.push("is-root"),(l||c)&&u.push("is-area-selected"),null!==d&&d===e&&e!==g&&u.push("is-hovering-area"),n&&u.push(n),/* @__PURE__ */V("div",{className:u.join(" "),[fe]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${i}px`},children:s.map(e=>/* @__PURE__ */V(Ee,{node:e},e.props.id))})}function Ie(e,t){return L(()=>{const n={};for(const o of P(A(e)))n[o]=function(e={}){/* @__PURE__ */
2
- return V(Se,{parentId:t,slot:o,...e})};return n},[e,t])}function Ce(e){return L(()=>function({zone:t,...n}){/* @__PURE__ */
3
- return V(Se,{parentId:e,slot:t,...n})},[e])}function Ee({node:e}){const t=ce().config.components[e.type],n=e.props.id,o=function(e){const t=$(null);return L(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(pe),o.removeAttribute("data-puck-dnd")),t.current=n,n&&(n.setAttribute(pe,e),n.setAttribute("data-puck-dnd",e),n.style.position="relative")},[e])}(n),r=N(ke),i=Ie(t,n),a=Ce(n);if(!t?.render)return null;const s=t.render,l={...M(t),...e.props,...i},c={renderDropZone:a,isEditing:!0,dragRef:t.inline?o:null,metadata:{...r,...t.metadata}};return t.inline?/* @__PURE__ */V(s,{...l,puck:c,editMode:!0}):/* @__PURE__ */V("div",{[pe]:n,"data-puck-dnd":n,style:{position:"relative"},children:/* @__PURE__ */V(s,{...l,puck:c,editMode:!0})})}function xe({metadata:e}){const t=de(e=>e.config),n=de(e=>e.appState.data.root).props??{},o=t.root?.render,r=Ie(t.root,g),i=Ce(g),a=/* @__PURE__ */V(Se,{parentId:g,slot:O}),s=o?/* @__PURE__ */V(o,{id:"puck-root",...n,...r,puck:{renderDropZone:i,isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:a}):a;/* @__PURE__ */
4
- return V(ke.Provider,{value:e??he,children:s})}var De=z(void 0);function Oe(e,t,n){const[o,r]=B(null),i=$(t);return i.current=t,ge(()=>{const t=e.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!i.current)return void r(null);let o=0;const a=()=>{o=0;const n=function(e,t){if(!e||!t)return null;const n=h(e),o=t.getBoundingClientRect();return{top:n.top-o.top,left:n.left-o.left,width:n.width,height:n.height}}(i.current?i.current(t):null,e.current?.parentElement??null);r(e=>{return(t=e)===(o=n)||t&&o&&t.top===o.top&&t.left===o.left&&t.width===o.width&&t.height===o.height?e:n;var t,o})},s=()=>{o||(o=(n.requestAnimationFrame??(e=>n.setTimeout(e,16)))(a))};a();const l="MutationObserver"in n?new n.MutationObserver(s):null;l?.observe(t.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0});const c="ResizeObserver"in n?new n.ResizeObserver(s):null;return c?.observe(t.documentElement),n.addEventListener("resize",s),()=>{l?.disconnect(),c?.disconnect(),n.removeEventListener("resize",s),o&&(n.cancelAnimationFrame??n.clearTimeout)(o)}},[n]),o}function Pe({id:e,kind:t,overlay:n}){const o=$(null),r=Oe(o,e?t=>t.querySelector(`[${pe}="${t.defaultView?.CSS?.escape?t.defaultView.CSS.escape(e):e}"]`):null,e),i=/* @__PURE__ */V("div",{ref:o,"aria-hidden":"true",className:`es-canvas-outline is-${t}`,style:r?{position:"absolute",top:r.top,left:r.left,width:r.width,height:r.height}:{display:"none"}});return n&&e?/* @__PURE__ */V(n,{componentId:e,kind:t,children:i}):i}function Ae(e,t,n){const o=l(e,n),r=o.text.length,i=e.ownerDocument;if(!t)return[r,r];let a=null;const s=i.caretPositionFromPoint?.(t.x,t.y);if(s&&e.contains(s.offsetNode))a=o.at(s.offsetNode,s.offset);else{const n=i.caretRangeFromPoint?.(t.x,t.y);n&&e.contains(n.startContainer)&&(a=o.at(n.startContainer,n.startOffset))}if(null===a)return[r,r];const c=o.text;let d=a,u=a;for(;d>0&&!/\s/.test(c[d-1]);)d-=1;for(;u<c.length&&!/\s/.test(c[u]);)u+=1;return[d,u]}function Me({s:e,element:t,toolbar:n,label:o}){const r=e.pressed(),i=new Set(n.offered.filter(e=>"link"!==e));/* @__PURE__ */
5
- return V(H,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?p(o,{left:n.left,top:n.top,width:n.width,height:n.height}):{left:n.left,top:n.top,width:n.width,height:n.height};return{left:r.left-6,top:r.top-6,right:r.left+r.width+6,bottom:r.top+r.height+6}},bounds:()=>{const e=t(),n=e?.ownerDocument.defaultView?.frameElement,o=(n??e?.closest(".es-canvas")??e)?.getBoundingClientRect();return o?{left:o.left,top:o.top,right:o.right,bottom:o.bottom}:{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight}},"aria-label":o,children:/* @__PURE__ */V("div",{style:{width:"18rem"},children:/* @__PURE__ */V(Y,{offered:i,pressed:r.marks,onMark:t=>{"link"!==t&&e.press(t)},list:{pressed:r.list,onList:t=>e.list(t)},alignment:n.alignment,letterCase:n.letterCase,last:n.lastTool?.({className:"rosh-tb-btn",disabled:!1,selected:r.selected,keepCaret:t=>{t.preventDefault(),e.hold()},insert:t=>e.insert(t)})})})})}function ze({element:e}){const t=$(null),n=Oe(t,()=>e(),e);/* @__PURE__ */
6
- return V("div",{ref:t,"aria-hidden":"true",className:"es-canvas-outline is-typing",style:n?{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height}:{display:"none"}})}function Ke({frame:t=!0,className:n,style:o,metadata:r,mirrorStyles:l,onDocument:d,height:u,title:p,nonce:h,hotkeys:m,frameWrapper:g,overlay:v,children:y,typing:w,passThrough:k}){const b=ce(),S=N(De),I=k??S,C=N(se),E=c("canvas",e),x=m??C,[D,O]=B(void 0),P=de(e=>"node"===e.selection?.kind?e.selection.id:null),[A,M]=B(null),[z,j]=B(null),L=$(null),[,R]=B(0),Z=$(w);Z.current=w;const T=$(null),H=e=>{const t=T.current?.ownerDocument,n=t?.defaultView?.CustomEvent;t&&n&&t.dispatchEvent(new n(f,{detail:{typing:e}}))},Y=(e,t)=>{L.current?.s.stop("stop");const n=e.element();if(!n)return!1;const o=b.group(),r=e.element,i=s({element:r,value:e.value,rules:e.rules,multiline:e.multiline,skip:e.skip,caret:Ae(n,t,e.skip),write:e.write,remount:e.remount,onSelect:()=>R(e=>e+1),end:e=>{o.close(),L.current?.element===r&&(L.current=null),j(null),H(!1),Z.current?.onChange?.({typing:!1,why:e})}});if(!i)return o.close(),!1;const a=n.closest?.(`[${pe}]`)?.getAttribute(pe);return a&&b.select(a),L.current={s:i,element:r,target:e},j(()=>r),M(null),H(!0),Z.current?.onChange?.({typing:!0,element:n}),!0};K(()=>()=>L.current?.s.stop("stop"),[]);const W=e=>{const t=L.current?.element();return Boolean(t&&t.contains(e))},X=e=>{const t=e.closest?.(`[${pe}]`)?.getAttribute(pe);if(!t)return;const n=b.getState(),o="node"===n.selection?.kind?n.selection.id:null;return a(n.appState.data,b.config,t,o,I)??t},q=e=>{if("Enter"!==e.key||e.defaultPrevented||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;if(L.current)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select, button"))return;const n=Z.current?.atSelection?.();n&&Y(n,null)&&e.preventDefault()},U=/* @__PURE__ */F("div",{ref:T,className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;if(t.closest?.("a[href]")&&e.preventDefault(),L.current){if(W(t))return;L.current.s.stop("outside")}const n=X(t);void 0===n?t.hasAttribute?.(fe)||b.select(null):b.select(n)},onDoubleClick:e=>{const t=Z.current;if(!t||W(e.target))return;const n=t.at(e.target);n&&Y(n,{x:e.clientX,y:e.clientY})&&e.preventDefault()},onKeyDown:e=>q(e),onMouseOver:e=>{if(L.current)return;const t=X(e.target)??null;t!==A&&M(t)},onMouseLeave:()=>M(null),children:[
7
- /* @__PURE__ */V(we.Provider,{value:A,children:/* @__PURE__ */V(xe,{metadata:r})}),
8
- /* @__PURE__ */F("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
9
- /* @__PURE__ */V(Pe,{id:!z&&A&&A!==P?A:null,kind:"hover",overlay:v}),
10
- /* @__PURE__ */V(Pe,{id:z?null:P,kind:"selected",overlay:v}),z?/* @__PURE__ */V(ze,{element:z}):null]}),y]}),J=g?/* @__PURE__ */V(g,{document:D,children:U}):U;K(()=>{if(D&&x)return ie(D,b)},[D,x,b]),K(()=>{if(!D)return;const e=e=>{if("Enter"===e.key)return void q(e);if("Escape"!==e.key||e.defaultPrevented)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select"))return;const n=b.getState();if("node"!==n.selection?.kind)return;const o=i(n.appState.data,b.config,n.selection);"node"===o?.kind&&b.select(o.id)};return D.addEventListener("keydown",e),()=>D.removeEventListener("keydown",e)},[D,b]);/* @__PURE__ */
11
- return F("div",{className:"es-canvas"+(n?` ${n}`:""),style:o,"data-puck-preview":"","data-es-typing":z?"":void 0,children:[z&&L.current?.target.toolbar?/* @__PURE__ */V(Me,{s:L.current.s,element:L.current.element,toolbar:L.current.target.toolbar,label:E.textTools}):null,t?/* @__PURE__ */V(ye,{mirrorStyles:l,onDocument:e=>{O(e??void 0),d?.(e)},height:u,title:p,nonce:h,children:J}):/* @__PURE__ */V("div",{id:"preview-frame","data-puck-entry":"",children:J})]})}function Ne(e={}){const t=ce(),n=de(e=>e.appState.data);return r({...e,data:n,config:t.config,commit:(e,{select:n})=>t.run({data:e,select:n})})}function $e(){const e=ce(),n=de(e=>e.config),o=e.resolveCache,r=de(e=>e.selectedItem),i=de(e=>e.appState.data.root),a=r?r.props.id:"root",s=i.props??{},l=L(()=>r||{type:"root",props:s},[r,s]),c=r?n.components[r.type]:n.root,d=e.getState(),u=r?m(d.appState.data,n,a):null,p=u&&"root"!==u.place.parentId?u.place.parentId:null,f=p?d.getItemById(p)??null:null,{fields:h}=t({id:a,node:l,block:c,parent:f,appState:d.appState}),g=de(e=>!1===e.getPermissions(r?{item:r}:{root:!0}).edit),v=R(t=>{(async()=>{const r=e.getState();if("root"!==a){const i=r.getItemById(a),s=r.getSelectorForId(a);if(!i||!s)return;const l={...i,props:{...i.props,...t}},{node:c}=await D(l,n,{cache:o,trigger:"replace"}),d=e.getState().getSelectorForId(a);if(!d)return;return void e.dispatch({type:"replace",destinationZone:d.zone??"root:default-zone",destinationIndex:d.index,data:c})}const i=r.appState.data.root.props??{},{node:s}=await D({type:"root",props:{...i,...t}},n,{cache:o,trigger:"replace"});e.dispatch({type:"replaceRoot",root:{props:s.props,readOnly:s.readOnly},recordHistory:!0})})()},[e,n,o,a]),y=R((e,t)=>v({[e]:t}),[v]);return{id:a,node:l,fields:h,values:l.props,readOnly:g,onChange:y,onChangeMany:v}}export{ye as CanvasFrame,De as CanvasPassThroughContext,te as DEFAULT_UI,Ke as EaselCanvas,le as EaselProvider,xe as EditDocument,ie as bindUndoKeys,re as createEasel,ue as createUseEasel,W as recordsByDefault,G as reduce,U as uiView,de as useEasel,ce as useEaselApi,Ne as useEaselNodeOps,$e as useSelectedFields,J as validSelection};
1
+ import{DEFAULT_CANVAS_WORDS as e}from"./chunk-TBY3DFKS.js";import{useResolvedFields as t}from"./chunk-YRLPFZW3.js";import{toItemSelector as n,fromItemSelector as o,useNodeOps as r,parentStep as i,clickPick as a}from"./chunk-ECM5F6JJ.js";import{startCanvasTyping as s,textMap as l}from"./chunk-TJ6NRHYF.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{setCanvasNonce as d,isTypingTarget as u,frameRectToHost as p,CANVAS_TYPING_EVENT as f,drawnBox as h}from"./chunk-ILXP5VX5.js";import{find as m,ROOT_ID as g,getList as v,remove as y,parseZoneKey as w,move as k,duplicate as b,replaceNode as S,createNode as I,insert as C,normalizeData as E,createResolveCache as x,resolveNodeData as D,ROOT_SLOT as O}from"./chunk-KRXQM65X.js";import{topLevelSlotKeys as A,fieldsFrom as M,defaultsFrom as P}from"./chunk-NKB3KVAB.js";import{createContext as z,useEffect as N,useContext as K,useRef as R,useSyncExternalStore as $,useState as j,useMemo as B,useCallback as Z,useLayoutEffect as L}from"react";import{jsx as F,jsxs as V}from"react/jsx-runtime";import{createPortal as T}from"react-dom";import{FloatingBar as H,TextToolbar as Y}from"efficient-shell/ui";function W(e){return!["setData","setUi","set"].includes(e.type)}var X=(e,t,n,o)=>{const r=v(e,t,w(n));return r?.[o]??null},q=(e,t,n,o,r)=>{const i=X(e,t,n,o);if(!i)throw new Error(`${r}: nothing at ${n}[${o}]`);return i};function J(e,t){const{selection:o}=e;return{...e.ui,itemSelector:n(e.data,t,o),selectedSlot:o&&"slot"===o.kind?{parentId:o.parentId,slot:o.slot}:null}}function U(e,t,n){return n?"node"===n.kind?m(e,t,n.id)?n:null:n.parentId===g?v(e,t,n)?n:null:m(e,t,n.parentId)&&v(e,t,n)?n:null:null}function G(e,t,n,r=!1){const{itemSelector:i,selectedSlot:a,...s}=n;let l=e.selection;var c;return"itemSelector"in n&&(l=o(e.data,t,i??null)),"selectedSlot"in n&&(a?l=(c=a)?{kind:"slot",parentId:c.parentId,slot:c.slot}:null:"slot"===l?.kind&&(l=null)),{...e,selection:l,ui:r?s:{...e.ui,...s}}}function Q(e,t,n){const o=_(e,t,n);if(o===e)return e;const r=U(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function _(e,t,n){const{data:o}=e;switch(t.type){case"setData":{const n="function"==typeof t.data?t.data(o):t.data;return{...e,data:{...o,...n}}}case"setUi":return G(e,n,"function"==typeof t.ui?t.ui(J(e,n)):t.ui);case"set":{const r={data:o,ui:J(e,n)},i="function"==typeof t.state?t.state(r):t.state;let a=i.data?{...e,data:i.data}:e;return i.ui&&(a=G(a,n,i.ui,!0)),a}case"insert":{const r={...w(t.destinationZone),index:t.destinationIndex},i=I(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:C(o,n,r,i)}}case"replace":{const r=q(o,n,t.destinationZone,t.destinationIndex,"replace");if(r.props.id!==t.data.props.id)throw new Error("Can't change the id during a replace action. Use remove and insert for a new node.");return{...e,data:S(o,n,r.props.id,t.data)}}case"replaceRoot":{const n={...o.root,props:{...o.root.props,...t.root.props},readOnly:t.root.readOnly};return{...e,data:{...o,root:n}}}case"duplicate":{const r=q(o,n,t.sourceZone,t.sourceIndex,"duplicate"),i=b(o,n,r.props.id),a=X(i,n,t.sourceZone,t.sourceIndex+1);return{...e,data:i,selection:a?{kind:"node",id:a.props.id}:e.selection}}case"reorder":return _(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=X(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const i={...w(t.destinationZone),index:t.destinationIndex};return{...e,data:k(o,n,r.props.id,i)}}case"remove":{const r=q(o,n,t.zone,t.index,"remove");return{...e,data:y(o,n,r.props.id)}}default:return e}}var ee={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},te={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},ne=0,oe=()=>`history-${ne+=1}`;function re(e){let t=e.config;const r=e.now??(()=>Date.now()),i=e.historyCoalesceMs??250;let a=e.permissions??{};const s=E(e.data,t);let l={data:s,selection:null,ui:{...te}};if(e.ui){const{itemSelector:n,selectedSlot:r,...i}=e.ui;l={data:s,selection:r?{kind:"slot",...r}:o(s,t,n??null),ui:{...te,...i}}}let c=[{core:l,at:-1/0,sealed:!0,id:oe()}],d=0;const u=e=>{const t=c[d],n=r();!e&&d===c.length-1&&d>0&&!t.sealed&&n-t.at<i?c=[...c.slice(0,d),{...t,core:l,at:n}]:(c=[...c.slice(0,d+1),{core:l,at:n,sealed:e,id:oe()}],d=c.length-1)},p=/* @__PURE__ */new Set;let f=null,h=null,g=0,y=null,w=!1;const k=()=>{for(const e of[...p])e()},b=()=>{c=[...c.slice(0,d),{...c[d],core:l},...c.slice(d+1)]},I=(t,n)=>{g>0?w=w||n:(n?u(!1):l!==t&&b(),l.data!==t.data&&e.onChange?.(l.data),l!==t&&k())},C=e=>{const n=l;if(l=Q(l,e,t),l===n)return;const o=e.recordHistory??W(e);I(n,o&&l.data!==n.data)},O=t=>{0===g&&(y=l,w=!1),g+=1;try{t()}catch(e){throw g-=1,0===g&&y&&(l=y,y=null),e}if(g-=1,g>0||!y)return;const n=y;y=null,w&&l.data!==n.data?u(!0):l!==n&&b(),l.data!==n.data&&e.onChange?.(l.data),l!==n&&k()},A=e=>{const n=l,o=U(l.data,t,e);var r,i;(r=o,i=l.selection,r===i||r&&i&&r.kind===i.kind&&("node"===r.kind&&"node"===i.kind?r.id===i.id:"slot"===r.kind&&"slot"===i.kind&&r.parentId===i.parentId&&r.slot===i.slot))||(l={...l,selection:o},I(n,!1))},M=t=>{const n=l;d=t,l=c[d].core,l.data!==n.data&&e.onChange?.(l.data),l!==n&&k()},P=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...ee,...a,...n}};let z=P();const N=x(),K={resolveCache:N,async resolveAll({trigger:e="load",metadata:n}={}){const o=l.data,r={type:"root",props:{...o.root.props??{}}},i=[...o.content,...Object.values(o.zones??{}).flat()],[a,...s]=await Promise.all([D(r,t,{cache:N,trigger:e,metadata:n}),...i.map(o=>D(o,t,{cache:N,trigger:e,metadata:n}))]);O(()=>{const e=l;let n=l.data;s.forEach((e,r)=>{if(!e.didChange)return;const a=i[r].props.id,s=m(n,t,a)?.node;s&&s===m(o,t,a)?.node&&(n=S(n,t,a,e.node))}),a.didChange&&n.root===o.root&&(n={...n,root:{...n.root,props:a.node.props,readOnly:a.node.readOnly??n.root.readOnly}}),n!==l.data&&(l={...l,data:n,selection:U(n,t,l.selection)},I(e,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=m(l.data,t,e)?.node;if(!r)return!1;const i=await D(r,t,{cache:N,trigger:n,metadata:o});if(!i.didChange)return!1;let a=!1;return O(()=>{const n=l;if(m(l.data,t,e)?.node!==r)return;const o=S(l.data,t,e,i.node);o!==l.data&&(l={...l,data:o,selection:U(o,t,l.selection)},I(n,!1),a=!0)}),a},get config(){return t},getState(){if(f&&h===l)return f;const e=l,o={data:e.data,ui:J(e,t)},r="node"===e.selection?.kind?m(e.data,t,e.selection.id)?.node??null:null;return f={appState:o,selection:e.selection,selectedItem:r,config:t,dispatch:C,history:{back:()=>K.undo(),forward:()=>K.redo(),hasPast:d>0,hasFuture:d<c.length-1,histories:c.map(e=>({id:e.id,state:{data:e.core.data,ui:J(e.core,t)}})),index:d,setHistoryIndex:e=>{e>=0&&e<c.length&&e!==d&&M(e)}},getPermissions:z,getItemById:n=>m(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return v(e,t,{parentId:o,slot:r})?.[n.index]}(e.data,t,n),getSelectorForId:o=>{const r=n(e.data,t,{kind:"node",id:o});return r?{index:r.index,zone:r.zone??"root:default-zone"}:void 0}},h=e,f},subscribe:e=>(p.add(e),()=>{p.delete(e)}),dispatch:C,batch:O,group:()=>{const e=d,t=c[e].id;let n=!0;return{close:()=>{if(!n)return;if(n=!1,c[e]?.id!==t)return;if(d<=e+1)return void(d===e+1&&(c=[...c.slice(0,d),{...c[d],sealed:!0},...c.slice(d+1)]));const o=c[d];c=[...c.slice(0,e+1),{...o,sealed:!0},...c.slice(d+1)],d=e+1}}},select:e=>A(e?{kind:"node",id:e}:null),selectSlot:e=>A(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){O(()=>{const n=l,o=void 0===e.select?l.selection:e.select;l={...l,data:e.data,selection:U(e.data,t,o)},I(n,e.data!==n.data)})},load(e,n={}){const o=l,r=E(e,t);l={...l,data:r,selection:U(r,t,n.selection??l.selection)},n.keepHistory||(c=[{core:l,at:-1/0,sealed:!0,id:oe()}],d=0),l!==o&&k()},undo(){d>0&&M(d-1)},redo(){d<c.length-1&&M(d+1)},setPermissions(e){(function(e,t){if(e===t)return!0;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])})(e,a)||(a=e,z=P(),f=null,k())},setConfig(e){e!==t&&(t=e,z=P(),f=null,k())}};return K}function ie(e,t,n={}){const o=e=>{if(e.altKey)return;if(!(e.metaKey!==e.ctrlKey))return;const o="KeyZ"===e.code,r="KeyY"===e.code&&!e.shiftKey;(o||r)&&(n.leaveTyping&&u(e.target)||!1!==t.getState?.().getPermissions().edit&&(e.preventDefault(),r||e.shiftKey?t.redo():t.undo()))};return e.addEventListener("keydown",o),()=>e.removeEventListener("keydown",o)}var ae=z(null),se=z(!0);function le({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return N(()=>{n&&e.resolveAll()},[e,n]),N(()=>{if(t&&"undefined"!=typeof document)return ie(document,e)},[e,t]),/* @__PURE__ */F(ae.Provider,{value:e,children:/* @__PURE__ */F(se.Provider,{value:t,children:o})})}function ce(){const e=K(ae);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function de(e){const t=ce(),n=R({view:null,selector:null,value:void 0,has:!1}),o=()=>{const o=t.getState(),r=n.current;if(r.has&&r.view===o&&r.selector===e)return r.value;const i=e(o);return r.has&&Object.is(r.value,i)?(n.current={view:o,selector:e,value:r.value,has:!0},r.value):(n.current={view:o,selector:e,value:i,has:!0},i)};return $(t.subscribe,o,o)}function ue(){return function(e){return de(e)}}var pe="data-puck-component",fe="data-puck-dropzone",he={},me="data-es-mirror",ge="undefined"==typeof window?N:L;function ve(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${me}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(me,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function ye({children:t,id:n="preview-frame",title:o,className:r,style:i,mirrorStyles:a=!0,onDocument:s,height:l="auto",nonce:u}){const p=c("canvas",e),f=R(null),[h,m]=j(null);return ge(()=>{const e=f.current,t=h?.ownerDocument.defaultView;if("auto"!==l||!e||!h||!t)return;const n=()=>{e.style.height=`${Math.ceil(h.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(h),()=>r?.disconnect()},[h,l]),ge(()=>{let e=f.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=f.current?.contentDocument??e),e.body||e.documentElement.appendChild(e.createElement("body")),e.body.style.margin="0";const t=e.createElement("div");t.setAttribute("data-puck-entry",""),t.id="frame-root","fill"===l&&t.classList.add("es-frame-fill"),e.body.appendChild(t),d(e,u),m(t),s?.(e);let n=null;const o=f.current?.ownerDocument;if(a&&o){ve(o,e,u);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>ve(o,e,u)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}return()=>{n?.disconnect(),t.remove(),m(null),s?.(null)}},[]),/* @__PURE__ */F("iframe",{ref:f,id:n,title:o??p.frame,className:["es-canvas-frame","fill"===l?"is-fill":"",r??""].filter(Boolean).join(" "),style:i,children:h?T(t,h):null})}var we=z(null),ke=z(he),be=[];function Se({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:i=120}){const a=ce(),s=de(n=>v(n.appState.data,a.config,{parentId:e,slot:t})??be),l=de(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==g),c=de(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),d=K(we),u=["es-zone"];return s.length&&u.push("has-children"),e===g&&u.push("is-root"),(l||c)&&u.push("is-area-selected"),null!==d&&d===e&&e!==g&&u.push("is-hovering-area"),n&&u.push(n),/* @__PURE__ */F("div",{className:u.join(" "),[fe]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${i}px`},children:s.map(e=>/* @__PURE__ */F(Ee,{node:e},e.props.id))})}function Ie(e,t){return B(()=>{const n={};for(const o of A(M(e)))n[o]=function(e={}){/* @__PURE__ */
2
+ return F(Se,{parentId:t,slot:o,...e})};return n},[e,t])}function Ce(e){return B(()=>function({zone:t,...n}){/* @__PURE__ */
3
+ return F(Se,{parentId:e,slot:t,...n})},[e])}function Ee({node:e}){const t=ce().config.components[e.type],n=e.props.id,o=function(e){const t=R(null);return B(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(pe),o.removeAttribute("data-puck-dnd")),t.current=n,n&&(n.setAttribute(pe,e),n.setAttribute("data-puck-dnd",e),n.style.position="relative")},[e])}(n),r=K(ke),i=Ie(t,n),a=Ce(n);if(!t?.render)return null;const s=t.render,l={...P(t),...e.props,...i},c={renderDropZone:a,isEditing:!0,dragRef:t.inline?o:null,metadata:{...r,...t.metadata}};return t.inline?/* @__PURE__ */F(s,{...l,puck:c,editMode:!0}):/* @__PURE__ */F("div",{[pe]:n,"data-puck-dnd":n,style:{position:"relative"},children:/* @__PURE__ */F(s,{...l,puck:c,editMode:!0})})}function xe({metadata:e}){const t=de(e=>e.config),n=de(e=>e.appState.data.root).props??{},o=t.root?.render,r=Ie(t.root,g),i=Ce(g),a=/* @__PURE__ */F(Se,{parentId:g,slot:O}),s=o?/* @__PURE__ */F(o,{id:"puck-root",...n,...r,puck:{renderDropZone:i,isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:a}):a;/* @__PURE__ */
4
+ return F(ke.Provider,{value:e??he,children:s})}var De=z(void 0);function Oe(e,t,n){const[o,r]=j(null),i=R(t);return i.current=t,ge(()=>{const t=e.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!i.current)return void r(null);let o=0;const a=()=>{o=0;const n=function(e,t){if(!e||!t)return null;const n=h(e),o=t.getBoundingClientRect();return{top:n.top-o.top,left:n.left-o.left,width:n.width,height:n.height}}(i.current?i.current(t):null,e.current?.parentElement??null);r(e=>{return(t=e)===(o=n)||t&&o&&t.top===o.top&&t.left===o.left&&t.width===o.width&&t.height===o.height?e:n;var t,o})},s=()=>{o||(o=(n.requestAnimationFrame??(e=>n.setTimeout(e,16)))(a))};a();const l="MutationObserver"in n?new n.MutationObserver(s):null;l?.observe(t.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0});const c="ResizeObserver"in n?new n.ResizeObserver(s):null;return c?.observe(t.documentElement),n.addEventListener("resize",s),()=>{l?.disconnect(),c?.disconnect(),n.removeEventListener("resize",s),o&&(n.cancelAnimationFrame??n.clearTimeout)(o)}},[n]),o}function Ae({id:e,kind:t,overlay:n}){const o=R(null),r=Oe(o,e?t=>t.querySelector(`[${pe}="${t.defaultView?.CSS?.escape?t.defaultView.CSS.escape(e):e}"]`):null,e),i=/* @__PURE__ */F("div",{ref:o,"aria-hidden":"true",className:`es-canvas-outline is-${t}`,style:r?{position:"absolute",top:r.top,left:r.left,width:r.width,height:r.height}:{display:"none"}});return n&&e?/* @__PURE__ */F(n,{componentId:e,kind:t,children:i}):i}function Me(e,t,n){const o=l(e,n),r=o.text.length,i=e.ownerDocument;if(!t)return[r,r];let a=null;const s=i.caretPositionFromPoint?.(t.x,t.y);if(s&&e.contains(s.offsetNode))a=o.at(s.offsetNode,s.offset);else{const n=i.caretRangeFromPoint?.(t.x,t.y);n&&e.contains(n.startContainer)&&(a=o.at(n.startContainer,n.startOffset))}if(null===a)return[r,r];const c=o.text;let d=a,u=a;for(;d>0&&!/\s/.test(c[d-1]);)d-=1;for(;u<c.length&&!/\s/.test(c[u]);)u+=1;return[d,u]}function Pe({s:e,element:t,toolbar:n,label:o}){const r=e.pressed(),i=new Set(n.offered.filter(e=>"link"!==e));/* @__PURE__ */
5
+ return F(H,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?p(o,{left:n.left,top:n.top,width:n.width,height:n.height}):{left:n.left,top:n.top,width:n.width,height:n.height};return{left:r.left-6,top:r.top-6,right:r.left+r.width+6,bottom:r.top+r.height+6}},bounds:()=>{const e=t(),n=e?.ownerDocument.defaultView?.frameElement,o=(n??e?.closest(".es-canvas")??e)?.getBoundingClientRect();return o?{left:o.left,top:o.top,right:o.right,bottom:o.bottom}:{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight}},"aria-label":o,children:/* @__PURE__ */F("div",{style:{width:"18rem"},children:/* @__PURE__ */F(Y,{offered:i,pressed:r.marks,onMark:t=>{"link"!==t&&e.press(t)},list:{pressed:r.list,onList:t=>e.list(t)},alignment:n.alignment,letterCase:n.letterCase,last:n.lastTool?.({className:"rosh-tb-btn",disabled:!1,selected:r.selected,keepCaret:t=>{t.preventDefault(),e.hold()},insert:t=>e.insert(t)})})})})}function ze({element:e}){const t=R(null),n=Oe(t,()=>e(),e);/* @__PURE__ */
6
+ return F("div",{ref:t,"aria-hidden":"true",className:"es-canvas-outline is-typing",style:n?{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height}:{display:"none"}})}function Ne({frame:t=!0,className:n,style:o,metadata:r,mirrorStyles:l,onDocument:d,height:u,title:p,nonce:h,hotkeys:m,frameWrapper:g,overlay:v,children:y,typing:w,passThrough:k}){const b=ce(),S=K(De),I=k??S,C=K(se),E=c("canvas",e),x=m??C,[D,O]=j(void 0),A=de(e=>"node"===e.selection?.kind?e.selection.id:null),[M,P]=j(null),[z,$]=j(null),B=R(null),[,Z]=j(0),L=R(w);L.current=w;const T=R(null),H=e=>{const t=T.current?.ownerDocument,n=t?.defaultView?.CustomEvent;t&&n&&t.dispatchEvent(new n(f,{detail:{typing:e}}))},Y=(e,t)=>{B.current?.s.stop("stop");const n=e.element();if(!n)return!1;const o=b.group(),r=e.element,i=s({element:r,value:e.value,rules:e.rules,multiline:e.multiline,skip:e.skip,caret:Me(n,t,e.skip),write:e.write,remount:e.remount,onSelect:()=>Z(e=>e+1),end:e=>{o.close(),B.current?.element===r&&(B.current=null),$(null),H(!1),L.current?.onChange?.({typing:!1,why:e})}});if(!i)return o.close(),!1;const a=n.closest?.(`[${pe}]`)?.getAttribute(pe);return a&&b.select(a),B.current={s:i,element:r,target:e},$(()=>r),P(null),H(!0),L.current?.onChange?.({typing:!0,element:n}),!0};N(()=>()=>B.current?.s.stop("stop"),[]);const W=e=>{const t=B.current?.element();return Boolean(t&&t.contains(e))},X=e=>{const t=e.closest?.(`[${pe}]`)?.getAttribute(pe);if(!t)return;const n=b.getState(),o="node"===n.selection?.kind?n.selection.id:null;return a(n.appState.data,b.config,t,o,I)??t},q=e=>{if("Enter"!==e.key||e.defaultPrevented||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;if(B.current)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select, button"))return;const n=L.current?.atSelection?.();n&&Y(n,null)&&e.preventDefault()},J=/* @__PURE__ */V("div",{ref:T,className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;if(t.closest?.("a[href]")&&e.preventDefault(),B.current){if(W(t))return;B.current.s.stop("outside")}const n=X(t);void 0===n?t.hasAttribute?.(fe)||b.select(null):b.select(n)},onDoubleClick:e=>{const t=L.current;if(!t||W(e.target))return;const n=t.at(e.target);n&&Y(n,{x:e.clientX,y:e.clientY})&&e.preventDefault()},onKeyDown:e=>q(e),onMouseOver:e=>{if(B.current)return;const t=X(e.target)??null;t!==M&&P(t)},onMouseLeave:()=>P(null),children:[
7
+ /* @__PURE__ */F(we.Provider,{value:M,children:/* @__PURE__ */F(xe,{metadata:r})}),
8
+ /* @__PURE__ */V("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
9
+ /* @__PURE__ */F(Ae,{id:!z&&M&&M!==A?M:null,kind:"hover",overlay:v}),
10
+ /* @__PURE__ */F(Ae,{id:z?null:A,kind:"selected",overlay:v}),z?/* @__PURE__ */F(ze,{element:z}):null]}),y]}),U=g?/* @__PURE__ */F(g,{document:D,children:J}):J;N(()=>{if(D&&x)return ie(D,b)},[D,x,b]),N(()=>{if(!D)return;const e=e=>{if("Enter"===e.key)return void q(e);if("Escape"!==e.key||e.defaultPrevented)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select"))return;const n=b.getState();if("node"!==n.selection?.kind)return;const o=i(n.appState.data,b.config,n.selection);"node"===o?.kind&&b.select(o.id)};return D.addEventListener("keydown",e),()=>D.removeEventListener("keydown",e)},[D,b]);/* @__PURE__ */
11
+ return V("div",{className:"es-canvas"+(n?` ${n}`:""),style:o,"data-puck-preview":"","data-es-typing":z?"":void 0,children:[z&&B.current?.target.toolbar?/* @__PURE__ */F(Pe,{s:B.current.s,element:B.current.element,toolbar:B.current.target.toolbar,label:E.textTools}):null,t?/* @__PURE__ */F(ye,{mirrorStyles:l,onDocument:e=>{O(e??void 0),d?.(e)},height:u,title:p,nonce:h,children:U}):/* @__PURE__ */F("div",{id:"preview-frame","data-puck-entry":"",children:U})]})}function Ke(e={}){const t=ce(),n=de(e=>e.appState.data);return r({...e,data:n,config:t.config,commit:(e,{select:n})=>t.run({data:e,select:n})})}function Re(){const e=ce(),n=de(e=>e.config),o=e.resolveCache,r=de(e=>e.selectedItem),i=de(e=>e.appState.data.root),a=r?r.props.id:"root",s=i.props??{},l=B(()=>r||{type:"root",props:s},[r,s]),c=r?n.components[r.type]:n.root,d=e.getState(),u=r?m(d.appState.data,n,a):null,p=u&&"root"!==u.place.parentId?u.place.parentId:null,f=p?d.getItemById(p)??null:null,{fields:h}=t({id:a,node:l,block:c,parent:f,appState:d.appState}),g=de(e=>!1===e.getPermissions(r?{item:r}:{root:!0}).edit),v=Z(t=>{(async()=>{const r=e.getState();if("root"!==a){const i=r.getItemById(a),s=r.getSelectorForId(a);if(!i||!s)return;const l={...i,props:{...i.props,...t}},{node:c}=await D(l,n,{cache:o,trigger:"replace"}),d=e.getState().getSelectorForId(a);if(!d)return;return void e.dispatch({type:"replace",destinationZone:d.zone??"root:default-zone",destinationIndex:d.index,data:c})}const i=r.appState.data.root.props??{},{node:s}=await D({type:"root",props:{...i,...t}},n,{cache:o,trigger:"replace"});e.dispatch({type:"replaceRoot",root:{props:s.props,readOnly:s.readOnly},recordHistory:!0})})()},[e,n,o,a]),y=Z((e,t)=>v({[e]:t}),[v]);return{id:a,node:l,fields:h,values:l.props,readOnly:g,onChange:y,onChangeMany:v}}export{ye as CanvasFrame,De as CanvasPassThroughContext,te as DEFAULT_UI,Ne as EaselCanvas,le as EaselProvider,xe as EditDocument,ie as bindUndoKeys,re as createEasel,ue as createUseEasel,W as recordsByDefault,Q as reduce,J as uiView,de as useEasel,ce as useEaselApi,Ke as useEaselNodeOps,Re as useSelectedFields,U as validSelection};