efficient-easel 22.0.0 → 23.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 (145) hide show
  1. package/README.md +38 -23
  2. package/dist/{CanvasDragLayer-B6Yn9S8T.d.ts → CanvasDragLayer-NZpaX6aq.d.ts} +15 -4
  3. package/dist/{ScreenDocumentContext-BIK3uWtF.d.ts → ScreenDocumentContext-BDLUYzlM.d.ts} +4 -4
  4. package/dist/blocks/index.d.ts +11 -11
  5. package/dist/canvas/index.d.ts +21 -9
  6. package/dist/canvas/index.js +1 -1
  7. package/dist/{canvas-typing-Be4FO4q7.d.ts → canvas-typing-DOBx8dD3.d.ts} +12 -2
  8. package/dist/{chunk-XWKQP6AE.js → chunk-3P735WOM.js} +4 -4
  9. package/dist/{chunk-KWLHKKZO.js → chunk-4YUC7B7E.js} +1 -1
  10. package/dist/chunk-6F5GO337.js +1 -0
  11. package/dist/{chunk-3S5N4HLJ.js → chunk-6NJHYXJM.js} +1 -1
  12. package/dist/{chunk-BTDI7JAA.js → chunk-A6ZP5II4.js} +2 -2
  13. package/dist/{chunk-IWCKVZHS.js → chunk-AGWKB77Q.js} +1 -1
  14. package/dist/chunk-AT4DDMJS.js +1 -0
  15. package/dist/chunk-FF54HWSE.js +8 -0
  16. package/dist/{chunk-IROEWITG.js → chunk-FOOK54T2.js} +1 -1
  17. package/dist/{chunk-SWBADIQT.js → chunk-G3HAKQUF.js} +1 -1
  18. package/dist/{chunk-ZOSEBPAI.js → chunk-GKG3M5QK.js} +1 -1
  19. package/dist/chunk-GXRS52JD.js +5 -0
  20. package/dist/{chunk-YC6KLSW3.js → chunk-HLMQ34GP.js} +1 -1
  21. package/dist/chunk-HZSZT3BE.js +7 -0
  22. package/dist/{chunk-EB6NI2VK.js → chunk-IYHO4XQX.js} +1 -1
  23. package/dist/chunk-IZGFJWH4.js +1 -0
  24. package/dist/chunk-KXM6YRG2.js +1 -0
  25. package/dist/chunk-KXTXYINN.js +16 -0
  26. package/dist/chunk-LN43DP2A.js +18 -0
  27. package/dist/{chunk-YHFKWV7H.js → chunk-MXECWHRJ.js} +10 -10
  28. package/dist/chunk-OXZDSOZV.js +1 -0
  29. package/dist/{chunk-BSHIQIZC.js → chunk-RPMSET77.js} +1 -1
  30. package/dist/{chunk-K7BTCBWD.js → chunk-TGZCD6IP.js} +1 -1
  31. package/dist/chunk-VZUXOZGP.js +64 -0
  32. package/dist/{chunk-RY5AWQ63.js → chunk-XJ23ULBP.js} +1 -1
  33. package/dist/{chunk-TLN5ZT76.js → chunk-YHEYJKQL.js} +1 -1
  34. package/dist/chunk-YU3WHLGI.js +1 -0
  35. package/dist/copy/index.d.ts +20 -6
  36. package/dist/copy/index.js +29 -29
  37. package/dist/data/index.d.ts +30 -22
  38. package/dist/data/index.js +1 -1
  39. package/dist/drag/drag.css +10 -1
  40. package/dist/drag/index.d.ts +5 -5
  41. package/dist/drag/index.js +1 -1
  42. package/dist/draw/index.d.ts +1 -1
  43. package/dist/easel/easel.css +12 -5
  44. package/dist/easel/index.d.ts +90 -53
  45. package/dist/easel/index.js +1 -1
  46. package/dist/edit-lock/index.d.ts +5 -5
  47. package/dist/fields/fields.css +1 -1
  48. package/dist/fields/index.d.ts +15 -15
  49. package/dist/fields/index.js +1 -1
  50. package/dist/node-ops/index.d.ts +3 -3
  51. package/dist/node-ops/index.js +1 -1
  52. package/dist/panel/index.d.ts +1 -1
  53. package/dist/panel/panel.css +6 -1
  54. package/dist/pick/index.d.ts +5 -5
  55. package/dist/{plan-CRUh2kVK.d.ts → plan-D0DgSLnY.d.ts} +5 -5
  56. package/dist/render/index.d.ts +13 -13
  57. package/dist/render/index.js +1 -1
  58. package/dist/{resolve-AJ6WF4EL.d.ts → resolve-Bz4mszpL.d.ts} +5 -5
  59. package/dist/screen/components/AddBlockRow.js +1 -1
  60. package/dist/screen/components/AddSidePanel.d.ts +2 -2
  61. package/dist/screen/components/AddSidePanel.js +1 -1
  62. package/dist/screen/components/NodeContextMenu.d.ts +17 -20
  63. package/dist/screen/components/NodeContextMenu.js +1 -1
  64. package/dist/screen/components/PageEditGuardNotices.js +1 -1
  65. package/dist/screen/components/PreviewDeviceContext.d.ts +1 -1
  66. package/dist/screen/components/PreviewPartsContext.d.ts +2 -2
  67. package/dist/screen/components/SaveControls.d.ts +8 -8
  68. package/dist/screen/components/ScreenChrome.js +1 -1
  69. package/dist/screen/components/ScreenDocumentContext.d.ts +5 -5
  70. package/dist/screen/components/ScreenDocumentContext.js +1 -1
  71. package/dist/screen/components/ScreenMount.d.ts +8 -8
  72. package/dist/screen/components/ScreenMount.js +1 -1
  73. package/dist/screen/components/ScreenStoreProvider.d.ts +12 -12
  74. package/dist/screen/components/ScreenStoreProvider.js +1 -1
  75. package/dist/screen/components/SectionScreenShell.js +17 -17
  76. package/dist/screen/components/usePartBridge.d.ts +10 -10
  77. package/dist/screen/components/usePartBridge.js +1 -1
  78. package/dist/screen/index.d.ts +8 -8
  79. package/dist/screen/index.js +1 -1
  80. package/dist/screen/lib/admin-bridge.d.ts +4 -4
  81. package/dist/screen/lib/document/block-types-in.d.ts +2 -1
  82. package/dist/screen/lib/document/block-types-in.js +1 -1
  83. package/dist/screen/lib/document/content-tree.d.ts +8 -8
  84. package/dist/screen/lib/document/device-fields.d.ts +7 -7
  85. package/dist/screen/lib/document/device-fields.js +1 -1
  86. package/dist/screen/lib/document/field-markers.d.ts +4 -4
  87. package/dist/screen/lib/document/palette-sections.d.ts +5 -5
  88. package/dist/screen/lib/document/panel-fields.d.ts +5 -5
  89. package/dist/screen/lib/document/panel-no-control-mark.d.ts +3 -3
  90. package/dist/screen/lib/document/part-id.d.ts +1 -1
  91. package/dist/screen/lib/document/preview-events.d.ts +2 -2
  92. package/dist/screen/lib/document/preview-selection-context.d.ts +2 -2
  93. package/dist/screen/lib/document/section-doc.d.ts +5 -5
  94. package/dist/screen/lib/document/section-doc.js +1 -1
  95. package/dist/screen/lib/document/slot-child-name.d.ts +1 -1
  96. package/dist/screen/lib/document/slot-section-spec.d.ts +1 -1
  97. package/dist/screen/lib/document/style-clipboard.d.ts +8 -8
  98. package/dist/screen/lib/document/style-clipboard.js +1 -1
  99. package/dist/screen/lib/document/tree-reveal.d.ts +4 -4
  100. package/dist/screen/lib/document/use-section-ops.d.ts +6 -6
  101. package/dist/screen/lib/document/use-section-ops.js +1 -1
  102. package/dist/screen/lib/document-addressing.d.ts +5 -5
  103. package/dist/screen/lib/document-hooks.d.ts +4 -4
  104. package/dist/screen/lib/host.d.ts +5 -5
  105. package/dist/screen/lib/key-scope.d.ts +1 -1
  106. package/dist/screen/lib/key-scope.js +1 -1
  107. package/dist/screen/lib/media-panel.d.ts +5 -5
  108. package/dist/screen/lib/media-picker.d.ts +6 -6
  109. package/dist/screen/lib/page-lock.d.ts +4 -4
  110. package/dist/screen/lib/screen-parts.d.ts +22 -10
  111. package/dist/screen/lib/screen-parts.js +1 -1
  112. package/dist/screen/lib/section-templates.d.ts +4 -4
  113. package/dist/screen/lib/session-context.d.ts +4 -4
  114. package/dist/screen/lib/session.d.ts +5 -5
  115. package/dist/screen/lib/shared-sections.d.ts +4 -4
  116. package/dist/screen/screen.css +14 -14
  117. package/dist/screen/words.d.ts +4 -3
  118. package/dist/screen/words.js +1 -1
  119. package/dist/{session-CrWwDt7Z.d.ts → session-EsjORLQ0.d.ts} +1 -1
  120. package/dist/shell/shell.css +2 -2
  121. package/dist/strings/index.d.ts +2 -2
  122. package/dist/strings/index.js +2 -2
  123. package/dist/style-clipboard/index.d.ts +2 -2
  124. package/dist/text-styles/index.d.ts +3 -3
  125. package/dist/text-styles/model.d.ts +1 -1
  126. package/dist/{types-BFd8FqQw.d.ts → types-BIytwvvH.d.ts} +2 -2
  127. package/dist/{types-DFxBChE3.d.ts → types-BljCVdzR.d.ts} +17 -17
  128. package/dist/{types-DlQIM1YO.d.ts → types-Dq180WRV.d.ts} +8 -8
  129. package/dist/{useNodeOps-C_nisDHh.d.ts → useNodeOps-igxrnEhq.d.ts} +2 -2
  130. package/dist/{watch-D0bNZRtU.d.ts → watch-Unf6SfUf.d.ts} +3 -3
  131. package/dist/{words-gIDCeRv3.d.ts → words-B5Gb7KFq.d.ts} +1 -1
  132. package/dist/{words-BpTjCfqO.d.ts → words-Cf5VT2Ic.d.ts} +2 -2
  133. package/package.json +1 -1
  134. package/dist/chunk-4LGROS5L.js +0 -1
  135. package/dist/chunk-BDSLF5BR.js +0 -1
  136. package/dist/chunk-CPL43ZLJ.js +0 -1
  137. package/dist/chunk-CUZQ2HMA.js +0 -18
  138. package/dist/chunk-GHBK7BKL.js +0 -1
  139. package/dist/chunk-IYYE7VJN.js +0 -65
  140. package/dist/chunk-KN2TIXUT.js +0 -1
  141. package/dist/chunk-L55YIXDC.js +0 -1
  142. package/dist/chunk-MZ5GSSZ3.js +0 -7
  143. package/dist/chunk-SJMS247S.js +0 -5
  144. package/dist/chunk-TXR7GC5A.js +0 -8
  145. package/dist/chunk-WJSEWAWK.js +0 -15
@@ -1,65 +0,0 @@
1
- import{cloneNodeWithFreshIds as e}from"./chunk-BDSLF5BR.js";import{dedupeSlotChildren as n}from"./chunk-7OCEPOEJ.js";import{styleClipboardOf as t}from"./chunk-SWBADIQT.js";import{markedTreeNodeId as o,revealSelectedTreeRow as r,sameSelector as i}from"./chunk-UMBNBCL4.js";import{scrollPreviewToSection as l,gotoPreviewSlide as s,scrollPreviewToTop as d}from"./chunk-DDH2DYQP.js";import{useEaselKeyTarget as a,useEaselUndoKeys as c,useEaselSaveKey as p,editorRootFocus as u}from"./chunk-TLN5ZT76.js";import{SlotChildActionsProvider as h}from"./chunk-KCBEE2MC.js";import{screenStorageKeys as f,DEFAULT_PANEL_W as m,clampPanelWidth as g}from"./chunk-C56MPJBH.js";import{usePartBridge as y}from"./chunk-KN2TIXUT.js";import{useSectionOps as v}from"./chunk-IROEWITG.js";import{ScreenSaveIcon as k,ScreenMainButton as b}from"./chunk-PY7OOQEZ.js";import{useBrowserOffline as S}from"./chunk-RKTF5XLP.js";import{AddChildRow as w}from"./chunk-5545A3PC.js";import{AddSidePanel as x}from"./chunk-TXR7GC5A.js";import{keepsSharedSections as z,sharedSectionsOf as C}from"./chunk-N3MJOHAG.js";import{PanelHideButton as B,SidePanelHead as I,PanelShowStrip as N}from"./chunk-SINAM2IT.js";import{offeredChoices as O}from"./chunk-RUQOIQWI.js";import{useScreenSaveSwitch as P,useScreenNodeKeys as $,useScreenPinned as M,useScreenDocumentLabel as T,useScreenCanvasFrame as A,useScreenInspectorPanel as j,useScreenDevices as L,useScreenPickFollowsSelection as E,useScreenLeftView as R,SELECTION_MODE as F,isSelectionMode as D,sameInspectorMode as W,useScreenBridges as H,useScreenBlockRules as V,useScreenBlockLook as U,useScreenStorageNamespace as Y,useScreenNotify as G,useScreenCanvasHead as J,isSlotMode as K,useScreenStyleClipboard as Q,useScreenDocumentPass as X,useScreenCanvasDrag as Z,ScreenCanvasTargetProvider as _,isPinnedFirst as q,isPinnedLast as ee,screenSlotsOf as ne}from"./chunk-SJMS247S.js";import{MediaPopup as te}from"./chunk-2G6MAXPY.js";import{useNodeClipboard as oe,useNodeContextMenu as re}from"./chunk-4LGROS5L.js";import{PageEditGuardNotices as ie}from"./chunk-ZOSEBPAI.js";import{useScreenDocument as le}from"./chunk-BTDI7JAA.js";import{requestMediaPick as se}from"./chunk-UNVKPVZW.js";import{useMediaPanel as de,usePanelPick as ae,useMediaBrowsing as ce,useOpenMediaBrowse as pe,useMediaPlace as ue}from"./chunk-FHCKFOCD.js";import{useEaselSession as he}from"./chunk-YM4UEGBV.js";import{useEaselHost as fe,useHostEscape as me}from"./chunk-MQA7OFRA.js";import{LayersIcon as ge,MediaIcon as ye}from"./chunk-XFYFKITX.js";import{DEFAULT_SCREEN_WORDS as ve}from"./chunk-EB6NI2VK.js";import{heldStyle as ke,styleShortcut as be}from"./chunk-V7U33NF2.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as Se}from"./chunk-6WY6ZXJG.js";import{rootRowName as we,slotChildRowName as xe,slotChildRenameProp as ze,sectionRenameProp as Ce}from"./chunk-SSRYU3YG.js";import{ROOT_ZONE as Be,blockNodeActions as Ie,TREE_MAX_DEPTH as Ne,childSlotsOf as Oe,slotFieldsOf as Pe,newNodeId as $e,slotChildrenIn as Me,nestsInTree as Te}from"./chunk-TCAAOYQY.js";import{useEasel as Ae,useEaselApi as je,CanvasPassThroughContext as Le,CanvasSharedContext as Ee}from"./chunk-WJSEWAWK.js";import{TreeRow as Re,Subtree as Fe,LayersTree as De,TreeGroupLabel as We,TreeRowAction as He,TreeSeam as Ve}from"./chunk-WHS6Y55E.js";import{DEFAULT_TREE_WORDS as Ue}from"./chunk-K56YDHYQ.js";import{DEFAULT_NODE_MENU_WORDS as Ye}from"./chunk-WK3AFPXY.js";import{toItemSelector as Ge,useNodeOps as Je,clickPick as Ke}from"./chunk-BSHIQIZC.js";import{EaselTopBar as Qe,EaselIconButton as Xe,TopBarCluster as Ze,DeviceSwitch as _e,InspectorIconButton as qe,PanelResizeHandle as en,MAX_PANEL_W as nn,MIN_PANEL_W_BY_SIDE as tn,panelWidthVars as on}from"./chunk-ZG6PVMC3.js";import{DEFAULT_NOTICE_WORDS as rn,DEFAULT_CHROME_WORDS as ln}from"./chunk-AJSDWWJW.js";import{holderOf as sn,nameOrSomeone as dn}from"./chunk-THWO5YVZ.js";import{DEFAULT_LOCK_WORDS as an}from"./chunk-RE4LP46F.js";import{useWords as cn}from"./chunk-MFIRYGHW.js";import{insertSeams as pn,CanvasDragLayer as un,CanvasInsert as hn}from"./chunk-CUZQ2HMA.js";import{DEFAULT_DRAG_WORDS as fn}from"./chunk-TQ5Y6S2X.js";import{createDragSession as mn,useTreeDrag as gn,gapToMoveIndex as yn}from"./chunk-3S5N4HLJ.js";import{useCanvasFrame as vn,LIST_SELECTOR as kn,BLOCK_SELECTOR as bn,useCanvasTyping as Sn,useCanvasEvent as wn,nodeIdAt as xn,frameRectToHost as zn,BLOCK_ATTRIBUTE as Cn,drawnBox as Bn}from"./chunk-GHBK7BKL.js";import{queryMainCopy as In}from"./chunk-LF3FUSCQ.js";import{ROOT_ID as Nn,ROOT_SLOT as On,zoneKey as Pn,parseZoneKey as $n,find as Mn,DataError as Tn}from"./chunk-K7BTCBWD.js";import{useRef as An,useMemo as jn,useState as Ln,useEffect as En,useCallback as Rn,useLayoutEffect as Fn,Fragment as Dn,useId as Wn}from"react";import{ColoredBadge as Hn,Button as Vn,Tabs as Un,toast as Yn,readMediaFileDrag as Gn,Tooltip as Jn,groupColors as Kn,Dialog as Qn,FormField as Xn,Input as Zn,MEDIA_FILE_DRAG_TYPE as _n}from"efficient-shell/ui";import{UndoIcon as qn,RedoIcon as et,RefreshIcon as nt,AddIcon as tt,TrashIcon as ot,EyeOffIcon as rt,EyeIcon as it,SharedIcon as lt,DuplicateIcon as st}from"efficient-shell/icons/efficient";import{jsx as dt,jsxs as at,Fragment as ct}from"react/jsx-runtime";var pt="media-file";function ut({name:e,onMake:n,onCancel:t}){const o=cn("screen",ve).shared,[r,i]=Ln(e),[l,s]=Ln(!1),d=Wn(),a=An(null),c=async()=>{const e=r.trim();if(e&&!l){s(!0);try{await n(e)}finally{s(!1)}}};/* @__PURE__ */
2
- return dt(Qn,{open:!0,size:"sm",title:o.makeShared,description:o.makeSharedHint,onClose:t,initialFocus:a,footer:/* @__PURE__ */at(ct,{children:[
3
- /* @__PURE__ */dt(Vn,{variant:"secondary",onClick:t,children:o.cancel}),
4
- /* @__PURE__ */dt(Vn,{variant:"primary",loading:l,disabled:!r.trim(),onClick:()=>{c()},children:o.makeShared})]}),children:/* @__PURE__ */dt("form",{onSubmit:e=>{e.preventDefault(),c()},children:/* @__PURE__ */dt(Xn,{label:o.name,htmlFor:d,children:/* @__PURE__ */dt(Zn,{id:d,ref:a,value:r,onChange:e=>i(e.target.value)})})})})}var ht=/* @__PURE__ */new WeakSet;function ft(e,n,t){const o=Mn(e,n,t);if(!o)return null;const r=o.path.find(e=>"root"!==e.parentId);return r?r.parentId:t}function mt({canvas:e,tabs:n,onSelect:t}){const o=An(null),[r,i]=Ln({}),l=n.map(e=>`${e.id}:${e.below?1:0}`).join("|");return Fn(()=>{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=zn(l,{left:0,top:0,width:r.innerWidth,height:r.innerHeight},e),a={};for(const o of n){const n=In(t,`[${Cn}="${r.CSS?.escape?r.CSS.escape(o.id):o.id}"]`),i=n?Bn(n):null;if(!i||0===i.height){a[o.id]=null;continue}const s=zn(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__ */dt("div",{ref:o,className:"es-band-tabs","aria-hidden":"true",children:n.map(e=>{const n=r[e.id];return n?/* @__PURE__ */dt("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__ */dt(Jn,{content:e.reach,children:/* @__PURE__ */at(Hn,{colorClass:Kn("success","solid"),size:"sm",children:[
6
- /* @__PURE__ */dt("span",{className:"es-band-tab-mark",children:/* @__PURE__ */dt(lt,{size:12})}),e.label]})}):/* @__PURE__ */dt(Hn,{colorClass:Kn("info","solid"),size:"sm",children:e.label})},e.id):null})})}function gt({expand:e}){/* @__PURE__ */
7
- return dt("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round",children:/* @__PURE__ */at(ct,e?{children:[
8
- /* @__PURE__ */dt("path",{d:"M8 9l4-4 4 4"}),
9
- /* @__PURE__ */dt("path",{d:"M8 15l4 4 4-4"})]}:{children:[
10
- /* @__PURE__ */dt("path",{d:"M8 4l4 4 4-4"}),
11
- /* @__PURE__ */dt("path",{d:"M8 20l4-4 4 4"}),
12
- /* @__PURE__ */dt("path",{d:"M5 12h14"})]})})}var yt=`${kn}, ${bn}`;function vt(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 kt="__rungs";var bt="screen:band",St={duplicate:!0,delete:!0},wt=()=>null;function xt(){const kn=fe(),zn=kn.panels?.Toolbar,Cn=(kn.panels?.useRight??wt)(),{target:Bn,docId:Wn,capabilities:Jn,currentSlug:Kn,siteId:Qn,onPublish:Xn,saveState:Zn,saveConflict:lt,retrySave:xt,toggleAutoSave:zt,flushSave:Ct,access:Bt,saveUnreachable:It=!1,readOnly:Nt,readOnlyReason:Ot=null}=le(),Pt=P(),$t=$(),{mediaEditing:Mt,hasEditGuard:Tt,hasPinnedChrome:At}=Jn,{appState:jt,dispatch:Lt,history:Et,selectedItem:Rt,getSelectorForId:Ft,config:Dt}=Ae(e=>e),Wt=M(),{first:Ht,firstGroup:Vt,lastGroup:Ut,isSectionGroup:Yt,sectionGroupZone:Gt,panelOf:Jt}=Wt,Kt=Jt(Ht),Qt=e=>q(Wt,e),Xt=e=>ee(Wt,e),Zt="node"===Wt.firstRow,_t=Wt.band??null,qt=cn("screen",ve),eo=cn("tree",Ue),no=cn("drag",fn),to=cn("notice",rn),oo=cn("lock",an),ro=cn("menu",Ye),io=cn("styleClipboard",Se),lo=cn("chrome",ln),so=T()??`/${Kn}`,ao=A(),co=j(),po=v({readOnly:Nt}),uo=v({readOnly:Nt,foldIntoHistory:!0}),ho=An(null),fo=je(),mo=jn(()=>({...po,select:e=>{ho.current=e,po.select(e)},commitDocument:(e,n)=>{if(void 0!==n){const t=fo.config;ho.current=Ge(e,t,n)}po.commitDocument(e,n)}}),[po,fo]),go=jt.ui,yo=go.leftSideBarVisible,vo=go.rightSideBarVisible,{options:ko,widths:bo,initial:So,fluid:wo,fit:xo}=L(),[zo,Co]=Ln(So),Bo=de(),Io=Mt&&null!==Bo;ae(),ce();const No=pe();E(Rt?.props.id);const{read:Oo,write:Po,forSelection:$o}=R(),[Mo,To]=Ln(Oo);En(()=>{Po(Mo)},[Mo]);const[Ao,jo]=Ln(0),Lo=An(null),Eo=An(null),Ro=vn(Eo,{readySelector:yt}),Fo=Sn(Ro),Do=a(Eo);c(Eo,Ro);const Wo=S(),Ho=sn(Bt),Vo={state:Zn,offline:Wo||Zn.failed&&It,readOnlyReason:Ot,editing:Ho?to.editing({name:dn(Ho.name,oo),noun:qt.noun}):null,conflict:null!=lt,notSaving:qt.bar.notSaving},Uo=()=>{Nt||(Zn.failed?xt():Ct())};p(Eo,Ro,Uo);const[Yo,Go]=Ln(!1),Jo=An(!1),[Ko,Qo]=Ln(null),[Xo,Zo]=Ln([]),[_o,qo]=Ln(F),er=D(_o),nr=o(_o,Rt?.props.id),[tr,or]=Ln(null);En(()=>{tr&&(r(),or(null))},[tr]);const rr=An(Ft);rr.current=Ft;const ir=Rn((e,{scroll:n})=>{To(n=>$o(e,n)),n&&or(e);const t=[];let o=e;for(let e=0;e<4;e++){const e=rr.current(o)?.zone;if(!e||!e.includes(":"))break;const n=e.split(":")[0];t.push(n),t.push(e),o=n}0!==t.length&&Ar(e=>{if(t.every(n=>!e.has(n)))return e;const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},[]),lr=An(null);En(()=>{const e=lr.current;lr.current=null;const n=null==Rt?.props.id?null:String(Rt.props.id);qo(t=>e&&e.id===n?e.mode:"part"===t.kind&&"nodeId"in t&&t.nodeId===n?t:Jt(Rt?.type)??F);const t=Rt?.props.id,o=ho.current;if(ho.current=null,!t)return;const r=Ft(t);ir(String(t),{scroll:!i(o,r??null,Be)})},[Rt?.props.id,ir]);const sr=Rn(e=>{qo(n=>W(n,e)?n:e),Lt({type:"setUi",ui:{rightSideBarVisible:!0}})},[Lt]),dr=An(()=>{});dr.current=(e,n)=>{const t=e?Pi(e.zone??Be)[e.index]?.props.id:null,o=null==t?null:String(t),r=null==Rt?.props.id?null:String(Rt.props.id);qo(e=>W(e,n)?e:n),o!==r&&(lr.current={id:o,mode:n},mo.select(e))};const ar=Rn((e,n)=>dr.current(e,n),[]),cr={kind:_o.kind,mode:_o,open:sr,show:e=>qo(e),reveal:()=>{vo||Lt({type:"setUi",ui:{rightSideBarVisible:!0}})},select:ar},pr=H(cr,{data:jt.data,selected:Rt??null,zoneOf:e=>Ft(e)?.zone,readOnly:Boolean(Nt),select:e=>{qo(F),mo.select({index:e})},replace:(e,n)=>mo.replaceComponent(Be,e,n),scrollTo:e=>l(e)},{device:zo,refreshes:Ao},{setView:To,reveal:()=>{yo||Lt({type:"setUi",ui:{leftSideBarVisible:!0}})}}),ur=pr.resolveLeftView?pr.resolveLeftView(Mo):"sections",hr=V(),{isLockedBlock:fr,duplicateBlocked:mr,nestDepth:gr,newSectionNode:yr,canAddTo:vr,blockIsOffered:kr}=hr,br=U(),{labelAtLevel:Sr,Icon:wr,useProducts:xr}=br,zr=br.rowName?(e,n,t)=>br.rowName(e,n,t):void 0,Cr=Rn(e=>{Lt({type:"setUi",ui:{rightSideBarVisible:!0}}),l(e),ir(e,{scroll:!0})},[Lt,ir]),{selectNode:Br,openPartId:Ir}=y({mode:_o,setMode:qo,onOpenPart:Cr}),[Nr,Or]=Ln(null);me(null!==Nr,()=>Or(null));const Pr=f(Y()),$r=Pr.collapsed,Mr=Pr.panelWidths,[Tr,Ar]=Ln(()=>{if("undefined"==typeof window)/* @__PURE__ */return new Set;try{const e=window.localStorage.getItem($r);return new Set(e?JSON.parse(e):[])}catch{/* @__PURE__ */
13
- return new Set}});En(()=>{try{window.localStorage.setItem($r,JSON.stringify([...Tr]))}catch{}},[Tr]);const[jr,Lr]=Ln(()=>{if("undefined"==typeof window)return{...m};try{const e=window.localStorage.getItem(Mr);if(!e)return{...m};const n=JSON.parse(e);return{left:g(Number(n.left)||m.left,"left"),right:g(Number(n.right)||m.right,"right")}}catch{return{...m}}});En(()=>{const e=setTimeout(()=>{try{window.localStorage.setItem(Mr,JSON.stringify(jr))}catch{}},300);return()=>clearTimeout(e)},[jr]);const Er=Rn((e,n)=>Lr(t=>{const o="function"==typeof n?n(t[e]):n;return t[e]===o?t:{...t,[e]:o}}),[]),Rr=Rn(e=>Er("left",e),[Er]),Fr=Rn(e=>Er("right",e),[Er]),Dr=e=>Tr.has(e),Wr=e=>Ar(n=>{const t=new Set(n);return t.has(e)?t.delete(e):t.add(e),t}),Hr=An(!1),Vr=An(null);En(()=>{if(Hr.current&&!Yo){const e=Vr.current,n=e&&e.isConnected&&!e.closest('[aria-hidden="true"]')?e:null;(n??Eo.current?.querySelector(`button[aria-label="${CSS.escape(qt.add.title)}"]`))?.focus(),Vr.current=null}Hr.current=Yo},[Yo]),En(()=>{if(!Yo||!Do)return;const e=e=>{"Escape"===e.key&&dl()};return Do.addEventListener("keydown",e),()=>Do.removeEventListener("keydown",e)},[Yo,Do]),me(Yo,()=>dl()),En(()=>{!yo&&Yo&&(Go(!1),Qo(null),Jo.current=!1)},[yo]);const Ur=G(),Yr=(e,n="success",t)=>{if(Ur)return void(t?Ur(e,"error"===n?"error":"info",t):Ur(e,"error"===n?"error":"info"));const o={sound:!1,action:t?.action,onClose:t?.onClose};"error"===n?Yn.error(e,{...o,duration:t?.duration??3200}):Yn.success(e,{...o,duration:t?.duration??1900})},Gr=An(null),[Jr,Kr]=Ln(0),[Qr,Xr]=Ln(0),Zr=J(),_r=An(null),qr=e=>Math.max(0,e.clientHeight-(_r.current?.offsetHeight??0));En(()=>{const e=Gr.current;if(!e)return;const n=()=>{Kr(e.clientWidth),Xr(qr(e))};n();const t=new ResizeObserver(n);return t.observe(e),_r.current&&t.observe(_r.current),()=>t.disconnect()},[]),Fn(()=>{Gr.current&&(Kr(Gr.current.clientWidth),Xr(qr(Gr.current)))},[jr,yo,vo]);const ei=zo===wo?Jr>0?Jr:bo[wo]:bo[zo],ni=Jr>0?Math.min(Jr/ei,"shrink"===xo?1:2):1,ti=ei*ni,oi=Jr>0&&ti>Jr+1,ri={width:ti,height:Qr||"100%",flex:"none",position:"relative"},ii={width:ei,height:Qr?Qr/ni:"100%",maxHeight:"none",transform:1!==ni?`scale(${ni})`:void 0,transformOrigin:"top left"},li=()=>Lt({type:"setUi",ui:{leftSideBarVisible:!yo}}),si=()=>Lt({type:"setUi",ui:{rightSideBarVisible:!vo}}),di=e=>{Yo&&(Go(!1),Qo(null),Jo.current=!1,yo&&Mo===e)||(To(e),yo||Lt({type:"setUi",ui:{leftSideBarVisible:!0}}))},ai=()=>{qo(F),mo.select(null),d()},ci=()=>{qo(Kt??F),vo||Lt({type:"setUi",ui:{rightSideBarVisible:!0}})},pi=jt.data.content??[],ui=()=>{const e=pi.findIndex(Qt),n=pi.findIndex(Xt);return{floor:e>=0?e+1:0,cap:n>=0?n:pi.length}},hi=Dt,fi=hr.stripCopy,mi=n=>e(n,fi),gi=oe(),yi=Je({data:jt.data,config:hi,readOnly:Boolean(Nt),clipboard:gi,strip:fi?e=>fi(e):void 0,afterRemove:"none",stepBounds:(e,n)=>{if(e.parentId!==Nn||e.slot!==On)return{min:0,max:n-1};const{floor:t,cap:o}=ui();return{min:t,max:o-1}},commit:(e,{select:n})=>{void 0!==n&&qo(F);const t=void 0===n||"node"===n?.kind?n:null;mo.commitDocument(e,t)}}),vi=he(),[ki,bi]=Ln(null),Si=e=>{const n=pi.find(n=>String(n.props.id)===e),t=Wt.shared;n&&t&&yi.swap(e,t.detach(n))},wi=e=>{const n=Mn(jt.data,Dt,e);if(!n)return!1;const t=Pn(n.place),o=n.node,r=t===Be?Ii(o):Wi(o),i=t===Be?Wt.shared?.usedOn(o):null;return!!yi.remove(e)&&(Yr(i?qt.shared.removed({count:Math.max(0,i.length-1)}):qt.deleted({name:r}),"success",{duration:8e3,action:{label:qt.bar.undo,onClick:()=>{yi.restore(n.node,n.place)}}}),!0)},xi={...yi,remove:wi},zi=e=>Sr(e,"block",Dt.components[e]?.label??e),Ci=Rn(e=>Dt.components[e]?.defaultProps??{},[Dt]),Bi=e=>Sr(e,"section",zi(e)),Ii=e=>we({type:e.type,props:e.props??{}},Bi(e.type),zr),{nodeAddresses:Ni,zoneItems:Oi}=jn(()=>{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>=Ne)return;const s=/* @__PURE__ */new Map;for(const{child:e,zone:t}of Oe(Dt,n))s.set(t,[...s.get(t)??[],e]);for(const[e,n]of s)t(n,e,i+1)})};return t(pi,Be,0),{nodeAddresses:e,zoneItems:n}},[pi,Dt]),Pi=Rn(e=>Oi.get(e)??[],[Oi]),$i=e=>{const n=Ni.get(e);return n?Pi(n.zone)[n.index]:void 0},Mi=e=>ne(hr,Dt,e),Ti=e=>{if(!hr.slotsOf||e===Be)return null;const n=e.lastIndexOf(":");if(n<=0)return null;const t=$i(e.slice(0,n));if(!t)return null;const o=Mi(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}},Ai=(()=>{if(!K(_o))return null;const e=`${_o.nodeId}:${_o.slot}`;return Ti(e)?.slot.panel===_o.kind?e:null})(),ji=An(null);En(()=>{const e=ji.current;if(ji.current=null,!Ai||!K(_o))return;const n=_o.nodeId;ir(n,{scroll:e!==Ai}),Ar(e=>{if(!e.has(n))return e;const t=new Set(e);return t.delete(n),t})},[_o]);const Li=(e,n,t)=>{const o=String(e.props.id);if(!n.panel)return void(e=>{const n=Ni.get(e);n&&(n.zone===Be?nl(n.index):Nl(n.zone,n.index,e,$i(n.zone.slice(0,n.zone.lastIndexOf(":")))?.type??""))})(o);const r={kind:n.panel,nodeId:o,slot:n.slot},i=`${o}:${n.slot}`;t&&Ai!==i&&(ji.current=i),ar(null,r),vo||Lt({type:"setUi",ui:{rightSideBarVisible:!0}}),l(o)},Ei=(e,n,t)=>{const o=`${e}:${n}`;if(Ar(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;Ai!==o&&(ji.current=o);ar(null,{kind:t,nodeId:e,slot:n})},Ri=(e,n,t)=>{if(Nt||!hr.moveSlot)return;const o=$i(e),r=o?Mi(o).filter(e=>e.rung):[],i=r[n];if(!i)return;const l={parentId:e,slot:kt,index:n},s=yn(l,{...l,index:Math.min(Math.max(t,0),r.length)});if(s===n)return;const d=hr.moveSlot(e,n,s);"string"==typeof d&&Ei(e,d,i.panel)},Fi=xr(),Di=jn(()=>{const e=/* @__PURE__ */new Map;for(const n of Fi??[])e.set(n.slug,n.name);return e},[Fi]),Wi=e=>xe(e,zi,br.plainText,e=>Di.get(e),br.rowName),Hi=(e,n)=>{const t=Dt.components[e.type]?.fields,o=n===Be||es(n)?"section":"block",r=n===Be&&(Qt(e)||Xt(e)||Yt(e.type)),i="block"===o?ze(t):r?null:Ce(t);return br.renamePropOf?br.renamePropOf(e,o,i):i},Vi=(e,n,t,o)=>{if(!(!Nt&&Nr?.zone===e&&Nr.index===n))return;const r=(t,o)=>{Or(null),o&&((e,n,t)=>{const o=Pi(e)[n];if(!o)return;const r=Hi(o,e);r&&mo.replaceComponent(e,n,{...o,props:{...o.props,[r]:t.trim()}})})(e,n,t)};/* @__PURE__ */
14
- return dt("input",{className:"es-tree-rename",defaultValue:o,autoFocus:!0,"aria-label":qt.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)},Ui=t(Q(),io),Yi=Ui.scope({target:Bn,siteId:Qn,docId:Wn}),Gi=Dt,Ji=(e,n)=>n===Be?Bi(e):zi(e),Ki=(e,n,t)=>{const o=Ui.plan(Yi,t,Ji(t.type,e),Gi);o&&(o.changed&&mo.replaceComponent(e,n,{...t,props:{...o.props,id:t.props.id}}),Yr(o.message))},Qi=re({nodesIn:Pi,nodeAt:(e,n)=>Pi(e)[n]??null,labelOf:(e,n)=>n===Be?Bi(e):zi(e),renamePropOf:Hi,beginRename:(e,n)=>Or({zone:e,index:n}),history:{hasPast:Et.hasPast,hasFuture:Et.hasFuture,back:()=>Et.back(),forward:()=>Et.forward()},openPageSettings:()=>{mo.select(null),qo(F)},pageSettingsLabel:qt.pageSettings,words:{menu:ro,styleClipboard:io,screen:qt.menu},readOnly:Boolean(Nt),collapseAll:()=>Ar(new Set(Pi(Be).map(e=>String(e.props.id)))),onPasteRefused:e=>Yr(e?qt.pasteRefused({name:e.label}):qt.menu.clipboardRefused,"error"),canPasteAt:(e,n)=>os(e,n),menuRows:(e,n,t)=>{const o=pr.menuRows?.(e,n,t)??null,r=((e,n)=>{const t=Wt.shared;if(!t||n!==Be)return null;const o=t.usedOn(e);if(o){const n={pick:[{label:qt.shared.onPages({count:o.length}),onClick:()=>{},children:o.map(e=>({label:e.title,onClick:()=>t.openPage(e)}))}]};return Nt||fr(e.type,e)?n:{...n,change:[{label:qt.shared.detach,onClick:()=>Si(e.props.id)}],remove:[{label:qt.shared.removeFromPage,danger:!0,onClick:()=>{wi(e.props.id)}}]}}return Nt||Qt(e)||Xt(e)||Yt(e.type)?null:z(vi)?{change:[{label:qt.shared.makeShared,onClick:()=>bi({id:e.props.id,name:Ii(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=>fr(e.type,e),duplicateBlocked:e=>mr(jt.data,e),permits:e=>{const n=Ie(Dt,e.type);return Wt.shared?.usedOn(e)?{...n,delete:!1}:n},nodeOps:xi,isPinned:(e,n)=>n===Be&&(Qt(e)||Xt(e)),sectionBand:ui,locate:e=>Ni.get(e)??null,rowNameOf:(e,n)=>n===Be?Ii(e):Wi(e),selectAt:(e,n,t,o)=>{e===Be?nl(n):Nl(e,n,t,o??"")},slotRung:e=>{const n=Ti(e);return n?.slot.panel?{label:n.slot.label,select:()=>Li(n.node,n.slot,!1)}:null},style:{held:()=>ke(Yi),canCopy:e=>Ui.rows(Gi,e).some(e=>!1!==e.counted),copy:(e,n)=>Ui.copy(Yi,e,Ji(e.type,n),Gi),paste:(e,n,t)=>Ki(e,n,t)},keys:$t?{target:Do,selected:()=>{const e=jt.ui.itemSelector;return e?{zone:e.zone??Be,index:e.index}:null},held:()=>gi.get(),readOnly:Boolean(Nt),onDone:({done:e,name:n})=>{"copied"===e&&Yr(qt.copied({name:n}))}}:void 0},Ro),Xi=An({copy:(e,n)=>{},paste:(e,n,t)=>{},at:()=>null,readOnly:!1});En(()=>{Xi.current={copy:(e,n)=>Ui.copy(Yi,e,Ji(e.type,n),Gi),paste:Ki,at:()=>{const e=jt.ui.itemSelector;if(!e)return null;const n=e.zone??Be,t=Pi(n)[e.index];return t?{zone:n,index:e.index,node:t}:null},readOnly:Boolean(Nt)}});const Zi=Rn(e=>{const n=be(e);if(!n)return;const t=Xi.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))},[]);En(()=>{if(!Do)return;const e=e=>Zi(e);return Do.addEventListener("keydown",e),()=>Do.removeEventListener("keydown",e)},[Zi,Do]),wn(Ro,"keydown",Zi);const _i=pi.map(e=>e.props.id).join("|");En(()=>{const e=Ro?.document??null,n=Ro?.window??null;let t=0;const o=[],r=()=>{if(!e)return void Zo(e=>e.length?[]:e);const n=pi.findIndex(Xt),t=n>=0?n:pi.length,o=n=>{const t=pi[n]?.props?.id;return null==t?null:In(e,`[data-easel-block="${CSS.escape(String(t))}"]`)},r=e=>e?[...e.querySelectorAll(bn)].map(e=>e.getBoundingClientRect()).filter(e=>e.width>0||e.height>0):[],i=[];for(let e=pi.length>0&&!Qt(pi[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=vt(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})}Zo(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()}},[Ro,_i,zo,ni,yo,vo,Rt?.props.id]);const qi=Ro?.document??null,el=Ro?.window??null;En(()=>{const e=Lo.current;if(!e||!qi||!el)return;const n=[],t=()=>{const n=In(qi,`[data-easel-block="${CSS.escape(e.id)}"]`);if(!n)return!1;const t=n.getBoundingClientRect().top-e.offset;return Math.abs(t)>1&&el.scrollTo({left:el.scrollX,top:el.scrollY+t,behavior:"instant"}),!0};return Lo.current=null,t()&&n.push(setTimeout(t,150),setTimeout(t,450)),()=>n.forEach(clearTimeout)},[qi,el]);const nl=e=>{qo(F),mo.select({index:e}),pr.sectionPressed?.(pi[e]);const n=pi[e]?.props?.id;n&&l(n)},tl=e=>{const{floor:n,cap:t}=ui(),o=e=>Math.min(Math.max(n,e),t);if("number"==typeof e)return o(e);const r=Rt&&_o.kind!==Kt?.kind?pi.findIndex(e=>e.props.id===Rt.props.id):-1;return o(r>=0?r+1:t)},ol=(e,n)=>{const{floor:t,cap:o}=ui(),r=Math.min(Math.max(n,t),o),i=e<r?r-1:r;return i===e?{moved:!1,dest:e}:(mo.reorderComponent(Be,e,i),mo.select({index:i}),{moved:!0,dest:i})},rl=(e,n,t,o)=>{qo(F),mo.select(o?{index:o.index,zone:o.zone}:{index:e}),l(n),Yr(qt.sectionAdded({name:t}))},il=(e,n)=>{const t=tl(n),o=yr(e,{nodeDefaults:Ci,newNodeId:$e,sectionLabel:Bi,blockIsOffered:kr}),r=o?mo.insertNode(Be,t,o):mo.insertSection(e,t);return rl(t,r,Bi(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 Oe(Dt,e)){if(s.type===t&&(!o.at||n>o.at.depth)){const r=vr(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},ll=e=>sl(Be,e),sl=(e,n)=>{Vr.current=document.activeElement??null,Qo(null===n?null:{zone:e,index:n}),Go(!0),yo||(Jo.current=!0,Lt({type:"setUi",ui:{leftSideBarVisible:!0}}))},dl=()=>{Go(!1),Qo(null),Jo.current&&Lt({type:"setUi",ui:{leftSideBarVisible:!1}}),Jo.current=!1},al=(e,n)=>br.rowName?n?Qt(e)?br.rowName(e,"section",qt.header):Xt(e)?br.rowName(e,"section",qt.footer):Yt(e.type)?br.rowName(e,"section",zi(e.type)):Ii(e):Wi(e):n?Bi(e.type):zi(e.type),cl=e=>n=>{e()},pl=(e,n,t)=>{if(Nt)return null;const o=Pi(e)[n];return o&&!Ie(Dt,o.type).delete||o&&fr(o.type,o)?null:/* @__PURE__ */dt(He,{kind:"delete",label:e===Be&&o&&Wt.shared?.usedOn(o)?qt.shared.removeFromPage:qt.deleteNamed({name:t}),onClick:()=>((e,n)=>{const t=Pi(e)[n]?.props?.id;null!=t&&wi(String(t))})(e,n),children:/* @__PURE__ */dt(ot,{size:15})})},ul=e=>br.rowPreview?.(e)||void 0,hl=e=>br.rowMarks?.(e)??void 0,fl=(e,n,t)=>br.rowActions?.(e,n,t)??null,ml=(e,n,t,o)=>{if(Nt)return null;if(fr(t.type,t))return null;const r=Boolean(t.props._hidden);/* @__PURE__ */
15
- return dt(He,{kind:"eye",label:r?qt.showNamed({name:o}):qt.hideNamed({name:o}),onClick:()=>yl(e,n,t),children:/* @__PURE__ */dt(r?rt:it,{size:14,strokeWidth:1.8,strokeLinecap:void 0,strokeLinejoin:void 0})})},gl=e=>Vs(Be,e),yl=(e,n,t)=>{mo.replaceComponent(e,n,{...t,props:{...t.props,_hidden:!t.props._hidden}})},vl=e=>Pe(Dt,e),kl=e=>Oe(Dt,e),bl=e=>hr.slotsOf?Mi(e).map(n=>({slot:n.slot,rung:n.rung?n:null,kids:Me(e,n.slot)})):[{slot:null,rung:null,kids:kl(e)}],Sl=e=>hr.slotsOf?bl(e).flatMap(e=>e.kids):kl(e),wl=e=>Boolean(hr.slotsOf)&&Mi(e).some(e=>e.rung),xl=(e,n,t)=>null===t?void 0===n?vr(e):vr(e,n):vr(e,n,t),zl=(e,n,t)=>{const o=Te(Dt,e.type,n)&&(t||Sl(e).length>0||wl(e));return{collapsible:o,folded:o&&Dr(String(e.props.id))}},Cl=(e,n,t)=>bl(e).flatMap(o=>{const r=o.rung?n+1:n,i=o.kids.flatMap(({child:e})=>zl(e,r,t(e.type)).collapsible?[String(e.props.id),...Cl(e,r+1,t)]:[]);return o.rung?[`${e.props.id}:${o.rung.slot}`,...i]:i}),Bl=e=>Sl(e).length>0||wl(e)||Boolean(vr(e.type)),Il=e=>Boolean(vr(e)),Nl=(e,n,t,o)=>{if(qo(F),vr(o)?.spec?.slider){const t=e.split(":")[0];s(t,n),mo.select({index:n,zone:e}),l(t)}else mo.select({index:n,zone:e}),l(t)},Ol=(e,n,t,o,r)=>{const i=`${e}:${n}`;mo.insertComponent(i,t,o),vr(r)?.spec?.slider?requestAnimationFrame(()=>{s(e,o),mo.select({index:o,zone:i})}):mo.select({index:o,zone:i})},Pl=An(/* @__PURE__ */new Set);En(()=>{pi.forEach(e=>{const n=vr(e.type)?.spec;if(!n)return;const t=e.props.id;if(Pl.current.has(t))return;Pl.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(Ci)).forEach((e,t)=>uo.seedChild(o,t,n.childType,e))})},[pi,uo,Ci]);const $l=An(/* @__PURE__ */new Set);En(()=>{pi.forEach((e,t)=>{const o=e.props.id;if($l.current.has(o))return;const r=n(e,vl(e.type));$l.current.add(o),r&&uo.replaceComponent(Be,t,{...e,props:r})})},[pi,uo]),X(uo,Dt);const Ml=pi.findIndex(Xt),Tl=Ml>=0?pi[Ml]:null,Al=Zt?pi.findIndex(Qt):-1,jl=Al>=0?pi[Al]:null,Ll=Wt.groupTab,El=jn(()=>Ll?e=>Yt(e.type):void 0,[Ll]),Rl=Boolean(Wt.groupBadge),Fl=Wt.sharedReach,Dl=e=>Fl?.(e)??void 0,Wl=jn(()=>Fl?new Set(pi.filter(e=>Dl(e)).map(e=>String(e.props.id))):null,[pi,Fl]),Hl=jn(()=>Wl?e=>Wl.has(e):void 0,[Wl]),Vl=Wt.first?Fl?.({type:Wt.first,props:{id:""}})??void 0:void 0,Ul=Wt.groupBadge?/* @__PURE__ */dt("span",{className:"es-tree-group-badge",children:/* @__PURE__ */dt(Hn,{tone:"info",size:"xs",children:Wt.groupBadge})}):void 0,Yl=pi.find(e=>e.type===Vt)??null,Gl=pi.find(e=>e.type===Ut)??null,Jl=Ml>=0?Ml:pi.length,Kl=[];pi.forEach(e=>{Xt(e)||(Bl(e)&&Kl.push(String(e.props.id)),Kl.push(...Cl(e,1,Il)))}),Tl&&(Kl.push(String(Tl.props.id)),Kl.push(...Cl(Tl,1,Il)));const Ql=Kl.length>0&&Kl.every(e=>Tr.has(e)),Xl=e=>{const n=br.blockRowName(e,zi);return br.rowName?br.rowName(e,"block",n):n},Zl=(e,n,t,o)=>{const r=Pi(e)[t];if(!r)return;const i={...$n(e),index:t},l={...$n(n),index:Math.min(Math.max(o,0),Pi(n).length)},s=yn(i,l);if(e!==n||s!==t)try{yi.move(String(r.props.id),{...l,index:s})}catch(e){if(!(e instanceof Tn))throw e}},_l=e=>{const n=/* @__PURE__ */new Set,t=e=>{for(const{child:o,zone:r}of kl(e))n.add(r),t(o)};for(const t of vl(e.type))n.add(`${e.props.id}:${t}`);return t(e),n},ql=e=>{let n=e.slice(0,e.indexOf(":"));for(let e=0;e<64;e++){const e=Ni.get(n);if(!e)return null;if(e.zone===Be)return n;n=e.zone.slice(0,e.zone.indexOf(":"))}return null},es=e=>{const n=e.slice(0,e.indexOf(":")),t=pi.find(e=>Yt(e.type)&&String(e.props.id)===n);return t&&Gt(n)===e?t:null},ns=(e,n)=>{const t=es(e);return!t||(!Wt.groupAccepts||Wt.groupAccepts(t.type,n,Pi(e).length))},ts=(e,n,t)=>{if(e.rung){const t=$i(e.rung.nodeId),o=t?Mi(t).filter(e=>e.rung).length:0;return n.parentId===e.rung.nodeId&&n.slot===kt&&n.index>=0&&n.index<=o}if(n.slot===kt)return!1;if(e.add)return ls(e.add,n);const o=Pn(n);if(Yt(e.type))return!1;const r=es(o),i=es(e.zone);if(r||i)return!(!r||!i)&&(!(r!==i&&!ns(o,e.type))&&(n.index>=0&&n.index<=Pi(o).length));if(e.zone===Be||o===Be){if(e.zone!==o)return!1;const{floor:t,cap:r}=ui();return n.index>=t&&n.index<=r}if(n.index<0||n.index>Pi(o).length)return!1;if(e.zone===o)return!0;const l=Tl&&!Wt.lastIsOpen?String(Tl.props.id):null;return(!l||ql(e.zone)!==l&&ql(o)!==l)&&((e,n,t,o)=>{if(e===n)return!0;const r=o??Pi(e)[t];if(!r)return!1;const i=n.split(":")[0],l=Ni.get(i),s=l?Pi(l.zone)[l.index]:void 0;if(!s)return!1;if(!o&&_l(r).has(n))return!1;const d=vr(s.type,gr(jt?.data,s.type,i),n.slice(n.lastIndexOf(":")+1));return!!d&&(!!(d.choices?d.choices.some(e=>e.type===r.type):d.spec?.childType===r.type)&&!d.spec?.addBlocked?.(Pi(n),r))})(e.zone,o,e.index,t)},os=(e,n)=>{const t=Pn(e.from),o=e.node;return t===Pn(n)?ns(t,o.type):ts({id:String(o.props?.id??""),zone:t,index:-1,type:o.type},n,o)},rs=e=>{const n=e.slice(0,e.indexOf(":")),t=Ni.get(n),o=t?Pi(t.zone)[t.index]:void 0;if(!t||!o)return null;const r=vr(o.type,gr(jt?.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=O(r.choices??(r.spec?[{type:r.spec.childType,label:zi(r.spec.childType)}]:[])),l=Ti(e);return{parent:o,parentId:n,target:r,choices:i,parentName:l?l.slot.label:al(o,t.zone===Be)}},is=(e,n)=>{if("section"!==e.kind)return e;const t=Pn(n);return t===Be||es(t)?e:rs(t)?.choices.some(n=>n.type===e.type)?{kind:"block",type:e.type}:e},ls=(e,n)=>{const t=is(e,n),o=Pn(n);if("shared"===t.kind){if(o!==Be||!Wt.shared?.nodeOf(t.section))return!1;const{floor:e,cap:r}=ui();return n.index>=e&&n.index<=r}if("block"!==t.kind){if(es(o)){const e="section"===t.kind?t.type:t.template.node.type;return ns(o,e)&&n.index>=0&&n.index<=Pi(o).length}if(o!==Be)return!1;const{floor:e,cap:r}=ui();return n.index>=e&&n.index<=r}if(o===Be)return!1;const r=rs(o);return!(!r||!r.choices.some(e=>e.type===t.type))&&!r.target.spec?.addBlocked?.(Pi(o))},ss=(e,n)=>{const t=is(e,n);if("block"!==t.kind&&es(Pn(n)))return void((e,n,t)=>{const o="section"===e.kind?e.type:"template"===e.kind?e.template.node.type:null;if(o&&ns(n,o)){if("section"===e.kind)mo.insertComponent(n,e.type,t);else{if("template"!==e.kind)return;mo.insertNode(n,t,mi(e.template.node))}qo(F),mo.select({index:t,zone:n})}})(t,Pn(n),n.index);if("section"===t.kind)return void il(t.type,n.index);if("template"===t.kind)return void((e,n,t)=>{const o=tl(t),r=mo.insertNode(Be,o,n);rl(o,r,e)})(t.template.name,mi(t.template.node),n.index);if("shared"===t.kind){const e=Wt.shared?.nodeOf(t.section);if(!e)return;const o=tl(n.index);return void(yi.restore(e,{parentId:Nn,slot:On,index:o})&&rl(o,e.props.id,t.section.title))}const o=Pn(n),r=rs(o);r&&(r.target.spec?Ol(r.parentId,r.target.slot,t.type,n.index,r.parent.type):((e,n,t)=>{mo.insertComponent(e,n,t),qo(F),mo.select({index:t,zone:e})})(o,t.type,n.index))},ds=(e,n)=>{e.media?function(e){const n=Rs();if(!n||!js)return;Ds(n).then(n=>{n&&function(e,n){if(!js)return;const t=js.create(e,{nodeDefaults:Ci,newNodeId:$e,sectionLabel:Bi,blockIsOffered:kr}),o=Pn(n);if(o===Be){const e=tl(n.index),o=mo.insertNode(Be,e,t);return void rl(e,o,Bi(t.type))}mo.insertNode(o,n.index,t),qo(F),mo.select({index:n.index,zone:o})}(n,e)})}(n):e.rung?Ri(e.rung.nodeId,e.index,n.index):e.add?ss(e.add,n):e.zone===Be?ol(e.index,n.index):Zl(e.zone,Pn(n),e.index,n.index)},[as]=Ln(()=>mn()),cs=gn({keyOf:e=>e.id,readOnly:Boolean(Nt),session:as,canDrop:ts,onDrop:ds,onStep:(e,n)=>{e.rung?Ri(e.rung.nodeId,e.index,n<0?e.index-1:e.index+2):e.zone===Be?((e,n)=>{const t=Bi(pi[e]?.type??""),o=ol(e,n<0?e-1:e+2);if(!o.moved)return void Yr(n<0?qt.sectionFirst({name:t}):qt.sectionLast({name:t}));const{floor:r,cap:i}=ui();Yr(qt.sectionMoved({name:t,n:o.dest-r+1,total:i-r}))})(e.index,n):Zl(e.zone,e.zone,e.index,n<0?e.index-1:e.index+2)}}),ps=Rn(e=>{const{floor:n,cap:t}=ui(),o=[];for(const r of e.nodes){const e=Pn(r.place),i=Pi(e)[r.place.index];if(!i||String(i.props.id)!==r.id)continue;if(Qt(i)||Xt(i)||fr(i.type,i))continue;if(Yt(i.type))continue;const l=Boolean(es(e)),s=e===Be||l;e===Be&&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?Bi(i.type):Wi(i),from:r.place})}const r=e.zones.flatMap(e=>{const n=Pn(e.list);if(n===Be&&0===e.children.length)return[{...e,addLabel:qt.addSection,addAlways:!0}];const t=rs(n),o=t?.target.spec?.addLabel;return e.children.length>0||Boolean(t?.choices.length)||Boolean(es(n))?[o?{...e,addLabel:o}:e]:[]}),i=r.flatMap(e=>{const n=Pn(e.list),t=n===Be||es(n)?null:rs(n);return t?.choices.length?pn(e,t.target.spec?.addLabel??qt.addBlockHere):[]});return{sources:o,zones:r,seams:i}},[jt.data]),us=null==Rt?.props.id?null:String(Rt.props.id),hs=Rn(e=>{const n=Dt,t=e=>!e.item.rung&&null!==Mn(jt.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(us);return i||(r(Ke(jt.data,n,o.item.id,us,El))??o)},[jt.data,Dt,us,El]),[fs,ms]=Ln(null),gs=Boolean(Ll||Fl);wn(Ro,"mouseover",e=>{if(!gs)return;const n=xn(e.target),t=n?ft(jt.data,Dt,n):null;t!==fs&&ms(t)}),wn(Ro,"mouseout",e=>{gs&&!e.relatedTarget&&ms(null)});const ys=e=>Qt(e)||Xt(e)||Yt(e.type),vs=e=>{const n=Yt(e.type)?zi(e.type):Qt(e)?qt.header:Xt(e)?qt.footer:null;return null===n?Ii(e):br.rowName?br.rowName(e,"section",n):n},ks=[];if(gs){const e=us?ft(jt.data,Dt,us):null;for(const n of/* @__PURE__ */new Set([e,fs])){const e=n?pi.find(e=>String(e.props.id)===n):void 0;if(!e)continue;const t=Qt(e)||e.type===Vt,o=Dl(e);if(o){ks.push({id:String(e.props.id),label:vs(e),below:t,reach:o});continue}if(!Ll||!ys(e))continue;const r=Ll(e);r&&ks.push({id:String(e.props.id),label:r,below:t})}}const bs=he(),Ss=An(null);En(()=>{const e=Wt.changeNotice;if(!e)return;const n=JSON.stringify(pi.filter(ys)),t=Ss.current;if(Ss.current={doc:Wn,bands:n,index:Et.index},!t||t.doc!==Wn||t.bands===n)return;Et.hasPast&&Et.index>=t.index&&!ht.has(bs)&&(ht.add(bs),Yr(e,"success",{action:{label:qt.bar.undo,onClick:()=>Et.back()},duration:8e3}))},[pi]);const ws=e=>{qo(F),mo.select(e.zone===Be?{index:e.index}:{index:e.index,zone:e.zone})},xs=Z(),zs=()=>({data:jt.data,device:zo,ops:mo,inspector:cr}),Cs=xs?.model,Bs=jn(()=>Cs?e=>Cs(e,ps(e),zs()):ps,[Cs,ps,zo]),Is=xs?.measure,Ns=Is?(e,n)=>Is(e,n,zs()):void 0,Os=xs?.canDrop,Ps=Os?(e,n)=>Os(e,n,ts,zs()):ts,$s=xs?.drop,Ms=$s?(e,n)=>$s(e,n,ds,zs()):ds,Ts=xs?.pick,As=Ts?e=>Ts(e,ws,zs()):ws,js=xs?.media??null,Ls=An(null),Es=jn(()=>js?{id:pt,zone:"",index:-1,type:js.adds.type,add:{kind:js.adds.kind,type:js.adds.type},media:!0}:null,[js]);En(()=>{if(!Es||Nt||"undefined"==typeof document)return;const e=e=>{(e=>Array.from(e.dataTransfer?.types??[]).includes(_n))(e)&&(Ls.current=null,as.start({key:pt,item:Es}))},n=e=>{as.get()?.item.media&&(Ls.current=Gn(e.dataTransfer))},t=()=>{as.get()?.item.media&&as.end()};return document.addEventListener("dragstart",e),document.addEventListener("drop",n,!0),document.addEventListener("dragend",t,!0),()=>{document.removeEventListener("dragstart",e),document.removeEventListener("drop",n,!0),document.removeEventListener("dragend",t,!0)}},[Es,Nt,as]);const Rs=()=>{const e=Ls.current;return Ls.current=null,e},Fs=ue(),Ds=async e=>{if(!Fs)return e;const n=await Fs(e);return n?{...e,id:n.id,url:n.url}:null};const Ws=(e,n)=>{if(!js)return;const t=Mn(fo.getState().appState.data,hi,n);if(!t)return;const o=t.node;mo.replaceComponent(Pn(t.place),t.place.index,{...o,props:{...js.replace(o,e),id:o.props.id}})},Hs=e=>{const n=Pn(e),t=Ti(n);t&&Li(t.node,t.slot,!1),sl(n,e.index)},Vs=(e,n)=>/* @__PURE__ */dt(Ve,{...Nt?{}:cs.seam({place:{...$n(e),index:n}})},`seam:${e}:${n}`),Us={rowClick:cl,isCollapsed:Dr,toggleCollapse:Wr},Ys=e=>{const n=String(e.props.id),t=pi.findIndex(e=>String(e.props.id)===n),o=Gt(n),r=Pi(o),i=Dr(n),l=zi(e.type),s=br.rowName?br.rowName(e,"section",l):l,d=e=>Vs(o,e);/* @__PURE__ */
16
- return at(ct,{children:[
17
- /* @__PURE__ */dt(Re,{words:eo,icon:/* @__PURE__ */dt(wr,{type:e.type,size:13}),name:s,preview:ul(e),marks:hl(e),onSelect:()=>nl(t),nameSlot:Vi(Be,t,n,s),selected:nr===n,badge:Dl(e)?void 0:Ul,shared:Dl(e),actions:fl(e,Be,t)??void 0,rowProps:{"data-node-id":n,onClick:cl(()=>nl(t))},fold:{open:!i,label:"section",onToggle:()=>Wr(n)}}),!i&&/* @__PURE__ */at(Fe,{children:[r.map((n,t)=>{const r=String(n.props.id),i=Ii(n),l=Bl(n),s=l&&Dr(r),a=()=>Nl(o,t,r,e.type),{rowProps:c,...p}=cs.row({item:{id:r,zone:o,index:t,type:n.type},place:{...$n(o),index:t}},{"data-node-id":r,onClick:cl(a)});/* @__PURE__ */
18
- return at(Dn,{children:[d(t),
19
- /* @__PURE__ */dt(Re,{words:eo,icon:/* @__PURE__ */dt(wr,{type:n.type,size:13}),name:i,preview:ul(n),marks:hl(n),onSelect:a,nameSlot:Vi(o,t,r,i),selected:nr===r,hidden:Boolean(n.props._hidden),...p,fold:l?{open:!s,label:"section",onToggle:()=>Wr(r)}:void 0,actions:/* @__PURE__ */at(ct,{children:[pl(o,t,i),fl(n,o,t),ml(o,t,n,i)]}),rowProps:c}),l&&!s&&/* @__PURE__ */dt(Fe,{children:Ks(n,2)})]},r)}),d(r.length)]})]})},Gs=(e,n,t,o,r)=>{const i=String(e.props.id),l=`${i}:${n.slot}`,s=cs.dragging,d=!Dr(l)&&s?.rung?.nodeId!==i,a={...$n(l),index:0},c=s&&!s.rung&&ts(s,a)?a:void 0,p=()=>Li(e,n,!0),{rowProps:u,...h}=cs.row({item:{id:`rung:${l}`,zone:`${i}:${kt}`,index:t,type:e.type,rung:{nodeId:i,slot:n.slot}},place:{parentId:i,slot:kt,index:t},into:c,canDrag:Boolean(hr.moveSlot)&&!1!==n.movable&&o>1},{"data-slot-zone":l,onClick:cl(p)}),f=Nt?null:hr.slotActions?.(e,n.slot);/* @__PURE__ */
20
- return at(Dn,{children:[n.heading,
21
- /* @__PURE__ */dt(Re,{words:eo,icon:n.glyph??null,name:n.label,badge:n.badge,onSelect:p,selected:Ai===l,...h,dragHint:n.dragHint,fold:{open:d,label:n.label,onToggle:()=>Wr(l)},actions:f&&f.length>0?/* @__PURE__ */dt(ct,{children:f.map((t,o)=>/* @__PURE__ */dt(He,{kind:"delete"===t.kind?"delete":"plain",label:t.label,disabled:t.disabled,onClick:()=>((e,n,t)=>{if(Nt||t.disabled)return;const o=String(e.props.id),r=e=>{"string"==typeof e&&Ei(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__ */dt(ot,{size:15}):/* @__PURE__ */dt(st,{size:15})},`${o}:${t.kind}`))}):void 0,rowProps:u}),d&&/* @__PURE__ */dt(Fe,{children:r})]},l)},Js=(e,n)=>{const t=bl(e),o=t.filter(e=>e.rung).length;let r=0;/* @__PURE__ */
22
- return dt(ct,{children:t.map(t=>{const i=t.kids,l=t.rung?n+1:n,s=xl(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)=>Vs(e,n),p=/* @__PURE__ */at(ct,{children:[i.map(({child:n,zone:t,index:o})=>{const r=nr===String(n.props.id),{collapsible:i,folded:s}=zl(n,l,Il(n.type)),d=String(n.props.id),a=Xl(n),p=()=>Nl(t,o,d,e.type),{rowProps:u,...h}=cs.row({item:{id:d,zone:t,index:o,type:n.type},place:{...$n(t),index:o}},{"data-node-id":d,onClick:cl(p)});/* @__PURE__ */
23
- return at(Dn,{children:[0===o&&c(t,0),
24
- /* @__PURE__ */dt(Re,{words:eo,icon:/* @__PURE__ */dt(wr,{type:n.type,size:13}),name:a,preview:ul(n),marks:hl(n),onSelect:p,nameSlot:Vi(t,o,d,a),selected:r,hidden:Boolean(n.props._hidden),...h,fold:i?{open:!s,label:"group",onToggle:()=>Wr(d)}:void 0,actions:/* @__PURE__ */at(ct,{children:[pl(t,o,a),fl(n,t,o),ml(t,o,n,a)]}),rowProps:u}),i&&!s&&/* @__PURE__ */dt(Fe,{children:Js(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?Gs(e,t.rung,r++,o,p):/* @__PURE__ */dt(Dn,{children:p},t.slot??"")})})},Ks=(e,n)=>{const t=gr(jt?.data,e.type,String(e.props.id)),o=bl(e),r=o.filter(e=>e.rung).length;let i=0;/* @__PURE__ */
25
- return dt(ct,{children:o.map(o=>{const l=o.kids,s=o.rung?n+1:n,d=xl(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)=>Vs(e,n),g=null===o.slot?null:`${u}:${o.slot}`,y=Boolean(a&&!a.fixed&&(null===g||g===h)),v=/* @__PURE__ */at(ct,{children:[l.map(({child:n,zone:t,index:o})=>{const r=nr===String(n.props.id),i=Wi(n),l=String(n.props.id),{collapsible:d,folded:a}=zl(n,s,Il(n.type)),c=vl(n.type),p=1===c.length?`${l}:${c[0]}`:null,u=p?{...$n(p),index:Pi(p).length}:void 0,h=cs.dragging,f=u&&h&&ts(h,u)?u:void 0,g=()=>Nl(t,o,l,e.type),{rowProps:y,...v}=cs.row({item:{id:l,zone:t,index:o,type:n.type},place:{...$n(t),index:o},into:f,canDrag:!fr(n.type,n)},{"data-node-id":l,onClick:cl(g)});/* @__PURE__ */
26
- return at(Dn,{children:[0===o&&m(t,0),
27
- /* @__PURE__ */dt(Re,{words:eo,icon:/* @__PURE__ */dt(wr,{type:n.type,size:13}),name:i,preview:ul(n),marks:hl(n),onSelect:g,nameSlot:Vi(t,o,l,i),selected:r,hidden:Boolean(n.props._hidden),...v,fold:d?{open:!a,label:"group",onToggle:()=>Wr(l)}:void 0,actions:fr(n.type,n)?fl(n,t,o)??void 0:/* @__PURE__ */at(ct,{children:[pl(t,o,i),fl(n,t,o),ml(t,o,n,i)]}),rowProps:y}),d&&!a&&/* @__PURE__ */dt(Fe,{children:Ks(n,s+1)}),m(t,o+1)]},String(n.props.id??`${t}-${o}`))}),y&&a&&
28
- /* @__PURE__ */dt(w,{small:!0,label:a.addLabel,blocked:a.addBlocked?.(c)??null,onAdd:()=>Ol(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?Gs(e,o.rung,i++,r,v):/* @__PURE__ */dt(Dn,{children:v},o.slot??"")})})},Qs=Yo,Xs=e=>"panel"in e?{id:e.id,label:e.label,icon:e.icon,active:yo&&!Qs&&ur===e.id,onSelect:()=>di(e.id)}:e,Zs=[...(pr.railLead??[]).map(Xs),{id:"sections",label:qt.layers,icon:/* @__PURE__ */dt(ge,{}),active:yo&&!Qs&&"sections"===ur,onSelect:()=>di("sections")},...(pr.railTrail??[]).map(Xs)],_s=Io?{onPress:No}:Mt?{onPress:()=>{se(kn,{accept:"image/*",title:lo.mediaLibrary})}}:null,qs={value:Zs.find(e=>!0===e.active)?.id??"",press:e=>{const n=Zs.find(n=>n.id===e);n&&!n.disabled&&!0!==n.active&&n.onSelect?.()},items:Zs.map(e=>({id:e.id,icon:e.icon,label:/* @__PURE__ */dt("span",{className:"sr-only",children:e.label}),tooltip:e.label,disabled:e.disabled}))},ed=[...pr.railLead??[],...pr.railTrail??[]].find(e=>"panel"in e&&e.id===ur),nd=Boolean(_t?.foldable),td=_t?.label??(Tt?qt.pageSections:qt.templateSections),od=nd&&Dr(bt),rd=/* @__PURE__ */at(ct,{children:[pi.map((e,n)=>{if(Qt(e)||Xt(e)||Yt(e.type))return null;const t=nr===String(e.props.id),o=Boolean(e.props._hidden);kl(e);const r=String(e.props.id),i=pr.hasOwnRows?.(e)??!1,l=Bl(e)||i,s=l&&Dr(r),d=vl(e.type),a=1===d.length?`${r}:${d[0]}`:null,c=a?{...$n(a),index:Pi(a).length}:void 0,p=cs.dragging,u=c&&p&&ts(p,c)?c:void 0,{rowProps:h,...f}=cs.row({item:{id:r,zone:Be,index:n,type:e.type},place:{...$n(Be),index:n},into:u,canDrag:!fr(e.type,e)},{"data-node-id":r,onClick:cl(()=>nl(n))});/* @__PURE__ */
29
- return at(Dn,{children:[n>0&&gl(n),
30
- /* @__PURE__ */dt(Re,{words:eo,icon:/* @__PURE__ */dt(wr,{type:e.type,size:13}),name:Ii(e),preview:ul(e),marks:hl(e),shared:Dl(e),onSelect:()=>nl(n),nameSlot:Vi(Be,n,r,Ii(e)),selected:t,hidden:o,...f,fold:l?{open:!s,label:"section",onToggle:()=>Wr(r)}:void 0,actions:/* @__PURE__ */at(ct,{children:[pl(Be,n,Ii(e)),fl(e,Be,n),ml(Be,n,e,Ii(e))]}),rowProps:h}),Bl(e)&&!s&&/* @__PURE__ */at(Fe,{children:[Ks(e,1),pr.partRows?.(e,Us)]}),i&&!s&&/* @__PURE__ */dt(Fe,{children:pr.ownRows?.(e,n,Us)})]},String(e.props.id??n))}),Jl>0&&gl(Jl)]}),id=(e,n,t)=>{const o=String(e.props.id),r=Sl(e).length>0||wl(e)||Boolean(vr(e.type)),i=r&&Dr(o),l="header"===t?qt.header:qt.footer,s=br.rowName?br.rowName(e,"section",l):l;/* @__PURE__ */
31
- return at(ct,{children:[
32
- /* @__PURE__ */dt(Re,{words:eo,icon:/* @__PURE__ */dt(wr,{type:t,size:13}),name:s,preview:ul(e),marks:hl(e),badge:Dl(e)?void 0:Ul,shared:Dl(e),onSelect:()=>nl(n),nameSlot:Vi(Be,n,o,s),selected:nr===String(e.props.id),fold:r?{open:!i,label:"section",onToggle:()=>Wr(o)}:void 0,actions:fl(e,Be,n)??void 0,rowProps:{"data-node-id":o,onClick:cl(()=>nl(n))}}),r&&!i&&/* @__PURE__ */dt(Fe,{children:Js(e,1)})]})};return(pr.wrap??(e=>e))(
33
- /* @__PURE__ */dt(_,{target:Ro,children:/* @__PURE__ */at("div",{ref:Eo,className:"sf-editor es-editor",style:on(jr),onContextMenu:Qi.onEditorContextMenu,...u(kn),children:[
34
- /* @__PURE__ */at(Qe,{children:[
35
- /* @__PURE__ */at("div",{className:"es-cluster es-cluster--left",children:[_s?/* @__PURE__ */dt(Vn,{variant:"secondary",className:"es-barbtn",leftIcon:/* @__PURE__ */dt(ye,{}),onClick:_s.onPress,children:qt.railMedia}):null,
36
- /* @__PURE__ */dt(Xe,{label:qt.bar.undo,disabled:Boolean(Nt)||!Et.hasPast,onClick:()=>Et.back(),children:/* @__PURE__ */dt(qn,{})}),
37
- /* @__PURE__ */dt(Xe,{label:qt.bar.redo,disabled:Boolean(Nt)||!Et.hasFuture,onClick:()=>Et.forward(),children:/* @__PURE__ */dt(et,{})})]}),
38
- /* @__PURE__ */at(Ze,{children:[
39
- /* @__PURE__ */dt(_e,{devices:ko,value:zo,onChange:Co}),
40
- /* @__PURE__ */dt(Xe,{label:qt.bar.refresh,tip:qt.bar.refreshTip,onClick:()=>{Lo.current=(()=>{const e=Ro?.document;if(!e)return null;const n=pi.findIndex(Xt),t=n>=0?n:pi.length;let o=null;for(let n=0;n<t;n++){const t=pi[n]?.props?.id;if(null==t)continue;const r=In(e,`[data-easel-block="${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=Rt?.props?.id??pi[0]?.props?.id;null!=e&&(o={id:String(e),offset:0})}return o})(),jo(e=>e+1)},children:/* @__PURE__ */dt(nt,{})}),pr.barView?.()]}),
41
- /* @__PURE__ */at(Ze,{kind:"right",style:{minWidth:300},children:[
42
- /* @__PURE__ */dt(k,{input:Vo,words:qt.saveStatus}),zn?/* @__PURE__ */dt(zn,{}):null,pr.barLead?.(),pr.barTrail?.(),pr.mainAction||!pr.barMain?/* @__PURE__ */dt(b,{input:Vo,action:pr.mainAction??{label:qt.done,onPress:()=>{Xn(jt.data)}},readOnly:Boolean(Nt),saveSwitch:Pt,onToggleAutoSave:zt,onSaveNow:Uo,bar:qt.bar,words:qt.saveStatus}):pr.barMain()]})]}),
43
- /* @__PURE__ */dt(ie,{}),
44
- /* @__PURE__ */at("div",{className:"sf-body",children:[yo?/* @__PURE__ */at(ct,{children:[
45
- /* @__PURE__ */at("aside",{className:"es-sidepanel es-sidepanel--left sf-panel sf-panel--left","aria-label":qt.leftPanel,children:[
46
- /* @__PURE__ */at("div",{className:"es-paneltabs es-paneltabs--with-hide",children:[
47
- /* @__PURE__ */dt(B,{side:"left",onHide:li}),
48
- /* @__PURE__ */dt("span",{className:"es-paneltabs-divider","aria-hidden":"true"}),
49
- /* @__PURE__ */dt(Un,{variant:"underline",block:!0,"aria-label":qt.bar.views,value:qs.value,onChange:qs.press,items:qs.items})]}),Yo?/* @__PURE__ */dt(x,{at:Ko?{label:(e=>{const n=es(e.zone);if(n)return qt.add.addingTo({name:br.rowName?al(n,!0):zi(n.type)});if(e.zone===Be){const n=pi[e.index];return n&&!Xt(n)?qt.add.addingBefore({name:al(n,!0)}):qt.add.addingAtEnd}const t=rs(e.zone);return t?qt.add.addingTo({name:t.parentName}):qt.add.addingHere})(Ko),onClear:()=>Qo(null)}:void 0,placeBlocks:Ko&&Ko.zone!==Be?rs(Ko.zone)?.choices:void 0,canTake:Ko?e=>{if(!Ko)return null;const n={...$n(Ko.zone),index:Ko.index};if(ls(e,n))return null;if("shared"===e.kind&&Ko.zone===Be&&!Wt.shared?.nodeOf(e.section))return qt.shared.alreadyHere;const t=es(Ko.zone);if(t)return qt.add.notInside({name:al(t,!0)});if(Ko.zone===Be)return qt.add.onlySections;const o=rs(Ko.zone);return o?qt.add.notInside({name:o.parentName}):qt.add.onlySections}:void 0,onPick:Ko?e=>{if(!Ko)return;const n={...$n(Ko.zone),index:Ko.index};ls(e,n)&&(ss(e,n),dl())}: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:as,siteWide:pr.addPanelRow?.(dl),onClose:dl,readOnly:Boolean(Nt)}):ed?ed.panel({onHide:li,notify:Yr}):/* @__PURE__ */at(ct,{children:[
50
- /* @__PURE__ */dt(I,{icon:/* @__PURE__ */dt(ge,{}),title:qt.layers,context:so,actions:/* @__PURE__ */at(ct,{children:[!Nt&&/* @__PURE__ */dt(qe,{label:qt.add.title,onClick:()=>ll(null),children:/* @__PURE__ */dt(tt,{size:15})}),
51
- /* @__PURE__ */dt(qe,{label:Ql?qt.expandAll:qt.collapseAll,title:0===Kl.length?qt.nothingToFold:void 0,disabled:0===Kl.length,onClick:()=>Ar(e=>{const n=new Set(Kl);return Ql?new Set([...e].filter(e=>!n.has(e))):/* @__PURE__ */new Set([...e,...Kl])}),children:/* @__PURE__ */dt(gt,{expand:Ql})})]})}),
52
- /* @__PURE__ */at(De,{className:"sf-tree sf-scroll",words:eo,children:[
53
- /* @__PURE__ */dt(Re,{words:eo,icon:/* @__PURE__ */dt(wr,{type:"page",size:13}),name:qt.pageSettings,onSelect:ai,selected:!Rt&&er,rowProps:{onClick:cl(ai)}}),Yl&&/* @__PURE__ */at(ct,{children:[!Rl&&/* @__PURE__ */dt(We,{children:qt.header}),Ys(Yl)]}),At&&!(Rl&&Yl)&&/* @__PURE__ */at(ct,{children:[!Rl&&/* @__PURE__ */dt(We,{children:qt.header}),!Zt&&/* @__PURE__ */dt(Re,{words:eo,icon:/* @__PURE__ */dt(wr,{type:"header",size:13}),name:qt.header,badge:Vl?void 0:Ul,shared:Vl,onSelect:ci,selected:_o.kind===Kt?.kind,rowProps:{onClick:cl(ci)}})]}),jl&&!(Rl&&Yl)&&id(jl,Al,"header"),!nd&&/* @__PURE__ */dt(We,{children:td}),nd?/* @__PURE__ */at(ct,{children:[
54
- /* @__PURE__ */dt(Re,{words:eo,icon:null,name:td,fold:{open:!od,label:td,onToggle:()=>Wr(bt)}}),!od&&/* @__PURE__ */dt(Fe,{children:rd})]}):rd,At&&!Rl&&/* @__PURE__ */dt(We,{children:qt.footer}),Tl&&!(Rl&&Gl)&&id(Tl,Ml,"footer"),Gl&&Ys(Gl),pr.treeFoot?.()]})]})]}),
55
- /* @__PURE__ */dt(en,{side:"left",width:jr.left,min:tn.left,max:nn,defaultWidth:m.left,label:qt.resizeLeftPanel,onResize:Rr})]}):/* @__PURE__ */dt(N,{side:"left",onShow:li}),
56
- /* @__PURE__ */at("div",{ref:Gr,className:"sf-center sf-scroll","data-sf-canvas-head":Zr?"":void 0,style:{overflowX:oi?"auto":"hidden",overflowY:"hidden"},children:[Zr&&/* @__PURE__ */dt("div",{ref:_r,className:"sf-canvas-head",children:/* @__PURE__ */dt(Zr,{device:zo})}),
57
- /* @__PURE__ */at("div",{className:"sf-frame-scaler",style:ri,children:[
58
- /* @__PURE__ */dt("div",{className:"sf-frame "+(zo===wo?"":`sf-frame--${zo}`),style:ii,children:/* @__PURE__ */at("div",{className:"sf-preview-host",children:[
59
- /* @__PURE__ */dt(Le.Provider,{value:El,children:/* @__PURE__ */dt(Ee.Provider,{value:Hl,children:/* @__PURE__ */dt(ao,{},Ao)})}),
60
- /* @__PURE__ */dt(un,{canvas:Ro,session:as,model:Bs,measure:Ns,canDrop:Ps,onDrop:Ms,choose:hs,onPick:As,dropOn:js?{accepts:(e,n)=>{if(!e.media||!js||n.item.rung)return!1;const t=Mn(jt.data,hi,n.item.id);return null!==t&&js.takes(t.node)},onDrop:(e,n)=>(e=>{const n=Rs();n&&js&&Ds(n).then(n=>{n&&Ws(n,e.item.id)})})(n),label:()=>qt.canvasReplaceImage}:void 0,onZoneAdd:Hs,onSeamAdd:Hs,zoneAddLabel:qt.canvasAddBlock,words:no.canvas,readOnly:Boolean(Nt),revision:jt.data}),Xo.length>0&&!Fo&&/* @__PURE__ */dt("div",{className:"sf-preview-gaps",children:Xo.map(e=>
61
- /* @__PURE__ */dt(hn,{index:e.index,label:qt.addSectionHere,onInsert:()=>ll(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))})]})}),gs?/* @__PURE__ */dt(mt,{canvas:Ro,tabs:ks,onSelect:e=>{const n=pi.findIndex(n=>String(n.props.id)===e);n>=0&&nl(n)}}):null]})]}),vo?/* @__PURE__ */at(ct,{children:[Cn?
62
- /* @__PURE__ */dt("div",{className:"es-sidepanel es-sidepanel--right","data-es-host-panel":"",children:Cn}):/* @__PURE__ */dt(ct,{children:/* @__PURE__ */dt(h,{value:{selectChild:Nl,addChild:Ol,childRowName:Wi,blockRowName:Xl},children:/* @__PURE__ */dt(co,{mode:_o,onOpenWebsiteSettings:pr.openSettings??(()=>{}),onOpenSiteStyles:pr.openStyles,onSelectNode:Br,onNotify:Yr,onHidePanel:si,nodeActions:Rt?Ie(Dt,Rt.type):St})})}),
63
- /* @__PURE__ */dt(en,{side:"right",width:jr.right,min:tn.right,max:nn,defaultWidth:m.right,label:qt.resizeSettingsPanel,onResize:Fr})]}):
64
- /* @__PURE__ */dt(N,{side:"right",onShow:si})]}),Qi.menu,
65
- /* @__PURE__ */dt(te,{}),ki?/* @__PURE__ */dt(ut,{name:ki.name,onMake:e=>(async(e,n)=>{const t=pi.find(n=>String(n.props.id)===e),o=Wt.shared;if(!t||!o)return;let r;try{r=await C(vi).create(n,t)}catch{return void Yr(qt.shared.makeFailed,"error")}o.adopt(t,r),bi(null)})(ki.id,e),onCancel:()=>bi(null)}):null]})}))}export{xt as ScreenChrome};
@@ -1 +0,0 @@
1
- import{useSectionOps as o}from"./chunk-IROEWITG.js";import{SELECTION_MODE as e}from"./chunk-SJMS247S.js";import{decodePartId as r,encodePartId as t}from"./chunk-R4AUZVA3.js";import{useEasel as n}from"./chunk-WJSEWAWK.js";import{usePreviewParts as p}from"./chunk-467WWV4I.js";import{useCallback as d,useEffect as c}from"react";var s=o=>"part"===o.kind;function m({mode:m,setMode:i,onOpenPart:I}){const{getSelectorForId:a}=n(o=>o),u=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}),I?.(n)):i(o=>"part"===o.kind?e:o)},[i,I]);c(()=>{k(l)},[k,l]);const S=s(m)?t(m.nodeId,m.propKey):null;c(()=>{f(S)},[S,f]);return{selectNode:d(o=>{i(()=>e);const r=a(o);r&&u.select(r)},[i,a,u]),openPartId:S}}export{m as usePartBridge};
@@ -1 +0,0 @@
1
- var t=t=>!!t&&"object"==typeof t&&!Array.isArray(t),r=r=>t(r)&&"string"==typeof r.type&&t(r.props);function n(t,n){if(!Array.isArray(t))return 0;let e=0;for(const o of t)r(o)&&"function"==typeof n[o.type]?.render&&(e+=1);return e}function e(t){let r="";for(const n of t)r+="number"==typeof n?`[${n}]`:""===r?n:`.${n}`;return r}function o(t,r){return"root"===r?t.root:t.components[r]}function f(t){return t?.fields??{}}function s(t){return t?.defaultProps}function c(t,r){return f(o(t,r))}function i(t){return Object.keys(t).filter(r=>"slot"===t[r]?.type)}function u(t,r){const n=[];return y(t,r,[],n),n}function y(r,n,o,f){for(const s of Object.keys(n)){const c=n[s];if(!c)continue;const i=[...o,s],u=r[s];if("slot"===c.type){const t=Array.isArray(u);f.push({slot:e(i),segments:i,content:t?u:[],present:t})}else if("object"===c.type&&c.objectFields&&t(u))y(u,c.objectFields,i,f);else if("array"===c.type&&c.arrayFields&&Array.isArray(u)){const r=c.arrayFields;u.forEach((n,e)=>{t(n)&&y(n,r,[...i,e],f)})}}}function a(t,r){let n=t;for(const t of r){if(null==n||"object"!=typeof n)return;n=n[t]}return n}function p(r,n,e){if(0===n.length)return e;const[o,...f]=n;if("number"==typeof o){const t=Array.isArray(r)?[...r]:[];return t[o]=p(t[o],f,e),t}const s=t(r)?r:{};return{...s,[o]:p(s[o],f,e)}}export{o as blockOf,s as defaultsFrom,n as drawnBlockCount,f as fieldsFrom,c as fieldsOf,a as getIn,r as isNode,t as isRecord,p as setIn,u as slotLocations,i as topLevelSlotKeys};
@@ -1,7 +0,0 @@
1
- import{STANDARD_MARKUP as t,writeMarkedLines as e,sameMarks as n,markedLines as r,spanFor as l,marksIn as o,toggleMark as i,listIn as a,setList as s,colorOver as c,unlinkAt as u,linkOver as d,colorIn as h,findLink as f,isSafeLinkHref as p}from"efficient-shell/markup";import{Tooltip as m,ColorSwatch as g,ColorPickerPanel as b,Button as k}from"efficient-shell/ui";import{jsxs as v,jsx as y}from"react/jsx-runtime";var x=/* @__PURE__ */new Set(["script","style","head","title","meta","link","template","noscript","svg","math","object","iframe"]),w=/* @__PURE__ */new Set(["p","div","li","ul","ol","dl","dt","dd","h1","h2","h3","h4","h5","h6","blockquote","pre","table","thead","tbody","tfoot","tr","section","article","header","footer","aside","nav","figure","figcaption","address","hr"]);function D(l,o){const i=o.rules??t,a=l.html&&""!==l.html.trim()?function(t,l,o){const i=l.createElement("template");i.innerHTML=t;const a=[[]],s=()=>a[a.length-1],c=()=>{const t=s();for(;t.length>0&&" "===t[t.length-1].ch;)t.pop();t.length>0&&a.push([])},u=(t,e,n,r)=>{if(3===t.nodeType){for(const l of t.textContent??""){const t=/\s/.test(l)?" ":l,o=s();" "===t&&(0===o.length&&a.length>1||" "===o[o.length-1]?.ch)||o.push({ch:t,bold:e,italic:n,href:r})}return}if(1!==t.nodeType&&11!==t.nodeType)return;const l=t,o=1===t.nodeType?l.localName:"";if(x.has(o))return;if("br"===o)return void a.push([]);let i=e,d=n,h=r;if("b"!==o&&"strong"!==o||(i=!0),"i"!==o&&"em"!==o||(d=!0),"a"===o){const t=(l.getAttribute("href")??"").trim();h=p(t)?t:null}const f=1===t.nodeType?l.style:null;if(f){const t=f.fontWeight;"bold"===t||"bolder"===t||Number(t)>=600?i=!0:("normal"===t||"lighter"===t||""!==t&&Number(t)<600)&&(i=!1),"italic"===f.fontStyle||"oblique"===f.fontStyle?d=!0:"normal"===f.fontStyle&&(d=!1)}const m=w.has(o);m&&c();for(const e of[...t.childNodes])u(e,i,d,h);m&&c()};u(i.content,!1,!1,null);for(;a.length>1&&0===a[a.length-1].length;)a.pop();return a.map(t=>function(t,l){const o=e=>t.map((n,r)=>n[e]&&(" "!==n.ch||Boolean(t[r-1]?.[e])&&Boolean(t[r+1]?.[e]))),i=[{bold:!0,italic:!0,links:!0},{bold:!0,italic:!1,links:!0},{bold:!1,italic:!1,links:!0},{bold:!1,italic:!1,links:!1}];for(const a of i){const i=M(t,a.bold?o("bold"):null,a.italic?o("italic"):null,a.links),s=e([i]).text;if(n([i],r(s,l)))return s}return t.map(t=>t.ch).join("")}(t,o))}(l.html,o.doc,i):(l.text??"").replace(/\r\n?/g,"\n").split("\n");return o.multiline?a.join("\n"):1===a.length?a[0]:a.map(t=>t.trim()).filter(t=>""!==t).join(" ")}function M(t,e,n,r){let o=0,i=null,a=null,s=null;return{bullet:!1,chars:t.map((t,c)=>{const u=r?t.href:null;return i=null===u?null:i&&i.href===u?i:l(++o,"link",u),a=e?.[c]?a??l(++o,"bold"):null,s=n?.[c]?s??l(++o,"italic"):null,{ch:t.ch,at:-1,marks:[i,a,s].filter(t=>null!==t)}})}}var N="application/x-efficient-markup",T=/^([0-9]{1,3})\. $/;function C(t,e){const n=t.split("\n"),l=r(t,e);let o=0,i=0;const a=l.map((t,e)=>{const r=!t.bullet&&null==t.number&&"- "===n[e],l=null!=t.number||t.bullet?null:T.exec(n[e]),a=t.bullet||r,s=l?l[1]:t.number??null,c=r||l?[]:t.chars,u=c.map(t=>t.ch).join(""),d=null!=s?s.length+2:a?2:0,h={bullet:a,number:s,chars:c,start:o,src:o+d,vis:i,text:u};return o+=n[e].length+1,i+=u.length+1,h});return{lines:a,text:a.map(t=>t.text).join("\n")}}function A(t,e){const{lines:n}=t;for(let t=0;t<n.length;t+=1){const r=n[t];if(e<=r.vis+r.text.length||t===n.length-1)return[r,Math.max(0,Math.min(e-r.vis,r.text.length)),t]}return[n[0],0,0]}function E(t,e){const[n,r]=A(t,e);if(0===r)return n.src;let l=0;for(const t of n.chars){if(r<=l+t.ch.length)return t.at+(r-l);l+=t.ch.length}return n.src}function S(t,e){const[n,r]=A(t,e);let l=0;for(const t of n.chars){if(r===l)return t.at;l+=t.ch.length}return E(t,e)}function B(t,e){const{lines:n}=t;let r=n[0];for(const t of n)e>=t.start&&(r=t);let l=0;for(const t of r.chars){if(!(e>=t.at+t.ch.length)){e>t.at&&(l+=e-t.at);break}l+=t.ch.length}return r.vis+l}function R(t,e,n){return[B(t,e),B(t,n)]}function L(t,e,n){return e===n?[E(t,e),E(t,e)]:[S(t,e),E(t,n)]}function K(t,e){let n=0;for(let r=0;r<t.chars.length;r+=1){if(n>=e)return r;n+=t.chars[r].ch.length}return t.chars.length}function W(t,o,i,a,s){const c=C(t,o),[u,d,h]=A(c,Math.min(i,a)),[f,p,m]=A(c,Math.max(i,a)),g=K(u,d),b=K(f,p),k=u.chars.slice(0,g),v=f.chars.slice(b),y=i!==a&&u.chars[g]&&(h!==m||g<b)?u.chars[g].marks:function(t,e){const n=t.chars[e-1],r=t.chars[e],l=(t,e)=>{const n=t.findIndex(t=>"link"===t.kind);return-1===n||e?t:t.slice(0,n)};if(n){const t=n.marks.find(t=>"link"===t.kind),e=Boolean(t&&r?.marks.some(e=>e.id===t.id));return l(n.marks,e)}return r?l(r.marks,!1):[]}(u,g);let x=(w=c.lines,Math.max(0,...w.flatMap(t=>t.chars.flatMap(t=>t.marks.map(t=>t.id))))+1);var w;const D=t=>{let e;if(void 0!==s.markup){const t=x;e=r(s.markup,o).map(e=>({bullet:e.bullet,number:e.number??null,chars:e.chars.map(e=>({...e,at:-1,marks:e.marks.map(e=>({...e,id:e.id+t}))}))}))}else{let n=u.number??null;e=(s.text??"").split("\n").map((e,r)=>(r>0&&null!=n&&(n=function(t){return String(Number(t)+1).padStart(t.length,"0")}(n)),{bullet:u.bullet,number:n,chars:[...e].map(e=>({ch:e,at:-1,marks:t??[]}))}))}const n=e.map(t=>t.chars.map(t=>t.ch).join("")).join("\n"),l={bullet:u.bullet,number:u.number??null,chars:[...k,...e[0].chars]},i=e.slice(1);if(i.length>0){const t=i[i.length-1];i[i.length-1]={...t,chars:[...t.chars,...v]}}else l.chars.push(...v);return{lines:[...c.lines.slice(0,h).map(({bullet:t,number:e,chars:n})=>({bullet:t,number:e,chars:n})),l,...i,...c.lines.slice(m+1).map(({bullet:t,number:e,chars:n})=>({bullet:t,number:e,chars:n}))],shown:n}},M=void 0!==s.markup?[null]:[(t=>{let e=t.filter(t=>!s.drop?.some(e=>t.kind===e||"highlight"===e&&"accent"===t.kind));for(const t of s.add??[]){if(e.some(e=>e.kind===t))continue;const n=l(x++,t);n&&(e=[...e,n])}if(void 0!==s.color){e=e.filter(t=>"color"!==t.kind);const t=null===s.color?null:l(x++,"color",s.color);t&&(e=[...e,t])}return e})(y),y,[]];let N="",T="";for(const t of M){const r=D(t),l=e(r.lines).text;if(N=l,T=r.shown,n(r.lines,C(l,o).lines))break}return{text:N,caret:Math.min(i,a)+T.length}}function P(t,e,n,r){const l=C(t,e),[o,,i]=A(l,n);return n!==r||!o.bullet&&null==o.number||""!==o.text?W(t,e,n,r,{text:"\n"}):j(t,e,i,!1,n)}function j(t,n,r,l,o){const i=C(t,n).lines.map(({bullet:t,number:e,chars:n},o)=>o===r?{bullet:l,number:null,chars:n}:{bullet:t,number:e,chars:n});return{text:e(i).text,caret:o}}function V(t,n,r,l){const o=C(t,n),[i,a,s]=A(o,Math.min(r,l)),[c,u,d]=A(o,Math.max(r,l)),h=o.lines.slice(s,d+1).map(({bullet:t,number:e,chars:n},r)=>{const l=0===r?K(i,a):0,o=r===d-s?K(c,u):n.length;return{bullet:t,number:e,chars:n.slice(l,o)}});return e(h).text}function q(t,e,n){if(n<0){const n=t.charCodeAt(e-1);return e-(n>=56320&&n<=57343&&e>=2?2:1)}const r=t.charCodeAt(e);return e+(r>=55296&&r<=56319?2:1)}function F(t){const{value:e,rules:n,multiline:r,inputType:l,pending:o}=t;let[i,a]=t.sel;t.target&&t.target[0]!==t.target[1]&&l.startsWith("delete")&&([i,a]=t.target);const s=[i,a];if("historyUndo"===l||"historyRedo"===l)return{kind:"history",dir:"historyUndo"===l?"undo":"redo"};if("formatBold"===l||"formatItalic"===l||"formatStrikeThrough"===l)return{kind:"format",style:"formatBold"===l?"bold":"formatItalic"===l?"italic":"strike"};if("insertParagraph"===l||"insertLineBreak"===l)return r?{kind:"edit",edit:P(e,n,i,a),range:s}:null;if(l.startsWith("insert")){if("insertTranspose"===l)return null;let c=t.data??"";if("insertFromDrop"===l||"insertFromPaste"===l){const l=D({html:t.html??void 0,text:c},{doc:t.doc,multiline:r,rules:n});return{kind:"edit",edit:W(e,n,i,a,{markup:l}),range:s}}return r||(c=c.replace(/\s*\r?\n\s*/g," ")),{kind:"type",edit:W(e,n,i,a,{text:c,add:o?.add,drop:o?.drop,color:o?.color}),range:s}}if(l.startsWith("delete")){const t=C(e,n),r=t.text;if(i===a){const o=l.includes("Backward"),c=t.lines.findIndex(t=>i>=t.vis&&i<=t.vis+t.text.length),u=t.lines[c];if(o&&u&&i===u.vis&&(u.bullet||null!=u.number))return{kind:"edit",edit:j(e,n,c,!1,i),range:s};if(o?0===i:i===r.length)return null;o?i=q(r,i,-1):a=q(r,a,1)}return{kind:"type",edit:W(e,n,i,a,{text:""}),range:[i,a]}}return null}var I=1e3;function O(t=200){let e=[],n=[],r=null,l=0;return{record(o,i,a){const s="type"===i&&"type"===r&&a-l<1e3;r=i,l=a,n=[],s||(e.push(o),e.length>t&&e.shift())},undo(t){const l=e.pop();return l?(n.push(t),r=null,l):null},redo(t){const l=n.pop();return l?(e.push(t),r=null,l):null},reset(){e=[],n=[],r=null}}}var z=t=>t.preventDefault();function U(t,e){if(t)return t.startsWith("#")?t:e?.find(e=>e.name===t)?.value}function $({colors:t,current:e,words:n,onPick:r}){const l=null===e?null:e.startsWith("#")?e.toLowerCase():t.find(t=>t.name===e)?.value.toLowerCase()??null;/* @__PURE__ */
2
- return v("div",{className:"es-copy-pop es-copy-colors",role:"dialog","aria-label":n.title,onMouseDown:t=>{"INPUT"!==t.target.tagName&&t.preventDefault()},children:[
3
- /* @__PURE__ */y("span",{className:"es-copy-pop-label",children:n.theme}),
4
- /* @__PURE__ */y("div",{className:"es-copy-theme",role:"group","aria-label":n.theme,children:t.map(t=>/* @__PURE__ */y(m,{content:`${t.label} · ${t.value.toUpperCase()}`,children:/* @__PURE__ */y(g,{color:t.value,size:"sm",className:"es-copy-theme-swatch","data-color":t.name,"aria-label":t.label,selected:e===t.name,onMouseDown:z,onClick:()=>r(t.name)})},t.name))}),
5
- /* @__PURE__ */y("span",{className:"es-copy-pop-label",children:n.any}),
6
- /* @__PURE__ */y(b,{className:"es-copy-any",value:l??"",onChange:t=>{t!==e&&r(t)},label:n.title,dragWrites:"end"}),
7
- /* @__PURE__ */y("div",{className:"es-copy-pop-foot",children:/* @__PURE__ */y(k,{variant:"ghost-danger",size:"sm","data-window-action":"remove",onMouseDown:z,onClick:()=>r(null),children:n.remove})})]})}var H={sup:"sub",sub:"sup"};function X(t){const{value:e,rules:n,start:r,end:l,style:a,pending:s}=t,c=H[a];if(r===l){const t=o(e,r,l,n),i=s&&s.at===r?s:null,u=t.has(a),d=!!i?.add.includes(a)||!i?.drop.includes(a)&&u;let h=(i?.add??[]).filter(t=>t!==a),f=(i?.drop??[]).filter(t=>t!==a);return d&&u?f.push(a):d||u||h.push(a),!d&&c&&(h=h.filter(t=>t!==c),t.has(c)&&(f=[...f.filter(t=>t!==c),c])),{kind:"pending",pending:h.length||f.length||void 0!==i?.color?{add:h,drop:f,color:i?.color,at:r}:null}}let u=e,d=r,h=l;if(c&&!o(u,d,h,n).has(a)&&o(u,d,h,n).has(c)){const t=i(u,d,h,c,n);({text:u,selectionStart:d,selectionEnd:h}=t)}return{kind:"edit",result:i(u,d,h,a,n)}}var Y=/^(block|list-item|flex|grid|table|flow-root)$/;function Z(t){const e=t.ownerDocument.defaultView;return!!e&&Y.test(e.getComputedStyle(t).display)}function G(t,e){const n=[],r=/* @__PURE__ */new Map,l=/* @__PURE__ */new Map;let o="",i=!1;const a=()=>{i&&(o+="\n",i=!1)},s=t=>{for(const c of Array.from(t.childNodes)){if(3===c.nodeType){c.data.length>0&&a(),r.set(c,o.length),n.push({node:c,start:o.length,length:c.data.length}),o+=c.data,l.set(c,o.length);continue}if(1!==c.nodeType)continue;const t=c;if(e&&t.matches(e)){r.set(t,o.length),l.set(t,o.length);continue}if("BR"===t.tagName){a(),r.set(t,o.length),o+="\n",l.set(t,o.length);continue}const u=Z(t);u&&((i||o.length>0&&!o.endsWith("\n"))&&(o+="\n"),i=!1),r.set(t,o.length);const d=o.length;s(t),u&&o.length===d&&!i&&n.push({node:t,start:d,length:0}),l.set(t,o.length),u&&(i=!0)}};r.set(t,0),s(t),l.set(t,o.length);return{text:o,at:(t,e)=>{if(3===t.nodeType)return(r.get(t)??0)+Math.min(e,t.data.length);const n=t.childNodes;return e<n.length?r.get(n[e])??l.get(t)??0:l.get(t)??o.length},dom:e=>{for(let t=0;t<n.length;t+=1){const r=n[t],l=r.start+r.length;if(e<r.start)return[r.node,0];if(e<l||e===l&&(t===n.length-1||n[t+1].start>e))return 3===r.node.nodeType?[r.node,e-r.start]:[r.node,0]}const r=n[n.length-1];return r?3===r.node.nodeType?[r.node,r.length]:[r.node,0]:[t,0]}}}function J(t){const e=t.element();if(!e)return null;let n=t.value;const r=t.rules;if(G(e,t.skip).text!==C(n,r).text)return null;const l=t.now??(()=>Date.now()),i=O();let p=e,m=!1,g=null,b=null,k=[t.caret[0],t.caret[1]],v=null,y=!1,x=!1;const w=()=>{x||t.onSelect?.()},M={contenteditable:e.getAttribute("contenteditable"),spellcheck:e.getAttribute("spellcheck")},T=()=>p.ownerDocument,A=()=>T().defaultView?.getSelection()??null,E=()=>{if(!b)return!0;nt();const e=G(p,t.skip);if(e.text!==C(n,r).text)return!1;const[l,o]=b,[i,a]=e.dom(l),[s,c]=e.dom(o);return y||T().activeElement===p||p.focus({preventScroll:!0}),A()?.setBaseAndExtent(i,a,s,c),k=b,S=b,b=null,w(),!0};let S=null;const B=()=>{if(!S)return!1;const t=A(),e=t?.anchorNode??null;return!(e&&e.isConnected&&p.contains(e))||e===p&&0===t.anchorOffset&&(0!==S[0]||0!==S[1])},K=()=>{b=S,E()},P=()=>{E(),T().activeElement===p&&B()&&K();const e=A();if(!(e&&e.anchorNode&&e.focusNode&&p.contains(e.anchorNode)&&p.contains(e.focusNode)))return k;const n=G(p,t.skip),r=n.at(e.anchorNode,e.anchorOffset),l=n.at(e.focusNode,e.focusOffset);return k=r<=l?[r,l]:[l,r],k},j=t=>{const e=T().defaultView;t<=0||!e?S=null:e.requestAnimationFrame(()=>{m||b||(nt(),T().activeElement===p?(B()&&(K(),w()),j(t-1)):S=null)})},q=(t,e)=>{b=[t,e];const n=t=>{if(m)return;if(E())return void j(3);const e=T().defaultView;t>0&&e&&e.requestAnimationFrame(()=>n(t-1))};n(30)},I=(e,r,o)=>{e.text!==n?(i.record({text:n,start:r[0],end:r[1]},o,l()),n=e.text,t.write(n),q(e.caret,e.caret),w()):q(e.caret,e.caret)},z=t=>L(C(n,r),t[0],t[1]),U=(e,o)=>{if(e.text===n)return;i.record({text:n,start:o[0],end:o[1]},"edit",l()),n=e.text,t.write(n);const[a,s]=R(C(n,r),e.selectionStart,e.selectionEnd);q(a,s),w()},$=t=>{if(m)return;const e=P(),[l,o]=z(e),i=X({value:n,rules:r,start:l,end:o,style:t,pending:v});if("pending"===i.kind)return v=i.pending,void w();U(i.result,e)},H=e=>{n=e.text,t.write(n),q(e.start,e.end)},Y=e=>{if(m)return;m=!0,rt.removeEventListener("selectionchange",lt),et(p);const n=A();n&&n.rangeCount>0&&p.contains(n.anchorNode)&&p.contains(n.focusNode)&&n.removeAllRanges(),t.end(e)},Z=(t,e)=>{const l=P();!m&&l[0]!==l[1]&&t.clipboardData&&(t.preventDefault(),t.clipboardData.setData("text/plain",C(n,r).text.slice(l[0],l[1])),t.clipboardData.setData(N,V(n,r,l[0],l[1])),e&&I(W(n,r,l[0],l[1],{text:""}),l,"edit"))},J=t=>t.preventDefault(),Q=()=>{t.remount?.()},_=[["keydown",e=>{if(m||e.isComposing)return;const r=e.metaKey||e.ctrlKey;if("Escape"!==e.key){if(r&&!e.altKey&&!e.shiftKey&&("k"===e.key||"K"===e.key)&&t.onLinkKey?.())return e.preventDefault(),void e.stopPropagation();if(r&&!e.altKey&&!e.shiftKey&&("KeyA"===e.code||"a"===e.key||"A"===e.key))return e.preventDefault(),e.stopPropagation(),q(0,G(p,t.skip).text.length),void w();if("Enter"===e.key&&(!e.shiftKey||r))return e.preventDefault(),e.stopPropagation(),void Y("enter");if(r&&("z"===e.key||"Z"===e.key||"y"===e.key)){e.preventDefault(),e.stopPropagation();const t=P(),r={text:n,start:t[0],end:t[1]},l="y"===e.key||e.shiftKey?i.redo(r):i.undo(r);l&&H(l)}}else{if(e.preventDefault(),e.stopPropagation(),t.onEscape?.())return;Y("escape")}}],["beforeinput",e=>{if(m)return;if("insertCompositionText"===e.inputType)return;e.preventDefault();const l=P(),o=G(p,t.skip),a="function"==typeof e.getTargetRanges?e.getTargetRanges()[0]:void 0,s=a&&!a.collapsed?[o.at(a.startContainer,a.startOffset),o.at(a.endContainer,a.endOffset)]:null,c=F({value:n,rules:r,multiline:t.multiline,inputType:e.inputType,data:e.data??e.dataTransfer?.getData("text/plain")??"",html:e.dataTransfer?.getData("text/html"),doc:T(),sel:l,target:s,pending:v&&v.at===z(l)[0]?v:null});if(c){if("type"!==c.kind&&"edit"!==c.kind||(v=null),"history"===c.kind){const t={text:n,start:l[0],end:l[1]},e="undo"===c.dir?i.undo(t):i.redo(t);return void(e&&H(e))}"format"!==c.kind?I(c.edit,c.range,c.kind):$(c.style)}}],["compositionstart",()=>{g=P()}],["compositionend",e=>{const o=g;if(g=null,!m&&o)if(e.data){const a=W(n,r,o[0],o[1],{text:e.data});i.record({text:n,start:o[0],end:o[1]},"type",l()),n=a.text,t.write(n),Q(),q(a.caret,a.caret)}else Q(),q(o[0],o[0])}],["paste",e=>{if(m)return;e.preventDefault();const l=P(),o=e.clipboardData,i=o?.getData(N)??"",a=i?t.multiline?i:i.replace(/\s*\r?\n\s*/g," "):D({html:o?.getData("text/html")??"",text:o?.getData("text/plain")??""},{doc:T(),multiline:t.multiline,rules:r});I(W(n,r,l[0],l[1],{markup:a}),l,"edit")}],["copy",t=>Z(t,!1)],["cut",t=>Z(t,!0)],["drop",J],["dragstart",J],["blur",e=>{if(m||null!==g||y)return;const n=e.target,r=n.ownerDocument.defaultView,l=()=>{m||(n.isConnected&&n===t.element()?y||n.ownerDocument.activeElement===n||Y("blur"):q(k[0],k[1]))};r?.requestAnimationFrame?r.requestAnimationFrame(l):setTimeout(l,0)}],["focus",()=>{y=!1}]];function tt(t){t.setAttribute("contenteditable","true"),t.setAttribute("spellcheck","false"),t.setAttribute("data-es-typing","");for(const[e,n]of _)t.addEventListener(e,n)}function et(t){for(const[e,n]of _)t.removeEventListener(e,n);null===M.contenteditable?t.removeAttribute("contenteditable"):t.setAttribute("contenteditable",M.contenteditable),null===M.spellcheck?t.removeAttribute("spellcheck"):t.setAttribute("spellcheck",M.spellcheck),t.removeAttribute("data-es-typing")}function nt(){const e=t.element();e&&e!==p&&(et(p),p=e,tt(p))}const rt=p.ownerDocument;function lt(){m||w()}return rt.addEventListener("selectionchange",lt),tt(p),p.focus({preventScroll:!0}),q(t.caret[0],t.caret[1]),{get value(){return n},update(t){if(t===n)return;const e=C(t,r).text.length,[l,o]=P();n=t,i.reset(),q(Math.min(l,e),Math.min(o,e))},stop(t="stop"){Y(t)},pressed(){let t;x=!0;try{t=P()}finally{x=!1}const[e,l]=z(t),i=o(n,e,l,r),s={};for(const t of["bold","italic","underline","strike","sup","sub","link"]){const n=i.has(t),r=v&&v.at===e?v:null;s[t]=!!r?.add.includes(t)||!r?.drop.includes(t)&&n}const c=v&&v.at===e&&void 0!==v.color?v:null;return{marks:s,list:a(n,e,l,r),selected:l>e,href:f(n,e,l)?.href??null,color:c?c.color??null:h(n,e,l,r)}},press:$,insert(t){if(m)return;y=!1;const e=P(),[r,l]=z(e),o=r+t.length;U({text:n.slice(0,r)+t+n.slice(l),selectionStart:o,selectionEnd:o},e),nt(),p.focus({preventScroll:!0})},hold(){m||(P(),y=!0)},release(){y=!1},resume(){m||(y=!1,nt(),p.focus({preventScroll:!0}),q(k[0],k[1]))},link(t){if(m)return;y=!1;const e=P(),[l,o]=z(e),i=null===t?u(n,l,o,r):d(n,l,o,t,r),a=i.text===n;U(i,e),nt(),p.focus({preventScroll:!0}),a&&q(e[0],e[1])},color(t){if(m)return;const e=P(),[l,o]=z(e);if(l===o){const e=v&&v.at===l?v:null;return v={add:e?.add??[],drop:e?.drop??[],color:t,at:l},void w()}U(c(n,l,o,t,r),e)},list(e){if(m||!t.multiline)return;const l=P(),[o,i]=z(l),c=a(n,o,i,r);U(s(n,o,i,c===e?null:e,r),l)}}}var Q=(t,e,n)=>Math.min(Math.max(t,e),Math.max(e,n));function _({anchor:t,size:e,within:n,clip:r,parent:l,gap:o=8}){const i=Math.max(n.left,r.left),a=Math.min(n.right,r.right)-e.width,s=Q(t.left,i,a),c=r.bottom-(t.bottom+o),u=t.top-o-r.top,d=e.height>c&&(e.height<=u||u>c),h=d?t.top-o-e.height:t.bottom+o,f=t.left+Math.min((t.right-t.left)/2,10),p=Q(f-5-s,10,e.width-10-10);return{top:h-l.top,left:s-l.left,above:d,point:p}}var tt=t=>({left:t.left,top:t.top,right:t.right,bottom:t.bottom});function et(t,e){const n=("function"==typeof t.getClientRects?[...t.getClientRects()]:[]).filter(t=>t.height>0);if(n.length>0){const e="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():n[0];return e.height>0?tt(e):tt(n[0])}if(!e)return null;const r=e.getBoundingClientRect();return{left:r.left,top:r.top,right:r.left,bottom:r.bottom}}function nt(t){const e=t.ownerDocument,n=e.documentElement,r={left:0,top:0,right:n.clientWidth,bottom:n.clientHeight},l=e.defaultView?.getComputedStyle.bind(e.defaultView);for(let o=t.parentElement;o&&o!==n&&o!==e.body;o=o.parentElement){const t=l?.(o);if(!t||"visible"===t.overflowX&&"visible"===t.overflowY)continue;const e=o.getBoundingClientRect();if(0===e.width&&0===e.height)continue;const n=e.left+o.clientLeft,i=e.top+o.clientTop;r.left=Math.max(r.left,n),r.top=Math.max(r.top,i),r.right=Math.min(r.right,n+(o.clientWidth||e.width)),r.bottom=Math.min(r.bottom,i+(o.clientHeight||e.height))}return r}function rt(t){const e=t.offsetParent??t.parentElement;if(!e)return{left:0,top:0};const n=e.getBoundingClientRect();return{left:n.left+e.clientLeft-e.scrollLeft,top:n.top+e.clientTop-e.scrollTop}}function lt(t,e,n){const r=t.ownerDocument,l=r.createTreeWalker(t,4),o=t=>{let e=t,n=null;for(let t=l.nextNode();t;t=l.nextNode()){if(e<=t.data.length)return[t,e];e-=t.data.length,n=t}return n?[n,n.data.length]:null},i=o(e);l.currentNode=t;const a=o(n);if(!i||!a)return null;const s=r.createRange();return s.setStart(i[0],i[1]),s.setEnd(a[0],a[1]),s}export{$ as ColorWindow,N as MARKUP_CLIPBOARD_TYPE,I as TYPING_BURST_MS,U as colorRunOf,O as createHistory,W as editVisible,X as markPress,V as markupOfRange,P as newLine,rt as offsetOrigin,D as pasteToMarkup,_ as placeWindow,F as richInput,C as richLayout,et as selectionBox,L as selectionToSource,R as selectionToVisible,j as setBullet,J as startCanvasTyping,G as textMap,lt as textRange,E as toSource,S as toSourceStart,B as toVisible,nt as visibleArea};
@@ -1,5 +0,0 @@
1
- import{usePickFollowsSelection as n}from"./chunk-FHCKFOCD.js";import{slotFieldsOf as e}from"./chunk-TCAAOYQY.js";import{EaselCanvas as t,useSelectedFields as r}from"./chunk-WJSEWAWK.js";import{Inspector as i}from"./chunk-YHFKWV7H.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:"selection"};function f(n){return"selection"===n.kind}function a(n,e){if(f(n)&&f(e))return!0;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 d(n){const e=n;return"string"==typeof e.nodeId&&"string"==typeof e.slot}function p(n,t,r){const i=n.slotsOf?.(r);return i||e(t,r.type).map(n=>({slot:n,label:n,rung:!1}))}function m(n,e){return n.isFirst?n.isFirst(e):e.type===n.first}function k(n,e){return n.isLast?n.isLast(e):e.type===n.last}var h={},v=()=>h,g=()=>"",y=()=>null,b=()=>{},O={isLockedBlock:()=>!1,duplicateBlocked:()=>null,nestDepth:()=>0,newSectionNode:()=>null,canAddTo:()=>null,blockIsOffered:()=>!0},j={labelAtLevel:(n,e,t)=>t,descriptions:{},categoryLabel:()=>{},firstSection:null,blockRowName:(n,e)=>e(n.type),plainText:n=>n,Icon:()=>null,Thumbnail:()=>null,useProducts:()=>null},w={options:[{id:"desktop",label:"Desktop",icon:/* @__PURE__ */s(l,{})}],initial:"desktop",fluid:"desktop",widths:{desktop:2e3}},C={read:()=>"sections",write:()=>{},forSelection:(n,e)=>n?"sections":e},S={first:null,last:null,firstGroup:null,lastGroup:null,isSectionGroup:()=>!1,sectionGroupZone:()=>"",panelOf:()=>null};function L(){/* @__PURE__ */
2
- return s(t,{height:"fill"})}function D(){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 F=o({});function A({parts:n,children:e}){/* @__PURE__ */
4
- return s(F.Provider,{value:n,children:e})}function N(){return u(F)}function P(){return(N().useOwnerName??g)()}function x(){return(N().useDocumentLabel??y)()}function B(n,e,t,r){return(N().useBridges??v)(n,e,t,r)}function G(n){return(N().useStandaloneBridges??v)(n)}function H(n,e){(N().useDocumentPass??b)(n,e)}function I(){return N().blockRules??O}function K(){return N().blockLook??j}function T(){return N().devices??w}function W(){return N().leftView??C}function Y(){return N().pinned??S}function R(){return N().saveSwitch??!0}function V(e){n(!0===N().pickFollowsSelection,e)}function E(){return N().storageNamespace||void 0}function J(){return N().styleClipboard??null}function Q(){return N().nodeKeys??!0}function Z(){return N().notify??null}function q(){return N().Canvas??L}function z(){return N().CanvasHead??null}function M(){return N().canvasDrag??null}var U=o(null);function X({target:n,children:e}){/* @__PURE__ */
5
- return s(U.Provider,{value:n,children:e})}function $(){return u(U)}function _(){return N().Inspector??D}export{c as SELECTION_MODE,X as ScreenCanvasTargetProvider,A as ScreenPartsProvider,m as isPinnedFirst,k as isPinnedLast,f as isSelectionMode,d as isSlotMode,a as sameInspectorMode,p as screenSlotsOf,K as useScreenBlockLook,I as useScreenBlockRules,B as useScreenBridges,M as useScreenCanvasDrag,q as useScreenCanvasFrame,z as useScreenCanvasHead,$ as useScreenCanvasTarget,T as useScreenDevices,x as useScreenDocumentLabel,H as useScreenDocumentPass,_ as useScreenInspectorPanel,W as useScreenLeftView,Q as useScreenNodeKeys,Z as useScreenNotify,P as useScreenOwnerName,N as useScreenParts,V as useScreenPickFollowsSelection,Y as useScreenPinned,R as useScreenSaveSwitch,E as useScreenStorageNamespace,J as useScreenStyleClipboard,G as useStandaloneScreenBridges};
@@ -1,8 +0,0 @@
1
- import{buildPaletteSections as e,pinnedSection as t,categoryLabel as n}from"./chunk-VKPOH6MK.js";import{blockTypesIn as o}from"./chunk-CPL43ZLJ.js";import{sectionTemplatesOf as l}from"./chunk-N7E6264U.js";import{sharedSectionsOf as r}from"./chunk-N3MJOHAG.js";import{SidePanelHead as i,PanelModeExit as s}from"./chunk-SINAM2IT.js";import{blockRuns as c}from"./chunk-RUQOIQWI.js";import{useScreenBlockLook as a,useScreenBlockRules as d,useScreenPinned as p}from"./chunk-SJMS247S.js";import{useEaselSession as m}from"./chunk-YM4UEGBV.js";import{DEFAULT_SCREEN_WORDS as f}from"./chunk-EB6NI2VK.js";import{useEasel as u}from"./chunk-WJSEWAWK.js";import{easelMenuEntries as y}from"./chunk-FIVU2COQ.js";import{useWords as h}from"./chunk-MFIRYGHW.js";import{AddPanel as k}from"./chunk-CUZQ2HMA.js";import{DEFAULT_DRAG_WORDS as g}from"./chunk-TQ5Y6S2X.js";import{useState as b,useEffect as v,useMemo as j,useRef as C}from"react";import{SharedIcon as w,AddIcon as I}from"efficient-shell/icons/efficient";import{ContextMenu as M,toast as S,Dialog as E,Button as O}from"efficient-shell/ui";import{jsx as $,jsxs as x,Fragment as A}from"react/jsx-runtime";function T({name:e,pages:t,onDelete:n,onCancel:o}){const l=h("screen",f).shared,[r,i]=b(!1),s=C(null);/* @__PURE__ */
2
- return $(E,{open:!0,role:"alertdialog",size:"sm",title:l.deleteTitle({name:e}),onClose:o,initialFocus:s,footer:/* @__PURE__ */x(A,{children:[
3
- /* @__PURE__ */$(O,{ref:s,variant:"secondary",onClick:o,children:l.cancel}),
4
- /* @__PURE__ */$(O,{variant:"danger",loading:r,onClick:()=>{(async()=>{i(!0);try{await n()}finally{i(!1)}})()},children:l.deleteShared})]}),children:l.deleteMessage({count:t})})}var W=e=>`section:${e}`,F=e=>`block:${e}`,H=e=>`template:${e}`,L=e=>`shared:${e}`;function N({at:C,placeBlocks:E,canTake:O,onPick:N,itemFor:B,session:Q,siteWide:U,onClose:z,onHide:J,readOnly:K}){const P=u(e=>e.config),V=a(),{labelAtLevel:D,categoryLabel:G,firstSection:R,Icon:Y,Thumbnail:Z}=V,{blockIsOffered:_,canAddTo:X}=d(),q=h("screen",f).add,ee=h("drag",g).add,te=m(),[ne,oe]=b([]);v(()=>{let e=!1;const t=e=>_(e,te);return l(te).list().then(n=>{if(e)return;const l=P.components;oe(n.filter(e=>e.node?.type&&l[e.node.type]&&o(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[P,te]);const le=p().shared,re=h("screen",f).shared,[ie,se]=b([]),[ce,ae]=b(0);v(()=>{if(!le)return;let e=!1;const t=e=>_(e,te);return r(te).list().then(n=>{if(e)return;const l=P.components;se(n.filter(e=>e.node?.type&&l[e.node.type]&&o(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[P,te,ce]);const[de,pe]=b(null),[me,fe]=b(null),ue=j(()=>e(P,V),[P]),ye=e=>D(e,"section",P.components[e]?.label??e),he=e=>({type:W(e.type),label:e.name,cover:/* @__PURE__ */$(Z,{type:e.type}),title:e.desc?`${e.name} — ${e.desc}`:q.tile({name:e.name}),keywords:[e.alias??"",e.desc,e.type,e.catLabel].filter(Boolean)}),ke=e=>{const t=e.indexOf(":"),n=e.slice(0,t),o=e.slice(t+1);if("section"===n)return{kind:"section",type:o};if("block"===n)return{kind:"block",type:o};if("template"===n){const e=ne.find(e=>e.id===o);return e?{kind:"template",template:e}:null}if("shared"===n){const e=ie.find(e=>e.id===o);return e?{kind:"shared",section:e}:null}return null},ge=e=>/* @__PURE__ */$("span",{className:"es-add-glyph-cover",children:/* @__PURE__ */$(Y,{type:e,size:26})}),be=j(()=>{const e=t(ue,R),o=/* @__PURE__ */new Map,l=e=>{e.retired||o.has(e.type)||!_(e.type,te)||o.set(e.type,e)};for(const t of e?[e]:ue){const e=X(t.type)?.choices??[];e.forEach(l),e.forEach(e=>X(e.type,1)?.choices?.forEach(l))}E?.forEach(l);const r=new Set(ue.map(e=>e.type)),i=[...o.values()].filter(e=>!r.has(e.type)),s=e=>({type:F(e.type),label:e.label,cover:ge(e.type),title:q.tile({name:e.label}),keywords:[e.group??"",e.type].filter(Boolean)}),a=e=>o.has(e.type)?{...he(e),cover:ge(e.type)}:he(e),d=[];ie.length>0&&d.push({key:"shared",title:re.group,tiles:ie.map(e=>({type:L(e.id),label:e.title,cover:/* @__PURE__ */$(Z,{type:e.node.type}),mark:/* @__PURE__ */$(w,{size:12}),title:re.onPages({count:e.used_on.length}),keywords:[ye(e.node.type),e.node.type]}))}),ne.length>0&&d.push({key:"templates",title:q.templates,tiles:ne.map(e=>({type:H(e.id),label:e.name,cover:/* @__PURE__ */$(Z,{type:e.node.type}),keywords:[ye(e.node.type),e.node.type]}))});const p=i.filter(e=>!e.group);let m=!1;for(const t of Object.keys(P.categories??{})){const o=ue.filter(e=>e.cat===t);if(0===o.length)continue;const l=e&&o.some(t=>t.type===e.type)?e:null,r=(l?[l,...o.filter(e=>e.type!==l.type)]:o).map(a);l&&!m&&(r.splice(1,0,...p.map(s)),m=!0),d.push({key:`category:${t}`,title:n(P,t,G),tiles:r})}const f=d.find(e=>e.key?.startsWith("category:"));if(!m&&f&&p.length>0&&(f.tiles=[...f.tiles,...p.map(s)],m=!0),c(i.filter(e=>e.group||!m)).forEach((e,t)=>{d.push({key:`blocks:${t}`,title:e.group??"",tiles:e.items.map(s)})}),!O)return d;const u=d.map(e=>({...e,tiles:e.tiles.map(e=>{const t=ke(e.type),n=t?O(t):null;return n?{...e,disabled:!0,disabledReason:n}:e})})),y=e=>e.tiles.some(e=>!e.disabled);return[...u.filter(y),...u.filter(e=>!y(e))]},[ne,ie,re,ue,P,q,O,E,te]);/* @__PURE__ */
5
- return x(A,{children:[
6
- /* @__PURE__ */$(i,{icon:/* @__PURE__ */$(I,{size:15}),title:q.title,context:q.contextAll,actions:/* @__PURE__ */$(s,{label:q.done,description:q.doneDescription,onClick:z}),onHide:J}),
7
- /* @__PURE__ */x("div",{className:"sf-addside sf-scroll",children:[
8
- /* @__PURE__ */$(k,{groups:be,session:Q,itemFor:e=>B(ke(e)??{kind:"section",type:e}),onInsert:N?e=>{const t=ke(e);t&&N(t)}:void 0,onTileMenu:(e,t)=>{const n=ke(e);return"shared"===n?.kind&&!K&&(pe({section:n.section,...t}),!0)},at:C,hint:q.hint,searchLabel:q.search,readOnly:K,words:ee}),U??null]}),de?/* @__PURE__ */$(M,{at:{x:de.x,y:de.y},owner:de.owner,onClose:()=>pe(null),"aria-label":de.section.title,items:y([{label:re.deleteShared,danger:!0,onClick:()=>{fe(de.section),pe(null)}}])}):null,me?/* @__PURE__ */$(T,{name:me.title,pages:me.used_on.length,onDelete:()=>(async e=>{try{await r(te).remove(e.id)}catch{return void S.error(re.deleteFailed)}fe(null),le?.removed?.(e),se(t=>t.filter(t=>t.id!==e.id)),ae(e=>e+1)})(me),onCancel:()=>fe(null)}):null]})}export{N as AddSidePanel,F as blockKey,W as sectionKey,L as sharedKey,H as templateKey};
@@ -1,15 +0,0 @@
1
- import{DEFAULT_CANVAS_WORDS as e}from"./chunk-TBY3DFKS.js";import{useResolvedFields as t}from"./chunk-IWCKVZHS.js";import{toItemSelector as n,fromItemSelector as o,useNodeOps as r,parentStep as i,clickPickPart as l,clickPick as s}from"./chunk-BSHIQIZC.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-MZ5GSSZ3.js";import{DEFAULT_COPY_WORDS as m}from"./chunk-KRL3IUV3.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-GHBK7BKL.js";import{queryAllCopies as C}from"./chunk-LF3FUSCQ.js";import{find as I,ROOT_ID as D,getList as E,remove as x,parseZoneKey as O,move as A,duplicate as M,replaceNode as z,createNode as R,insert as B,normalizeData as L,createResolveCache as V,resolveNodeData as $,ROOT_SLOT as j}from"./chunk-K7BTCBWD.js";import{topLevelSlotKeys as K,fieldsFrom as N,drawnBlockCount as P,defaultsFrom as Z}from"./chunk-L55YIXDC.js";import{createContext as F,useEffect as H,useContext as T,useRef as W,useSyncExternalStore as Y,useState as q,useMemo as U,useCallback as G,useLayoutEffect as Q}from"react";import{jsx as X,jsxs as J,Fragment as _}from"react/jsx-runtime";import{createPortal as ee}from"react-dom";import{registerModalEscapeInterceptor as te,FloatingBar as ne,TextToolbar as oe,LinkPicker as re}from"efficient-shell/ui";function ie(e){return!["setData","setUi","set"].includes(e.type)}var le=(e,t,n,o)=>{const r=E(e,t,O(n));return r?.[o]??null},se=(e,t,n,o,r)=>{const i=le(e,t,n,o);if(!i)throw new Error(`${r}: nothing at ${n}[${o}]`);return i};function ae(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 ce(e,t,n){return n?"node"===n.kind?I(e,t,n.id)?n:null:n.parentId===D?E(e,t,n)?n:null:I(e,t,n.parentId)&&E(e,t,n)?n:null:null}function de(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 ue(e,t,n){const o=pe(e,t,n);if(o===e)return e;const r=ce(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function pe(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 de(e,n,"function"==typeof t.ui?t.ui(ae(e,n)):t.ui);case"set":{const r={data:o,ui:ae(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=de(l,n,i.ui,!0)),l}case"insert":{const r={...O(t.destinationZone),index:t.destinationIndex},i=R(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:B(o,n,r,i)}}case"replace":{const r=se(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:z(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=se(o,n,t.sourceZone,t.sourceIndex,"duplicate"),i=M(o,n,r.props.id),l=le(i,n,t.sourceZone,t.sourceIndex+1);return{...e,data:i,selection:l?{kind:"node",id:l.props.id}:e.selection}}case"reorder":return pe(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=le(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const i={...O(t.destinationZone),index:t.destinationIndex};return{...e,data:A(o,n,r.props.id,i)}}case"remove":{const r=se(o,n,t.zone,t.index,"remove");return{...e,data:x(o,n,r.props.id)}}default:return e}}var fe={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},he={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},me=0,ge=()=>`history-${me+=1}`;function ve(e){let t=e.config;const r=e.now??(()=>Date.now()),i=e.historyCoalesceMs??250;let l=e.permissions??{};const s=L(e.data,t);let a=s,c={data:s,selection:null,ui:{...he}};if(e.ui){const{itemSelector:n,selectedSlot:r,...i}=e.ui;c={data:s,selection:r?{kind:"slot",...r}:o(s,t,n??null),ui:{...he,...i}}}let d=[{core:c,at:-1/0,sealed:!0,id:ge()}],u=0;const p=e=>{const t=d[u],n=r();!e&&u===d.length-1&&u>0&&!t.sealed&&n-t.at<i?d=[...d.slice(0,u),{...t,core:c,at:n}]:(d=[...d.slice(0,u+1),{core:c,at:n,sealed:e,id:ge()}],u=d.length-1)},f=/* @__PURE__ */new Set;let h=null,m=null,g=0,v=null,y=!1;const w=()=>{for(const e of[...f])e()},b=()=>{d=[...d.slice(0,u),{...d[u],core:c},...d.slice(u+1)]},k=(t,n)=>{g>0?y=y||n:(n?p(!1):c!==t&&b(),c.data!==t.data&&e.onChange?.(c.data),c!==t&&w())},S=e=>{const n=c;if(c=ue(c,e,t),c===n)return;const o=e.recordHistory??ie(e);k(n,o&&c.data!==n.data)},C=t=>{0===g&&(v=c,y=!1),g+=1;try{t()}catch(e){throw g-=1,0===g&&v&&(c=v,v=null),e}if(g-=1,g>0||!v)return;const n=v;v=null,y&&c.data!==n.data?p(!0):c!==n&&b(),c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},D=e=>{const n=c,o=ce(c.data,t,e);var r,i;(r=o,i=c.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))||(c={...c,selection:o},k(n,!1))},x=t=>{const n=c;u=t,c=d[u].core,c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},O=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...fe,...l,...n}};let A=O();const M=V(),R={resolveCache:M,async resolveAll({trigger:e="load",metadata:n}={}){const o=c.data,r={type:"root",props:{...o.root.props??{}}},i=[...o.content,...Object.values(o.zones??{}).flat()],[l,...s]=await Promise.all([$(r,t,{cache:M,trigger:e,metadata:n}),...i.map(o=>$(o,t,{cache:M,trigger:e,metadata:n}))]);C(()=>{const n=c;let r=c.data;s.forEach((e,n)=>{if(!e.didChange)return;const l=i[n].props.id,s=I(r,t,l)?.node;s&&s===I(o,t,l)?.node&&(r=z(r,t,l,e.node))}),l.didChange&&r.root===o.root&&(r={...r,root:{...r.root,props:l.node.props,readOnly:l.node.readOnly??r.root.readOnly}}),r!==c.data&&("load"===e&&c.data===a&&(a=r),c={...c,data:r,selection:ce(r,t,c.selection)},k(n,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=I(c.data,t,e)?.node;if(!r)return!1;const i=await $(r,t,{cache:M,trigger:n,metadata:o});if(!i.didChange)return!1;let l=!1;return C(()=>{const n=c;if(I(c.data,t,e)?.node!==r)return;const o=z(c.data,t,e,i.node);o!==c.data&&(c={...c,data:o,selection:ce(o,t,c.selection)},k(n,!1),l=!0)}),l},get config(){return t},get loaded(){return a},getState(){if(h&&m===c)return h;const e=c,o={data:e.data,ui:ae(e,t)},r="node"===e.selection?.kind?I(e.data,t,e.selection.id)?.node??null:null;return h={appState:o,selection:e.selection,selectedItem:r,config:t,dispatch:S,history:{back:()=>R.undo(),forward:()=>R.redo(),hasPast:u>0,hasFuture:u<d.length-1,histories:d.map(e=>({id:e.id,state:{data:e.core.data,ui:ae(e.core,t)}})),index:u,setHistoryIndex:e=>{e>=0&&e<d.length&&e!==u&&x(e)}},getPermissions:A,getItemById:n=>I(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}},m=e,h},subscribe:e=>(f.add(e),()=>{f.delete(e)}),dispatch:S,batch:C,group:()=>{const e=u,t=d[e].id;let n=!0;return{close:()=>{if(!n)return;if(n=!1,d[e]?.id!==t)return;if(u<=e+1)return void(u===e+1&&(d=[...d.slice(0,u),{...d[u],sealed:!0},...d.slice(u+1)]));const o=d[u];d=[...d.slice(0,e+1),{...o,sealed:!0},...d.slice(u+1)],u=e+1}}},select:e=>D(e?{kind:"node",id:e}:null),selectSlot:e=>D(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){C(()=>{const n=c,o=void 0===e.select?c.selection:e.select;c={...c,data:e.data,selection:ce(e.data,t,o)},k(n,e.data!==n.data)})},load(e,n={}){const o=c,r=L(e,t);c={...c,data:r,selection:ce(r,t,n.selection??c.selection)},a=r,n.keepHistory||(d=[{core:c,at:-1/0,sealed:!0,id:ge()}],u=0),c!==o&&w()},undo(){u>0&&x(u-1)},redo(){u<d.length-1&&x(u+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=O(),h=null,w())},setConfig(e){e!==t&&(t=e,A=O(),h=null,w())}};return R}function ye(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 we=F(null),be=F(!0);function ke({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return H(()=>{n&&e.resolveAll()},[e,n]),H(()=>{if(t&&"undefined"!=typeof document)return ye(document,e)},[e,t]),/* @__PURE__ */X(we.Provider,{value:e,children:/* @__PURE__ */X(be.Provider,{value:t,children:o})})}function Se(){const e=T(we);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function Ce(e){const t=Se(),n=W({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 Y(t.subscribe,o,o)}function Ie(){return function(e){return Ce(e)}}var De="data-easel-block",Ee="data-easel-dropzone",xe={},Oe="data-es-mirror",Ae="undefined"==typeof window?H:Q;function Me(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${Oe}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(Oe,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function ze({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=W(null),[p,f]=q(null);return Ae(()=>{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]),Ae(()=>{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-easel-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){Me(o,e,c);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>Me(o,e,c)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}return()=>{n?.disconnect(),t.remove(),f(null),s?.(null)}},[]),/* @__PURE__ */X("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?ee(t,p):null})}var Re=F(null),Be=F(xe),Le=[];function Ve({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:i=120}){const l=Se(),s=Ce(n=>E(n.appState.data,l.config,{parentId:e,slot:t})??Le),a=Ce(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==D),c=Ce(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),d=T(Re),u=["es-zone"];return s.length&&u.push("has-children"),e===D&&u.push("is-root"),(a||c)&&u.push("is-area-selected"),null!==d&&d===e&&e!==D&&u.push("is-hovering-area"),n&&u.push(n),/* @__PURE__ */X("div",{className:u.join(" "),[Ee]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${i}px`},children:s.map(e=>/* @__PURE__ */X(He,{node:e},e.props.id))})}function $e(e,t,n,o){const r=U(()=>{const n={};for(const o of K(N(e)))n[o]=Object.assign(function(e={}){/* @__PURE__ */
2
- return X(Ve,{parentId:t,slot:o,...e})},{blockCount:0});return n},[e,t]);for(const e of Object.keys(r))r[e].blockCount=P(n[e],o);return r}function je(e){return U(()=>function({zone:t,...n}){/* @__PURE__ */
3
- return X(Ve,{parentId:e,slot:t,...n})},[e])}var Ke=["top","bottom","zIndex"];function Ne(e,t,n){e.style[t]!==n&&(e.style[t]=n)}function Pe(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));Ne(e,"position",t?"sticky":"relative");for(const n of Ke)Ne(e,n,t?.[n]??"");return!!t}var Ze="data-es-canvas-relative";function Fe(e){e.hasAttribute(Ze)&&("relative"===e.style.position&&(e.style.position=""),e.removeAttribute(Ze));const t=e.ownerDocument.defaultView?.getComputedStyle(e).position;return t&&"static"!==t?"sticky"===t:(e.style.position||(e.style.position="relative",e.setAttribute(Ze,"")),!1)}function He({node:e}){const t=Se().config,n=t.components[e.type],o=e.props.id,r=W(null),i=function(e,t){return U(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(De),o.removeAttribute("data-easel-dnd")),t.current=n,n&&(n.setAttribute(De,e),n.setAttribute("data-easel-dnd",e),Fe(n))},[e,t])}(o,r),l=W(null),s=!!n?.inline;!function(e,t){const n=W(!1),o=W(()=>{});o.current=()=>{const o=e(),i=n.current;n.current=!!o&&t(o),i!==n.current&&r.current()};const r=W(()=>{});Ae(()=>o.current()),Ae(()=>{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=()=>{}}},[])}(()=>s?r.current:l.current,e=>s?Fe(e):Pe(e));const a=T(Be),c=$e(n,o,e.props,t.components),d=je(o);if(!n?.render)return null;const u=n.render,p={...Z(n),...e.props,...c},f={renderDropZone:d,isEditing:!0,dragRef:n.inline?i:null,metadata:{...a,...n.metadata}};return n.inline?/* @__PURE__ */X(u,{...p,editor:f,editMode:!0}):
4
- /* @__PURE__ */X("div",{ref:l,[De]:o,"data-easel-dnd":o,style:{position:"relative"},children:/* @__PURE__ */X(u,{...p,editor:f,editMode:!0})})}function Te({metadata:e}){const t=Ce(e=>e.config),n=Ce(e=>e.appState.data.root).props??{},o=t.root?.render,r=$e(t.root,D,n,t.components),i=je(D),l=/* @__PURE__ */X(Ve,{parentId:D,slot:j}),s=o?/* @__PURE__ */X(o,{id:"page-root",...n,...r,editor:{renderDropZone:i,isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:l}):l;/* @__PURE__ */
5
- return X(Be.Provider,{value:e??xe,children:s})}var We=F(void 0),Ye=F(void 0),qe=F(void 0);function Ue({element:e}){const t=W(null),n=Ge(t,e?()=>e:null,e);/* @__PURE__ */
6
- return X("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 Ge(e,t,n){return Xe(e,t?e=>{const n=t(e);return n?[n]:[]}:null,n)[0]??null}var Qe=[];function Xe(e,t,n){const[o,r]=q(Qe),i=W(t);return i.current=t,Ae(()=>{const t=e.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!i.current)return void r(Qe);let o=0;const l=()=>{o=0;const n=e.current?.parentElement??null,l=(i.current?i.current(t):[]).map(e=>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}}(e,n)).filter(e=>null!==e);r(e=>{return(t=e)===(n=l)||t.length===n.length&&t.every((e,t)=>function(e,t){return e===t||!!e&&!!t&&e.top===t.top&&e.left===t.left&&e.width===t.width&&e.height===t.height}(e,n[t]))?e:l.length?l:Qe;var t,n})},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 Je({id:e,kind:t,overlay:n}){const o=W(null),r=T(Ye),i=null!==e&&!0===r?.(e),l=Xe(o,e?t=>C(t,`[${De}="${t.defaultView?.CSS?.escape?t.defaultView.CSS.escape(e):e}"]`):null,e),[s,...a]=l,c=`es-canvas-outline is-${t}${i?" is-shared":""}`,d=e=>({position:"absolute",top:e.top,left:e.left,width:e.width,height:e.height}),u=/* @__PURE__ */J(_,{children:[
7
- /* @__PURE__ */X("div",{ref:o,"aria-hidden":"true",className:c,style:s?d(s):{display:"none"}}),a.map((e,t)=>/* @__PURE__ */X("div",{"aria-hidden":"true",className:c,style:d(e)},t))]});return n&&e?/* @__PURE__ */X(n,{componentId:e,kind:t,children:u}):u}function _e(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 et({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=W(null),[v,y]=q(!1),[w,k]=q(null),S=v||null!==w,C=()=>{e.hold(),y(!1),k({href:e.pressed().href})},I=()=>{y(!1),k(null),e.resume()};Q(()=>{r.current={escape:()=>!!S&&(I(),!0),link:()=>!!s.has("link")&&(C(),!0)}}),Q(()=>()=>{r.current=null},[r]);const D=W(I);D.current=I,H(()=>{if(v)return te(e=>{const t=h.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(D.current(),!0)},()=>h.current?.querySelector(".es-copy-colors"))},[v]),H(()=>{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]),Q(()=>{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 E=f?{run:u(l.color,f),open:v,onToggle:()=>{k(null),v?I():(e.hold(),y(!0))}}:void 0;/* @__PURE__ */
8
- return X(ne,{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__ */X("div",{ref:h,children:/* @__PURE__ */X(oe,{layout:"row",offered:s,pressed:l.marks,onMark:t=>{"link"===t?C():e.press(t)},color:E,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(_,{children:[v&&f?/* @__PURE__ */X(p,{colors:f,current:l.color,words:i.colors??m.colors,onPick:t=>e.color(t)}):null,w?
9
- /* @__PURE__ */X(re,{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 tt({element:e}){const t=W(null),n=Ge(t,()=>e(),e);/* @__PURE__ */
10
- return X("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 nt({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=Se(),I=T(We),D=S??I,E=T(be),x=g("canvas",e),O=h??E,[A,M]=q(void 0),z=Ce(e=>"node"===e.selection?.kind?e.selection.id:null),[R,B]=q(null),[L,V]=q(null),$=T(qe),[j,K]=q(null),N=W(null),[,P]=q(0),Z=W(b);Z.current=b;const F=W(null),Y=W(null),U=Ce(e=>e.appState.data);H(()=>{const e=Y.current?.ownerDocument,t=e?.defaultView?.CustomEvent;if(!e||!t)return;const n=z&&!j&&Z.current?.atSelection?.()?z:null;e.dispatchEvent(new t(y,{detail:{id:n}}))},[z,j,U]);const G=e=>{const t=Y.current?.ownerDocument,n=t?.defaultView?.CustomEvent;t&&n&&t.dispatchEvent(new n(k,{detail:{typing:e}}))},Q=(e,t)=>{N.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:_e(n,t,e.skip),write:e.write,remount:e.remount,onSelect:()=>P(e=>e+1),onEscape:()=>F.current?.escape()??!1,onLinkKey:()=>F.current?.link()??!1,end:e=>{o.close(),N.current?.element===r&&(N.current=null),K(null),G(!1),Z.current?.onChange?.({typing:!1,why:e})}});if(!i)return o.close(),!1;const l=n.closest?.(`[${De}]`)?.getAttribute(De);return l&&C.select(l),N.current={s:i,element:r,target:e},K(()=>r),B(null),G(!0),Z.current?.onChange?.({typing:!0,element:n}),!0};H(()=>()=>N.current?.s.stop("stop"),[]);const _=e=>{const t=N.current?.element();return Boolean(t&&t.contains(e))},ee=e=>{const t=e.closest?.(`[${De}]`)?.getAttribute(De);if(!t)return;const n=C.getState(),o="node"===n.selection?.kind?n.selection.id:null,r=$?.partAt(e,t)??null;if(r){const e=l(n.appState.data,C.config,t,r.id,o,$?.selected()??null,D);if(e)return{node:e.node,part:e.part?r:null}}return{node:s(n.appState.data,C.config,t,o,D)??t,part:null}},te=e=>{if("Enter"!==e.key||e.defaultPrevented||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;if(N.current)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select, button"))return;const n=Z.current?.atSelection?.();n&&Q(n,null)&&e.preventDefault()},ne=/* @__PURE__ */J("div",{ref:Y,className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;if(t.closest?.("a[href]")&&e.preventDefault(),N.current){if(_(t))return;N.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($&&(o.part?.id??null)!==$.selected()&&$.select(o.part?.id??null));t.hasAttribute?.(Ee)||(C.select(null),$?.selected()&&$.select(null))},onDoubleClick:e=>{const t=Z.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(N.current)return;const t=ee(e.target),n=t?.part&&t.part.id!==$?.selected()?t.part.element:null,o=t&&!t.part?t.node:null;o!==R&&B(o),n!==L&&V(n)},onMouseLeave:()=>{B(null),V(null)},children:[
11
- /* @__PURE__ */X(Re.Provider,{value:R,children:/* @__PURE__ */X(Te,{metadata:r})}),
12
- /* @__PURE__ */J("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
13
- /* @__PURE__ */X(Je,{id:!j&&R&&R!==z?R:null,kind:"hover",overlay:v}),$?/* @__PURE__ */X(Ue,{element:j?null:L}):null,
14
- /* @__PURE__ */X(Je,{id:j?null:z,kind:"selected",overlay:v}),j?/* @__PURE__ */X(tt,{element:j}):null]}),w]}),oe=m?/* @__PURE__ */X(m,{document:A,children:ne}):ne;H(()=>{if(A&&O)return ye(A,C)},[A,O,C]),H(()=>{if(!A)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($?.selected())return void $.select(null);const o=i(n.appState.data,C.config,n.selection);"node"===o?.kind&&C.select(o.id)};return A.addEventListener("keydown",e),()=>A.removeEventListener("keydown",e)},[A,C,$]);/* @__PURE__ */
15
- return J("div",{className:"es-canvas"+(n?` ${n}`:""),style:o,"data-easel-preview":"","data-es-typing":j?"":void 0,children:[j&&N.current?.target.toolbar?/* @__PURE__ */X(et,{s:N.current.s,element:N.current.element,toolbar:N.current.target.toolbar,label:x.textTools,keys:F}):null,t?/* @__PURE__ */X(ze,{mirrorStyles:a,onDocument:e=>{M(e??void 0),c?.(e)},height:d,title:u,nonce:p,children:oe}):/* @__PURE__ */X("div",{id:"preview-frame","data-easel-entry":"",children:oe})]})}function ot(e={}){const t=Se(),n=Ce(e=>e.appState.data);return r({...e,data:n,config:t.config,commit:(e,{select:n})=>t.run({data:e,select:n})})}function rt(){const e=Se(),n=Ce(e=>e.config),o=e.resolveCache,r=Ce(e=>e.selectedItem),i=Ce(e=>e.appState.data.root),l=r?r.props.id:"root",s=i.props??{},a=U(()=>r||{type:"root",props:s},[r,s]),c=r?n.components[r.type]:n.root,d=e.getState(),u=r?I(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=Ce(e=>!1===e.getPermissions(r?{item:r}:{root:!0}).edit),g=G(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 $(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 $({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=G((e,t)=>g({[e]:t}),[g]);return{id:l,node:a,fields:h,values:a.props,readOnly:m,onChange:v,onChangeMany:g}}export{ze as CanvasFrame,qe as CanvasPartsContext,We as CanvasPassThroughContext,Ye as CanvasSharedContext,he as DEFAULT_UI,nt as EaselCanvas,ke as EaselProvider,Te as EditDocument,ye as bindUndoKeys,ve as createEasel,Ie as createUseEasel,ie as recordsByDefault,ue as reduce,ae as uiView,Ce as useEasel,Se as useEaselApi,ot as useEaselNodeOps,rt as useSelectedFields,ce as validSelection};