efficient-easel 7.1.0 → 7.2.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 (44) hide show
  1. package/README.md +8 -0
  2. package/dist/{chunk-HKQB5ITX.js → chunk-2AAJCKCB.js} +1 -1
  3. package/dist/{chunk-CCIBI2BA.js → chunk-3PASGRBK.js} +1 -1
  4. package/dist/{chunk-WF5IIVDD.js → chunk-AWKOTOE6.js} +5 -5
  5. package/dist/{chunk-LRB6UP6D.js → chunk-CLWYUKUO.js} +3 -3
  6. package/dist/chunk-GZH4UVDH.js +8 -0
  7. package/dist/chunk-HUTO5ZIL.js +5 -0
  8. package/dist/{chunk-XY5AE7DQ.js → chunk-JVTSUA2U.js} +1 -1
  9. package/dist/{chunk-5POZQNAJ.js → chunk-LC62L4P2.js} +1 -1
  10. package/dist/{chunk-RKOWJG5O.js → chunk-MUUPE34I.js} +1 -1
  11. package/dist/chunk-NCMQD4P6.js +5 -0
  12. package/dist/{chunk-VGTNT6UW.js → chunk-PH3GWKS2.js} +1 -1
  13. package/dist/{chunk-5WKEKFMB.js → chunk-U2SECYQB.js} +1 -1
  14. package/dist/chunk-UCLVWF5E.js +21 -0
  15. package/dist/{chunk-3QGESV36.js → chunk-UJZGOO3D.js} +43 -43
  16. package/dist/{chunk-6F2SGZ7F.js → chunk-XC36V42X.js} +1 -1
  17. package/dist/copy/index.js +7 -7
  18. package/dist/easel/easel.css +6 -0
  19. package/dist/easel/index.js +1 -1
  20. package/dist/fields/index.d.ts +52 -40
  21. package/dist/fields/index.js +1 -1
  22. package/dist/panel/index.d.ts +16 -2
  23. package/dist/panel/index.js +1 -1
  24. package/dist/panel/panel.css +16 -0
  25. package/dist/screen/components/AddBlockRow.js +1 -1
  26. package/dist/screen/components/AddSidePanel.js +1 -1
  27. package/dist/screen/components/MediaSidePanel.js +1 -1
  28. package/dist/screen/components/NodeContextMenu.js +1 -1
  29. package/dist/screen/components/ScreenChrome.js +1 -1
  30. package/dist/screen/components/ScreenMount.js +1 -1
  31. package/dist/screen/components/ScreenStoreProvider.js +1 -1
  32. package/dist/screen/components/SectionScreenShell.js +16 -16
  33. package/dist/screen/components/usePartBridge.js +1 -1
  34. package/dist/screen/index.js +1 -1
  35. package/dist/screen/lib/key-scope.js +1 -1
  36. package/dist/screen/lib/puck/use-section-ops.js +1 -1
  37. package/dist/screen/lib/screen-parts.js +1 -1
  38. package/dist/strings/catalogue.js +1 -1
  39. package/dist/strings/index.js +1 -1
  40. package/package.json +1 -1
  41. package/dist/chunk-3ZJSLHHI.js +0 -8
  42. package/dist/chunk-PG3QGGTU.js +0 -5
  43. package/dist/chunk-POBSVKN7.js +0 -5
  44. package/dist/chunk-UCAM256Q.js +0 -21
@@ -1,62 +1,62 @@
1
- import{dedupeSlotChildren as e}from"./chunk-26OOWIJJ.js";import{styleClipboardOf as n}from"./chunk-MVQEEWTE.js";import{markedTreeNodeId as t,revealSelectedTreeRow as o,sameSelector as r}from"./chunk-FGNR22NY.js";import{cloneNodeWithFreshIds as i}from"./chunk-2GVCAIPX.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,editorRootFocus as m}from"./chunk-HKQB5ITX.js";import{SlotChildActionsProvider as g}from"./chunk-KCBEE2MC.js";import{screenStorageKeys as y,DEFAULT_PANEL_W as k,clampPanelWidth as S}from"./chunk-6TOYXESC.js";import{usePartBridge as v}from"./chunk-CCIBI2BA.js";import{useSectionOps as x}from"./chunk-RKOWJG5O.js";import{useNodeClipboard as w,useNodeContextMenu as b}from"./chunk-5POZQNAJ.js";import{PageEditGuardNotices as z}from"./chunk-E4MAYJX5.js";import{useScreenDocument as B}from"./chunk-64ZRPAWS.js";import{requestMediaPick as C}from"./chunk-KG7RJWOK.js";import{heldStyle as O,styleShortcut as I}from"./chunk-V7U33NF2.js";import{AddChildRow as N}from"./chunk-5545A3PC.js";import{AddSidePanel as $}from"./chunk-POBSVKN7.js";import{SidePanelHead as P,PanelShowStrip as T}from"./chunk-PFNIVZPN.js";import{MediaSidePanel as A}from"./chunk-5WKEKFMB.js";import{useScreenSaveSwitch as M,useScreenNodeKeys as j,useScreenPinned as R,useScreenDocumentLabel as E,useScreenCanvasFrame as L,useScreenInspectorPanel as V,useScreenDevices as F,useScreenPickFollowsSelection as W,useScreenLeftView as H,useScreenAdd as D,SELECTION_MODE as U,sameInspectorMode as G,useScreenBridges as J,useScreenBlockRules as K,useScreenBlockLook as Y,useScreenStorageNamespace as X,useScreenNotify as Q,useScreenCanvasHead as _,isSlotMode as Z,useScreenStyleClipboard as q,useScreenDocumentPass as ee,useScreenCanvasDrag as ne,ScreenCanvasTargetProvider as te,isPinnedFirst as oe,isPinnedLast as re,screenSlotsOf as ie}from"./chunk-PG3QGGTU.js";import{ROOT_ZONE as le,blockNodeActions as se,TREE_MAX_DEPTH as de,childSlotsOf as ce,slotFieldsOf as ae,slotChildrenIn as pe,nestsInTree as ue,newNodeId as fe}from"./chunk-PLVEGYK6.js";import{useMediaPanel as he,usePanelPick as me,useCancelPanelPick as ge}from"./chunk-R6WTQWAC.js";import{useEaselHost as ye,useHostEscape as ke}from"./chunk-U3JP4VGF.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as Se}from"./chunk-6WY6ZXJG.js";import{DEFAULT_NODE_MENU_WORDS as ve}from"./chunk-WK3AFPXY.js";import{DEFAULT_SCREEN_WORDS as xe}from"./chunk-5F3PKNT7.js";import{useEasel as we,useEaselApi as be}from"./chunk-WF5IIVDD.js";import{toItemSelector as ze,useNodeOps as Be,clickPick as Ce}from"./chunk-SOZUYCQZ.js";import{TreeRow as Oe,Subtree as Ie,LayersTree as Ne,TreeGroupLabel as $e,TreeRowAction as Pe,TreeSeam as Te}from"./chunk-4JSBIW5H.js";import{DEFAULT_TREE_WORDS as Ae}from"./chunk-K56YDHYQ.js";import{LayersIcon as Me,MediaIcon as je}from"./chunk-4VJATVVR.js";import{DEFAULT_SAVE_WORDS as Re,saveIndicator as Ee}from"./chunk-H6DDIBQ4.js";import{EaselTopBar as Le,TopBarRail as Ve,TopBarCluster as Fe,EaselIconButton as We,TopBarDivider as He,DeviceSwitch as De,InspectorIconButton as Ue,PanelResizeHandle as Ge,MAX_PANEL_W as Je,MIN_PANEL_W as Ke,panelWidthVars as Ye,SaveState as Xe,SaveStateToggle as Qe}from"./chunk-UB4TLWVJ.js";import{DEFAULT_CHROME_WORDS as _e}from"./chunk-Y2G7CU6A.js";import{useWords as Ze}from"./chunk-MFIRYGHW.js";import{insertSeams as qe,CanvasDragLayer as en,CanvasInsert as nn}from"./chunk-SSORUDHE.js";import{DEFAULT_DRAG_WORDS as tn}from"./chunk-O2NLQBFX.js";import{createDragSession as on,useTreeDrag as rn,gapToMoveIndex as ln}from"./chunk-67GNT6PF.js";import{useCanvasFrame as sn,LIST_SELECTOR as dn,BLOCK_SELECTOR as cn,useCanvasEvent as an}from"./chunk-AWJUYMX7.js";import{zoneKey as pn,ROOT_ID as un,ROOT_SLOT as fn,parseZoneKey as hn,find as mn,DataError as gn}from"./chunk-KRXQM65X.js";import{useRef as yn,useMemo as kn,useState as Sn,useEffect as vn,useCallback as xn,useLayoutEffect as wn,Fragment as bn}from"react";import{Tooltip as zn,Button as Bn,toast as Cn}from"efficient-shell/ui";import{UndoIcon as On,RedoIcon as In,TrashIcon as Nn,EyeOffIcon as $n,EyeIcon as Pn,DuplicateIcon as Tn}from"efficient-shell/icons/efficient";import{jsx as An,jsxs as Mn,Fragment as jn}from"react/jsx-runtime";function Rn({saveState:e,notSaving:n,readOnlyReason:t,toggle:o,onToggle:r,onRetry:i,words:l,saveWords:s}){if(null!==t)/* @__PURE__ */return An(Xe,{tone:"off",label:t,role:"status"});if(n)/* @__PURE__ */
2
- return An(Xe,{tone:e.pending?"off-unsaved":"off",label:l.notSaving,role:"status"});const{tone:d,label:c}=Ee(e,s),a=e.failed&&!e.paused&&/* @__PURE__ */An(Bn,{variant:"secondary",size:"sm",onClick:i,children:l.retry});/* @__PURE__ */
1
+ import{dedupeSlotChildren as e}from"./chunk-26OOWIJJ.js";import{styleClipboardOf as n}from"./chunk-MVQEEWTE.js";import{markedTreeNodeId as t,revealSelectedTreeRow as o,sameSelector as r}from"./chunk-FGNR22NY.js";import{cloneNodeWithFreshIds as i}from"./chunk-2GVCAIPX.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,editorRootFocus as m}from"./chunk-2AAJCKCB.js";import{SlotChildActionsProvider as g}from"./chunk-KCBEE2MC.js";import{screenStorageKeys as y,DEFAULT_PANEL_W as k,clampPanelWidth as S}from"./chunk-6TOYXESC.js";import{usePartBridge as v}from"./chunk-3PASGRBK.js";import{useSectionOps as x}from"./chunk-MUUPE34I.js";import{useNodeClipboard as w,useNodeContextMenu as b}from"./chunk-LC62L4P2.js";import{PageEditGuardNotices as z}from"./chunk-E4MAYJX5.js";import{useScreenDocument as B}from"./chunk-64ZRPAWS.js";import{requestMediaPick as C}from"./chunk-KG7RJWOK.js";import{heldStyle as O,styleShortcut as I}from"./chunk-V7U33NF2.js";import{AddChildRow as N}from"./chunk-5545A3PC.js";import{AddSidePanel as P}from"./chunk-NCMQD4P6.js";import{SidePanelHead as $,PanelShowStrip as T}from"./chunk-PFNIVZPN.js";import{MediaSidePanel as A}from"./chunk-U2SECYQB.js";import{useScreenSaveSwitch as M,useScreenNodeKeys as j,useScreenPinned as E,useScreenDocumentLabel as R,useScreenCanvasFrame as L,useScreenInspectorPanel as V,useScreenDevices as F,useScreenPickFollowsSelection as H,useScreenLeftView as W,useScreenAdd as U,SELECTION_MODE as D,sameInspectorMode as G,useScreenBridges as J,useScreenBlockRules as Y,useScreenBlockLook as K,useScreenStorageNamespace as X,useScreenNotify as Q,useScreenCanvasHead as _,isSlotMode as Z,useScreenStyleClipboard as q,useScreenDocumentPass as ee,useScreenCanvasDrag as ne,ScreenCanvasTargetProvider as te,isPinnedFirst as oe,isPinnedLast as re,screenSlotsOf as ie}from"./chunk-HUTO5ZIL.js";import{ROOT_ZONE as le,blockNodeActions as se,TREE_MAX_DEPTH as de,childSlotsOf as ce,slotFieldsOf as ae,slotChildrenIn as pe,nestsInTree as ue,newNodeId as fe}from"./chunk-PLVEGYK6.js";import{useMediaPanel as he,usePanelPick as me,useCancelPanelPick as ge}from"./chunk-R6WTQWAC.js";import{useEaselHost as ye,useHostEscape as ke}from"./chunk-U3JP4VGF.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as Se}from"./chunk-6WY6ZXJG.js";import{DEFAULT_SCREEN_WORDS as ve}from"./chunk-5F3PKNT7.js";import{useEasel as xe,useEaselApi as we}from"./chunk-AWKOTOE6.js";import{TreeRow as be,Subtree as ze,LayersTree as Be,TreeGroupLabel as Ce,TreeRowAction as Oe,TreeSeam as Ie}from"./chunk-4JSBIW5H.js";import{DEFAULT_TREE_WORDS as Ne}from"./chunk-K56YDHYQ.js";import{DEFAULT_NODE_MENU_WORDS as Pe}from"./chunk-WK3AFPXY.js";import{toItemSelector as $e,useNodeOps as Te,clickPick as Ae}from"./chunk-SOZUYCQZ.js";import{LayersIcon as Me,MediaIcon as je}from"./chunk-4VJATVVR.js";import{DEFAULT_SAVE_WORDS as Ee,saveIndicator as Re}from"./chunk-H6DDIBQ4.js";import{EaselTopBar as Le,TopBarRail as Ve,TopBarCluster as Fe,EaselIconButton as He,TopBarDivider as We,DeviceSwitch as Ue,InspectorIconButton as De,PanelResizeHandle as Ge,MAX_PANEL_W as Je,MIN_PANEL_W as Ye,panelWidthVars as Ke,SaveState as Xe,SaveStateToggle as Qe}from"./chunk-UB4TLWVJ.js";import{DEFAULT_CHROME_WORDS as _e}from"./chunk-Y2G7CU6A.js";import{useWords as Ze}from"./chunk-MFIRYGHW.js";import{insertSeams as qe,CanvasDragLayer as en,CanvasInsert as nn}from"./chunk-SSORUDHE.js";import{DEFAULT_DRAG_WORDS as tn}from"./chunk-O2NLQBFX.js";import{createDragSession as on,useTreeDrag as rn,gapToMoveIndex as ln}from"./chunk-67GNT6PF.js";import{useCanvasFrame as sn,LIST_SELECTOR as dn,BLOCK_SELECTOR as cn,useCanvasEvent as an}from"./chunk-AWJUYMX7.js";import{zoneKey as pn,ROOT_ID as un,ROOT_SLOT as fn,parseZoneKey as hn,find as mn,DataError as gn}from"./chunk-KRXQM65X.js";import{useRef as yn,useMemo as kn,useState as Sn,useEffect as vn,useCallback as xn,useLayoutEffect as wn,Fragment as bn}from"react";import{Tooltip as zn,Button as Bn,toast as Cn}from"efficient-shell/ui";import{UndoIcon as On,RedoIcon as In,TrashIcon as Nn,EyeOffIcon as Pn,EyeIcon as $n,DuplicateIcon as Tn}from"efficient-shell/icons/efficient";import{jsx as An,jsxs as Mn,Fragment as jn}from"react/jsx-runtime";function En({saveState:e,notSaving:n,readOnlyReason:t,toggle:o,onToggle:r,onRetry:i,words:l,saveWords:s}){if(null!==t)/* @__PURE__ */return An(Xe,{tone:"off",label:t,role:"status"});if(n)/* @__PURE__ */
2
+ return An(Xe,{tone:e.pending?"off-unsaved":"off",label:l.notSaving,role:"status"});const{tone:d,label:c}=Re(e,s),a=e.failed&&!e.paused&&/* @__PURE__ */An(Bn,{variant:"secondary",size:"sm",onClick:i,children:l.retry});/* @__PURE__ */
3
3
  return Mn(jn,o?{children:[
4
4
  /* @__PURE__ */An(Qe,{pressed:e.paused,onToggle:r,title:e.paused?l.autoSaveOff:l.autoSaveOn,children:/* @__PURE__ */An(Xe,{tone:d,label:c})}),a]}:{children:[
5
- /* @__PURE__ */An(Xe,{tone:d,label:c,role:"status"}),a]})}function En({expand:e}){/* @__PURE__ */
5
+ /* @__PURE__ */An(Xe,{tone:d,label:c,role:"status"}),a]})}function Rn({expand:e}){/* @__PURE__ */
6
6
  return An("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round",children:/* @__PURE__ */Mn(jn,e?{children:[
7
7
  /* @__PURE__ */An("path",{d:"M8 9l4-4 4 4"}),
8
8
  /* @__PURE__ */An("path",{d:"M8 15l4 4 4-4"})]}:{children:[
9
9
  /* @__PURE__ */An("path",{d:"M8 4l4 4 4-4"}),
10
10
  /* @__PURE__ */An("path",{d:"M8 20l4-4 4 4"}),
11
- /* @__PURE__ */An("path",{d:"M5 12h14"})]})})}var Ln=`${dn}, ${cn}`;function Vn(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 Fn="__rungs";var Wn="screen:band",Hn={duplicate:!0,delete:!0};function Dn(){const Ee=ye(),{target:Xe,docId:Qe,capabilities:dn,currentSlug:Dn,siteId:Un,onPublish:Gn,saveState:Jn,saveConflict:Kn,retrySave:Yn,toggleAutoSave:Xn,readOnly:Qn,readOnlyReason:_n=null}=B(),Zn=M(),qn=j(),{mediaEditing:et,hasEditGuard:nt,hasPinnedChrome:tt}=dn,{appState:ot,dispatch:rt,history:it,selectedItem:lt,getSelectorForId:st,config:dt}=we(e=>e),ct=R(),{first:at,firstGroup:pt,lastGroup:ut,isSectionGroup:ft,sectionGroupZone:ht,panelOf:mt}=ct,gt=mt(at),yt=e=>oe(ct,e),kt=e=>re(ct,e),St="node"===ct.firstRow,vt=ct.band??null,xt=Ze("screen",xe),wt=Ze("tree",Ae),bt=Ze("drag",tn),zt=Ze("save",Re),Bt=Ze("menu",ve),Ct=Ze("styleClipboard",Se),Ot=Ze("chrome",_e),It=E()??`/${Dn}`,Nt=L(),$t=V(),Pt=x({readOnly:Qn}),Tt=x({readOnly:Qn,foldIntoHistory:!0}),At=yn(null),Mt=be(),jt=kn(()=>({...Pt,select:e=>{At.current=e,Pt.select(e)},commitDocument:(e,n)=>{if(void 0!==n){const t=Mt.config;At.current=ze(e,t,n)}Pt.commitDocument(e,n)}}),[Pt,Mt]),Rt=ot.ui,Et=Rt.leftSideBarVisible,Lt=Rt.rightSideBarVisible,{options:Vt,widths:Ft,initial:Wt,fluid:Ht,fit:Dt}=F(),[Ut,Gt]=Sn(Wt),Jt=he(),Kt=et&&null!==Jt,Yt=me(),Xt=ge();W(lt?.props.id);const{read:Qt,write:_t,forSelection:Zt}=H(),[qt,eo]=Sn(Qt);vn(()=>{_t(qt)},[qt]);const[no,to]=Sn(0),oo=yn(null),ro=yn(null),io=sn(ro,{readySelector:Ln}),lo=f(ro);h(ro,io);const[so,co]=Sn(!1),ao=yn(!1),po=yn(!1),[uo,fo]=Sn(null),ho=D(),mo=e=>fo(null===e?null:{zone:le,index:e}),[go,yo]=Sn([]),[ko,So]=Sn(U),vo="puck"===ko.kind,xo=so&&!uo&&ho.railTarget?ho.railTarget(ot.data,{node:lt??null,mode:ko}):null,wo=xo?{zone:pn(xo),index:xo.index}:null,bo=uo??wo,zo=bo&&bo.zone===le?bo.index:null,Bo=t(ko,lt?.props.id),[Co,Oo]=Sn(null);vn(()=>{Co&&(o(),Oo(null))},[Co]);const Io=yn(st);Io.current=st;const No=xn((e,{scroll:n})=>{eo(n=>Zt(e,n)),n&&Oo(e);const t=[];let o=e;for(let e=0;e<4;e++){const e=Io.current(o)?.zone;if(!e||!e.includes(":"))break;const n=e.split(":")[0];t.push(n),t.push(e),o=n}0!==t.length&&ir(e=>{if(t.every(n=>!e.has(n)))return e;const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},[]),$o=yn(null);vn(()=>{const e=$o.current;$o.current=null;const n=null==lt?.props.id?null:String(lt.props.id);So(t=>e&&e.id===n?e.mode:"part"===t.kind&&"nodeId"in t&&t.nodeId===n?t:mt(lt?.type)??U);const t=lt?.props.id,o=At.current;if(At.current=null,!t)return;const i=st(t);No(String(t),{scroll:!r(o,i??null,le)})},[lt?.props.id,No]);const Po=xn(e=>{So(n=>G(n,e)?n:e),rt({type:"setUi",ui:{rightSideBarVisible:!0}})},[rt]),To=yn(()=>{});To.current=(e,n)=>{const t=e?Zr(e.zone??le)[e.index]?.props.id:null,o=null==t?null:String(t),r=null==lt?.props.id?null:String(lt.props.id);So(e=>G(e,n)?e:n),o!==r&&($o.current={id:o,mode:n},jt.select(e))};const Ao=xn((e,n)=>To.current(e,n),[]),Mo={kind:ko.kind,mode:ko,open:Po,show:e=>So(e),reveal:()=>{Lt||rt({type:"setUi",ui:{rightSideBarVisible:!0}})},select:Ao},jo=J(Mo,{data:ot.data,selected:lt??null,zoneOf:e=>st(e)?.zone,readOnly:Boolean(Qn),select:e=>{So(U),jt.select({index:e})},replace:(e,n)=>jt.replaceComponent(le,e,n),scrollTo:e=>bi(e)},{device:Ut,refreshes:no},{setView:eo,reveal:()=>{Et||rt({type:"setUi",ui:{leftSideBarVisible:!0}})}}),Ro=jo.pinnedSource??!1,Eo=jo.resolveLeftView?jo.resolveLeftView(qt,Kt):"media"===qt&&Kt?qt:"sections",Lo=K(),{isLockedBlock:Vo,duplicateBlocked:Fo,nestDepth:Wo,newSectionNode:Ho,canAddTo:Do,blockIsOffered:Uo}=Lo,Go=Y(),{labelAtLevel:Jo,Icon:Ko,useProducts:Yo}=Go,Xo=Go.rowName?(e,n,t)=>Go.rowName(e,n,t):void 0,Qo=xn(e=>{rt({type:"setUi",ui:{rightSideBarVisible:!0}}),a(e),No(e,{scroll:!0})},[rt,No]),{selectNode:_o,openPartId:Zo}=v({mode:ko,setMode:So,onOpenPart:Qo}),[qo,er]=Sn(null);ke(null!==qo,()=>er(null));const nr=y(X()),tr=nr.collapsed,or=nr.panelWidths,[rr,ir]=Sn(()=>{if("undefined"==typeof window)/* @__PURE__ */return new Set;try{const e=window.localStorage.getItem(tr);return new Set(e?JSON.parse(e):[])}catch{/* @__PURE__ */
12
- return new Set}});vn(()=>{try{window.localStorage.setItem(tr,JSON.stringify([...rr]))}catch{}},[rr]);const[lr,sr]=Sn(()=>{if("undefined"==typeof window)return{...k};try{const e=window.localStorage.getItem(or);if(!e)return{...k};const n=JSON.parse(e);return{left:S(Number(n.left)||k.left),right:S(Number(n.right)||k.right)}}catch{return{...k}}});vn(()=>{const e=setTimeout(()=>{try{window.localStorage.setItem(or,JSON.stringify(lr))}catch{}},300);return()=>clearTimeout(e)},[lr]);const dr=xn((e,n)=>sr(t=>{const o="function"==typeof n?n(t[e]):n;return t[e]===o?t:{...t,[e]:o}}),[]),cr=xn(e=>dr("left",e),[dr]),ar=xn(e=>dr("right",e),[dr]),pr=e=>rr.has(e),ur=e=>ir(n=>{const t=new Set(n);return t.has(e)?t.delete(e):t.add(e),t}),fr=yn(!1),hr=yn(null);vn(()=>{if(fr.current&&!so){const e=hr.current,n=e&&e.isConnected&&!e.closest('[aria-hidden="true"]')?e:null;(n??ro.current?.querySelector(`button[aria-label="${CSS.escape(xt.add.title)}"]`))?.focus(),hr.current=null}fr.current=so},[so]),vn(()=>{if(!so||!lo)return;const e=e=>{"Escape"===e.key&&Ti()};return lo.addEventListener("keydown",e),()=>lo.removeEventListener("keydown",e)},[so,lo]),ke(so,()=>Ti()),vn(()=>{!Et&&so&&(co(!1),fo(null),ao.current=!1)},[Et]),vn(()=>{if(!Yt)return po.current&&rt({type:"setUi",ui:{leftSideBarVisible:!1}}),void(po.current=!1);so&&(co(!1),fo(null),po.current=ao.current,ao.current=!1),Et||(po.current=!0,rt({type:"setUi",ui:{leftSideBarVisible:!0}}))},[Yt]),vn(()=>{!Et&&Yt&&(po.current=!1,Xt())},[Et]),vn(()=>{if(!Yt||!lo)return;const e=e=>{"Escape"===e.key&&Xt()};return lo.addEventListener("keydown",e),()=>lo.removeEventListener("keydown",e)},[Yt,lo]),ke(null!==Yt,()=>Xt());const mr=Q(),gr=(e,n="success",t)=>{if(mr)return void(t?mr(e,"error"===n?"error":"info",t):mr(e,"error"===n?"error":"info"));const o={sound:!1,action:t?.action,onClose:t?.onClose};"error"===n?Cn.error(e,{...o,duration:t?.duration??3200}):Cn.success(e,{...o,duration:t?.duration??1900})},yr=yn(null),[kr,Sr]=Sn(0),[vr,xr]=Sn(0),wr=_(),br=yn(null),zr=e=>Math.max(0,e.clientHeight-(br.current?.offsetHeight??0));vn(()=>{const e=yr.current;if(!e)return;const n=()=>{Sr(e.clientWidth),xr(zr(e))};n();const t=new ResizeObserver(n);return t.observe(e),br.current&&t.observe(br.current),()=>t.disconnect()},[]),wn(()=>{yr.current&&(Sr(yr.current.clientWidth),xr(zr(yr.current)))},[lr,Et,Lt]);const Br=Ut===Ht?kr>0?kr:Ft[Ht]:Ft[Ut],Cr=kr>0?Math.min(kr/Br,"shrink"===Dt?1:2):1,Or=Br*Cr,Ir=kr>0&&Or>kr+1,Nr={width:Or,height:vr||"100%",flex:"none",position:"relative"},$r={width:Br,height:vr?vr/Cr:"100%",maxHeight:"none",transform:1!==Cr?`scale(${Cr})`:void 0,transformOrigin:"top left"},Pr=()=>rt({type:"setUi",ui:{leftSideBarVisible:!Et}}),Tr=()=>rt({type:"setUi",ui:{rightSideBarVisible:!Lt}}),Ar=e=>{so&&(co(!1),fo(null),ao.current=!1,Et&&qt===e)||Yt&&(po.current=!1,Xt(),Et&&qt===e)||(Et&&qt===e?Pr():(eo(e),Et||rt({type:"setUi",ui:{leftSideBarVisible:!0}})))},Mr=()=>{C(Ee,{accept:"image/*",title:Ot.mediaLibrary})},jr=()=>{So(U),jt.select(null),u()},Rr=()=>{So(gt??U),Lt||rt({type:"setUi",ui:{rightSideBarVisible:!0}})},Er=ot.data.content??[],Lr=()=>{const e=Er.findIndex(yt),n=Er.findIndex(kt);return{floor:e>=0?e+1:0,cap:n>=0?n:Er.length}},Vr=dt,Fr=Lo.stripCopy,Wr=e=>i(e,Fr),Hr=w(),Dr=Be({data:ot.data,config:Vr,readOnly:Boolean(Qn),clipboard:Hr,strip:Fr?e=>Fr(e):void 0,afterRemove:"none",stepBounds:(e,n)=>{if(e.parentId!==un||e.slot!==fn)return{min:0,max:n-1};const{floor:t,cap:o}=Lr();return{min:t,max:o-1}},commit:(e,{select:n})=>{void 0!==n&&So(U);const t=void 0===n||"node"===n?.kind?n:null;jt.commitDocument(e,t)}}),Ur=e=>{const n=mn(ot.data,dt,e);if(!n)return!1;const t=pn(n.place),o=n.node,r=t===le?Xr(o):ci(o);return!!Dr.remove(e)&&(gr(xt.deleted({name:r}),"success",{duration:8e3,action:{label:xt.bar.undo,onClick:()=>{Dr.restore(n.node,n.place)}}}),!0)},Gr={...Dr,remove:Ur},Jr=e=>Jo(e,"block",dt.components[e]?.label??e),Kr=xn(e=>dt.components[e]?.defaultProps??{},[dt]),Yr=e=>Jo(e,"section",Jr(e)),Xr=e=>l({type:e.type,props:e.props??{}},Yr(e.type),Xo),{nodeAddresses:Qr,zoneItems:_r}=kn(()=>{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>=de)return;const s=/* @__PURE__ */new Map;for(const{child:e,zone:t}of ce(dt,n))s.set(t,[...s.get(t)??[],e]);for(const[e,n]of s)t(n,e,i+1)})};return t(Er,le,0),{nodeAddresses:e,zoneItems:n}},[Er,dt]),Zr=xn(e=>_r.get(e)??[],[_r]),qr=e=>{const n=Qr.get(e);return n?Zr(n.zone)[n.index]:void 0},ei=e=>ie(Lo,dt,e),ni=e=>{if(!Lo.slotsOf||e===le)return null;const n=e.lastIndexOf(":");if(n<=0)return null;const t=qr(e.slice(0,n));if(!t)return null;const o=ei(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}},ti=(()=>{if(!Z(ko))return null;const e=`${ko.nodeId}:${ko.slot}`;return ni(e)?.slot.panel===ko.kind?e:null})(),oi=yn(null);vn(()=>{const e=oi.current;if(oi.current=null,!ti||!Z(ko))return;const n=ko.nodeId;No(n,{scroll:e!==ti}),ir(e=>{if(!e.has(n))return e;const t=new Set(e);return t.delete(n),t})},[ko]);const ri=(e,n,t)=>{const o=String(e.props.id);if(!n.panel)return void(e=>{const n=Qr.get(e);n&&(n.zone===le?zi(n.index):el(n.zone,n.index,e,qr(n.zone.slice(0,n.zone.lastIndexOf(":")))?.type??""))})(o);const r={kind:n.panel,nodeId:o,slot:n.slot},i=`${o}:${n.slot}`;t&&ti!==i&&(oi.current=i),Ao(null,r),Lt||rt({type:"setUi",ui:{rightSideBarVisible:!0}}),bi(o)},ii=(e,n,t)=>{const o=`${e}:${n}`;if(ir(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;ti!==o&&(oi.current=o);Ao(null,{kind:t,nodeId:e,slot:n})},li=(e,n,t)=>{if(Qn||!Lo.moveSlot)return;const o=qr(e),r=o?ei(o).filter(e=>e.rung):[],i=r[n];if(!i)return;const l={parentId:e,slot:Fn,index:n},s=ln(l,{...l,index:Math.min(Math.max(t,0),r.length)});if(s===n)return;const d=Lo.moveSlot(e,n,s);"string"==typeof d&&ii(e,d,i.panel)},si=Yo(),di=kn(()=>{const e=/* @__PURE__ */new Map;for(const n of si??[])e.set(n.slug,n.name);return e},[si]),ci=e=>s(e,Jr,Go.plainText,e=>di.get(e),Go.rowName),ai=(e,n)=>{const t=dt.components[e.type]?.fields,o=n===le||kl(n)?"section":"block",r=n===le&&(yt(e)||kt(e)||ft(e.type)),i="block"===o?d(t):r?null:c(t);return Go.renamePropOf?Go.renamePropOf(e,o,i):i},pi=(e,n,t,o)=>{if(!(!Qn&&qo?.zone===e&&qo.index===n))return;const r=(t,o)=>{er(null),o&&((e,n,t)=>{const o=Zr(e)[n];if(!o)return;const r=ai(o,e);r&&jt.replaceComponent(e,n,{...o,props:{...o.props,[r]:t.trim()}})})(e,n,t)};/* @__PURE__ */
13
- return An("input",{className:"es-tree-rename",defaultValue:o,autoFocus:!0,"aria-label":xt.rename,onClick:e=>e.stopPropagation(),onBlur:e=>r(e.currentTarget.value,!0),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),r(e.currentTarget.value,!0)):"Escape"===e.key&&(e.preventDefault(),r("",!1))}},t)},ui=n(q(),Ct),fi=ui.scope({target:Xe,siteId:Un,docId:Qe}),hi=dt,mi=(e,n)=>n===le?Yr(e):Jr(e),gi=(e,n,t)=>{const o=ui.plan(fi,t,mi(t.type,e),hi);o&&(o.changed&&jt.replaceComponent(e,n,{...t,props:{...o.props,id:t.props.id}}),gr(o.message))},yi=b({nodesIn:Zr,nodeAt:(e,n)=>Zr(e)[n]??null,labelOf:(e,n)=>n===le?Yr(e):Jr(e),renamePropOf:ai,beginRename:(e,n)=>er({zone:e,index:n}),history:{hasPast:it.hasPast,hasFuture:it.hasFuture,back:()=>it.back(),forward:()=>it.forward()},openAddSection:()=>{jt.select(null),$i(null)},openPageSettings:()=>{jt.select(null),So(U)},pageSettingsLabel:xt.pageSettings,words:{menu:Bt,styleClipboard:Ct,screen:xt.menu},readOnly:Boolean(Qn),collapseAll:()=>ir(new Set(Zr(le).map(e=>String(e.props.id)))),onPasteRefused:e=>gr(e?xt.pasteRefused({name:e.label}):xt.menu.clipboardRefused,"error"),canPasteAt:(e,n)=>vl(e,n),menuRows:jo.menuRows,isLocked:e=>Vo(e.type),duplicateBlocked:e=>Fo(ot.data,e),permits:e=>se(dt,e.type),canAddTo:Do,nodeOps:Gr,isPinned:(e,n)=>n===le&&(yt(e)||kt(e)),sectionBand:Lr,openAddInside:(e,n)=>{e===le?zi(n):jt.select({zone:e,index:n}),$i(null)},locate:e=>Qr.get(e)??null,rowNameOf:(e,n)=>n===le?Xr(e):ci(e),selectAt:(e,n,t,o)=>{e===le?zi(n):el(e,n,t,o??"")},slotRung:e=>{const n=ni(e);return n?.slot.panel?{label:n.slot.label,select:()=>ri(n.node,n.slot,!1)}:null},style:{held:()=>O(fi),canCopy:e=>ui.rows(hi,e).some(e=>!1!==e.counted),copy:(e,n)=>ui.copy(fi,e,mi(e.type,n),hi),paste:(e,n,t)=>gi(e,n,t)},keys:qn?{target:lo,selected:()=>{const e=ot.ui.itemSelector;return e?{zone:e.zone??le,index:e.index}:null},held:()=>Hr.get(),readOnly:Boolean(Qn),onDone:({done:e,name:n})=>{"copied"===e&&gr(xt.copied({name:n}))}}:void 0},io),ki=yn({copy:(e,n)=>{},paste:(e,n,t)=>{},at:()=>null,readOnly:!1});vn(()=>{ki.current={copy:(e,n)=>ui.copy(fi,e,mi(e.type,n),hi),paste:gi,at:()=>{const e=ot.ui.itemSelector;if(!e)return null;const n=e.zone??le,t=Zr(n)[e.index];return t?{zone:n,index:e.index,node:t}:null},readOnly:Boolean(Qn)}});const Si=xn(e=>{const n=I(e);if(!n)return;const t=ki.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))},[]);vn(()=>{if(!lo)return;const e=e=>Si(e);return lo.addEventListener("keydown",e),()=>lo.removeEventListener("keydown",e)},[Si,lo]),an(io,"keydown",Si);const vi=Er.map(e=>e.props.id).join("|");vn(()=>{const e=io?.document??null,n=io?.window??null;let t=0;const o=[],r=()=>{if(!e)return void yo(e=>e.length?[]:e);const n=Er.findIndex(kt),t=n>=0?n:Er.length,o=n=>{const t=Er[n]?.props?.id;return null==t?null:e.querySelector(`[data-puck-component="${CSS.escape(String(t))}"]`)},r=e=>e?[...e.querySelectorAll(cn)].map(e=>e.getBoundingClientRect()).filter(e=>e.width>0||e.height>0):[],i=[];for(let e=Er.length>0&&!yt(Er[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=Vn(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})}yo(e=>function(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t].top!==n[t].top||e[t].index!==n[t].index||e[t].height!==n[t].height)return!1;return!0}(e,i)?e:i)},i=()=>{cancelAnimationFrame(t),t=requestAnimationFrame(r)};if(!e||!n)return void r();n.addEventListener("scroll",i,{passive:!0});const l=new ResizeObserver(i);return l.observe(e.documentElement),r(),o.push(setTimeout(r,150),setTimeout(r,450)),()=>{cancelAnimationFrame(t),o.forEach(clearTimeout),n.removeEventListener("scroll",i),l.disconnect()}},[io,vi,Ut,Cr,Et,Lt,lt?.props.id]);const xi=io?.document??null,wi=io?.window??null;vn(()=>{const e=oo.current;if(!e||!xi||!wi)return;const n=[],t=()=>{const n=xi.querySelector(`[data-puck-component="${CSS.escape(e.id)}"]`);if(!n)return!1;const t=n.getBoundingClientRect().top-e.offset;return Math.abs(t)>1&&wi.scrollTo({left:wi.scrollX,top:wi.scrollY+t,behavior:"instant"}),!0};return oo.current=null,t()&&n.push(setTimeout(t,150),setTimeout(t,450)),()=>n.forEach(clearTimeout)},[xi,wi]);const bi=e=>{jo.holdCanvasOn?jo.holdCanvasOn(e):a(e)},zi=e=>{So(U),jt.select({index:e}),jo.sectionPressed?.(Er[e]);const n=Er[e]?.props?.id;n&&bi(n)},Bi=e=>{const{floor:n,cap:t}=Lr(),o=e=>Math.min(Math.max(n,e),t);if("number"==typeof e)return o(e);const r=lt&&ko.kind!==gt?.kind?Er.findIndex(e=>e.props.id===lt.props.id):-1;return o(r>=0?r+1:t)},Ci=(e,n)=>{const{floor:t,cap:o}=Lr(),r=Math.min(Math.max(n,t),o),i=e<r?r-1:r;return i===e?{moved:!1,dest:e}:(jt.reorderComponent(le,e,i),jt.select({index:i}),{moved:!0,dest:i})},Oi=(e,n,t,o)=>{So(U),jt.select(o?{index:o.index,zone:o.zone}:{index:e}),a(n),gr(xt.sectionAdded({name:t}))},Ii=(e,n)=>{const t=Bi(n),o=Ho(e,{nodeDefaults:Kr,newNodeId:fe,sectionLabel:Yr,blockIsOffered:Uo}),r=o?jt.insertNode(le,t,o):jt.insertSection(e,t);return Oi(t,r,Yr(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 ce(dt,e)){if(s.type===t&&(!o.at||n>o.at.depth)){const r=Do(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},Ni=(e,n,t)=>{const o=Bi(t),r=jt.insertNode(le,o,n);return Oi(o,r,e),o},$i=e=>Pi(le,e),Pi=(e,n)=>{hr.current=document.activeElement??null,Yt&&(ao.current=po.current,po.current=!1,Xt()),fo(null===n?null:{zone:e,index:n}),co(!0),Et||(ao.current=!0,rt({type:"setUi",ui:{leftSideBarVisible:!0}}))},Ti=()=>{co(!1),fo(null),ao.current&&rt({type:"setUi",ui:{leftSideBarVisible:!1}}),ao.current=!1},Ai=(e,n,t)=>{if("section"===e.kind)jt.insertComponent(n,e.type,t);else{if("template"!==e.kind)return;jt.insertNode(n,t,Wr(e.template.node))}So(U),jt.select({index:t,zone:n})},Mi=(e,n)=>Go.rowName?n?yt(e)?Go.rowName(e,"section",xt.header):kt(e)?Go.rowName(e,"section",xt.footer):ft(e.type)?Go.rowName(e,"section",Jr(e.type)):Xr(e):ci(e):n?Yr(e.type):Jr(e.type),ji=e=>n=>{e()},Ri=()=>jo.editPinnedSource?.(),Ei=(e,n,t)=>{if(Qn)return null;const o=Zr(e)[n];return o&&!se(dt,o.type).delete?null:/* @__PURE__ */An(Pe,{kind:"delete",label:xt.deleteNamed({name:t}),onClick:()=>((e,n)=>{const t=Zr(e)[n]?.props?.id;null!=t&&Ur(String(t))})(e,n),children:/* @__PURE__ */An(Nn,{size:15})})},Li=e=>Go.rowPreview?.(e)||void 0,Vi=e=>Go.rowMarks?.(e)??void 0,Fi=(e,n,t)=>Go.rowActions?.(e,n,t)??null,Wi=(e,n,t,o)=>{if(Qn)return null;const r=Boolean(t.props._hidden);/* @__PURE__ */
14
- return An(Pe,{kind:"eye",label:r?xt.showNamed({name:o}):xt.hideNamed({name:o}),onClick:()=>Di(e,n,t),children:/* @__PURE__ */An(r?$n:Pn,{size:14,strokeWidth:1.8,strokeLinecap:void 0,strokeLinejoin:void 0})})},Hi=e=>{const n=Yr(Er[e]?.type??""),t=n?xt.addSectionBefore({name:n}):xt.addSectionHere;return Dl(le,e,()=>$i(e),t)},Di=(e,n,t)=>{jt.replaceComponent(e,n,{...t,props:{...t.props,_hidden:!t.props._hidden}})},Ui=e=>ae(dt,e),Gi=e=>ce(dt,e),Ji=e=>Lo.slotsOf?ei(e).map(n=>({slot:n.slot,rung:n.rung?n:null,kids:pe(e,n.slot)})):[{slot:null,rung:null,kids:Gi(e)}],Ki=e=>Lo.slotsOf?Ji(e).flatMap(e=>e.kids):Gi(e),Yi=e=>Boolean(Lo.slotsOf)&&ei(e).some(e=>e.rung),Xi=(e,n,t)=>null===t?void 0===n?Do(e):Do(e,n):Do(e,n,t),Qi=(e,n,t)=>{const o=ue(dt,e.type,n)&&(t||Ki(e).length>0||Yi(e));return{collapsible:o,folded:o&&pr(String(e.props.id))}},_i=(e,n,t)=>Ji(e).flatMap(o=>{const r=o.rung?n+1:n,i=o.kids.flatMap(({child:e})=>Qi(e,r,t(e.type)).collapsible?[String(e.props.id),..._i(e,r+1,t)]:[]);return o.rung?[`${e.props.id}:${o.rung.slot}`,...i]:i}),Zi=e=>Ki(e).length>0||Yi(e)||Boolean(Do(e.type)),qi=e=>Boolean(Do(e)),el=(e,n,t,o)=>{if(So(U),Do(o)?.spec?.slider){const t=e.split(":")[0];p(t,n),jt.select({index:n,zone:e}),a(t)}else jt.select({index:n,zone:e}),bi(t)},nl=(e,n,t,o,r)=>{const i=`${e}:${n}`;jt.insertComponent(i,t,o),Do(r)?.spec?.slider?requestAnimationFrame(()=>{p(e,o),jt.select({index:o,zone:i})}):jt.select({index:o,zone:i})},tl=(e,n,t)=>{jt.insertComponent(e,n,t),So(U),jt.select({index:t,zone:e})},ol=yn(/* @__PURE__ */new Set);vn(()=>{Er.forEach(e=>{const n=Do(e.type)?.spec;if(!n)return;const t=e.props.id;if(ol.current.has(t))return;ol.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(Kr)).forEach((e,t)=>Tt.seedChild(o,t,n.childType,e))})},[Er,Tt,Kr]);const rl=yn(/* @__PURE__ */new Set);vn(()=>{Er.forEach((n,t)=>{const o=n.props.id;if(rl.current.has(o))return;const r=e(n,Ui(n.type));rl.current.add(o),r&&Tt.replaceComponent(le,t,{...n,props:r})})},[Er,Tt]),ee(Tt,dt);const il=Er.findIndex(kt),ll=il>=0?Er[il]:null,sl=St?Er.findIndex(yt):-1,dl=sl>=0?Er[sl]:null,cl=Er.find(e=>e.type===pt)??null,al=Er.find(e=>e.type===ut)??null,pl=il>=0?il:Er.length,ul=[];Er.forEach(e=>{kt(e)||(Zi(e)&&ul.push(String(e.props.id)),ul.push(..._i(e,1,qi)))}),ll&&(ul.push(String(ll.props.id)),ul.push(..._i(ll,1,qi)));const fl=ul.length>0&&ul.every(e=>rr.has(e)),hl=e=>{const n=Go.blockRowName(e,Jr);return Go.rowName?Go.rowName(e,"block",n):n},ml=(e,n,t,o)=>{const r=Zr(e)[t];if(!r)return;const i={...hn(e),index:t},l={...hn(n),index:Math.min(Math.max(o,0),Zr(n).length)},s=ln(i,l);if(e!==n||s!==t)try{Dr.move(String(r.props.id),{...l,index:s})}catch(e){if(!(e instanceof gn))throw e}},gl=e=>{const n=/* @__PURE__ */new Set,t=e=>{for(const{child:o,zone:r}of Gi(e))n.add(r),t(o)};for(const t of Ui(e.type))n.add(`${e.props.id}:${t}`);return t(e),n},yl=e=>{let n=e.slice(0,e.indexOf(":"));for(let e=0;e<64;e++){const e=Qr.get(n);if(!e)return null;if(e.zone===le)return n;n=e.zone.slice(0,e.zone.indexOf(":"))}return null},kl=e=>{const n=e.slice(0,e.indexOf(":")),t=Er.find(e=>ft(e.type)&&String(e.props.id)===n);return t&&ht(n)===e?t:null},Sl=(e,n,t)=>{if(e.rung){const t=qr(e.rung.nodeId),o=t?ei(t).filter(e=>e.rung).length:0;return n.parentId===e.rung.nodeId&&n.slot===Fn&&n.index>=0&&n.index<=o}if(n.slot===Fn)return!1;if(e.add)return wl(e.add,n);const o=pn(n);if(ft(e.type))return!1;const r=kl(o),i=kl(e.zone);if(r||i)return!(!r||!i)&&(n.index>=0&&n.index<=Zr(o).length);if(e.zone===le||o===le){if(e.zone!==o)return!1;const{floor:t,cap:r}=Lr();return n.index>=t&&n.index<=r}if(n.index<0||n.index>Zr(o).length)return!1;if(e.zone===o)return!0;const l=ll&&!ct.lastIsOpen?String(ll.props.id):null;return(!l||yl(e.zone)!==l&&yl(o)!==l)&&((e,n,t,o)=>{if(e===n)return!0;const r=o??Zr(e)[t];if(!r)return!1;const i=n.split(":")[0],l=Qr.get(i),s=l?Zr(l.zone)[l.index]:void 0;if(!s)return!1;if(!o&&gl(r).has(n))return!1;const d=Do(s.type,Wo(ot?.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?.(Zr(n),r))})(e.zone,o,e.index,t)},vl=(e,n)=>{const t=pn(e.from);if(t===pn(n))return!0;const o=e.node;return Sl({id:String(o.props?.id??""),zone:t,index:-1,type:o.type},n,o)},xl=e=>{const n=e.slice(0,e.indexOf(":")),t=Qr.get(n),o=t?Zr(t.zone)[t.index]:void 0;if(!t||!o)return null;const r=Do(o.type,Wo(ot?.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:Jr(r.spec.childType)}]:[]),l=ni(e);return{parent:o,parentId:n,target:r,choices:i,parentName:l?l.slot.label:Mi(o,t.zone===le)}},wl=(e,n)=>{const t=pn(n);if("block"!==e.kind){if(kl(t))return n.index>=0&&n.index<=Zr(t).length;if(t!==le)return!1;const{floor:e,cap:o}=Lr();return n.index>=e&&n.index<=o}if(t===le)return!1;const o=xl(t);return!(!o||!o.choices.some(n=>n.type===e.type))&&!o.target.spec?.addBlocked?.(Zr(t))},bl=(e,n)=>{e.rung?li(e.rung.nodeId,e.index,n.index):e.add?((e,n)=>{if("block"!==e.kind&&kl(pn(n)))return void Ai(e,pn(n),n.index);if("section"===e.kind)return void Ii(e.type,n.index);if("template"===e.kind)return void Ni(e.template.name,Wr(e.template.node),n.index);const t=pn(n),o=xl(t);o&&(o.target.spec?nl(o.parentId,o.target.slot,e.type,n.index,o.parent.type):tl(t,e.type,n.index))})(e.add,n):e.zone===le?Ci(e.index,n.index):ml(e.zone,pn(n),e.index,n.index)},[zl]=Sn(()=>on()),Bl=rn({keyOf:e=>e.id,readOnly:Boolean(Qn),session:zl,canDrop:Sl,onDrop:bl,onStep:(e,n)=>{e.rung?li(e.rung.nodeId,e.index,n<0?e.index-1:e.index+2):e.zone===le?((e,n)=>{const t=Yr(Er[e]?.type??""),o=Ci(e,n<0?e-1:e+2);if(!o.moved)return void gr(n<0?xt.sectionFirst({name:t}):xt.sectionLast({name:t}));const{floor:r,cap:i}=Lr();gr(xt.sectionMoved({name:t,n:o.dest-r+1,total:i-r}))})(e.index,n):ml(e.zone,e.zone,e.index,n<0?e.index-1:e.index+2)}}),Cl=xn(e=>{const{floor:n,cap:t}=Lr(),o=[];for(const r of e.nodes){const e=pn(r.place),i=Zr(e)[r.place.index];if(!i||String(i.props.id)!==r.id)continue;if(yt(i)||kt(i)||Vo(i.type))continue;if(ft(i.type))continue;const l=Boolean(kl(e)),s=e===le||l;e===le&&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?Yr(i.type):ci(i),from:r.place})}const r=e.zones.flatMap(e=>{const n=pn(e.list);return n===le&&0===e.children.length?[{...e,addLabel:xt.addSection,addAlways:!0}]:e.children.length>0||Boolean(xl(n)?.choices.length)||Boolean(kl(n))?[e]:[]}),i=r.flatMap(e=>{const n=pn(e.list);return n===le||kl(n)||!xl(n)?.choices.length?[]:qe(e,xt.addBlockHere)});return{sources:o,zones:r,seams:i}},[ot.data]),Ol=null==lt?.props.id?null:String(lt.props.id),Il=xn(e=>{const n=dt,t=e=>!e.item.rung&&null!==mn(ot.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(Ol);return i||(r(Ce(ot.data,n,o.item.id,Ol))??o)},[ot.data,dt,Ol]),Nl=e=>{So(U),jt.select(e.zone===le?{index:e.index}:{index:e.index,zone:e.zone})},$l=ne(),Pl=()=>({data:ot.data,device:Ut,ops:jt,inspector:Mo}),Tl=$l?.model,Al=kn(()=>Tl?e=>Tl(e,Cl(e),Pl()):Cl,[Tl,Cl,Ut]),Ml=$l?.measure,jl=Ml?(e,n)=>Ml(e,n,Pl()):void 0,Rl=$l?.canDrop,El=Rl?(e,n)=>Rl(e,n,Sl,Pl()):Sl,Ll=$l?.drop,Vl=Ll?(e,n)=>Ll(e,n,bl,Pl()):bl,Fl=$l?.pick,Wl=Fl?e=>Fl(e,Nl,Pl()):Nl,Hl=e=>{const n=pn(e),t=ni(n);t&&ri(t.node,t.slot,!1),Pi(n,e.index)},Dl=(e,n,t,o)=>/* @__PURE__ */An(Te,{...Qn?{}:Bl.seam({place:{...hn(e),index:n}}),onAdd:Qn?void 0:t,label:o},`seam:${e}:${n}`),Ul={rowClick:ji,isCollapsed:pr,toggleCollapse:ur},Gl=e=>{const n=String(e.props.id),t=Er.findIndex(e=>String(e.props.id)===n),o=ht(n),r=Zr(o),i=pr(n),l=Jr(e.type),s=Go.rowName?Go.rowName(e,"section",l):l,d=e=>Dl(o,e,()=>Pi(o,e),xt.addSectionHere);/* @__PURE__ */
11
+ /* @__PURE__ */An("path",{d:"M5 12h14"})]})})}var Ln=`${dn}, ${cn}`;function Vn(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 Fn="__rungs";var Hn="screen:band",Wn={duplicate:!0,delete:!0};function Un(){const Re=ye(),{target:Xe,docId:Qe,capabilities:dn,currentSlug:Un,siteId:Dn,onPublish:Gn,saveState:Jn,saveConflict:Yn,retrySave:Kn,toggleAutoSave:Xn,readOnly:Qn,readOnlyReason:_n=null}=B(),Zn=M(),qn=j(),{mediaEditing:et,hasEditGuard:nt,hasPinnedChrome:tt}=dn,{appState:ot,dispatch:rt,history:it,selectedItem:lt,getSelectorForId:st,config:dt}=xe(e=>e),ct=E(),{first:at,firstGroup:pt,lastGroup:ut,isSectionGroup:ft,sectionGroupZone:ht,panelOf:mt}=ct,gt=mt(at),yt=e=>oe(ct,e),kt=e=>re(ct,e),St="node"===ct.firstRow,vt=ct.band??null,xt=Ze("screen",ve),wt=Ze("tree",Ne),bt=Ze("drag",tn),zt=Ze("save",Ee),Bt=Ze("menu",Pe),Ct=Ze("styleClipboard",Se),Ot=Ze("chrome",_e),It=R()??`/${Un}`,Nt=L(),Pt=V(),$t=x({readOnly:Qn}),Tt=x({readOnly:Qn,foldIntoHistory:!0}),At=yn(null),Mt=we(),jt=kn(()=>({...$t,select:e=>{At.current=e,$t.select(e)},commitDocument:(e,n)=>{if(void 0!==n){const t=Mt.config;At.current=$e(e,t,n)}$t.commitDocument(e,n)}}),[$t,Mt]),Et=ot.ui,Rt=Et.leftSideBarVisible,Lt=Et.rightSideBarVisible,{options:Vt,widths:Ft,initial:Ht,fluid:Wt,fit:Ut}=F(),[Dt,Gt]=Sn(Ht),Jt=he(),Yt=et&&null!==Jt,Kt=me(),Xt=ge();H(lt?.props.id);const{read:Qt,write:_t,forSelection:Zt}=W(),[qt,eo]=Sn(Qt);vn(()=>{_t(qt)},[qt]);const[no,to]=Sn(0),oo=yn(null),ro=yn(null),io=sn(ro,{readySelector:Ln}),lo=f(ro);h(ro,io);const[so,co]=Sn(!1),ao=yn(!1),po=yn(!1),[uo,fo]=Sn(null),ho=U(),mo=e=>fo(null===e?null:{zone:le,index:e}),[go,yo]=Sn([]),[ko,So]=Sn(D),vo="puck"===ko.kind,xo=so&&!uo&&ho.railTarget?ho.railTarget(ot.data,{node:lt??null,mode:ko}):null,wo=xo?{zone:pn(xo),index:xo.index}:null,bo=uo??wo,zo=bo&&bo.zone===le?bo.index:null,Bo=t(ko,lt?.props.id),[Co,Oo]=Sn(null);vn(()=>{Co&&(o(),Oo(null))},[Co]);const Io=yn(st);Io.current=st;const No=xn((e,{scroll:n})=>{eo(n=>Zt(e,n)),n&&Oo(e);const t=[];let o=e;for(let e=0;e<4;e++){const e=Io.current(o)?.zone;if(!e||!e.includes(":"))break;const n=e.split(":")[0];t.push(n),t.push(e),o=n}0!==t.length&&ir(e=>{if(t.every(n=>!e.has(n)))return e;const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},[]),Po=yn(null);vn(()=>{const e=Po.current;Po.current=null;const n=null==lt?.props.id?null:String(lt.props.id);So(t=>e&&e.id===n?e.mode:"part"===t.kind&&"nodeId"in t&&t.nodeId===n?t:mt(lt?.type)??D);const t=lt?.props.id,o=At.current;if(At.current=null,!t)return;const i=st(t);No(String(t),{scroll:!r(o,i??null,le)})},[lt?.props.id,No]);const $o=xn(e=>{So(n=>G(n,e)?n:e),rt({type:"setUi",ui:{rightSideBarVisible:!0}})},[rt]),To=yn(()=>{});To.current=(e,n)=>{const t=e?Zr(e.zone??le)[e.index]?.props.id:null,o=null==t?null:String(t),r=null==lt?.props.id?null:String(lt.props.id);So(e=>G(e,n)?e:n),o!==r&&(Po.current={id:o,mode:n},jt.select(e))};const Ao=xn((e,n)=>To.current(e,n),[]),Mo={kind:ko.kind,mode:ko,open:$o,show:e=>So(e),reveal:()=>{Lt||rt({type:"setUi",ui:{rightSideBarVisible:!0}})},select:Ao},jo=J(Mo,{data:ot.data,selected:lt??null,zoneOf:e=>st(e)?.zone,readOnly:Boolean(Qn),select:e=>{So(D),jt.select({index:e})},replace:(e,n)=>jt.replaceComponent(le,e,n),scrollTo:e=>bi(e)},{device:Dt,refreshes:no},{setView:eo,reveal:()=>{Rt||rt({type:"setUi",ui:{leftSideBarVisible:!0}})}}),Eo=jo.pinnedSource??!1,Ro=jo.resolveLeftView?jo.resolveLeftView(qt,Yt):"media"===qt&&Yt?qt:"sections",Lo=Y(),{isLockedBlock:Vo,duplicateBlocked:Fo,nestDepth:Ho,newSectionNode:Wo,canAddTo:Uo,blockIsOffered:Do}=Lo,Go=K(),{labelAtLevel:Jo,Icon:Yo,useProducts:Ko}=Go,Xo=Go.rowName?(e,n,t)=>Go.rowName(e,n,t):void 0,Qo=xn(e=>{rt({type:"setUi",ui:{rightSideBarVisible:!0}}),a(e),No(e,{scroll:!0})},[rt,No]),{selectNode:_o,openPartId:Zo}=v({mode:ko,setMode:So,onOpenPart:Qo}),[qo,er]=Sn(null);ke(null!==qo,()=>er(null));const nr=y(X()),tr=nr.collapsed,or=nr.panelWidths,[rr,ir]=Sn(()=>{if("undefined"==typeof window)/* @__PURE__ */return new Set;try{const e=window.localStorage.getItem(tr);return new Set(e?JSON.parse(e):[])}catch{/* @__PURE__ */
12
+ return new Set}});vn(()=>{try{window.localStorage.setItem(tr,JSON.stringify([...rr]))}catch{}},[rr]);const[lr,sr]=Sn(()=>{if("undefined"==typeof window)return{...k};try{const e=window.localStorage.getItem(or);if(!e)return{...k};const n=JSON.parse(e);return{left:S(Number(n.left)||k.left),right:S(Number(n.right)||k.right)}}catch{return{...k}}});vn(()=>{const e=setTimeout(()=>{try{window.localStorage.setItem(or,JSON.stringify(lr))}catch{}},300);return()=>clearTimeout(e)},[lr]);const dr=xn((e,n)=>sr(t=>{const o="function"==typeof n?n(t[e]):n;return t[e]===o?t:{...t,[e]:o}}),[]),cr=xn(e=>dr("left",e),[dr]),ar=xn(e=>dr("right",e),[dr]),pr=e=>rr.has(e),ur=e=>ir(n=>{const t=new Set(n);return t.has(e)?t.delete(e):t.add(e),t}),fr=yn(!1),hr=yn(null);vn(()=>{if(fr.current&&!so){const e=hr.current,n=e&&e.isConnected&&!e.closest('[aria-hidden="true"]')?e:null;(n??ro.current?.querySelector(`button[aria-label="${CSS.escape(xt.add.title)}"]`))?.focus(),hr.current=null}fr.current=so},[so]),vn(()=>{if(!so||!lo)return;const e=e=>{"Escape"===e.key&&Ti()};return lo.addEventListener("keydown",e),()=>lo.removeEventListener("keydown",e)},[so,lo]),ke(so,()=>Ti()),vn(()=>{!Rt&&so&&(co(!1),fo(null),ao.current=!1)},[Rt]),vn(()=>{if(!Kt)return po.current&&rt({type:"setUi",ui:{leftSideBarVisible:!1}}),void(po.current=!1);so&&(co(!1),fo(null),po.current=ao.current,ao.current=!1),Rt||(po.current=!0,rt({type:"setUi",ui:{leftSideBarVisible:!0}}))},[Kt]),vn(()=>{!Rt&&Kt&&(po.current=!1,Xt())},[Rt]),vn(()=>{if(!Kt||!lo)return;const e=e=>{"Escape"===e.key&&Xt()};return lo.addEventListener("keydown",e),()=>lo.removeEventListener("keydown",e)},[Kt,lo]),ke(null!==Kt,()=>Xt());const mr=Q(),gr=(e,n="success",t)=>{if(mr)return void(t?mr(e,"error"===n?"error":"info",t):mr(e,"error"===n?"error":"info"));const o={sound:!1,action:t?.action,onClose:t?.onClose};"error"===n?Cn.error(e,{...o,duration:t?.duration??3200}):Cn.success(e,{...o,duration:t?.duration??1900})},yr=yn(null),[kr,Sr]=Sn(0),[vr,xr]=Sn(0),wr=_(),br=yn(null),zr=e=>Math.max(0,e.clientHeight-(br.current?.offsetHeight??0));vn(()=>{const e=yr.current;if(!e)return;const n=()=>{Sr(e.clientWidth),xr(zr(e))};n();const t=new ResizeObserver(n);return t.observe(e),br.current&&t.observe(br.current),()=>t.disconnect()},[]),wn(()=>{yr.current&&(Sr(yr.current.clientWidth),xr(zr(yr.current)))},[lr,Rt,Lt]);const Br=Dt===Wt?kr>0?kr:Ft[Wt]:Ft[Dt],Cr=kr>0?Math.min(kr/Br,"shrink"===Ut?1:2):1,Or=Br*Cr,Ir=kr>0&&Or>kr+1,Nr={width:Or,height:vr||"100%",flex:"none",position:"relative"},Pr={width:Br,height:vr?vr/Cr:"100%",maxHeight:"none",transform:1!==Cr?`scale(${Cr})`:void 0,transformOrigin:"top left"},$r=()=>rt({type:"setUi",ui:{leftSideBarVisible:!Rt}}),Tr=()=>rt({type:"setUi",ui:{rightSideBarVisible:!Lt}}),Ar=e=>{so&&(co(!1),fo(null),ao.current=!1,Rt&&qt===e)||Kt&&(po.current=!1,Xt(),Rt&&qt===e)||(Rt&&qt===e?$r():(eo(e),Rt||rt({type:"setUi",ui:{leftSideBarVisible:!0}})))},Mr=()=>{C(Re,{accept:"image/*",title:Ot.mediaLibrary})},jr=()=>{So(D),jt.select(null),u()},Er=()=>{So(gt??D),Lt||rt({type:"setUi",ui:{rightSideBarVisible:!0}})},Rr=ot.data.content??[],Lr=()=>{const e=Rr.findIndex(yt),n=Rr.findIndex(kt);return{floor:e>=0?e+1:0,cap:n>=0?n:Rr.length}},Vr=dt,Fr=Lo.stripCopy,Hr=e=>i(e,Fr),Wr=w(),Ur=Te({data:ot.data,config:Vr,readOnly:Boolean(Qn),clipboard:Wr,strip:Fr?e=>Fr(e):void 0,afterRemove:"none",stepBounds:(e,n)=>{if(e.parentId!==un||e.slot!==fn)return{min:0,max:n-1};const{floor:t,cap:o}=Lr();return{min:t,max:o-1}},commit:(e,{select:n})=>{void 0!==n&&So(D);const t=void 0===n||"node"===n?.kind?n:null;jt.commitDocument(e,t)}}),Dr=e=>{const n=mn(ot.data,dt,e);if(!n)return!1;const t=pn(n.place),o=n.node,r=t===le?Xr(o):ci(o);return!!Ur.remove(e)&&(gr(xt.deleted({name:r}),"success",{duration:8e3,action:{label:xt.bar.undo,onClick:()=>{Ur.restore(n.node,n.place)}}}),!0)},Gr={...Ur,remove:Dr},Jr=e=>Jo(e,"block",dt.components[e]?.label??e),Yr=xn(e=>dt.components[e]?.defaultProps??{},[dt]),Kr=e=>Jo(e,"section",Jr(e)),Xr=e=>l({type:e.type,props:e.props??{}},Kr(e.type),Xo),{nodeAddresses:Qr,zoneItems:_r}=kn(()=>{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>=de)return;const s=/* @__PURE__ */new Map;for(const{child:e,zone:t}of ce(dt,n))s.set(t,[...s.get(t)??[],e]);for(const[e,n]of s)t(n,e,i+1)})};return t(Rr,le,0),{nodeAddresses:e,zoneItems:n}},[Rr,dt]),Zr=xn(e=>_r.get(e)??[],[_r]),qr=e=>{const n=Qr.get(e);return n?Zr(n.zone)[n.index]:void 0},ei=e=>ie(Lo,dt,e),ni=e=>{if(!Lo.slotsOf||e===le)return null;const n=e.lastIndexOf(":");if(n<=0)return null;const t=qr(e.slice(0,n));if(!t)return null;const o=ei(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}},ti=(()=>{if(!Z(ko))return null;const e=`${ko.nodeId}:${ko.slot}`;return ni(e)?.slot.panel===ko.kind?e:null})(),oi=yn(null);vn(()=>{const e=oi.current;if(oi.current=null,!ti||!Z(ko))return;const n=ko.nodeId;No(n,{scroll:e!==ti}),ir(e=>{if(!e.has(n))return e;const t=new Set(e);return t.delete(n),t})},[ko]);const ri=(e,n,t)=>{const o=String(e.props.id);if(!n.panel)return void(e=>{const n=Qr.get(e);n&&(n.zone===le?zi(n.index):el(n.zone,n.index,e,qr(n.zone.slice(0,n.zone.lastIndexOf(":")))?.type??""))})(o);const r={kind:n.panel,nodeId:o,slot:n.slot},i=`${o}:${n.slot}`;t&&ti!==i&&(oi.current=i),Ao(null,r),Lt||rt({type:"setUi",ui:{rightSideBarVisible:!0}}),bi(o)},ii=(e,n,t)=>{const o=`${e}:${n}`;if(ir(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;ti!==o&&(oi.current=o);Ao(null,{kind:t,nodeId:e,slot:n})},li=(e,n,t)=>{if(Qn||!Lo.moveSlot)return;const o=qr(e),r=o?ei(o).filter(e=>e.rung):[],i=r[n];if(!i)return;const l={parentId:e,slot:Fn,index:n},s=ln(l,{...l,index:Math.min(Math.max(t,0),r.length)});if(s===n)return;const d=Lo.moveSlot(e,n,s);"string"==typeof d&&ii(e,d,i.panel)},si=Ko(),di=kn(()=>{const e=/* @__PURE__ */new Map;for(const n of si??[])e.set(n.slug,n.name);return e},[si]),ci=e=>s(e,Jr,Go.plainText,e=>di.get(e),Go.rowName),ai=(e,n)=>{const t=dt.components[e.type]?.fields,o=n===le||kl(n)?"section":"block",r=n===le&&(yt(e)||kt(e)||ft(e.type)),i="block"===o?d(t):r?null:c(t);return Go.renamePropOf?Go.renamePropOf(e,o,i):i},pi=(e,n,t,o)=>{if(!(!Qn&&qo?.zone===e&&qo.index===n))return;const r=(t,o)=>{er(null),o&&((e,n,t)=>{const o=Zr(e)[n];if(!o)return;const r=ai(o,e);r&&jt.replaceComponent(e,n,{...o,props:{...o.props,[r]:t.trim()}})})(e,n,t)};/* @__PURE__ */
13
+ return An("input",{className:"es-tree-rename",defaultValue:o,autoFocus:!0,"aria-label":xt.rename,onClick:e=>e.stopPropagation(),onBlur:e=>r(e.currentTarget.value,!0),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),r(e.currentTarget.value,!0)):"Escape"===e.key&&(e.preventDefault(),r("",!1))}},t)},ui=n(q(),Ct),fi=ui.scope({target:Xe,siteId:Dn,docId:Qe}),hi=dt,mi=(e,n)=>n===le?Kr(e):Jr(e),gi=(e,n,t)=>{const o=ui.plan(fi,t,mi(t.type,e),hi);o&&(o.changed&&jt.replaceComponent(e,n,{...t,props:{...o.props,id:t.props.id}}),gr(o.message))},yi=b({nodesIn:Zr,nodeAt:(e,n)=>Zr(e)[n]??null,labelOf:(e,n)=>n===le?Kr(e):Jr(e),renamePropOf:ai,beginRename:(e,n)=>er({zone:e,index:n}),history:{hasPast:it.hasPast,hasFuture:it.hasFuture,back:()=>it.back(),forward:()=>it.forward()},openAddSection:()=>{jt.select(null),Pi(null)},openPageSettings:()=>{jt.select(null),So(D)},pageSettingsLabel:xt.pageSettings,words:{menu:Bt,styleClipboard:Ct,screen:xt.menu},readOnly:Boolean(Qn),collapseAll:()=>ir(new Set(Zr(le).map(e=>String(e.props.id)))),onPasteRefused:e=>gr(e?xt.pasteRefused({name:e.label}):xt.menu.clipboardRefused,"error"),canPasteAt:(e,n)=>vl(e,n),menuRows:jo.menuRows,isLocked:e=>Vo(e.type),duplicateBlocked:e=>Fo(ot.data,e),permits:e=>se(dt,e.type),canAddTo:Uo,nodeOps:Gr,isPinned:(e,n)=>n===le&&(yt(e)||kt(e)),sectionBand:Lr,openAddInside:(e,n)=>{e===le?zi(n):jt.select({zone:e,index:n}),Pi(null)},locate:e=>Qr.get(e)??null,rowNameOf:(e,n)=>n===le?Xr(e):ci(e),selectAt:(e,n,t,o)=>{e===le?zi(n):el(e,n,t,o??"")},slotRung:e=>{const n=ni(e);return n?.slot.panel?{label:n.slot.label,select:()=>ri(n.node,n.slot,!1)}:null},style:{held:()=>O(fi),canCopy:e=>ui.rows(hi,e).some(e=>!1!==e.counted),copy:(e,n)=>ui.copy(fi,e,mi(e.type,n),hi),paste:(e,n,t)=>gi(e,n,t)},keys:qn?{target:lo,selected:()=>{const e=ot.ui.itemSelector;return e?{zone:e.zone??le,index:e.index}:null},held:()=>Wr.get(),readOnly:Boolean(Qn),onDone:({done:e,name:n})=>{"copied"===e&&gr(xt.copied({name:n}))}}:void 0},io),ki=yn({copy:(e,n)=>{},paste:(e,n,t)=>{},at:()=>null,readOnly:!1});vn(()=>{ki.current={copy:(e,n)=>ui.copy(fi,e,mi(e.type,n),hi),paste:gi,at:()=>{const e=ot.ui.itemSelector;if(!e)return null;const n=e.zone??le,t=Zr(n)[e.index];return t?{zone:n,index:e.index,node:t}:null},readOnly:Boolean(Qn)}});const Si=xn(e=>{const n=I(e);if(!n)return;const t=ki.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))},[]);vn(()=>{if(!lo)return;const e=e=>Si(e);return lo.addEventListener("keydown",e),()=>lo.removeEventListener("keydown",e)},[Si,lo]),an(io,"keydown",Si);const vi=Rr.map(e=>e.props.id).join("|");vn(()=>{const e=io?.document??null,n=io?.window??null;let t=0;const o=[],r=()=>{if(!e)return void yo(e=>e.length?[]:e);const n=Rr.findIndex(kt),t=n>=0?n:Rr.length,o=n=>{const t=Rr[n]?.props?.id;return null==t?null:e.querySelector(`[data-puck-component="${CSS.escape(String(t))}"]`)},r=e=>e?[...e.querySelectorAll(cn)].map(e=>e.getBoundingClientRect()).filter(e=>e.width>0||e.height>0):[],i=[];for(let e=Rr.length>0&&!yt(Rr[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=Vn(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})}yo(e=>function(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t].top!==n[t].top||e[t].index!==n[t].index||e[t].height!==n[t].height)return!1;return!0}(e,i)?e:i)},i=()=>{cancelAnimationFrame(t),t=requestAnimationFrame(r)};if(!e||!n)return void r();n.addEventListener("scroll",i,{passive:!0});const l=new ResizeObserver(i);return l.observe(e.documentElement),r(),o.push(setTimeout(r,150),setTimeout(r,450)),()=>{cancelAnimationFrame(t),o.forEach(clearTimeout),n.removeEventListener("scroll",i),l.disconnect()}},[io,vi,Dt,Cr,Rt,Lt,lt?.props.id]);const xi=io?.document??null,wi=io?.window??null;vn(()=>{const e=oo.current;if(!e||!xi||!wi)return;const n=[],t=()=>{const n=xi.querySelector(`[data-puck-component="${CSS.escape(e.id)}"]`);if(!n)return!1;const t=n.getBoundingClientRect().top-e.offset;return Math.abs(t)>1&&wi.scrollTo({left:wi.scrollX,top:wi.scrollY+t,behavior:"instant"}),!0};return oo.current=null,t()&&n.push(setTimeout(t,150),setTimeout(t,450)),()=>n.forEach(clearTimeout)},[xi,wi]);const bi=e=>{jo.holdCanvasOn?jo.holdCanvasOn(e):a(e)},zi=e=>{So(D),jt.select({index:e}),jo.sectionPressed?.(Rr[e]);const n=Rr[e]?.props?.id;n&&bi(n)},Bi=e=>{const{floor:n,cap:t}=Lr(),o=e=>Math.min(Math.max(n,e),t);if("number"==typeof e)return o(e);const r=lt&&ko.kind!==gt?.kind?Rr.findIndex(e=>e.props.id===lt.props.id):-1;return o(r>=0?r+1:t)},Ci=(e,n)=>{const{floor:t,cap:o}=Lr(),r=Math.min(Math.max(n,t),o),i=e<r?r-1:r;return i===e?{moved:!1,dest:e}:(jt.reorderComponent(le,e,i),jt.select({index:i}),{moved:!0,dest:i})},Oi=(e,n,t,o)=>{So(D),jt.select(o?{index:o.index,zone:o.zone}:{index:e}),a(n),gr(xt.sectionAdded({name:t}))},Ii=(e,n)=>{const t=Bi(n),o=Wo(e,{nodeDefaults:Yr,newNodeId:fe,sectionLabel:Kr,blockIsOffered:Do}),r=o?jt.insertNode(le,t,o):jt.insertSection(e,t);return Oi(t,r,Kr(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 ce(dt,e)){if(s.type===t&&(!o.at||n>o.at.depth)){const r=Uo(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},Ni=(e,n,t)=>{const o=Bi(t),r=jt.insertNode(le,o,n);return Oi(o,r,e),o},Pi=e=>$i(le,e),$i=(e,n)=>{hr.current=document.activeElement??null,Kt&&(ao.current=po.current,po.current=!1,Xt()),fo(null===n?null:{zone:e,index:n}),co(!0),Rt||(ao.current=!0,rt({type:"setUi",ui:{leftSideBarVisible:!0}}))},Ti=()=>{co(!1),fo(null),ao.current&&rt({type:"setUi",ui:{leftSideBarVisible:!1}}),ao.current=!1},Ai=(e,n,t)=>{if("section"===e.kind)jt.insertComponent(n,e.type,t);else{if("template"!==e.kind)return;jt.insertNode(n,t,Hr(e.template.node))}So(D),jt.select({index:t,zone:n})},Mi=(e,n)=>Go.rowName?n?yt(e)?Go.rowName(e,"section",xt.header):kt(e)?Go.rowName(e,"section",xt.footer):ft(e.type)?Go.rowName(e,"section",Jr(e.type)):Xr(e):ci(e):n?Kr(e.type):Jr(e.type),ji=e=>n=>{e()},Ei=()=>jo.editPinnedSource?.(),Ri=(e,n,t)=>{if(Qn)return null;const o=Zr(e)[n];return o&&!se(dt,o.type).delete?null:/* @__PURE__ */An(Oe,{kind:"delete",label:xt.deleteNamed({name:t}),onClick:()=>((e,n)=>{const t=Zr(e)[n]?.props?.id;null!=t&&Dr(String(t))})(e,n),children:/* @__PURE__ */An(Nn,{size:15})})},Li=e=>Go.rowPreview?.(e)||void 0,Vi=e=>Go.rowMarks?.(e)??void 0,Fi=(e,n,t)=>Go.rowActions?.(e,n,t)??null,Hi=(e,n,t,o)=>{if(Qn)return null;const r=Boolean(t.props._hidden);/* @__PURE__ */
14
+ return An(Oe,{kind:"eye",label:r?xt.showNamed({name:o}):xt.hideNamed({name:o}),onClick:()=>Ui(e,n,t),children:/* @__PURE__ */An(r?Pn:$n,{size:14,strokeWidth:1.8,strokeLinecap:void 0,strokeLinejoin:void 0})})},Wi=e=>{const n=Kr(Rr[e]?.type??""),t=n?xt.addSectionBefore({name:n}):xt.addSectionHere;return Ul(le,e,()=>Pi(e),t)},Ui=(e,n,t)=>{jt.replaceComponent(e,n,{...t,props:{...t.props,_hidden:!t.props._hidden}})},Di=e=>ae(dt,e),Gi=e=>ce(dt,e),Ji=e=>Lo.slotsOf?ei(e).map(n=>({slot:n.slot,rung:n.rung?n:null,kids:pe(e,n.slot)})):[{slot:null,rung:null,kids:Gi(e)}],Yi=e=>Lo.slotsOf?Ji(e).flatMap(e=>e.kids):Gi(e),Ki=e=>Boolean(Lo.slotsOf)&&ei(e).some(e=>e.rung),Xi=(e,n,t)=>null===t?void 0===n?Uo(e):Uo(e,n):Uo(e,n,t),Qi=(e,n,t)=>{const o=ue(dt,e.type,n)&&(t||Yi(e).length>0||Ki(e));return{collapsible:o,folded:o&&pr(String(e.props.id))}},_i=(e,n,t)=>Ji(e).flatMap(o=>{const r=o.rung?n+1:n,i=o.kids.flatMap(({child:e})=>Qi(e,r,t(e.type)).collapsible?[String(e.props.id),..._i(e,r+1,t)]:[]);return o.rung?[`${e.props.id}:${o.rung.slot}`,...i]:i}),Zi=e=>Yi(e).length>0||Ki(e)||Boolean(Uo(e.type)),qi=e=>Boolean(Uo(e)),el=(e,n,t,o)=>{if(So(D),Uo(o)?.spec?.slider){const t=e.split(":")[0];p(t,n),jt.select({index:n,zone:e}),a(t)}else jt.select({index:n,zone:e}),bi(t)},nl=(e,n,t,o,r)=>{const i=`${e}:${n}`;jt.insertComponent(i,t,o),Uo(r)?.spec?.slider?requestAnimationFrame(()=>{p(e,o),jt.select({index:o,zone:i})}):jt.select({index:o,zone:i})},tl=(e,n,t)=>{jt.insertComponent(e,n,t),So(D),jt.select({index:t,zone:e})},ol=yn(/* @__PURE__ */new Set);vn(()=>{Rr.forEach(e=>{const n=Uo(e.type)?.spec;if(!n)return;const t=e.props.id;if(ol.current.has(t))return;ol.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(Yr)).forEach((e,t)=>Tt.seedChild(o,t,n.childType,e))})},[Rr,Tt,Yr]);const rl=yn(/* @__PURE__ */new Set);vn(()=>{Rr.forEach((n,t)=>{const o=n.props.id;if(rl.current.has(o))return;const r=e(n,Di(n.type));rl.current.add(o),r&&Tt.replaceComponent(le,t,{...n,props:r})})},[Rr,Tt]),ee(Tt,dt);const il=Rr.findIndex(kt),ll=il>=0?Rr[il]:null,sl=St?Rr.findIndex(yt):-1,dl=sl>=0?Rr[sl]:null,cl=Rr.find(e=>e.type===pt)??null,al=Rr.find(e=>e.type===ut)??null,pl=il>=0?il:Rr.length,ul=[];Rr.forEach(e=>{kt(e)||(Zi(e)&&ul.push(String(e.props.id)),ul.push(..._i(e,1,qi)))}),ll&&(ul.push(String(ll.props.id)),ul.push(..._i(ll,1,qi)));const fl=ul.length>0&&ul.every(e=>rr.has(e)),hl=e=>{const n=Go.blockRowName(e,Jr);return Go.rowName?Go.rowName(e,"block",n):n},ml=(e,n,t,o)=>{const r=Zr(e)[t];if(!r)return;const i={...hn(e),index:t},l={...hn(n),index:Math.min(Math.max(o,0),Zr(n).length)},s=ln(i,l);if(e!==n||s!==t)try{Ur.move(String(r.props.id),{...l,index:s})}catch(e){if(!(e instanceof gn))throw e}},gl=e=>{const n=/* @__PURE__ */new Set,t=e=>{for(const{child:o,zone:r}of Gi(e))n.add(r),t(o)};for(const t of Di(e.type))n.add(`${e.props.id}:${t}`);return t(e),n},yl=e=>{let n=e.slice(0,e.indexOf(":"));for(let e=0;e<64;e++){const e=Qr.get(n);if(!e)return null;if(e.zone===le)return n;n=e.zone.slice(0,e.zone.indexOf(":"))}return null},kl=e=>{const n=e.slice(0,e.indexOf(":")),t=Rr.find(e=>ft(e.type)&&String(e.props.id)===n);return t&&ht(n)===e?t:null},Sl=(e,n,t)=>{if(e.rung){const t=qr(e.rung.nodeId),o=t?ei(t).filter(e=>e.rung).length:0;return n.parentId===e.rung.nodeId&&n.slot===Fn&&n.index>=0&&n.index<=o}if(n.slot===Fn)return!1;if(e.add)return wl(e.add,n);const o=pn(n);if(ft(e.type))return!1;const r=kl(o),i=kl(e.zone);if(r||i)return!(!r||!i)&&(n.index>=0&&n.index<=Zr(o).length);if(e.zone===le||o===le){if(e.zone!==o)return!1;const{floor:t,cap:r}=Lr();return n.index>=t&&n.index<=r}if(n.index<0||n.index>Zr(o).length)return!1;if(e.zone===o)return!0;const l=ll&&!ct.lastIsOpen?String(ll.props.id):null;return(!l||yl(e.zone)!==l&&yl(o)!==l)&&((e,n,t,o)=>{if(e===n)return!0;const r=o??Zr(e)[t];if(!r)return!1;const i=n.split(":")[0],l=Qr.get(i),s=l?Zr(l.zone)[l.index]:void 0;if(!s)return!1;if(!o&&gl(r).has(n))return!1;const d=Uo(s.type,Ho(ot?.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?.(Zr(n),r))})(e.zone,o,e.index,t)},vl=(e,n)=>{const t=pn(e.from);if(t===pn(n))return!0;const o=e.node;return Sl({id:String(o.props?.id??""),zone:t,index:-1,type:o.type},n,o)},xl=e=>{const n=e.slice(0,e.indexOf(":")),t=Qr.get(n),o=t?Zr(t.zone)[t.index]:void 0;if(!t||!o)return null;const r=Uo(o.type,Ho(ot?.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:Jr(r.spec.childType)}]:[]),l=ni(e);return{parent:o,parentId:n,target:r,choices:i,parentName:l?l.slot.label:Mi(o,t.zone===le)}},wl=(e,n)=>{const t=pn(n);if("block"!==e.kind){if(kl(t))return n.index>=0&&n.index<=Zr(t).length;if(t!==le)return!1;const{floor:e,cap:o}=Lr();return n.index>=e&&n.index<=o}if(t===le)return!1;const o=xl(t);return!(!o||!o.choices.some(n=>n.type===e.type))&&!o.target.spec?.addBlocked?.(Zr(t))},bl=(e,n)=>{e.rung?li(e.rung.nodeId,e.index,n.index):e.add?((e,n)=>{if("block"!==e.kind&&kl(pn(n)))return void Ai(e,pn(n),n.index);if("section"===e.kind)return void Ii(e.type,n.index);if("template"===e.kind)return void Ni(e.template.name,Hr(e.template.node),n.index);const t=pn(n),o=xl(t);o&&(o.target.spec?nl(o.parentId,o.target.slot,e.type,n.index,o.parent.type):tl(t,e.type,n.index))})(e.add,n):e.zone===le?Ci(e.index,n.index):ml(e.zone,pn(n),e.index,n.index)},[zl]=Sn(()=>on()),Bl=rn({keyOf:e=>e.id,readOnly:Boolean(Qn),session:zl,canDrop:Sl,onDrop:bl,onStep:(e,n)=>{e.rung?li(e.rung.nodeId,e.index,n<0?e.index-1:e.index+2):e.zone===le?((e,n)=>{const t=Kr(Rr[e]?.type??""),o=Ci(e,n<0?e-1:e+2);if(!o.moved)return void gr(n<0?xt.sectionFirst({name:t}):xt.sectionLast({name:t}));const{floor:r,cap:i}=Lr();gr(xt.sectionMoved({name:t,n:o.dest-r+1,total:i-r}))})(e.index,n):ml(e.zone,e.zone,e.index,n<0?e.index-1:e.index+2)}}),Cl=xn(e=>{const{floor:n,cap:t}=Lr(),o=[];for(const r of e.nodes){const e=pn(r.place),i=Zr(e)[r.place.index];if(!i||String(i.props.id)!==r.id)continue;if(yt(i)||kt(i)||Vo(i.type))continue;if(ft(i.type))continue;const l=Boolean(kl(e)),s=e===le||l;e===le&&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?Kr(i.type):ci(i),from:r.place})}const r=e.zones.flatMap(e=>{const n=pn(e.list);return n===le&&0===e.children.length?[{...e,addLabel:xt.addSection,addAlways:!0}]:e.children.length>0||Boolean(xl(n)?.choices.length)||Boolean(kl(n))?[e]:[]}),i=r.flatMap(e=>{const n=pn(e.list);return n===le||kl(n)||!xl(n)?.choices.length?[]:qe(e,xt.addBlockHere)});return{sources:o,zones:r,seams:i}},[ot.data]),Ol=null==lt?.props.id?null:String(lt.props.id),Il=xn(e=>{const n=dt,t=e=>!e.item.rung&&null!==mn(ot.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(Ol);return i||(r(Ae(ot.data,n,o.item.id,Ol))??o)},[ot.data,dt,Ol]),Nl=e=>{So(D),jt.select(e.zone===le?{index:e.index}:{index:e.index,zone:e.zone})},Pl=ne(),$l=()=>({data:ot.data,device:Dt,ops:jt,inspector:Mo}),Tl=Pl?.model,Al=kn(()=>Tl?e=>Tl(e,Cl(e),$l()):Cl,[Tl,Cl,Dt]),Ml=Pl?.measure,jl=Ml?(e,n)=>Ml(e,n,$l()):void 0,El=Pl?.canDrop,Rl=El?(e,n)=>El(e,n,Sl,$l()):Sl,Ll=Pl?.drop,Vl=Ll?(e,n)=>Ll(e,n,bl,$l()):bl,Fl=Pl?.pick,Hl=Fl?e=>Fl(e,Nl,$l()):Nl,Wl=e=>{const n=pn(e),t=ni(n);t&&ri(t.node,t.slot,!1),$i(n,e.index)},Ul=(e,n,t,o)=>/* @__PURE__ */An(Ie,{...Qn?{}:Bl.seam({place:{...hn(e),index:n}}),onAdd:Qn?void 0:t,label:o},`seam:${e}:${n}`),Dl={rowClick:ji,isCollapsed:pr,toggleCollapse:ur},Gl=e=>{const n=String(e.props.id),t=Rr.findIndex(e=>String(e.props.id)===n),o=ht(n),r=Zr(o),i=pr(n),l=Jr(e.type),s=Go.rowName?Go.rowName(e,"section",l):l,d=e=>Ul(o,e,()=>$i(o,e),xt.addSectionHere);/* @__PURE__ */
15
15
  return Mn(jn,{children:[
16
- /* @__PURE__ */An(Oe,{words:wt,icon:/* @__PURE__ */An(Ko,{type:e.type,size:13}),name:s,preview:Li(e),marks:Vi(e),onSelect:()=>zi(t),nameSlot:pi(le,t,n,s),selected:Bo===n,actions:Fi(e,le,t)??void 0,rowProps:{"data-node-id":n,onClick:ji(()=>zi(t))},fold:{open:!i,label:"section",onToggle:()=>ur(n)}}),!i&&/* @__PURE__ */Mn(Ie,{children:[r.map((n,t)=>{const r=String(n.props.id),i=Xr(n),l=Zi(n),s=l&&pr(r),c=()=>el(o,t,r,e.type),{rowProps:a,...p}=Bl.row({item:{id:r,zone:o,index:t,type:n.type},place:{...hn(o),index:t}},{"data-node-id":r,onClick:ji(c)});/* @__PURE__ */
16
+ /* @__PURE__ */An(be,{words:wt,icon:/* @__PURE__ */An(Yo,{type:e.type,size:13}),name:s,preview:Li(e),marks:Vi(e),onSelect:()=>zi(t),nameSlot:pi(le,t,n,s),selected:Bo===n,actions:Fi(e,le,t)??void 0,rowProps:{"data-node-id":n,onClick:ji(()=>zi(t))},fold:{open:!i,label:"section",onToggle:()=>ur(n)}}),!i&&/* @__PURE__ */Mn(ze,{children:[r.map((n,t)=>{const r=String(n.props.id),i=Xr(n),l=Zi(n),s=l&&pr(r),c=()=>el(o,t,r,e.type),{rowProps:a,...p}=Bl.row({item:{id:r,zone:o,index:t,type:n.type},place:{...hn(o),index:t}},{"data-node-id":r,onClick:ji(c)});/* @__PURE__ */
17
17
  return Mn(bn,{children:[d(t),
18
- /* @__PURE__ */An(Oe,{words:wt,icon:/* @__PURE__ */An(Ko,{type:n.type,size:13}),name:i,preview:Li(n),marks:Vi(n),onSelect:c,nameSlot:pi(o,t,r,i),selected:Bo===r,hidden:Boolean(n.props._hidden),...p,fold:l?{open:!s,label:"section",onToggle:()=>ur(r)}:void 0,actions:/* @__PURE__ */Mn(jn,{children:[Ei(o,t,i),Fi(n,o,t),Wi(o,t,n,i)]}),rowProps:a}),l&&!s&&/* @__PURE__ */An(Ie,{children:Yl(n,2)})]},r)}),d(r.length)]})]})},Jl=(e,n,t,o,r)=>{const i=String(e.props.id),l=`${i}:${n.slot}`,s=Bl.dragging,d=!pr(l)&&s?.rung?.nodeId!==i,c={...hn(l),index:0},a=s&&!s.rung&&Sl(s,c)?c:void 0,p=()=>ri(e,n,!0),{rowProps:u,...f}=Bl.row({item:{id:`rung:${l}`,zone:`${i}:${Fn}`,index:t,type:e.type,rung:{nodeId:i,slot:n.slot}},place:{parentId:i,slot:Fn,index:t},into:a,canDrag:Boolean(Lo.moveSlot)&&!1!==n.movable&&o>1},{"data-slot-zone":l,onClick:ji(p)}),h=Qn?null:Lo.slotActions?.(e,n.slot);/* @__PURE__ */
18
+ /* @__PURE__ */An(be,{words:wt,icon:/* @__PURE__ */An(Yo,{type:n.type,size:13}),name:i,preview:Li(n),marks:Vi(n),onSelect:c,nameSlot:pi(o,t,r,i),selected:Bo===r,hidden:Boolean(n.props._hidden),...p,fold:l?{open:!s,label:"section",onToggle:()=>ur(r)}:void 0,actions:/* @__PURE__ */Mn(jn,{children:[Ri(o,t,i),Fi(n,o,t),Hi(o,t,n,i)]}),rowProps:a}),l&&!s&&/* @__PURE__ */An(ze,{children:Kl(n,2)})]},r)}),d(r.length)]})]})},Jl=(e,n,t,o,r)=>{const i=String(e.props.id),l=`${i}:${n.slot}`,s=Bl.dragging,d=!pr(l)&&s?.rung?.nodeId!==i,c={...hn(l),index:0},a=s&&!s.rung&&Sl(s,c)?c:void 0,p=()=>ri(e,n,!0),{rowProps:u,...f}=Bl.row({item:{id:`rung:${l}`,zone:`${i}:${Fn}`,index:t,type:e.type,rung:{nodeId:i,slot:n.slot}},place:{parentId:i,slot:Fn,index:t},into:a,canDrag:Boolean(Lo.moveSlot)&&!1!==n.movable&&o>1},{"data-slot-zone":l,onClick:ji(p)}),h=Qn?null:Lo.slotActions?.(e,n.slot);/* @__PURE__ */
19
19
  return Mn(bn,{children:[n.heading,
20
- /* @__PURE__ */An(Oe,{words:wt,icon:n.glyph??null,name:n.label,badge:n.badge,onSelect:p,selected:ti===l,...f,dragHint:n.dragHint,fold:{open:d,label:n.label,onToggle:()=>ur(l)},actions:h&&h.length>0?/* @__PURE__ */An(jn,{children:h.map((t,o)=>/* @__PURE__ */An(Pe,{kind:"delete"===t.kind?"delete":"plain",label:t.label,disabled:t.disabled,onClick:()=>((e,n,t)=>{if(Qn||t.disabled)return;const o=String(e.props.id),r=e=>{"string"==typeof e&&ii(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__ */An(Nn,{size:15}):/* @__PURE__ */An(Tn,{size:15})},`${o}:${t.kind}`))}):void 0,rowProps:u}),d&&/* @__PURE__ */An(Ie,{children:r})]},l)},Kl=(e,n)=>{const t=Ji(e),o=t.filter(e=>e.rung).length;let r=0;/* @__PURE__ */
21
- return An(jn,{children:t.map(t=>{const i=t.kids,l=t.rung?n+1:n,s=Xi(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=null!==c&&Boolean(xl(c)?.choices.length),p=(e,n)=>a?Dl(e,n,()=>Pi(e,n),xt.addBlockHere):Dl(e,n),u=/* @__PURE__ */Mn(jn,{children:[i.map(({child:n,zone:t,index:o})=>{const r=Bo===String(n.props.id),{collapsible:i,folded:s}=Qi(n,l,qi(n.type)),d=String(n.props.id),c=hl(n),a=()=>el(t,o,d,e.type),{rowProps:u,...f}=Bl.row({item:{id:d,zone:t,index:o,type:n.type},place:{...hn(t),index:o}},{"data-node-id":d,onClick:ji(a)});/* @__PURE__ */
20
+ /* @__PURE__ */An(be,{words:wt,icon:n.glyph??null,name:n.label,badge:n.badge,onSelect:p,selected:ti===l,...f,dragHint:n.dragHint,fold:{open:d,label:n.label,onToggle:()=>ur(l)},actions:h&&h.length>0?/* @__PURE__ */An(jn,{children:h.map((t,o)=>/* @__PURE__ */An(Oe,{kind:"delete"===t.kind?"delete":"plain",label:t.label,disabled:t.disabled,onClick:()=>((e,n,t)=>{if(Qn||t.disabled)return;const o=String(e.props.id),r=e=>{"string"==typeof e&&ii(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__ */An(Nn,{size:15}):/* @__PURE__ */An(Tn,{size:15})},`${o}:${t.kind}`))}):void 0,rowProps:u}),d&&/* @__PURE__ */An(ze,{children:r})]},l)},Yl=(e,n)=>{const t=Ji(e),o=t.filter(e=>e.rung).length;let r=0;/* @__PURE__ */
21
+ return An(jn,{children:t.map(t=>{const i=t.kids,l=t.rung?n+1:n,s=Xi(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=null!==c&&Boolean(xl(c)?.choices.length),p=(e,n)=>a?Ul(e,n,()=>$i(e,n),xt.addBlockHere):Ul(e,n),u=/* @__PURE__ */Mn(jn,{children:[i.map(({child:n,zone:t,index:o})=>{const r=Bo===String(n.props.id),{collapsible:i,folded:s}=Qi(n,l,qi(n.type)),d=String(n.props.id),c=hl(n),a=()=>el(t,o,d,e.type),{rowProps:u,...f}=Bl.row({item:{id:d,zone:t,index:o,type:n.type},place:{...hn(t),index:o}},{"data-node-id":d,onClick:ji(a)});/* @__PURE__ */
22
22
  return Mn(bn,{children:[0===o&&p(t,0),
23
- /* @__PURE__ */An(Oe,{words:wt,icon:/* @__PURE__ */An(Ko,{type:n.type,size:13}),name:c,preview:Li(n),marks:Vi(n),onSelect:a,nameSlot:pi(t,o,d,c),selected:r,hidden:Boolean(n.props._hidden),...f,fold:i?{open:!s,label:"group",onToggle:()=>ur(d)}:void 0,actions:/* @__PURE__ */Mn(jn,{children:[Ei(t,o,c),Fi(n,t,o),Wi(t,o,n,c)]}),rowProps:u}),i&&!s&&/* @__PURE__ */An(Ie,{children:Kl(n,l+1)}),p(t,o+1)]},String(n.props.id??`${t}-${o}`))}),null===c?d&&!i.some(e=>e.zone===d)?p(d,0):null:0!==i.length||!t.rung&&d!==c?null:p(c,0)]});return t.rung?Jl(e,t.rung,r++,o,u):/* @__PURE__ */An(bn,{children:u},t.slot??"")})})},Yl=(e,n)=>{const t=Wo(ot?.data,e.type,String(e.props.id)),o=Ji(e),r=o.filter(e=>e.rung).length;let i=0;/* @__PURE__ */
24
- return An(jn,{children:o.map(o=>{const l=o.kids,s=o.rung?n+1:n,d=Xi(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=(n,t)=>{const o=n===f&&c&&!c.addBlocked?.(a)?()=>nl(e.props.id,c.slot,c.childType,t,e.type):n===h?()=>Pi(n,t):void 0;return Dl(n,t,o,n===f&&c?c.addLabel:xt.addBlockHere)},g=null===o.slot?null:`${u}:${o.slot}`,y=Boolean(c&&!c.fixed&&(null===g||g===f)),k=/* @__PURE__ */Mn(jn,{children:[l.map(({child:n,zone:t,index:o})=>{const r=Bo===String(n.props.id),i=ci(n),l=String(n.props.id),{collapsible:d,folded:c}=Qi(n,s,qi(n.type)),a=Ui(n.type),p=1===a.length?`${l}:${a[0]}`:null,u=p?{...hn(p),index:Zr(p).length}:void 0,f=Bl.dragging,h=u&&f&&Sl(f,u)?u:void 0,g=()=>el(t,o,l,e.type),{rowProps:y,...k}=Bl.row({item:{id:l,zone:t,index:o,type:n.type},place:{...hn(t),index:o},into:h,canDrag:!Vo(n.type)},{"data-node-id":l,onClick:ji(g)});/* @__PURE__ */
23
+ /* @__PURE__ */An(be,{words:wt,icon:/* @__PURE__ */An(Yo,{type:n.type,size:13}),name:c,preview:Li(n),marks:Vi(n),onSelect:a,nameSlot:pi(t,o,d,c),selected:r,hidden:Boolean(n.props._hidden),...f,fold:i?{open:!s,label:"group",onToggle:()=>ur(d)}:void 0,actions:/* @__PURE__ */Mn(jn,{children:[Ri(t,o,c),Fi(n,t,o),Hi(t,o,n,c)]}),rowProps:u}),i&&!s&&/* @__PURE__ */An(ze,{children:Yl(n,l+1)}),p(t,o+1)]},String(n.props.id??`${t}-${o}`))}),null===c?d&&!i.some(e=>e.zone===d)?p(d,0):null:0!==i.length||!t.rung&&d!==c?null:p(c,0)]});return t.rung?Jl(e,t.rung,r++,o,u):/* @__PURE__ */An(bn,{children:u},t.slot??"")})})},Kl=(e,n)=>{const t=Ho(ot?.data,e.type,String(e.props.id)),o=Ji(e),r=o.filter(e=>e.rung).length;let i=0;/* @__PURE__ */
24
+ return An(jn,{children:o.map(o=>{const l=o.kids,s=o.rung?n+1:n,d=Xi(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=(n,t)=>{const o=n===f&&c&&!c.addBlocked?.(a)?()=>nl(e.props.id,c.slot,c.childType,t,e.type):n===h?()=>$i(n,t):void 0;return Ul(n,t,o,n===f&&c?c.addLabel:xt.addBlockHere)},g=null===o.slot?null:`${u}:${o.slot}`,y=Boolean(c&&!c.fixed&&(null===g||g===f)),k=/* @__PURE__ */Mn(jn,{children:[l.map(({child:n,zone:t,index:o})=>{const r=Bo===String(n.props.id),i=ci(n),l=String(n.props.id),{collapsible:d,folded:c}=Qi(n,s,qi(n.type)),a=Di(n.type),p=1===a.length?`${l}:${a[0]}`:null,u=p?{...hn(p),index:Zr(p).length}:void 0,f=Bl.dragging,h=u&&f&&Sl(f,u)?u:void 0,g=()=>el(t,o,l,e.type),{rowProps:y,...k}=Bl.row({item:{id:l,zone:t,index:o,type:n.type},place:{...hn(t),index:o},into:h,canDrag:!Vo(n.type)},{"data-node-id":l,onClick:ji(g)});/* @__PURE__ */
25
25
  return Mn(bn,{children:[0===o&&m(t,0),
26
- /* @__PURE__ */An(Oe,{words:wt,icon:/* @__PURE__ */An(Ko,{type:n.type,size:13}),name:i,preview:Li(n),marks:Vi(n),onSelect:g,nameSlot:pi(t,o,l,i),selected:r,hidden:Boolean(n.props._hidden),...k,fold:d?{open:!c,label:"group",onToggle:()=>ur(l)}:void 0,actions:Vo(n.type)?Fi(n,t,o)??void 0:/* @__PURE__ */Mn(jn,{children:[Ei(t,o,i),Fi(n,t,o),Wi(t,o,n,i)]}),rowProps:y}),d&&!c&&/* @__PURE__ */An(Ie,{children:Yl(n,s+1)}),m(t,o+1)]},String(n.props.id??`${t}-${o}`))}),y&&c&&
27
- /* @__PURE__ */An(N,{small:!0,label:c.addLabel,blocked:c.addBlocked?.(a)??null,onAdd:()=>nl(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?Jl(e,o.rung,i++,r,k):/* @__PURE__ */An(bn,{children:k},o.slot??"")})})},Xl=(()=>{if(!lt||!vo)return null;const e=String(lt.type),n=String(lt.props.id),t=Do(e,Wo(ot?.data,e,n));if(!t||"footer"===t.source)return null;const o=Er.some(e=>String(e.props?.id)===n),r=Array.isArray(lt.props[t.slot])?lt.props[t.slot]:[];if(t.spec?.addBlocked?.(r))return null;const i=t.choices??(t.spec?[{type:t.spec.childType,label:Jr(t.spec.childType)}]:[]);return 0===i.length?null:{parentName:Mi(lt,o),choices:i,onPick:o=>{t.spec?nl(n,t.slot,o,r.length,e):tl(`${n}:${t.slot}`,o,r.length)}}})(),Ql=bo&&bo.zone!==le&&!kl(bo.zone)?bo.zone:null,_l=!0===ho.blocksFirst,Zl=Ql?xl(Ql):_l&&bo?null:Xl,ql=Boolean(uo&&Ql)||_l&&Boolean(Zl&&Zl.choices.length>0),es=so||null!==Yt,ns=e=>"panel"in e?{id:e.id,label:e.label,icon:e.icon,active:Et&&!es&&Eo===e.id,onSelect:()=>Ar(e.id)}:e,ts=[{id:"add",label:xt.add.title,icon:/* @__PURE__ */An("span",{className:"sf-rail-plus","aria-hidden":"true",children:"+"}),active:so,onSelect:()=>so?Ti():$i(null)},...(jo.railLead??[]).map(ns),{id:"sections",label:xt.layers,icon:/* @__PURE__ */An(Me,{}),active:Et&&!es&&"sections"===Eo,onSelect:()=>Ar("sections")},...(jo.railTrail??[]).map(ns)];Kt?ts.push({id:"media",label:xt.railMedia,icon:/* @__PURE__ */An(je,{}),active:Et&&!so&&(null!==Yt||"media"===Eo),onSelect:()=>Ar("media")}):et&&ts.push({id:"media",label:xt.railMedia,icon:/* @__PURE__ */An(je,{}),onSelect:Mr});const os=[...jo.railLead??[],...jo.railTrail??[]].find(e=>"panel"in e&&e.id===Eo),rs=Boolean(vt?.foldable)&&!Ro,is=vt?.label??(nt?xt.pageSections:xt.templateSections),ls=rs&&pr(Wn),ss=/* @__PURE__ */Mn(jn,{children:[Er.map((e,n)=>{if(yt(e)||kt(e)||ft(e.type))return null;const t=Bo===String(e.props.id),o=Boolean(e.props._hidden);Gi(e);const r=String(e.props.id),i=jo.hasOwnRows?.(e)??!1,l=Zi(e)||i,s=l&&pr(r),d=Ui(e.type),c=1===d.length?`${r}:${d[0]}`:null,a=c?{...hn(c),index:Zr(c).length}:void 0,p=Bl.dragging,u=a&&p&&Sl(p,a)?a:void 0,{rowProps:f,...h}=Bl.row({item:{id:r,zone:le,index:n,type:e.type},place:{...hn(le),index:n},into:u},{"data-node-id":r,onClick:ji(()=>zi(n))});/* @__PURE__ */
28
- return Mn(bn,{children:[n>0&&Hi(n),
29
- /* @__PURE__ */An(Oe,{words:wt,icon:/* @__PURE__ */An(Ko,{type:e.type,size:13}),name:Xr(e),preview:Li(e),marks:Vi(e),onSelect:()=>zi(n),nameSlot:pi(le,n,r,Xr(e)),selected:t,hidden:o,...h,fold:l?{open:!s,label:"section",onToggle:()=>ur(r)}:void 0,actions:/* @__PURE__ */Mn(jn,{children:[Ei(le,n,Xr(e)),Fi(e,le,n),Wi(le,n,e,Xr(e))]}),rowProps:f}),Zi(e)&&!s&&/* @__PURE__ */Mn(Ie,{children:[Yl(e,1),jo.partRows?.(e,Ul)]}),i&&!s&&/* @__PURE__ */An(Ie,{children:jo.ownRows?.(e,n,Ul)})]},String(e.props.id??n))}),!Ro&&pl>0&&Hi(pl),vt?.addAtEnd&&!Ro&&!Qn&&/* @__PURE__ */An(N,{small:!0,label:xt.addSection,blocked:null,onAdd:()=>$i(pl)})]}),ds=(e,n,t)=>{const o=String(e.props.id),r=Ki(e).length>0||Yi(e)||Boolean(Do(e.type)),i=r&&pr(o),l="header"===t?xt.header:xt.footer,s=Go.rowName?Go.rowName(e,"section",l):l;/* @__PURE__ */
26
+ /* @__PURE__ */An(be,{words:wt,icon:/* @__PURE__ */An(Yo,{type:n.type,size:13}),name:i,preview:Li(n),marks:Vi(n),onSelect:g,nameSlot:pi(t,o,l,i),selected:r,hidden:Boolean(n.props._hidden),...k,fold:d?{open:!c,label:"group",onToggle:()=>ur(l)}:void 0,actions:Vo(n.type)?Fi(n,t,o)??void 0:/* @__PURE__ */Mn(jn,{children:[Ri(t,o,i),Fi(n,t,o),Hi(t,o,n,i)]}),rowProps:y}),d&&!c&&/* @__PURE__ */An(ze,{children:Kl(n,s+1)}),m(t,o+1)]},String(n.props.id??`${t}-${o}`))}),y&&c&&
27
+ /* @__PURE__ */An(N,{small:!0,label:c.addLabel,blocked:c.addBlocked?.(a)??null,onAdd:()=>nl(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?Jl(e,o.rung,i++,r,k):/* @__PURE__ */An(bn,{children:k},o.slot??"")})})},Xl=(()=>{if(!lt||!vo)return null;const e=String(lt.type),n=String(lt.props.id),t=Uo(e,Ho(ot?.data,e,n));if(!t||"footer"===t.source)return null;const o=Rr.some(e=>String(e.props?.id)===n),r=Array.isArray(lt.props[t.slot])?lt.props[t.slot]:[];if(t.spec?.addBlocked?.(r))return null;const i=t.choices??(t.spec?[{type:t.spec.childType,label:Jr(t.spec.childType)}]:[]);return 0===i.length?null:{parentName:Mi(lt,o),choices:i,onPick:o=>{t.spec?nl(n,t.slot,o,r.length,e):tl(`${n}:${t.slot}`,o,r.length)}}})(),Ql=bo&&bo.zone!==le&&!kl(bo.zone)?bo.zone:null,_l=!0===ho.blocksFirst,Zl=Ql?xl(Ql):_l&&bo?null:Xl,ql=Boolean(uo&&Ql)||_l&&Boolean(Zl&&Zl.choices.length>0),es=so||null!==Kt,ns=e=>"panel"in e?{id:e.id,label:e.label,icon:e.icon,active:Rt&&!es&&Ro===e.id,onSelect:()=>Ar(e.id)}:e,ts=[{id:"add",label:xt.add.title,icon:/* @__PURE__ */An("span",{className:"sf-rail-plus","aria-hidden":"true",children:"+"}),active:so,onSelect:()=>so?Ti():Pi(null)},...(jo.railLead??[]).map(ns),{id:"sections",label:xt.layers,icon:/* @__PURE__ */An(Me,{}),active:Rt&&!es&&"sections"===Ro,onSelect:()=>Ar("sections")},...(jo.railTrail??[]).map(ns)];Yt?ts.push({id:"media",label:xt.railMedia,icon:/* @__PURE__ */An(je,{}),active:Rt&&!so&&(null!==Kt||"media"===Ro),onSelect:()=>Ar("media")}):et&&ts.push({id:"media",label:xt.railMedia,icon:/* @__PURE__ */An(je,{}),onSelect:Mr});const os=[...jo.railLead??[],...jo.railTrail??[]].find(e=>"panel"in e&&e.id===Ro),rs=Boolean(vt?.foldable)&&!Eo,is=vt?.label??(nt?xt.pageSections:xt.templateSections),ls=rs&&pr(Hn),ss=/* @__PURE__ */Mn(jn,{children:[Rr.map((e,n)=>{if(yt(e)||kt(e)||ft(e.type))return null;const t=Bo===String(e.props.id),o=Boolean(e.props._hidden);Gi(e);const r=String(e.props.id),i=jo.hasOwnRows?.(e)??!1,l=Zi(e)||i,s=l&&pr(r),d=Di(e.type),c=1===d.length?`${r}:${d[0]}`:null,a=c?{...hn(c),index:Zr(c).length}:void 0,p=Bl.dragging,u=a&&p&&Sl(p,a)?a:void 0,{rowProps:f,...h}=Bl.row({item:{id:r,zone:le,index:n,type:e.type},place:{...hn(le),index:n},into:u},{"data-node-id":r,onClick:ji(()=>zi(n))});/* @__PURE__ */
28
+ return Mn(bn,{children:[n>0&&Wi(n),
29
+ /* @__PURE__ */An(be,{words:wt,icon:/* @__PURE__ */An(Yo,{type:e.type,size:13}),name:Xr(e),preview:Li(e),marks:Vi(e),onSelect:()=>zi(n),nameSlot:pi(le,n,r,Xr(e)),selected:t,hidden:o,...h,fold:l?{open:!s,label:"section",onToggle:()=>ur(r)}:void 0,actions:/* @__PURE__ */Mn(jn,{children:[Ri(le,n,Xr(e)),Fi(e,le,n),Hi(le,n,e,Xr(e))]}),rowProps:f}),Zi(e)&&!s&&/* @__PURE__ */Mn(ze,{children:[Kl(e,1),jo.partRows?.(e,Dl)]}),i&&!s&&/* @__PURE__ */An(ze,{children:jo.ownRows?.(e,n,Dl)})]},String(e.props.id??n))}),!Eo&&pl>0&&Wi(pl),vt?.addAtEnd&&!Eo&&!Qn&&/* @__PURE__ */An(N,{small:!0,label:xt.addSection,blocked:null,onAdd:()=>Pi(pl)})]}),ds=(e,n,t)=>{const o=String(e.props.id),r=Yi(e).length>0||Ki(e)||Boolean(Uo(e.type)),i=r&&pr(o),l="header"===t?xt.header:xt.footer,s=Go.rowName?Go.rowName(e,"section",l):l;/* @__PURE__ */
30
30
  return Mn(jn,{children:[
31
- /* @__PURE__ */An(Oe,{words:wt,icon:/* @__PURE__ */An(Ko,{type:t,size:13}),name:s,preview:Li(e),marks:Vi(e),onSelect:()=>zi(n),nameSlot:pi(le,n,o,s),selected:Bo===String(e.props.id),fold:r?{open:!i,label:"section",onToggle:()=>ur(o)}:void 0,actions:Fi(e,le,n)??void 0,rowProps:{"data-node-id":o,onClick:ji(()=>zi(n))}}),r&&!i&&/* @__PURE__ */An(Ie,{children:Kl(e,1)})]})};return(jo.wrap??(e=>e))(
32
- /* @__PURE__ */An(te,{target:io,children:/* @__PURE__ */Mn("div",{ref:ro,className:"sf-editor es-editor",style:Ye(lr),onContextMenu:yi.onEditorContextMenu,...m(Ee),children:[
31
+ /* @__PURE__ */An(be,{words:wt,icon:/* @__PURE__ */An(Yo,{type:t,size:13}),name:s,preview:Li(e),marks:Vi(e),onSelect:()=>zi(n),nameSlot:pi(le,n,o,s),selected:Bo===String(e.props.id),fold:r?{open:!i,label:"section",onToggle:()=>ur(o)}:void 0,actions:Fi(e,le,n)??void 0,rowProps:{"data-node-id":o,onClick:ji(()=>zi(n))}}),r&&!i&&/* @__PURE__ */An(ze,{children:Yl(e,1)})]})};return(jo.wrap??(e=>e))(
32
+ /* @__PURE__ */An(te,{target:io,children:/* @__PURE__ */Mn("div",{ref:ro,className:"sf-editor es-editor",style:Ke(lr),onContextMenu:yi.onEditorContextMenu,...m(Re),children:[
33
33
  /* @__PURE__ */Mn(Le,{children:[
34
34
  /* @__PURE__ */An(Ve,{items:ts,ariaLabel:xt.bar.views}),
35
35
  /* @__PURE__ */Mn(Fe,{children:[
36
- /* @__PURE__ */An(We,{label:xt.bar.undo,disabled:Boolean(Qn)||!it.hasPast,onClick:()=>it.back(),children:/* @__PURE__ */An(On,{})}),
37
- /* @__PURE__ */An(We,{label:xt.bar.redo,disabled:Boolean(Qn)||!it.hasFuture,onClick:()=>it.forward(),children:/* @__PURE__ */An(In,{})}),
38
- /* @__PURE__ */An(He,{}),
39
- /* @__PURE__ */An(De,{devices:Vt,value:Ut,onChange:Gt})]}),
36
+ /* @__PURE__ */An(He,{label:xt.bar.undo,disabled:Boolean(Qn)||!it.hasPast,onClick:()=>it.back(),children:/* @__PURE__ */An(On,{})}),
37
+ /* @__PURE__ */An(He,{label:xt.bar.redo,disabled:Boolean(Qn)||!it.hasFuture,onClick:()=>it.forward(),children:/* @__PURE__ */An(In,{})}),
38
+ /* @__PURE__ */An(We,{}),
39
+ /* @__PURE__ */An(Ue,{devices:Vt,value:Dt,onChange:Gt})]}),
40
40
  /* @__PURE__ */Mn(Fe,{kind:"right",style:{minWidth:300},children:[
41
- /* @__PURE__ */An(Rn,{saveState:Jn,notSaving:Boolean(Qn)||null!=Kn,readOnlyReason:_n,toggle:Zn,onToggle:Xn,onRetry:Yn,words:xt.bar,saveWords:zt}),jo.barLead?.(),
42
- /* @__PURE__ */An(zn,{content:xt.bar.refreshTip,side:"bottom",children:/* @__PURE__ */An(Bn,{variant:"secondary",onClick:()=>{oo.current=(()=>{const e=io?.document;if(!e)return null;const n=Er.findIndex(kt),t=n>=0?n:Er.length;let o=null;for(let n=0;n<t;n++){const t=Er[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=lt?.props?.id??Er[0]?.props?.id;null!=e&&(o={id:String(e),offset:0})}return o})(),to(e=>e+1)},children:xt.bar.refresh})}),jo.barTrail?.(),jo.barMain?jo.barMain():/* @__PURE__ */An(Bn,{variant:"primary",disabled:null!==_n,onClick:()=>{Gn(ot.data)},children:xt.done})]})]}),
41
+ /* @__PURE__ */An(En,{saveState:Jn,notSaving:Boolean(Qn)||null!=Yn,readOnlyReason:_n,toggle:Zn,onToggle:Xn,onRetry:Kn,words:xt.bar,saveWords:zt}),jo.barLead?.(),
42
+ /* @__PURE__ */An(zn,{content:xt.bar.refreshTip,side:"bottom",children:/* @__PURE__ */An(Bn,{variant:"secondary",onClick:()=>{oo.current=(()=>{const e=io?.document;if(!e)return null;const n=Rr.findIndex(kt),t=n>=0?n:Rr.length;let o=null;for(let n=0;n<t;n++){const t=Rr[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=lt?.props?.id??Rr[0]?.props?.id;null!=e&&(o={id:String(e),offset:0})}return o})(),to(e=>e+1)},children:xt.bar.refresh})}),jo.barTrail?.(),jo.barMain?jo.barMain():/* @__PURE__ */An(Bn,{variant:"primary",disabled:null!==_n,onClick:()=>{Gn(ot.data)},children:xt.done})]})]}),
43
43
  /* @__PURE__ */An(z,{}),
44
- /* @__PURE__ */Mn("div",{className:"sf-body",children:[Et?/* @__PURE__ */Mn(jn,{children:[
45
- /* @__PURE__ */An("aside",{className:"es-sidepanel es-sidepanel--left sf-panel sf-panel--left","aria-label":xt.leftPanel,children:so?/* @__PURE__ */An($,{blocks:Zl,blocksOnly:ql,at:uo?{label:(e=>{const n=kl(e.zone);if(n)return xt.add.addingTo({name:Go.rowName?Mi(n,!0):Jr(n.type)});if(e.zone===le){const n=Er[e.index];return n&&!kt(n)?xt.add.addingBefore({name:Mi(n,!0)}):xt.add.addingAtEnd}const t=xl(e.zone);return t?xt.add.addingTo({name:t.parentName}):xt.add.addingHere})(uo),onClear:()=>fo(null)}:void 0,onAdd:e=>{const n=bo,t=(e,n)=>{uo&&fo({zone:e,index:n})};if(n&&"block"!==e.kind&&kl(n.zone))return Ai(e,n.zone,n.index),void t(n.zone,n.index+1);if("section"===e.kind)return(e=>{if(null===zo)return void Ii(e);const n=Ii(e,zo);uo&&mo(n+1)})(e.type);if("template"===e.kind)return((e,n)=>{if(null===zo)return void Ni(e,n);const t=Ni(e,n,zo);uo&&mo(t+1)})(e.template.name,Wr(e.template.node));if(n&&n.zone!==le){const o=xl(n.zone);if(!o)return;return o.target.spec?nl(o.parentId,o.target.slot,e.type,n.index,o.parent.type):tl(n.zone,e.type,n.index),void t(n.zone,n.index+1)}Xl?.onPick(e.type)},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:zl,siteWide:jo.addPanelRow?.(Ti),onClose:Ti,onHide:Pr,readOnly:Boolean(Qn)}):Yt&&Jt?
46
- /* @__PURE__ */An(A,{panel:Jt,pick:Yt,onHide:Pr}):os?os.panel({onHide:Pr,notify:gr}):"media"===Eo&&Jt?/* @__PURE__ */An(A,{panel:Jt,pick:null,onHide:Pr}):/* @__PURE__ */Mn(jn,{children:[
47
- /* @__PURE__ */An(P,{icon:/* @__PURE__ */An(Me,{}),title:xt.layers,context:It,actions:
48
- /* @__PURE__ */An(Ue,{label:fl?xt.expandAll:xt.collapseAll,title:0===ul.length?xt.nothingToFold:void 0,disabled:0===ul.length,onClick:()=>ir(e=>{const n=new Set(ul);return fl?new Set([...e].filter(e=>!n.has(e))):/* @__PURE__ */new Set([...e,...ul])}),children:/* @__PURE__ */An(En,{expand:fl})}),onHide:Pr}),
49
- /* @__PURE__ */Mn(Ne,{className:"sf-tree sf-scroll",words:wt,children:[
50
- /* @__PURE__ */An(Oe,{words:wt,icon:/* @__PURE__ */An(Ko,{type:"page",size:13}),name:xt.pageSettings,onSelect:jr,selected:!lt&&vo,rowProps:{onClick:ji(jr)}}),cl&&/* @__PURE__ */Mn(jn,{children:[
51
- /* @__PURE__ */An($e,{children:xt.header}),Gl(cl)]}),!Ro&&tt&&/* @__PURE__ */Mn(jn,{children:[
52
- /* @__PURE__ */An($e,{children:xt.header}),!St&&/* @__PURE__ */An(Oe,{words:wt,icon:/* @__PURE__ */An(Ko,{type:"header",size:13}),name:xt.header,onSelect:Rr,selected:ko.kind===gt?.kind,rowProps:{onClick:ji(Rr)}})]}),!Ro&&dl&&ds(dl,sl,"header"),!Ro&&!rs&&/* @__PURE__ */An($e,{children:is}),rs?/* @__PURE__ */Mn(jn,{children:[
53
- /* @__PURE__ */An(Oe,{words:wt,icon:null,name:is,fold:{open:!ls,label:is,onToggle:()=>ur(Wn)}}),!ls&&/* @__PURE__ */An(Ie,{children:ss})]}):ss,tt&&/* @__PURE__ */An($e,{children:xt.footer}),ll&&ds(ll,il,"footer"),!Ro&&!ll&&tt&&/* @__PURE__ */An(Oe,{words:wt,icon:/* @__PURE__ */An(Ko,{type:"footer",size:13}),name:xt.footer,onSelect:Ri,rowProps:{onClick:ji(Ri),title:xt.editFooter}}),al&&Gl(al),jo.treeFoot?.()]})]})}),
54
- /* @__PURE__ */An(Ge,{side:"left",width:lr.left,min:Ke,max:Je,defaultWidth:k.left,label:xt.resizeLeftPanel,onResize:cr})]}):/* @__PURE__ */An(T,{side:"left",onShow:Pr}),
55
- /* @__PURE__ */Mn("div",{ref:yr,className:"sf-center sf-scroll","data-sf-canvas-head":wr?"":void 0,style:{overflowX:Ir?"auto":"hidden",overflowY:"hidden"},children:[wr&&/* @__PURE__ */An("div",{ref:br,className:"sf-canvas-head",children:/* @__PURE__ */An(wr,{device:Ut})}),
56
- /* @__PURE__ */An("div",{className:"sf-frame-scaler",style:Nr,children:/* @__PURE__ */An("div",{className:"sf-frame "+(Ut===Ht?"":`sf-frame--${Ut}`),style:$r,children:/* @__PURE__ */Mn("div",{className:"sf-preview-host",children:[
44
+ /* @__PURE__ */Mn("div",{className:"sf-body",children:[Rt?/* @__PURE__ */Mn(jn,{children:[
45
+ /* @__PURE__ */An("aside",{className:"es-sidepanel es-sidepanel--left sf-panel sf-panel--left","aria-label":xt.leftPanel,children:so?/* @__PURE__ */An(P,{blocks:Zl,blocksOnly:ql,at:uo?{label:(e=>{const n=kl(e.zone);if(n)return xt.add.addingTo({name:Go.rowName?Mi(n,!0):Jr(n.type)});if(e.zone===le){const n=Rr[e.index];return n&&!kt(n)?xt.add.addingBefore({name:Mi(n,!0)}):xt.add.addingAtEnd}const t=xl(e.zone);return t?xt.add.addingTo({name:t.parentName}):xt.add.addingHere})(uo),onClear:()=>fo(null)}:void 0,onAdd:e=>{const n=bo,t=(e,n)=>{uo&&fo({zone:e,index:n})};if(n&&"block"!==e.kind&&kl(n.zone))return Ai(e,n.zone,n.index),void t(n.zone,n.index+1);if("section"===e.kind)return(e=>{if(null===zo)return void Ii(e);const n=Ii(e,zo);uo&&mo(n+1)})(e.type);if("template"===e.kind)return((e,n)=>{if(null===zo)return void Ni(e,n);const t=Ni(e,n,zo);uo&&mo(t+1)})(e.template.name,Hr(e.template.node));if(n&&n.zone!==le){const o=xl(n.zone);if(!o)return;return o.target.spec?nl(o.parentId,o.target.slot,e.type,n.index,o.parent.type):tl(n.zone,e.type,n.index),void t(n.zone,n.index+1)}Xl?.onPick(e.type)},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:zl,siteWide:jo.addPanelRow?.(Ti),onClose:Ti,onHide:$r,readOnly:Boolean(Qn)}):Kt&&Jt?
46
+ /* @__PURE__ */An(A,{panel:Jt,pick:Kt,onHide:$r}):os?os.panel({onHide:$r,notify:gr}):"media"===Ro&&Jt?/* @__PURE__ */An(A,{panel:Jt,pick:null,onHide:$r}):/* @__PURE__ */Mn(jn,{children:[
47
+ /* @__PURE__ */An($,{icon:/* @__PURE__ */An(Me,{}),title:xt.layers,context:It,actions:
48
+ /* @__PURE__ */An(De,{label:fl?xt.expandAll:xt.collapseAll,title:0===ul.length?xt.nothingToFold:void 0,disabled:0===ul.length,onClick:()=>ir(e=>{const n=new Set(ul);return fl?new Set([...e].filter(e=>!n.has(e))):/* @__PURE__ */new Set([...e,...ul])}),children:/* @__PURE__ */An(Rn,{expand:fl})}),onHide:$r}),
49
+ /* @__PURE__ */Mn(Be,{className:"sf-tree sf-scroll",words:wt,children:[
50
+ /* @__PURE__ */An(be,{words:wt,icon:/* @__PURE__ */An(Yo,{type:"page",size:13}),name:xt.pageSettings,onSelect:jr,selected:!lt&&vo,rowProps:{onClick:ji(jr)}}),cl&&/* @__PURE__ */Mn(jn,{children:[
51
+ /* @__PURE__ */An(Ce,{children:xt.header}),Gl(cl)]}),!Eo&&tt&&/* @__PURE__ */Mn(jn,{children:[
52
+ /* @__PURE__ */An(Ce,{children:xt.header}),!St&&/* @__PURE__ */An(be,{words:wt,icon:/* @__PURE__ */An(Yo,{type:"header",size:13}),name:xt.header,onSelect:Er,selected:ko.kind===gt?.kind,rowProps:{onClick:ji(Er)}})]}),!Eo&&dl&&ds(dl,sl,"header"),!Eo&&!rs&&/* @__PURE__ */An(Ce,{children:is}),rs?/* @__PURE__ */Mn(jn,{children:[
53
+ /* @__PURE__ */An(be,{words:wt,icon:null,name:is,fold:{open:!ls,label:is,onToggle:()=>ur(Hn)}}),!ls&&/* @__PURE__ */An(ze,{children:ss})]}):ss,tt&&/* @__PURE__ */An(Ce,{children:xt.footer}),ll&&ds(ll,il,"footer"),!Eo&&!ll&&tt&&/* @__PURE__ */An(be,{words:wt,icon:/* @__PURE__ */An(Yo,{type:"footer",size:13}),name:xt.footer,onSelect:Ei,rowProps:{onClick:ji(Ei),title:xt.editFooter}}),al&&Gl(al),jo.treeFoot?.()]})]})}),
54
+ /* @__PURE__ */An(Ge,{side:"left",width:lr.left,min:Ye,max:Je,defaultWidth:k.left,label:xt.resizeLeftPanel,onResize:cr})]}):/* @__PURE__ */An(T,{side:"left",onShow:$r}),
55
+ /* @__PURE__ */Mn("div",{ref:yr,className:"sf-center sf-scroll","data-sf-canvas-head":wr?"":void 0,style:{overflowX:Ir?"auto":"hidden",overflowY:"hidden"},children:[wr&&/* @__PURE__ */An("div",{ref:br,className:"sf-canvas-head",children:/* @__PURE__ */An(wr,{device:Dt})}),
56
+ /* @__PURE__ */An("div",{className:"sf-frame-scaler",style:Nr,children:/* @__PURE__ */An("div",{className:"sf-frame "+(Dt===Wt?"":`sf-frame--${Dt}`),style:Pr,children:/* @__PURE__ */Mn("div",{className:"sf-preview-host",children:[
57
57
  /* @__PURE__ */An(Nt,{},no),
58
- /* @__PURE__ */An(en,{canvas:io,session:zl,model:Al,measure:jl,canDrop:El,onDrop:Vl,choose:Il,onPick:Wl,onZoneAdd:Hl,onSeamAdd:Hl,zoneAddLabel:xt.canvasAddBlock,words:bt.canvas,readOnly:Boolean(Qn),revision:ot.data}),go.length>0&&/* @__PURE__ */An("div",{className:"sf-preview-gaps",children:go.map(e=>
59
- /* @__PURE__ */An(nn,{index:e.index,label:xt.addSectionHere,onInsert:()=>$i(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))})]})})})]}),Lt?/* @__PURE__ */Mn(jn,{children:[
60
- /* @__PURE__ */An(g,{value:{selectChild:el,addChild:nl,childRowName:ci,blockRowName:hl},children:/* @__PURE__ */An($t,{mode:ko,onOpenWebsiteSettings:jo.openSettings??(()=>{}),onOpenSiteStyles:jo.openStyles,onSelectNode:_o,onNotify:gr,onHidePanel:Tr,nodeActions:lt?se(dt,lt.type):Hn})}),
61
- /* @__PURE__ */An(Ge,{side:"right",width:lr.right,min:Ke,max:Je,defaultWidth:k.right,label:xt.resizeSettingsPanel,onResize:ar})]}):
62
- /* @__PURE__ */An(T,{side:"right",onShow:Tr})]}),yi.menu]})}))}export{Dn as ScreenChrome};
58
+ /* @__PURE__ */An(en,{canvas:io,session:zl,model:Al,measure:jl,canDrop:Rl,onDrop:Vl,choose:Il,onPick:Hl,onZoneAdd:Wl,onSeamAdd:Wl,zoneAddLabel:xt.canvasAddBlock,words:bt.canvas,readOnly:Boolean(Qn),revision:ot.data}),go.length>0&&/* @__PURE__ */An("div",{className:"sf-preview-gaps",children:go.map(e=>
59
+ /* @__PURE__ */An(nn,{index:e.index,label:xt.addSectionHere,onInsert:()=>Pi(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))})]})})})]}),Lt?/* @__PURE__ */Mn(jn,{children:[
60
+ /* @__PURE__ */An(g,{value:{selectChild:el,addChild:nl,childRowName:ci,blockRowName:hl},children:/* @__PURE__ */An(Pt,{mode:ko,onOpenWebsiteSettings:jo.openSettings??(()=>{}),onOpenSiteStyles:jo.openStyles,onSelectNode:_o,onNotify:gr,onHidePanel:Tr,nodeActions:lt?se(dt,lt.type):Wn})}),
61
+ /* @__PURE__ */An(Ge,{side:"right",width:lr.right,min:Ye,max:Je,defaultWidth:k.right,label:xt.resizeSettingsPanel,onResize:ar})]}):
62
+ /* @__PURE__ */An(T,{side:"right",onShow:Tr})]}),yi.menu]})}))}export{Un as ScreenChrome};
@@ -1,4 +1,4 @@
1
- import{blockRuns as e}from"./chunk-HQ4VVRIC.js";import{useScreenBlockLook as r}from"./chunk-PG3QGGTU.js";import{DEFAULT_SCREEN_WORDS as s}from"./chunk-5F3PKNT7.js";import{useWords as t}from"./chunk-MFIRYGHW.js";import{DropdownMenu as n}from"efficient-shell/ui";import{jsxs as c,Fragment as i,jsx as o}from"react/jsx-runtime";function l({choices:l,onPick:p}){const{Icon:a}=r(),m=t("screen",s),u=e(l).flatMap(e=>[...e.group?[{type:"label",key:`group:${e.group}`,label:/* @__PURE__ */c(i,{children:[e.group," ",
1
+ import{blockRuns as e}from"./chunk-HQ4VVRIC.js";import{useScreenBlockLook as r}from"./chunk-HUTO5ZIL.js";import{DEFAULT_SCREEN_WORDS as s}from"./chunk-5F3PKNT7.js";import{useWords as t}from"./chunk-MFIRYGHW.js";import{DropdownMenu as n}from"efficient-shell/ui";import{jsxs as c,Fragment as i,jsx as o}from"react/jsx-runtime";function l({choices:l,onPick:p}){const{Icon:a}=r(),m=t("screen",s),u=e(l).flatMap(e=>[...e.group?[{type:"label",key:`group:${e.group}`,label:/* @__PURE__ */c(i,{children:[e.group," ",
2
2
  /* @__PURE__ */o("span",{className:"sf-menugroup-count",children:e.items.length})]})}]:[],...e.items.map(e=>({key:e.type,label:e.label,icon:/* @__PURE__ */o("span",{className:"sf-chip",children:/* @__PURE__ */o(a,{type:e.type,size:13})}),onSelect:()=>p(e.type)}))]);/* @__PURE__ */
3
3
  return o(n,{align:"start",triggerClassName:"sf-add-card",items:u,trigger:/* @__PURE__ */c(i,{children:[
4
4
  /* @__PURE__ */o("span",{className:"sf-plus sf-plus--sm",children:"+"}),m.addBlockMenu]})})}export{l as AddBlockRow};
@@ -1,4 +1,4 @@
1
- import{DEFAULT_COPY_WORDS as e}from"../chunk-AUT242JK.js";import{selectionToVisible as t,selectionToSource as n,richLayout as r,createHistory as l,markPress as o,pasteToMarkup as a,richInput as s,editVisible as i,MARKUP_CLIPBOARD_TYPE as c,markupOfRange as u}from"../chunk-WQASXLXS.js";export{MARKUP_CLIPBOARD_TYPE,TYPING_BURST_MS,createHistory,editVisible,markupOfRange,newLine,pasteToMarkup,richInput,richLayout,selectionToSource,selectionToVisible,setBullet,startCanvasTyping,textMap,toSource,toSourceStart,toVisible}from"../chunk-WQASXLXS.js";import{FieldNumber as d}from"../chunk-66LWADFP.js";import"../chunk-FFYXVAAL.js";import{GoldTextInput as p}from"../chunk-2FZJWH24.js";import{RETIRED_MARKS as f,applyMark as h,markupTools as m,marksIn as g,STANDARD_MARKUP as y,findLink as v,markedAt as b,listIn as k,colorIn as x,spanFor as w,clearStyle as S,toggleMark as E,colorOver as C,setList as D,unlinkAt as N,removeLink as L,linkOver as T,writeLink as M}from"../chunk-546BBOPE.js";import{SettingsSegmented as R,SettingsSwitch as B}from"../chunk-QLD57GBB.js";import{useWords as P}from"../chunk-MFIRYGHW.js";import{withTip as O}from"../chunk-P2VEMZH5.js";import{Tooltip as z,ColorSwatch as K,ColorPickerPanel as F,Button as W,IconButton as $,registerModalEscapeInterceptor as j,textToolbarRows as H,TextToolbar as A,LinkPicker as V}from"efficient-shell/ui";export{TextToolbar}from"efficient-shell/ui";import{useRef as I,useState as U,useLayoutEffect as q,useEffect as X,useId as Y}from"react";import{AlignJustifyIcon as _,AlignRightIcon as G,AlignCenterIcon as Q,AlignLeftIcon as Z,ParagraphSpacingIcon as J,LetterSpacingIcon as ee,TextLinesIcon as te,TextSizeIcon as ne,ClearMarksIcon as re,LinkIcon as le,QuietIcon as oe,EmphasisIcon as ae,StrikeIcon as se,ItalicIcon as ie,BoldIcon as ce}from"efficient-shell/icons/efficient";import{jsx as ue,jsxs as de,Fragment as pe}from"react/jsx-runtime";var fe=["left","center","right","justify"],he=e.align,me={left:/* @__PURE__ */ue(Z,{}),center:/* @__PURE__ */ue(Q,{}),right:/* @__PURE__ */ue(G,{}),justify:/* @__PURE__ */ue(_,{})},ge={three:{labelsPx:94.5,widestLabelPx:39.94},four:{labelsPx:140,widestLabelPx:44}};function ye(e,t=he){return fe.filter(t=>e.includes(t)).map(e=>({id:e,label:t[e],icon:me[e],title:t[e]}))}var ve=/[\u1100-\u11ff\u2e80-\u9fff\uac00-\ud7af\uf900-\ufaff\uff00-\uffef]/;function be(e){if(e.every(e=>e.label===he[e.id]))return e.length>3?ge.four:ge.three;const t=e.map(e=>[...e.label].reduce((e,t)=>e+(ve.test(t)?13:8),0));return{labelsPx:t.reduce((e,t)=>e+t,0),widestLabelPx:Math.max(0,...t)}}function ke(e,t){const n=t?.selectionStart??e.length;return{start:n,end:t?.selectionEnd??n}}function xe(e,t,n,r=h){const{start:l,end:o}=ke(e,n);return r(e,l,o,t)}function we(e,t,n){const{start:r,end:l}=ke(e,n),o=r+t.length;return{text:e.slice(0,r)+t+e.slice(l),selectionStart:o,selectionEnd:o}}function Se(e,t,n,r){switch(t){case"bold":return e.createElement("strong");case"italic":return e.createElement("em");case"strike":return e.createElement("s");case"underline":return e.createElement("u");case"sup":return e.createElement("sup");case"sub":return e.createElement("sub");case"color":{const t=e.createElement("span");return t.className="es-rich-color",r&&(t.dataset.color=r,t.title=r.startsWith("#")?r.toUpperCase():r,t.style.color=r.startsWith("#")?r:`var(--es-color-${r}, inherit)`),t}case"link":{const t=e.createElement("a");return t.className="es-rich-link",n&&(t.title=n),t}default:{const n=e.createElement("span");return n.className="highlight"===t||"accent"===t?"es-rich-emphasis":`es-rich-${t}`,n}}}function Ee(e,t,n,r){const l=e.layout.lines;if(n===t)return r>=e.lines.length?e.layout.text.length:l[r].vis;const o=e.lines.findIndex(e=>e===n||e.contains(n));if(-1===o)return 0;const a=t.ownerDocument.createRange();a.setStart(e.lines[o],0);try{a.setEnd(n,r)}catch{return l[o].vis}return l[o].vis+Math.min(a.toString().length,l[o].text.length)}function Ce(e,t){const n=e.layout.lines;let r=n.length-1;for(let e=0;e<n.length;e+=1)if(t<=n[e].vis+n[e].text.length){r=e;break}let l=Math.max(0,t-n[r].vis);const o=e.lines[r].ownerDocument.createTreeWalker(e.lines[r],4);let a=o.nextNode(),s=null;for(;a;){if(l<=a.data.length)return[a,l];l-=a.data.length,s=a,a=o.nextNode()}return s?[s,s.data.length]:[e.lines[r],0]}function De({value:e,rules:l,multiline:o,readOnly:d=!1,placeholder:p,ariaLabel:f,handle:h,onEdit:m,onSelect:g,onHistory:y,onFormat:v,pending:b,onCommit:k,onCancel:x}){const w=I(null),S=I(null),E=I(null),C=I(null),D=I(null),N=I(e),[L,T]=U(0),M=I({value:e,rules:l,multiline:o,readOnly:d,pending:b,onEdit:m,onHistory:y,onFormat:v});M.current={value:e,rules:l,multiline:o,readOnly:d,pending:b,onEdit:m,onHistory:y,onFormat:v};const R=()=>{const e=w.current,t=S.current,n=e?.ownerDocument.getSelection();if(!(e&&t&&n&&0!==n.rangeCount&&n.anchorNode&&e.contains(n.anchorNode)))return null;const r=Ee(t,e,n.anchorNode,n.anchorOffset),l=n.focusNode&&e.contains(n.focusNode)?Ee(t,e,n.focusNode,n.focusOffset):r;return r<=l?[r,l]:[l,r]},B=(e,t)=>{const n=w.current,r=S.current;if(!n||!r)return;const[l,o]=Ce(r,e),[a,s]=Ce(r,t);n.ownerDocument.getSelection()?.setBaseAndExtent(l,o,a,s)};h.current={getSource(){const e=R(),t=S.current;if(!e||!t)return null;const[r,l]=n(t.layout,e[0],e[1]);return{start:r,end:l}},setSource(e,t,n){C.current={text:n,src:[e,t]},T(e=>e+1)},focus(){w.current?.focus()},rangeOf(e,n){const r=w.current,l=S.current;if(!r||!l)return null;const[o,a]=t(l.layout,e,n),[s,i]=Ce(l,o),[c,u]=Ce(l,a),d=r.ownerDocument.createRange();return d.setStart(s,i),d.setEnd(c,u),d}},q(()=>{const n=w.current;if(!n||D.current)return;const o=C.current?null:R();S.current=function(e,t){const n=e.ownerDocument;e.replaceChildren();const r=t.lines.map(t=>{const r=n.createElement("div");r.className=null!=t.number?"es-rich-line is-numbered":t.bullet?"es-rich-line is-bullet":"es-rich-line",null!=t.number&&(r.dataset.number=t.number);const l=[],o=()=>l.length?l[l.length-1].el:r;let a=null;for(const e of t.chars){let t=0;for(;t<l.length&&t<e.marks.length&&l[t].id===e.marks[t].id;)t+=1;(l.length>t||e.marks.length>t)&&(a=null),l.length=t;for(let r=t;r<e.marks.length;r+=1){const t=Se(n,e.marks[r].kind,e.marks[r].href,e.marks[r].color);o().appendChild(t),l.push({id:e.marks[r].id,el:t})}a||(a=n.createTextNode(""),o().appendChild(a)),a.data+=e.ch}return 0===t.chars.length&&r.appendChild(n.createElement("br")),e.appendChild(r),r});return{layout:t,lines:r}}(n,r(e,l)),E.current=e;const a=C.current;if(!a||a.text!==e)return void(o&&n.ownerDocument.activeElement===n&&B(o[0],Math.min(o[1],S.current.layout.text.length)));C.current=null;const s=S.current.layout,[i,c]=a.vis??t(s,a.src[0],a.src[1]);n.ownerDocument.activeElement!==n&&n.focus(),B(i,c)},[e,l,L]);const P=(e,t,r)=>{const l=S.current,[o,a]=n(l.layout,t[0],t[1]);C.current={text:e.text,vis:[e.caret,e.caret]},e.text!==M.current.value?M.current.onEdit(e.text,{start:o,end:a},r):T(e=>e+1)};X(()=>{const e=w.current;if(!e)return;const t=t=>{const{value:n,rules:r,multiline:l,readOnly:o,pending:a}=M.current;if("insertCompositionText"===t.inputType)return;if(t.preventDefault(),o)return;const i=S.current,c=R();if(!i||!c)return;const u="function"==typeof t.getTargetRanges?t.getTargetRanges()[0]:void 0,d=u&&!u.collapsed?[Ee(i,e,u.startContainer,u.startOffset),Ee(i,e,u.endContainer,u.endOffset)]:null,p=s({value:n,rules:r,multiline:l,inputType:t.inputType,data:t.data??t.dataTransfer?.getData("text/plain")??"",html:t.dataTransfer?.getData("text/html"),doc:e.ownerDocument,sel:c,target:d,pending:a});p&&("history"!==p.kind?"format"!==p.kind?P(p.edit,p.range,p.kind):M.current.onFormat(p.style):M.current.onHistory(p.dir))},n=()=>{D.current||T(e=>e+1)};return e.addEventListener("beforeinput",t),e.addEventListener("input",n),()=>{e.removeEventListener("beforeinput",t),e.removeEventListener("input",n)}},[]),X(()=>{const e=w.current;if(!e)return;const t=e.ownerDocument,n=()=>{const e=h.current?.getSource();e&&g(e)};return t.addEventListener("selectionchange",n),()=>t.removeEventListener("selectionchange",n)});const O=(t,n=!1)=>{const r=R();if(!r||r[0]===r[1])return;t.preventDefault();const o=S.current;t.clipboardData.setData("text/plain",o.layout.text.slice(r[0],r[1])),t.clipboardData.setData(c,u(e,l,r[0],r[1])),n&&!d&&P(i(e,l,r[0],r[1],{text:""}),r,"edit")};/* @__PURE__ */
1
+ import{DEFAULT_COPY_WORDS as e}from"../chunk-AUT242JK.js";import{selectionToVisible as t,selectionToSource as n,richLayout as r,createHistory as l,markPress as o,pasteToMarkup as a,richInput as s,editVisible as i,MARKUP_CLIPBOARD_TYPE as c,markupOfRange as u}from"../chunk-WQASXLXS.js";export{MARKUP_CLIPBOARD_TYPE,TYPING_BURST_MS,createHistory,editVisible,markupOfRange,newLine,pasteToMarkup,richInput,richLayout,selectionToSource,selectionToVisible,setBullet,startCanvasTyping,textMap,toSource,toSourceStart,toVisible}from"../chunk-WQASXLXS.js";import{FieldNumber as d}from"../chunk-66LWADFP.js";import{SettingsSegmented as p,SettingsSwitch as f}from"../chunk-QLD57GBB.js";import"../chunk-FFYXVAAL.js";import{GoldTextInput as h}from"../chunk-2FZJWH24.js";import{RETIRED_MARKS as m,applyMark as g,markupTools as y,marksIn as v,STANDARD_MARKUP as b,findLink as k,markedAt as x,listIn as w,colorIn as S,spanFor as E,clearStyle as C,toggleMark as D,colorOver as N,setList as L,unlinkAt as T,removeLink as M,linkOver as R,writeLink as B}from"../chunk-546BBOPE.js";import{useWords as P}from"../chunk-MFIRYGHW.js";import{withTip as O}from"../chunk-P2VEMZH5.js";import{Tooltip as z,ColorSwatch as K,ColorPickerPanel as F,Button as W,IconButton as $,registerModalEscapeInterceptor as j,textToolbarRows as H,TextToolbar as A,LinkPicker as V}from"efficient-shell/ui";export{TextToolbar}from"efficient-shell/ui";import{useRef as I,useState as U,useLayoutEffect as q,useEffect as X,useId as Y}from"react";import{AlignJustifyIcon as _,AlignRightIcon as G,AlignCenterIcon as Q,AlignLeftIcon as Z,ParagraphSpacingIcon as J,LetterSpacingIcon as ee,TextLinesIcon as te,TextSizeIcon as ne,ClearMarksIcon as re,LinkIcon as le,QuietIcon as oe,EmphasisIcon as ae,StrikeIcon as se,ItalicIcon as ie,BoldIcon as ce}from"efficient-shell/icons/efficient";import{jsx as ue,jsxs as de,Fragment as pe}from"react/jsx-runtime";var fe=["left","center","right","justify"],he=e.align,me={left:/* @__PURE__ */ue(Z,{}),center:/* @__PURE__ */ue(Q,{}),right:/* @__PURE__ */ue(G,{}),justify:/* @__PURE__ */ue(_,{})},ge={three:{labelsPx:94.5,widestLabelPx:39.94},four:{labelsPx:140,widestLabelPx:44}};function ye(e,t=he){return fe.filter(t=>e.includes(t)).map(e=>({id:e,label:t[e],icon:me[e],title:t[e]}))}var ve=/[\u1100-\u11ff\u2e80-\u9fff\uac00-\ud7af\uf900-\ufaff\uff00-\uffef]/;function be(e){if(e.every(e=>e.label===he[e.id]))return e.length>3?ge.four:ge.three;const t=e.map(e=>[...e.label].reduce((e,t)=>e+(ve.test(t)?13:8),0));return{labelsPx:t.reduce((e,t)=>e+t,0),widestLabelPx:Math.max(0,...t)}}function ke(e,t){const n=t?.selectionStart??e.length;return{start:n,end:t?.selectionEnd??n}}function xe(e,t,n,r=g){const{start:l,end:o}=ke(e,n);return r(e,l,o,t)}function we(e,t,n){const{start:r,end:l}=ke(e,n),o=r+t.length;return{text:e.slice(0,r)+t+e.slice(l),selectionStart:o,selectionEnd:o}}function Se(e,t,n,r){switch(t){case"bold":return e.createElement("strong");case"italic":return e.createElement("em");case"strike":return e.createElement("s");case"underline":return e.createElement("u");case"sup":return e.createElement("sup");case"sub":return e.createElement("sub");case"color":{const t=e.createElement("span");return t.className="es-rich-color",r&&(t.dataset.color=r,t.title=r.startsWith("#")?r.toUpperCase():r,t.style.color=r.startsWith("#")?r:`var(--es-color-${r}, inherit)`),t}case"link":{const t=e.createElement("a");return t.className="es-rich-link",n&&(t.title=n),t}default:{const n=e.createElement("span");return n.className="highlight"===t||"accent"===t?"es-rich-emphasis":`es-rich-${t}`,n}}}function Ee(e,t,n,r){const l=e.layout.lines;if(n===t)return r>=e.lines.length?e.layout.text.length:l[r].vis;const o=e.lines.findIndex(e=>e===n||e.contains(n));if(-1===o)return 0;const a=t.ownerDocument.createRange();a.setStart(e.lines[o],0);try{a.setEnd(n,r)}catch{return l[o].vis}return l[o].vis+Math.min(a.toString().length,l[o].text.length)}function Ce(e,t){const n=e.layout.lines;let r=n.length-1;for(let e=0;e<n.length;e+=1)if(t<=n[e].vis+n[e].text.length){r=e;break}let l=Math.max(0,t-n[r].vis);const o=e.lines[r].ownerDocument.createTreeWalker(e.lines[r],4);let a=o.nextNode(),s=null;for(;a;){if(l<=a.data.length)return[a,l];l-=a.data.length,s=a,a=o.nextNode()}return s?[s,s.data.length]:[e.lines[r],0]}function De({value:e,rules:l,multiline:o,readOnly:d=!1,placeholder:p,ariaLabel:f,handle:h,onEdit:m,onSelect:g,onHistory:y,onFormat:v,pending:b,onCommit:k,onCancel:x}){const w=I(null),S=I(null),E=I(null),C=I(null),D=I(null),N=I(e),[L,T]=U(0),M=I({value:e,rules:l,multiline:o,readOnly:d,pending:b,onEdit:m,onHistory:y,onFormat:v});M.current={value:e,rules:l,multiline:o,readOnly:d,pending:b,onEdit:m,onHistory:y,onFormat:v};const R=()=>{const e=w.current,t=S.current,n=e?.ownerDocument.getSelection();if(!(e&&t&&n&&0!==n.rangeCount&&n.anchorNode&&e.contains(n.anchorNode)))return null;const r=Ee(t,e,n.anchorNode,n.anchorOffset),l=n.focusNode&&e.contains(n.focusNode)?Ee(t,e,n.focusNode,n.focusOffset):r;return r<=l?[r,l]:[l,r]},B=(e,t)=>{const n=w.current,r=S.current;if(!n||!r)return;const[l,o]=Ce(r,e),[a,s]=Ce(r,t);n.ownerDocument.getSelection()?.setBaseAndExtent(l,o,a,s)};h.current={getSource(){const e=R(),t=S.current;if(!e||!t)return null;const[r,l]=n(t.layout,e[0],e[1]);return{start:r,end:l}},setSource(e,t,n){C.current={text:n,src:[e,t]},T(e=>e+1)},focus(){w.current?.focus()},rangeOf(e,n){const r=w.current,l=S.current;if(!r||!l)return null;const[o,a]=t(l.layout,e,n),[s,i]=Ce(l,o),[c,u]=Ce(l,a),d=r.ownerDocument.createRange();return d.setStart(s,i),d.setEnd(c,u),d}},q(()=>{const n=w.current;if(!n||D.current)return;const o=C.current?null:R();S.current=function(e,t){const n=e.ownerDocument;e.replaceChildren();const r=t.lines.map(t=>{const r=n.createElement("div");r.className=null!=t.number?"es-rich-line is-numbered":t.bullet?"es-rich-line is-bullet":"es-rich-line",null!=t.number&&(r.dataset.number=t.number);const l=[],o=()=>l.length?l[l.length-1].el:r;let a=null;for(const e of t.chars){let t=0;for(;t<l.length&&t<e.marks.length&&l[t].id===e.marks[t].id;)t+=1;(l.length>t||e.marks.length>t)&&(a=null),l.length=t;for(let r=t;r<e.marks.length;r+=1){const t=Se(n,e.marks[r].kind,e.marks[r].href,e.marks[r].color);o().appendChild(t),l.push({id:e.marks[r].id,el:t})}a||(a=n.createTextNode(""),o().appendChild(a)),a.data+=e.ch}return 0===t.chars.length&&r.appendChild(n.createElement("br")),e.appendChild(r),r});return{layout:t,lines:r}}(n,r(e,l)),E.current=e;const a=C.current;if(!a||a.text!==e)return void(o&&n.ownerDocument.activeElement===n&&B(o[0],Math.min(o[1],S.current.layout.text.length)));C.current=null;const s=S.current.layout,[i,c]=a.vis??t(s,a.src[0],a.src[1]);n.ownerDocument.activeElement!==n&&n.focus(),B(i,c)},[e,l,L]);const P=(e,t,r)=>{const l=S.current,[o,a]=n(l.layout,t[0],t[1]);C.current={text:e.text,vis:[e.caret,e.caret]},e.text!==M.current.value?M.current.onEdit(e.text,{start:o,end:a},r):T(e=>e+1)};X(()=>{const e=w.current;if(!e)return;const t=t=>{const{value:n,rules:r,multiline:l,readOnly:o,pending:a}=M.current;if("insertCompositionText"===t.inputType)return;if(t.preventDefault(),o)return;const i=S.current,c=R();if(!i||!c)return;const u="function"==typeof t.getTargetRanges?t.getTargetRanges()[0]:void 0,d=u&&!u.collapsed?[Ee(i,e,u.startContainer,u.startOffset),Ee(i,e,u.endContainer,u.endOffset)]:null,p=s({value:n,rules:r,multiline:l,inputType:t.inputType,data:t.data??t.dataTransfer?.getData("text/plain")??"",html:t.dataTransfer?.getData("text/html"),doc:e.ownerDocument,sel:c,target:d,pending:a});p&&("history"!==p.kind?"format"!==p.kind?P(p.edit,p.range,p.kind):M.current.onFormat(p.style):M.current.onHistory(p.dir))},n=()=>{D.current||T(e=>e+1)};return e.addEventListener("beforeinput",t),e.addEventListener("input",n),()=>{e.removeEventListener("beforeinput",t),e.removeEventListener("input",n)}},[]),X(()=>{const e=w.current;if(!e)return;const t=e.ownerDocument,n=()=>{const e=h.current?.getSource();e&&g(e)};return t.addEventListener("selectionchange",n),()=>t.removeEventListener("selectionchange",n)});const O=(t,n=!1)=>{const r=R();if(!r||r[0]===r[1])return;t.preventDefault();const o=S.current;t.clipboardData.setData("text/plain",o.layout.text.slice(r[0],r[1])),t.clipboardData.setData(c,u(e,l,r[0],r[1])),n&&!d&&P(i(e,l,r[0],r[1],{text:""}),r,"edit")};/* @__PURE__ */
2
2
  return de("div",{className:"es-rich-wrap",children:[p&&""===e?/* @__PURE__ */ue("div",{className:"es-rich-placeholder","aria-hidden":"true",children:p}):null,
3
3
  /* @__PURE__ */ue("div",{ref:w,className:`es-rich${o?" is-multiline":" is-single"}${d?" is-off":""}`,contentEditable:!d,suppressContentEditableWarning:!0,role:"textbox","aria-multiline":o,"aria-label":f,"aria-readonly":d||void 0,"aria-placeholder":p,tabIndex:d?-1:0,spellCheck:!0,onFocus:()=>{N.current=e},onBlur:()=>{e!==N.current&&k?.(e),N.current=e},onKeyDown:t=>{if("Escape"===t.key)return t.preventDefault(),x?.(N.current),void(N.current=e);"Enter"!==t.key||o||(t.preventDefault(),e!==N.current&&k?.(e),N.current=e)},onCompositionStart:()=>{const e=R()??[0,0];D.current={from:e[0],to:e[1]}},onCompositionEnd:e=>{const t=D.current;if(D.current=null,!t)return;const{value:n,rules:r,pending:l}=M.current;e.data?P(i(n,r,t.from,t.to,{text:e.data,add:l?.add,drop:l?.drop,color:l?.color}),[t.from,t.to],"type"):T(e=>e+1)},onCopy:e=>O(e),onCut:e=>O(e,!0),onPaste:t=>{if(t.preventDefault(),d)return;const n=R();if(!n)return;const r=t.clipboardData.getData(c),s=r?o?r:r.replace(/\s*\r?\n\s*/g," "):a({html:t.clipboardData.getData("text/html"),text:t.clipboardData.getData("text/plain")},{doc:t.currentTarget.ownerDocument,multiline:o,rules:l});P(i(e,l,n[0],n[1],{markup:s}),n,"edit")}})]})}var Ne={fontSize:{key:"fontSize",nameKey:"fontSize",icon:/* @__PURE__ */ue(ne,{}),unit:"px",step:1,shiftStep:10,min:5},lineHeight:{key:"lineHeight",nameKey:"lineHeight",icon:/* @__PURE__ */ue(te,{}),unit:"%",step:1,shiftStep:10,min:50,max:250,scale:100},letterSpacing:{key:"letterSpacing",nameKey:"letterSpacing",icon:/* @__PURE__ */ue(ee,{}),unit:"px",step:.1,shiftStep:1,min:-10},paragraphSpacing:{key:"paragraphSpacing",nameKey:"paragraphSpacing",icon:/* @__PURE__ */ue(J,{}),unit:"px",step:1,shiftStep:10,min:0}};function Le(e,t){return void 0===e?void 0:Number((e*t).toFixed(6))}function Te({cells:t,words:n,readOnly:r=!1}){const l=n??e.cells;/* @__PURE__ */
4
4
  return ue("div",{className:"es-copy-cells",children:t.map(e=>{const t=e.scale??1,n=e.name??(e.nameKey?l[e.nameKey]:e.key),o=e.unit??"",a=e.step??1;/* @__PURE__ */
@@ -8,11 +8,11 @@ return de("div",{className:"es-copy-pop es-copy-colors",role:"dialog","aria-labe
8
8
  /* @__PURE__ */ue("div",{className:"es-copy-theme",role:"group","aria-label":n.theme,children:e.map(e=>/* @__PURE__ */ue(z,{content:`${e.label} · ${e.value.toUpperCase()}`,children:/* @__PURE__ */ue(K,{color:e.value,size:"sm",className:"es-copy-theme-swatch","data-color":e.name,"aria-label":e.label,selected:t===e.name,onMouseDown:Me,onClick:()=>r(e.name)})},e.name))}),
9
9
  /* @__PURE__ */ue("span",{className:"es-copy-pop-label",children:n.any}),
10
10
  /* @__PURE__ */ue(F,{className:"es-copy-any",value:l??"",onChange:e=>{e!==t&&r(e)},label:n.title,dragWrites:"end"}),
11
- /* @__PURE__ */ue("div",{className:"es-copy-pop-foot",children:/* @__PURE__ */ue(W,{variant:"ghost-danger",size:"sm","data-window-action":"remove",onMouseDown:Me,onClick:()=>r(null),children:n.remove})})]})}var Be=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n));var Pe=e=>({left:e.left,top:e.top,right:e.right,bottom:e.bottom});function Oe(e){const t=e.ownerDocument,n=t.documentElement,r={left:0,top:0,right:n.clientWidth,bottom:n.clientHeight},l=t.defaultView?.getComputedStyle.bind(t.defaultView);for(let o=e.parentElement;o&&o!==n&&o!==t.body;o=o.parentElement){const e=l?.(o);if(!e||"visible"===e.overflowX&&"visible"===e.overflowY)continue;const t=o.getBoundingClientRect();if(0===t.width&&0===t.height)continue;const n=t.left+o.clientLeft,a=t.top+o.clientTop;r.left=Math.max(r.left,n),r.top=Math.max(r.top,a),r.right=Math.min(r.right,n+(o.clientWidth||t.width)),r.bottom=Math.min(r.bottom,a+(o.clientHeight||t.height))}return r}function ze(e){const t=e.offsetParent??e.parentElement;if(!t)return{left:0,top:0};const n=t.getBoundingClientRect();return{left:n.left+t.clientLeft-t.scrollLeft,top:n.top+t.clientTop-t.scrollTop}}var Ke=/* @__PURE__ */new Set([...f,"clear"]),Fe={bold:/* @__PURE__ */ue(ce,{size:16}),italic:/* @__PURE__ */ue(ie,{size:16}),strike:/* @__PURE__ */ue(se,{size:16}),highlight:/* @__PURE__ */ue(ae,{size:16}),quiet:/* @__PURE__ */ue(oe,{size:16}),link:/* @__PURE__ */ue(le,{size:16}),clear:/* @__PURE__ */ue(re,{size:16})};function We(e){if(!e)return;const t=e.split("+"),n=t.pop().toUpperCase();return["Meta",...t.map(e=>e[0].toUpperCase()+e.slice(1)),n].join("+")}var $e={bold:"is-bold",italic:"is-italic",strike:"is-strike"};function je({tools:t,onApply:n,disabled:r=!1,actions:l,align:o,glyphs:a,ariaLabel:s,pressed:i,open:c=null}){const u=P("copy",e),d=("string"==typeof t[0]?m(t).map(e=>({...e,...u.marks[e.style]})):t).filter(e=>!Ke.has(e.style));return 0!==d.length||l||o?/* @__PURE__ */de("div",{className:"es-copy-bar",role:"group","aria-label":s??u.formatting,children:[d.map(e=>{const t=a?.[e.style]??Fe[e.style],l=c===e.style||Boolean(i?.[e.style]),o="link"===e.style&&Boolean(i);return O(e.title,/* @__PURE__ */ue($,{onMouseDown:e=>e.preventDefault(),onClick:()=>n(e.style),disabled:r,"aria-label":e.name??e.title,"aria-keyshortcuts":We(e.shortcut),"aria-pressed":o||!i&&!c?void 0:l,pressed:o?l:void 0,"aria-haspopup":o?"dialog":void 0,"aria-expanded":o?"link"===c:void 0,className:`es-copy-mark${t?" has-glyph":$e[e.style]?` ${$e[e.style]}`:""}${l?" is-active":""}`,children:t??e.label},e.style))}),l?/* @__PURE__ */de(pe,{children:[
12
- /* @__PURE__ */ue("span",{className:"es-copy-bar-split","aria-hidden":"true"}),l]}):null,o?/* @__PURE__ */ue("span",{className:"es-copy-bar-end",children:o}):null]}):null}function He({target:e,onChange:t}){const n=I(null);return q(()=>{const t=n.current,r=e.current;t&&r&&r.value===t.text&&(n.current=null,r.focus(),r.setSelectionRange(t.start,t.end))}),r=>{const l=r(e.current);t(l.text),n.current={start:l.selectionStart,end:l.selectionEnd,text:l.text}}}var Ae=["bold","italic","underline","strike","sup","sub"];function Ve({value:t,onChange:n,onCommit:r,onCancel:s,multiline:i=!1,placeholder:c,ariaLabel:u,className:d,readOnly:f=!1,rules:z,tools:K=[],writeMark:F,actions:$,align:_,glyphs:G,barLabel:Q,renderFooter:Z,inputRef:J,barShows:ee="always",richText:te=!0,defaultShowMarks:ne=!1,toolbar:le="final",colors:oe,cells:ae,letterCase:se,lastTool:ie}){const ce="final"===le,fe=P("copy",e),he=I(null),me=J??he,[ge,ve]=U(!1),[ke,Se]=U(null),Ee=I(l()).current,Ce=I(null);X(()=>{const e=Ce.current;e&&t===e.to?Ce.current=null:e&&t===e.from||(Ce.current=null,Ee.reset())},[t,Ee]);const Ne=e=>{Ce.current={from:Ce.current?.from??t,to:e},n(e)},Le=e=>({text:t,start:e?.selectionStart??ke?.start??t.length,end:e?.selectionEnd??ke?.end??t.length}),[Me,Fe]=U(ne),We=te&&!(i&&Me),$e=I(null),Ve=Y(),[Ie,Ue]=U(null),[qe,Xe]=U(!1),Ye=()=>{if(!We)return me.current;const e=$e.current?.getSource()??ke;return e?{selectionStart:e.start,selectionEnd:e.end}:null},_e=He({target:me,onChange:Ne}),Ge=e=>(Se({start:e.selectionStart,end:e.selectionEnd}),e),Qe=(e,n)=>{if(!We)return void _e(t=>(n&&Ee.record(Le(t),"edit",Date.now()),Ge(e(t))));const r=Ye(),l=Ge(e(r));n&&Ee.record(Le(r),"edit",Date.now()),Ue(null),l.text!==t&&Ne(l.text),$e.current?.setSource(l.selectionStart,l.selectionEnd,l.text)},Ze=e=>Qe(e,!0),Je=e=>Qe(t=>{const n=Le(t),r=Ee[e](n);return r?{text:r.text,selectionStart:r.start,selectionEnd:r.end}:{text:n.text,selectionStart:n.start,selectionEnd:n.end}},!1),et=I(null);q(()=>{const e=et.current;e&&(et.current=null,We?$e.current?.setSource(e.start,e.end,t):(me.current?.focus(),me.current?.setSelectionRange(e.start,e.end),Se(e)))},[We]);const[tt,nt]=U(null),rt=z??y,lt=("string"==typeof K[0]?m(K):K).filter(e=>!Ke.has(e.style)),ot=ce?("string"==typeof K[0]?K:K.map(e=>e.style)).filter(e=>!Ke.has(e)):lt.map(e=>e.style),at={};if(ke&&(We||ce)){const e=g(t,ke.start,ke.end,rt);for(const t of ot){const n=e.has(t)||"highlight"===t&&e.has("accent");at[t]=!!Ie?.add.includes(t)||!Ie?.drop.includes(t)&&n}ce&&(at.link=e.has("link"))}else if(ke)for(const e of ot)at[e]="link"===e?null!==v(t,ke.start,ke.end):b(t,ke.start,ke.end,e);const st=()=>{const e=Ye(),n=e?.selectionStart??t.length;return{start:n,end:e?.selectionEnd??n}},it=e=>{if(ce&&"link"!==e&&w(0,e)){const{start:n,end:r}=st();if(n===r&&!We)return void Ze(n=>xe(t,e,n,(e,t,n,r)=>h(e,t,n,r,rt,fe.placeholders)));const l=o({value:t,rules:rt,start:n,end:r,style:e,pending:Ie});return void("pending"===l.kind?Ue(l.pending):Ze(()=>l.result))}if("clear"===e)return void Ze(n=>xe(t,e,n,(e,t,n)=>h(e,t,n,"clear",rt)));if("link"!==e&&We&&w(0,e)){const n=Ye(),r=n?.selectionStart??t.length,l=n?.selectionEnd??r;if(r===l){const n=g(t,r,l,rt),o=n.has(e)||"highlight"===e&&n.has("accent"),a=Ie&&Ie.at===r?Ie:null,s=!!a?.add.includes(e)||!a?.drop.includes(e)&&o,i=(a?.add??[]).filter(t=>t!==e),c=(a?.drop??[]).filter(t=>t!==e);return s&&o?c.push(e):s||o||i.push(e),void Ue(i.length||c.length?{add:i,drop:c,at:r}:null)}return void Ze(n=>E(t,n?.selectionStart??r,n?.selectionEnd??l,e,rt))}if("link"!==e){const n=F??((e,t,n,r)=>h(e,t,n,r,y,fe.placeholders));return void Ze(r=>xe(t,e,r,n))}const n=Ye(),r=n?.selectionStart??t.length,l=n?.selectionEnd??r;Xe(!1),nt({start:r,end:l,link:v(t,r,l)})},ct=Boolean(ke&&ke.start!==ke.end),ut=ke?k(t,ke.start,ke.end,rt):null,dt=ke?Ie&&void 0!==Ie.color&&Ie.at===ke.start?Ie.color:x(t,ke.start,ke.end,rt):null,pt=dt?dt.startsWith("#")?dt:oe?.find(e=>e.name===dt)?.value:void 0,ft=e=>{We?e?$e.current?.setSource(e.start,e.end,t):$e.current?.focus():(me.current?.focus(),e&&me.current?.setSelectionRange(e.start,e.end))},ht=()=>{const e=tt;nt(null),ft(e?{start:e.start,end:e.end}:ke)},mt=()=>{const e=yt.current,t=Boolean(e&&e.querySelector(".es-copy-colors")?.contains(e.ownerDocument.activeElement));Xe(!1),t&&ft(ke)},gt=I(mt);gt.current=mt,X(()=>{if(qe)return j(e=>{const t=yt.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(gt.current(),!0)},()=>yt.current?.querySelector(".es-copy-colors"))},[qe]);const yt=I(null),vt=qe||null!==tt;X(()=>{const e=yt.current;if(!vt||!e)return;const t=e.ownerDocument,n=()=>{Xe(!1),nt(null)},r=t=>{e.contains(t.target)||n()};let l;const o=r=>{const o=r.relatedTarget;o?e.contains(o)||n():(clearTimeout(l),l=setTimeout(()=>{const r=t.activeElement;t.hasFocus()&&r&&r!==t.body&&!e.contains(r)&&n()},0))};return t.addEventListener("pointerdown",r,!0),e.addEventListener("focusout",o),()=>{clearTimeout(l),t.removeEventListener("pointerdown",r,!0),e.removeEventListener("focusout",o)}},[vt]);const bt=tt??(qe?ke??{start:t.length,end:t.length}:null),kt=I(()=>{});kt.current=()=>{const e=yt.current,t=e?.querySelector(".rosh-tb-wrap > .es-copy-pop");if(!e||!t||!bt)return;const n=We?null:e.querySelector(".es-gold-layer"),r=We?$e.current?.rangeOf(bt.start,bt.end)??null:n?function(e,t,n){const r=e.ownerDocument,l=r.createTreeWalker(e,4),o=e=>{let t=e,n=null;for(let e=l.nextNode();e;e=l.nextNode()){if(t<=e.data.length)return[e,t];t-=e.data.length,n=e}return n?[n,n.data.length]:null},a=o(t);l.currentNode=e;const s=o(n);if(!a||!s)return null;const i=r.createRange();return i.setStart(a[0],a[1]),i.setEnd(s[0],s[1]),i}(n,bt.start,bt.end):null,l=r?.endContainer,o=l?1===l.nodeType?l:l.parentElement:null,a=r?function(e,t){const n=("function"==typeof e.getClientRects?[...e.getClientRects()]:[]).filter(e=>e.height>0);if(n.length>0){const t="function"==typeof e.getBoundingClientRect?e.getBoundingClientRect():n[0];return t.height>0?Pe(t):Pe(n[0])}if(!t)return null;const r=t.getBoundingClientRect();return{left:r.left,top:r.top,right:r.left,bottom:r.bottom}}(r,o?.closest(".es-rich-line, .es-gold-layer")??null):null;if(!a)return;const s=function({anchor:e,size:t,within:n,clip:r,parent:l,gap:o=8}){const a=Math.max(n.left,r.left),s=Math.min(n.right,r.right)-t.width,i=Be(e.left,a,s),c=r.bottom-(e.bottom+o),u=e.top-o-r.top,d=t.height>c&&(t.height<=u||u>c),p=d?e.top-o-t.height:e.bottom+o,f=e.left+Math.min((e.right-e.left)/2,10),h=Be(f-5-i,10,t.width-10-10);return{top:p-l.top,left:i-l.left,above:d,point:h}}({anchor:a,size:{width:t.offsetWidth,height:t.offsetHeight},within:e.getBoundingClientRect(),clip:Oe(e),parent:ze(t)});t.style.top=`${s.top}px`,t.style.left=`${s.left}px`,t.style.setProperty("--es-pop-point",`${s.point}px`),t.dataset.side=s.above?"above":"below"},q(()=>{const e=yt.current;if(!vt||!e)return;const t=()=>kt.current();t();const n=e.ownerDocument.defaultView;n?.addEventListener("resize",t);const r=e.querySelector(".rosh-tb-wrap > .es-copy-pop"),l=n?.ResizeObserver,o=l&&r?new l(t):null;return o&&r&&o.observe(r),()=>{n?.removeEventListener("resize",t),o?.disconnect()}},[vt,qe,tt,bt?.start,bt?.end,We]);const xt=e=>tt&&/* @__PURE__ */ue(V,{className:e?"es-copy-link es-copy-pop":"es-copy-link",value:tt.link?.href??"",onApply:e=>{const n=tt;nt(null),Ze(()=>We?T(t,n.start,n.end,e,rt):M(t,n.start,n.end,e))},onRemove:tt.link?()=>{const e=tt.link,n=tt;nt(null),e&&Ze(()=>We?N(t,n.start,n.end,rt):L(t,e))}:void 0,onCancel:ht}),wt=_?ye(_.allow,fe.align):[],St="always"===ee||ge||null!==tt||qe,Et=oe&&oe.length>0?{run:pt,open:qe,onToggle:()=>{nt(null),qe?mt():Xe(!0)}}:void 0,Ct=St&&ce&&ie?ie({className:"rosh-tb-btn",disabled:f,selected:ct,keepCaret:e=>e.preventDefault(),insert:e=>Ze(n=>we(t,e,n))}):void 0,Dt=new Set(ot),Nt=_?{value:_.value,allow:_.allow,onChange:_.onChange,disabled:_.disabled}:void 0,Lt={pressed:ut,onList:e=>{const{start:n,end:r}=st(),l=k(t,n,r,rt);Ze(()=>D(t,n,r,l===e?null:e,rt))}},Tt=H({offered:Dt,color:Et,last:Ct,alignment:Nt,list:Lt,letterCase:se}),Mt=ce&&St&&(Ae.some(e=>Dt.has(e))||Boolean(Et));/* @__PURE__ */
13
- return de("div",{ref:yt,className:"es-copy"+(d?` ${d}`:""),onFocus:()=>ve(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||ve(!1)},onKeyDown:e=>{const t=e.target===me.current||Boolean(e.target.closest?.(".es-rich"));if(f||!t)return;if(e.altKey||e.metaKey===e.ctrlKey)return;const n=e.key.toLowerCase(),r="KeyZ"===e.code||"z"===n,l=("KeyY"===e.code||"y"===n)&&!e.shiftKey;if(r||l)return e.preventDefault(),e.stopPropagation(),void Je(l||e.shiftKey?"redo":"undo");const o=`${e.shiftKey?"shift+":""}${n}`;if(ce){const t={b:"bold",i:"italic",u:"underline",k:"link"}[o];if(!t||!ot.includes(t))return;return e.preventDefault(),e.stopPropagation(),void it(t)}const a=lt.find(e=>e.shortcut===o);a&&(e.preventDefault(),e.stopPropagation(),it(a.style))},onPaste:e=>{const n=me.current;if(f||!n||e.target!==n)return;e.preventDefault();const r=a({html:e.clipboardData.getData("text/html"),text:e.clipboardData.getData("text/plain")},{doc:n.ownerDocument,multiline:i,rules:rt});Ze(e=>we(t,r,e))},style:oe&&oe.length>0?Object.fromEntries(oe.map(e=>[`--es-color-${e.name}`,e.value])):void 0,onSelect:()=>{const e=me.current;e&&e.ownerDocument.activeElement===e&&Se({start:e.selectionStart??t.length,end:e.selectionEnd??t.length})},children:[St&&ce&&(Tt.words||Tt.paragraph)?
14
- /* @__PURE__ */ue(A,{className:"es-copy-toolbar","aria-label":Q??fe.formatting,offered:Dt,pressed:at,onMark:e=>it(e),color:Et,linkOpen:null!==tt,last:Ct,alignment:Nt,list:Lt,letterCase:se,disabled:f,windows:/* @__PURE__ */de(pe,{children:[qe&&oe&&oe.length>0?/* @__PURE__ */ue(Re,{colors:oe,current:dt,words:fe.colors??e.colors,onPick:e=>{const{start:n,end:r}=st();if(n!==r)Ze(()=>C(t,n,r,e,rt));else{if(!We)return;Ue({add:Ie?.add??[],drop:Ie?.drop??[],color:e,at:n})}}}):null,tt?xt(!0):null]})}):null,ce&&ae&&ae.length>0?/* @__PURE__ */ue(Te,{cells:ae,words:fe.cells??e.cells,readOnly:f}):null,St&&!ce?/* @__PURE__ */ue(je,{tools:K,disabled:f,actions:$,glyphs:G,ariaLabel:Q,pressed:at,open:tt?"link":null,onApply:it,align:_?/* @__PURE__ */ue(R,{options:wt,value:_.value,onChange:_.onChange,ariaLabel:fe.alignment,disabled:f||_.disabled,fit:be(wt)}):null}):null,We?/* @__PURE__ */ue(De,{value:t,rules:rt,multiline:i,readOnly:f,placeholder:c,ariaLabel:u,handle:$e,pending:Ie??void 0,onEdit:(e,n,r)=>{Ee.record({text:t,start:n.start,end:n.end},r,Date.now()),Ue(null),Ne(e)},onSelect:e=>{Se(t=>t&&t.start===e.start&&t.end===e.end?t:e),!Ie||e.start===Ie.at&&e.end===Ie.at||Ue(null)},onHistory:Je,onFormat:e=>{ot.includes(e)&&it(e)},onCommit:r,onCancel:s}):/* @__PURE__ */ue(p,{value:t,onInput:e=>{Ee.record(Le(null),"type",Date.now()),Ne(e)},onCommit:r,onCancel:s,multiline:i,placeholder:c,ariaLabel:u,rules:z,disabled:f,inputRef:me,className:"es-copy-box"}),tt&&!ce?xt(!1):null,Z?Z({focused:ge,insert:e=>Ze(n=>we(t,e,n))}):null,te&&i||Mt?
11
+ /* @__PURE__ */ue("div",{className:"es-copy-pop-foot",children:/* @__PURE__ */ue(W,{variant:"ghost-danger",size:"sm","data-window-action":"remove",onMouseDown:Me,onClick:()=>r(null),children:n.remove})})]})}var Be=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n));var Pe=e=>({left:e.left,top:e.top,right:e.right,bottom:e.bottom});function Oe(e){const t=e.ownerDocument,n=t.documentElement,r={left:0,top:0,right:n.clientWidth,bottom:n.clientHeight},l=t.defaultView?.getComputedStyle.bind(t.defaultView);for(let o=e.parentElement;o&&o!==n&&o!==t.body;o=o.parentElement){const e=l?.(o);if(!e||"visible"===e.overflowX&&"visible"===e.overflowY)continue;const t=o.getBoundingClientRect();if(0===t.width&&0===t.height)continue;const n=t.left+o.clientLeft,a=t.top+o.clientTop;r.left=Math.max(r.left,n),r.top=Math.max(r.top,a),r.right=Math.min(r.right,n+(o.clientWidth||t.width)),r.bottom=Math.min(r.bottom,a+(o.clientHeight||t.height))}return r}function ze(e){const t=e.offsetParent??e.parentElement;if(!t)return{left:0,top:0};const n=t.getBoundingClientRect();return{left:n.left+t.clientLeft-t.scrollLeft,top:n.top+t.clientTop-t.scrollTop}}var Ke=/* @__PURE__ */new Set([...m,"clear"]),Fe={bold:/* @__PURE__ */ue(ce,{size:16}),italic:/* @__PURE__ */ue(ie,{size:16}),strike:/* @__PURE__ */ue(se,{size:16}),highlight:/* @__PURE__ */ue(ae,{size:16}),quiet:/* @__PURE__ */ue(oe,{size:16}),link:/* @__PURE__ */ue(le,{size:16}),clear:/* @__PURE__ */ue(re,{size:16})};function We(e){if(!e)return;const t=e.split("+"),n=t.pop().toUpperCase();return["Meta",...t.map(e=>e[0].toUpperCase()+e.slice(1)),n].join("+")}var $e={bold:"is-bold",italic:"is-italic",strike:"is-strike"};function je({tools:t,onApply:n,disabled:r=!1,actions:l,align:o,glyphs:a,ariaLabel:s,pressed:i,open:c=null}){const u=P("copy",e),d=("string"==typeof t[0]?y(t).map(e=>({...e,...u.marks[e.style]})):t).filter(e=>!Ke.has(e.style));return 0!==d.length||l||o?/* @__PURE__ */de("div",{className:"es-copy-bar",role:"group","aria-label":s??u.formatting,children:[d.map(e=>{const t=a?.[e.style]??Fe[e.style],l=c===e.style||Boolean(i?.[e.style]),o="link"===e.style&&Boolean(i);return O(e.title,/* @__PURE__ */ue($,{onMouseDown:e=>e.preventDefault(),onClick:()=>n(e.style),disabled:r,"aria-label":e.name??e.title,"aria-keyshortcuts":We(e.shortcut),"aria-pressed":o||!i&&!c?void 0:l,pressed:o?l:void 0,"aria-haspopup":o?"dialog":void 0,"aria-expanded":o?"link"===c:void 0,className:`es-copy-mark${t?" has-glyph":$e[e.style]?` ${$e[e.style]}`:""}${l?" is-active":""}`,children:t??e.label},e.style))}),l?/* @__PURE__ */de(pe,{children:[
12
+ /* @__PURE__ */ue("span",{className:"es-copy-bar-split","aria-hidden":"true"}),l]}):null,o?/* @__PURE__ */ue("span",{className:"es-copy-bar-end",children:o}):null]}):null}function He({target:e,onChange:t}){const n=I(null);return q(()=>{const t=n.current,r=e.current;t&&r&&r.value===t.text&&(n.current=null,r.focus(),r.setSelectionRange(t.start,t.end))}),r=>{const l=r(e.current);t(l.text),n.current={start:l.selectionStart,end:l.selectionEnd,text:l.text}}}var Ae=["bold","italic","underline","strike","sup","sub"];function Ve({value:t,onChange:n,onCommit:r,onCancel:s,multiline:i=!1,placeholder:c,ariaLabel:u,className:d,readOnly:m=!1,rules:z,tools:K=[],writeMark:F,actions:$,align:_,glyphs:G,barLabel:Q,renderFooter:Z,inputRef:J,barShows:ee="always",richText:te=!0,defaultShowMarks:ne=!1,toolbar:le="final",colors:oe,cells:ae,letterCase:se,lastTool:ie}){const ce="final"===le,fe=P("copy",e),he=I(null),me=J??he,[ge,ve]=U(!1),[ke,Se]=U(null),Ee=I(l()).current,Ce=I(null);X(()=>{const e=Ce.current;e&&t===e.to?Ce.current=null:e&&t===e.from||(Ce.current=null,Ee.reset())},[t,Ee]);const Ne=e=>{Ce.current={from:Ce.current?.from??t,to:e},n(e)},Le=e=>({text:t,start:e?.selectionStart??ke?.start??t.length,end:e?.selectionEnd??ke?.end??t.length}),[Me,Fe]=U(ne),We=te&&!(i&&Me),$e=I(null),Ve=Y(),[Ie,Ue]=U(null),[qe,Xe]=U(!1),Ye=()=>{if(!We)return me.current;const e=$e.current?.getSource()??ke;return e?{selectionStart:e.start,selectionEnd:e.end}:null},_e=He({target:me,onChange:Ne}),Ge=e=>(Se({start:e.selectionStart,end:e.selectionEnd}),e),Qe=(e,n)=>{if(!We)return void _e(t=>(n&&Ee.record(Le(t),"edit",Date.now()),Ge(e(t))));const r=Ye(),l=Ge(e(r));n&&Ee.record(Le(r),"edit",Date.now()),Ue(null),l.text!==t&&Ne(l.text),$e.current?.setSource(l.selectionStart,l.selectionEnd,l.text)},Ze=e=>Qe(e,!0),Je=e=>Qe(t=>{const n=Le(t),r=Ee[e](n);return r?{text:r.text,selectionStart:r.start,selectionEnd:r.end}:{text:n.text,selectionStart:n.start,selectionEnd:n.end}},!1),et=I(null);q(()=>{const e=et.current;e&&(et.current=null,We?$e.current?.setSource(e.start,e.end,t):(me.current?.focus(),me.current?.setSelectionRange(e.start,e.end),Se(e)))},[We]);const[tt,nt]=U(null),rt=z??b,lt=("string"==typeof K[0]?y(K):K).filter(e=>!Ke.has(e.style)),ot=ce?("string"==typeof K[0]?K:K.map(e=>e.style)).filter(e=>!Ke.has(e)):lt.map(e=>e.style),at={};if(ke&&(We||ce)){const e=v(t,ke.start,ke.end,rt);for(const t of ot){const n=e.has(t)||"highlight"===t&&e.has("accent");at[t]=!!Ie?.add.includes(t)||!Ie?.drop.includes(t)&&n}ce&&(at.link=e.has("link"))}else if(ke)for(const e of ot)at[e]="link"===e?null!==k(t,ke.start,ke.end):x(t,ke.start,ke.end,e);const st=()=>{const e=Ye(),n=e?.selectionStart??t.length;return{start:n,end:e?.selectionEnd??n}},it=e=>{if(ce&&"link"!==e&&E(0,e)){const{start:n,end:r}=st();if(n===r&&!We)return void Ze(n=>xe(t,e,n,(e,t,n,r)=>g(e,t,n,r,rt,fe.placeholders)));const l=o({value:t,rules:rt,start:n,end:r,style:e,pending:Ie});return void("pending"===l.kind?Ue(l.pending):Ze(()=>l.result))}if("clear"===e)return void Ze(n=>xe(t,e,n,(e,t,n)=>g(e,t,n,"clear",rt)));if("link"!==e&&We&&E(0,e)){const n=Ye(),r=n?.selectionStart??t.length,l=n?.selectionEnd??r;if(r===l){const n=v(t,r,l,rt),o=n.has(e)||"highlight"===e&&n.has("accent"),a=Ie&&Ie.at===r?Ie:null,s=!!a?.add.includes(e)||!a?.drop.includes(e)&&o,i=(a?.add??[]).filter(t=>t!==e),c=(a?.drop??[]).filter(t=>t!==e);return s&&o?c.push(e):s||o||i.push(e),void Ue(i.length||c.length?{add:i,drop:c,at:r}:null)}return void Ze(n=>D(t,n?.selectionStart??r,n?.selectionEnd??l,e,rt))}if("link"!==e){const n=F??((e,t,n,r)=>g(e,t,n,r,b,fe.placeholders));return void Ze(r=>xe(t,e,r,n))}const n=Ye(),r=n?.selectionStart??t.length,l=n?.selectionEnd??r;Xe(!1),nt({start:r,end:l,link:k(t,r,l)})},ct=Boolean(ke&&ke.start!==ke.end),ut=ke?w(t,ke.start,ke.end,rt):null,dt=ke?Ie&&void 0!==Ie.color&&Ie.at===ke.start?Ie.color:S(t,ke.start,ke.end,rt):null,pt=dt?dt.startsWith("#")?dt:oe?.find(e=>e.name===dt)?.value:void 0,ft=e=>{We?e?$e.current?.setSource(e.start,e.end,t):$e.current?.focus():(me.current?.focus(),e&&me.current?.setSelectionRange(e.start,e.end))},ht=()=>{const e=tt;nt(null),ft(e?{start:e.start,end:e.end}:ke)},mt=()=>{const e=yt.current,t=Boolean(e&&e.querySelector(".es-copy-colors")?.contains(e.ownerDocument.activeElement));Xe(!1),t&&ft(ke)},gt=I(mt);gt.current=mt,X(()=>{if(qe)return j(e=>{const t=yt.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(gt.current(),!0)},()=>yt.current?.querySelector(".es-copy-colors"))},[qe]);const yt=I(null),vt=qe||null!==tt;X(()=>{const e=yt.current;if(!vt||!e)return;const t=e.ownerDocument,n=()=>{Xe(!1),nt(null)},r=t=>{e.contains(t.target)||n()};let l;const o=r=>{const o=r.relatedTarget;o?e.contains(o)||n():(clearTimeout(l),l=setTimeout(()=>{const r=t.activeElement;t.hasFocus()&&r&&r!==t.body&&!e.contains(r)&&n()},0))};return t.addEventListener("pointerdown",r,!0),e.addEventListener("focusout",o),()=>{clearTimeout(l),t.removeEventListener("pointerdown",r,!0),e.removeEventListener("focusout",o)}},[vt]);const bt=tt??(qe?ke??{start:t.length,end:t.length}:null),kt=I(()=>{});kt.current=()=>{const e=yt.current,t=e?.querySelector(".rosh-tb-wrap > .es-copy-pop");if(!e||!t||!bt)return;const n=We?null:e.querySelector(".es-gold-layer"),r=We?$e.current?.rangeOf(bt.start,bt.end)??null:n?function(e,t,n){const r=e.ownerDocument,l=r.createTreeWalker(e,4),o=e=>{let t=e,n=null;for(let e=l.nextNode();e;e=l.nextNode()){if(t<=e.data.length)return[e,t];t-=e.data.length,n=e}return n?[n,n.data.length]:null},a=o(t);l.currentNode=e;const s=o(n);if(!a||!s)return null;const i=r.createRange();return i.setStart(a[0],a[1]),i.setEnd(s[0],s[1]),i}(n,bt.start,bt.end):null,l=r?.endContainer,o=l?1===l.nodeType?l:l.parentElement:null,a=r?function(e,t){const n=("function"==typeof e.getClientRects?[...e.getClientRects()]:[]).filter(e=>e.height>0);if(n.length>0){const t="function"==typeof e.getBoundingClientRect?e.getBoundingClientRect():n[0];return t.height>0?Pe(t):Pe(n[0])}if(!t)return null;const r=t.getBoundingClientRect();return{left:r.left,top:r.top,right:r.left,bottom:r.bottom}}(r,o?.closest(".es-rich-line, .es-gold-layer")??null):null;if(!a)return;const s=function({anchor:e,size:t,within:n,clip:r,parent:l,gap:o=8}){const a=Math.max(n.left,r.left),s=Math.min(n.right,r.right)-t.width,i=Be(e.left,a,s),c=r.bottom-(e.bottom+o),u=e.top-o-r.top,d=t.height>c&&(t.height<=u||u>c),p=d?e.top-o-t.height:e.bottom+o,f=e.left+Math.min((e.right-e.left)/2,10),h=Be(f-5-i,10,t.width-10-10);return{top:p-l.top,left:i-l.left,above:d,point:h}}({anchor:a,size:{width:t.offsetWidth,height:t.offsetHeight},within:e.getBoundingClientRect(),clip:Oe(e),parent:ze(t)});t.style.top=`${s.top}px`,t.style.left=`${s.left}px`,t.style.setProperty("--es-pop-point",`${s.point}px`),t.dataset.side=s.above?"above":"below"},q(()=>{const e=yt.current;if(!vt||!e)return;const t=()=>kt.current();t();const n=e.ownerDocument.defaultView;n?.addEventListener("resize",t);const r=e.querySelector(".rosh-tb-wrap > .es-copy-pop"),l=n?.ResizeObserver,o=l&&r?new l(t):null;return o&&r&&o.observe(r),()=>{n?.removeEventListener("resize",t),o?.disconnect()}},[vt,qe,tt,bt?.start,bt?.end,We]);const xt=e=>tt&&/* @__PURE__ */ue(V,{className:e?"es-copy-link es-copy-pop":"es-copy-link",value:tt.link?.href??"",onApply:e=>{const n=tt;nt(null),Ze(()=>We?R(t,n.start,n.end,e,rt):B(t,n.start,n.end,e))},onRemove:tt.link?()=>{const e=tt.link,n=tt;nt(null),e&&Ze(()=>We?T(t,n.start,n.end,rt):M(t,e))}:void 0,onCancel:ht}),wt=_?ye(_.allow,fe.align):[],St="always"===ee||ge||null!==tt||qe,Et=oe&&oe.length>0?{run:pt,open:qe,onToggle:()=>{nt(null),qe?mt():Xe(!0)}}:void 0,Ct=St&&ce&&ie?ie({className:"rosh-tb-btn",disabled:m,selected:ct,keepCaret:e=>e.preventDefault(),insert:e=>Ze(n=>we(t,e,n))}):void 0,Dt=new Set(ot),Nt=_?{value:_.value,allow:_.allow,onChange:_.onChange,disabled:_.disabled}:void 0,Lt={pressed:ut,onList:e=>{const{start:n,end:r}=st(),l=w(t,n,r,rt);Ze(()=>L(t,n,r,l===e?null:e,rt))}},Tt=H({offered:Dt,color:Et,last:Ct,alignment:Nt,list:Lt,letterCase:se}),Mt=ce&&St&&(Ae.some(e=>Dt.has(e))||Boolean(Et));/* @__PURE__ */
13
+ return de("div",{ref:yt,className:"es-copy"+(d?` ${d}`:""),onFocus:()=>ve(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||ve(!1)},onKeyDown:e=>{const t=e.target===me.current||Boolean(e.target.closest?.(".es-rich"));if(m||!t)return;if(e.altKey||e.metaKey===e.ctrlKey)return;const n=e.key.toLowerCase(),r="KeyZ"===e.code||"z"===n,l=("KeyY"===e.code||"y"===n)&&!e.shiftKey;if(r||l)return e.preventDefault(),e.stopPropagation(),void Je(l||e.shiftKey?"redo":"undo");const o=`${e.shiftKey?"shift+":""}${n}`;if(ce){const t={b:"bold",i:"italic",u:"underline",k:"link"}[o];if(!t||!ot.includes(t))return;return e.preventDefault(),e.stopPropagation(),void it(t)}const a=lt.find(e=>e.shortcut===o);a&&(e.preventDefault(),e.stopPropagation(),it(a.style))},onPaste:e=>{const n=me.current;if(m||!n||e.target!==n)return;e.preventDefault();const r=a({html:e.clipboardData.getData("text/html"),text:e.clipboardData.getData("text/plain")},{doc:n.ownerDocument,multiline:i,rules:rt});Ze(e=>we(t,r,e))},style:oe&&oe.length>0?Object.fromEntries(oe.map(e=>[`--es-color-${e.name}`,e.value])):void 0,onSelect:()=>{const e=me.current;e&&e.ownerDocument.activeElement===e&&Se({start:e.selectionStart??t.length,end:e.selectionEnd??t.length})},children:[St&&ce&&(Tt.words||Tt.paragraph)?
14
+ /* @__PURE__ */ue(A,{className:"es-copy-toolbar","aria-label":Q??fe.formatting,offered:Dt,pressed:at,onMark:e=>it(e),color:Et,linkOpen:null!==tt,last:Ct,alignment:Nt,list:Lt,letterCase:se,disabled:m,windows:/* @__PURE__ */de(pe,{children:[qe&&oe&&oe.length>0?/* @__PURE__ */ue(Re,{colors:oe,current:dt,words:fe.colors??e.colors,onPick:e=>{const{start:n,end:r}=st();if(n!==r)Ze(()=>N(t,n,r,e,rt));else{if(!We)return;Ue({add:Ie?.add??[],drop:Ie?.drop??[],color:e,at:n})}}}):null,tt?xt(!0):null]})}):null,ce&&ae&&ae.length>0?/* @__PURE__ */ue(Te,{cells:ae,words:fe.cells??e.cells,readOnly:m}):null,St&&!ce?/* @__PURE__ */ue(je,{tools:K,disabled:m,actions:$,glyphs:G,ariaLabel:Q,pressed:at,open:tt?"link":null,onApply:it,align:_?/* @__PURE__ */ue(p,{options:wt,value:_.value,onChange:_.onChange,ariaLabel:fe.alignment,disabled:m||_.disabled,fit:be(wt)}):null}):null,We?/* @__PURE__ */ue(De,{value:t,rules:rt,multiline:i,readOnly:m,placeholder:c,ariaLabel:u,handle:$e,pending:Ie??void 0,onEdit:(e,n,r)=>{Ee.record({text:t,start:n.start,end:n.end},r,Date.now()),Ue(null),Ne(e)},onSelect:e=>{Se(t=>t&&t.start===e.start&&t.end===e.end?t:e),!Ie||e.start===Ie.at&&e.end===Ie.at||Ue(null)},onHistory:Je,onFormat:e=>{ot.includes(e)&&it(e)},onCommit:r,onCancel:s}):/* @__PURE__ */ue(h,{value:t,onInput:e=>{Ee.record(Le(null),"type",Date.now()),Ne(e)},onCommit:r,onCancel:s,multiline:i,placeholder:c,ariaLabel:u,rules:z,disabled:m,inputRef:me,className:"es-copy-box"}),tt&&!ce?xt(!1):null,Z?Z({focused:ge,insert:e=>Ze(n=>we(t,e,n))}):null,te&&i||Mt?
15
15
  /* @__PURE__ */de("div",{className:"es-copy-marks",children:[te&&i?/* @__PURE__ */de(pe,{children:[
16
- /* @__PURE__ */ue(B,{checked:Me,onChange:()=>{const e=Ye();et.current=e&&null!==e.selectionStart&&null!==e.selectionEnd?{start:e.selectionStart,end:e.selectionEnd}:ke,Ue(null),Fe(e=>!e)},ariaLabelledBy:Ve,disabled:f}),
17
- /* @__PURE__ */ue("span",{id:Ve,className:"es-copy-marks-label",children:fe.showMarks??"Show marks"})]}):null,Mt?O(ct?void 0:fe.clearStyleEmpty??"Select words first",/* @__PURE__ */de(W,{variant:"secondary",size:"sm",className:"es-copy-clear",disabled:f||!ct,onMouseDown:e=>e.preventDefault(),onClick:()=>{const{start:e,end:n}=st();if(e===n)return;const r=S(t,e,n,rt);r.text!==t&&Ze(()=>r)},children:[
16
+ /* @__PURE__ */ue(f,{checked:Me,onChange:()=>{const e=Ye();et.current=e&&null!==e.selectionStart&&null!==e.selectionEnd?{start:e.selectionStart,end:e.selectionEnd}:ke,Ue(null),Fe(e=>!e)},ariaLabelledBy:Ve,disabled:m}),
17
+ /* @__PURE__ */ue("span",{id:Ve,className:"es-copy-marks-label",children:fe.showMarks??"Show marks"})]}):null,Mt?O(ct?void 0:fe.clearStyleEmpty??"Select words first",/* @__PURE__ */de(W,{variant:"secondary",size:"sm",className:"es-copy-clear",disabled:m||!ct,onMouseDown:e=>e.preventDefault(),onClick:()=>{const{start:e,end:n}=st();if(e===n)return;const r=C(t,e,n,rt);r.text!==t&&Ze(()=>r)},children:[
18
18
  /* @__PURE__ */ue(re,{size:16}),fe.clearStyle??"Clear style"]})):null]}):null]})}export{fe as COPY_ALIGNS,ge as COPY_ALIGN_FIT,me as COPY_ALIGN_GLYPHS,he as COPY_ALIGN_LABELS,Ne as COPY_CELLS,Re as ColorWindow,Ve as CopyBox,Te as CopyCells,je as MarkBar,De as RichBox,We as ariaShortcut,ye as copyAlignOptions,we as insertSelection,xe as markSelection,He as useCaretEdit};
@@ -102,3 +102,9 @@
102
102
  outline: 2px solid var(--es-canvas-outline-colour);
103
103
  outline-offset: 4px;
104
104
  }
105
+ /* …and the words themselves draw no focus ring: a contenteditable gets the
106
+ browser's (`outline: auto`), which drew a second line inside the box on a
107
+ page whose own sheet does not remove it (an email). */
108
+ [data-es-typing]:focus {
109
+ outline: none;
110
+ }
@@ -1 +1 @@
1
- export{CanvasFrame,DEFAULT_UI,EaselCanvas,EaselProvider,EditDocument,bindUndoKeys,createEasel,createUseEasel,recordsByDefault,reduce,uiView,useEasel,useEaselApi,useEaselNodeOps,useSelectedFields,validSelection}from"../chunk-WF5IIVDD.js";import"../chunk-SOZUYCQZ.js";import"../chunk-TBY3DFKS.js";import"../chunk-YRLPFZW3.js";import"../chunk-WQASXLXS.js";import"../chunk-546BBOPE.js";import"../chunk-MFIRYGHW.js";import"../chunk-AWJUYMX7.js";import"../chunk-KRXQM65X.js";import"../chunk-NKB3KVAB.js";
1
+ export{CanvasFrame,DEFAULT_UI,EaselCanvas,EaselProvider,EditDocument,bindUndoKeys,createEasel,createUseEasel,recordsByDefault,reduce,uiView,useEasel,useEaselApi,useEaselNodeOps,useSelectedFields,validSelection}from"../chunk-AWKOTOE6.js";import"../chunk-TBY3DFKS.js";import"../chunk-YRLPFZW3.js";import"../chunk-SOZUYCQZ.js";import"../chunk-WQASXLXS.js";import"../chunk-546BBOPE.js";import"../chunk-MFIRYGHW.js";import"../chunk-AWJUYMX7.js";import"../chunk-KRXQM65X.js";import"../chunk-NKB3KVAB.js";