efficient-easel 12.0.0 → 12.1.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 (73) hide show
  1. package/README.md +24 -0
  2. package/dist/{canvas-typing-CZ11Y5tb.d.ts → canvas-typing-CC0wA-ys.d.ts} +1 -1
  3. package/dist/{chunk-4ES5JGGX.js → chunk-3Z2MVLCD.js} +1 -1
  4. package/dist/{chunk-5NM5TPAX.js → chunk-4EI6UGGH.js} +1 -1
  5. package/dist/chunk-5AIA5VIP.js +1 -0
  6. package/dist/chunk-6OA4UXKZ.js +2 -0
  7. package/dist/{chunk-2SOOKBHH.js → chunk-BPZQ7S2Z.js} +16 -16
  8. package/dist/chunk-DWIOHQG7.js +1 -0
  9. package/dist/{chunk-WUO2GBPO.js → chunk-ENXLPJ77.js} +1 -1
  10. package/dist/chunk-FZ3Y3QTQ.js +5 -0
  11. package/dist/chunk-GYNIDJKN.js +57 -0
  12. package/dist/chunk-H5QI34FV.js +1 -0
  13. package/dist/{chunk-5QP7ZE35.js → chunk-J2JDC3EZ.js} +1 -1
  14. package/dist/{chunk-CZYR5V77.js → chunk-J54OXLQF.js} +1 -1
  15. package/dist/chunk-M4CNCPHA.js +1 -0
  16. package/dist/{chunk-FHLYUIJJ.js → chunk-NBDMTIU2.js} +2 -2
  17. package/dist/chunk-NQXFINT2.js +7 -0
  18. package/dist/chunk-NY7HHUGB.js +7 -0
  19. package/dist/{chunk-EC2I7SIY.js → chunk-O5XI3WAQ.js} +1 -1
  20. package/dist/chunk-PIND6KE7.js +1 -0
  21. package/dist/chunk-PVAIOBBE.js +13 -0
  22. package/dist/{chunk-X4VIDPKV.js → chunk-S2MMPHKD.js} +1 -1
  23. package/dist/{chunk-XY5ZHRMR.js → chunk-TLDRFVD2.js} +1 -1
  24. package/dist/chunk-WUSJ6SSF.js +5 -0
  25. package/dist/{chunk-47JTYRQC.js → chunk-ZIFDZGY7.js} +2 -2
  26. package/dist/copy/index.d.ts +4 -4
  27. package/dist/copy/index.js +18 -18
  28. package/dist/draw/client.d.ts +6 -0
  29. package/dist/draw/client.js +1 -0
  30. package/dist/draw/index.d.ts +8 -0
  31. package/dist/draw/index.js +1 -0
  32. package/dist/easel/index.d.ts +2 -2
  33. package/dist/easel/index.js +1 -1
  34. package/dist/fields/index.js +1 -1
  35. package/dist/index.js +1 -1
  36. package/dist/panel/index.js +1 -1
  37. package/dist/screen/components/AddBlockRow.js +1 -1
  38. package/dist/screen/components/AddSidePanel.js +1 -1
  39. package/dist/screen/components/MediaSidePanel.js +1 -1
  40. package/dist/screen/components/NodeContextMenu.js +1 -1
  41. package/dist/screen/components/PageEditGuardNotices.js +1 -1
  42. package/dist/screen/components/ScreenChrome.js +1 -1
  43. package/dist/screen/components/ScreenDocumentContext.js +1 -1
  44. package/dist/screen/components/ScreenMount.js +1 -1
  45. package/dist/screen/components/ScreenStoreProvider.js +1 -1
  46. package/dist/screen/components/SectionScreenShell.js +15 -15
  47. package/dist/screen/components/UiIcon.js +1 -2
  48. package/dist/screen/components/usePartBridge.js +1 -1
  49. package/dist/screen/index.js +1 -1
  50. package/dist/screen/lib/content/view-tiers.js +1 -1
  51. package/dist/screen/lib/key-scope.js +1 -1
  52. package/dist/screen/lib/puck/device-fields.js +1 -1
  53. package/dist/screen/lib/puck/preview-dom.js +1 -1
  54. package/dist/screen/lib/puck/style-clipboard.js +1 -1
  55. package/dist/screen/lib/puck/text-control-kinds.js +1 -1
  56. package/dist/screen/lib/puck/use-section-ops.js +1 -1
  57. package/dist/screen/lib/screen-parts.js +1 -1
  58. package/dist/strings/catalogue.d.ts +1 -1
  59. package/dist/strings/catalogue.js +1 -1
  60. package/dist/strings/index.d.ts +1 -1
  61. package/dist/strings/index.js +1 -1
  62. package/dist/text-styles/index.js +26 -26
  63. package/dist/{words-notpwHR2.d.ts → words-CiuKuiy0.d.ts} +1 -1
  64. package/package.json +11 -1
  65. package/dist/chunk-5R7FE4VT.js +0 -57
  66. package/dist/chunk-KE2CXEIK.js +0 -13
  67. package/dist/chunk-KR4OCYRP.js +0 -1
  68. package/dist/chunk-LZS7JZK5.js +0 -1
  69. package/dist/chunk-O3RLI7XE.js +0 -1
  70. package/dist/chunk-UX7UJPC5.js +0 -5
  71. package/dist/chunk-WDQY6JMM.js +0 -7
  72. package/dist/chunk-WP7AZDCV.js +0 -5
  73. package/dist/chunk-WY5U4XFO.js +0 -7
@@ -1,57 +0,0 @@
1
- import{markedTreeNodeId as e,revealSelectedTreeRow as n,sameSelector as t}from"./chunk-FGNR22NY.js";import{cloneNodeWithFreshIds as o}from"./chunk-2GVCAIPX.js";import{dedupeSlotChildren as r}from"./chunk-26OOWIJJ.js";import{styleClipboardOf as i}from"./chunk-LZS7JZK5.js";import{rootRowName as l,slotChildRowName as s,slotChildRenameProp as d,sectionRenameProp as c}from"./chunk-TBF5CVPA.js";import{scrollPreviewToSection as a,gotoPreviewSlide as p,scrollPreviewToTop as u}from"./chunk-4ES5JGGX.js";import{useEaselKeyTarget as f,useEaselUndoKeys as h,useEaselSaveKey as m,editorRootFocus as g}from"./chunk-5NM5TPAX.js";import{usePartBridge as y}from"./chunk-O3RLI7XE.js";import{useSectionOps as k}from"./chunk-X4VIDPKV.js";import{SlotChildActionsProvider as S}from"./chunk-KCBEE2MC.js";import{screenStorageKeys as v,DEFAULT_PANEL_W as b,clampPanelWidth as w}from"./chunk-TZIIRGVY.js";import{MediaSidePanel as x}from"./chunk-5QP7ZE35.js";import{useNodeClipboard as z,useNodeContextMenu as C}from"./chunk-EC2I7SIY.js";import{PageEditGuardNotices as I}from"./chunk-WUO2GBPO.js";import{useScreenDocument as B}from"./chunk-47JTYRQC.js";import{requestMediaPick as P}from"./chunk-KG7RJWOK.js";import{ScreenSaveIcon as N,ScreenMainButton as O}from"./chunk-W4U4SHKW.js";import{useBrowserOffline as $}from"./chunk-RKTF5XLP.js";import{heldStyle as M,styleShortcut as j}from"./chunk-V7U33NF2.js";import{AddChildRow as T}from"./chunk-5545A3PC.js";import{AddSidePanel as A}from"./chunk-UX7UJPC5.js";import{SidePanelHead as E,PanelShowStrip as L}from"./chunk-62VPYC7F.js";import{useEaselSession as R}from"./chunk-O7Q4DDJT.js";import{useScreenSaveSwitch as V,useScreenNodeKeys as F,useScreenPinned as W,useScreenDocumentLabel as H,useScreenCanvasFrame as D,useScreenInspectorPanel as J,useScreenDevices as U,useScreenPickFollowsSelection as G,useScreenLeftView as X,SELECTION_MODE as Y,sameInspectorMode as K,useScreenBridges as Z,useScreenBlockRules as q,useScreenBlockLook as _,useScreenStorageNamespace as Q,useScreenNotify as ee,useScreenCanvasHead as ne,isSlotMode as te,useScreenStyleClipboard as oe,useScreenDocumentPass as re,useScreenCanvasDrag as ie,ScreenCanvasTargetProvider as le,isPinnedFirst as se,isPinnedLast as de,screenSlotsOf as ce}from"./chunk-WP7AZDCV.js";import{ROOT_ZONE as ae,blockNodeActions as pe,TREE_MAX_DEPTH as ue,childSlotsOf as fe,slotFieldsOf as he,slotChildrenIn as me,nestsInTree as ge,newNodeId as ye}from"./chunk-PLVEGYK6.js";import{useMediaPanel as ke,usePanelPick as Se,useCancelPanelPick as ve}from"./chunk-R6WTQWAC.js";import{useEaselHost as be,useHostEscape as we}from"./chunk-U3JP4VGF.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as xe}from"./chunk-6WY6ZXJG.js";import{DEFAULT_SCREEN_WORDS as ze}from"./chunk-VVPZMWJE.js";import{EaselTopBar as Ce,TopBarRail as Ie,TopBarCluster as Be,EaselIconButton as Pe,TopBarDivider as Ne,DeviceSwitch as Oe,InspectorIconButton as $e,PanelResizeHandle as Me,MAX_PANEL_W as je,MIN_PANEL_W as Te,panelWidthVars as Ae}from"./chunk-IE55HNMA.js";import{DEFAULT_NOTICE_WORDS as Ee,DEFAULT_CHROME_WORDS as Le}from"./chunk-Z6PVRXVY.js";import{holderOf as Re,nameOrSomeone as Ve}from"./chunk-THWO5YVZ.js";import{DEFAULT_LOCK_WORDS as Fe}from"./chunk-RE4LP46F.js";import{TreeRow as We,Subtree as He,LayersTree as De,TreeGroupLabel as Je,TreeRowAction as Ue,TreeSeam as Ge}from"./chunk-4JSBIW5H.js";import{DEFAULT_TREE_WORDS as Xe}from"./chunk-K56YDHYQ.js";import{DEFAULT_NODE_MENU_WORDS as Ye}from"./chunk-WK3AFPXY.js";import{LayersIcon as Ke,MediaIcon as Ze}from"./chunk-4VJATVVR.js";import{insertSeams as qe,CanvasDragLayer as _e,CanvasInsert as Qe}from"./chunk-QFVRMARS.js";import{DEFAULT_DRAG_WORDS as en}from"./chunk-AYWN5NRH.js";import{createDragSession as nn,useTreeDrag as tn,gapToMoveIndex as on}from"./chunk-67GNT6PF.js";import{useEasel as rn,useEaselApi as ln,CanvasPassThroughContext as sn}from"./chunk-KE2CXEIK.js";import{toItemSelector as dn,useNodeOps as cn,clickPick as an}from"./chunk-ECM5F6JJ.js";import{useCanvasFrame as pn,LIST_SELECTOR as un,BLOCK_SELECTOR as fn,useCanvasEvent as hn,nodeIdAt as mn,frameRectToHost as gn,BLOCK_ATTRIBUTE as yn,drawnBox as kn}from"./chunk-ILXP5VX5.js";import{ROOT_ID as Sn,ROOT_SLOT as vn,zoneKey as bn,parseZoneKey as wn,find as xn,DataError as zn}from"./chunk-KRXQM65X.js";import{useWords as Cn}from"./chunk-MFIRYGHW.js";import{useRef as In,useMemo as Bn,useState as Pn,useEffect as Nn,useCallback as On,useLayoutEffect as $n,Fragment as Mn}from"react";import{ColoredBadge as jn,toast as Tn,groupColors as An}from"efficient-shell/ui";import{UndoIcon as En,RedoIcon as Ln,RefreshIcon as Rn,AddIcon as Vn,TrashIcon as Fn,EyeOffIcon as Wn,EyeIcon as Hn,DuplicateIcon as Dn}from"efficient-shell/icons/efficient";import{jsx as Jn,jsxs as Un,Fragment as Gn}from"react/jsx-runtime";var Xn=/* @__PURE__ */new WeakSet;function Yn(e,n,t){const o=xn(e,n,t);if(!o)return null;const r=o.path.find(e=>"root"!==e.parentId);return r?r.parentId:t}function Kn({canvas:e,tabs:n,onSelect:t}){const o=In(null),[r,i]=Pn({}),l=n.map(e=>`${e.id}:${e.below?1:0}`).join("|");return $n(()=>{const t=e?.document,r=e?.window,l=e?.frame;if(!t||!r||!l||0===n.length)return void i({});let s=0;const d=()=>{s=0;const e=o.current;if(!e)return;const d=gn(l,{left:0,top:0,width:r.innerWidth,height:r.innerHeight},e),c={};for(const o of n){const n=t.querySelector(`[${yn}="${r.CSS?.escape?r.CSS.escape(o.id):o.id}"]`),i=n?kn(n):null;if(!i||0===i.height){c[o.id]=null;continue}const s=gn(l,{left:i.left,top:i.top,width:i.width,height:i.height},e),a=s.top+s.height;if(a<d.top||s.top>d.top+d.height){c[o.id]=null;continue}const p=o.below?a+4:Math.max(s.top,d.top)+6;c[o.id]={left:Math.max(s.left,d.left)+6,top:p}}i(c)},c=()=>{s||(s=r.requestAnimationFrame(d))};d(),r.addEventListener("scroll",c,!0),r.addEventListener("resize",c);const a=new r.MutationObserver(c);return a.observe(t.body,{childList:!0,subtree:!0,attributes:!0}),()=>{s&&r.cancelAnimationFrame(s),r.removeEventListener("scroll",c,!0),r.removeEventListener("resize",c),a.disconnect()}},[e,l]),/* @__PURE__ */Jn("div",{ref:o,className:"es-band-tabs","aria-hidden":"true",children:n.map(e=>{const n=r[e.id];return n?/* @__PURE__ */Jn("span",{className:"es-band-tab","data-band-tab":e.id,style:{left:n.left,top:n.top},onClick:n=>{n.stopPropagation(),t(e.id)},children:/* @__PURE__ */Jn(jn,{colorClass:An("info","solid"),size:"sm",children:e.label})},e.id):null})})}function Zn({expand:e}){/* @__PURE__ */
2
- return Jn("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round",children:/* @__PURE__ */Un(Gn,e?{children:[
3
- /* @__PURE__ */Jn("path",{d:"M8 9l4-4 4 4"}),
4
- /* @__PURE__ */Jn("path",{d:"M8 15l4 4 4-4"})]}:{children:[
5
- /* @__PURE__ */Jn("path",{d:"M8 4l4 4 4-4"}),
6
- /* @__PURE__ */Jn("path",{d:"M8 20l4-4 4 4"}),
7
- /* @__PURE__ */Jn("path",{d:"M5 12h14"})]})})}var qn=`${un}, ${fn}`;function _n(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 Qn="__rungs";var et="screen:band",nt={duplicate:!0,delete:!0};function tt(){const un=be(),{target:gn,docId:yn,capabilities:kn,currentSlug:An,siteId:tt,onPublish:ot,saveState:rt,saveConflict:it,retrySave:lt,toggleAutoSave:st,flushSave:dt,access:ct,saveUnreachable:at=!1,readOnly:pt,readOnlyReason:ut=null}=B(),ft=V(),ht=F(),{mediaEditing:mt,hasEditGuard:gt,hasPinnedChrome:yt}=kn,{appState:kt,dispatch:St,history:vt,selectedItem:bt,getSelectorForId:wt,config:xt}=rn(e=>e),zt=W(),{first:Ct,firstGroup:It,lastGroup:Bt,isSectionGroup:Pt,sectionGroupZone:Nt,panelOf:Ot}=zt,$t=Ot(Ct),Mt=e=>se(zt,e),jt=e=>de(zt,e),Tt="node"===zt.firstRow,At=zt.band??null,Et=Cn("screen",ze),Lt=Cn("tree",Xe),Rt=Cn("drag",en),Vt=Cn("notice",Ee),Ft=Cn("lock",Fe),Wt=Cn("menu",Ye),Ht=Cn("styleClipboard",xe),Dt=Cn("chrome",Le),Jt=H()??`/${An}`,Ut=D(),Gt=J(),Xt=k({readOnly:pt}),Yt=k({readOnly:pt,foldIntoHistory:!0}),Kt=In(null),Zt=ln(),qt=Bn(()=>({...Xt,select:e=>{Kt.current=e,Xt.select(e)},commitDocument:(e,n)=>{if(void 0!==n){const t=Zt.config;Kt.current=dn(e,t,n)}Xt.commitDocument(e,n)}}),[Xt,Zt]),_t=kt.ui,Qt=_t.leftSideBarVisible,eo=_t.rightSideBarVisible,{options:no,widths:to,initial:oo,fluid:ro,fit:io}=U(),[lo,so]=Pn(oo),co=ke(),ao=mt&&null!==co,po=Se(),uo=ve();G(bt?.props.id);const{read:fo,write:ho,forSelection:mo}=X(),[go,yo]=Pn(fo);Nn(()=>{ho(go)},[go]);const[ko,So]=Pn(0),vo=In(null),bo=In(null),wo=pn(bo,{readySelector:qn}),xo=f(bo);h(bo,wo);const zo=$(),Co=Re(ct),Io={state:rt,offline:zo||rt.failed&&at,readOnlyReason:ut,editing:Co?Vt.editing({name:Ve(Co.name,Ft),noun:Et.noun}):null,conflict:null!=it,notSaving:Et.bar.notSaving},Bo=()=>{pt||(rt.failed?lt():dt())};m(bo,wo,Bo);const[Po,No]=Pn(!1),Oo=In(!1),$o=In(!1),[Mo,jo]=Pn(null),[To,Ao]=Pn([]),[Eo,Lo]=Pn(Y),Ro="puck"===Eo.kind,Vo=e(Eo,bt?.props.id),[Fo,Wo]=Pn(null);Nn(()=>{Fo&&(n(),Wo(null))},[Fo]);const Ho=In(wt);Ho.current=wt;const Do=On((e,{scroll:n})=>{yo(n=>mo(e,n)),n&&Wo(e);const t=[];let o=e;for(let e=0;e<4;e++){const e=Ho.current(o)?.zone;if(!e||!e.includes(":"))break;const n=e.split(":")[0];t.push(n),t.push(e),o=n}0!==t.length&&Sr(e=>{if(t.every(n=>!e.has(n)))return e;const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},[]),Jo=In(null);Nn(()=>{const e=Jo.current;Jo.current=null;const n=null==bt?.props.id?null:String(bt.props.id);Lo(t=>e&&e.id===n?e.mode:"part"===t.kind&&"nodeId"in t&&t.nodeId===n?t:Ot(bt?.type)??Y);const o=bt?.props.id,r=Kt.current;if(Kt.current=null,!o)return;const i=wt(o);Do(String(o),{scroll:!t(r,i??null,ae)})},[bt?.props.id,Do]);const Uo=On(e=>{Lo(n=>K(n,e)?n:e),St({type:"setUi",ui:{rightSideBarVisible:!0}})},[St]),Go=In(()=>{});Go.current=(e,n)=>{const t=e?ui(e.zone??ae)[e.index]?.props.id:null,o=null==t?null:String(t),r=null==bt?.props.id?null:String(bt.props.id);Lo(e=>K(e,n)?e:n),o!==r&&(Jo.current={id:o,mode:n},qt.select(e))};const Xo=On((e,n)=>Go.current(e,n),[]),Yo={kind:Eo.kind,mode:Eo,open:Uo,show:e=>Lo(e),reveal:()=>{eo||St({type:"setUi",ui:{rightSideBarVisible:!0}})},select:Xo},Ko=Z(Yo,{data:kt.data,selected:bt??null,zoneOf:e=>wt(e)?.zone,readOnly:Boolean(pt),select:e=>{Lo(Y),qt.select({index:e})},replace:(e,n)=>qt.replaceComponent(ae,e,n),scrollTo:e=>Li(e)},{device:lo,refreshes:ko},{setView:yo,reveal:()=>{Qt||St({type:"setUi",ui:{leftSideBarVisible:!0}})}}),Zo=Ko.pinnedSource??!1,qo=Ko.resolveLeftView?Ko.resolveLeftView(go,ao):"media"===go&&ao?go:"sections",_o=q(),{isLockedBlock:Qo,duplicateBlocked:er,nestDepth:nr,newSectionNode:tr,canAddTo:or,blockIsOffered:rr}=_o,ir=_(),{labelAtLevel:lr,Icon:sr,useProducts:dr}=ir,cr=ir.rowName?(e,n,t)=>ir.rowName(e,n,t):void 0,ar=On(e=>{St({type:"setUi",ui:{rightSideBarVisible:!0}}),a(e),Do(e,{scroll:!0})},[St,Do]),{selectNode:pr,openPartId:ur}=y({mode:Eo,setMode:Lo,onOpenPart:ar}),[fr,hr]=Pn(null);we(null!==fr,()=>hr(null));const mr=v(Q()),gr=mr.collapsed,yr=mr.panelWidths,[kr,Sr]=Pn(()=>{if("undefined"==typeof window)/* @__PURE__ */return new Set;try{const e=window.localStorage.getItem(gr);return new Set(e?JSON.parse(e):[])}catch{/* @__PURE__ */
8
- return new Set}});Nn(()=>{try{window.localStorage.setItem(gr,JSON.stringify([...kr]))}catch{}},[kr]);const[vr,br]=Pn(()=>{if("undefined"==typeof window)return{...b};try{const e=window.localStorage.getItem(yr);if(!e)return{...b};const n=JSON.parse(e);return{left:w(Number(n.left)||b.left),right:w(Number(n.right)||b.right)}}catch{return{...b}}});Nn(()=>{const e=setTimeout(()=>{try{window.localStorage.setItem(yr,JSON.stringify(vr))}catch{}},300);return()=>clearTimeout(e)},[vr]);const wr=On((e,n)=>br(t=>{const o="function"==typeof n?n(t[e]):n;return t[e]===o?t:{...t,[e]:o}}),[]),xr=On(e=>wr("left",e),[wr]),zr=On(e=>wr("right",e),[wr]),Cr=e=>kr.has(e),Ir=e=>Sr(n=>{const t=new Set(n);return t.has(e)?t.delete(e):t.add(e),t}),Br=In(!1),Pr=In(null);Nn(()=>{if(Br.current&&!Po){const e=Pr.current,n=e&&e.isConnected&&!e.closest('[aria-hidden="true"]')?e:null;(n??bo.current?.querySelector(`button[aria-label="${CSS.escape(Et.add.title)}"]`))?.focus(),Pr.current=null}Br.current=Po},[Po]),Nn(()=>{if(!Po||!xo)return;const e=e=>{"Escape"===e.key&&Ui()};return xo.addEventListener("keydown",e),()=>xo.removeEventListener("keydown",e)},[Po,xo]),we(Po,()=>Ui()),Nn(()=>{!Qt&&Po&&(No(!1),jo(null),Oo.current=!1)},[Qt]),Nn(()=>{if(!po)return $o.current&&St({type:"setUi",ui:{leftSideBarVisible:!1}}),void($o.current=!1);Po&&(No(!1),jo(null),$o.current=Oo.current,Oo.current=!1),Qt||($o.current=!0,St({type:"setUi",ui:{leftSideBarVisible:!0}}))},[po]),Nn(()=>{!Qt&&po&&($o.current=!1,uo())},[Qt]),Nn(()=>{if(!po||!xo)return;const e=e=>{"Escape"===e.key&&uo()};return xo.addEventListener("keydown",e),()=>xo.removeEventListener("keydown",e)},[po,xo]),we(null!==po,()=>uo());const Nr=ee(),Or=(e,n="success",t)=>{if(Nr)return void(t?Nr(e,"error"===n?"error":"info",t):Nr(e,"error"===n?"error":"info"));const o={sound:!1,action:t?.action,onClose:t?.onClose};"error"===n?Tn.error(e,{...o,duration:t?.duration??3200}):Tn.success(e,{...o,duration:t?.duration??1900})},$r=In(null),[Mr,jr]=Pn(0),[Tr,Ar]=Pn(0),Er=ne(),Lr=In(null),Rr=e=>Math.max(0,e.clientHeight-(Lr.current?.offsetHeight??0));Nn(()=>{const e=$r.current;if(!e)return;const n=()=>{jr(e.clientWidth),Ar(Rr(e))};n();const t=new ResizeObserver(n);return t.observe(e),Lr.current&&t.observe(Lr.current),()=>t.disconnect()},[]),$n(()=>{$r.current&&(jr($r.current.clientWidth),Ar(Rr($r.current)))},[vr,Qt,eo]);const Vr=lo===ro?Mr>0?Mr:to[ro]:to[lo],Fr=Mr>0?Math.min(Mr/Vr,"shrink"===io?1:2):1,Wr=Vr*Fr,Hr=Mr>0&&Wr>Mr+1,Dr={width:Wr,height:Tr||"100%",flex:"none",position:"relative"},Jr={width:Vr,height:Tr?Tr/Fr:"100%",maxHeight:"none",transform:1!==Fr?`scale(${Fr})`:void 0,transformOrigin:"top left"},Ur=()=>St({type:"setUi",ui:{leftSideBarVisible:!Qt}}),Gr=()=>St({type:"setUi",ui:{rightSideBarVisible:!eo}}),Xr=e=>{Po&&(No(!1),jo(null),Oo.current=!1,Qt&&go===e)||po&&($o.current=!1,uo(),Qt&&go===e)||(Qt&&go===e?Ur():(yo(e),Qt||St({type:"setUi",ui:{leftSideBarVisible:!0}})))},Yr=()=>{P(un,{accept:"image/*",title:Dt.mediaLibrary})},Kr=()=>{Lo(Y),qt.select(null),u()},Zr=()=>{Lo($t??Y),eo||St({type:"setUi",ui:{rightSideBarVisible:!0}})},qr=kt.data.content??[],_r=()=>{const e=qr.findIndex(Mt),n=qr.findIndex(jt);return{floor:e>=0?e+1:0,cap:n>=0?n:qr.length}},Qr=xt,ei=_o.stripCopy,ni=e=>o(e,ei),ti=z(),oi=cn({data:kt.data,config:Qr,readOnly:Boolean(pt),clipboard:ti,strip:ei?e=>ei(e):void 0,afterRemove:"none",stepBounds:(e,n)=>{if(e.parentId!==Sn||e.slot!==vn)return{min:0,max:n-1};const{floor:t,cap:o}=_r();return{min:t,max:o-1}},commit:(e,{select:n})=>{void 0!==n&&Lo(Y);const t=void 0===n||"node"===n?.kind?n:null;qt.commitDocument(e,t)}}),ri=e=>{const n=xn(kt.data,xt,e);if(!n)return!1;const t=bn(n.place),o=n.node,r=t===ae?ci(o):xi(o);return!!oi.remove(e)&&(Or(Et.deleted({name:r}),"success",{duration:8e3,action:{label:Et.bar.undo,onClick:()=>{oi.restore(n.node,n.place)}}}),!0)},ii={...oi,remove:ri},li=e=>lr(e,"block",xt.components[e]?.label??e),si=On(e=>xt.components[e]?.defaultProps??{},[xt]),di=e=>lr(e,"section",li(e)),ci=e=>l({type:e.type,props:e.props??{}},di(e.type),cr),{nodeAddresses:ai,zoneItems:pi}=Bn(()=>{const e=/* @__PURE__ */new Map,n=/* @__PURE__ */new Map,t=(o,r,i)=>{n.set(r,o),o.forEach((n,o)=>{const l=String(n.props?.id??"");if(l&&e.set(l,{zone:r,index:o}),i>=ue)return;const s=/* @__PURE__ */new Map;for(const{child:e,zone:t}of fe(xt,n))s.set(t,[...s.get(t)??[],e]);for(const[e,n]of s)t(n,e,i+1)})};return t(qr,ae,0),{nodeAddresses:e,zoneItems:n}},[qr,xt]),ui=On(e=>pi.get(e)??[],[pi]),fi=e=>{const n=ai.get(e);return n?ui(n.zone)[n.index]:void 0},hi=e=>ce(_o,xt,e),mi=e=>{if(!_o.slotsOf||e===ae)return null;const n=e.lastIndexOf(":");if(n<=0)return null;const t=fi(e.slice(0,n));if(!t)return null;const o=hi(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}},gi=(()=>{if(!te(Eo))return null;const e=`${Eo.nodeId}:${Eo.slot}`;return mi(e)?.slot.panel===Eo.kind?e:null})(),yi=In(null);Nn(()=>{const e=yi.current;if(yi.current=null,!gi||!te(Eo))return;const n=Eo.nodeId;Do(n,{scroll:e!==gi}),Sr(e=>{if(!e.has(n))return e;const t=new Set(e);return t.delete(n),t})},[Eo]);const ki=(e,n,t)=>{const o=String(e.props.id);if(!n.panel)return void(e=>{const n=ai.get(e);n&&(n.zone===ae?Ri(n.index):ul(n.zone,n.index,e,fi(n.zone.slice(0,n.zone.lastIndexOf(":")))?.type??""))})(o);const r={kind:n.panel,nodeId:o,slot:n.slot},i=`${o}:${n.slot}`;t&&gi!==i&&(yi.current=i),Xo(null,r),eo||St({type:"setUi",ui:{rightSideBarVisible:!0}}),Li(o)},Si=(e,n,t)=>{const o=`${e}:${n}`;if(Sr(n=>{if(!n.has(o)&&!n.has(e))return n;const t=new Set(n);return t.delete(o),t.delete(e),t}),!t)return;gi!==o&&(yi.current=o);Xo(null,{kind:t,nodeId:e,slot:n})},vi=(e,n,t)=>{if(pt||!_o.moveSlot)return;const o=fi(e),r=o?hi(o).filter(e=>e.rung):[],i=r[n];if(!i)return;const l={parentId:e,slot:Qn,index:n},s=on(l,{...l,index:Math.min(Math.max(t,0),r.length)});if(s===n)return;const d=_o.moveSlot(e,n,s);"string"==typeof d&&Si(e,d,i.panel)},bi=dr(),wi=Bn(()=>{const e=/* @__PURE__ */new Map;for(const n of bi??[])e.set(n.slug,n.name);return e},[bi]),xi=e=>s(e,li,ir.plainText,e=>wi.get(e),ir.rowName),zi=(e,n)=>{const t=xt.components[e.type]?.fields,o=n===ae||jl(n)?"section":"block",r=n===ae&&(Mt(e)||jt(e)||Pt(e.type)),i="block"===o?d(t):r?null:c(t);return ir.renamePropOf?ir.renamePropOf(e,o,i):i},Ci=(e,n,t,o)=>{if(!(!pt&&fr?.zone===e&&fr.index===n))return;const r=(t,o)=>{hr(null),o&&((e,n,t)=>{const o=ui(e)[n];if(!o)return;const r=zi(o,e);r&&qt.replaceComponent(e,n,{...o,props:{...o.props,[r]:t.trim()}})})(e,n,t)};/* @__PURE__ */
9
- return Jn("input",{className:"es-tree-rename",defaultValue:o,autoFocus:!0,"aria-label":Et.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)},Ii=i(oe(),Ht),Bi=Ii.scope({target:gn,siteId:tt,docId:yn}),Pi=xt,Ni=(e,n)=>n===ae?di(e):li(e),Oi=(e,n,t)=>{const o=Ii.plan(Bi,t,Ni(t.type,e),Pi);o&&(o.changed&&qt.replaceComponent(e,n,{...t,props:{...o.props,id:t.props.id}}),Or(o.message))},$i=C({nodesIn:ui,nodeAt:(e,n)=>ui(e)[n]??null,labelOf:(e,n)=>n===ae?di(e):li(e),renamePropOf:zi,beginRename:(e,n)=>hr({zone:e,index:n}),history:{hasPast:vt.hasPast,hasFuture:vt.hasFuture,back:()=>vt.back(),forward:()=>vt.forward()},openPageSettings:()=>{qt.select(null),Lo(Y)},pageSettingsLabel:Et.pageSettings,words:{menu:Wt,styleClipboard:Ht,screen:Et.menu},readOnly:Boolean(pt),collapseAll:()=>Sr(new Set(ui(ae).map(e=>String(e.props.id)))),onPasteRefused:e=>Or(e?Et.pasteRefused({name:e.label}):Et.menu.clipboardRefused,"error"),canPasteAt:(e,n)=>El(e,n),menuRows:Ko.menuRows,isLocked:e=>Qo(e.type),duplicateBlocked:e=>er(kt.data,e),permits:e=>pe(xt,e.type),nodeOps:ii,isPinned:(e,n)=>n===ae&&(Mt(e)||jt(e)),sectionBand:_r,locate:e=>ai.get(e)??null,rowNameOf:(e,n)=>n===ae?ci(e):xi(e),selectAt:(e,n,t,o)=>{e===ae?Ri(n):ul(e,n,t,o??"")},slotRung:e=>{const n=mi(e);return n?.slot.panel?{label:n.slot.label,select:()=>ki(n.node,n.slot,!1)}:null},style:{held:()=>M(Bi),canCopy:e=>Ii.rows(Pi,e).some(e=>!1!==e.counted),copy:(e,n)=>Ii.copy(Bi,e,Ni(e.type,n),Pi),paste:(e,n,t)=>Oi(e,n,t)},keys:ht?{target:xo,selected:()=>{const e=kt.ui.itemSelector;return e?{zone:e.zone??ae,index:e.index}:null},held:()=>ti.get(),readOnly:Boolean(pt),onDone:({done:e,name:n})=>{"copied"===e&&Or(Et.copied({name:n}))}}:void 0},wo),Mi=In({copy:(e,n)=>{},paste:(e,n,t)=>{},at:()=>null,readOnly:!1});Nn(()=>{Mi.current={copy:(e,n)=>Ii.copy(Bi,e,Ni(e.type,n),Pi),paste:Oi,at:()=>{const e=kt.ui.itemSelector;if(!e)return null;const n=e.zone??ae,t=ui(n)[e.index];return t?{zone:n,index:e.index,node:t}:null},readOnly:Boolean(pt)}});const ji=On(e=>{const n=j(e);if(!n)return;const t=Mi.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))},[]);Nn(()=>{if(!xo)return;const e=e=>ji(e);return xo.addEventListener("keydown",e),()=>xo.removeEventListener("keydown",e)},[ji,xo]),hn(wo,"keydown",ji);const Ti=qr.map(e=>e.props.id).join("|");Nn(()=>{const e=wo?.document??null,n=wo?.window??null;let t=0;const o=[],r=()=>{if(!e)return void Ao(e=>e.length?[]:e);const n=qr.findIndex(jt),t=n>=0?n:qr.length,o=n=>{const t=qr[n]?.props?.id;return null==t?null:e.querySelector(`[data-puck-component="${CSS.escape(String(t))}"]`)},r=e=>e?[...e.querySelectorAll(fn)].map(e=>e.getBoundingClientRect()).filter(e=>e.width>0||e.height>0):[],i=[];for(let e=qr.length>0&&!Mt(qr[0])?0:1;e<=t;e++){const n=o(e),t=o(e-1),l=n?.getBoundingClientRect()??null,s=t?.getBoundingClientRect()??null;if(!l&&!s)continue;const d=_n(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})}Ao(e=>function(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t].top!==n[t].top||e[t].index!==n[t].index||e[t].height!==n[t].height)return!1;return!0}(e,i)?e:i)},i=()=>{cancelAnimationFrame(t),t=requestAnimationFrame(r)};if(!e||!n)return void r();n.addEventListener("scroll",i,{passive:!0});const l=new ResizeObserver(i);return l.observe(e.documentElement),r(),o.push(setTimeout(r,150),setTimeout(r,450)),()=>{cancelAnimationFrame(t),o.forEach(clearTimeout),n.removeEventListener("scroll",i),l.disconnect()}},[wo,Ti,lo,Fr,Qt,eo,bt?.props.id]);const Ai=wo?.document??null,Ei=wo?.window??null;Nn(()=>{const e=vo.current;if(!e||!Ai||!Ei)return;const n=[],t=()=>{const n=Ai.querySelector(`[data-puck-component="${CSS.escape(e.id)}"]`);if(!n)return!1;const t=n.getBoundingClientRect().top-e.offset;return Math.abs(t)>1&&Ei.scrollTo({left:Ei.scrollX,top:Ei.scrollY+t,behavior:"instant"}),!0};return vo.current=null,t()&&n.push(setTimeout(t,150),setTimeout(t,450)),()=>n.forEach(clearTimeout)},[Ai,Ei]);const Li=e=>{Ko.holdCanvasOn?Ko.holdCanvasOn(e):a(e)},Ri=e=>{Lo(Y),qt.select({index:e}),Ko.sectionPressed?.(qr[e]);const n=qr[e]?.props?.id;n&&Li(n)},Vi=e=>{const{floor:n,cap:t}=_r(),o=e=>Math.min(Math.max(n,e),t);if("number"==typeof e)return o(e);const r=bt&&Eo.kind!==$t?.kind?qr.findIndex(e=>e.props.id===bt.props.id):-1;return o(r>=0?r+1:t)},Fi=(e,n)=>{const{floor:t,cap:o}=_r(),r=Math.min(Math.max(n,t),o),i=e<r?r-1:r;return i===e?{moved:!1,dest:e}:(qt.reorderComponent(ae,e,i),qt.select({index:i}),{moved:!0,dest:i})},Wi=(e,n,t,o)=>{Lo(Y),qt.select(o?{index:o.index,zone:o.zone}:{index:e}),a(n),Or(Et.sectionAdded({name:t}))},Hi=(e,n)=>{const t=Vi(n),o=tr(e,{nodeDefaults:si,newNodeId:ye,sectionLabel:di,blockIsOffered:rr}),r=o?qt.insertNode(ae,t,o):qt.insertSection(e,t);return Wi(t,r,di(e),o?((e,n,t)=>{if(e.type===t)return null;const o={at:null},r=(e,n,i)=>{const l=i.filter(n=>n===e.type).length;for(const{child:s,zone:d,index:c}of fe(xt,e)){if(s.type===t&&(!o.at||n>o.at.depth)){const r=or(e.type,l,d.slice(d.lastIndexOf(":")+1)),i=r?.choices??(r?.spec?[{type:r.spec.childType,label:r.spec.childType}]:[]);null!==r&&"footer"!==r.source&&`${e.props.id}:${r.slot}`===d&&i.some(e=>e.type===t)&&(o.at={zone:d,index:c,depth:n})}r(s,n+1,[...i,e.type])}};return r({type:e.type,props:{...e.props,id:n}},1,[]),o.at?{zone:o.at.zone,index:o.at.index}:null})(o,r,e):null),t},Di=e=>Ji(ae,e),Ji=(e,n)=>{Pr.current=document.activeElement??null,po&&(Oo.current=$o.current,$o.current=!1,uo()),jo(null===n?null:{zone:e,index:n}),No(!0),Qt||(Oo.current=!0,St({type:"setUi",ui:{leftSideBarVisible:!0}}))},Ui=()=>{No(!1),jo(null),Oo.current&&St({type:"setUi",ui:{leftSideBarVisible:!1}}),Oo.current=!1},Gi=(e,n)=>ir.rowName?n?Mt(e)?ir.rowName(e,"section",Et.header):jt(e)?ir.rowName(e,"section",Et.footer):Pt(e.type)?ir.rowName(e,"section",li(e.type)):ci(e):xi(e):n?di(e.type):li(e.type),Xi=e=>n=>{e()},Yi=()=>Ko.editPinnedSource?.(),Ki=(e,n,t)=>{if(pt)return null;const o=ui(e)[n];return o&&!pe(xt,o.type).delete?null:/* @__PURE__ */Jn(Ue,{kind:"delete",label:Et.deleteNamed({name:t}),onClick:()=>((e,n)=>{const t=ui(e)[n]?.props?.id;null!=t&&ri(String(t))})(e,n),children:/* @__PURE__ */Jn(Fn,{size:15})})},Zi=e=>ir.rowPreview?.(e)||void 0,qi=e=>ir.rowMarks?.(e)??void 0,_i=(e,n,t)=>ir.rowActions?.(e,n,t)??null,Qi=(e,n,t,o)=>{if(pt)return null;const r=Boolean(t.props._hidden);/* @__PURE__ */
10
- return Jn(Ue,{kind:"eye",label:r?Et.showNamed({name:o}):Et.hideNamed({name:o}),onClick:()=>nl(e,n,t),children:/* @__PURE__ */Jn(r?Wn:Hn,{size:14,strokeWidth:1.8,strokeLinecap:void 0,strokeLinejoin:void 0})})},el=e=>fs(ae,e),nl=(e,n,t)=>{qt.replaceComponent(e,n,{...t,props:{...t.props,_hidden:!t.props._hidden}})},tl=e=>he(xt,e),ol=e=>fe(xt,e),rl=e=>_o.slotsOf?hi(e).map(n=>({slot:n.slot,rung:n.rung?n:null,kids:me(e,n.slot)})):[{slot:null,rung:null,kids:ol(e)}],il=e=>_o.slotsOf?rl(e).flatMap(e=>e.kids):ol(e),ll=e=>Boolean(_o.slotsOf)&&hi(e).some(e=>e.rung),sl=(e,n,t)=>null===t?void 0===n?or(e):or(e,n):or(e,n,t),dl=(e,n,t)=>{const o=ge(xt,e.type,n)&&(t||il(e).length>0||ll(e));return{collapsible:o,folded:o&&Cr(String(e.props.id))}},cl=(e,n,t)=>rl(e).flatMap(o=>{const r=o.rung?n+1:n,i=o.kids.flatMap(({child:e})=>dl(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}),al=e=>il(e).length>0||ll(e)||Boolean(or(e.type)),pl=e=>Boolean(or(e)),ul=(e,n,t,o)=>{if(Lo(Y),or(o)?.spec?.slider){const t=e.split(":")[0];p(t,n),qt.select({index:n,zone:e}),a(t)}else qt.select({index:n,zone:e}),Li(t)},fl=(e,n,t,o,r)=>{const i=`${e}:${n}`;qt.insertComponent(i,t,o),or(r)?.spec?.slider?requestAnimationFrame(()=>{p(e,o),qt.select({index:o,zone:i})}):qt.select({index:o,zone:i})},hl=In(/* @__PURE__ */new Set);Nn(()=>{qr.forEach(e=>{const n=or(e.type)?.spec;if(!n)return;const t=e.props.id;if(hl.current.has(t))return;hl.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(si)).forEach((e,t)=>Yt.seedChild(o,t,n.childType,e))})},[qr,Yt,si]);const ml=In(/* @__PURE__ */new Set);Nn(()=>{qr.forEach((e,n)=>{const t=e.props.id;if(ml.current.has(t))return;const o=r(e,tl(e.type));ml.current.add(t),o&&Yt.replaceComponent(ae,n,{...e,props:o})})},[qr,Yt]),re(Yt,xt);const gl=qr.findIndex(jt),yl=gl>=0?qr[gl]:null,kl=Tt?qr.findIndex(Mt):-1,Sl=kl>=0?qr[kl]:null,vl=zt.groupTab,bl=Bn(()=>vl?e=>Pt(e.type):void 0,[vl]),wl=Boolean(zt.groupBadge),xl=zt.groupBadge?/* @__PURE__ */Jn("span",{className:"es-tree-group-badge",children:/* @__PURE__ */Jn(jn,{tone:"info",size:"xs",children:zt.groupBadge})}):void 0,zl=qr.find(e=>e.type===It)??null,Cl=qr.find(e=>e.type===Bt)??null,Il=gl>=0?gl:qr.length,Bl=[];qr.forEach(e=>{jt(e)||(al(e)&&Bl.push(String(e.props.id)),Bl.push(...cl(e,1,pl)))}),yl&&(Bl.push(String(yl.props.id)),Bl.push(...cl(yl,1,pl)));const Pl=Bl.length>0&&Bl.every(e=>kr.has(e)),Nl=e=>{const n=ir.blockRowName(e,li);return ir.rowName?ir.rowName(e,"block",n):n},Ol=(e,n,t,o)=>{const r=ui(e)[t];if(!r)return;const i={...wn(e),index:t},l={...wn(n),index:Math.min(Math.max(o,0),ui(n).length)},s=on(i,l);if(e!==n||s!==t)try{oi.move(String(r.props.id),{...l,index:s})}catch(e){if(!(e instanceof zn))throw e}},$l=e=>{const n=/* @__PURE__ */new Set,t=e=>{for(const{child:o,zone:r}of ol(e))n.add(r),t(o)};for(const t of tl(e.type))n.add(`${e.props.id}:${t}`);return t(e),n},Ml=e=>{let n=e.slice(0,e.indexOf(":"));for(let e=0;e<64;e++){const e=ai.get(n);if(!e)return null;if(e.zone===ae)return n;n=e.zone.slice(0,e.zone.indexOf(":"))}return null},jl=e=>{const n=e.slice(0,e.indexOf(":")),t=qr.find(e=>Pt(e.type)&&String(e.props.id)===n);return t&&Nt(n)===e?t:null},Tl=(e,n)=>{const t=jl(e);return!t||(!zt.groupAccepts||zt.groupAccepts(t.type,n,ui(e).length))},Al=(e,n,t)=>{if(e.rung){const t=fi(e.rung.nodeId),o=t?hi(t).filter(e=>e.rung).length:0;return n.parentId===e.rung.nodeId&&n.slot===Qn&&n.index>=0&&n.index<=o}if(n.slot===Qn)return!1;if(e.add)return Vl(e.add,n);const o=bn(n);if(Pt(e.type))return!1;const r=jl(o),i=jl(e.zone);if(r||i)return!(!r||!i)&&(!(r!==i&&!Tl(o,e.type))&&(n.index>=0&&n.index<=ui(o).length));if(e.zone===ae||o===ae){if(e.zone!==o)return!1;const{floor:t,cap:r}=_r();return n.index>=t&&n.index<=r}if(n.index<0||n.index>ui(o).length)return!1;if(e.zone===o)return!0;const l=yl&&!zt.lastIsOpen?String(yl.props.id):null;return(!l||Ml(e.zone)!==l&&Ml(o)!==l)&&((e,n,t,o)=>{if(e===n)return!0;const r=o??ui(e)[t];if(!r)return!1;const i=n.split(":")[0],l=ai.get(i),s=l?ui(l.zone)[l.index]:void 0;if(!s)return!1;if(!o&&$l(r).has(n))return!1;const d=or(s.type,nr(kt?.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?.(ui(n),r))})(e.zone,o,e.index,t)},El=(e,n)=>{const t=bn(e.from),o=e.node;return t===bn(n)?Tl(t,o.type):Al({id:String(o.props?.id??""),zone:t,index:-1,type:o.type},n,o)},Ll=e=>{const n=e.slice(0,e.indexOf(":")),t=ai.get(n),o=t?ui(t.zone)[t.index]:void 0;if(!t||!o)return null;const r=or(o.type,nr(kt?.data,o.type,n),e.slice(e.lastIndexOf(":")+1));if(!r||`${n}:${r.slot}`!==e)return null;if("footer"===r.source)return null;const i=r.choices??(r.spec?[{type:r.spec.childType,label:li(r.spec.childType)}]:[]),l=mi(e);return{parent:o,parentId:n,target:r,choices:i,parentName:l?l.slot.label:Gi(o,t.zone===ae)}},Rl=(e,n)=>{if("section"!==e.kind)return e;const t=bn(n);return t===ae||jl(t)?e:Ll(t)?.choices.some(n=>n.type===e.type)?{kind:"block",type:e.type}:e},Vl=(e,n)=>{const t=Rl(e,n),o=bn(n);if("block"!==t.kind){if(jl(o)){const e="section"===t.kind?t.type:t.template.node.type;return Tl(o,e)&&n.index>=0&&n.index<=ui(o).length}if(o!==ae)return!1;const{floor:e,cap:r}=_r();return n.index>=e&&n.index<=r}if(o===ae)return!1;const r=Ll(o);return!(!r||!r.choices.some(e=>e.type===t.type))&&!r.target.spec?.addBlocked?.(ui(o))},Fl=(e,n)=>{const t=Rl(e,n);if("block"!==t.kind&&jl(bn(n)))return void((e,n,t)=>{const o="section"===e.kind?e.type:"template"===e.kind?e.template.node.type:null;if(o&&Tl(n,o)){if("section"===e.kind)qt.insertComponent(n,e.type,t);else{if("template"!==e.kind)return;qt.insertNode(n,t,ni(e.template.node))}Lo(Y),qt.select({index:t,zone:n})}})(t,bn(n),n.index);if("section"===t.kind)return void Hi(t.type,n.index);if("template"===t.kind)return void((e,n,t)=>{const o=Vi(t),r=qt.insertNode(ae,o,n);Wi(o,r,e)})(t.template.name,ni(t.template.node),n.index);const o=bn(n),r=Ll(o);r&&(r.target.spec?fl(r.parentId,r.target.slot,t.type,n.index,r.parent.type):((e,n,t)=>{qt.insertComponent(e,n,t),Lo(Y),qt.select({index:t,zone:e})})(o,t.type,n.index))},Wl=(e,n)=>{e.rung?vi(e.rung.nodeId,e.index,n.index):e.add?Fl(e.add,n):e.zone===ae?Fi(e.index,n.index):Ol(e.zone,bn(n),e.index,n.index)},[Hl]=Pn(()=>nn()),Dl=tn({keyOf:e=>e.id,readOnly:Boolean(pt),session:Hl,canDrop:Al,onDrop:Wl,onStep:(e,n)=>{e.rung?vi(e.rung.nodeId,e.index,n<0?e.index-1:e.index+2):e.zone===ae?((e,n)=>{const t=di(qr[e]?.type??""),o=Fi(e,n<0?e-1:e+2);if(!o.moved)return void Or(n<0?Et.sectionFirst({name:t}):Et.sectionLast({name:t}));const{floor:r,cap:i}=_r();Or(Et.sectionMoved({name:t,n:o.dest-r+1,total:i-r}))})(e.index,n):Ol(e.zone,e.zone,e.index,n<0?e.index-1:e.index+2)}}),Jl=On(e=>{const{floor:n,cap:t}=_r(),o=[];for(const r of e.nodes){const e=bn(r.place),i=ui(e)[r.place.index];if(!i||String(i.props.id)!==r.id)continue;if(Mt(i)||jt(i)||Qo(i.type))continue;if(Pt(i.type))continue;const l=Boolean(jl(e)),s=e===ae||l;e===ae&&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?di(i.type):xi(i),from:r.place})}const r=e.zones.flatMap(e=>{const n=bn(e.list);if(n===ae&&0===e.children.length)return[{...e,addLabel:Et.addSection,addAlways:!0}];const t=Ll(n),o=t?.target.spec?.addLabel;return e.children.length>0||Boolean(t?.choices.length)||Boolean(jl(n))?[o?{...e,addLabel:o}:e]:[]}),i=r.flatMap(e=>{const n=bn(e.list),t=n===ae||jl(n)?null:Ll(n);return t?.choices.length?qe(e,t.target.spec?.addLabel??Et.addBlockHere):[]});return{sources:o,zones:r,seams:i}},[kt.data]),Ul=null==bt?.props.id?null:String(bt.props.id),Gl=On(e=>{const n=xt,t=e=>!e.item.rung&&null!==xn(kt.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(Ul);return i||(r(an(kt.data,n,o.item.id,Ul,bl))??o)},[kt.data,xt,Ul,bl]),[Xl,Yl]=Pn(null);hn(wo,"mouseover",e=>{if(!vl)return;const n=mn(e.target),t=n?Yn(kt.data,xt,n):null;t!==Xl&&Yl(t)}),hn(wo,"mouseout",e=>{vl&&!e.relatedTarget&&Yl(null)});const Kl=e=>Mt(e)||jt(e)||Pt(e.type),Zl=[];if(vl){const e=Ul?Yn(kt.data,xt,Ul):null;for(const n of/* @__PURE__ */new Set([e,Xl])){const e=n?qr.find(e=>String(e.props.id)===n):void 0;if(!e||!Kl(e))continue;const t=vl(e);t&&Zl.push({id:String(e.props.id),label:t,below:Mt(e)||e.type===It})}}const ql=R(),_l=In(null);Nn(()=>{const e=zt.changeNotice;if(!e)return;const n=JSON.stringify(qr.filter(Kl)),t=_l.current;if(_l.current={doc:yn,bands:n,index:vt.index},!t||t.doc!==yn||t.bands===n)return;vt.hasPast&&vt.index>=t.index&&!Xn.has(ql)&&(Xn.add(ql),Or(e,"success",{action:{label:Et.bar.undo,onClick:()=>vt.back()},duration:8e3}))},[qr]);const Ql=e=>{Lo(Y),qt.select(e.zone===ae?{index:e.index}:{index:e.index,zone:e.zone})},es=ie(),ns=()=>({data:kt.data,device:lo,ops:qt,inspector:Yo}),ts=es?.model,os=Bn(()=>ts?e=>ts(e,Jl(e),ns()):Jl,[ts,Jl,lo]),rs=es?.measure,is=rs?(e,n)=>rs(e,n,ns()):void 0,ls=es?.canDrop,ss=ls?(e,n)=>ls(e,n,Al,ns()):Al,ds=es?.drop,cs=ds?(e,n)=>ds(e,n,Wl,ns()):Wl,as=es?.pick,ps=as?e=>as(e,Ql,ns()):Ql,us=e=>{const n=bn(e),t=mi(n);t&&ki(t.node,t.slot,!1),Ji(n,e.index)},fs=(e,n)=>/* @__PURE__ */Jn(Ge,{...pt?{}:Dl.seam({place:{...wn(e),index:n}})},`seam:${e}:${n}`),hs={rowClick:Xi,isCollapsed:Cr,toggleCollapse:Ir},ms=e=>{const n=String(e.props.id),t=qr.findIndex(e=>String(e.props.id)===n),o=Nt(n),r=ui(o),i=Cr(n),l=li(e.type),s=ir.rowName?ir.rowName(e,"section",l):l,d=e=>fs(o,e);/* @__PURE__ */
11
- return Un(Gn,{children:[
12
- /* @__PURE__ */Jn(We,{words:Lt,icon:/* @__PURE__ */Jn(sr,{type:e.type,size:13}),name:s,preview:Zi(e),marks:qi(e),onSelect:()=>Ri(t),nameSlot:Ci(ae,t,n,s),selected:Vo===n,badge:xl,actions:_i(e,ae,t)??void 0,rowProps:{"data-node-id":n,onClick:Xi(()=>Ri(t))},fold:{open:!i,label:"section",onToggle:()=>Ir(n)}}),!i&&/* @__PURE__ */Un(He,{children:[r.map((n,t)=>{const r=String(n.props.id),i=ci(n),l=al(n),s=l&&Cr(r),c=()=>ul(o,t,r,e.type),{rowProps:a,...p}=Dl.row({item:{id:r,zone:o,index:t,type:n.type},place:{...wn(o),index:t}},{"data-node-id":r,onClick:Xi(c)});/* @__PURE__ */
13
- return Un(Mn,{children:[d(t),
14
- /* @__PURE__ */Jn(We,{words:Lt,icon:/* @__PURE__ */Jn(sr,{type:n.type,size:13}),name:i,preview:Zi(n),marks:qi(n),onSelect:c,nameSlot:Ci(o,t,r,i),selected:Vo===r,hidden:Boolean(n.props._hidden),...p,fold:l?{open:!s,label:"section",onToggle:()=>Ir(r)}:void 0,actions:/* @__PURE__ */Un(Gn,{children:[Ki(o,t,i),_i(n,o,t),Qi(o,t,n,i)]}),rowProps:a}),l&&!s&&/* @__PURE__ */Jn(He,{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=Dl.dragging,d=!Cr(l)&&s?.rung?.nodeId!==i,c={...wn(l),index:0},a=s&&!s.rung&&Al(s,c)?c:void 0,p=()=>ki(e,n,!0),{rowProps:u,...f}=Dl.row({item:{id:`rung:${l}`,zone:`${i}:${Qn}`,index:t,type:e.type,rung:{nodeId:i,slot:n.slot}},place:{parentId:i,slot:Qn,index:t},into:a,canDrag:Boolean(_o.moveSlot)&&!1!==n.movable&&o>1},{"data-slot-zone":l,onClick:Xi(p)}),h=pt?null:_o.slotActions?.(e,n.slot);/* @__PURE__ */
15
- return Un(Mn,{children:[n.heading,
16
- /* @__PURE__ */Jn(We,{words:Lt,icon:n.glyph??null,name:n.label,badge:n.badge,onSelect:p,selected:gi===l,...f,dragHint:n.dragHint,fold:{open:d,label:n.label,onToggle:()=>Ir(l)},actions:h&&h.length>0?/* @__PURE__ */Jn(Gn,{children:h.map((t,o)=>/* @__PURE__ */Jn(Ue,{kind:"delete"===t.kind?"delete":"plain",label:t.label,disabled:t.disabled,onClick:()=>((e,n,t)=>{if(pt||t.disabled)return;const o=String(e.props.id),r=e=>{"string"==typeof e&&Si(o,e,n.panel)},i=t.run();i&&"function"==typeof i.then?i.then(r):r(i)})(e,n,t),children:"delete"===t.kind?/* @__PURE__ */Jn(Fn,{size:15}):/* @__PURE__ */Jn(Dn,{size:15})},`${o}:${t.kind}`))}):void 0,rowProps:u}),d&&/* @__PURE__ */Jn(He,{children:r})]},l)},ys=(e,n)=>{const t=rl(e),o=t.filter(e=>e.rung).length;let r=0;/* @__PURE__ */
17
- return Jn(Gn,{children:t.map(t=>{const i=t.kids,l=t.rung?n+1:n,s=sl(e.type,void 0,t.slot),d=s?`${e.props.id}:${s.slot}`:null,c=null===t.slot?null:`${e.props.id}:${t.slot}`,a=(e,n)=>fs(e,n),p=/* @__PURE__ */Un(Gn,{children:[i.map(({child:n,zone:t,index:o})=>{const r=Vo===String(n.props.id),{collapsible:i,folded:s}=dl(n,l,pl(n.type)),d=String(n.props.id),c=Nl(n),p=()=>ul(t,o,d,e.type),{rowProps:u,...f}=Dl.row({item:{id:d,zone:t,index:o,type:n.type},place:{...wn(t),index:o}},{"data-node-id":d,onClick:Xi(p)});/* @__PURE__ */
18
- return Un(Mn,{children:[0===o&&a(t,0),
19
- /* @__PURE__ */Jn(We,{words:Lt,icon:/* @__PURE__ */Jn(sr,{type:n.type,size:13}),name:c,preview:Zi(n),marks:qi(n),onSelect:p,nameSlot:Ci(t,o,d,c),selected:r,hidden:Boolean(n.props._hidden),...f,fold:i?{open:!s,label:"group",onToggle:()=>Ir(d)}:void 0,actions:/* @__PURE__ */Un(Gn,{children:[Ki(t,o,c),_i(n,t,o),Qi(t,o,n,c)]}),rowProps:u}),i&&!s&&/* @__PURE__ */Jn(He,{children:ys(n,l+1)}),a(t,o+1)]},String(n.props.id??`${t}-${o}`))}),null===c?d&&!i.some(e=>e.zone===d)?a(d,0):null:0!==i.length||!t.rung&&d!==c?null:a(c,0)]});return t.rung?gs(e,t.rung,r++,o,p):/* @__PURE__ */Jn(Mn,{children:p},t.slot??"")})})},ks=(e,n)=>{const t=nr(kt?.data,e.type,String(e.props.id)),o=rl(e),r=o.filter(e=>e.rung).length;let i=0;/* @__PURE__ */
20
- return Jn(Gn,{children:o.map(o=>{const l=o.kids,s=o.rung?n+1:n,d=sl(e.type,t,o.slot),c=d?.spec??null,a=c&&Array.isArray(e.props[c.slot])?e.props[c.slot]:[],p=d&&d.choices?{slot:d.slot,choices:d.choices}:null,u=String(e.props.id),f=c&&!c.fixed?`${u}:${c.slot}`:null,h=p?`${u}:${p.slot}`:null,m=(e,n)=>fs(e,n),g=null===o.slot?null:`${u}:${o.slot}`,y=Boolean(c&&!c.fixed&&(null===g||g===f)),k=/* @__PURE__ */Un(Gn,{children:[l.map(({child:n,zone:t,index:o})=>{const r=Vo===String(n.props.id),i=xi(n),l=String(n.props.id),{collapsible:d,folded:c}=dl(n,s,pl(n.type)),a=tl(n.type),p=1===a.length?`${l}:${a[0]}`:null,u=p?{...wn(p),index:ui(p).length}:void 0,f=Dl.dragging,h=u&&f&&Al(f,u)?u:void 0,g=()=>ul(t,o,l,e.type),{rowProps:y,...k}=Dl.row({item:{id:l,zone:t,index:o,type:n.type},place:{...wn(t),index:o},into:h,canDrag:!Qo(n.type)},{"data-node-id":l,onClick:Xi(g)});/* @__PURE__ */
21
- return Un(Mn,{children:[0===o&&m(t,0),
22
- /* @__PURE__ */Jn(We,{words:Lt,icon:/* @__PURE__ */Jn(sr,{type:n.type,size:13}),name:i,preview:Zi(n),marks:qi(n),onSelect:g,nameSlot:Ci(t,o,l,i),selected:r,hidden:Boolean(n.props._hidden),...k,fold:d?{open:!c,label:"group",onToggle:()=>Ir(l)}:void 0,actions:Qo(n.type)?_i(n,t,o)??void 0:/* @__PURE__ */Un(Gn,{children:[Ki(t,o,i),_i(n,t,o),Qi(t,o,n,i)]}),rowProps:y}),d&&!c&&/* @__PURE__ */Jn(He,{children:ks(n,s+1)}),m(t,o+1)]},String(n.props.id??`${t}-${o}`))}),y&&c&&
23
- /* @__PURE__ */Jn(T,{small:!0,label:c.addLabel,blocked:c.addBlocked?.(a)??null,onAdd:()=>fl(e.props.id,c.slot,c.childType,a.length,e.type)}),null===g?h&&!l.some(e=>e.zone===h)?m(h,0):null:0!==l.length||(o.rung?y:g!==h)?null:m(g,0)]});return o.rung?gs(e,o.rung,i++,r,k):/* @__PURE__ */Jn(Mn,{children:k},o.slot??"")})})},Ss=Po||null!==po,vs=e=>"panel"in e?{id:e.id,label:e.label,icon:e.icon,active:Qt&&!Ss&&qo===e.id,onSelect:()=>Xr(e.id)}:e,bs=[...(Ko.railLead??[]).map(vs),{id:"sections",label:Et.layers,icon:/* @__PURE__ */Jn(Ke,{}),active:Qt&&!Ss&&"sections"===qo,onSelect:()=>Xr("sections")},...(Ko.railTrail??[]).map(vs)];ao?bs.push({id:"media",label:Et.railMedia,icon:/* @__PURE__ */Jn(Ze,{}),active:Qt&&!Po&&(null!==po||"media"===qo),onSelect:()=>Xr("media")}):mt&&bs.push({id:"media",label:Et.railMedia,icon:/* @__PURE__ */Jn(Ze,{}),onSelect:Yr});const ws=[...Ko.railLead??[],...Ko.railTrail??[]].find(e=>"panel"in e&&e.id===qo),xs=Boolean(At?.foldable)&&!Zo,zs=At?.label??(gt?Et.pageSections:Et.templateSections),Cs=xs&&Cr(et),Is=/* @__PURE__ */Un(Gn,{children:[qr.map((e,n)=>{if(Mt(e)||jt(e)||Pt(e.type))return null;const t=Vo===String(e.props.id),o=Boolean(e.props._hidden);ol(e);const r=String(e.props.id),i=Ko.hasOwnRows?.(e)??!1,l=al(e)||i,s=l&&Cr(r),d=tl(e.type),c=1===d.length?`${r}:${d[0]}`:null,a=c?{...wn(c),index:ui(c).length}:void 0,p=Dl.dragging,u=a&&p&&Al(p,a)?a:void 0,{rowProps:f,...h}=Dl.row({item:{id:r,zone:ae,index:n,type:e.type},place:{...wn(ae),index:n},into:u},{"data-node-id":r,onClick:Xi(()=>Ri(n))});/* @__PURE__ */
24
- return Un(Mn,{children:[n>0&&el(n),
25
- /* @__PURE__ */Jn(We,{words:Lt,icon:/* @__PURE__ */Jn(sr,{type:e.type,size:13}),name:ci(e),preview:Zi(e),marks:qi(e),onSelect:()=>Ri(n),nameSlot:Ci(ae,n,r,ci(e)),selected:t,hidden:o,...h,fold:l?{open:!s,label:"section",onToggle:()=>Ir(r)}:void 0,actions:/* @__PURE__ */Un(Gn,{children:[Ki(ae,n,ci(e)),_i(e,ae,n),Qi(ae,n,e,ci(e))]}),rowProps:f}),al(e)&&!s&&/* @__PURE__ */Un(He,{children:[ks(e,1),Ko.partRows?.(e,hs)]}),i&&!s&&/* @__PURE__ */Jn(He,{children:Ko.ownRows?.(e,n,hs)})]},String(e.props.id??n))}),!Zo&&Il>0&&el(Il)]}),Bs=(e,n,t)=>{const o=String(e.props.id),r=il(e).length>0||ll(e)||Boolean(or(e.type)),i=r&&Cr(o),l="header"===t?Et.header:Et.footer,s=ir.rowName?ir.rowName(e,"section",l):l;/* @__PURE__ */
26
- return Un(Gn,{children:[
27
- /* @__PURE__ */Jn(We,{words:Lt,icon:/* @__PURE__ */Jn(sr,{type:t,size:13}),name:s,preview:Zi(e),marks:qi(e),badge:xl,onSelect:()=>Ri(n),nameSlot:Ci(ae,n,o,s),selected:Vo===String(e.props.id),fold:r?{open:!i,label:"section",onToggle:()=>Ir(o)}:void 0,actions:_i(e,ae,n)??void 0,rowProps:{"data-node-id":o,onClick:Xi(()=>Ri(n))}}),r&&!i&&/* @__PURE__ */Jn(He,{children:ys(e,1)})]})};return(Ko.wrap??(e=>e))(
28
- /* @__PURE__ */Jn(le,{target:wo,children:/* @__PURE__ */Un("div",{ref:bo,className:"sf-editor es-editor",style:Ae(vr),onContextMenu:$i.onEditorContextMenu,...g(un),children:[
29
- /* @__PURE__ */Un(Ce,{children:[
30
- /* @__PURE__ */Jn(Ie,{items:bs,ariaLabel:Et.bar.views}),
31
- /* @__PURE__ */Un(Be,{children:[
32
- /* @__PURE__ */Jn(Pe,{label:Et.bar.undo,disabled:Boolean(pt)||!vt.hasPast,onClick:()=>vt.back(),children:/* @__PURE__ */Jn(En,{})}),
33
- /* @__PURE__ */Jn(Pe,{label:Et.bar.redo,disabled:Boolean(pt)||!vt.hasFuture,onClick:()=>vt.forward(),children:/* @__PURE__ */Jn(Ln,{})}),
34
- /* @__PURE__ */Jn(Ne,{}),
35
- /* @__PURE__ */Jn(Oe,{devices:no,value:lo,onChange:so}),
36
- /* @__PURE__ */Jn(Pe,{label:Et.bar.refresh,tip:Et.bar.refreshTip,onClick:()=>{vo.current=(()=>{const e=wo?.document;if(!e)return null;const n=qr.findIndex(jt),t=n>=0?n:qr.length;let o=null;for(let n=0;n<t;n++){const t=qr[n]?.props?.id;if(null==t)continue;const r=e.querySelector(`[data-puck-component="${CSS.escape(String(t))}"]`);if(!r)continue;const i=r.getBoundingClientRect().top;i<=4&&(null===o||i>o.offset)&&(o={id:String(t),offset:i})}if(!o){const e=bt?.props?.id??qr[0]?.props?.id;null!=e&&(o={id:String(e),offset:0})}return o})(),So(e=>e+1)},children:/* @__PURE__ */Jn(Rn,{})})]}),
37
- /* @__PURE__ */Un(Be,{kind:"right",style:{minWidth:300},children:[
38
- /* @__PURE__ */Jn(N,{input:Io,words:Et.saveStatus}),Ko.barLead?.(),Ko.barTrail?.(),Ko.mainAction||!Ko.barMain?/* @__PURE__ */Jn(O,{input:Io,action:Ko.mainAction??{label:Et.done,onPress:()=>{ot(kt.data)}},readOnly:Boolean(pt),saveSwitch:ft,onToggleAutoSave:st,onSaveNow:Bo,bar:Et.bar,words:Et.saveStatus}):Ko.barMain()]})]}),
39
- /* @__PURE__ */Jn(I,{}),
40
- /* @__PURE__ */Un("div",{className:"sf-body",children:[Qt?/* @__PURE__ */Un(Gn,{children:[
41
- /* @__PURE__ */Jn("aside",{className:"es-sidepanel es-sidepanel--left sf-panel sf-panel--left","aria-label":Et.leftPanel,children:Po?/* @__PURE__ */Jn(A,{at:Mo?{label:(e=>{const n=jl(e.zone);if(n)return Et.add.addingTo({name:ir.rowName?Gi(n,!0):li(n.type)});if(e.zone===ae){const n=qr[e.index];return n&&!jt(n)?Et.add.addingBefore({name:Gi(n,!0)}):Et.add.addingAtEnd}const t=Ll(e.zone);return t?Et.add.addingTo({name:t.parentName}):Et.add.addingHere})(Mo),onClear:()=>jo(null)}:void 0,placeBlocks:Mo&&Mo.zone!==ae?Ll(Mo.zone)?.choices:void 0,canTake:Mo?e=>{if(!Mo)return null;const n={...wn(Mo.zone),index:Mo.index};if(Vl(e,n))return null;const t=jl(Mo.zone);if(t)return Et.add.notInside({name:Gi(t,!0)});if(Mo.zone===ae)return Et.add.onlySections;const o=Ll(Mo.zone);return o?Et.add.notInside({name:o.parentName}):Et.add.onlySections}:void 0,onPick:Mo?e=>{if(!Mo)return;const n={...wn(Mo.zone),index:Mo.index};Vl(e,n)&&(Fl(e,n),Ui())}:void 0,itemFor:e=>({id:`new:${e.kind}:${"template"===e.kind?e.template.id:e.type}`,zone:"",index:-1,type:"template"===e.kind?e.template.node.type:e.type,add:e}),session:Hl,siteWide:Ko.addPanelRow?.(Ui),onClose:Ui,onHide:Ur,readOnly:Boolean(pt)}):po&&co?
42
- /* @__PURE__ */Jn(x,{panel:co,pick:po,onHide:Ur}):ws?ws.panel({onHide:Ur,notify:Or}):"media"===qo&&co?/* @__PURE__ */Jn(x,{panel:co,pick:null,onHide:Ur}):/* @__PURE__ */Un(Gn,{children:[
43
- /* @__PURE__ */Jn(E,{icon:/* @__PURE__ */Jn(Ke,{}),title:Et.layers,context:Jt,actions:/* @__PURE__ */Un(Gn,{children:[!pt&&/* @__PURE__ */Jn($e,{label:Et.add.title,onClick:()=>Di(null),children:/* @__PURE__ */Jn(Vn,{size:15})}),
44
- /* @__PURE__ */Jn($e,{label:Pl?Et.expandAll:Et.collapseAll,title:0===Bl.length?Et.nothingToFold:void 0,disabled:0===Bl.length,onClick:()=>Sr(e=>{const n=new Set(Bl);return Pl?new Set([...e].filter(e=>!n.has(e))):/* @__PURE__ */new Set([...e,...Bl])}),children:/* @__PURE__ */Jn(Zn,{expand:Pl})})]}),onHide:Ur}),
45
- /* @__PURE__ */Un(De,{className:"sf-tree sf-scroll",words:Lt,children:[
46
- /* @__PURE__ */Jn(We,{words:Lt,icon:/* @__PURE__ */Jn(sr,{type:"page",size:13}),name:Et.pageSettings,onSelect:Kr,selected:!bt&&Ro,rowProps:{onClick:Xi(Kr)}}),zl&&/* @__PURE__ */Un(Gn,{children:[!wl&&/* @__PURE__ */Jn(Je,{children:Et.header}),ms(zl)]}),!Zo&&yt&&!(wl&&zl)&&/* @__PURE__ */Un(Gn,{children:[!wl&&/* @__PURE__ */Jn(Je,{children:Et.header}),!Tt&&/* @__PURE__ */Jn(We,{words:Lt,icon:/* @__PURE__ */Jn(sr,{type:"header",size:13}),name:Et.header,badge:xl,onSelect:Zr,selected:Eo.kind===$t?.kind,rowProps:{onClick:Xi(Zr)}})]}),!Zo&&Sl&&!(wl&&zl)&&Bs(Sl,kl,"header"),!Zo&&!xs&&/* @__PURE__ */Jn(Je,{children:zs}),xs?/* @__PURE__ */Un(Gn,{children:[
47
- /* @__PURE__ */Jn(We,{words:Lt,icon:null,name:zs,fold:{open:!Cs,label:zs,onToggle:()=>Ir(et)}}),!Cs&&/* @__PURE__ */Jn(He,{children:Is})]}):Is,yt&&!wl&&/* @__PURE__ */Jn(Je,{children:Et.footer}),yl&&!(wl&&Cl)&&Bs(yl,gl,"footer"),!Zo&&!yl&&yt&&!wl&&/* @__PURE__ */Jn(We,{words:Lt,icon:/* @__PURE__ */Jn(sr,{type:"footer",size:13}),name:Et.footer,onSelect:Yi,rowProps:{onClick:Xi(Yi),title:Et.editFooter}}),Cl&&ms(Cl),Ko.treeFoot?.()]})]})}),
48
- /* @__PURE__ */Jn(Me,{side:"left",width:vr.left,min:Te,max:je,defaultWidth:b.left,label:Et.resizeLeftPanel,onResize:xr})]}):/* @__PURE__ */Jn(L,{side:"left",onShow:Ur}),
49
- /* @__PURE__ */Un("div",{ref:$r,className:"sf-center sf-scroll","data-sf-canvas-head":Er?"":void 0,style:{overflowX:Hr?"auto":"hidden",overflowY:"hidden"},children:[Er&&/* @__PURE__ */Jn("div",{ref:Lr,className:"sf-canvas-head",children:/* @__PURE__ */Jn(Er,{device:lo})}),
50
- /* @__PURE__ */Un("div",{className:"sf-frame-scaler",style:Dr,children:[
51
- /* @__PURE__ */Jn("div",{className:"sf-frame "+(lo===ro?"":`sf-frame--${lo}`),style:Jr,children:/* @__PURE__ */Un("div",{className:"sf-preview-host",children:[
52
- /* @__PURE__ */Jn(sn.Provider,{value:bl,children:/* @__PURE__ */Jn(Ut,{},ko)}),
53
- /* @__PURE__ */Jn(_e,{canvas:wo,session:Hl,model:os,measure:is,canDrop:ss,onDrop:cs,choose:Gl,onPick:ps,onZoneAdd:us,onSeamAdd:us,zoneAddLabel:Et.canvasAddBlock,words:Rt.canvas,readOnly:Boolean(pt),revision:kt.data}),To.length>0&&/* @__PURE__ */Jn("div",{className:"sf-preview-gaps",children:To.map(e=>
54
- /* @__PURE__ */Jn(Qe,{index:e.index,label:Et.addSectionHere,onInsert:()=>Di(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))})]})}),vl?/* @__PURE__ */Jn(Kn,{canvas:wo,tabs:Zl,onSelect:e=>{const n=qr.findIndex(n=>String(n.props.id)===e);n>=0&&Ri(n)}}):null]})]}),eo?/* @__PURE__ */Un(Gn,{children:[
55
- /* @__PURE__ */Jn(S,{value:{selectChild:ul,addChild:fl,childRowName:xi,blockRowName:Nl},children:/* @__PURE__ */Jn(Gt,{mode:Eo,onOpenWebsiteSettings:Ko.openSettings??(()=>{}),onOpenSiteStyles:Ko.openStyles,onSelectNode:pr,onNotify:Or,onHidePanel:Gr,nodeActions:bt?pe(xt,bt.type):nt})}),
56
- /* @__PURE__ */Jn(Me,{side:"right",width:vr.right,min:Te,max:je,defaultWidth:b.right,label:Et.resizeSettingsPanel,onResize:zr})]}):
57
- /* @__PURE__ */Jn(L,{side:"right",onShow:Gr})]}),$i.menu]})}))}export{tt as ScreenChrome};
@@ -1,13 +0,0 @@
1
- import{DEFAULT_CANVAS_WORDS as e}from"./chunk-TBY3DFKS.js";import{useResolvedFields as t}from"./chunk-YRLPFZW3.js";import{toItemSelector as n,fromItemSelector as o,useNodeOps as r,parentStep as i,clickPick as l}from"./chunk-ECM5F6JJ.js";import{setCanvasNonce as s,isTypingTarget as a,frameRectToHost as c,CANVAS_TYPING_EVENT as d,drawnBox as u}from"./chunk-ILXP5VX5.js";import{find as p,ROOT_ID as f,getList as h,remove as m,parseZoneKey as g,move as v,duplicate as y,replaceNode as w,createNode as b,insert as k,normalizeData as S,createResolveCache as C,resolveNodeData as I,ROOT_SLOT as E}from"./chunk-KRXQM65X.js";import{topLevelSlotKeys as x,fieldsFrom as D,defaultsFrom as M}from"./chunk-NKB3KVAB.js";import{selectionBox as A,placeWindow as O,offsetOrigin as z,colorRunOf as R,ColorWindow as P,startCanvasTyping as L,textMap as B}from"./chunk-WDQY6JMM.js";import{DEFAULT_COPY_WORDS as V}from"./chunk-33C6ALT5.js";import{useWords as $}from"./chunk-MFIRYGHW.js";import{createContext as N,useEffect as K,useContext as j,useRef as Z,useSyncExternalStore as F,useState as T,useMemo as H,useCallback as W,useLayoutEffect as Y}from"react";import{jsx as q,jsxs as X,Fragment as J}from"react/jsx-runtime";import{createPortal as U}from"react-dom";import{registerModalEscapeInterceptor as Q,FloatingBar as G,TextToolbar as _,LinkPicker as ee}from"efficient-shell/ui";function te(e){return!["setData","setUi","set"].includes(e.type)}var ne=(e,t,n,o)=>{const r=h(e,t,g(n));return r?.[o]??null},oe=(e,t,n,o,r)=>{const i=ne(e,t,n,o);if(!i)throw new Error(`${r}: nothing at ${n}[${o}]`);return i};function re(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 ie(e,t,n){return n?"node"===n.kind?p(e,t,n.id)?n:null:n.parentId===f?h(e,t,n)?n:null:p(e,t,n.parentId)&&h(e,t,n)?n:null:null}function le(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 se(e,t,n){const o=ae(e,t,n);if(o===e)return e;const r=ie(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function ae(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 le(e,n,"function"==typeof t.ui?t.ui(re(e,n)):t.ui);case"set":{const r={data:o,ui:re(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=le(l,n,i.ui,!0)),l}case"insert":{const r={...g(t.destinationZone),index:t.destinationIndex},i=b(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:k(o,n,r,i)}}case"replace":{const r=oe(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:w(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=oe(o,n,t.sourceZone,t.sourceIndex,"duplicate"),i=y(o,n,r.props.id),l=ne(i,n,t.sourceZone,t.sourceIndex+1);return{...e,data:i,selection:l?{kind:"node",id:l.props.id}:e.selection}}case"reorder":return ae(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=ne(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const i={...g(t.destinationZone),index:t.destinationIndex};return{...e,data:v(o,n,r.props.id,i)}}case"remove":{const r=oe(o,n,t.zone,t.index,"remove");return{...e,data:m(o,n,r.props.id)}}default:return e}}var ce={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},de={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},ue=0,pe=()=>`history-${ue+=1}`;function fe(e){let t=e.config;const r=e.now??(()=>Date.now()),i=e.historyCoalesceMs??250;let l=e.permissions??{};const s=S(e.data,t);let a={data:s,selection:null,ui:{...de}};if(e.ui){const{itemSelector:n,selectedSlot:r,...i}=e.ui;a={data:s,selection:r?{kind:"slot",...r}:o(s,t,n??null),ui:{...de,...i}}}let c=[{core:a,at:-1/0,sealed:!0,id:pe()}],d=0;const u=e=>{const t=c[d],n=r();!e&&d===c.length-1&&d>0&&!t.sealed&&n-t.at<i?c=[...c.slice(0,d),{...t,core:a,at:n}]:(c=[...c.slice(0,d+1),{core:a,at:n,sealed:e,id:pe()}],d=c.length-1)},f=/* @__PURE__ */new Set;let m=null,g=null,v=0,y=null,b=!1;const k=()=>{for(const e of[...f])e()},E=()=>{c=[...c.slice(0,d),{...c[d],core:a},...c.slice(d+1)]},x=(t,n)=>{v>0?b=b||n:(n?u(!1):a!==t&&E(),a.data!==t.data&&e.onChange?.(a.data),a!==t&&k())},D=e=>{const n=a;if(a=se(a,e,t),a===n)return;const o=e.recordHistory??te(e);x(n,o&&a.data!==n.data)},M=t=>{0===v&&(y=a,b=!1),v+=1;try{t()}catch(e){throw v-=1,0===v&&y&&(a=y,y=null),e}if(v-=1,v>0||!y)return;const n=y;y=null,b&&a.data!==n.data?u(!0):a!==n&&E(),a.data!==n.data&&e.onChange?.(a.data),a!==n&&k()},A=e=>{const n=a,o=ie(a.data,t,e);var r,i;(r=o,i=a.selection,r===i||r&&i&&r.kind===i.kind&&("node"===r.kind&&"node"===i.kind?r.id===i.id:"slot"===r.kind&&"slot"===i.kind&&r.parentId===i.parentId&&r.slot===i.slot))||(a={...a,selection:o},x(n,!1))},O=t=>{const n=a;d=t,a=c[d].core,a.data!==n.data&&e.onChange?.(a.data),a!==n&&k()},z=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...ce,...l,...n}};let R=z();const P=C(),L={resolveCache:P,async resolveAll({trigger:e="load",metadata:n}={}){const o=a.data,r={type:"root",props:{...o.root.props??{}}},i=[...o.content,...Object.values(o.zones??{}).flat()],[l,...s]=await Promise.all([I(r,t,{cache:P,trigger:e,metadata:n}),...i.map(o=>I(o,t,{cache:P,trigger:e,metadata:n}))]);M(()=>{const e=a;let n=a.data;s.forEach((e,r)=>{if(!e.didChange)return;const l=i[r].props.id,s=p(n,t,l)?.node;s&&s===p(o,t,l)?.node&&(n=w(n,t,l,e.node))}),l.didChange&&n.root===o.root&&(n={...n,root:{...n.root,props:l.node.props,readOnly:l.node.readOnly??n.root.readOnly}}),n!==a.data&&(a={...a,data:n,selection:ie(n,t,a.selection)},x(e,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=p(a.data,t,e)?.node;if(!r)return!1;const i=await I(r,t,{cache:P,trigger:n,metadata:o});if(!i.didChange)return!1;let l=!1;return M(()=>{const n=a;if(p(a.data,t,e)?.node!==r)return;const o=w(a.data,t,e,i.node);o!==a.data&&(a={...a,data:o,selection:ie(o,t,a.selection)},x(n,!1),l=!0)}),l},get config(){return t},getState(){if(m&&g===a)return m;const e=a,o={data:e.data,ui:re(e,t)},r="node"===e.selection?.kind?p(e.data,t,e.selection.id)?.node??null:null;return m={appState:o,selection:e.selection,selectedItem:r,config:t,dispatch:D,history:{back:()=>L.undo(),forward:()=>L.redo(),hasPast:d>0,hasFuture:d<c.length-1,histories:c.map(e=>({id:e.id,state:{data:e.core.data,ui:re(e.core,t)}})),index:d,setHistoryIndex:e=>{e>=0&&e<c.length&&e!==d&&O(e)}},getPermissions:R,getItemById:n=>p(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return h(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}},g=e,m},subscribe:e=>(f.add(e),()=>{f.delete(e)}),dispatch:D,batch:M,group:()=>{const e=d,t=c[e].id;let n=!0;return{close:()=>{if(!n)return;if(n=!1,c[e]?.id!==t)return;if(d<=e+1)return void(d===e+1&&(c=[...c.slice(0,d),{...c[d],sealed:!0},...c.slice(d+1)]));const o=c[d];c=[...c.slice(0,e+1),{...o,sealed:!0},...c.slice(d+1)],d=e+1}}},select:e=>A(e?{kind:"node",id:e}:null),selectSlot:e=>A(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){M(()=>{const n=a,o=void 0===e.select?a.selection:e.select;a={...a,data:e.data,selection:ie(e.data,t,o)},x(n,e.data!==n.data)})},load(e,n={}){const o=a,r=S(e,t);a={...a,data:r,selection:ie(r,t,n.selection??a.selection)},n.keepHistory||(c=[{core:a,at:-1/0,sealed:!0,id:pe()}],d=0),a!==o&&k()},undo(){d>0&&O(d-1)},redo(){d<c.length-1&&O(d+1)},setPermissions(e){(function(e,t){if(e===t)return!0;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])})(e,l)||(l=e,R=z(),m=null,k())},setConfig(e){e!==t&&(t=e,R=z(),m=null,k())}};return L}function he(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&&a(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 me=N(null),ge=N(!0);function ve({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return K(()=>{n&&e.resolveAll()},[e,n]),K(()=>{if(t&&"undefined"!=typeof document)return he(document,e)},[e,t]),/* @__PURE__ */q(me.Provider,{value:e,children:/* @__PURE__ */q(ge.Provider,{value:t,children:o})})}function ye(){const e=j(me);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function we(e){const t=ye(),n=Z({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 F(t.subscribe,o,o)}function be(){return function(e){return we(e)}}var ke="data-puck-component",Se="data-puck-dropzone",Ce={},Ie="data-es-mirror",Ee="undefined"==typeof window?K:Y;function xe(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${Ie}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(Ie,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function De({children:t,id:n="preview-frame",title:o,className:r,style:i,mirrorStyles:l=!0,onDocument:a,height:c="auto",nonce:d}){const u=$("canvas",e),p=Z(null),[f,h]=T(null);return Ee(()=>{const e=p.current,t=f?.ownerDocument.defaultView;if("auto"!==c||!e||!f||!t)return;const n=()=>{e.style.height=`${Math.ceil(f.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(f),()=>r?.disconnect()},[f,c]),Ee(()=>{let e=p.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=p.current?.contentDocument??e),e.body||e.documentElement.appendChild(e.createElement("body")),e.body.style.margin="0";const t=e.createElement("div");t.setAttribute("data-puck-entry",""),t.id="frame-root","fill"===c&&t.classList.add("es-frame-fill"),e.body.appendChild(t),s(e,d),h(t),a?.(e);let n=null;const o=p.current?.ownerDocument;if(l&&o){xe(o,e,d);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>xe(o,e,d)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}return()=>{n?.disconnect(),t.remove(),h(null),a?.(null)}},[]),/* @__PURE__ */q("iframe",{ref:p,id:n,title:o??u.frame,className:["es-canvas-frame","fill"===c?"is-fill":"",r??""].filter(Boolean).join(" "),style:i,children:f?U(t,f):null})}var Me=N(null),Ae=N(Ce),Oe=[];function ze({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:i=120}){const l=ye(),s=we(n=>h(n.appState.data,l.config,{parentId:e,slot:t})??Oe),a=we(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==f),c=we(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),d=j(Me),u=["es-zone"];return s.length&&u.push("has-children"),e===f&&u.push("is-root"),(a||c)&&u.push("is-area-selected"),null!==d&&d===e&&e!==f&&u.push("is-hovering-area"),n&&u.push(n),/* @__PURE__ */q("div",{className:u.join(" "),[Se]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${i}px`},children:s.map(e=>/* @__PURE__ */q(Ke,{node:e},e.props.id))})}function Re(e,t){return H(()=>{const n={};for(const o of x(D(e)))n[o]=function(e={}){/* @__PURE__ */
2
- return q(ze,{parentId:t,slot:o,...e})};return n},[e,t])}function Pe(e){return H(()=>function({zone:t,...n}){/* @__PURE__ */
3
- return q(ze,{parentId:e,slot:t,...n})},[e])}var Le=["top","bottom","zIndex"];function Be(e,t,n){e.style[t]!==n&&(e.style[t]=n)}function Ve(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));Be(e,"position",t?"sticky":"relative");for(const n of Le)Be(e,n,t?.[n]??"");return!!t}var $e="data-es-canvas-relative";function Ne(e){e.hasAttribute($e)&&("relative"===e.style.position&&(e.style.position=""),e.removeAttribute($e));const t=e.ownerDocument.defaultView?.getComputedStyle(e).position;return t&&"static"!==t?"sticky"===t:(e.style.position||(e.style.position="relative",e.setAttribute($e,"")),!1)}function Ke({node:e}){const t=ye().config.components[e.type],n=e.props.id,o=Z(null),r=function(e,t){return H(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(ke),o.removeAttribute("data-puck-dnd")),t.current=n,n&&(n.setAttribute(ke,e),n.setAttribute("data-puck-dnd",e),Ne(n))},[e,t])}(n,o),i=Z(null),l=!!t?.inline;!function(e,t){const n=Z(!1),o=Z(()=>{});o.current=()=>{const o=e(),i=n.current;n.current=!!o&&t(o),i!==n.current&&r.current()};const r=Z(()=>{});Ee(()=>o.current()),Ee(()=>{const t=e(),i=t?.ownerDocument.defaultView;if(!t||!i)return;const l=()=>o.current();i.addEventListener("resize",l);const s=i.ResizeObserver,a=s?new s(l):null;a?.observe(t);let c=null;return r.current=()=>{c?.disconnect(),c=null;const e=t.ownerDocument.documentElement;n.current&&e&&i.MutationObserver&&(c=new i.MutationObserver(l),c.observe(e,{attributes:!0}))},r.current(),()=>{i.removeEventListener("resize",l),a?.disconnect(),c?.disconnect(),r.current=()=>{}}},[])}(()=>l?o.current:i.current,e=>l?Ne(e):Ve(e));const s=j(Ae),a=Re(t,n),c=Pe(n);if(!t?.render)return null;const d=t.render,u={...M(t),...e.props,...a},p={renderDropZone:c,isEditing:!0,dragRef:t.inline?r:null,metadata:{...s,...t.metadata}};return t.inline?/* @__PURE__ */q(d,{...u,puck:p,editMode:!0}):
4
- /* @__PURE__ */q("div",{ref:i,[ke]:n,"data-puck-dnd":n,style:{position:"relative"},children:/* @__PURE__ */q(d,{...u,puck:p,editMode:!0})})}function je({metadata:e}){const t=we(e=>e.config),n=we(e=>e.appState.data.root).props??{},o=t.root?.render,r=Re(t.root,f),i=Pe(f),l=/* @__PURE__ */q(ze,{parentId:f,slot:E}),s=o?/* @__PURE__ */q(o,{id:"puck-root",...n,...r,puck:{renderDropZone:i,isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:l}):l;/* @__PURE__ */
5
- return q(Ae.Provider,{value:e??Ce,children:s})}var Ze=N(void 0);function Fe(e,t,n){const[o,r]=T(null),i=Z(t);return i.current=t,Ee(()=>{const t=e.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!i.current)return void r(null);let o=0;const l=()=>{o=0;const n=function(e,t){if(!e||!t)return null;const n=u(e),o=t.getBoundingClientRect();return{top:n.top-o.top,left:n.left-o.left,width:n.width,height:n.height}}(i.current?i.current(t):null,e.current?.parentElement??null);r(e=>{return(t=e)===(o=n)||t&&o&&t.top===o.top&&t.left===o.left&&t.width===o.width&&t.height===o.height?e:n;var t,o})},s=()=>{o||(o=(n.requestAnimationFrame??(e=>n.setTimeout(e,16)))(l))};l();const a="MutationObserver"in n?new n.MutationObserver(s):null;a?.observe(t.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0});const c="ResizeObserver"in n?new n.ResizeObserver(s):null;return c?.observe(t.documentElement),n.addEventListener("resize",s),()=>{a?.disconnect(),c?.disconnect(),n.removeEventListener("resize",s),o&&(n.cancelAnimationFrame??n.clearTimeout)(o)}},[n]),o}function Te({id:e,kind:t,overlay:n}){const o=Z(null),r=Fe(o,e?t=>t.querySelector(`[${ke}="${t.defaultView?.CSS?.escape?t.defaultView.CSS.escape(e):e}"]`):null,e),i=/* @__PURE__ */q("div",{ref:o,"aria-hidden":"true",className:`es-canvas-outline is-${t}`,style:r?{position:"absolute",top:r.top,left:r.left,width:r.width,height:r.height}:{display:"none"}});return n&&e?/* @__PURE__ */q(n,{componentId:e,kind:t,children:i}):i}function He(e,t,n){const o=B(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 We({s:e,element:t,toolbar:n,label:o,keys:r}){const i=$("copy",V),l=e.pressed(),s=new Set(n.offered),a=n.colors&&n.colors.length>0?n.colors:null,d=Z(null),[u,p]=T(!1),[f,h]=T(null),m=u||null!==f,g=()=>{e.hold(),p(!1),h({href:e.pressed().href})},v=()=>{p(!1),h(null),e.resume()};Y(()=>{r.current={escape:()=>!!m&&(v(),!0),link:()=>!!s.has("link")&&(g(),!0)}}),Y(()=>()=>{r.current=null},[r]);const y=Z(v);y.current=v,K(()=>{if(u)return Q(e=>{const t=d.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(y.current(),!0)},()=>d.current?.querySelector(".es-copy-colors"))},[u]),K(()=>{const n=d.current;if(!m||!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;p(!1),h(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)}},[m,e,t]),Y(()=>{const e=d.current,n=e?.querySelector(".rosh-tb-wrap > .es-copy-pop"),o=t();if(!(m&&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,a=s?c(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},u=o.getBoundingClientRect(),p=s?c(s,{left:u.left,top:u.top,width:u.width,height:u.height}):{left:u.left,top:u.top,width:u.width,height:u.height},f=(e.closest("[data-floating-bar]")??e).getBoundingClientRect(),h={left:a.left,right:a.left+a.width,top:Math.min(a.top,p.top-6,f.top),bottom:Math.max(a.top+a.height,p.top+p.height+6,f.bottom)},g=e.ownerDocument.documentElement,v=(s??o.closest(".es-canvas")??o).getBoundingClientRect(),y={left:Math.max(0,v.left),top:Math.max(0,v.top),right:Math.min(g.clientWidth||v.right,v.right),bottom:Math.min(g.clientHeight||v.bottom,v.bottom)};if(y.right<=y.left||y.bottom<=y.top||0===n.offsetWidth)return;const w=O({anchor:h,size:{width:n.offsetWidth,height:n.offsetHeight},within:{left:v.left,top:v.top,right:v.right,bottom:v.bottom},clip:y,parent:z(n)});n.style.top=`${w.top}px`,n.style.left=`${w.left}px`,n.style.setProperty("--es-pop-point",`${w.point}px`),n.dataset.side=w.above?"above":"below"});const w=a?{run:R(l.color,a),open:u,onToggle:()=>{h(null),u?v():(e.hold(),p(!0))}}:void 0;/* @__PURE__ */
6
- return q(G,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?c(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__ */q("div",{ref:d,style:{width:"18rem"},children:/* @__PURE__ */q(_,{offered:s,pressed:l.marks,onMark:t=>{"link"===t?g():e.press(t)},color:w,linkOpen:null!==f,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__ */X(J,{children:[u&&a?/* @__PURE__ */q(P,{colors:a,current:l.color,words:i.colors??V.colors,onPick:t=>e.color(t)}):null,f?
7
- /* @__PURE__ */q(ee,{className:"es-copy-link es-copy-pop",value:f.href??"",onApply:t=>{h(null),e.link(t)},onRemove:null!==f.href?()=>{h(null),e.link(null)}:void 0,onCancel:v}):null]})})})})}function Ye({element:e}){const t=Z(null),n=Fe(t,()=>e(),e);/* @__PURE__ */
8
- return q("div",{ref:t,"aria-hidden":"true",className:"es-canvas-outline is-typing",style:n?{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height}:{display:"none"}})}function qe({frame:t=!0,className:n,style:o,metadata:r,mirrorStyles:s,onDocument:a,height:c,title:u,nonce:p,hotkeys:f,frameWrapper:h,overlay:m,children:g,typing:v,passThrough:y}){const w=ye(),b=j(Ze),k=y??b,S=j(ge),C=$("canvas",e),I=f??S,[E,x]=T(void 0),D=we(e=>"node"===e.selection?.kind?e.selection.id:null),[M,A]=T(null),[O,z]=T(null),R=Z(null),[,P]=T(0),B=Z(v);B.current=v;const V=Z(null),N=Z(null),F=e=>{const t=N.current?.ownerDocument,n=t?.defaultView?.CustomEvent;t&&n&&t.dispatchEvent(new n(d,{detail:{typing:e}}))},H=(e,t)=>{R.current?.s.stop("stop");const n=e.element();if(!n)return!1;const o=w.group(),r=e.element,i=L({element:r,value:e.value,rules:e.rules,multiline:e.multiline,skip:e.skip,caret:He(n,t,e.skip),write:e.write,remount:e.remount,onSelect:()=>P(e=>e+1),onEscape:()=>V.current?.escape()??!1,onLinkKey:()=>V.current?.link()??!1,end:e=>{o.close(),R.current?.element===r&&(R.current=null),z(null),F(!1),B.current?.onChange?.({typing:!1,why:e})}});if(!i)return o.close(),!1;const l=n.closest?.(`[${ke}]`)?.getAttribute(ke);return l&&w.select(l),R.current={s:i,element:r,target:e},z(()=>r),A(null),F(!0),B.current?.onChange?.({typing:!0,element:n}),!0};K(()=>()=>R.current?.s.stop("stop"),[]);const W=e=>{const t=R.current?.element();return Boolean(t&&t.contains(e))},Y=e=>{const t=e.closest?.(`[${ke}]`)?.getAttribute(ke);if(!t)return;const n=w.getState(),o="node"===n.selection?.kind?n.selection.id:null;return l(n.appState.data,w.config,t,o,k)??t},J=e=>{if("Enter"!==e.key||e.defaultPrevented||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;if(R.current)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select, button"))return;const n=B.current?.atSelection?.();n&&H(n,null)&&e.preventDefault()},U=/* @__PURE__ */X("div",{ref:N,className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;if(t.closest?.("a[href]")&&e.preventDefault(),R.current){if(W(t))return;R.current.s.stop("outside")}const n=Y(t);void 0===n?t.hasAttribute?.(Se)||w.select(null):w.select(n)},onDoubleClick:e=>{const t=B.current;if(!t||W(e.target))return;const n=t.at(e.target);n&&H(n,{x:e.clientX,y:e.clientY})&&e.preventDefault()},onKeyDown:e=>J(e),onMouseOver:e=>{if(R.current)return;const t=Y(e.target)??null;t!==M&&A(t)},onMouseLeave:()=>A(null),children:[
9
- /* @__PURE__ */q(Me.Provider,{value:M,children:/* @__PURE__ */q(je,{metadata:r})}),
10
- /* @__PURE__ */X("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
11
- /* @__PURE__ */q(Te,{id:!O&&M&&M!==D?M:null,kind:"hover",overlay:m}),
12
- /* @__PURE__ */q(Te,{id:O?null:D,kind:"selected",overlay:m}),O?/* @__PURE__ */q(Ye,{element:O}):null]}),g]}),Q=h?/* @__PURE__ */q(h,{document:E,children:U}):U;K(()=>{if(E&&I)return he(E,w)},[E,I,w]),K(()=>{if(!E)return;const e=e=>{if("Enter"===e.key)return void J(e);if("Escape"!==e.key||e.defaultPrevented)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select"))return;const n=w.getState();if("node"!==n.selection?.kind)return;const o=i(n.appState.data,w.config,n.selection);"node"===o?.kind&&w.select(o.id)};return E.addEventListener("keydown",e),()=>E.removeEventListener("keydown",e)},[E,w]);/* @__PURE__ */
13
- return X("div",{className:"es-canvas"+(n?` ${n}`:""),style:o,"data-puck-preview":"","data-es-typing":O?"":void 0,children:[O&&R.current?.target.toolbar?/* @__PURE__ */q(We,{s:R.current.s,element:R.current.element,toolbar:R.current.target.toolbar,label:C.textTools,keys:V}):null,t?/* @__PURE__ */q(De,{mirrorStyles:s,onDocument:e=>{x(e??void 0),a?.(e)},height:c,title:u,nonce:p,children:Q}):/* @__PURE__ */q("div",{id:"preview-frame","data-puck-entry":"",children:Q})]})}function Xe(e={}){const t=ye(),n=we(e=>e.appState.data);return r({...e,data:n,config:t.config,commit:(e,{select:n})=>t.run({data:e,select:n})})}function Je(){const e=ye(),n=we(e=>e.config),o=e.resolveCache,r=we(e=>e.selectedItem),i=we(e=>e.appState.data.root),l=r?r.props.id:"root",s=i.props??{},a=H(()=>r||{type:"root",props:s},[r,s]),c=r?n.components[r.type]:n.root,d=e.getState(),u=r?p(d.appState.data,n,l):null,f=u&&"root"!==u.place.parentId?u.place.parentId:null,h=f?d.getItemById(f)??null:null,{fields:m}=t({id:l,node:a,block:c,parent:h,appState:d.appState}),g=we(e=>!1===e.getPermissions(r?{item:r}:{root:!0}).edit),v=W(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 I(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 I({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]),y=W((e,t)=>v({[e]:t}),[v]);return{id:l,node:a,fields:m,values:a.props,readOnly:g,onChange:y,onChangeMany:v}}export{De as CanvasFrame,Ze as CanvasPassThroughContext,de as DEFAULT_UI,qe as EaselCanvas,ve as EaselProvider,je as EditDocument,he as bindUndoKeys,fe as createEasel,be as createUseEasel,te as recordsByDefault,se as reduce,re as uiView,we as useEasel,ye as useEaselApi,Xe as useEaselNodeOps,Je as useSelectedFields,ie as validSelection};
@@ -1 +0,0 @@
1
- import{DEFAULT_TEXT_STYLES_WORDS as o}from"./chunk-OGH6CC3E.js";import{DEFAULT_PICK_WORDS as r}from"./chunk-643PVCEG.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as t}from"./chunk-6WY6ZXJG.js";import{DEFAULT_SCREEN_WORDS as m}from"./chunk-VVPZMWJE.js";import{DEFAULT_CHROME_WORDS as n,DEFAULT_NOTICE_WORDS as c}from"./chunk-Z6PVRXVY.js";import{DEFAULT_LOCK_WORDS as s}from"./chunk-RE4LP46F.js";import{DEFAULT_TREE_WORDS as f}from"./chunk-K56YDHYQ.js";import{DEFAULT_PANEL_WORDS as p}from"./chunk-KFV7N2DJ.js";import{DEFAULT_NODE_MENU_WORDS as e}from"./chunk-WK3AFPXY.js";import{DEFAULT_RAIL_WORDS as i}from"./chunk-2OAZYSWJ.js";import{DEFAULT_SAVE_WORDS as u}from"./chunk-H6DDIBQ4.js";import{DEFAULT_DRAG_WORDS as k}from"./chunk-AYWN5NRH.js";import{DEFAULT_CANVAS_WORDS as j}from"./chunk-TBY3DFKS.js";import{DEFAULT_FIELDS_WORDS as h}from"./chunk-WRFD4EXD.js";import{DEFAULT_COPY_WORDS as l}from"./chunk-33C6ALT5.js";var a={notice:c,lock:s,save:u,chrome:n,rail:i,tree:f,panel:p,fields:h,pick:r,drag:k,menu:e,styleClipboard:t,copy:l,canvas:j,textStyles:o,screen:m},Y=o=>"object"==typeof o&&null!==o;function y(o,r){const t={};for(const m of Object.keys(o)){const n=o[m],c=r[m];null==c?t[m]=n:Y(n)?t[m]=Y(c)?y(n,c):n:t[m]=typeof c==typeof n?c:n}return t}function D(o,r){return r?y(o,r):o}export{a as DEFAULT_EASEL_STRINGS,D as mergeEaselStrings};
@@ -1 +0,0 @@
1
- import{panelFieldsOf as t}from"./chunk-ZE7I3PLX.js";import{withoutDeviceGate as o,deviceMetaOf as n}from"./chunk-FHLYUIJJ.js";import{DESIGN_GROUP_KEY as e,BUCKET_KEY as r}from"./chunk-MQNBD6AB.js";import{ANCHOR_FIELD_KEYS as s,foldMetaOf as c,MEDIA_FIELD_MARKER as i,TEXT_FIELD_MARKER as p,LINK_FIELD_MARKER as u}from"./chunk-DUVRZ456.js";import{STYLE_KIND as a,fieldKind as f,copyStyle as l,heldStyle as m,planPaste as h,pasteMessage as y}from"./chunk-V7U33NF2.js";var j=/* @__PURE__ */new Set([e.Size,e.Design,e.Layout,e.Position]),w=new Set(Object.values(e)),b=new Set(Object.values(r)),S=new Set(s),g=/* @__PURE__ */new Set(["focal","imageFocal"]),k=[i,p,u];function v(t){return`site:${t??""}`}function D(t){if(!t||"object"!=typeof t)return null;const n=t,e=o(t)??t,r=n[a]??e[a];if("string"==typeof r)return r;const s=n.options??e.options;if(Array.isArray(s)){return`choice:${s.map(t=>String(t?.value)).sort().join("|")}`}return f(e)}function L(t){const n=t,e=o(t);return k.some(t=>t in n||e&&t in e)}function d(o,e){const s=t(o,e)??{},i=[];let p=!0,u=!1;for(const[t,o]of Object.entries(s))b.has(t)?(p=t===r.Design,u=!1):w.has(t)?p&&(u=j.has(t)):u&&o&&"object"==typeof o&&!t.startsWith("_")&&(c(o)||S.has(t)||g.has(t)||L(o)||"slot"!==o.type&&i.push({path:[t],kind:D(o),counted:"mobile"!==n(o)?.tier}));return i}function A(t,o,n,e,r){l({scope:n,type:e.type,label:r,rows:t(o,e),props:e.props})}function F(t,o,n,e,r,s){const c=m(n);if(!c)return null;const i=h(c,{type:e.type,rows:t(o,e),props:e.props});return{...i,message:y(i,c.sourceLabel,r,s)}}function I(t,o,n,e){A(d,t,o,n,e)}function O(t,o,n,e,r){return F(d,t,o,n,e,r)}var U={scope:t=>v(t.siteId),rows:(t,o)=>d(t,o),copy:(t,o,n,e)=>I(e,t,o,n),plan:(t,o,n,e)=>O(e,t,o,n)};function B(t,o){if(!t&&!o)return U;const n=t?.rows,e=n?(t,o)=>n(t,o):d;return{scope:t?.scope??U.scope,rows:(t,o)=>e(t,o),copy:t?.copy??((t,o,n,r)=>A(e,r,t,o,n)),plan:t?.plan??((t,n,r,s)=>F(e,s,t,n,r,o))}}export{I as copyNodeStyle,d as nodeStyleRows,O as planNodePaste,D as shopFieldKind,v as siteStyleScope,B as styleClipboardOf};
@@ -1 +0,0 @@
1
- import{useSectionOps as o}from"./chunk-X4VIDPKV.js";import{decodePartId as e,encodePartId as r}from"./chunk-IYT6NN2J.js";import{usePreviewParts as t}from"./chunk-I54UCYOU.js";import{SELECTION_MODE as n}from"./chunk-WP7AZDCV.js";import{useEasel as p}from"./chunk-KE2CXEIK.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}=p(o=>o),u=o(),{setSelectedPartId:f,setSelectHandler:k}=t(),l=d(o=>{const r=e(o);if(!r)return;const{nodeId:t,propKey:p}=r;p?(i(o=>s(o)&&o.nodeId===t&&o.propKey===p?o:{kind:"part",nodeId:t,propKey:p}),I?.(t)):i(o=>"part"===o.kind?n:o)},[i,I]);c(()=>{k(l)},[k,l]);const K=s(m)?r(m.nodeId,m.propKey):null;c(()=>{f(K)},[K,f]);return{selectNode:d(o=>{i(()=>n);const e=a(o);e&&u.select(e)},[i,a,u]),openPartId:K}}export{m as usePartBridge};
@@ -1,5 +0,0 @@
1
- import{buildPaletteSections as e,pinnedSection as t,categoryLabel as o}from"./chunk-PA3PNTVV.js";import{blockTypesIn as n}from"./chunk-5ZBY24K7.js";import{sectionTemplatesOf as s}from"./chunk-BVN33R76.js";import{SidePanelHead as i,PanelModeExit as r}from"./chunk-62VPYC7F.js";import{useEaselSession as l}from"./chunk-O7Q4DDJT.js";import{blockRuns as c}from"./chunk-HQ4VVRIC.js";import{useScreenBlockLook as a,useScreenBlockRules as p}from"./chunk-WP7AZDCV.js";import{DEFAULT_SCREEN_WORDS as m}from"./chunk-VVPZMWJE.js";import{AddPanel as d}from"./chunk-QFVRMARS.js";import{DEFAULT_DRAG_WORDS as f}from"./chunk-AYWN5NRH.js";import{useEasel as y}from"./chunk-KE2CXEIK.js";import{useWords as h}from"./chunk-MFIRYGHW.js";import{useState as u,useEffect as k,useMemo as b}from"react";import{AddIcon as g}from"efficient-shell/icons/efficient";import{jsx as j,jsxs as v,Fragment as V}from"react/jsx-runtime";var E=e=>`section:${e}`,A=e=>`block:${e}`,R=e=>`template:${e}`;function $({at:$,placeBlocks:w,canTake:C,onPick:I,itemFor:N,session:O,siteWide:P,onClose:W,onHide:x,readOnly:B}){const F=y(e=>e.config),H=a(),{labelAtLevel:T,categoryLabel:D,firstSection:L,Icon:M,Thumbnail:Y}=H,{blockIsOffered:K,canAddTo:Q}=p(),S=h("screen",m).add,Z=h("drag",f).add,z=l(),[J,G]=u([]);k(()=>{let e=!1;const t=e=>K(e,z);return s(z).list().then(o=>{if(e)return;const s=F.components;G(o.filter(e=>e.node?.type&&s[e.node.type]&&n(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[F,z]);const X=b(()=>e(F,H),[F]),q=e=>({type:E(e.type),label:e.name,cover:/* @__PURE__ */j(Y,{type:e.type}),title:e.desc?`${e.name} — ${e.desc}`:S.tile({name:e.name}),keywords:[e.alias??"",e.desc,e.type,e.catLabel].filter(Boolean)}),U=e=>{const t=e.indexOf(":"),o=e.slice(0,t),n=e.slice(t+1);if("section"===o)return{kind:"section",type:n};if("block"===o)return{kind:"block",type:n};if("template"===o){const e=J.find(e=>e.id===n);return e?{kind:"template",template:e}:null}return null},_=e=>/* @__PURE__ */j("span",{className:"es-add-glyph-cover",children:/* @__PURE__ */j(M,{type:e,size:26})}),ee=b(()=>{const e=t(X,L),n=/* @__PURE__ */new Map,s=e=>{!n.has(e.type)&&K(e.type,z)&&n.set(e.type,e)};for(const t of e?[e]:X){const e=Q(t.type)?.choices??[];e.forEach(s),e.forEach(e=>Q(e.type,1)?.choices?.forEach(s))}w?.forEach(s);const i=new Set(X.map(e=>e.type)),r=[...n.values()].filter(e=>!i.has(e.type)),l=e=>({type:A(e.type),label:e.label,cover:_(e.type),title:S.tile({name:e.label}),keywords:[e.group??"",e.type].filter(Boolean)}),a=e=>n.has(e.type)?{...q(e),cover:_(e.type)}:q(e),p=[];J.length>0&&p.push({key:"templates",title:S.templates,tiles:J.map(e=>{return{type:R(e.id),label:e.name,cover:/* @__PURE__ */j(Y,{type:e.node.type}),keywords:[(t=e.node.type,T(t,"section",F.components[t]?.label??t)),e.node.type]};var t})});const m=r.filter(e=>!e.group);let d=!1;for(const t of Object.keys(F.categories??{})){const n=X.filter(e=>e.cat===t);if(0===n.length)continue;const s=e&&n.some(t=>t.type===e.type)?e:null,i=(s?[s,...n.filter(e=>e.type!==s.type)]:n).map(a);s&&!d&&(i.splice(1,0,...m.map(l)),d=!0),p.push({key:`category:${t}`,title:o(F,t,D),tiles:i})}const f=p.find(e=>e.key?.startsWith("category:"));if(!d&&f&&m.length>0&&(f.tiles=[...f.tiles,...m.map(l)],d=!0),c(r.filter(e=>e.group||!d)).forEach((e,t)=>{p.push({key:`blocks:${t}`,title:e.group??"",tiles:e.items.map(l)})}),!C)return p;const y=p.map(e=>({...e,tiles:e.tiles.map(e=>{const t=U(e.type),o=t?C(t):null;return o?{...e,disabled:!0,disabledReason:o}:e})})),h=e=>e.tiles.some(e=>!e.disabled);return[...y.filter(h),...y.filter(e=>!h(e))]},[J,X,F,S,C,w,z]);/* @__PURE__ */
2
- return v(V,{children:[
3
- /* @__PURE__ */j(i,{icon:/* @__PURE__ */j(g,{size:15}),title:S.title,context:S.contextAll,actions:/* @__PURE__ */j(r,{label:S.done,description:S.doneDescription,onClick:W}),onHide:x}),
4
- /* @__PURE__ */v("div",{className:"sf-addside sf-scroll",children:[
5
- /* @__PURE__ */j(d,{groups:ee,session:O,itemFor:e=>N(U(e)??{kind:"section",type:e}),onInsert:I?e=>{const t=U(e);t&&I(t)}:void 0,at:$,hint:S.hint,searchLabel:S.search,readOnly:B,words:Z}),P??null]})]})}export{$ as AddSidePanel,A as blockKey,E as sectionKey,R as templateKey};
@@ -1,7 +0,0 @@
1
- import{STANDARD_MARKUP as t,writeMarkedLines as e,sameMarks as n,markedLines as l,spanFor as r,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=1e3;function w(t=200){let e=[],n=[],l=null,r=0;return{record(o,i,a){const s="type"===i&&"type"===l&&a-r<1e3;l=i,r=a,n=[],s||(e.push(o),e.length>t&&e.shift())},undo(t){const r=e.pop();return r?(n.push(t),l=null,r):null},redo(t){const r=n.pop();return r?(e.push(t),l=null,r):null},reset(){e=[],n=[],l=null}}}var D=/* @__PURE__ */new Set(["script","style","head","title","meta","link","template","noscript","svg","math","object","iframe"]),M=/* @__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 T(r,o){const i=o.rules??t,a=r.html&&""!==r.html.trim()?function(t,r,o){const i=r.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,l)=>{if(3===t.nodeType){for(const r of t.textContent??""){const t=/\s/.test(r)?" ":r,o=s();" "===t&&(0===o.length&&a.length>1||" "===o[o.length-1]?.ch)||o.push({ch:t,bold:e,italic:n,href:l})}return}if(1!==t.nodeType&&11!==t.nodeType)return;const r=t,o=1===t.nodeType?r.localName:"";if(D.has(o))return;if("br"===o)return void a.push([]);let i=e,d=n,h=l;if("b"!==o&&"strong"!==o||(i=!0),"i"!==o&&"em"!==o||(d=!0),"a"===o){const t=(r.getAttribute("href")??"").trim();h=p(t)?t:null}const f=1===t.nodeType?r.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=M.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,r){const o=e=>t.map((n,l)=>n[e]&&(" "!==n.ch||Boolean(t[l-1]?.[e])&&Boolean(t[l+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=N(t,a.bold?o("bold"):null,a.italic?o("italic"):null,a.links),s=e([i]).text;if(n([i],l(s,r)))return s}return t.map(t=>t.ch).join("")}(t,o))}(r.html,o.doc,i):(r.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 N(t,e,n,l){let o=0,i=null,a=null,s=null;return{bullet:!1,chars:t.map((t,c)=>{const u=l?t.href:null;return i=null===u?null:i&&i.href===u?i:r(++o,"link",u),a=e?.[c]?a??r(++o,"bold"):null,s=n?.[c]?s??r(++o,"italic"):null,{ch:t.ch,at:-1,marks:[i,a,s].filter(t=>null!==t)}})}}var C="application/x-efficient-markup",E=/^([0-9]{1,3})\. $/;function S(t,e){const n=t.split("\n"),r=l(t,e);let o=0,i=0;const a=r.map((t,e)=>{const l=!t.bullet&&null==t.number&&"- "===n[e],r=null!=t.number||t.bullet?null:E.exec(n[e]),a=t.bullet||l,s=r?r[1]:t.number??null,c=l||r?[]: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 l=n[t];if(e<=l.vis+l.text.length||t===n.length-1)return[l,Math.max(0,Math.min(e-l.vis,l.text.length)),t]}return[n[0],0,0]}function B(t,e){const[n,l]=A(t,e);if(0===l)return n.src;let r=0;for(const t of n.chars){if(l<=r+t.ch.length)return t.at+(l-r);r+=t.ch.length}return n.src}function L(t,e){const[n,l]=A(t,e);let r=0;for(const t of n.chars){if(l===r)return t.at;r+=t.ch.length}return B(t,e)}function R(t,e){const{lines:n}=t;let l=n[0];for(const t of n)e>=t.start&&(l=t);let r=0;for(const t of l.chars){if(!(e>=t.at+t.ch.length)){e>t.at&&(r+=e-t.at);break}r+=t.ch.length}return l.vis+r}function W(t,e,n){return[R(t,e),R(t,n)]}function j(t,e,n){return e===n?[B(t,e),B(t,e)]:[L(t,e),B(t,n)]}function P(t,e){let n=0;for(let l=0;l<t.chars.length;l+=1){if(n>=e)return l;n+=t.chars[l].ch.length}return t.chars.length}function K(t,o,i,a,s){const c=S(t,o),[u,d,h]=A(c,Math.min(i,a)),[f,p,m]=A(c,Math.max(i,a)),g=P(u,d),b=P(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],l=t.chars[e],r=(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&&l?.marks.some(e=>e.id===t.id));return r(n.marks,e)}return l?r(l.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=l(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,l)=>(l>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"),r={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 r.chars.push(...v);return{lines:[...c.lines.slice(0,h).map(({bullet:t,number:e,chars:n})=>({bullet:t,number:e,chars:n})),r,...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=r(x++,t);n&&(e=[...e,n])}if(void 0!==s.color){e=e.filter(t=>"color"!==t.kind);const t=null===s.color?null:r(x++,"color",s.color);t&&(e=[...e,t])}return e})(y),y,[]];let T="",N="";for(const t of M){const l=D(t),r=e(l.lines).text;if(T=r,N=l.shown,n(l.lines,S(r,o).lines))break}return{text:T,caret:Math.min(i,a)+N.length}}function V(t,e,n,l){const r=S(t,e),[o,,i]=A(r,n);return n!==l||!o.bullet&&null==o.number||""!==o.text?K(t,e,n,l,{text:"\n"}):q(t,e,i,!1,n)}function q(t,n,l,r,o){const i=S(t,n).lines.map(({bullet:t,number:e,chars:n},o)=>o===l?{bullet:r,number:null,chars:n}:{bullet:t,number:e,chars:n});return{text:e(i).text,caret:o}}function F(t,n,l,r){const o=S(t,n),[i,a,s]=A(o,Math.min(l,r)),[c,u,d]=A(o,Math.max(l,r)),h=o.lines.slice(s,d+1).map(({bullet:t,number:e,chars:n},l)=>{const r=0===l?P(i,a):0,o=l===d-s?P(c,u):n.length;return{bullet:t,number:e,chars:n.slice(r,o)}});return e(h).text}function I(t,e,n){if(n<0){const n=t.charCodeAt(e-1);return e-(n>=56320&&n<=57343&&e>=2?2:1)}const l=t.charCodeAt(e);return e+(l>=55296&&l<=56319?2:1)}function O(t){const{value:e,rules:n,multiline:l,inputType:r,pending:o}=t;let[i,a]=t.sel;t.target&&t.target[0]!==t.target[1]&&r.startsWith("delete")&&([i,a]=t.target);const s=[i,a];if("historyUndo"===r||"historyRedo"===r)return{kind:"history",dir:"historyUndo"===r?"undo":"redo"};if("formatBold"===r||"formatItalic"===r||"formatStrikeThrough"===r)return{kind:"format",style:"formatBold"===r?"bold":"formatItalic"===r?"italic":"strike"};if("insertParagraph"===r||"insertLineBreak"===r)return l?{kind:"edit",edit:V(e,n,i,a),range:s}:null;if(r.startsWith("insert")){if("insertTranspose"===r)return null;let c=t.data??"";if("insertFromDrop"===r||"insertFromPaste"===r){const r=T({html:t.html??void 0,text:c},{doc:t.doc,multiline:l,rules:n});return{kind:"edit",edit:K(e,n,i,a,{markup:r}),range:s}}return l||(c=c.replace(/\s*\r?\n\s*/g," ")),{kind:"type",edit:K(e,n,i,a,{text:c,add:o?.add,drop:o?.drop,color:o?.color}),range:s}}if(r.startsWith("delete")){const t=S(e,n),l=t.text;if(i===a){const o=r.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:q(e,n,c,!1,i),range:s};if(o?0===i:i===l.length)return null;o?i=I(l,i,-1):a=I(l,a,1)}return{kind:"type",edit:K(e,n,i,a,{text:""}),range:[i,a]}}return null}var z={sup:"sub",sub:"sup"};function U(t){const{value:e,rules:n,start:l,end:r,style:a,pending:s}=t,c=z[a];if(l===r){const t=o(e,l,r,n),i=s&&s.at===l?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:l}:null}}let u=e,d=l,h=r;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 $=/^(block|list-item|flex|grid|table|flow-root)$/;function H(t){const e=t.ownerDocument.defaultView;return!!e&&$.test(e.getComputedStyle(t).display)}function X(t,e){const n=[],l=/* @__PURE__ */new Map,r=/* @__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(),l.set(c,o.length),n.push({node:c,start:o.length,length:c.data.length}),o+=c.data,r.set(c,o.length);continue}if(1!==c.nodeType)continue;const t=c;if(e&&t.matches(e)){l.set(t,o.length),r.set(t,o.length);continue}if("BR"===t.tagName){a(),l.set(t,o.length),o+="\n",r.set(t,o.length);continue}const u=H(t);u&&((i||o.length>0&&!o.endsWith("\n"))&&(o+="\n"),i=!1),l.set(t,o.length);const d=o.length;s(t),u&&o.length===d&&!i&&n.push({node:t,start:d,length:0}),r.set(t,o.length),u&&(i=!0)}};l.set(t,0),s(t),r.set(t,o.length);return{text:o,at:(t,e)=>{if(3===t.nodeType)return(l.get(t)??0)+Math.min(e,t.data.length);const n=t.childNodes;return e<n.length?l.get(n[e])??r.get(t)??0:r.get(t)??o.length},dom:e=>{for(let t=0;t<n.length;t+=1){const l=n[t],r=l.start+l.length;if(e<l.start)return[l.node,0];if(e<r||e===r&&(t===n.length-1||n[t+1].start>e))return 3===l.node.nodeType?[l.node,e-l.start]:[l.node,0]}const l=n[n.length-1];return l?3===l.node.nodeType?[l.node,l.length]:[l.node,0]:[t,0]}}}function Y(t){const e=t.element();if(!e)return null;let n=t.value;const l=t.rules;if(X(e,t.skip).text!==S(n,l).text)return null;const r=t.now??(()=>Date.now()),i=w();let p=e,m=!1,g=null,b=null,k=[t.caret[0],t.caret[1]],v=null,y=!1,x=!1;const D=()=>{x||t.onSelect?.()},M={contenteditable:e.getAttribute("contenteditable"),spellcheck:e.getAttribute("spellcheck")},N=()=>p.ownerDocument,E=()=>N().defaultView?.getSelection()??null,A=()=>{if(!b)return!0;nt();const e=X(p,t.skip);if(e.text!==S(n,l).text)return!1;const[r,o]=b,[i,a]=e.dom(r),[s,c]=e.dom(o);return y||N().activeElement===p||p.focus({preventScroll:!0}),E()?.setBaseAndExtent(i,a,s,c),k=b,B=b,b=null,D(),!0};let B=null;const L=()=>{if(!B)return!1;const t=E(),e=t?.anchorNode??null;return!(e&&e.isConnected&&p.contains(e))||e===p&&0===t.anchorOffset&&(0!==B[0]||0!==B[1])},R=()=>{b=B,A()},P=()=>{A(),N().activeElement===p&&L()&&R();const e=E();if(!(e&&e.anchorNode&&e.focusNode&&p.contains(e.anchorNode)&&p.contains(e.focusNode)))return k;const n=X(p,t.skip),l=n.at(e.anchorNode,e.anchorOffset),r=n.at(e.focusNode,e.focusOffset);return k=l<=r?[l,r]:[r,l],k},V=t=>{const e=N().defaultView;t<=0||!e?B=null:e.requestAnimationFrame(()=>{m||b||(nt(),N().activeElement===p?(L()&&(R(),D()),V(t-1)):B=null)})},q=(t,e)=>{b=[t,e];const n=t=>{if(m)return;if(A())return void V(3);const e=N().defaultView;t>0&&e&&e.requestAnimationFrame(()=>n(t-1))};n(30)},I=(e,l,o)=>{e.text!==n?(i.record({text:n,start:l[0],end:l[1]},o,r()),n=e.text,t.write(n),q(e.caret,e.caret),D()):q(e.caret,e.caret)},z=t=>j(S(n,l),t[0],t[1]),$=(e,o)=>{if(e.text===n)return;i.record({text:n,start:o[0],end:o[1]},"edit",r()),n=e.text,t.write(n);const[a,s]=W(S(n,l),e.selectionStart,e.selectionEnd);q(a,s),D()},H=t=>{if(m)return;const e=P(),[r,o]=z(e),i=U({value:n,rules:l,start:r,end:o,style:t,pending:v});if("pending"===i.kind)return v=i.pending,void D();$(i.result,e)},Y=e=>{n=e.text,t.write(n),q(e.start,e.end)},Z=e=>{m||(m=!0,lt.removeEventListener("selectionchange",rt),et(p),t.end(e))},G=(t,e)=>{const r=P();!m&&r[0]!==r[1]&&t.clipboardData&&(t.preventDefault(),t.clipboardData.setData("text/plain",S(n,l).text.slice(r[0],r[1])),t.clipboardData.setData(C,F(n,l,r[0],r[1])),e&&I(K(n,l,r[0],r[1],{text:""}),r,"edit"))},J=t=>t.preventDefault(),Q=()=>{t.remount?.()},_=[["keydown",e=>{if(m||e.isComposing)return;const l=e.metaKey||e.ctrlKey;if("Escape"!==e.key){if(l&&!e.altKey&&!e.shiftKey&&("k"===e.key||"K"===e.key)&&t.onLinkKey?.())return e.preventDefault(),void e.stopPropagation();if("Enter"===e.key&&(!e.shiftKey||l))return e.preventDefault(),e.stopPropagation(),void Z("enter");if(l&&("z"===e.key||"Z"===e.key||"y"===e.key)){e.preventDefault(),e.stopPropagation();const t=P(),l={text:n,start:t[0],end:t[1]},r="y"===e.key||e.shiftKey?i.redo(l):i.undo(l);r&&Y(r)}}else{if(e.preventDefault(),e.stopPropagation(),t.onEscape?.())return;Z("escape")}}],["beforeinput",e=>{if(m)return;if("insertCompositionText"===e.inputType)return;e.preventDefault();const r=P(),o=X(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=O({value:n,rules:l,multiline:t.multiline,inputType:e.inputType,data:e.data??e.dataTransfer?.getData("text/plain")??"",html:e.dataTransfer?.getData("text/html"),doc:N(),sel:r,target:s,pending:v&&v.at===z(r)[0]?v:null});if(c){if("type"!==c.kind&&"edit"!==c.kind||(v=null),"history"===c.kind){const t={text:n,start:r[0],end:r[1]},e="undo"===c.dir?i.undo(t):i.redo(t);return void(e&&Y(e))}"format"!==c.kind?I(c.edit,c.range,c.kind):H(c.style)}}],["compositionstart",()=>{g=P()}],["compositionend",e=>{const o=g;if(g=null,!m&&o)if(e.data){const a=K(n,l,o[0],o[1],{text:e.data});i.record({text:n,start:o[0],end:o[1]},"type",r()),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 r=P(),o=e.clipboardData,i=o?.getData(C)??"",a=i?t.multiline?i:i.replace(/\s*\r?\n\s*/g," "):T({html:o?.getData("text/html")??"",text:o?.getData("text/plain")??""},{doc:N(),multiline:t.multiline,rules:l});I(K(n,l,r[0],r[1],{markup:a}),r,"edit")}],["copy",t=>G(t,!1)],["cut",t=>G(t,!0)],["drop",J],["dragstart",J],["blur",e=>{if(m||null!==g||y)return;const n=e.target,l=n.ownerDocument.defaultView,r=()=>{m||(n.isConnected&&n===t.element()?y||n.ownerDocument.activeElement===n||Z("blur"):q(k[0],k[1]))};l?.requestAnimationFrame?l.requestAnimationFrame(r):setTimeout(r,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 lt=p.ownerDocument;function rt(){m||D()}return lt.addEventListener("selectionchange",rt),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=S(t,l).text.length,[r,o]=P();n=t,i.reset(),q(Math.min(r,e),Math.min(o,e))},stop(t="stop"){Z(t)},pressed(){let t;x=!0;try{t=P()}finally{x=!1}const[e,r]=z(t),i=o(n,e,r,l),s={};for(const t of["bold","italic","underline","strike","sup","sub","link"]){const n=i.has(t),l=v&&v.at===e?v:null;s[t]=!!l?.add.includes(t)||!l?.drop.includes(t)&&n}const c=v&&v.at===e&&void 0!==v.color?v:null;return{marks:s,list:a(n,e,r,l),selected:r>e,href:f(n,e,r)?.href??null,color:c?c.color??null:h(n,e,r,l)}},press:H,insert(t){if(m)return;y=!1;const e=P(),[l,r]=z(e),o=l+t.length;$({text:n.slice(0,l)+t+n.slice(r),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(),[r,o]=z(e),i=null===t?u(n,r,o,l):d(n,r,o,t,l),a=i.text===n;$(i,e),nt(),p.focus({preventScroll:!0}),a&&q(e[0],e[1])},color(t){if(m)return;const e=P(),[r,o]=z(e);if(r===o){const e=v&&v.at===r?v:null;return v={add:e?.add??[],drop:e?.drop??[],color:t,at:r},void D()}$(c(n,r,o,t,l),e)},list(e){if(m||!t.multiline)return;const r=P(),[o,i]=z(r),c=a(n,o,i,l);$(s(n,o,i,c===e?null:e,l),r)}}}var Z=t=>t.preventDefault();function G(t,e){if(t)return t.startsWith("#")?t:e?.find(e=>e.name===t)?.value}function J({colors:t,current:e,words:n,onPick:l}){const r=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:()=>l(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:r??"",onChange:t=>{t!==e&&l(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:()=>l(null),children:n.remove})})]})}var Q=(t,e,n)=>Math.min(Math.max(t,e),Math.max(e,n));function _({anchor:t,size:e,within:n,clip:l,parent:r,gap:o=8}){const i=Math.max(n.left,l.left),a=Math.min(n.right,l.right)-e.width,s=Q(t.left,i,a),c=l.bottom-(t.bottom+o),u=t.top-o-l.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-r.top,left:s-r.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 l=e.getBoundingClientRect();return{left:l.left,top:l.top,right:l.left,bottom:l.bottom}}function nt(t){const e=t.ownerDocument,n=e.documentElement,l={left:0,top:0,right:n.clientWidth,bottom:n.clientHeight},r=e.defaultView?.getComputedStyle.bind(e.defaultView);for(let o=t.parentElement;o&&o!==n&&o!==e.body;o=o.parentElement){const t=r?.(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;l.left=Math.max(l.left,n),l.top=Math.max(l.top,i),l.right=Math.min(l.right,n+(o.clientWidth||e.width)),l.bottom=Math.min(l.bottom,i+(o.clientHeight||e.height))}return l}function lt(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 rt(t,e,n){const l=t.ownerDocument,r=l.createTreeWalker(t,4),o=t=>{let e=t,n=null;for(let t=r.nextNode();t;t=r.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);r.currentNode=t;const a=o(n);if(!i||!a)return null;const s=l.createRange();return s.setStart(i[0],i[1]),s.setEnd(a[0],a[1]),s}export{J as ColorWindow,C as MARKUP_CLIPBOARD_TYPE,x as TYPING_BURST_MS,G as colorRunOf,w as createHistory,K as editVisible,U as markPress,F as markupOfRange,V as newLine,lt as offsetOrigin,T as pasteToMarkup,_ as placeWindow,O as richInput,S as richLayout,et as selectionBox,j as selectionToSource,W as selectionToVisible,q as setBullet,Y as startCanvasTyping,X as textMap,rt as textRange,B as toSource,L as toSourceStart,R as toVisible,nt as visibleArea};
@@ -1,5 +0,0 @@
1
- import{slotFieldsOf as n}from"./chunk-PLVEGYK6.js";import{usePickFollowsSelection as e}from"./chunk-R6WTQWAC.js";import{Inspector as t}from"./chunk-2SOOKBHH.js";import{EaselCanvas as r,useSelectedFields as i}from"./chunk-KE2CXEIK.js";import{createContext as o,useContext as u}from"react";import{DesktopIcon as l}from"efficient-shell/icons/efficient";import{jsx as s}from"react/jsx-runtime";var c={kind:"puck"};function f(n,e){const t=n,r=e,i=Object.keys(t);return i.length===Object.keys(r).length&&i.every(n=>Object.is(t[n],r[n]))}function a(n){const e=n;return"string"==typeof e.nodeId&&"string"==typeof e.slot}function d(e,t,r){const i=e.slotsOf?.(r);return i||n(t,r.type).map(n=>({slot:n,label:n,rung:!1}))}function p(n,e){return n.isFirst?n.isFirst(e):e.type===n.first}function m(n,e){return n.isLast?n.isLast(e):e.type===n.last}var k={},h=()=>k,v=()=>"",g=()=>null,y=()=>{},b={isLockedBlock:()=>!1,duplicateBlocked:()=>null,nestDepth:()=>0,newSectionNode:()=>null,canAddTo:()=>null,blockIsOffered:()=>!0},O={labelAtLevel:(n,e,t)=>t,descriptions:{},categoryLabel:()=>{},firstSection:null,blockRowName:(n,e)=>e(n.type),plainText:n=>n,Icon:()=>null,Thumbnail:()=>null,useProducts:()=>null},j={options:[{id:"desktop",label:"Desktop",icon:/* @__PURE__ */s(l,{})}],initial:"desktop",fluid:"desktop",widths:{desktop:2e3}},w={read:()=>"sections",write:()=>{},forSelection:(n,e)=>n?"sections":e},L={first:null,last:null,firstGroup:null,lastGroup:null,isSectionGroup:()=>!1,sectionGroupZone:()=>"",panelOf:()=>null};function S(){/* @__PURE__ */
2
- return s(r,{height:"fill"})}function C(){const{id:n,fields:e,values:r,readOnly:o,onChange:u}=i();/* @__PURE__ */
3
- return s("div",{className:"es-sidepanel es-sidepanel--right",children:/* @__PURE__ */s(t,{fields:e,values:r,onChange:u,readOnly:o,idPrefix:n})})}var P=o({});function B({parts:n,children:e}){/* @__PURE__ */
4
- return s(P.Provider,{value:n,children:e})}function D(){return u(P)}function G(){return(D().useOwnerName??v)()}function I(){return(D().useDocumentLabel??g)()}function K(n,e,t,r){return(D().useBridges??h)(n,e,t,r)}function N(n){return(D().useStandaloneBridges??h)(n)}function x(n,e){(D().useDocumentPass??y)(n,e)}function T(){return D().blockRules??b}function A(){return D().blockLook??O}function E(){return D().devices??j}function F(){return D().leftView??w}function H(){return D().pinned??L}function R(){return D().saveSwitch??!0}function V(n){e(!0===D().pickFollowsSelection,n)}function W(){return D().storageNamespace||void 0}function Q(){return D().styleClipboard??null}function X(){return D().nodeKeys??!0}function Y(){return D().notify??null}function Z(){return D().Canvas??S}function q(){return D().CanvasHead??null}function z(){return D().canvasDrag??null}var J=o(null);function M({target:n,children:e}){/* @__PURE__ */
5
- return s(J.Provider,{value:n,children:e})}function U(){return u(J)}function $(){return D().Inspector??C}export{c as SELECTION_MODE,M as ScreenCanvasTargetProvider,B as ScreenPartsProvider,p as isPinnedFirst,m as isPinnedLast,a as isSlotMode,f as sameInspectorMode,d as screenSlotsOf,A as useScreenBlockLook,T as useScreenBlockRules,K as useScreenBridges,z as useScreenCanvasDrag,Z as useScreenCanvasFrame,q as useScreenCanvasHead,U as useScreenCanvasTarget,E as useScreenDevices,I as useScreenDocumentLabel,x as useScreenDocumentPass,$ as useScreenInspectorPanel,F as useScreenLeftView,X as useScreenNodeKeys,Y as useScreenNotify,G as useScreenOwnerName,D as useScreenParts,V as useScreenPickFollowsSelection,H as useScreenPinned,R as useScreenSaveSwitch,W as useScreenStorageNamespace,Q as useScreenStyleClipboard,N as useStandaloneScreenBridges};
@@ -1,7 +0,0 @@
1
- import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenStoreProvider as n}from"./chunk-CZYR5V77.js";import{ScreenChrome as e}from"./chunk-5R7FE4VT.js";import{ScreenDocumentProvider as i,useScreenDocument as a}from"./chunk-47JTYRQC.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-VVPZMWJE.js";import{documentPermissions as s}from"./chunk-THWO5YVZ.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{useMemo as t,useState as d,useRef as l,useEffect as m,useCallback as g}from"react";import{Dialog as h,Button as f}from"efficient-shell/ui";import{jsx as u,jsxs as p,Fragment as v}from"react/jsx-runtime";var C=r(n),k=r(e);function j({onCancel:r,onDiscard:n,onSave:e}){const i=c("screen",o).leave,[a,s]=d(!1),t=l(!0);m(()=>(t.current=!0,()=>{t.current=!1}),[]);const C=g(async()=>{s(!0);try{await e()}finally{t.current&&s(!1)}},[e]);/* @__PURE__ */
2
- return u(h,{open:!0,role:"alertdialog",size:"sm",title:i.title,onClose:r,footer:/* @__PURE__ */p(v,{children:[
3
- /* @__PURE__ */u(f,{variant:"secondary",onClick:r,children:i.cancel}),
4
- /* @__PURE__ */u(f,{variant:"ghost-danger",onClick:n,children:i.discard}),
5
- /* @__PURE__ */u(f,{variant:"primary",loading:a,onClick:()=>{C()},children:i.save})]}),children:i.body})}function y({target:r,addressing:n,onHostMessage:e,children:a}){/* @__PURE__ */
6
- return u(i,{target:r,addressing:n,onHostMessage:e,children:a})}var N=(r,n)=>/* @__PURE__ */p(v,{children:[r,n]});function V({config:r,parts:n,wrap:e=N}){const{data:i,error:d,redirecting:l,ready:m,readOnly:g,onChange:h,pendingNav:f,cancelPendingNav:p,discardAndNavigate:v,saveAndNavigate:y}=a(),V=t(()=>s(!g),[g]),H=c("screen",o);return l?/* @__PURE__ */u("div",{className:"sf-msg",children:H.loading}):d?/* @__PURE__ */u("div",{className:"sf-msg sf-msg--error",children:d}):m?i?e(
7
- /* @__PURE__ */u(C,{config:r,data:i,onChange:h,permissions:V,parts:n,children:/* @__PURE__ */u(k,{})}),f&&/* @__PURE__ */u(j,{onCancel:p,onDiscard:v,onSave:y})):/* @__PURE__ */u("div",{className:"sf-msg",children:H.loading}):/* @__PURE__ */u("div",{className:"sf-msg",children:H.waitingForAuthorization})}export{V as DocumentScreen,y as ScreenMount};