efficient-easel 16.1.0 → 18.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 (149) hide show
  1. package/README.md +28 -65
  2. package/dist/autosave/index.d.ts +4 -4
  3. package/dist/blocks/index.d.ts +2 -2
  4. package/dist/chrome/index.d.ts +3 -3
  5. package/dist/chrome/index.js +1 -1
  6. package/dist/chunk-43AEUUNQ.js +1 -0
  7. package/dist/{chunk-K6EM4F5N.js → chunk-5VD2LGIZ.js} +18 -18
  8. package/dist/{chunk-ATOXCKEE.js → chunk-7TOQCTHV.js} +3 -3
  9. package/dist/chunk-A6Z4SD3I.js +10 -0
  10. package/dist/{chunk-V6VKM2QX.js → chunk-A7FF65FL.js} +1 -1
  11. package/dist/chunk-BHRC3ASL.js +1 -0
  12. package/dist/chunk-BRMYJBMB.js +8 -0
  13. package/dist/chunk-C2RHV42O.js +1 -0
  14. package/dist/chunk-F7FDF6NS.js +4 -0
  15. package/dist/{chunk-IE55HNMA.js → chunk-GWIVPLOX.js} +11 -11
  16. package/dist/{chunk-2H3W5OLQ.js → chunk-HGV3FWOB.js} +1 -1
  17. package/dist/chunk-LLDHIBYG.js +18 -0
  18. package/dist/chunk-M2Z775ZC.js +1 -0
  19. package/dist/{chunk-2L2L7G5L.js → chunk-MPF5QZJ7.js} +1 -1
  20. package/dist/chunk-N3VPBHR6.js +62 -0
  21. package/dist/chunk-QEAUF632.js +14 -0
  22. package/dist/{chunk-UVQR7W6I.js → chunk-RFE7ZG3Y.js} +1 -1
  23. package/dist/chunk-STWSCR25.js +2 -0
  24. package/dist/{chunk-TZIIRGVY.js → chunk-U277UX5I.js} +1 -1
  25. package/dist/chunk-VEZPDGDQ.js +1 -0
  26. package/dist/{chunk-JQOYUH4A.js → chunk-W2GEGVUY.js} +4 -4
  27. package/dist/{chunk-GPLMNRHR.js → chunk-WOETW3H6.js} +1 -1
  28. package/dist/chunk-X3TYRF5V.js +1 -0
  29. package/dist/{chunk-62VPYC7F.js → chunk-XDZHKYQX.js} +1 -1
  30. package/dist/{chunk-HV56SLR2.js → chunk-XHHVMAGM.js} +1 -1
  31. package/dist/chunk-XHSGRH42.js +5 -0
  32. package/dist/{chunk-XQGV2XAK.js → chunk-YI4QXOVJ.js} +1 -1
  33. package/dist/{chunk-RFSLDGDA.js → chunk-YLQYEDUQ.js} +1 -1
  34. package/dist/copy/index.js +23 -11
  35. package/dist/drag/drag.css +8 -0
  36. package/dist/drag/index.d.ts +15 -1
  37. package/dist/drag/index.js +1 -1
  38. package/dist/draw/client.js +1 -1
  39. package/dist/draw/index.js +1 -1
  40. package/dist/easel/easel.css +8 -0
  41. package/dist/easel/index.d.ts +45 -6
  42. package/dist/easel/index.js +1 -1
  43. package/dist/fields/index.js +1 -1
  44. package/dist/gold/gold.css +1 -1
  45. package/dist/{host-DGmdCaNL.d.ts → host-epHo7r8P.d.ts} +12 -5
  46. package/dist/icons/index.d.ts +0 -2
  47. package/dist/node-ops/index.d.ts +2 -2
  48. package/dist/node-ops/index.js +1 -1
  49. package/dist/panel/index.js +1 -1
  50. package/dist/{plan-CGREINRO.d.ts → plan-CZS902DV.d.ts} +27 -1
  51. package/dist/rail/index.d.ts +2 -2
  52. package/dist/screen/components/AddBlockRow.js +1 -1
  53. package/dist/screen/components/AddSidePanel.d.ts +6 -1
  54. package/dist/screen/components/AddSidePanel.js +1 -1
  55. package/dist/screen/components/MediaSidePanel.d.ts +4 -3
  56. package/dist/screen/components/MediaSidePanel.js +1 -1
  57. package/dist/screen/components/NodeContextMenu.d.ts +8 -7
  58. package/dist/screen/components/NodeContextMenu.js +1 -1
  59. package/dist/screen/components/PageEditGuardNotices.js +1 -1
  60. package/dist/screen/components/SaveControls.d.ts +7 -6
  61. package/dist/screen/components/SaveControls.js +1 -1
  62. package/dist/screen/components/ScreenChrome.js +1 -1
  63. package/dist/screen/components/ScreenDocumentContext.d.ts +4 -3
  64. package/dist/screen/components/ScreenDocumentContext.js +1 -1
  65. package/dist/screen/components/ScreenMount.d.ts +7 -6
  66. package/dist/screen/components/ScreenMount.js +1 -1
  67. package/dist/screen/components/ScreenStoreProvider.d.ts +7 -6
  68. package/dist/screen/components/ScreenStoreProvider.js +1 -1
  69. package/dist/screen/components/SectionScreenShell.js +15 -15
  70. package/dist/screen/components/SidePanelHead.js +1 -1
  71. package/dist/screen/components/panel-widths.js +1 -1
  72. package/dist/screen/components/usePartBridge.d.ts +7 -6
  73. package/dist/screen/components/usePartBridge.js +1 -1
  74. package/dist/screen/index.d.ts +8 -7
  75. package/dist/screen/index.js +1 -1
  76. package/dist/screen/lib/admin-bridge.d.ts +3 -2
  77. package/dist/screen/lib/document-addressing.d.ts +4 -3
  78. package/dist/screen/lib/document-hooks.d.ts +2 -2
  79. package/dist/screen/lib/host-chrome.d.ts +0 -10
  80. package/dist/screen/lib/host.d.ts +4 -3
  81. package/dist/screen/lib/key-scope.js +1 -1
  82. package/dist/screen/lib/media-panel.d.ts +4 -3
  83. package/dist/screen/lib/media-picker.d.ts +7 -9
  84. package/dist/screen/lib/page-lock.d.ts +3 -2
  85. package/dist/screen/lib/puck/block-choice.d.ts +13 -1
  86. package/dist/screen/lib/puck/block-choice.js +1 -1
  87. package/dist/screen/lib/puck/device-fields.js +1 -1
  88. package/dist/screen/lib/puck/palette-sections.d.ts +2 -2
  89. package/dist/screen/lib/puck/section-doc.d.ts +2 -2
  90. package/dist/screen/lib/puck/slot-child-name.js +1 -1
  91. package/dist/screen/lib/puck/style-clipboard.d.ts +7 -6
  92. package/dist/screen/lib/puck/style-clipboard.js +1 -1
  93. package/dist/screen/lib/puck/use-section-ops.d.ts +2 -2
  94. package/dist/screen/lib/puck/use-section-ops.js +1 -1
  95. package/dist/screen/lib/save-status.d.ts +2 -2
  96. package/dist/screen/lib/screen-parts.d.ts +71 -29
  97. package/dist/screen/lib/screen-parts.js +1 -1
  98. package/dist/screen/lib/section-templates.d.ts +3 -2
  99. package/dist/screen/lib/session-context.d.ts +3 -2
  100. package/dist/screen/lib/session.d.ts +6 -2
  101. package/dist/screen/lib/shared-section-types.d.ts +71 -0
  102. package/dist/screen/lib/shared-section-types.js +1 -0
  103. package/dist/screen/lib/shared-sections.d.ts +34 -0
  104. package/dist/screen/lib/shared-sections.js +1 -0
  105. package/dist/screen/screen.css +7 -0
  106. package/dist/screen/words.d.ts +49 -3
  107. package/dist/screen/words.js +1 -1
  108. package/dist/shell/shell.css +6 -1
  109. package/dist/strings/index.d.ts +134 -20
  110. package/dist/strings/index.js +2 -2
  111. package/dist/text-styles/index.js +23 -23
  112. package/dist/tree/index.d.ts +3 -3
  113. package/dist/tree/index.js +1 -1
  114. package/dist/tree/tree.css +17 -0
  115. package/dist/{types-D8P9q-BG.d.ts → types-Bqq6ya0y.d.ts} +9 -0
  116. package/dist/{types-NQozKWEz.d.ts → types-Cq53lL8d.d.ts} +1 -1
  117. package/dist/{types-CsgMwHHa.d.ts → types-Cy7rdmXt.d.ts} +1 -1
  118. package/dist/{types-DGyDHiJV.d.ts → types-DT8ywrFQ.d.ts} +1 -1
  119. package/dist/{useNodeOps-BHRkUFfG.d.ts → useNodeOps-fIDWzftn.d.ts} +3 -1
  120. package/dist/{words-pgIK0I6g.d.ts → words-DkWcK1rh.d.ts} +2 -2
  121. package/package.json +16 -43
  122. package/dist/chunk-44COUKXO.js +0 -5
  123. package/dist/chunk-4BGYVIDQ.js +0 -57
  124. package/dist/chunk-4JSBIW5H.js +0 -9
  125. package/dist/chunk-ECM5F6JJ.js +0 -1
  126. package/dist/chunk-H4UMY7QF.js +0 -13
  127. package/dist/chunk-HMXIAMCU.js +0 -1
  128. package/dist/chunk-HQ4VVRIC.js +0 -1
  129. package/dist/chunk-IN22IYOM.js +0 -1
  130. package/dist/chunk-L2VGRQ4R.js +0 -4
  131. package/dist/chunk-L3GSW4XI.js +0 -1
  132. package/dist/chunk-POSLNRTO.js +0 -18
  133. package/dist/chunk-QX7GVECM.js +0 -13
  134. package/dist/chunk-TBF5CVPA.js +0 -1
  135. package/dist/chunk-U25CP5VX.js +0 -5
  136. package/dist/chunk-VVPZMWJE.js +0 -1
  137. package/dist/chunk-ZZ64CEC2.js +0 -2
  138. package/dist/gold/index.d.ts +0 -283
  139. package/dist/gold/index.js +0 -1
  140. package/dist/icons/meanings.d.ts +0 -1
  141. package/dist/icons/meanings.js +0 -1
  142. package/dist/index.d.ts +0 -6
  143. package/dist/index.js +0 -1
  144. package/dist/markup/index.d.ts +0 -1
  145. package/dist/markup/index.js +0 -1
  146. package/dist/shell/index.d.ts +0 -195
  147. package/dist/shell/index.js +0 -1
  148. package/dist/strings/catalogue.d.ts +0 -139
  149. package/dist/strings/catalogue.js +0 -1
@@ -0,0 +1,62 @@
1
+ import{cloneNodeWithFreshIds as e}from"./chunk-2GVCAIPX.js";import{dedupeSlotChildren as n}from"./chunk-26OOWIJJ.js";import{styleClipboardOf as t}from"./chunk-VEZPDGDQ.js";import{markedTreeNodeId as o,revealSelectedTreeRow as r,sameSelector as i}from"./chunk-FGNR22NY.js";import{scrollPreviewToSection as l,gotoPreviewSlide as s,scrollPreviewToTop as d}from"./chunk-4ES5JGGX.js";import{useEaselKeyTarget as a,useEaselUndoKeys as c,useEaselSaveKey as p,editorRootFocus as u}from"./chunk-YLQYEDUQ.js";import{SlotChildActionsProvider as h}from"./chunk-KCBEE2MC.js";import{screenStorageKeys as f,DEFAULT_PANEL_W as m,clampPanelWidth as g}from"./chunk-U277UX5I.js";import{usePartBridge as y}from"./chunk-YI4QXOVJ.js";import{useSectionOps as k}from"./chunk-A7FF65FL.js";import{ScreenSaveIcon as v,ScreenMainButton as S}from"./chunk-7TOQCTHV.js";import{useBrowserOffline as b}from"./chunk-RKTF5XLP.js";import{AddChildRow as w}from"./chunk-5545A3PC.js";import{AddSidePanel as x}from"./chunk-BRMYJBMB.js";import{keepsSharedSections as z,sharedSectionsOf as C}from"./chunk-43AEUUNQ.js";import{SidePanelHead as O,PanelShowStrip as B}from"./chunk-XDZHKYQX.js";import{offeredChoices as I}from"./chunk-M2Z775ZC.js";import{MediaSidePanel as N}from"./chunk-WOETW3H6.js";import{useScreenSaveSwitch as P,useScreenNodeKeys as $,useScreenPinned as M,useScreenDocumentLabel as j,useScreenCanvasFrame as T,useScreenInspectorPanel as A,useScreenDevices as L,useScreenPickFollowsSelection as R,useScreenLeftView as E,SELECTION_MODE as F,sameInspectorMode as V,useScreenBridges as H,useScreenBlockRules as D,useScreenBlockLook as W,useScreenStorageNamespace as U,useScreenNotify as G,useScreenCanvasHead as Y,isSlotMode as X,useScreenStyleClipboard as J,useScreenDocumentPass as Q,useScreenCanvasDrag as K,ScreenCanvasTargetProvider as Z,isPinnedFirst as q,isPinnedLast as _,screenSlotsOf as ee}from"./chunk-XHSGRH42.js";import{useNodeClipboard as ne,useNodeContextMenu as te}from"./chunk-RFE7ZG3Y.js";import{PageEditGuardNotices as oe}from"./chunk-HGV3FWOB.js";import{useScreenDocument as re}from"./chunk-STWSCR25.js";import{requestMediaPick as ie}from"./chunk-KG7RJWOK.js";import{useMediaPanel as le,usePanelPick as se,useCancelPanelPick as de}from"./chunk-R6WTQWAC.js";import{useEaselSession as ae}from"./chunk-O7Q4DDJT.js";import{useEaselHost as ce,useHostEscape as pe}from"./chunk-U3JP4VGF.js";import{LayersIcon as ue,MediaIcon as he}from"./chunk-4VJATVVR.js";import{DEFAULT_SCREEN_WORDS as fe}from"./chunk-C2RHV42O.js";import{heldStyle as me,styleShortcut as ge}from"./chunk-V7U33NF2.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as ye}from"./chunk-6WY6ZXJG.js";import{rootRowName as ke,slotChildRowName as ve,slotChildRenameProp as Se,sectionRenameProp as be}from"./chunk-BHRC3ASL.js";import{ROOT_ZONE as we,blockNodeActions as xe,TREE_MAX_DEPTH as ze,childSlotsOf as Ce,slotFieldsOf as Oe,slotChildrenIn as Be,nestsInTree as Ie,newNodeId as Ne}from"./chunk-PLVEGYK6.js";import{useEasel as Pe,useEaselApi as $e,CanvasPassThroughContext as Me,CanvasSharedContext as je}from"./chunk-QEAUF632.js";import{TreeRow as Te,Subtree as Ae,LayersTree as Le,TreeGroupLabel as Re,TreeRowAction as Ee,TreeSeam as Fe}from"./chunk-A6Z4SD3I.js";import{DEFAULT_TREE_WORDS as Ve}from"./chunk-K56YDHYQ.js";import{DEFAULT_NODE_MENU_WORDS as He}from"./chunk-WK3AFPXY.js";import{toItemSelector as De,useNodeOps as We,clickPick as Ue}from"./chunk-X3TYRF5V.js";import{EaselTopBar as Ge,TopBarRail as Ye,TopBarCluster as Xe,EaselIconButton as Je,TopBarDivider as Qe,DeviceSwitch as Ke,InspectorIconButton as Ze,PanelResizeHandle as qe,MAX_PANEL_W as _e,MIN_PANEL_W as en,panelWidthVars as nn}from"./chunk-GWIVPLOX.js";import{DEFAULT_NOTICE_WORDS as tn,DEFAULT_CHROME_WORDS as on}from"./chunk-Z6PVRXVY.js";import{holderOf as rn,nameOrSomeone as ln}from"./chunk-THWO5YVZ.js";import{DEFAULT_LOCK_WORDS as sn}from"./chunk-RE4LP46F.js";import{useWords as dn}from"./chunk-MFIRYGHW.js";import{insertSeams as an,CanvasDragLayer as cn,CanvasInsert as pn}from"./chunk-LLDHIBYG.js";import{DEFAULT_DRAG_WORDS as un}from"./chunk-KAML3KQH.js";import{createDragSession as hn,useTreeDrag as fn,gapToMoveIndex as mn}from"./chunk-67GNT6PF.js";import{useCanvasFrame as gn,LIST_SELECTOR as yn,BLOCK_SELECTOR as kn,useCanvasTyping as vn,useCanvasEvent as Sn,nodeIdAt as bn,frameRectToHost as wn,BLOCK_ATTRIBUTE as xn,drawnBox as zn}from"./chunk-X4T6JT3M.js";import{ROOT_ID as Cn,ROOT_SLOT as On,zoneKey as Bn,parseZoneKey as In,find as Nn,DataError as Pn}from"./chunk-KRXQM65X.js";import{useRef as $n,useMemo as Mn,useState as jn,useEffect as Tn,useCallback as An,useLayoutEffect as Ln,Fragment as Rn,useId as En}from"react";import{ColoredBadge as Fn,toast as Vn,Tooltip as Hn,groupColors as Dn,Dialog as Wn,FormField as Un,Input as Gn,Button as Yn}from"efficient-shell/ui";import{UndoIcon as Xn,RedoIcon as Jn,RefreshIcon as Qn,AddIcon as Kn,TrashIcon as Zn,EyeOffIcon as qn,EyeIcon as _n,SharedIcon as et,DuplicateIcon as nt}from"efficient-shell/icons/efficient";import{jsx as tt,jsxs as ot,Fragment as rt}from"react/jsx-runtime";function it({name:e,onMake:n,onCancel:t}){const o=dn("screen",fe).shared,[r,i]=jn(e),[l,s]=jn(!1),d=En(),a=$n(null),c=async()=>{const e=r.trim();if(e&&!l){s(!0);try{await n(e)}finally{s(!1)}}};/* @__PURE__ */
2
+ return tt(Wn,{open:!0,size:"sm",title:o.makeShared,description:o.makeSharedHint,onClose:t,initialFocus:a,footer:/* @__PURE__ */ot(rt,{children:[
3
+ /* @__PURE__ */tt(Yn,{variant:"secondary",onClick:t,children:o.cancel}),
4
+ /* @__PURE__ */tt(Yn,{variant:"primary",loading:l,disabled:!r.trim(),onClick:()=>{c()},children:o.makeShared})]}),children:/* @__PURE__ */tt("form",{onSubmit:e=>{e.preventDefault(),c()},children:/* @__PURE__ */tt(Un,{label:o.name,htmlFor:d,children:/* @__PURE__ */tt(Gn,{id:d,ref:a,value:r,onChange:e=>i(e.target.value)})})})})}var lt=/* @__PURE__ */new WeakSet;function st(e,n,t){const o=Nn(e,n,t);if(!o)return null;const r=o.path.find(e=>"root"!==e.parentId);return r?r.parentId:t}function dt({canvas:e,tabs:n,onSelect:t}){const o=$n(null),[r,i]=jn({}),l=n.map(e=>`${e.id}:${e.below?1:0}`).join("|");return Ln(()=>{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=wn(l,{left:0,top:0,width:r.innerWidth,height:r.innerHeight},e),a={};for(const o of n){const n=t.querySelector(`[${xn}="${r.CSS?.escape?r.CSS.escape(o.id):o.id}"]`),i=n?zn(n):null;if(!i||0===i.height){a[o.id]=null;continue}const s=wn(l,{left:i.left,top:i.top,width:i.width,height:i.height},e),c=s.top+s.height;if(c<d.top||s.top>d.top+d.height){a[o.id]=null;continue}const p=o.below?c+4:Math.max(s.top,d.top)+6;a[o.id]={left:Math.max(s.left,d.left)+6,top:p}}i(a)},a=()=>{s||(s=r.requestAnimationFrame(d))};d(),r.addEventListener("scroll",a,!0),r.addEventListener("resize",a);const c=new r.MutationObserver(a);return c.observe(t.body,{childList:!0,subtree:!0,attributes:!0}),()=>{s&&r.cancelAnimationFrame(s),r.removeEventListener("scroll",a,!0),r.removeEventListener("resize",a),c.disconnect()}},[e,l]),/* @__PURE__ */tt("div",{ref:o,className:"es-band-tabs","aria-hidden":"true",children:n.map(e=>{const n=r[e.id];return n?/* @__PURE__ */tt("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:e.reach?
5
+ /* @__PURE__ */tt(Hn,{content:e.reach,children:/* @__PURE__ */ot(Fn,{colorClass:Dn("success","solid"),size:"sm",children:[
6
+ /* @__PURE__ */tt("span",{className:"es-band-tab-mark",children:/* @__PURE__ */tt(et,{size:12})}),e.label]})}):/* @__PURE__ */tt(Fn,{colorClass:Dn("info","solid"),size:"sm",children:e.label})},e.id):null})})}function at({expand:e}){/* @__PURE__ */
7
+ return tt("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round",children:/* @__PURE__ */ot(rt,e?{children:[
8
+ /* @__PURE__ */tt("path",{d:"M8 9l4-4 4 4"}),
9
+ /* @__PURE__ */tt("path",{d:"M8 15l4 4 4-4"})]}:{children:[
10
+ /* @__PURE__ */tt("path",{d:"M8 4l4 4 4-4"}),
11
+ /* @__PURE__ */tt("path",{d:"M8 20l4-4 4 4"}),
12
+ /* @__PURE__ */tt("path",{d:"M5 12h14"})]})})}var ct=`${yn}, ${kn}`;function pt(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 ut="__rungs";var ht="screen:band",ft={duplicate:!0,delete:!0};function mt(){const yn=ce(),{target:wn,docId:xn,capabilities:zn,currentSlug:En,siteId:Hn,onPublish:Dn,saveState:Wn,saveConflict:Un,retrySave:Gn,toggleAutoSave:Yn,flushSave:et,access:mt,saveUnreachable:gt=!1,readOnly:yt,readOnlyReason:kt=null}=re(),vt=P(),St=$(),{mediaEditing:bt,hasEditGuard:wt,hasPinnedChrome:xt}=zn,{appState:zt,dispatch:Ct,history:Ot,selectedItem:Bt,getSelectorForId:It,config:Nt}=Pe(e=>e),Pt=M(),{first:$t,firstGroup:Mt,lastGroup:jt,isSectionGroup:Tt,sectionGroupZone:At,panelOf:Lt}=Pt,Rt=Lt($t),Et=e=>q(Pt,e),Ft=e=>_(Pt,e),Vt="node"===Pt.firstRow,Ht=Pt.band??null,Dt=dn("screen",fe),Wt=dn("tree",Ve),Ut=dn("drag",un),Gt=dn("notice",tn),Yt=dn("lock",sn),Xt=dn("menu",He),Jt=dn("styleClipboard",ye),Qt=dn("chrome",on),Kt=j()??`/${En}`,Zt=T(),qt=A(),_t=k({readOnly:yt}),eo=k({readOnly:yt,foldIntoHistory:!0}),no=$n(null),to=$e(),oo=Mn(()=>({..._t,select:e=>{no.current=e,_t.select(e)},commitDocument:(e,n)=>{if(void 0!==n){const t=to.config;no.current=De(e,t,n)}_t.commitDocument(e,n)}}),[_t,to]),ro=zt.ui,io=ro.leftSideBarVisible,lo=ro.rightSideBarVisible,{options:so,widths:ao,initial:co,fluid:po,fit:uo}=L(),[ho,fo]=jn(co),mo=le(),go=bt&&null!==mo,yo=se(),ko=de();R(Bt?.props.id);const{read:vo,write:So,forSelection:bo}=E(),[wo,xo]=jn(vo);Tn(()=>{So(wo)},[wo]);const[zo,Co]=jn(0),Oo=$n(null),Bo=$n(null),Io=gn(Bo,{readySelector:ct}),No=vn(Io),Po=a(Bo);c(Bo,Io);const $o=b(),Mo=rn(mt),jo={state:Wn,offline:$o||Wn.failed&&gt,readOnlyReason:kt,editing:Mo?Gt.editing({name:ln(Mo.name,Yt),noun:Dt.noun}):null,conflict:null!=Un,notSaving:Dt.bar.notSaving},To=()=>{yt||(Wn.failed?Gn():et())};p(Bo,Io,To);const[Ao,Lo]=jn(!1),Ro=$n(!1),Eo=$n(!1),[Fo,Vo]=jn(null),[Ho,Do]=jn([]),[Wo,Uo]=jn(F),Go="puck"===Wo.kind,Yo=o(Wo,Bt?.props.id),[Xo,Jo]=jn(null);Tn(()=>{Xo&&(r(),Jo(null))},[Xo]);const Qo=$n(It);Qo.current=It;const Ko=An((e,{scroll:n})=>{xo(n=>bo(e,n)),n&&Jo(e);const t=[];let o=e;for(let e=0;e<4;e++){const e=Qo.current(o)?.zone;if(!e||!e.includes(":"))break;const n=e.split(":")[0];t.push(n),t.push(e),o=n}0!==t.length&&Cr(e=>{if(t.every(n=>!e.has(n)))return e;const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},[]),Zo=$n(null);Tn(()=>{const e=Zo.current;Zo.current=null;const n=null==Bt?.props.id?null:String(Bt.props.id);Uo(t=>e&&e.id===n?e.mode:"part"===t.kind&&"nodeId"in t&&t.nodeId===n?t:Lt(Bt?.type)??F);const t=Bt?.props.id,o=no.current;if(no.current=null,!t)return;const r=It(t);Ko(String(t),{scroll:!i(o,r??null,we)})},[Bt?.props.id,Ko]);const qo=An(e=>{Uo(n=>V(n,e)?n:e),Ct({type:"setUi",ui:{rightSideBarVisible:!0}})},[Ct]),_o=$n(()=>{});_o.current=(e,n)=>{const t=e?wi(e.zone??we)[e.index]?.props.id:null,o=null==t?null:String(t),r=null==Bt?.props.id?null:String(Bt.props.id);Uo(e=>V(e,n)?e:n),o!==r&&(Zo.current={id:o,mode:n},oo.select(e))};const er=An((e,n)=>_o.current(e,n),[]),nr={kind:Wo.kind,mode:Wo,open:qo,show:e=>Uo(e),reveal:()=>{lo||Ct({type:"setUi",ui:{rightSideBarVisible:!0}})},select:er},tr=H(nr,{data:zt.data,selected:Bt??null,zoneOf:e=>It(e)?.zone,readOnly:Boolean(yt),select:e=>{Uo(F),oo.select({index:e})},replace:(e,n)=>oo.replaceComponent(we,e,n),scrollTo:e=>l(e)},{device:ho,refreshes:zo},{setView:xo,reveal:()=>{io||Ct({type:"setUi",ui:{leftSideBarVisible:!0}})}}),or=tr.resolveLeftView?tr.resolveLeftView(wo,go):"media"===wo&&go?wo:"sections",rr=D(),{isLockedBlock:ir,duplicateBlocked:lr,nestDepth:sr,newSectionNode:dr,canAddTo:ar,blockIsOffered:cr}=rr,pr=W(),{labelAtLevel:ur,Icon:hr,useProducts:fr}=pr,mr=pr.rowName?(e,n,t)=>pr.rowName(e,n,t):void 0,gr=An(e=>{Ct({type:"setUi",ui:{rightSideBarVisible:!0}}),l(e),Ko(e,{scroll:!0})},[Ct,Ko]),{selectNode:yr,openPartId:kr}=y({mode:Wo,setMode:Uo,onOpenPart:gr}),[vr,Sr]=jn(null);pe(null!==vr,()=>Sr(null));const br=f(U()),wr=br.collapsed,xr=br.panelWidths,[zr,Cr]=jn(()=>{if("undefined"==typeof window)/* @__PURE__ */return new Set;try{const e=window.localStorage.getItem(wr);return new Set(e?JSON.parse(e):[])}catch{/* @__PURE__ */
13
+ return new Set}});Tn(()=>{try{window.localStorage.setItem(wr,JSON.stringify([...zr]))}catch{}},[zr]);const[Or,Br]=jn(()=>{if("undefined"==typeof window)return{...m};try{const e=window.localStorage.getItem(xr);if(!e)return{...m};const n=JSON.parse(e);return{left:g(Number(n.left)||m.left),right:g(Number(n.right)||m.right)}}catch{return{...m}}});Tn(()=>{const e=setTimeout(()=>{try{window.localStorage.setItem(xr,JSON.stringify(Or))}catch{}},300);return()=>clearTimeout(e)},[Or]);const Ir=An((e,n)=>Br(t=>{const o="function"==typeof n?n(t[e]):n;return t[e]===o?t:{...t,[e]:o}}),[]),Nr=An(e=>Ir("left",e),[Ir]),Pr=An(e=>Ir("right",e),[Ir]),$r=e=>zr.has(e),Mr=e=>Cr(n=>{const t=new Set(n);return t.has(e)?t.delete(e):t.add(e),t}),jr=$n(!1),Tr=$n(null);Tn(()=>{if(jr.current&&!Ao){const e=Tr.current,n=e&&e.isConnected&&!e.closest('[aria-hidden="true"]')?e:null;(n??Bo.current?.querySelector(`button[aria-label="${CSS.escape(Dt.add.title)}"]`))?.focus(),Tr.current=null}jr.current=Ao},[Ao]),Tn(()=>{if(!Ao||!Po)return;const e=e=>{"Escape"===e.key&&el()};return Po.addEventListener("keydown",e),()=>Po.removeEventListener("keydown",e)},[Ao,Po]),pe(Ao,()=>el()),Tn(()=>{!io&&Ao&&(Lo(!1),Vo(null),Ro.current=!1)},[io]),Tn(()=>{if(!yo)return Eo.current&&Ct({type:"setUi",ui:{leftSideBarVisible:!1}}),void(Eo.current=!1);Ao&&(Lo(!1),Vo(null),Eo.current=Ro.current,Ro.current=!1),io||(Eo.current=!0,Ct({type:"setUi",ui:{leftSideBarVisible:!0}}))},[yo]),Tn(()=>{!io&&yo&&(Eo.current=!1,ko())},[io]),Tn(()=>{if(!yo||!Po)return;const e=e=>{"Escape"===e.key&&ko()};return Po.addEventListener("keydown",e),()=>Po.removeEventListener("keydown",e)},[yo,Po]),pe(null!==yo,()=>ko());const Ar=G(),Lr=(e,n="success",t)=>{if(Ar)return void(t?Ar(e,"error"===n?"error":"info",t):Ar(e,"error"===n?"error":"info"));const o={sound:!1,action:t?.action,onClose:t?.onClose};"error"===n?Vn.error(e,{...o,duration:t?.duration??3200}):Vn.success(e,{...o,duration:t?.duration??1900})},Rr=$n(null),[Er,Fr]=jn(0),[Vr,Hr]=jn(0),Dr=Y(),Wr=$n(null),Ur=e=>Math.max(0,e.clientHeight-(Wr.current?.offsetHeight??0));Tn(()=>{const e=Rr.current;if(!e)return;const n=()=>{Fr(e.clientWidth),Hr(Ur(e))};n();const t=new ResizeObserver(n);return t.observe(e),Wr.current&&t.observe(Wr.current),()=>t.disconnect()},[]),Ln(()=>{Rr.current&&(Fr(Rr.current.clientWidth),Hr(Ur(Rr.current)))},[Or,io,lo]);const Gr=ho===po?Er>0?Er:ao[po]:ao[ho],Yr=Er>0?Math.min(Er/Gr,"shrink"===uo?1:2):1,Xr=Gr*Yr,Jr=Er>0&&Xr>Er+1,Qr={width:Xr,height:Vr||"100%",flex:"none",position:"relative"},Kr={width:Gr,height:Vr?Vr/Yr:"100%",maxHeight:"none",transform:1!==Yr?`scale(${Yr})`:void 0,transformOrigin:"top left"},Zr=()=>Ct({type:"setUi",ui:{leftSideBarVisible:!io}}),qr=()=>Ct({type:"setUi",ui:{rightSideBarVisible:!lo}}),_r=e=>{Ao&&(Lo(!1),Vo(null),Ro.current=!1,io&&wo===e)||yo&&(Eo.current=!1,ko(),io&&wo===e)||(io&&wo===e?Zr():(xo(e),io||Ct({type:"setUi",ui:{leftSideBarVisible:!0}})))},ei=()=>{ie(yn,{accept:"image/*",title:Qt.mediaLibrary})},ni=()=>{Uo(F),oo.select(null),d()},ti=()=>{Uo(Rt??F),lo||Ct({type:"setUi",ui:{rightSideBarVisible:!0}})},oi=zt.data.content??[],ri=()=>{const e=oi.findIndex(Et),n=oi.findIndex(Ft);return{floor:e>=0?e+1:0,cap:n>=0?n:oi.length}},ii=Nt,li=rr.stripCopy,si=n=>e(n,li),di=ne(),ai=We({data:zt.data,config:ii,readOnly:Boolean(yt),clipboard:di,strip:li?e=>li(e):void 0,afterRemove:"none",stepBounds:(e,n)=>{if(e.parentId!==Cn||e.slot!==On)return{min:0,max:n-1};const{floor:t,cap:o}=ri();return{min:t,max:o-1}},commit:(e,{select:n})=>{void 0!==n&&Uo(F);const t=void 0===n||"node"===n?.kind?n:null;oo.commitDocument(e,t)}}),ci=ae(),[pi,ui]=jn(null),hi=e=>{const n=oi.find(n=>String(n.props.id)===e),t=Pt.shared;n&&t&&ai.swap(e,t.detach(n))},fi=e=>{const n=Nn(zt.data,Nt,e);if(!n)return!1;const t=Bn(n.place),o=n.node,r=t===we?vi(o):ji(o),i=t===we?Pt.shared?.usedOn(o):null;return!!ai.remove(e)&&(Lr(i?Dt.shared.removed({count:Math.max(0,i.length-1)}):Dt.deleted({name:r}),"success",{duration:8e3,action:{label:Dt.bar.undo,onClick:()=>{ai.restore(n.node,n.place)}}}),!0)},mi={...ai,remove:fi},gi=e=>ur(e,"block",Nt.components[e]?.label??e),yi=An(e=>Nt.components[e]?.defaultProps??{},[Nt]),ki=e=>ur(e,"section",gi(e)),vi=e=>ke({type:e.type,props:e.props??{}},ki(e.type),mr),{nodeAddresses:Si,zoneItems:bi}=Mn(()=>{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>=ze)return;const s=/* @__PURE__ */new Map;for(const{child:e,zone:t}of Ce(Nt,n))s.set(t,[...s.get(t)??[],e]);for(const[e,n]of s)t(n,e,i+1)})};return t(oi,we,0),{nodeAddresses:e,zoneItems:n}},[oi,Nt]),wi=An(e=>bi.get(e)??[],[bi]),xi=e=>{const n=Si.get(e);return n?wi(n.zone)[n.index]:void 0},zi=e=>ee(rr,Nt,e),Ci=e=>{if(!rr.slotsOf||e===we)return null;const n=e.lastIndexOf(":");if(n<=0)return null;const t=xi(e.slice(0,n));if(!t)return null;const o=zi(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}},Oi=(()=>{if(!X(Wo))return null;const e=`${Wo.nodeId}:${Wo.slot}`;return Ci(e)?.slot.panel===Wo.kind?e:null})(),Bi=$n(null);Tn(()=>{const e=Bi.current;if(Bi.current=null,!Oi||!X(Wo))return;const n=Wo.nodeId;Ko(n,{scroll:e!==Oi}),Cr(e=>{if(!e.has(n))return e;const t=new Set(e);return t.delete(n),t})},[Wo]);const Ii=(e,n,t)=>{const o=String(e.props.id);if(!n.panel)return void(e=>{const n=Si.get(e);n&&(n.zone===we?Xi(n.index):Sl(n.zone,n.index,e,xi(n.zone.slice(0,n.zone.lastIndexOf(":")))?.type??""))})(o);const r={kind:n.panel,nodeId:o,slot:n.slot},i=`${o}:${n.slot}`;t&&Oi!==i&&(Bi.current=i),er(null,r),lo||Ct({type:"setUi",ui:{rightSideBarVisible:!0}}),l(o)},Ni=(e,n,t)=>{const o=`${e}:${n}`;if(Cr(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;Oi!==o&&(Bi.current=o);er(null,{kind:t,nodeId:e,slot:n})},Pi=(e,n,t)=>{if(yt||!rr.moveSlot)return;const o=xi(e),r=o?zi(o).filter(e=>e.rung):[],i=r[n];if(!i)return;const l={parentId:e,slot:ut,index:n},s=mn(l,{...l,index:Math.min(Math.max(t,0),r.length)});if(s===n)return;const d=rr.moveSlot(e,n,s);"string"==typeof d&&Ni(e,d,i.panel)},$i=fr(),Mi=Mn(()=>{const e=/* @__PURE__ */new Map;for(const n of $i??[])e.set(n.slug,n.name);return e},[$i]),ji=e=>ve(e,gi,pr.plainText,e=>Mi.get(e),pr.rowName),Ti=(e,n)=>{const t=Nt.components[e.type]?.fields,o=n===we||Yl(n)?"section":"block",r=n===we&&(Et(e)||Ft(e)||Tt(e.type)),i="block"===o?Se(t):r?null:be(t);return pr.renamePropOf?pr.renamePropOf(e,o,i):i},Ai=(e,n,t,o)=>{if(!(!yt&&vr?.zone===e&&vr.index===n))return;const r=(t,o)=>{Sr(null),o&&((e,n,t)=>{const o=wi(e)[n];if(!o)return;const r=Ti(o,e);r&&oo.replaceComponent(e,n,{...o,props:{...o.props,[r]:t.trim()}})})(e,n,t)};/* @__PURE__ */
14
+ return tt("input",{className:"es-tree-rename",defaultValue:o,autoFocus:!0,"aria-label":Dt.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)},Li=t(J(),Jt),Ri=Li.scope({target:wn,siteId:Hn,docId:xn}),Ei=Nt,Fi=(e,n)=>n===we?ki(e):gi(e),Vi=(e,n,t)=>{const o=Li.plan(Ri,t,Fi(t.type,e),Ei);o&&(o.changed&&oo.replaceComponent(e,n,{...t,props:{...o.props,id:t.props.id}}),Lr(o.message))},Hi=te({nodesIn:wi,nodeAt:(e,n)=>wi(e)[n]??null,labelOf:(e,n)=>n===we?ki(e):gi(e),renamePropOf:Ti,beginRename:(e,n)=>Sr({zone:e,index:n}),history:{hasPast:Ot.hasPast,hasFuture:Ot.hasFuture,back:()=>Ot.back(),forward:()=>Ot.forward()},openPageSettings:()=>{oo.select(null),Uo(F)},pageSettingsLabel:Dt.pageSettings,words:{menu:Xt,styleClipboard:Jt,screen:Dt.menu},readOnly:Boolean(yt),collapseAll:()=>Cr(new Set(wi(we).map(e=>String(e.props.id)))),onPasteRefused:e=>Lr(e?Dt.pasteRefused({name:e.label}):Dt.menu.clipboardRefused,"error"),canPasteAt:(e,n)=>Ql(e,n),menuRows:(e,n,t)=>{const o=tr.menuRows?.(e,n,t)??null,r=((e,n)=>{const t=Pt.shared;if(!t||n!==we)return null;const o=t.usedOn(e);if(o){const n={pick:[{label:Dt.shared.onPages({count:o.length}),onClick:()=>{},children:o.map(e=>({label:e.title,onClick:()=>t.openPage(e)}))}]};return yt?n:{...n,change:[{label:Dt.shared.detach,onClick:()=>hi(e.props.id)}],remove:[{label:Dt.shared.removeFromPage,danger:!0,onClick:()=>{fi(e.props.id)}}]}}return yt||Et(e)||Ft(e)||Tt(e.type)?null:z(ci)?{change:[{label:Dt.shared.makeShared,onClick:()=>ui({id:e.props.id,name:vi(e)})}]}:null})(e,n);if(!r)return o;return Object.fromEntries(["pick","make","change","remove"].map(e=>[e,[...o?.[e]??[],...r[e]??[]]]).filter(([,e])=>e.length>0))},isLocked:e=>ir(e.type),duplicateBlocked:e=>lr(zt.data,e),permits:e=>{const n=xe(Nt,e.type);return Pt.shared?.usedOn(e)?{...n,delete:!1}:n},nodeOps:mi,isPinned:(e,n)=>n===we&&(Et(e)||Ft(e)),sectionBand:ri,locate:e=>Si.get(e)??null,rowNameOf:(e,n)=>n===we?vi(e):ji(e),selectAt:(e,n,t,o)=>{e===we?Xi(n):Sl(e,n,t,o??"")},slotRung:e=>{const n=Ci(e);return n?.slot.panel?{label:n.slot.label,select:()=>Ii(n.node,n.slot,!1)}:null},style:{held:()=>me(Ri),canCopy:e=>Li.rows(Ei,e).some(e=>!1!==e.counted),copy:(e,n)=>Li.copy(Ri,e,Fi(e.type,n),Ei),paste:(e,n,t)=>Vi(e,n,t)},keys:St?{target:Po,selected:()=>{const e=zt.ui.itemSelector;return e?{zone:e.zone??we,index:e.index}:null},held:()=>di.get(),readOnly:Boolean(yt),onDone:({done:e,name:n})=>{"copied"===e&&Lr(Dt.copied({name:n}))}}:void 0},Io),Di=$n({copy:(e,n)=>{},paste:(e,n,t)=>{},at:()=>null,readOnly:!1});Tn(()=>{Di.current={copy:(e,n)=>Li.copy(Ri,e,Fi(e.type,n),Ei),paste:Vi,at:()=>{const e=zt.ui.itemSelector;if(!e)return null;const n=e.zone??we,t=wi(n)[e.index];return t?{zone:n,index:e.index,node:t}:null},readOnly:Boolean(yt)}});const Wi=An(e=>{const n=ge(e);if(!n)return;const t=Di.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))},[]);Tn(()=>{if(!Po)return;const e=e=>Wi(e);return Po.addEventListener("keydown",e),()=>Po.removeEventListener("keydown",e)},[Wi,Po]),Sn(Io,"keydown",Wi);const Ui=oi.map(e=>e.props.id).join("|");Tn(()=>{const e=Io?.document??null,n=Io?.window??null;let t=0;const o=[],r=()=>{if(!e)return void Do(e=>e.length?[]:e);const n=oi.findIndex(Ft),t=n>=0?n:oi.length,o=n=>{const t=oi[n]?.props?.id;return null==t?null:e.querySelector(`[data-puck-component="${CSS.escape(String(t))}"]`)},r=e=>e?[...e.querySelectorAll(kn)].map(e=>e.getBoundingClientRect()).filter(e=>e.width>0||e.height>0):[],i=[];for(let e=oi.length>0&&!Et(oi[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=pt(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})}Do(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()}},[Io,Ui,ho,Yr,io,lo,Bt?.props.id]);const Gi=Io?.document??null,Yi=Io?.window??null;Tn(()=>{const e=Oo.current;if(!e||!Gi||!Yi)return;const n=[],t=()=>{const n=Gi.querySelector(`[data-puck-component="${CSS.escape(e.id)}"]`);if(!n)return!1;const t=n.getBoundingClientRect().top-e.offset;return Math.abs(t)>1&&Yi.scrollTo({left:Yi.scrollX,top:Yi.scrollY+t,behavior:"instant"}),!0};return Oo.current=null,t()&&n.push(setTimeout(t,150),setTimeout(t,450)),()=>n.forEach(clearTimeout)},[Gi,Yi]);const Xi=e=>{Uo(F),oo.select({index:e}),tr.sectionPressed?.(oi[e]);const n=oi[e]?.props?.id;n&&l(n)},Ji=e=>{const{floor:n,cap:t}=ri(),o=e=>Math.min(Math.max(n,e),t);if("number"==typeof e)return o(e);const r=Bt&&Wo.kind!==Rt?.kind?oi.findIndex(e=>e.props.id===Bt.props.id):-1;return o(r>=0?r+1:t)},Qi=(e,n)=>{const{floor:t,cap:o}=ri(),r=Math.min(Math.max(n,t),o),i=e<r?r-1:r;return i===e?{moved:!1,dest:e}:(oo.reorderComponent(we,e,i),oo.select({index:i}),{moved:!0,dest:i})},Ki=(e,n,t,o)=>{Uo(F),oo.select(o?{index:o.index,zone:o.zone}:{index:e}),l(n),Lr(Dt.sectionAdded({name:t}))},Zi=(e,n)=>{const t=Ji(n),o=dr(e,{nodeDefaults:yi,newNodeId:Ne,sectionLabel:ki,blockIsOffered:cr}),r=o?oo.insertNode(we,t,o):oo.insertSection(e,t);return Ki(t,r,ki(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:a}of Ce(Nt,e)){if(s.type===t&&(!o.at||n>o.at.depth)){const r=ar(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:a,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},qi=e=>_i(we,e),_i=(e,n)=>{Tr.current=document.activeElement??null,yo&&(Ro.current=Eo.current,Eo.current=!1,ko()),Vo(null===n?null:{zone:e,index:n}),Lo(!0),io||(Ro.current=!0,Ct({type:"setUi",ui:{leftSideBarVisible:!0}}))},el=()=>{Lo(!1),Vo(null),Ro.current&&Ct({type:"setUi",ui:{leftSideBarVisible:!1}}),Ro.current=!1},nl=(e,n)=>pr.rowName?n?Et(e)?pr.rowName(e,"section",Dt.header):Ft(e)?pr.rowName(e,"section",Dt.footer):Tt(e.type)?pr.rowName(e,"section",gi(e.type)):vi(e):ji(e):n?ki(e.type):gi(e.type),tl=e=>n=>{e()},ol=(e,n,t)=>{if(yt)return null;const o=wi(e)[n];return o&&!xe(Nt,o.type).delete?null:/* @__PURE__ */tt(Ee,{kind:"delete",label:e===we&&o&&Pt.shared?.usedOn(o)?Dt.shared.removeFromPage:Dt.deleteNamed({name:t}),onClick:()=>((e,n)=>{const t=wi(e)[n]?.props?.id;null!=t&&fi(String(t))})(e,n),children:/* @__PURE__ */tt(Zn,{size:15})})},rl=e=>pr.rowPreview?.(e)||void 0,il=e=>pr.rowMarks?.(e)??void 0,ll=(e,n,t)=>pr.rowActions?.(e,n,t)??null,sl=(e,n,t,o)=>{if(yt)return null;const r=Boolean(t.props._hidden);/* @__PURE__ */
15
+ return tt(Ee,{kind:"eye",label:r?Dt.showNamed({name:o}):Dt.hideNamed({name:o}),onClick:()=>al(e,n,t),children:/* @__PURE__ */tt(r?qn:_n,{size:14,strokeWidth:1.8,strokeLinecap:void 0,strokeLinejoin:void 0})})},dl=e=>Is(we,e),al=(e,n,t)=>{oo.replaceComponent(e,n,{...t,props:{...t.props,_hidden:!t.props._hidden}})},cl=e=>Oe(Nt,e),pl=e=>Ce(Nt,e),ul=e=>rr.slotsOf?zi(e).map(n=>({slot:n.slot,rung:n.rung?n:null,kids:Be(e,n.slot)})):[{slot:null,rung:null,kids:pl(e)}],hl=e=>rr.slotsOf?ul(e).flatMap(e=>e.kids):pl(e),fl=e=>Boolean(rr.slotsOf)&&zi(e).some(e=>e.rung),ml=(e,n,t)=>null===t?void 0===n?ar(e):ar(e,n):ar(e,n,t),gl=(e,n,t)=>{const o=Ie(Nt,e.type,n)&&(t||hl(e).length>0||fl(e));return{collapsible:o,folded:o&&$r(String(e.props.id))}},yl=(e,n,t)=>ul(e).flatMap(o=>{const r=o.rung?n+1:n,i=o.kids.flatMap(({child:e})=>gl(e,r,t(e.type)).collapsible?[String(e.props.id),...yl(e,r+1,t)]:[]);return o.rung?[`${e.props.id}:${o.rung.slot}`,...i]:i}),kl=e=>hl(e).length>0||fl(e)||Boolean(ar(e.type)),vl=e=>Boolean(ar(e)),Sl=(e,n,t,o)=>{if(Uo(F),ar(o)?.spec?.slider){const t=e.split(":")[0];s(t,n),oo.select({index:n,zone:e}),l(t)}else oo.select({index:n,zone:e}),l(t)},bl=(e,n,t,o,r)=>{const i=`${e}:${n}`;oo.insertComponent(i,t,o),ar(r)?.spec?.slider?requestAnimationFrame(()=>{s(e,o),oo.select({index:o,zone:i})}):oo.select({index:o,zone:i})},wl=$n(/* @__PURE__ */new Set);Tn(()=>{oi.forEach(e=>{const n=ar(e.type)?.spec;if(!n)return;const t=e.props.id;if(wl.current.has(t))return;wl.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(yi)).forEach((e,t)=>eo.seedChild(o,t,n.childType,e))})},[oi,eo,yi]);const xl=$n(/* @__PURE__ */new Set);Tn(()=>{oi.forEach((e,t)=>{const o=e.props.id;if(xl.current.has(o))return;const r=n(e,cl(e.type));xl.current.add(o),r&&eo.replaceComponent(we,t,{...e,props:r})})},[oi,eo]),Q(eo,Nt);const zl=oi.findIndex(Ft),Cl=zl>=0?oi[zl]:null,Ol=Vt?oi.findIndex(Et):-1,Bl=Ol>=0?oi[Ol]:null,Il=Pt.groupTab,Nl=Mn(()=>Il?e=>Tt(e.type):void 0,[Il]),Pl=Boolean(Pt.groupBadge),$l=Pt.sharedReach,Ml=e=>$l?.(e)??void 0,jl=Mn(()=>$l?new Set(oi.filter(e=>Ml(e)).map(e=>String(e.props.id))):null,[oi,$l]),Tl=Mn(()=>jl?e=>jl.has(e):void 0,[jl]),Al=Pt.first?$l?.({type:Pt.first,props:{id:""}})??void 0:void 0,Ll=Pt.groupBadge?/* @__PURE__ */tt("span",{className:"es-tree-group-badge",children:/* @__PURE__ */tt(Fn,{tone:"info",size:"xs",children:Pt.groupBadge})}):void 0,Rl=oi.find(e=>e.type===Mt)??null,El=oi.find(e=>e.type===jt)??null,Fl=zl>=0?zl:oi.length,Vl=[];oi.forEach(e=>{Ft(e)||(kl(e)&&Vl.push(String(e.props.id)),Vl.push(...yl(e,1,vl)))}),Cl&&(Vl.push(String(Cl.props.id)),Vl.push(...yl(Cl,1,vl)));const Hl=Vl.length>0&&Vl.every(e=>zr.has(e)),Dl=e=>{const n=pr.blockRowName(e,gi);return pr.rowName?pr.rowName(e,"block",n):n},Wl=(e,n,t,o)=>{const r=wi(e)[t];if(!r)return;const i={...In(e),index:t},l={...In(n),index:Math.min(Math.max(o,0),wi(n).length)},s=mn(i,l);if(e!==n||s!==t)try{ai.move(String(r.props.id),{...l,index:s})}catch(e){if(!(e instanceof Pn))throw e}},Ul=e=>{const n=/* @__PURE__ */new Set,t=e=>{for(const{child:o,zone:r}of pl(e))n.add(r),t(o)};for(const t of cl(e.type))n.add(`${e.props.id}:${t}`);return t(e),n},Gl=e=>{let n=e.slice(0,e.indexOf(":"));for(let e=0;e<64;e++){const e=Si.get(n);if(!e)return null;if(e.zone===we)return n;n=e.zone.slice(0,e.zone.indexOf(":"))}return null},Yl=e=>{const n=e.slice(0,e.indexOf(":")),t=oi.find(e=>Tt(e.type)&&String(e.props.id)===n);return t&&At(n)===e?t:null},Xl=(e,n)=>{const t=Yl(e);return!t||(!Pt.groupAccepts||Pt.groupAccepts(t.type,n,wi(e).length))},Jl=(e,n,t)=>{if(e.rung){const t=xi(e.rung.nodeId),o=t?zi(t).filter(e=>e.rung).length:0;return n.parentId===e.rung.nodeId&&n.slot===ut&&n.index>=0&&n.index<=o}if(n.slot===ut)return!1;if(e.add)return ql(e.add,n);const o=Bn(n);if(Tt(e.type))return!1;const r=Yl(o),i=Yl(e.zone);if(r||i)return!(!r||!i)&&(!(r!==i&&!Xl(o,e.type))&&(n.index>=0&&n.index<=wi(o).length));if(e.zone===we||o===we){if(e.zone!==o)return!1;const{floor:t,cap:r}=ri();return n.index>=t&&n.index<=r}if(n.index<0||n.index>wi(o).length)return!1;if(e.zone===o)return!0;const l=Cl&&!Pt.lastIsOpen?String(Cl.props.id):null;return(!l||Gl(e.zone)!==l&&Gl(o)!==l)&&((e,n,t,o)=>{if(e===n)return!0;const r=o??wi(e)[t];if(!r)return!1;const i=n.split(":")[0],l=Si.get(i),s=l?wi(l.zone)[l.index]:void 0;if(!s)return!1;if(!o&&Ul(r).has(n))return!1;const d=ar(s.type,sr(zt?.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?.(wi(n),r))})(e.zone,o,e.index,t)},Ql=(e,n)=>{const t=Bn(e.from),o=e.node;return t===Bn(n)?Xl(t,o.type):Jl({id:String(o.props?.id??""),zone:t,index:-1,type:o.type},n,o)},Kl=e=>{const n=e.slice(0,e.indexOf(":")),t=Si.get(n),o=t?wi(t.zone)[t.index]:void 0;if(!t||!o)return null;const r=ar(o.type,sr(zt?.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=I(r.choices??(r.spec?[{type:r.spec.childType,label:gi(r.spec.childType)}]:[])),l=Ci(e);return{parent:o,parentId:n,target:r,choices:i,parentName:l?l.slot.label:nl(o,t.zone===we)}},Zl=(e,n)=>{if("section"!==e.kind)return e;const t=Bn(n);return t===we||Yl(t)?e:Kl(t)?.choices.some(n=>n.type===e.type)?{kind:"block",type:e.type}:e},ql=(e,n)=>{const t=Zl(e,n),o=Bn(n);if("shared"===t.kind){if(o!==we||!Pt.shared?.nodeOf(t.section))return!1;const{floor:e,cap:r}=ri();return n.index>=e&&n.index<=r}if("block"!==t.kind){if(Yl(o)){const e="section"===t.kind?t.type:t.template.node.type;return Xl(o,e)&&n.index>=0&&n.index<=wi(o).length}if(o!==we)return!1;const{floor:e,cap:r}=ri();return n.index>=e&&n.index<=r}if(o===we)return!1;const r=Kl(o);return!(!r||!r.choices.some(e=>e.type===t.type))&&!r.target.spec?.addBlocked?.(wi(o))},_l=(e,n)=>{const t=Zl(e,n);if("block"!==t.kind&&Yl(Bn(n)))return void((e,n,t)=>{const o="section"===e.kind?e.type:"template"===e.kind?e.template.node.type:null;if(o&&Xl(n,o)){if("section"===e.kind)oo.insertComponent(n,e.type,t);else{if("template"!==e.kind)return;oo.insertNode(n,t,si(e.template.node))}Uo(F),oo.select({index:t,zone:n})}})(t,Bn(n),n.index);if("section"===t.kind)return void Zi(t.type,n.index);if("template"===t.kind)return void((e,n,t)=>{const o=Ji(t),r=oo.insertNode(we,o,n);Ki(o,r,e)})(t.template.name,si(t.template.node),n.index);if("shared"===t.kind){const e=Pt.shared?.nodeOf(t.section);if(!e)return;const o=Ji(n.index);return void(ai.restore(e,{parentId:Cn,slot:On,index:o})&&Ki(o,e.props.id,t.section.title))}const o=Bn(n),r=Kl(o);r&&(r.target.spec?bl(r.parentId,r.target.slot,t.type,n.index,r.parent.type):((e,n,t)=>{oo.insertComponent(e,n,t),Uo(F),oo.select({index:t,zone:e})})(o,t.type,n.index))},es=(e,n)=>{e.rung?Pi(e.rung.nodeId,e.index,n.index):e.add?_l(e.add,n):e.zone===we?Qi(e.index,n.index):Wl(e.zone,Bn(n),e.index,n.index)},[ns]=jn(()=>hn()),ts=fn({keyOf:e=>e.id,readOnly:Boolean(yt),session:ns,canDrop:Jl,onDrop:es,onStep:(e,n)=>{e.rung?Pi(e.rung.nodeId,e.index,n<0?e.index-1:e.index+2):e.zone===we?((e,n)=>{const t=ki(oi[e]?.type??""),o=Qi(e,n<0?e-1:e+2);if(!o.moved)return void Lr(n<0?Dt.sectionFirst({name:t}):Dt.sectionLast({name:t}));const{floor:r,cap:i}=ri();Lr(Dt.sectionMoved({name:t,n:o.dest-r+1,total:i-r}))})(e.index,n):Wl(e.zone,e.zone,e.index,n<0?e.index-1:e.index+2)}}),os=An(e=>{const{floor:n,cap:t}=ri(),o=[];for(const r of e.nodes){const e=Bn(r.place),i=wi(e)[r.place.index];if(!i||String(i.props.id)!==r.id)continue;if(Et(i)||Ft(i)||ir(i.type))continue;if(Tt(i.type))continue;const l=Boolean(Yl(e)),s=e===we||l;e===we&&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?ki(i.type):ji(i),from:r.place})}const r=e.zones.flatMap(e=>{const n=Bn(e.list);if(n===we&&0===e.children.length)return[{...e,addLabel:Dt.addSection,addAlways:!0}];const t=Kl(n),o=t?.target.spec?.addLabel;return e.children.length>0||Boolean(t?.choices.length)||Boolean(Yl(n))?[o?{...e,addLabel:o}:e]:[]}),i=r.flatMap(e=>{const n=Bn(e.list),t=n===we||Yl(n)?null:Kl(n);return t?.choices.length?an(e,t.target.spec?.addLabel??Dt.addBlockHere):[]});return{sources:o,zones:r,seams:i}},[zt.data]),rs=null==Bt?.props.id?null:String(Bt.props.id),is=An(e=>{const n=Nt,t=e=>!e.item.rung&&null!==Nn(zt.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(rs);return i||(r(Ue(zt.data,n,o.item.id,rs,Nl))??o)},[zt.data,Nt,rs,Nl]),[ls,ss]=jn(null),ds=Boolean(Il||$l);Sn(Io,"mouseover",e=>{if(!ds)return;const n=bn(e.target),t=n?st(zt.data,Nt,n):null;t!==ls&&ss(t)}),Sn(Io,"mouseout",e=>{ds&&!e.relatedTarget&&ss(null)});const as=e=>Et(e)||Ft(e)||Tt(e.type),cs=e=>{const n=Tt(e.type)?gi(e.type):Et(e)?Dt.header:Ft(e)?Dt.footer:null;return null===n?vi(e):pr.rowName?pr.rowName(e,"section",n):n},ps=[];if(ds){const e=rs?st(zt.data,Nt,rs):null;for(const n of/* @__PURE__ */new Set([e,ls])){const e=n?oi.find(e=>String(e.props.id)===n):void 0;if(!e)continue;const t=Et(e)||e.type===Mt,o=Ml(e);if(o){ps.push({id:String(e.props.id),label:cs(e),below:t,reach:o});continue}if(!Il||!as(e))continue;const r=Il(e);r&&ps.push({id:String(e.props.id),label:r,below:t})}}const us=ae(),hs=$n(null);Tn(()=>{const e=Pt.changeNotice;if(!e)return;const n=JSON.stringify(oi.filter(as)),t=hs.current;if(hs.current={doc:xn,bands:n,index:Ot.index},!t||t.doc!==xn||t.bands===n)return;Ot.hasPast&&Ot.index>=t.index&&!lt.has(us)&&(lt.add(us),Lr(e,"success",{action:{label:Dt.bar.undo,onClick:()=>Ot.back()},duration:8e3}))},[oi]);const fs=e=>{Uo(F),oo.select(e.zone===we?{index:e.index}:{index:e.index,zone:e.zone})},ms=K(),gs=()=>({data:zt.data,device:ho,ops:oo,inspector:nr}),ys=ms?.model,ks=Mn(()=>ys?e=>ys(e,os(e),gs()):os,[ys,os,ho]),vs=ms?.measure,Ss=vs?(e,n)=>vs(e,n,gs()):void 0,bs=ms?.canDrop,ws=bs?(e,n)=>bs(e,n,Jl,gs()):Jl,xs=ms?.drop,zs=xs?(e,n)=>xs(e,n,es,gs()):es,Cs=ms?.pick,Os=Cs?e=>Cs(e,fs,gs()):fs,Bs=e=>{const n=Bn(e),t=Ci(n);t&&Ii(t.node,t.slot,!1),_i(n,e.index)},Is=(e,n)=>/* @__PURE__ */tt(Fe,{...yt?{}:ts.seam({place:{...In(e),index:n}})},`seam:${e}:${n}`),Ns={rowClick:tl,isCollapsed:$r,toggleCollapse:Mr},Ps=e=>{const n=String(e.props.id),t=oi.findIndex(e=>String(e.props.id)===n),o=At(n),r=wi(o),i=$r(n),l=gi(e.type),s=pr.rowName?pr.rowName(e,"section",l):l,d=e=>Is(o,e);/* @__PURE__ */
16
+ return ot(rt,{children:[
17
+ /* @__PURE__ */tt(Te,{words:Wt,icon:/* @__PURE__ */tt(hr,{type:e.type,size:13}),name:s,preview:rl(e),marks:il(e),onSelect:()=>Xi(t),nameSlot:Ai(we,t,n,s),selected:Yo===n,badge:Ml(e)?void 0:Ll,shared:Ml(e),actions:ll(e,we,t)??void 0,rowProps:{"data-node-id":n,onClick:tl(()=>Xi(t))},fold:{open:!i,label:"section",onToggle:()=>Mr(n)}}),!i&&/* @__PURE__ */ot(Ae,{children:[r.map((n,t)=>{const r=String(n.props.id),i=vi(n),l=kl(n),s=l&&$r(r),a=()=>Sl(o,t,r,e.type),{rowProps:c,...p}=ts.row({item:{id:r,zone:o,index:t,type:n.type},place:{...In(o),index:t}},{"data-node-id":r,onClick:tl(a)});/* @__PURE__ */
18
+ return ot(Rn,{children:[d(t),
19
+ /* @__PURE__ */tt(Te,{words:Wt,icon:/* @__PURE__ */tt(hr,{type:n.type,size:13}),name:i,preview:rl(n),marks:il(n),onSelect:a,nameSlot:Ai(o,t,r,i),selected:Yo===r,hidden:Boolean(n.props._hidden),...p,fold:l?{open:!s,label:"section",onToggle:()=>Mr(r)}:void 0,actions:/* @__PURE__ */ot(rt,{children:[ol(o,t,i),ll(n,o,t),sl(o,t,n,i)]}),rowProps:c}),l&&!s&&/* @__PURE__ */tt(Ae,{children:js(n,2)})]},r)}),d(r.length)]})]})},$s=(e,n,t,o,r)=>{const i=String(e.props.id),l=`${i}:${n.slot}`,s=ts.dragging,d=!$r(l)&&s?.rung?.nodeId!==i,a={...In(l),index:0},c=s&&!s.rung&&Jl(s,a)?a:void 0,p=()=>Ii(e,n,!0),{rowProps:u,...h}=ts.row({item:{id:`rung:${l}`,zone:`${i}:${ut}`,index:t,type:e.type,rung:{nodeId:i,slot:n.slot}},place:{parentId:i,slot:ut,index:t},into:c,canDrag:Boolean(rr.moveSlot)&&!1!==n.movable&&o>1},{"data-slot-zone":l,onClick:tl(p)}),f=yt?null:rr.slotActions?.(e,n.slot);/* @__PURE__ */
20
+ return ot(Rn,{children:[n.heading,
21
+ /* @__PURE__ */tt(Te,{words:Wt,icon:n.glyph??null,name:n.label,badge:n.badge,onSelect:p,selected:Oi===l,...h,dragHint:n.dragHint,fold:{open:d,label:n.label,onToggle:()=>Mr(l)},actions:f&&f.length>0?/* @__PURE__ */tt(rt,{children:f.map((t,o)=>/* @__PURE__ */tt(Ee,{kind:"delete"===t.kind?"delete":"plain",label:t.label,disabled:t.disabled,onClick:()=>((e,n,t)=>{if(yt||t.disabled)return;const o=String(e.props.id),r=e=>{"string"==typeof e&&Ni(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__ */tt(Zn,{size:15}):/* @__PURE__ */tt(nt,{size:15})},`${o}:${t.kind}`))}):void 0,rowProps:u}),d&&/* @__PURE__ */tt(Ae,{children:r})]},l)},Ms=(e,n)=>{const t=ul(e),o=t.filter(e=>e.rung).length;let r=0;/* @__PURE__ */
22
+ return tt(rt,{children:t.map(t=>{const i=t.kids,l=t.rung?n+1:n,s=ml(e.type,void 0,t.slot),d=s?`${e.props.id}:${s.slot}`:null,a=null===t.slot?null:`${e.props.id}:${t.slot}`,c=(e,n)=>Is(e,n),p=/* @__PURE__ */ot(rt,{children:[i.map(({child:n,zone:t,index:o})=>{const r=Yo===String(n.props.id),{collapsible:i,folded:s}=gl(n,l,vl(n.type)),d=String(n.props.id),a=Dl(n),p=()=>Sl(t,o,d,e.type),{rowProps:u,...h}=ts.row({item:{id:d,zone:t,index:o,type:n.type},place:{...In(t),index:o}},{"data-node-id":d,onClick:tl(p)});/* @__PURE__ */
23
+ return ot(Rn,{children:[0===o&&c(t,0),
24
+ /* @__PURE__ */tt(Te,{words:Wt,icon:/* @__PURE__ */tt(hr,{type:n.type,size:13}),name:a,preview:rl(n),marks:il(n),onSelect:p,nameSlot:Ai(t,o,d,a),selected:r,hidden:Boolean(n.props._hidden),...h,fold:i?{open:!s,label:"group",onToggle:()=>Mr(d)}:void 0,actions:/* @__PURE__ */ot(rt,{children:[ol(t,o,a),ll(n,t,o),sl(t,o,n,a)]}),rowProps:u}),i&&!s&&/* @__PURE__ */tt(Ae,{children:Ms(n,l+1)}),c(t,o+1)]},String(n.props.id??`${t}-${o}`))}),null===a?d&&!i.some(e=>e.zone===d)?c(d,0):null:0!==i.length||!t.rung&&d!==a?null:c(a,0)]});return t.rung?$s(e,t.rung,r++,o,p):/* @__PURE__ */tt(Rn,{children:p},t.slot??"")})})},js=(e,n)=>{const t=sr(zt?.data,e.type,String(e.props.id)),o=ul(e),r=o.filter(e=>e.rung).length;let i=0;/* @__PURE__ */
25
+ return tt(rt,{children:o.map(o=>{const l=o.kids,s=o.rung?n+1:n,d=ml(e.type,t,o.slot),a=d?.spec??null,c=a&&Array.isArray(e.props[a.slot])?e.props[a.slot]:[],p=d&&d.choices?{slot:d.slot,choices:d.choices}:null,u=String(e.props.id),h=a&&!a.fixed?`${u}:${a.slot}`:null,f=p?`${u}:${p.slot}`:null,m=(e,n)=>Is(e,n),g=null===o.slot?null:`${u}:${o.slot}`,y=Boolean(a&&!a.fixed&&(null===g||g===h)),k=/* @__PURE__ */ot(rt,{children:[l.map(({child:n,zone:t,index:o})=>{const r=Yo===String(n.props.id),i=ji(n),l=String(n.props.id),{collapsible:d,folded:a}=gl(n,s,vl(n.type)),c=cl(n.type),p=1===c.length?`${l}:${c[0]}`:null,u=p?{...In(p),index:wi(p).length}:void 0,h=ts.dragging,f=u&&h&&Jl(h,u)?u:void 0,g=()=>Sl(t,o,l,e.type),{rowProps:y,...k}=ts.row({item:{id:l,zone:t,index:o,type:n.type},place:{...In(t),index:o},into:f,canDrag:!ir(n.type)},{"data-node-id":l,onClick:tl(g)});/* @__PURE__ */
26
+ return ot(Rn,{children:[0===o&&m(t,0),
27
+ /* @__PURE__ */tt(Te,{words:Wt,icon:/* @__PURE__ */tt(hr,{type:n.type,size:13}),name:i,preview:rl(n),marks:il(n),onSelect:g,nameSlot:Ai(t,o,l,i),selected:r,hidden:Boolean(n.props._hidden),...k,fold:d?{open:!a,label:"group",onToggle:()=>Mr(l)}:void 0,actions:ir(n.type)?ll(n,t,o)??void 0:/* @__PURE__ */ot(rt,{children:[ol(t,o,i),ll(n,t,o),sl(t,o,n,i)]}),rowProps:y}),d&&!a&&/* @__PURE__ */tt(Ae,{children:js(n,s+1)}),m(t,o+1)]},String(n.props.id??`${t}-${o}`))}),y&&a&&
28
+ /* @__PURE__ */tt(w,{small:!0,label:a.addLabel,blocked:a.addBlocked?.(c)??null,onAdd:()=>bl(e.props.id,a.slot,a.childType,c.length,e.type)}),null===g?f&&!l.some(e=>e.zone===f)?m(f,0):null:0!==l.length||(o.rung?y:g!==f)?null:m(g,0)]});return o.rung?$s(e,o.rung,i++,r,k):/* @__PURE__ */tt(Rn,{children:k},o.slot??"")})})},Ts=Ao||null!==yo,As=e=>"panel"in e?{id:e.id,label:e.label,icon:e.icon,active:io&&!Ts&&or===e.id,onSelect:()=>_r(e.id)}:e,Ls=[...(tr.railLead??[]).map(As),{id:"sections",label:Dt.layers,icon:/* @__PURE__ */tt(ue,{}),active:io&&!Ts&&"sections"===or,onSelect:()=>_r("sections")},...(tr.railTrail??[]).map(As)];go?Ls.push({id:"media",label:Dt.railMedia,icon:/* @__PURE__ */tt(he,{}),active:io&&!Ao&&(null!==yo||"media"===or),onSelect:()=>_r("media")}):bt&&Ls.push({id:"media",label:Dt.railMedia,icon:/* @__PURE__ */tt(he,{}),onSelect:ei});const Rs=[...tr.railLead??[],...tr.railTrail??[]].find(e=>"panel"in e&&e.id===or),Es=Boolean(Ht?.foldable),Fs=Ht?.label??(wt?Dt.pageSections:Dt.templateSections),Vs=Es&&$r(ht),Hs=/* @__PURE__ */ot(rt,{children:[oi.map((e,n)=>{if(Et(e)||Ft(e)||Tt(e.type))return null;const t=Yo===String(e.props.id),o=Boolean(e.props._hidden);pl(e);const r=String(e.props.id),i=tr.hasOwnRows?.(e)??!1,l=kl(e)||i,s=l&&$r(r),d=cl(e.type),a=1===d.length?`${r}:${d[0]}`:null,c=a?{...In(a),index:wi(a).length}:void 0,p=ts.dragging,u=c&&p&&Jl(p,c)?c:void 0,{rowProps:h,...f}=ts.row({item:{id:r,zone:we,index:n,type:e.type},place:{...In(we),index:n},into:u},{"data-node-id":r,onClick:tl(()=>Xi(n))});/* @__PURE__ */
29
+ return ot(Rn,{children:[n>0&&dl(n),
30
+ /* @__PURE__ */tt(Te,{words:Wt,icon:/* @__PURE__ */tt(hr,{type:e.type,size:13}),name:vi(e),preview:rl(e),marks:il(e),shared:Ml(e),onSelect:()=>Xi(n),nameSlot:Ai(we,n,r,vi(e)),selected:t,hidden:o,...f,fold:l?{open:!s,label:"section",onToggle:()=>Mr(r)}:void 0,actions:/* @__PURE__ */ot(rt,{children:[ol(we,n,vi(e)),ll(e,we,n),sl(we,n,e,vi(e))]}),rowProps:h}),kl(e)&&!s&&/* @__PURE__ */ot(Ae,{children:[js(e,1),tr.partRows?.(e,Ns)]}),i&&!s&&/* @__PURE__ */tt(Ae,{children:tr.ownRows?.(e,n,Ns)})]},String(e.props.id??n))}),Fl>0&&dl(Fl)]}),Ds=(e,n,t)=>{const o=String(e.props.id),r=hl(e).length>0||fl(e)||Boolean(ar(e.type)),i=r&&$r(o),l="header"===t?Dt.header:Dt.footer,s=pr.rowName?pr.rowName(e,"section",l):l;/* @__PURE__ */
31
+ return ot(rt,{children:[
32
+ /* @__PURE__ */tt(Te,{words:Wt,icon:/* @__PURE__ */tt(hr,{type:t,size:13}),name:s,preview:rl(e),marks:il(e),badge:Ml(e)?void 0:Ll,shared:Ml(e),onSelect:()=>Xi(n),nameSlot:Ai(we,n,o,s),selected:Yo===String(e.props.id),fold:r?{open:!i,label:"section",onToggle:()=>Mr(o)}:void 0,actions:ll(e,we,n)??void 0,rowProps:{"data-node-id":o,onClick:tl(()=>Xi(n))}}),r&&!i&&/* @__PURE__ */tt(Ae,{children:Ms(e,1)})]})};return(tr.wrap??(e=>e))(
33
+ /* @__PURE__ */tt(Z,{target:Io,children:/* @__PURE__ */ot("div",{ref:Bo,className:"sf-editor es-editor",style:nn(Or),onContextMenu:Hi.onEditorContextMenu,...u(yn),children:[
34
+ /* @__PURE__ */ot(Ge,{children:[
35
+ /* @__PURE__ */tt(Ye,{items:Ls,ariaLabel:Dt.bar.views}),
36
+ /* @__PURE__ */ot(Xe,{children:[
37
+ /* @__PURE__ */tt(Je,{label:Dt.bar.undo,disabled:Boolean(yt)||!Ot.hasPast,onClick:()=>Ot.back(),children:/* @__PURE__ */tt(Xn,{})}),
38
+ /* @__PURE__ */tt(Je,{label:Dt.bar.redo,disabled:Boolean(yt)||!Ot.hasFuture,onClick:()=>Ot.forward(),children:/* @__PURE__ */tt(Jn,{})}),
39
+ /* @__PURE__ */tt(Qe,{}),
40
+ /* @__PURE__ */tt(Ke,{devices:so,value:ho,onChange:fo}),
41
+ /* @__PURE__ */tt(Je,{label:Dt.bar.refresh,tip:Dt.bar.refreshTip,onClick:()=>{Oo.current=(()=>{const e=Io?.document;if(!e)return null;const n=oi.findIndex(Ft),t=n>=0?n:oi.length;let o=null;for(let n=0;n<t;n++){const t=oi[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=Bt?.props?.id??oi[0]?.props?.id;null!=e&&(o={id:String(e),offset:0})}return o})(),Co(e=>e+1)},children:/* @__PURE__ */tt(Qn,{})})]}),
42
+ /* @__PURE__ */ot(Xe,{kind:"right",style:{minWidth:300},children:[
43
+ /* @__PURE__ */tt(v,{input:jo,words:Dt.saveStatus}),tr.barLead?.(),tr.barTrail?.(),tr.mainAction||!tr.barMain?/* @__PURE__ */tt(S,{input:jo,action:tr.mainAction??{label:Dt.done,onPress:()=>{Dn(zt.data)}},readOnly:Boolean(yt),saveSwitch:vt,onToggleAutoSave:Yn,onSaveNow:To,bar:Dt.bar,words:Dt.saveStatus}):tr.barMain()]})]}),
44
+ /* @__PURE__ */tt(oe,{}),
45
+ /* @__PURE__ */ot("div",{className:"sf-body",children:[io?/* @__PURE__ */ot(rt,{children:[
46
+ /* @__PURE__ */tt("aside",{className:"es-sidepanel es-sidepanel--left sf-panel sf-panel--left","aria-label":Dt.leftPanel,children:Ao?/* @__PURE__ */tt(x,{at:Fo?{label:(e=>{const n=Yl(e.zone);if(n)return Dt.add.addingTo({name:pr.rowName?nl(n,!0):gi(n.type)});if(e.zone===we){const n=oi[e.index];return n&&!Ft(n)?Dt.add.addingBefore({name:nl(n,!0)}):Dt.add.addingAtEnd}const t=Kl(e.zone);return t?Dt.add.addingTo({name:t.parentName}):Dt.add.addingHere})(Fo),onClear:()=>Vo(null)}:void 0,placeBlocks:Fo&&Fo.zone!==we?Kl(Fo.zone)?.choices:void 0,canTake:Fo?e=>{if(!Fo)return null;const n={...In(Fo.zone),index:Fo.index};if(ql(e,n))return null;if("shared"===e.kind&&Fo.zone===we&&!Pt.shared?.nodeOf(e.section))return Dt.shared.alreadyHere;const t=Yl(Fo.zone);if(t)return Dt.add.notInside({name:nl(t,!0)});if(Fo.zone===we)return Dt.add.onlySections;const o=Kl(Fo.zone);return o?Dt.add.notInside({name:o.parentName}):Dt.add.onlySections}:void 0,onPick:Fo?e=>{if(!Fo)return;const n={...In(Fo.zone),index:Fo.index};ql(e,n)&&(_l(e,n),el())}:void 0,itemFor:e=>({id:`new:${e.kind}:${"template"===e.kind?e.template.id:"shared"===e.kind?e.section.id:e.type}`,zone:"",index:-1,type:"template"===e.kind?e.template.node.type:"shared"===e.kind?e.section.node.type:e.type,add:e}),session:ns,siteWide:tr.addPanelRow?.(el),onClose:el,onHide:Zr,readOnly:Boolean(yt)}):yo&&mo?
47
+ /* @__PURE__ */tt(N,{panel:mo,pick:yo,onHide:Zr}):Rs?Rs.panel({onHide:Zr,notify:Lr}):"media"===or&&mo?/* @__PURE__ */tt(N,{panel:mo,pick:null,onHide:Zr}):/* @__PURE__ */ot(rt,{children:[
48
+ /* @__PURE__ */tt(O,{icon:/* @__PURE__ */tt(ue,{}),title:Dt.layers,context:Kt,actions:/* @__PURE__ */ot(rt,{children:[!yt&&/* @__PURE__ */tt(Ze,{label:Dt.add.title,onClick:()=>qi(null),children:/* @__PURE__ */tt(Kn,{size:15})}),
49
+ /* @__PURE__ */tt(Ze,{label:Hl?Dt.expandAll:Dt.collapseAll,title:0===Vl.length?Dt.nothingToFold:void 0,disabled:0===Vl.length,onClick:()=>Cr(e=>{const n=new Set(Vl);return Hl?new Set([...e].filter(e=>!n.has(e))):/* @__PURE__ */new Set([...e,...Vl])}),children:/* @__PURE__ */tt(at,{expand:Hl})})]}),onHide:Zr}),
50
+ /* @__PURE__ */ot(Le,{className:"sf-tree sf-scroll",words:Wt,children:[
51
+ /* @__PURE__ */tt(Te,{words:Wt,icon:/* @__PURE__ */tt(hr,{type:"page",size:13}),name:Dt.pageSettings,onSelect:ni,selected:!Bt&&Go,rowProps:{onClick:tl(ni)}}),Rl&&/* @__PURE__ */ot(rt,{children:[!Pl&&/* @__PURE__ */tt(Re,{children:Dt.header}),Ps(Rl)]}),xt&&!(Pl&&Rl)&&/* @__PURE__ */ot(rt,{children:[!Pl&&/* @__PURE__ */tt(Re,{children:Dt.header}),!Vt&&/* @__PURE__ */tt(Te,{words:Wt,icon:/* @__PURE__ */tt(hr,{type:"header",size:13}),name:Dt.header,badge:Al?void 0:Ll,shared:Al,onSelect:ti,selected:Wo.kind===Rt?.kind,rowProps:{onClick:tl(ti)}})]}),Bl&&!(Pl&&Rl)&&Ds(Bl,Ol,"header"),!Es&&/* @__PURE__ */tt(Re,{children:Fs}),Es?/* @__PURE__ */ot(rt,{children:[
52
+ /* @__PURE__ */tt(Te,{words:Wt,icon:null,name:Fs,fold:{open:!Vs,label:Fs,onToggle:()=>Mr(ht)}}),!Vs&&/* @__PURE__ */tt(Ae,{children:Hs})]}):Hs,xt&&!Pl&&/* @__PURE__ */tt(Re,{children:Dt.footer}),Cl&&!(Pl&&El)&&Ds(Cl,zl,"footer"),El&&Ps(El),tr.treeFoot?.()]})]})}),
53
+ /* @__PURE__ */tt(qe,{side:"left",width:Or.left,min:en,max:_e,defaultWidth:m.left,label:Dt.resizeLeftPanel,onResize:Nr})]}):/* @__PURE__ */tt(B,{side:"left",onShow:Zr}),
54
+ /* @__PURE__ */ot("div",{ref:Rr,className:"sf-center sf-scroll","data-sf-canvas-head":Dr?"":void 0,style:{overflowX:Jr?"auto":"hidden",overflowY:"hidden"},children:[Dr&&/* @__PURE__ */tt("div",{ref:Wr,className:"sf-canvas-head",children:/* @__PURE__ */tt(Dr,{device:ho})}),
55
+ /* @__PURE__ */ot("div",{className:"sf-frame-scaler",style:Qr,children:[
56
+ /* @__PURE__ */tt("div",{className:"sf-frame "+(ho===po?"":`sf-frame--${ho}`),style:Kr,children:/* @__PURE__ */ot("div",{className:"sf-preview-host",children:[
57
+ /* @__PURE__ */tt(Me.Provider,{value:Nl,children:/* @__PURE__ */tt(je.Provider,{value:Tl,children:/* @__PURE__ */tt(Zt,{},zo)})}),
58
+ /* @__PURE__ */tt(cn,{canvas:Io,session:ns,model:ks,measure:Ss,canDrop:ws,onDrop:zs,choose:is,onPick:Os,onZoneAdd:Bs,onSeamAdd:Bs,zoneAddLabel:Dt.canvasAddBlock,words:Ut.canvas,readOnly:Boolean(yt),revision:zt.data}),Ho.length>0&&!No&&/* @__PURE__ */tt("div",{className:"sf-preview-gaps",children:Ho.map(e=>
59
+ /* @__PURE__ */tt(pn,{index:e.index,label:Dt.addSectionHere,onInsert:()=>qi(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))})]})}),ds?/* @__PURE__ */tt(dt,{canvas:Io,tabs:ps,onSelect:e=>{const n=oi.findIndex(n=>String(n.props.id)===e);n>=0&&Xi(n)}}):null]})]}),lo?/* @__PURE__ */ot(rt,{children:[
60
+ /* @__PURE__ */tt(h,{value:{selectChild:Sl,addChild:bl,childRowName:ji,blockRowName:Dl},children:/* @__PURE__ */tt(qt,{mode:Wo,onOpenWebsiteSettings:tr.openSettings??(()=>{}),onOpenSiteStyles:tr.openStyles,onSelectNode:yr,onNotify:Lr,onHidePanel:qr,nodeActions:Bt?xe(Nt,Bt.type):ft})}),
61
+ /* @__PURE__ */tt(qe,{side:"right",width:Or.right,min:en,max:_e,defaultWidth:m.right,label:Dt.resizeSettingsPanel,onResize:Pr})]}):
62
+ /* @__PURE__ */tt(B,{side:"right",onShow:qr})]}),Hi.menu,pi?/* @__PURE__ */tt(it,{name:pi.name,onMake:e=>(async(e,n)=>{const t=oi.find(n=>String(n.props.id)===e),o=Pt.shared;if(!t||!o)return;let r;try{r=await C(ci).create(n,t)}catch{return void Lr(Dt.shared.makeFailed,"error")}o.adopt(t,r),ui(null)})(pi.id,e),onCancel:()=>ui(null)}):null]})}))}export{mt as ScreenChrome};
@@ -0,0 +1,14 @@
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,clickPickPart as l,clickPick as s}from"./chunk-X3TYRF5V.js";import{selectionBox as a,placeWindow as c,offsetOrigin as d,colorRunOf as u,ColorWindow as p,startCanvasTyping as f,textMap as h}from"./chunk-23VM4PMV.js";import{DEFAULT_COPY_WORDS as m}from"./chunk-B4JN227A.js";import{useWords as g}from"./chunk-MFIRYGHW.js";import{setCanvasNonce as v,CANVAS_TYPABLE_EVENT as y,isTypingTarget as w,frameRectToHost as b,CANVAS_TYPING_EVENT as k,drawnBox as S}from"./chunk-X4T6JT3M.js";import{find as C,ROOT_ID as I,getList as E,remove as D,parseZoneKey as x,move as A,duplicate as M,replaceNode as O,createNode as R,insert as z,normalizeData as V,createResolveCache as P,resolveNodeData as B,ROOT_SLOT as N}from"./chunk-KRXQM65X.js";import{topLevelSlotKeys as $,fieldsFrom as L,defaultsFrom as K}from"./chunk-NKB3KVAB.js";import{createContext as j,useEffect as Z,useContext as T,useRef as F,useSyncExternalStore as H,useState as W,useMemo as Y,useCallback as q,useLayoutEffect as X}from"react";import{jsx as U,jsxs as J,Fragment as G}from"react/jsx-runtime";import{createPortal as Q}from"react-dom";import{registerModalEscapeInterceptor as _,FloatingBar as ee,TextToolbar as te,LinkPicker as ne}from"efficient-shell/ui";function oe(e){return!["setData","setUi","set"].includes(e.type)}var re=(e,t,n,o)=>{const r=E(e,t,x(n));return r?.[o]??null},ie=(e,t,n,o,r)=>{const i=re(e,t,n,o);if(!i)throw new Error(`${r}: nothing at ${n}[${o}]`);return i};function le(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 se(e,t,n){return n?"node"===n.kind?C(e,t,n.id)?n:null:n.parentId===I?E(e,t,n)?n:null:C(e,t,n.parentId)&&E(e,t,n)?n:null:null}function ae(e,t,n,r=!1){const{itemSelector:i,selectedSlot:l,...s}=n;let a=e.selection;var c;return"itemSelector"in n&&(a=o(e.data,t,i??null)),"selectedSlot"in n&&(l?a=(c=l)?{kind:"slot",parentId:c.parentId,slot:c.slot}:null:"slot"===a?.kind&&(a=null)),{...e,selection:a,ui:r?s:{...e.ui,...s}}}function ce(e,t,n){const o=de(e,t,n);if(o===e)return e;const r=se(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function de(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 ae(e,n,"function"==typeof t.ui?t.ui(le(e,n)):t.ui);case"set":{const r={data:o,ui:le(e,n)},i="function"==typeof t.state?t.state(r):t.state;let l=i.data?{...e,data:i.data}:e;return i.ui&&(l=ae(l,n,i.ui,!0)),l}case"insert":{const r={...x(t.destinationZone),index:t.destinationIndex},i=R(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:z(o,n,r,i)}}case"replace":{const r=ie(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:O(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=ie(o,n,t.sourceZone,t.sourceIndex,"duplicate"),i=M(o,n,r.props.id),l=re(i,n,t.sourceZone,t.sourceIndex+1);return{...e,data:i,selection:l?{kind:"node",id:l.props.id}:e.selection}}case"reorder":return de(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=re(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const i={...x(t.destinationZone),index:t.destinationIndex};return{...e,data:A(o,n,r.props.id,i)}}case"remove":{const r=ie(o,n,t.zone,t.index,"remove");return{...e,data:D(o,n,r.props.id)}}default:return e}}var ue={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},pe={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},fe=0,he=()=>`history-${fe+=1}`;function me(e){let t=e.config;const r=e.now??(()=>Date.now()),i=e.historyCoalesceMs??250;let l=e.permissions??{};const s=V(e.data,t);let a={data:s,selection:null,ui:{...pe}};if(e.ui){const{itemSelector:n,selectedSlot:r,...i}=e.ui;a={data:s,selection:r?{kind:"slot",...r}:o(s,t,n??null),ui:{...pe,...i}}}let c=[{core:a,at:-1/0,sealed:!0,id:he()}],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:a,at:n}]:(c=[...c.slice(0,d+1),{core:a,at:n,sealed:e,id:he()}],d=c.length-1)},p=/* @__PURE__ */new Set;let f=null,h=null,m=0,g=null,v=!1;const y=()=>{for(const e of[...p])e()},w=()=>{c=[...c.slice(0,d),{...c[d],core:a},...c.slice(d+1)]},b=(t,n)=>{m>0?v=v||n:(n?u(!1):a!==t&&w(),a.data!==t.data&&e.onChange?.(a.data),a!==t&&y())},k=e=>{const n=a;if(a=ce(a,e,t),a===n)return;const o=e.recordHistory??oe(e);b(n,o&&a.data!==n.data)},S=t=>{0===m&&(g=a,v=!1),m+=1;try{t()}catch(e){throw m-=1,0===m&&g&&(a=g,g=null),e}if(m-=1,m>0||!g)return;const n=g;g=null,v&&a.data!==n.data?u(!0):a!==n&&w(),a.data!==n.data&&e.onChange?.(a.data),a!==n&&y()},I=e=>{const n=a,o=se(a.data,t,e);var r,i;(r=o,i=a.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))||(a={...a,selection:o},b(n,!1))},D=t=>{const n=a;d=t,a=c[d].core,a.data!==n.data&&e.onChange?.(a.data),a!==n&&y()},x=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...ue,...l,...n}};let A=x();const M=P(),R={resolveCache:M,async resolveAll({trigger:e="load",metadata:n}={}){const o=a.data,r={type:"root",props:{...o.root.props??{}}},i=[...o.content,...Object.values(o.zones??{}).flat()],[l,...s]=await Promise.all([B(r,t,{cache:M,trigger:e,metadata:n}),...i.map(o=>B(o,t,{cache:M,trigger:e,metadata:n}))]);S(()=>{const e=a;let n=a.data;s.forEach((e,r)=>{if(!e.didChange)return;const l=i[r].props.id,s=C(n,t,l)?.node;s&&s===C(o,t,l)?.node&&(n=O(n,t,l,e.node))}),l.didChange&&n.root===o.root&&(n={...n,root:{...n.root,props:l.node.props,readOnly:l.node.readOnly??n.root.readOnly}}),n!==a.data&&(a={...a,data:n,selection:se(n,t,a.selection)},b(e,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=C(a.data,t,e)?.node;if(!r)return!1;const i=await B(r,t,{cache:M,trigger:n,metadata:o});if(!i.didChange)return!1;let l=!1;return S(()=>{const n=a;if(C(a.data,t,e)?.node!==r)return;const o=O(a.data,t,e,i.node);o!==a.data&&(a={...a,data:o,selection:se(o,t,a.selection)},b(n,!1),l=!0)}),l},get config(){return t},getState(){if(f&&h===a)return f;const e=a,o={data:e.data,ui:le(e,t)},r="node"===e.selection?.kind?C(e.data,t,e.selection.id)?.node??null:null;return f={appState:o,selection:e.selection,selectedItem:r,config:t,dispatch:k,history:{back:()=>R.undo(),forward:()=>R.redo(),hasPast:d>0,hasFuture:d<c.length-1,histories:c.map(e=>({id:e.id,state:{data:e.core.data,ui:le(e.core,t)}})),index:d,setHistoryIndex:e=>{e>=0&&e<c.length&&e!==d&&D(e)}},getPermissions:A,getItemById:n=>C(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return E(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:k,batch:S,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=>I(e?{kind:"node",id:e}:null),selectSlot:e=>I(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){S(()=>{const n=a,o=void 0===e.select?a.selection:e.select;a={...a,data:e.data,selection:se(e.data,t,o)},b(n,e.data!==n.data)})},load(e,n={}){const o=a,r=V(e,t);a={...a,data:r,selection:se(r,t,n.selection??a.selection)},n.keepHistory||(c=[{core:a,at:-1/0,sealed:!0,id:he()}],d=0),a!==o&&y()},undo(){d>0&&D(d-1)},redo(){d<c.length-1&&D(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,l)||(l=e,A=x(),f=null,y())},setConfig(e){e!==t&&(t=e,A=x(),f=null,y())}};return R}function ge(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&&w(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 ve=j(null),ye=j(!0);function we({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return Z(()=>{n&&e.resolveAll()},[e,n]),Z(()=>{if(t&&"undefined"!=typeof document)return ge(document,e)},[e,t]),/* @__PURE__ */U(ve.Provider,{value:e,children:/* @__PURE__ */U(ye.Provider,{value:t,children:o})})}function be(){const e=T(ve);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function ke(e){const t=be(),n=F({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 H(t.subscribe,o,o)}function Se(){return function(e){return ke(e)}}var Ce="data-puck-component",Ie="data-puck-dropzone",Ee={},De="data-es-mirror",xe="undefined"==typeof window?Z:X;function Ae(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${De}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(De,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function Me({children:t,id:n="preview-frame",title:o,className:r,style:i,mirrorStyles:l=!0,onDocument:s,height:a="auto",nonce:c}){const d=g("canvas",e),u=F(null),[p,f]=W(null);return xe(()=>{const e=u.current,t=p?.ownerDocument.defaultView;if("auto"!==a||!e||!p||!t)return;const n=()=>{e.style.height=`${Math.ceil(p.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(p),()=>r?.disconnect()},[p,a]),xe(()=>{let e=u.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=u.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"===a&&t.classList.add("es-frame-fill"),e.body.appendChild(t),v(e,c),f(t),s?.(e);let n=null;const o=u.current?.ownerDocument;if(l&&o){Ae(o,e,c);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>Ae(o,e,c)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}return()=>{n?.disconnect(),t.remove(),f(null),s?.(null)}},[]),/* @__PURE__ */U("iframe",{ref:u,id:n,title:o??d.frame,className:["es-canvas-frame","fill"===a?"is-fill":"",r??""].filter(Boolean).join(" "),style:i,children:p?Q(t,p):null})}var Oe=j(null),Re=j(Ee),ze=[];function Ve({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:i=120}){const l=be(),s=ke(n=>E(n.appState.data,l.config,{parentId:e,slot:t})??ze),a=ke(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==I),c=ke(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),d=T(Oe),u=["es-zone"];return s.length&&u.push("has-children"),e===I&&u.push("is-root"),(a||c)&&u.push("is-area-selected"),null!==d&&d===e&&e!==I&&u.push("is-hovering-area"),n&&u.push(n),/* @__PURE__ */U("div",{className:u.join(" "),[Ie]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${i}px`},children:s.map(e=>/* @__PURE__ */U(Ze,{node:e},e.props.id))})}function Pe(e,t){return Y(()=>{const n={};for(const o of $(L(e)))n[o]=function(e={}){/* @__PURE__ */
2
+ return U(Ve,{parentId:t,slot:o,...e})};return n},[e,t])}function Be(e){return Y(()=>function({zone:t,...n}){/* @__PURE__ */
3
+ return U(Ve,{parentId:e,slot:t,...n})},[e])}var Ne=["top","bottom","zIndex"];function $e(e,t,n){e.style[t]!==n&&(e.style[t]=n)}function Le(e){const t=function(e){const t=e?.ownerDocument.defaultView?.getComputedStyle(e);if(!t||"sticky"!==t.position)return null;const n=e=>"auto"===e?"":e;return{top:n(t.top),bottom:n(t.bottom),zIndex:n(t.zIndex)}}(function(e){const t=e.ownerDocument.defaultView;let n=null;for(const o of Array.from(e.children))if("none"!==t?.getComputedStyle(o).display){if(n)return null;n=o}return n}(e));$e(e,"position",t?"sticky":"relative");for(const n of Ne)$e(e,n,t?.[n]??"");return!!t}var Ke="data-es-canvas-relative";function je(e){e.hasAttribute(Ke)&&("relative"===e.style.position&&(e.style.position=""),e.removeAttribute(Ke));const t=e.ownerDocument.defaultView?.getComputedStyle(e).position;return t&&"static"!==t?"sticky"===t:(e.style.position||(e.style.position="relative",e.setAttribute(Ke,"")),!1)}function Ze({node:e}){const t=be().config.components[e.type],n=e.props.id,o=F(null),r=function(e,t){return Y(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(Ce),o.removeAttribute("data-puck-dnd")),t.current=n,n&&(n.setAttribute(Ce,e),n.setAttribute("data-puck-dnd",e),je(n))},[e,t])}(n,o),i=F(null),l=!!t?.inline;!function(e,t){const n=F(!1),o=F(()=>{});o.current=()=>{const o=e(),i=n.current;n.current=!!o&&t(o),i!==n.current&&r.current()};const r=F(()=>{});xe(()=>o.current()),xe(()=>{const t=e(),i=t?.ownerDocument.defaultView;if(!t||!i)return;const l=()=>o.current();i.addEventListener("resize",l);const s=i.ResizeObserver,a=s?new s(l):null;a?.observe(t);let c=null;return r.current=()=>{c?.disconnect(),c=null;const e=t.ownerDocument.documentElement;n.current&&e&&i.MutationObserver&&(c=new i.MutationObserver(l),c.observe(e,{attributes:!0}))},r.current(),()=>{i.removeEventListener("resize",l),a?.disconnect(),c?.disconnect(),r.current=()=>{}}},[])}(()=>l?o.current:i.current,e=>l?je(e):Le(e));const s=T(Re),a=Pe(t,n),c=Be(n);if(!t?.render)return null;const d=t.render,u={...K(t),...e.props,...a},p={renderDropZone:c,isEditing:!0,dragRef:t.inline?r:null,metadata:{...s,...t.metadata}};return t.inline?/* @__PURE__ */U(d,{...u,puck:p,editMode:!0}):
4
+ /* @__PURE__ */U("div",{ref:i,[Ce]:n,"data-puck-dnd":n,style:{position:"relative"},children:/* @__PURE__ */U(d,{...u,puck:p,editMode:!0})})}function Te({metadata:e}){const t=ke(e=>e.config),n=ke(e=>e.appState.data.root).props??{},o=t.root?.render,r=Pe(t.root,I),i=Be(I),l=/* @__PURE__ */U(Ve,{parentId:I,slot:N}),s=o?/* @__PURE__ */U(o,{id:"puck-root",...n,...r,puck:{renderDropZone:i,isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:l}):l;/* @__PURE__ */
5
+ return U(Re.Provider,{value:e??Ee,children:s})}var Fe=j(void 0),He=j(void 0),We=j(void 0);function Ye({element:e}){const t=F(null),n=qe(t,e?()=>e:null,e);/* @__PURE__ */
6
+ return U("div",{ref:t,"aria-hidden":"true",className:"es-canvas-outline is-hover is-hover-part",style:n?{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height}:{display:"none"}})}function qe(e,t,n){const[o,r]=W(null),i=F(t);return i.current=t,xe(()=>{const t=e.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!i.current)return void r(null);let o=0;const l=()=>{o=0;const n=function(e,t){if(!e||!t)return null;const n=S(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)))(l))};l();const a="MutationObserver"in n?new n.MutationObserver(s):null;a?.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),()=>{a?.disconnect(),c?.disconnect(),n.removeEventListener("resize",s),o&&(n.cancelAnimationFrame??n.clearTimeout)(o)}},[n]),o}function Xe({id:e,kind:t,overlay:n}){const o=F(null),r=T(He),i=null!==e&&!0===r?.(e),l=qe(o,e?t=>t.querySelector(`[${Ce}="${t.defaultView?.CSS?.escape?t.defaultView.CSS.escape(e):e}"]`):null,e),s=/* @__PURE__ */U("div",{ref:o,"aria-hidden":"true",className:`es-canvas-outline is-${t}${i?" is-shared":""}`,style:l?{position:"absolute",top:l.top,left:l.left,width:l.width,height:l.height}:{display:"none"}});return n&&e?/* @__PURE__ */U(n,{componentId:e,kind:t,children:s}):s}function Ue(e,t,n){const o=h(e,n),r=o.text.length,i=e.ownerDocument;if(!t)return[r,r];let l=null;const s=i.caretPositionFromPoint?.(t.x,t.y);if(s&&e.contains(s.offsetNode))l=o.at(s.offsetNode,s.offset);else{const n=i.caretRangeFromPoint?.(t.x,t.y);n&&e.contains(n.startContainer)&&(l=o.at(n.startContainer,n.startOffset))}if(null===l)return[r,r];const a=o.text;let c=l,d=l;for(;c>0&&!/\s/.test(a[c-1]);)c-=1;for(;d<a.length&&!/\s/.test(a[d]);)d+=1;return[c,d]}function Je({s:e,element:t,toolbar:n,label:o,keys:r}){const i=g("copy",m),l=e.pressed(),s=new Set(n.offered),f=n.colors&&n.colors.length>0?n.colors:null,h=F(null),[v,y]=W(!1),[w,k]=W(null),S=v||null!==w,C=()=>{e.hold(),y(!1),k({href:e.pressed().href})},I=()=>{y(!1),k(null),e.resume()};X(()=>{r.current={escape:()=>!!S&&(I(),!0),link:()=>!!s.has("link")&&(C(),!0)}}),X(()=>()=>{r.current=null},[r]);const E=F(I);E.current=I,Z(()=>{if(v)return _(e=>{const t=h.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(E.current(),!0)},()=>h.current?.querySelector(".es-copy-colors"))},[v]),Z(()=>{const n=h.current;if(!S||!n)return;const o=/* @__PURE__ */new Set([n.ownerDocument]),r=t();r&&o.add(r.ownerDocument);const i=o=>{const r=o.target;if(r&&n.contains(r))return;y(!1),k(null);const i=t();r&&i&&i.contains(r)?e.release():e.stop("outside")};for(const e of o)e.addEventListener("pointerdown",i,!0);return()=>{for(const e of o)e.removeEventListener("pointerdown",i,!0)}},[S,e,t]),X(()=>{const e=h.current,n=e?.querySelector(".rosh-tb-wrap > .es-copy-pop"),o=t();if(!(S&&e&&n&&o))return;const r=o.ownerDocument.defaultView?.getSelection()??null,i=r&&r.rangeCount>0&&o.contains(r.getRangeAt(0).startContainer)?r.getRangeAt(0):null,l=(i?a(i,o):null)??(()=>{const e=o.getBoundingClientRect();return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}})(),s=o.ownerDocument.defaultView?.frameElement,u=s?b(s,{left:l.left,top:l.top,width:l.right-l.left,height:l.bottom-l.top}):{left:l.left,top:l.top,width:l.right-l.left,height:l.bottom-l.top},p=o.getBoundingClientRect(),f=s?b(s,{left:p.left,top:p.top,width:p.width,height:p.height}):{left:p.left,top:p.top,width:p.width,height:p.height},m=(e.closest("[data-floating-bar]")??e).getBoundingClientRect(),g={left:u.left,right:u.left+u.width,top:Math.min(u.top,f.top-6,m.top),bottom:Math.max(u.top+u.height,f.top+f.height+6,m.bottom)},v=e.ownerDocument.documentElement,y=(s??o.closest(".es-canvas")??o).getBoundingClientRect(),w={left:Math.max(0,y.left),top:Math.max(0,y.top),right:Math.min(v.clientWidth||y.right,y.right),bottom:Math.min(v.clientHeight||y.bottom,y.bottom)};if(w.right<=w.left||w.bottom<=w.top||0===n.offsetWidth)return;const k=c({anchor:g,size:{width:n.offsetWidth,height:n.offsetHeight},within:{left:y.left,top:y.top,right:y.right,bottom:y.bottom},clip:w,parent:d(n)});n.style.top=`${k.top}px`,n.style.left=`${k.left}px`,n.style.setProperty("--es-pop-point",`${k.point}px`),n.dataset.side=k.above?"above":"below"});const D=f?{run:u(l.color,f),open:v,onToggle:()=>{k(null),v?I():(e.hold(),y(!0))}}:void 0;/* @__PURE__ */
7
+ return U(ee,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?b(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__ */U("div",{ref:h,children:/* @__PURE__ */U(te,{layout:"row",offered:s,pressed:l.marks,onMark:t=>{"link"===t?C():e.press(t)},color:D,linkOpen:null!==w,list:{pressed:l.list,onList:t=>e.list(t)},alignment:n.alignment,letterCase:n.letterCase,last:n.lastTool?.({className:"rosh-tb-btn",disabled:!1,selected:l.selected,keepCaret:t=>{t.preventDefault(),e.hold()},insert:t=>e.insert(t)}),windows:/* @__PURE__ */J(G,{children:[v&&f?/* @__PURE__ */U(p,{colors:f,current:l.color,words:i.colors??m.colors,onPick:t=>e.color(t)}):null,w?
8
+ /* @__PURE__ */U(ne,{className:"es-copy-link es-copy-pop",value:w.href??"",onApply:t=>{k(null),e.link(t)},onRemove:null!==w.href?()=>{k(null),e.link(null)}:void 0,onCancel:I}):null]})})})})}function Ge({element:e}){const t=F(null),n=qe(t,()=>e(),e);/* @__PURE__ */
9
+ return U("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 Qe({frame:t=!0,className:n,style:o,metadata:r,mirrorStyles:a,onDocument:c,height:d,title:u,nonce:p,hotkeys:h,frameWrapper:m,overlay:v,children:w,typing:b,passThrough:S}){const C=be(),I=T(Fe),E=S??I,D=T(ye),x=g("canvas",e),A=h??D,[M,O]=W(void 0),R=ke(e=>"node"===e.selection?.kind?e.selection.id:null),[z,V]=W(null),[P,B]=W(null),N=T(We),[$,L]=W(null),K=F(null),[,j]=W(0),H=F(b);H.current=b;const Y=F(null),q=F(null),X=ke(e=>e.appState.data);Z(()=>{const e=q.current?.ownerDocument,t=e?.defaultView?.CustomEvent;if(!e||!t)return;const n=R&&!$&&H.current?.atSelection?.()?R:null;e.dispatchEvent(new t(y,{detail:{id:n}}))},[R,$,X]);const G=e=>{const t=q.current?.ownerDocument,n=t?.defaultView?.CustomEvent;t&&n&&t.dispatchEvent(new n(k,{detail:{typing:e}}))},Q=(e,t)=>{K.current?.s.stop("stop");const n=e.element();if(!n)return!1;const o=C.group(),r=e.element,i=f({element:r,value:e.value,rules:e.rules,multiline:e.multiline,skip:e.skip,caret:Ue(n,t,e.skip),write:e.write,remount:e.remount,onSelect:()=>j(e=>e+1),onEscape:()=>Y.current?.escape()??!1,onLinkKey:()=>Y.current?.link()??!1,end:e=>{o.close(),K.current?.element===r&&(K.current=null),L(null),G(!1),H.current?.onChange?.({typing:!1,why:e})}});if(!i)return o.close(),!1;const l=n.closest?.(`[${Ce}]`)?.getAttribute(Ce);return l&&C.select(l),K.current={s:i,element:r,target:e},L(()=>r),V(null),G(!0),H.current?.onChange?.({typing:!0,element:n}),!0};Z(()=>()=>K.current?.s.stop("stop"),[]);const _=e=>{const t=K.current?.element();return Boolean(t&&t.contains(e))},ee=e=>{const t=e.closest?.(`[${Ce}]`)?.getAttribute(Ce);if(!t)return;const n=C.getState(),o="node"===n.selection?.kind?n.selection.id:null,r=N?.partAt(e,t)??null;if(r){const e=l(n.appState.data,C.config,t,r.id,o,N?.selected()??null,E);if(e)return{node:e.node,part:e.part?r:null}}return{node:s(n.appState.data,C.config,t,o,E)??t,part:null}},te=e=>{if("Enter"!==e.key||e.defaultPrevented||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;if(K.current)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select, button"))return;const n=H.current?.atSelection?.();n&&Q(n,null)&&e.preventDefault()},ne=/* @__PURE__ */J("div",{ref:q,className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;if(t.closest?.("a[href]")&&e.preventDefault(),K.current){if(_(t))return;K.current.s.stop("outside")}const n=t.ownerDocument?.getSelection?.();n&&n.rangeCount>0&&n.isCollapsed&&n.removeAllRanges();const o=ee(t);if(void 0!==o)return C.select(o.node),void(N&&(o.part?.id??null)!==N.selected()&&N.select(o.part?.id??null));t.hasAttribute?.(Ie)||(C.select(null),N?.selected()&&N.select(null))},onDoubleClick:e=>{const t=H.current;if(!t||_(e.target))return;const n=t.at(e.target);n&&Q(n,{x:e.clientX,y:e.clientY})&&e.preventDefault()},onKeyDown:e=>te(e),onMouseOver:e=>{if(K.current)return;const t=ee(e.target),n=t?.part&&t.part.id!==N?.selected()?t.part.element:null,o=t&&!t.part?t.node:null;o!==z&&V(o),n!==P&&B(n)},onMouseLeave:()=>{V(null),B(null)},children:[
10
+ /* @__PURE__ */U(Oe.Provider,{value:z,children:/* @__PURE__ */U(Te,{metadata:r})}),
11
+ /* @__PURE__ */J("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
12
+ /* @__PURE__ */U(Xe,{id:!$&&z&&z!==R?z:null,kind:"hover",overlay:v}),N?/* @__PURE__ */U(Ye,{element:$?null:P}):null,
13
+ /* @__PURE__ */U(Xe,{id:$?null:R,kind:"selected",overlay:v}),$?/* @__PURE__ */U(Ge,{element:$}):null]}),w]}),oe=m?/* @__PURE__ */U(m,{document:M,children:ne}):ne;Z(()=>{if(M&&A)return ge(M,C)},[M,A,C]),Z(()=>{if(!M)return;const e=e=>{if("Enter"===e.key)return void te(e);if("Escape"!==e.key||e.defaultPrevented)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select"))return;const n=C.getState();if("node"!==n.selection?.kind)return;if(N?.selected())return void N.select(null);const o=i(n.appState.data,C.config,n.selection);"node"===o?.kind&&C.select(o.id)};return M.addEventListener("keydown",e),()=>M.removeEventListener("keydown",e)},[M,C,N]);/* @__PURE__ */
14
+ return J("div",{className:"es-canvas"+(n?` ${n}`:""),style:o,"data-puck-preview":"","data-es-typing":$?"":void 0,children:[$&&K.current?.target.toolbar?/* @__PURE__ */U(Je,{s:K.current.s,element:K.current.element,toolbar:K.current.target.toolbar,label:x.textTools,keys:Y}):null,t?/* @__PURE__ */U(Me,{mirrorStyles:a,onDocument:e=>{O(e??void 0),c?.(e)},height:d,title:u,nonce:p,children:oe}):/* @__PURE__ */U("div",{id:"preview-frame","data-puck-entry":"",children:oe})]})}function _e(e={}){const t=be(),n=ke(e=>e.appState.data);return r({...e,data:n,config:t.config,commit:(e,{select:n})=>t.run({data:e,select:n})})}function et(){const e=be(),n=ke(e=>e.config),o=e.resolveCache,r=ke(e=>e.selectedItem),i=ke(e=>e.appState.data.root),l=r?r.props.id:"root",s=i.props??{},a=Y(()=>r||{type:"root",props:s},[r,s]),c=r?n.components[r.type]:n.root,d=e.getState(),u=r?C(d.appState.data,n,l):null,p=u&&"root"!==u.place.parentId?u.place.parentId:null,f=p?d.getItemById(p)??null:null,{fields:h}=t({id:l,node:a,block:c,parent:f,appState:d.appState}),m=ke(e=>!1===e.getPermissions(r?{item:r}:{root:!0}).edit),g=q(t=>{(async()=>{const r=e.getState();if("root"!==l){const i=r.getItemById(l),s=r.getSelectorForId(l);if(!i||!s)return;const a={...i,props:{...i.props,...t}},{node:c}=await B(a,n,{cache:o,trigger:"replace"}),d=e.getState().getSelectorForId(l);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 B({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,l]),v=q((e,t)=>g({[e]:t}),[g]);return{id:l,node:a,fields:h,values:a.props,readOnly:m,onChange:v,onChangeMany:g}}export{Me as CanvasFrame,We as CanvasPartsContext,Fe as CanvasPassThroughContext,He as CanvasSharedContext,pe as DEFAULT_UI,Qe as EaselCanvas,we as EaselProvider,Te as EditDocument,ge as bindUndoKeys,me as createEasel,Se as createUseEasel,oe as recordsByDefault,ce as reduce,le as uiView,ke as useEasel,be as useEaselApi,_e as useEaselNodeOps,et as useSelectedFields,se as validSelection};
@@ -1 +1 @@
1
- import{useEaselSession as e}from"./chunk-O7Q4DDJT.js";import{useHostEscape as n}from"./chunk-U3JP4VGF.js";import{DEFAULT_SCREEN_WORDS as t}from"./chunk-VVPZMWJE.js";import{styleMenuItems as o}from"./chunk-V7U33NF2.js";import{createNodeClipboard as l,nodeMenuItems as r}from"./chunk-OSPUG6S6.js";import{DEFAULT_NODE_MENU_WORDS as i}from"./chunk-WK3AFPXY.js";import{ROOT_ZONE as c}from"./chunk-PLVEGYK6.js";import{easelMenuEntries as s,menuLabel as a}from"./chunk-BALFHI3G.js";import{isTypingTarget as u,useCanvasEvent as d,framePointToHost as p}from"./chunk-X4T6JT3M.js";import{zoneKey as f,ROOT_SLOT as m,ROOT_ID as h}from"./chunk-KRXQM65X.js";import{useState as y,useCallback as k,useRef as b,useEffect as v}from"react";import{ContextMenu as g}from"efficient-shell/ui";import{UndoIcon as w,RedoIcon as x,PasteIcon as C,SettingsIcon as z,LayersIcon as P,CopyIcon as O}from"efficient-shell/icons/efficient";import{jsx as A}from"react/jsx-runtime";function D(e,n){const t=[],o=/* @__PURE__ */new Set;let l={zone:n.zone,index:n.index};for(;l;){const n=e.nodeAt(l.zone,l.index);if(!n||o.has(n.props.id))break;if(o.add(n.props.id),t.push({zone:l.zone,index:l.index,node:n,parentType:null}),l.zone===c)break;const r=l.zone.lastIndexOf(":");if(r<=0)break;l=e.locate(l.zone.slice(0,r))}for(let e=0;e<t.length-1;e+=1)t[e].parentType=t[e+1].node.type;return t}var K=l(),M=/* @__PURE__ */new WeakMap;function j(e){if(e.claimsPage)return K;const n=e.registry;if(!n)return e.cache("easel:node-clipboard",l);let t=M.get(n);return t||(t=l(),M.set(n,t)),t}function S(){return j(e())}function T(e,n,t){if(n===c){const{floor:n,cap:o}=e.sectionBand();return{parentId:h,slot:m,index:Math.min(Math.max(t,n),o)}}const o=n.lastIndexOf(":");return{parentId:n.slice(0,o),slot:n.slice(o+1),index:t}}function X(e,n,t){const o=e.isPinned(n,t),l=!o&&!e.isLocked(n)&&!e.duplicateBlocked(n),r=e.permits?.(n)??{duplicate:!0,delete:!0};return{copy:!o&&r.duplicate,cut:l&&r.duplicate&&r.delete,delete:l&&r.delete}}function E(e,n,t){const o=e.canPasteAt;if(!o)return f(n.from)===t.zone?T(e,t.zone,t.index+1):null;for(const l of D(e,t)){const t=T(e,l.zone,l.index+1);if(o(n,t))return t}return null}function L(e){if(e.defaultPrevented||e.altKey||e.shiftKey)return null;if(u(e.target))return null;const n=e.target,t=n&&"ownerDocument"in n?n.ownerDocument??n:null,o=t?.getSelection?.();if(o&&!o.isCollapsed&&o.toString().trim())return null;if(!e.metaKey&&!e.ctrlKey)return"Delete"===e.key?"delete":null;const l=e.code||(1===e.key.length?`Key${e.key.toUpperCase()}`:"");return"KeyC"===l?"copy":"KeyX"===l?"cut":"KeyV"===l?"paste":null}function V(e,n,t,o){const l=e.nodeAt(t.zone,t.index);if(!l)return null;const r=l.props.id,i=e.labelOf(l.type,t.zone),c=X(e,l,t.zone);if("copy"===n)return c.copy?(e.nodeOps.copy(r,i),{done:"copied",name:i}):null;if(o.readOnly)return null;if("cut"===n)return c.cut?(e.nodeOps.cut(r,i),{done:"cut",name:i}):null;if("delete"===n)return c.delete?(e.nodeOps.remove(r),{done:"deleted",name:i}):null;const s=o.held;if(!s)return null;const a=e.isPinned(l,t.zone)?null:E(e,s,t);return a?(e.nodeOps.paste(a),{done:"pasted",name:s.label}):(e.onPasteRefused(s),{done:"refused",name:s.label})}function I(e,n){const{zone:t,index:l}=n,i=e.nodeAt(t,l);if(!i)return[];const s=i.props.id,a=e.labelOf(i.type,t),u=Boolean(i.props._hidden),d=e.nodeOps,p=e.isPinned(i,t),f=e.isLocked(i),m=!p&&!f&&!e.duplicateBlocked(i),h=e.permits?.(i)??{duplicate:!0,delete:!0},y=X(e,i,t),k=D(e,n),b=d.held,v=b&&!p?E(e,b,n):null,g=!e.readOnly,w=e.style?o({held:g?e.style.held():null,canCopy:e.style.canCopy(i,t),onCopy:()=>e.style?.copy(i,t),onPaste:()=>e.style?.paste(t,l,i),words:e.words?.styleClipboard}):[];return r({title:a,words:e.words?.menu,layer:{group:"pick",items:k.flatMap((n,t)=>{const o={label:e.rowNameOf(n.node,n.zone),checked:0===t,onClick:()=>e.selectAt(n.zone,n.index,n.node.props.id,n.parentType)},l=n.zone===c?null:e.slotRung?.(n.zone)??null;return l?[o,{label:l.label,checked:!1,onClick:l.select}]:[o]})},actions:{duplicate:g&&m&&h.duplicate?()=>d.duplicate(s):void 0,moveUp:g&&d.canStep(s,-1)?()=>d.step(s,-1):void 0,moveDown:g&&d.canStep(s,1)?()=>d.step(s,1):void 0,copy:y.copy?()=>d.copy(s,a):void 0,cut:g&&y.cut?()=>d.cut(s,a):void 0,paste:g&&b&&v?{label:b.label,run:()=>d.paste(v)}:void 0,rename:g&&e.renamePropOf(i,t)?()=>e.beginRename(t,l):void 0,hide:!g||f||p?void 0:{hidden:u,run:()=>d.setProps(s,{_hidden:!u})},delete:g&&m&&h.delete?()=>d.remove(s):void 0},style:w,extras:e.menuRows?.(i,t,l)??void 0,pinnedLine:p?R(e).pinned:void 0})}var R=e=>e.words?.screen??t.menu;function B(e){const n=R(e),o=!e.readOnly,l=[];o&&e.history.hasPast&&l.push({label:n.undo,icon:/* @__PURE__ */A(w,{}),shortcut:"⌘Z",onClick:e.history.back}),o&&e.history.hasFuture&&l.push({label:n.redo,icon:/* @__PURE__ */A(x,{}),shortcut:"⇧⌘Z",onClick:e.history.forward});const r=[],s=e.nodeOps.held,a=T(e,c,e.sectionBand().cap);if(o&&s&&(e.canPasteAt?e.canPasteAt(s,a):f(s.from)===c)){const n=a,t=e.words?.menu??i;r.push({label:t.pasteNamed({paste:t.paste,label:s.label}),icon:/* @__PURE__ */A(C,{}),shortcut:"⌘V",onClick:()=>e.nodeOps.paste(n)})}const u=[l,r,[{label:e.pageSettingsLabel??t.pageSettings,icon:/* @__PURE__ */A(z,{}),onClick:e.openPageSettings},{label:n.collapseAll,icon:/* @__PURE__ */A(P,{}),onClick:e.collapseAll}]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return u.flatMap((e,n)=>n?[d,...e]:e)}function U(e,n){const t=n.selectionStart??0,o=n.selectionEnd??0,l=n.value.slice(t,o),r=e=>{n.focus(),n.setRangeText(e,t,o,"end"),n.dispatchEvent(new Event("input",{bubbles:!0}))},c=e.words?.menu??i,s=R(e),a=[];l&&(a.push({label:c.copy,icon:/* @__PURE__ */A(O,{}),shortcut:"⌘C",onClick:()=>navigator.clipboard?.writeText(l)}),a.push({label:c.cut,icon:/* @__PURE__ */A(O,{}),shortcut:"⌘X",onClick:()=>{navigator.clipboard?.writeText(l),r("")}})),a.push({label:c.paste,icon:/* @__PURE__ */A(C,{}),shortcut:"⌘V",onClick:()=>{navigator.clipboard?.readText().then(e=>{e&&r(e)}).catch(()=>e.onPasteRefused())}});const u=[a,n.value?[{label:s.selectAll,shortcut:"⌘A",onClick:()=>{n.focus(),n.select()}}]:[]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return u.flatMap((e,n)=>n?[d,...e]:e)}function Y(e){return e.shiftKey}function F(e,t){const[o,l]=y(null),r=k(()=>l(null),[]);n(null!==o,r);const i=b(e);i.current=e;const c=k(e=>{const n=i.current,t=n.keys;if(!t)return;const o=L(e);if(!o)return;const l=t.selected();if(!l)return;const r=V(n,o,l,{readOnly:t.readOnly,held:t.held()});r&&(e.preventDefault(),t.onDone?.(r))},[]),s=e.keys?.target??null;v(()=>{if(!s)return;const e=e=>c(e);return s.addEventListener("keydown",e),()=>s.removeEventListener("keydown",e)},[s,c]),d(t,"keydown",c);const a=k(n=>{if(Y(n))return;const t=n.target;if(t?.closest?.("[data-slot-zone]"))return n.preventDefault(),void l(null);const o=function(e){const n=e?.closest?.("input, textarea");return n&&("INPUT"!==n.tagName||["text","search","url","email","tel","number",""].includes(n.type))?n:null}(t);if(o)return n.preventDefault(),void l({kind:"input",x:n.clientX,y:n.clientY,el:o,owner:t});const r=t?.closest?.("[data-node-id]")?.getAttribute("data-node-id"),i=r?e.locate(r):null;n.preventDefault(),l(i?{kind:"node",x:n.clientX,y:n.clientY,...i,owner:t}:{kind:"empty",x:n.clientX,y:n.clientY,owner:t})},[e]);d(t,"contextmenu",n=>{if(Y(n)||!t)return;const o=n.target?.closest?.("[data-puck-component]")??null,r=o?.getAttribute("data-puck-component"),i=r?e.locate(r):null;n.preventDefault();const c=p(t.frame,n.clientX,n.clientY),s=t.frame;l(i?{kind:"node",...c,...i,owner:s}:{kind:"empty",...c,owner:s})}),d(t,"mousedown",r),d(t,"scroll",r,{on:"window"});return{onEditorContextMenu:a,menu:o?/* @__PURE__ */A(N,{host:e,target:o,onClose:r}):null,closeMenu:r}}function N({host:e,target:n,onClose:t}){const o="node"===n.kind?I(e,n):"input"===n.kind?U(e,n.el):B(e);return 0===o.length?null:/* @__PURE__ */A(g,{at:{x:n.x,y:n.y},owner:n.owner??null,onClose:t,"aria-label":a(o),items:s(o)})}export{K as EASEL_NODE_CLIPBOARD,D as ancestorChain,j as nodeClipboardOf,X as nodeClipboardRules,I as nodeMenuItems,L as nodeShortcut,B as pageMenuItems,E as pastePlace,V as runNodeShortcut,U as textMenuItems,S as useNodeClipboard,F as useNodeContextMenu};
1
+ import{useEaselSession as e}from"./chunk-O7Q4DDJT.js";import{useHostEscape as n}from"./chunk-U3JP4VGF.js";import{DEFAULT_SCREEN_WORDS as t}from"./chunk-C2RHV42O.js";import{styleMenuItems as o}from"./chunk-V7U33NF2.js";import{ROOT_ZONE as l}from"./chunk-PLVEGYK6.js";import{easelMenuEntries as r,menuLabel as i}from"./chunk-BALFHI3G.js";import{createNodeClipboard as c,nodeMenuItems as s}from"./chunk-OSPUG6S6.js";import{DEFAULT_NODE_MENU_WORDS as a}from"./chunk-WK3AFPXY.js";import{isTypingTarget as u,useCanvasEvent as d,framePointToHost as p}from"./chunk-X4T6JT3M.js";import{zoneKey as f,ROOT_SLOT as m,ROOT_ID as h}from"./chunk-KRXQM65X.js";import{useState as y,useCallback as k,useRef as b,useEffect as v}from"react";import{ContextMenu as g}from"efficient-shell/ui";import{UndoIcon as w,RedoIcon as x,PasteIcon as C,SettingsIcon as z,LayersIcon as O,CopyIcon as P}from"efficient-shell/icons/efficient";import{jsx as A}from"react/jsx-runtime";function D(e,n){const t=[],o=/* @__PURE__ */new Set;let r={zone:n.zone,index:n.index};for(;r;){const n=e.nodeAt(r.zone,r.index);if(!n||o.has(n.props.id))break;if(o.add(n.props.id),t.push({zone:r.zone,index:r.index,node:n,parentType:null}),r.zone===l)break;const i=r.zone.lastIndexOf(":");if(i<=0)break;r=e.locate(r.zone.slice(0,i))}for(let e=0;e<t.length-1;e+=1)t[e].parentType=t[e+1].node.type;return t}var K=c(),j=/* @__PURE__ */new WeakMap;function M(e){if(e.claimsPage)return K;const n=e.registry;if(!n)return e.cache("easel:node-clipboard",c);let t=j.get(n);return t||(t=c(),j.set(n,t)),t}function S(){return M(e())}function T(e,n,t){if(n===l){const{floor:n,cap:o}=e.sectionBand();return{parentId:h,slot:m,index:Math.min(Math.max(t,n),o)}}const o=n.lastIndexOf(":");return{parentId:n.slice(0,o),slot:n.slice(o+1),index:t}}function X(e,n,t){const o=e.isPinned(n,t),l=!o&&!e.isLocked(n)&&!e.duplicateBlocked(n),r=e.permits?.(n)??{duplicate:!0,delete:!0};return{copy:!o&&r.duplicate,cut:l&&r.duplicate&&r.delete,delete:l&&r.delete}}function L(e,n,t){const o=e.canPasteAt;if(!o)return f(n.from)===t.zone?T(e,t.zone,t.index+1):null;for(const l of D(e,t)){const t=T(e,l.zone,l.index+1);if(o(n,t))return t}return null}function R(e){if(e.defaultPrevented||e.altKey||e.shiftKey)return null;if(u(e.target))return null;const n=e.target,t=n&&"ownerDocument"in n?n.ownerDocument??n:null,o=t?.getSelection?.();if(o&&!o.isCollapsed&&o.toString().trim())return null;if(!e.metaKey&&!e.ctrlKey)return"Delete"===e.key?"delete":null;const l=e.code||(1===e.key.length?`Key${e.key.toUpperCase()}`:"");return"KeyC"===l?"copy":"KeyX"===l?"cut":"KeyV"===l?"paste":null}function E(e,n,t,o){const l=e.nodeAt(t.zone,t.index);if(!l)return null;const r=l.props.id,i=e.labelOf(l.type,t.zone),c=X(e,l,t.zone);if("copy"===n)return c.copy?(e.nodeOps.copy(r,i),{done:"copied",name:i}):null;if(o.readOnly)return null;if("cut"===n)return c.cut?(e.nodeOps.cut(r,i),{done:"cut",name:i}):null;if("delete"===n)return c.delete?(e.nodeOps.remove(r),{done:"deleted",name:i}):null;const s=o.held;if(!s)return null;const a=e.isPinned(l,t.zone)?null:L(e,s,t);return a?(e.nodeOps.paste(a),{done:"pasted",name:s.label}):(e.onPasteRefused(s),{done:"refused",name:s.label})}function I(e,n){const{zone:t,index:r}=n,i=e.nodeAt(t,r);if(!i)return[];const c=i.props.id,a=e.labelOf(i.type,t),u=Boolean(i.props._hidden),d=e.nodeOps,p=e.isPinned(i,t),f=e.isLocked(i),m=!p&&!f&&!e.duplicateBlocked(i),h=e.permits?.(i)??{duplicate:!0,delete:!0},y=X(e,i,t),k=D(e,n),b=d.held,v=b&&!p?L(e,b,n):null,g=!e.readOnly,w=e.style?o({held:g?e.style.held():null,canCopy:e.style.canCopy(i,t),onCopy:()=>e.style?.copy(i,t),onPaste:()=>e.style?.paste(t,r,i),words:e.words?.styleClipboard}):[];return s({title:a,words:e.words?.menu,layer:{group:"pick",items:k.flatMap((n,t)=>{const o={label:e.rowNameOf(n.node,n.zone),checked:0===t,onClick:()=>e.selectAt(n.zone,n.index,n.node.props.id,n.parentType)},r=n.zone===l?null:e.slotRung?.(n.zone)??null;return r?[o,{label:r.label,checked:!1,onClick:r.select}]:[o]})},actions:{duplicate:g&&m&&h.duplicate?()=>d.duplicate(c):void 0,moveUp:g&&d.canStep(c,-1)?()=>d.step(c,-1):void 0,moveDown:g&&d.canStep(c,1)?()=>d.step(c,1):void 0,copy:y.copy?()=>d.copy(c,a):void 0,cut:g&&y.cut?()=>d.cut(c,a):void 0,paste:g&&b&&v?{label:b.label,run:()=>d.paste(v)}:void 0,rename:g&&e.renamePropOf(i,t)?()=>e.beginRename(t,r):void 0,hide:!g||f||p?void 0:{hidden:u,run:()=>d.setProps(c,{_hidden:!u})},delete:g&&m&&h.delete?()=>d.remove(c):void 0},style:w,extras:e.menuRows?.(i,t,r)??void 0,pinnedLine:p?V(e).pinned:void 0})}var V=e=>e.words?.screen??t.menu;function B(e){const n=V(e),o=!e.readOnly,r=[];o&&e.history.hasPast&&r.push({label:n.undo,icon:/* @__PURE__ */A(w,{}),shortcut:"⌘Z",onClick:e.history.back}),o&&e.history.hasFuture&&r.push({label:n.redo,icon:/* @__PURE__ */A(x,{}),shortcut:"⇧⌘Z",onClick:e.history.forward});const i=[],c=e.nodeOps.held,s=T(e,l,e.sectionBand().cap);if(o&&c&&(e.canPasteAt?e.canPasteAt(c,s):f(c.from)===l)){const n=s,t=e.words?.menu??a;i.push({label:t.pasteNamed({paste:t.paste,label:c.label}),icon:/* @__PURE__ */A(C,{}),shortcut:"⌘V",onClick:()=>e.nodeOps.paste(n)})}const u=[r,i,[{label:e.pageSettingsLabel??t.pageSettings,icon:/* @__PURE__ */A(z,{}),onClick:e.openPageSettings},{label:n.collapseAll,icon:/* @__PURE__ */A(O,{}),onClick:e.collapseAll}]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return u.flatMap((e,n)=>n?[d,...e]:e)}function U(e,n){const t=n.selectionStart??0,o=n.selectionEnd??0,l=n.value.slice(t,o),r=e=>{n.focus(),n.setRangeText(e,t,o,"end"),n.dispatchEvent(new Event("input",{bubbles:!0}))},i=e.words?.menu??a,c=V(e),s=[];l&&(s.push({label:i.copy,icon:/* @__PURE__ */A(P,{}),shortcut:"⌘C",onClick:()=>navigator.clipboard?.writeText(l)}),s.push({label:i.cut,icon:/* @__PURE__ */A(P,{}),shortcut:"⌘X",onClick:()=>{navigator.clipboard?.writeText(l),r("")}})),s.push({label:i.paste,icon:/* @__PURE__ */A(C,{}),shortcut:"⌘V",onClick:()=>{navigator.clipboard?.readText().then(e=>{e&&r(e)}).catch(()=>e.onPasteRefused())}});const u=[s,n.value?[{label:c.selectAll,shortcut:"⌘A",onClick:()=>{n.focus(),n.select()}}]:[]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return u.flatMap((e,n)=>n?[d,...e]:e)}function Y(e){return e.shiftKey}function F(e,t){const[o,l]=y(null),r=k(()=>l(null),[]);n(null!==o,r);const i=b(e);i.current=e;const c=k(e=>{const n=i.current,t=n.keys;if(!t)return;const o=R(e);if(!o)return;const l=t.selected();if(!l)return;const r=E(n,o,l,{readOnly:t.readOnly,held:t.held()});r&&(e.preventDefault(),t.onDone?.(r))},[]),s=e.keys?.target??null;v(()=>{if(!s)return;const e=e=>c(e);return s.addEventListener("keydown",e),()=>s.removeEventListener("keydown",e)},[s,c]),d(t,"keydown",c);const a=k(n=>{if(Y(n))return;const t=n.target;if(t?.closest?.("[data-slot-zone]"))return n.preventDefault(),void l(null);const o=function(e){const n=e?.closest?.("input, textarea");return n&&("INPUT"!==n.tagName||["text","search","url","email","tel","number",""].includes(n.type))?n:null}(t);if(o)return n.preventDefault(),void l({kind:"input",x:n.clientX,y:n.clientY,el:o,owner:t});const r=t?.closest?.("[data-node-id]")?.getAttribute("data-node-id"),i=r?e.locate(r):null;n.preventDefault(),l(i?{kind:"node",x:n.clientX,y:n.clientY,...i,owner:t}:{kind:"empty",x:n.clientX,y:n.clientY,owner:t})},[e]);d(t,"contextmenu",n=>{if(Y(n)||!t)return;const o=n.target?.closest?.("[data-puck-component]")??null,r=o?.getAttribute("data-puck-component"),i=r?e.locate(r):null;n.preventDefault();const c=p(t.frame,n.clientX,n.clientY),s=t.frame;l(i?{kind:"node",...c,...i,owner:s}:{kind:"empty",...c,owner:s})}),d(t,"mousedown",r),d(t,"scroll",r,{on:"window"});return{onEditorContextMenu:a,menu:o?/* @__PURE__ */A(N,{host:e,target:o,onClose:r}):null,closeMenu:r}}function N({host:e,target:n,onClose:t}){const o="node"===n.kind?I(e,n):"input"===n.kind?U(e,n.el):B(e);return 0===o.length?null:/* @__PURE__ */A(g,{at:{x:n.x,y:n.y},owner:n.owner??null,onClose:t,"aria-label":i(o),items:r(o)})}export{K as EASEL_NODE_CLIPBOARD,D as ancestorChain,M as nodeClipboardOf,X as nodeClipboardRules,I as nodeMenuItems,R as nodeShortcut,B as pageMenuItems,L as pastePlace,E as runNodeShortcut,U as textMenuItems,S as useNodeClipboard,F as useNodeContextMenu};
@@ -0,0 +1,2 @@
1
+ import{routeSharedHostMessage as e}from"./chunk-S4AWJX4Q.js";import{describeLoadFailure as r,hostLoadRefusal as n}from"./chunk-ERR437B5.js";import{editLockOf as t}from"./chunk-GMCZXMOV.js";import{NO_DOCUMENT_ADDRESSING as o}from"./chunk-RLBXE4EU.js";import{saveStatusOf as u,resetForDocumentSwitch as a}from"./chunk-HNKB2ZYR.js";import{isExpiredSession as s,readEaselFailure as i}from"./chunk-CLOS6SSX.js";import{useAdminBridge as l}from"./chunk-VPFNZ7TB.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 v}from"./chunk-C2RHV42O.js";import{useAutosave as g}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 H,useEffect as O,useRef as E}from"react";import{jsx as T}from"react/jsx-runtime";var A={content:[],root:{},zones:{}};var D=j(null);function M(){const e=R(D);if(!e)throw new Error("useStorefrontDocument must be used within StorefrontDocumentProvider");return e}function N({target:j,addressing:R=o,onHostMessage:M,children:N}){const V=R,{homeSlug:F,entryMayBounce:L,entryBounce:W,onSwitch:Y,tellsHost:Z,adapterFor:J,migrateRenamedProps:U,describeMissing:X,onLoadFailed:x}=V,[G,K]=B(j),Q=k(),z=d(),_=C(()=>f(z),[z]),q=C(()=>t(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(()=>J(G,_,te),[J,_,te,G.kind,"template"===G.kind?G.id:"document"===G.kind?G.record:G.siteId]),ue=oe.capabilities,ae=H(e=>z.documentHooks?.stored?.(e)??e,[z]);O(()=>{m(z,ne)},[z,ne]);const se=E(G);O(()=>{se.current=G},[G]);const{token:ie,tokenRef:le,capabilities:ce}=l({onMessage:r=>{if(M?.(r)||e(r))return;const n=r;if("storefront-editor:navigate"===n?.type){const e=r;e?.target&&Br(e.target)}}}),de=!z.usesBridgedToken||null!==ie,fe=oe.lock,me=Boolean(_.lock),[ke,ve]=B(null),[ge,pe]=B(null),[he,ye]=B(null),[we,Se]=B(null),be=I("screen",v),Pe=we?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})}}(we,be):null,[Ie,je]=B(null),Re=E(null),Be=E(null),[Ce,He]=B(!1),Oe=E(null),[Ee,Te]=B(null),Ae=E(null),[De,Me]=B(null),[Ne,Ve]=B(!1),Fe=E(null);O(()=>{Fe.current=De},[De]);const[Le,We]=B(ue.hasEditLock?{kind:"checking"}:{kind:"editing"}),Ye=E(Le);O(()=>{Ye.current=Le},[Le]);const Ze=E(()=>Promise.resolve(!1)),Je=H(e=>{Be.current=e,He(!0)},[]),Ue=g({save:async({id:e,data:r})=>{if(p(Ye.current)){if(!await Ze.current(e,r)){if(!p(Ye.current))return void Je({id:e,data:r});throw new Error("page save did not land")}}else Je({id:e,data:r})},onFailure:(e,r)=>{0===r&&Q.send("storefront-editor:save-failed")}}),{state:Xe,push:xe,flush:Ge,pause:Ke,resume:Qe,stop:ze,reset:_e,retryNow:qe,hasPending:$e}=Ue,er=E(Xe);O(()=>{er.current=Xe},[Xe]);const rr=u(Xe),nr=H(()=>{const e=Be.current;e&&(Be.current=null,He(!1),xe(e))},[xe]),tr=E("");tr.current||(tr.current=h());const[or,ur]=B(0),ar=E(!1),[sr,ir]=B(L(j)),lr=E(!1);O(()=>{if(lr.current)return;lr.current=!0;const e=Q.address.search(),r=W(j,e);r?Q.address.load(r):L(j)&&ir(!1)},[j,Q]);const cr=Q.send;O(()=>{if(!de)return;let e=!1;const t=se.current,o=oe.resolve(re),u=z.documentHooks?.opening?.({slug:re,isTemplate:$,capabilities:ue});return o.then(async r=>{if(e)return;if(!r)return"page"===t.kind&&null!==F&&re!==F?void Q.address.load({kind:"page",slug:F,siteId:ne??void 0}):(Se({target:t,slug:re,missing:!0,sentence:X?.(t)??null}),void x?.(t,null));const n=r.readOnlyReason?r.readOnlyReason:null;Re.current=n,je(n),ve(r.id),pe(r.kind??null),Ae.current=r.version??null;const o=r.layout,a=o&&Object.keys(o).length?o:A,s=U(a),i=u?await u(s):s;e||ye(i)}).catch(o=>{e||(console.error("[storefront-editor] document load failed",o),Se({target:t,slug:re,missing:!1,sentence:n(o,{slug:re},z),cause:r(o,z)}),x?.(t,o))}),()=>{e=!0}},[de,ie,$,oe,re]);const dr=H(e=>new Promise(r=>{const n=Date.now(),t=setInterval(()=>{const o=le.current;o&&o!==e?(clearInterval(t),r(o)):Date.now()-n>6e3&&(clearInterval(t),r(null))},200)}),[]),fr=H(async e=>{const r=le.current;if(!r&&z.usesBridgedToken)return{ok:!1,error:new Error("no editor token")};try{return{ok:!0,value:await e(r??"")}}catch(n){if(s(n,z)){cr("storefront-editor:auth-expired");const n=r?await dr(r):null;if(n)try{return{ok:!0,value:await e(n)}}catch(e){return{ok:!1,error:e}}}return{ok:!1,error:n}}},[cr,dr,z]),mr=H(async e=>{const r=le.current?await fr(e):{ok:!1};return r.ok||cr("storefront-editor:save-failed"),r.ok},[cr,fr]),kr=H(async(e,r,n=!1)=>{if(null!==Re.current)return!1;if(!p(Ye.current))return!1;if(Fe.current)return!1;const t=await fr(()=>oe.saveLayout(e,r,Ae.current,tr.current));if(t.ok)return Ae.current=t.value.version??Ae.current,Ve(!1),!0;const o=q.readLockTaken(t.error);if(o){const e={kind:"takenover",holder:o};return Ye.current=e,We(e),!1}const u=q.readSaveConflict(t.error);if(u){if(u.savedByYou&&!n&&oe.rereadVersion){const n=await fr(()=>oe.rereadVersion(e));if(n.ok&&n.value)return Ae.current=n.value,Ze.current(e,r,!0)}ze(),Fe.current=u,Me(u)}return Ve(i(t.error,z)?.status===c),!1},[oe,fr,ze,z]);O(()=>{Ze.current=kr},[kr]);const vr=H(e=>{if(null!==Re.current)return;if(cr("storefront-editor:dirty"),!ke)return;const r=ae(e);Oe.current=r,p(Ye.current)?xe({id:ke,data:r}):Je({id:ke,data:r})},[ke,cr,Je,xe,ae]),gr=H(async()=>{p(Ye.current)&&nr();return await Ge()&&null==Be.current},[nr,Ge]),pr=E(gr);O(()=>{pr.current=gr},[gr]);const hr=E(fr);O(()=>{hr.current=fr},[fr]);const yr=H(()=>{Q.address.reload()},[Q]),wr=E(()=>Promise.resolve(!1));O(()=>{wr.current=()=>{const e=oe.rereadVersion;return ke&&e?y({ours:Ae.current,stored:async()=>{const r=await hr.current(()=>e(ke));return r.ok?r.value:null},hasPending:()=>null!=Be.current||$e(),reload:yr}):Promise.resolve(!1)}},[oe,ke,$e,yr]);const Sr=null!==Ie;O(()=>{if(!fe||!ke||!de||Sr)return;let e=!1,r=null,n=null;const t=tr.current,o={claim:async e=>{const r=await hr.current(()=>fe.claim(ke,t,e));if(r.ok)return{heartbeat_seconds:r.value.heartbeatSeconds};throw r.error},cancelled:()=>e,currentAccess:()=>Ye.current,heldWrite:()=>({pending:null!=Be.current||$e(),autoSaveEnabled:!er.current.paused,saveConflict:null!=Fe.current}),setAccess:e=>{Ye.current=e,We(e)},releaseHeldWrite:()=>{pr.current()},startHeartbeat:e=>{r&&clearInterval(r),r=setInterval(()=>{u(!1)},e)},stopHeartbeat:()=>{r&&(clearInterval(r),r=null)},reloadIfMoved:()=>{wr.current()}},u=q.makeClaimBeat(o),a=ar.current;return ar.current=!1,a||(We({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),fe.release(ke,t).catch(()=>{})}},[ke,fe,de,ie,or,Sr]);const br=H(()=>{fe&&ke&&(ar.current=!0,ur(e=>e+1))},[ke,fe]),Pr=H(()=>{We(e=>{const r="blocked"===e.kind||"takenover"===e.kind?e.holder:null;return r?{kind:"readonly",holder:r}:e})},[]),Ir=H(()=>{er.current.paused?(p(Ye.current)&&nr(),Qe()):Ke()},[nr,Ke,Qe]),jr=H(()=>{qe()},[qe]),Rr=H(e=>{Oe.current=null,a("template"!==e.kind&&me,{resetAutosave:()=>{_e(),Be.current=null,He(!1)},setVersion:e=>{Ae.current=e},setSaveConflict:Me,setAccess:We}),Y(e),K(e),Re.current=null,je(null),ve(null),pe(null),ye(null),Se(null),Q.address.show(e),"document"!==e.kind&&Z(e)&&Q.send("storefront-editor:navigated",{target:e})},[_e,Q,me,Y,Z]),Br=H(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,se.current,F))return;const r=null!=Be.current;if(!r&&!$e())return void Rr(e);const n=er.current;r||n.paused||n.failed||n.stopped?Te(e):Ge().then(r=>{r?Rr(e):Te(e)})},[Rr,$e,Ge,F]),Cr=H(()=>Te(null),[]),Hr=H(()=>{Te(e=>(e&&Rr(e),null))},[Rr]),Or=H(async()=>{const e=Ee;if(!e)return;await gr()&&(Te(null),Rr(e))},[Ee,gr,Rr]),Er=H(async e=>{if(null!==Re.current)return;if(!ke)return;if(!p(Ye.current)||Fe.current)return;const r=ae(e);if(!await kr(ke,r))return void(Fe.current||cr("storefront-editor:save-failed"));const n=oe.publish;if(!ue.canPublish||!n)return void cr("storefront-editor:saved");const t=await fr(()=>n(ke,Ae.current??void 0));if(!t.ok){const{error:e}=t;return void cr("storefront-editor:publish-failed",{reason:e instanceof Error&&e.message?e.message:null})}Ae.current=t.value.version??Ae.current,cr("storefront-editor:published")},[ke,oe,ue.canPublish,cr,kr,fr,ae]);/* @__PURE__ */
2
+ return T(D.Provider,{value:{target:G,adapter:oe,capabilities:ue,templateId:ee,currentSlug:re,currentKind:ge,siteId:ne,ready:de,token:ie,tokenRef:le,notifyParent:cr,bridgeCapabilities:ce,runAuthed:mr,docId:ke,data:he,getLiveData:()=>Oe.current??he,error:Pe,redirecting:sr,saveStatus:rr,saveState:Xe,autoSaveEnabled:!Xe.paused,autoSaveStoppedByConflict:Xe.stopped,hasUnsavedEdits:Xe.pending||Ce,toggleAutoSave:Ir,retrySave:jr,onChange:vr,flushSave:gr,onPublish:Er,access:Le,readOnly:null!==P(Le)||null!==Ie||null!==De,readOnlyReason:Ie,takeOverEditing:br,viewReadOnly:Pr,saveConflict:De,saveUnreachable:Ne,reloadFromServer:yr,navigate:Br,pendingNav:Ee,cancelPendingNav:Cr,discardAndNavigate:Hr,saveAndNavigate:Or},children:N})}export{D as ScreenDocumentContext,N as ScreenDocumentProvider,M as useScreenDocument};
@@ -1 +1 @@
1
- import{DEFAULT_PANEL_W as s,clampPanelWidth as e}from"./chunk-IE55HNMA.js";var a="sf-editor-panel-widths",l="sf-editor-collapsed-sections";function t(s){return s?{panelWidths:`${s}-panel-widths`,collapsed:`${s}-collapsed-sections`}:{panelWidths:a,collapsed:l}}var o={...s},d=s=>e(s);export{l as COLLAPSED_SECTIONS_KEY,o as DEFAULT_PANEL_W,a as PANEL_WIDTHS_KEY,d as clampPanelWidth,t as screenStorageKeys};
1
+ import{DEFAULT_PANEL_W as s,clampPanelWidth as e}from"./chunk-GWIVPLOX.js";var a="sf-editor-panel-widths",l="sf-editor-collapsed-sections";function t(s){return s?{panelWidths:`${s}-panel-widths`,collapsed:`${s}-collapsed-sections`}:{panelWidths:a,collapsed:l}}var o={...s},d=s=>e(s);export{l as COLLAPSED_SECTIONS_KEY,o as DEFAULT_PANEL_W,a as PANEL_WIDTHS_KEY,d as clampPanelWidth,t as screenStorageKeys};
@@ -0,0 +1 @@
1
+ import{panelFieldsOf as t}from"./chunk-LER7RKTO.js";import{withoutDeviceGate as o,deviceMetaOf as n}from"./chunk-XHHVMAGM.js";import{DESIGN_GROUP_KEY as e,BUCKET_KEY as r}from"./chunk-MQNBD6AB.js";import{STYLE_KIND as s,fieldKind as c,copyStyle as i,heldStyle as p,planPaste as u,pasteMessage as a}from"./chunk-V7U33NF2.js";import{ANCHOR_FIELD_KEYS as f,foldMetaOf as l,MEDIA_FIELD_MARKER as m,TEXT_FIELD_MARKER as h,LINK_FIELD_MARKER as y}from"./chunk-DUVRZ456.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(f),g=/* @__PURE__ */new Set(["focal","imageFocal"]),k=[m,h,y];function v(t){return`site:${t??""}`}function A(t){if(!t||"object"!=typeof t)return null;const n=t,e=o(t)??t,r=n[s]??e[s];if("string"==typeof r)return r;const i=n.options??e.options;if(Array.isArray(i)){return`choice:${i.map(t=>String(t?.value)).sort().join("|")}`}return c(e)}function D(t){const n=t,e=o(t);return k.some(t=>t in n||e&&t in e)}function O(o,e){const s=t(o,e)??{},c=[];let i=!0,p=!1;for(const[t,o]of Object.entries(s))b.has(t)?(i=t===r.Design,p=!1):w.has(t)?i&&(p=j.has(t)):p&&o&&"object"==typeof o&&!t.startsWith("_")&&(l(o)||S.has(t)||g.has(t)||D(o)||"slot"!==o.type&&c.push({path:[t],kind:A(o),counted:"mobile"!==n(o)?.tier}));return c}function d(t,o,n,e,r){i({scope:n,type:e.type,label:r,rows:t(o,e),props:e.props})}function L(t,o,n,e,r,s){const c=p(n);if(!c)return null;const i=u(c,{type:e.type,rows:t(o,e),props:e.props});return{...i,message:a(i,c.sourceLabel,r,s)}}function M(t,o,n,e){d(O,t,o,n,e)}function R(t,o,n,e,r){return L(O,t,o,n,e,r)}var V={scope:t=>v(t.siteId),rows:(t,o)=>O(t,o),copy:(t,o,n,e)=>M(e,t,o,n),plan:(t,o,n,e)=>R(e,t,o,n)};function B(t,o){if(!t&&!o)return V;const n=t?.rows,e=n?(t,o)=>n(t,o):O;return{scope:t?.scope??V.scope,rows:(t,o)=>e(t,o),copy:t?.copy??((t,o,n,r)=>d(e,r,t,o,n)),plan:t?.plan??((t,n,r,s)=>L(e,s,t,n,r,o))}}export{M as copyNodeStyle,O as nodeStyleRows,R as planNodePaste,A as shopFieldKind,v as siteStyleScope,B as styleClipboardOf};
@@ -1,7 +1,7 @@
1
- import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenChrome as n}from"./chunk-4BGYVIDQ.js";import{ScreenStoreProvider as e}from"./chunk-2L2L7G5L.js";import{ScreenDocumentProvider as i,useScreenDocument as a}from"./chunk-ZZ64CEC2.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-VVPZMWJE.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(e),k=r(n);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__ */
1
+ import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenChrome as n}from"./chunk-N3VPBHR6.js";import{ScreenStoreProvider as e}from"./chunk-MPF5QZJ7.js";import{ScreenDocumentProvider as i,useScreenDocument as a}from"./chunk-STWSCR25.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-C2RHV42O.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(e),k=r(n);function N({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:()=>{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 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]),G=c("screen",o);return l?/* @__PURE__ */u("div",{className:"sf-msg",children:G.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:Z,parts:n,children:/* @__PURE__ */u(k,{})}),f&&/* @__PURE__ */u(j,{onCancel:p,onDiscard:v,onSave:y})):/* @__PURE__ */u("div",{className:"sf-msg",children:G.loading}):/* @__PURE__ */u("div",{className:"sf-msg",children:G.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 j({target:r,addressing:n,onHostMessage:e,children:a}){/* @__PURE__ */
6
+ return u(i,{target:r,addressing:n,onHostMessage:e,children:a})}var y=(r,n)=>/* @__PURE__ */p(v,{children:[r,n]});function H({config:r,parts:n,wrap:e=y}){const{data:i,error:d,redirecting:l,ready:m,readOnly:g,onChange:h,pendingNav:f,cancelPendingNav:p,discardAndNavigate:v,saveAndNavigate:j}=a(),H=t(()=>s(!g),[g]),M=c("screen",o);return l?/* @__PURE__ */u("div",{className:"sf-msg",children:M.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:H,parts:n,children:/* @__PURE__ */u(k,{})}),f&&/* @__PURE__ */u(N,{onCancel:p,onDiscard:v,onSave:j})):/* @__PURE__ */u("div",{className:"sf-msg",children:M.loading}):/* @__PURE__ */u("div",{className:"sf-msg",children:M.waitingForAuthorization})}export{H as DocumentScreen,j as ScreenMount};
@@ -1,4 +1,4 @@
1
- import{useScreenOwnerName as e}from"./chunk-U25CP5VX.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-XHSGRH42.js";import{settlePanelPick as n}from"./chunk-R6WTQWAC.js";import{MediaPanelHead as i,mediaPickKind as c}from"./chunk-GWIVPLOX.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 @@
1
+ import{find as n,remove as t,getList as e,newId as r,duplicate as o,move as l,copyNode as a,insert as c,setProps as i,slotsOf as d}from"./chunk-KRXQM65X.js";import{useRef as s,useSyncExternalStore as p,useCallback as u,useMemo as f}from"react";var m=n=>({kind:"node",id:n});function x(r,o,l,a="none"){const c=n(r,o,l),i=t(r,o,l);if("none"===a||!c)return{data:i,select:null};const d=e(r,o,c.place)??[],s=d[c.place.index+1]??d[c.place.index-1];return s?.props?.id?{data:i,select:m(s.props.id)}:"root"!==c.place.parentId?{data:i,select:m(c.place.parentId)}:{data:i,select:null}}function g(t,e,l,a={}){const c=n(t,e,l)?.node,i=a.id??r(c?.type??"Node");return{data:o(t,e,l,{strip:a.strip,id:i}),select:m(i)}}function I(n,t,e,r){return{data:l(n,t,e,r),select:m(e)}}var h=(n,t)=>({min:0,max:t-1});function v(t,r,o,l,a=h){const c=n(t,r,o);if(!c)return!1;const i=e(t,r,c.place)?.length??0,{min:d,max:s}=a(c.place,i),p=c.place.index+l;return c.place.index>=d&&c.place.index<=s&&p>=d&&p<=s}function b(t,e,r,o,l=h){if(!v(t,e,r,o,l))return null;const a=n(t,e,r);return I(t,e,r,{...a.place,index:a.place.index+o})}function k(n,t,e,r,o={}){const l=a(e,t,{strip:o.strip});return{data:c(n,t,r,l),select:m(l.props.id)}}function y(t,r,o,l){if(n(t,r,o.props.id))return null;const a=e(t,r,l)??[],i={...l,index:Math.max(0,Math.min(l.index,a.length))};return{data:c(t,r,i,o),select:m(o.props.id)}}function M(e,r,o,l){const a=n(e,r,o);return a?l.props.id!==o&&n(e,r,l.props.id)?null:{data:c(t(e,r,o),r,a.place,l),select:m(l.props.id)}:null}function O(n,t,e,r){return{data:i(n,t,e,r),select:void 0}}function z(t,e,r,o=()=>!1){if(!r)return null;if("slot"===r.kind)return n(t,e,r.parentId)?m(r.parentId):null;const l=n(t,e,r.id);if(!l||"root"===l.place.parentId)return null;const a=n(t,e,l.place.parentId);return a?o(a.node,l.place.slot)?{kind:"slot",parentId:a.node.props.id,slot:l.place.slot}:m(a.node.props.id):null}function R(t,e,r,o){const l=n(t,e,r);if(!l)return[];const a=l.path.filter(n=>"root"!==n.parentId).map(n=>n.parentId);return o?[...a.filter(r=>{const l=n(t,e,r);return!l||!o(l.node)}),r]:[...a,r]}function B(n,t){if(0===n.length)return null;const e=null===t?-1:n.indexOf(t);return-1===e?n[0]:n[Math.min(e+1,n.length-1)]}function X(t,e,r,o,l){const a=n(t,e,r);return a?0===d(a.node,e).length?r:B(R(t,e,r,l),o):null}function $(t,e,r,o,l,a,c){const i=n(t,e,r);if(!i)return null;if(0===d(i.node,e).length)return{node:r,part:o};const s="\0part:"+o,p=B([...R(t,e,r,c),s],l===r&&a===o?s:l);return p===s?{node:r,part:o}:{node:p??r,part:null}}function j(t,e,r){if(!r||"node"!==r.kind)return null;const o=n(t,e,r.id);return o?{zone:`${o.place.parentId}:${o.place.slot}`,index:o.place.index}:null}function w(n,t,r){if(!r)return null;const[o,l]=(r.zone??"root:default-zone").split(/:(.*)/s),a={parentId:o,slot:l},c=e(n,t,a)?.[r.index];return c?.props?.id?m(c.props.id):null}var K={get:()=>null,set:()=>{},subscribe:()=>()=>{}};function L(t){const e=s(t);e.current=t;const r=t.clipboard??K,o=p(r.subscribe,r.get,r.get),l=u(n=>{const t=e.current;if(t.readOnly)return!1;const r=n(t.data,t.config);return!!r&&((r.data!==t.data||void 0!==r.select)&&(t.commit(r.data,{select:r.select}),e.current={...t,data:r.data},!0))},[]);return f(()=>{const t=()=>e.current,r=(e,r)=>{const o=n(t().data,t().config,e);return o?{node:o.node,label:r,from:{parentId:o.place.parentId,slot:o.place.slot}}:null};return{held:o,remove:n=>l((e,r)=>x(e,r,n,t().afterRemove)),duplicate:n=>l((e,r)=>g(e,r,n,{strip:t().strip})),move:(n,t)=>l((e,r)=>I(e,r,n,t)),step:(n,e)=>l((r,o)=>b(r,o,n,e,t().stepBounds)),canStep:(n,e)=>v(t().data,t().config,n,e,t().stepBounds),setProps:(n,t)=>l((e,r)=>O(e,r,n,t)),copy:(n,e)=>{const o=r(n,e);return o&&(t().clipboard??K).set(o),!!o},cut:(n,e)=>{if(t().readOnly)return!1;const o=r(n,e);return!!o&&((t().clipboard??K).set(o),l((e,r)=>x(e,r,n,t().afterRemove)))},paste:n=>{const e=(t().clipboard??K).get();return!!e&&l((r,o)=>k(r,o,e.node,n,{strip:t().strip}))},restore:(n,t)=>l((e,r)=>y(e,r,n,t)),swap:(n,t)=>l((e,r)=>M(e,r,n,t)),parentOf:n=>z(t().data,t().config,n,t().slotIsLevel)}},[o,l])}export{v as canStep,X as clickPick,$ as clickPickPart,w as fromItemSelector,B as nextInChain,R as nodeChain,z as parentStep,g as planDuplicate,I as planMove,k as planPaste,x as planRemove,y as planRestore,O as planSetProps,b as planStep,M as planSwap,j as toItemSelector,L as useNodeOps};
@@ -1,4 +1,4 @@
1
- import{PanelToggleIcon as e}from"./chunk-UMDQ6CLQ.js";import{InspectorHead as n}from"./chunk-IE55HNMA.js";import{DEFAULT_CHROME_WORDS as i}from"./chunk-Z6PVRXVY.js";import{useWords as o}from"./chunk-MFIRYGHW.js";import{Tooltip as s,IconButton as t,Button as c}from"efficient-shell/ui";import{jsx as r,jsxs as l,Fragment as d}from"react/jsx-runtime";function a({icon:e,title:i,context:o,actions:s,side:t="left",onHide:c}){/* @__PURE__ */
1
+ import{PanelToggleIcon as e}from"./chunk-UMDQ6CLQ.js";import{InspectorHead as n}from"./chunk-GWIVPLOX.js";import{DEFAULT_CHROME_WORDS as i}from"./chunk-Z6PVRXVY.js";import{useWords as o}from"./chunk-MFIRYGHW.js";import{Tooltip as s,IconButton as t,Button as c}from"efficient-shell/ui";import{jsx as r,jsxs as l,Fragment as d}from"react/jsx-runtime";function a({icon:e,title:i,context:o,actions:s,side:t="left",onHide:c}){/* @__PURE__ */
2
2
  return r(n,{icon:e,name:i,kind:o,actions:s||c?/* @__PURE__ */l(d,{children:[s,c?/* @__PURE__ */r(m,{side:t,onHide:c,divider:Boolean(s)}):null]}):void 0})}function m({side:n,onHide:c,divider:a=!1}){const m=o("chrome",i);/* @__PURE__ */
3
3
  return l(d,{children:[a?/* @__PURE__ */r("span",{className:"sf-head-divider","aria-hidden":"true"}):null,
4
4
  /* @__PURE__ */r(s,{content:m.hidePanel,side:"bottom",children:/* @__PURE__ */r(t,{className:"es-insp-iconbtn","aria-label":m.hidePanelLabel({side:n}),onClick:c,children:/* @__PURE__ */r(e,{side:n})})})]})}function h({side:n,onShow:c}){const l=o("chrome",i);/* @__PURE__ */
@@ -1,2 +1,2 @@
1
- import{noControlField as e}from"./chunk-7F52SZOI.js";import{DEFAULT_SCREEN_WORDS as n}from"./chunk-VVPZMWJE.js";import{useWords as r}from"./chunk-MFIRYGHW.js";import{usePreviewDevice as t}from"./chunk-BSPCSC45.js";import{jsx as o}from"react/jsx-runtime";function i(e){return"mobile"===e?"mobile":"desktop"}var c={desktop:null,tablet:n.deviceNote.tablet,mobile:n.deviceNote.mobile},u="data-sf-device-hidden";function d(){/* @__PURE__ */
1
+ import{noControlField as e}from"./chunk-7F52SZOI.js";import{DEFAULT_SCREEN_WORDS as n}from"./chunk-C2RHV42O.js";import{useWords as r}from"./chunk-MFIRYGHW.js";import{usePreviewDevice as t}from"./chunk-BSPCSC45.js";import{jsx as o}from"react/jsx-runtime";function i(e){return"mobile"===e?"mobile":"desktop"}var c={desktop:null,tablet:n.deviceNote.tablet,mobile:n.deviceNote.mobile},u="data-sf-device-hidden";function d(){/* @__PURE__ */
2
2
  return o("span",{hidden:!0,[u]:""})}function s({tier:e,render:n,...r}){return i(t())===e?/* @__PURE__ */o(n,{...r}):/* @__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=r("screen",n).deviceNote,i=t(),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};
@@ -0,0 +1,5 @@
1
+ import{usePickFollowsSelection as n}from"./chunk-R6WTQWAC.js";import{slotFieldsOf as e}from"./chunk-PLVEGYK6.js";import{EaselCanvas as t,useSelectedFields as r}from"./chunk-QEAUF632.js";import{Inspector as i}from"./chunk-5VD2LGIZ.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(n,t,r){const i=n.slotsOf?.(r);return i||e(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},L={labelAtLevel:(n,e,t)=>t,descriptions:{},categoryLabel:()=>{},firstSection:null,blockRowName:(n,e)=>e(n.type),plainText:n=>n,Icon:()=>null,Thumbnail:()=>null,useProducts:()=>null},O={options:[{id:"desktop",label:"Desktop",icon:/* @__PURE__ */s(l,{})}],initial:"desktop",fluid:"desktop",widths:{desktop:2e3}},j={read:()=>"sections",write:()=>{},forSelection:(n,e)=>n?"sections":e},w={first:null,last:null,firstGroup:null,lastGroup:null,isSectionGroup:()=>!1,sectionGroupZone:()=>"",panelOf:()=>null};function S(){/* @__PURE__ */
2
+ return s(t,{height:"fill"})}function C(){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 D=o({});function G({parts:n,children:e}){/* @__PURE__ */
4
+ return s(D.Provider,{value:n,children:e})}function P(){return u(D)}function I(){return(P().useOwnerName??v)()}function N(){return(P().useDocumentLabel??g)()}function x(n,e,t,r){return(P().useBridges??h)(n,e,t,r)}function A(n){return(P().useStandaloneBridges??h)(n)}function B(n,e){(P().useDocumentPass??y)(n,e)}function F(){return P().blockRules??b}function T(){return P().blockLook??L}function R(){return P().devices??O}function V(){return P().leftView??j}function E(){return P().pinned??w}function K(){return P().saveSwitch??!0}function Q(e){n(!0===P().pickFollowsSelection,e)}function W(){return P().storageNamespace||void 0}function Z(){return P().styleClipboard??null}function H(){return P().nodeKeys??!0}function U(){return P().notify??null}function Y(){return P().Canvas??S}function q(){return P().CanvasHead??null}function z(){return P().canvasDrag??null}var J=o(null);function M({target:n,children:e}){/* @__PURE__ */
5
+ return s(J.Provider,{value:n,children:e})}function X(){return u(J)}function $(){return P().Inspector??C}export{c as SELECTION_MODE,M as ScreenCanvasTargetProvider,G as ScreenPartsProvider,p as isPinnedFirst,m as isPinnedLast,a as isSlotMode,f as sameInspectorMode,d as screenSlotsOf,T as useScreenBlockLook,F as useScreenBlockRules,x as useScreenBridges,z as useScreenCanvasDrag,Y as useScreenCanvasFrame,q as useScreenCanvasHead,X as useScreenCanvasTarget,R as useScreenDevices,N as useScreenDocumentLabel,B as useScreenDocumentPass,$ as useScreenInspectorPanel,V as useScreenLeftView,H as useScreenNodeKeys,U as useScreenNotify,I as useScreenOwnerName,P as useScreenParts,Q as useScreenPickFollowsSelection,E as useScreenPinned,K as useScreenSaveSwitch,W as useScreenStorageNamespace,Z as useScreenStyleClipboard,A as useStandaloneScreenBridges};
@@ -1 +1 @@
1
- import{useSectionOps as o}from"./chunk-V6VKM2QX.js";import{SELECTION_MODE as e}from"./chunk-U25CP5VX.js";import{decodePartId as r,encodePartId as t}from"./chunk-IYT6NN2J.js";import{useEasel as n}from"./chunk-QX7GVECM.js";import{usePreviewParts as p}from"./chunk-I54UCYOU.js";import{useCallback as d,useEffect as c}from"react";var s=o=>"part"===o.kind;function m({mode:m,setMode:i,onOpenPart:a}){const{getSelectorForId:u}=n(o=>o),I=o(),{setSelectedPartId:f,setSelectHandler:k}=p(),l=d(o=>{const t=r(o);if(!t)return;const{nodeId:n,propKey:p}=t;p?(i(o=>s(o)&&o.nodeId===n&&o.propKey===p?o:{kind:"part",nodeId:n,propKey:p}),a?.(n)):i(o=>"part"===o.kind?e:o)},[i,a]);c(()=>{k(l)},[k,l]);const h=s(m)?t(m.nodeId,m.propKey):null;c(()=>{f(h)},[h,f]);return{selectNode:d(o=>{i(()=>e);const r=u(o);r&&I.select(r)},[i,u,I]),openPartId:h}}export{m as usePartBridge};
1
+ import{useSectionOps as o}from"./chunk-A7FF65FL.js";import{SELECTION_MODE as e}from"./chunk-XHSGRH42.js";import{decodePartId as r,encodePartId as t}from"./chunk-IYT6NN2J.js";import{useEasel as n}from"./chunk-QEAUF632.js";import{usePreviewParts as p}from"./chunk-I54UCYOU.js";import{useCallback as d,useEffect as c}from"react";var s=o=>"part"===o.kind;function m({mode:m,setMode:i,onOpenPart:a}){const{getSelectorForId:u}=n(o=>o),I=o(),{setSelectedPartId:f,setSelectHandler:k}=p(),l=d(o=>{const t=r(o);if(!t)return;const{nodeId:n,propKey:p}=t;p?(i(o=>s(o)&&o.nodeId===n&&o.propKey===p?o:{kind:"part",nodeId:n,propKey:p}),a?.(n)):i(o=>"part"===o.kind?e:o)},[i,a]);c(()=>{k(l)},[k,l]);const h=s(m)?t(m.nodeId,m.propKey):null;c(()=>{f(h)},[h,f]);return{selectNode:d(o=>{i(()=>e);const r=u(o);r&&I.select(r)},[i,u,I]),openPartId:h}}export{m as usePartBridge};
@@ -1 +1 @@
1
- import{useEaselHost as n}from"./chunk-U3JP4VGF.js";import{useEaselApi as e,bindUndoKeys as t}from"./chunk-QX7GVECM.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-QEAUF632.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};