efficient-easel 7.1.1 → 7.2.1
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.
- package/README.md +8 -0
- package/dist/chunk-2LBXIYF7.js +1 -0
- package/dist/{chunk-SWDPE63D.js → chunk-2QUWI67X.js} +1 -1
- package/dist/{chunk-NZGRBCBZ.js → chunk-4MVZZ56S.js} +3 -3
- package/dist/{chunk-H4OMQ3QW.js → chunk-BSZ54Q2T.js} +1 -1
- package/dist/{chunk-JWJ6B67U.js → chunk-COCSEEXP.js} +1 -1
- package/dist/{chunk-2AAJCKCB.js → chunk-DOHYKMMH.js} +1 -1
- package/dist/chunk-E3PD66A3.js +5 -0
- package/dist/{chunk-GLWQPLIA.js → chunk-G24HQEX4.js} +33 -33
- package/dist/chunk-GZH4UVDH.js +8 -0
- package/dist/{chunk-Q7KMV5XI.js → chunk-HS5DWUCH.js} +1 -1
- package/dist/{chunk-AWKOTOE6.js → chunk-KYG35KKJ.js} +4 -4
- package/dist/chunk-LIH5SH6S.js +5 -0
- package/dist/chunk-PEDDDWSG.js +21 -0
- package/dist/easel/index.js +1 -1
- package/dist/fields/index.d.ts +52 -40
- package/dist/fields/index.js +1 -1
- package/dist/panel/index.d.ts +16 -2
- package/dist/panel/index.js +1 -1
- package/dist/panel/panel.css +16 -0
- package/dist/screen/components/AddBlockRow.js +1 -1
- package/dist/screen/components/AddSidePanel.js +1 -1
- package/dist/screen/components/MediaSidePanel.js +1 -1
- package/dist/screen/components/ScreenChrome.js +1 -1
- package/dist/screen/components/ScreenMount.js +1 -1
- package/dist/screen/components/ScreenStoreProvider.js +1 -1
- package/dist/screen/components/SectionScreenShell.js +15 -15
- package/dist/screen/components/usePartBridge.js +1 -1
- package/dist/screen/index.js +1 -1
- package/dist/screen/lib/key-scope.js +1 -1
- package/dist/screen/lib/puck/use-section-ops.js +1 -1
- package/dist/screen/lib/screen-parts.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-2SXSWNKG.js +0 -5
- package/dist/chunk-3ZJSLHHI.js +0 -8
- package/dist/chunk-5ZIVEJAM.js +0 -1
- package/dist/chunk-CRWFB7MU.js +0 -21
- package/dist/chunk-FCEBEN5T.js +0 -5
package/README.md
CHANGED
|
@@ -941,6 +941,14 @@ const easel = createEasel<EaselConfig>({ config, data, onChange: (doc) => autosa
|
|
|
941
941
|
are drawn inside one `SettingsGroup` (− / +, open by default). `leadFold`
|
|
942
942
|
puts `lead` in a band of its own; `closedFolds` + `onFold` let the host hold
|
|
943
943
|
which bands are closed. A folded band's rows stay mounted.
|
|
944
|
+
- **A band's title is a heading since 7.2.0** (WAI-ARIA accordion pattern):
|
|
945
|
+
`SettingsGroup` draws `<h3 class="es-group-title"><button aria-expanded
|
|
946
|
+
aria-controls>…</button></h3>`. `headingLevel` (default 3) sets the bands'
|
|
947
|
+
level; a group inside a band draws one under it. `SettingsGroup` takes
|
|
948
|
+
`level` too. A band's DOM id is built from a safe form of its key (any
|
|
949
|
+
character but letters, digits, `-` and `_` becomes `-u<hex>-`, so `" text"`
|
|
950
|
+
is `<prefix>-fold--u20-text`); the key itself is unchanged for
|
|
951
|
+
`closedFolds`, `onFold` and `data-fold`.
|
|
944
952
|
- **`planFields().rows` holds `slot` rows.** They draw nothing and are there so
|
|
945
953
|
the slot's name has a bucket. Filter `row.field.type !== 'slot'` before
|
|
946
954
|
drawing or counting rows of your own.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useSectionOps as o}from"./chunk-2QUWI67X.js";import{decodePartId as e,encodePartId as r}from"./chunk-IYT6NN2J.js";import{usePreviewParts as t}from"./chunk-I54UCYOU.js";import{SELECTION_MODE as n}from"./chunk-E3PD66A3.js";import{useEasel as p}from"./chunk-KYG35KKJ.js";import{useCallback as d,useEffect as c}from"react";var s=o=>"part"===o.kind;function m({mode:m,setMode:i,onOpenPart:I}){const{getSelectorForId:a}=p(o=>o),u=o(),{setSelectedPartId:f,setSelectHandler:k}=t(),l=d(o=>{const r=e(o);if(!r)return;const{nodeId:t,propKey:p}=r;p?(i(o=>s(o)&&o.nodeId===t&&o.propKey===p?o:{kind:"part",nodeId:t,propKey:p}),I?.(t)):i(o=>"part"===o.kind?n:o)},[i,I]);c(()=>{k(l)},[k,l]);const K=s(m)?r(m.nodeId,m.propKey):null;c(()=>{f(K)},[K,f]);return{selectNode:d(o=>{i(()=>n);const e=a(o);e&&u.select(e)},[i,a,u]),openPartId:K}}export{m as usePartBridge};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useScreenBlockRules as e}from"./chunk-
|
|
1
|
+
import{useScreenBlockRules as e}from"./chunk-E3PD66A3.js";import{newNodeId as t,ROOT_ZONE as n}from"./chunk-PLVEGYK6.js";import{useEasel as o,useEaselApi as r}from"./chunk-KYG35KKJ.js";import{useMemo as s}from"react";function i(i={}){const{dispatch:p}=o(e=>e),d=r(),c=!0===i.readOnly,a=e().resolveOnInsert,l=!0===(i.resolveOnInsert??a),m=!0===i.foldIntoHistory;return s(()=>{const e=m?e=>p({...e,recordHistory:!1}):p,o=(n,o,r)=>{const s=t(o);return c||e({type:"insert",componentType:o,destinationZone:n,destinationIndex:r,id:s}),s},r=e=>(l&&!c&&d.resolveNode(e,{trigger:"insert"}),e),s=(t,n,o)=>{c||e({type:"replace",destinationZone:t,destinationIndex:n,data:o})},i=(e,t,n)=>r(o(e,t,n));return{insertComponent:i,insertSection:(e,t)=>i(n,e,t),replaceComponent:s,seedChild:(e,t,n,i)=>{const p=o(e,n,t);s(e,t,{type:n,props:{id:p,...i}}),r(p)},insertNode:(e,t,n)=>{const i=o(e,n.type,t);return s(e,t,{type:n.type,props:{...n.props,id:i}}),r(i)},removeComponent:(t,n)=>{c||e({type:"remove",index:n,zone:t})},reorderComponent:(t,n,o)=>{c||e({type:"reorder",sourceIndex:n,destinationIndex:o,destinationZone:t})},duplicateComponent:(t,n)=>{c||e({type:"duplicate",sourceIndex:n,sourceZone:t})},select:e=>p({type:"setUi",ui:{itemSelector:e}}),setDocument:t=>{c||e({type:"setData",data:t})},commitDocument:(t,n)=>{c||(m?d.batch(()=>{e({type:"setData",data:t}),void 0!==n&&("slot"===n?.kind?d.selectSlot({parentId:n.parentId,slot:n.slot}):d.select(n?n.id:null))}):d.run({data:t,select:n}))}}},[p,c,l,d,m])}export{i as useSectionOps};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{clientOnly as n}from"./chunk-GXQCZJOP.js";import{ScreenStoreProvider as r}from"./chunk-
|
|
1
|
+
import{clientOnly as n}from"./chunk-GXQCZJOP.js";import{ScreenStoreProvider as r}from"./chunk-BSZ54Q2T.js";import{ScreenChrome as e}from"./chunk-G24HQEX4.js";import{ScreenDocumentProvider as i,useScreenDocument as a}from"./chunk-64ZRPAWS.js";import{DEFAULT_SCREEN_WORDS as s}from"./chunk-5F3PKNT7.js";import{documentPermissions as o}from"./chunk-THWO5YVZ.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{useMemo as t}from"react";import{Dialog as d,Button as l}from"efficient-shell/ui";import{jsx as m,jsxs as g,Fragment as h}from"react/jsx-runtime";var f=n(r),v=n(e);function p({saving:n,onCancel:r,onDiscard:e,onSave:i}){const a=c("screen",s).leave;/* @__PURE__ */
|
|
2
2
|
return m(d,{open:!0,role:"alertdialog",size:"sm",title:a.title,onClose:r,footer:/* @__PURE__ */g(h,{children:[
|
|
3
3
|
/* @__PURE__ */m(l,{variant:"secondary",onClick:r,children:a.cancel}),
|
|
4
4
|
/* @__PURE__ */m(l,{variant:"ghost-danger",onClick:e,children:a.discard}),
|
|
5
5
|
/* @__PURE__ */m(l,{variant:"primary",loading:n,onClick:i,children:n?a.saving:a.save})]}),children:a.body})}function u({target:n,addressing:r,onHostMessage:e,children:a}){/* @__PURE__ */
|
|
6
|
-
return m(i,{target:n,addressing:r,onHostMessage:e,children:a})}var k=(n,r)=>/* @__PURE__ */g(h,{children:[n,r]});function C({config:n,parts:r,wrap:e=k}){const{data:i,error:d,redirecting:l,ready:g,saveStatus:h,readOnly:u,onChange:C,pendingNav:N,cancelPendingNav:j,discardAndNavigate:y,saveAndNavigate:
|
|
7
|
-
/* @__PURE__ */m(f,{config:n,data:i,onChange:C,permissions:
|
|
6
|
+
return m(i,{target:n,addressing:r,onHostMessage:e,children:a})}var k=(n,r)=>/* @__PURE__ */g(h,{children:[n,r]});function C({config:n,parts:r,wrap:e=k}){const{data:i,error:d,redirecting:l,ready:g,saveStatus:h,readOnly:u,onChange:C,pendingNav:N,cancelPendingNav:j,discardAndNavigate:y,saveAndNavigate:H}=a(),S=t(()=>o(!u),[u]),A=c("screen",s);return l?/* @__PURE__ */m("div",{className:"sf-msg",children:A.loading}):d?/* @__PURE__ */m("div",{className:"sf-msg sf-msg--error",children:d}):g?i?e(
|
|
7
|
+
/* @__PURE__ */m(f,{config:n,data:i,onChange:C,permissions:S,parts:r,children:/* @__PURE__ */m(v,{})}),N&&/* @__PURE__ */m(p,{saving:"saving"===h,onCancel:j,onDiscard:y,onSave:()=>{H()}})):/* @__PURE__ */m("div",{className:"sf-msg",children:A.loading}):/* @__PURE__ */m("div",{className:"sf-msg",children:A.waitingForAuthorization})}export{C as DocumentScreen,u as ScreenMount};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ScreenPartsProvider as t}from"./chunk-
|
|
1
|
+
import{ScreenPartsProvider as t}from"./chunk-E3PD66A3.js";import{useEaselHost as r}from"./chunk-U3JP4VGF.js";import{createEasel as e,EaselProvider as n}from"./chunk-KYG35KKJ.js";import{useState as o,useEffect as s}from"react";import{jsx as i}from"react/jsx-runtime";function a({config:a,data:c,onChange:m,permissions:p,parts:f,children:u}){const[h]=o(()=>e({config:a,data:c,permissions:p}));s(()=>{h.setConfig(a)},[h,a]),s(()=>{if(!m)return;let t=h.getState().appState.data;return h.subscribe(()=>{const r=h.getState().appState.data;r!==t&&(t=r,m(r))})},[h,m]),s(()=>{p&&h.setPermissions(p)},[h,p]);const d=r();/* @__PURE__ */
|
|
2
2
|
return i(n,{easel:h,hotkeys:d.ownsDocument,children:/* @__PURE__ */i(t,{parts:f,children:u})})}export{a as ScreenStoreProvider};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{useScreenOwnerName as e}from"./chunk-
|
|
1
|
+
import{useScreenOwnerName as e}from"./chunk-E3PD66A3.js";import{settlePanelPick as n}from"./chunk-R6WTQWAC.js";import{MediaPanelHead as i,mediaPickKind as c}from"./chunk-UB4TLWVJ.js";import{jsxs as o,Fragment as r,jsx as t}from"react/jsx-runtime";function l({panel:l,pick:d,onHide:m}){const p=e();/* @__PURE__ */
|
|
2
2
|
return o(r,{children:[
|
|
3
3
|
/* @__PURE__ */t(i,{context:p,pick:d?{kind:c(d.accept),field:d.title||void 0}:null,onCancel:()=>d&&n(d.requestId,null),onHide:m}),
|
|
4
4
|
/* @__PURE__ */t("div",{className:"sf-media-panel",children:/* @__PURE__ */t(l,{pick:d,onPick:e=>d&&n(d.requestId,e)})})]})}export{l as MediaSidePanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEaselHost as n}from"./chunk-U3JP4VGF.js";import{useEaselApi as o,bindUndoKeys as t}from"./chunk-
|
|
1
|
+
import{useEaselHost as n}from"./chunk-U3JP4VGF.js";import{useEaselApi as o,bindUndoKeys as t}from"./chunk-KYG35KKJ.js";import{useState as e,useEffect as u}from"react";function r(o){const t=n(),[r,c]=e(null);return u(()=>c(o.current),[o]),t.ownsDocument?"undefined"==typeof document?null:document:r}function c(e,c){const m=n(),i=o(),f=r(e);u(()=>{if(!m.ownsDocument&&f)return t(f,i,{leaveTyping:!0})},[m,i,f]);const s=c?.document??null;u(()=>{if(!m.ownsDocument&&s)return t(s,i,{leaveTyping:!0})},[m,i,s])}function m(n){return n.ownsDocument?{}:{tabIndex:-1}}export{m as editorRootFocus,r as useEaselKeyTarget,c as useEaselUndoKeys};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{slotFieldsOf as n}from"./chunk-PLVEGYK6.js";import{usePickFollowsSelection as e}from"./chunk-R6WTQWAC.js";import{EaselCanvas as t,useSelectedFields as r}from"./chunk-KYG35KKJ.js";import{Inspector as i}from"./chunk-PEDDDWSG.js";import{createContext as o,useContext as u}from"react";import{DesktopIcon as l}from"efficient-shell/icons/efficient";import{jsx as s}from"react/jsx-runtime";var c={kind:"puck"};function f(n,e){const t=n,r=e,i=Object.keys(t);return i.length===Object.keys(r).length&&i.every(n=>Object.is(t[n],r[n]))}function a(n){const e=n;return"string"==typeof e.nodeId&&"string"==typeof e.slot}function d(e,t,r){const i=e.slotsOf?.(r);return i||n(t,r.type).map(n=>({slot:n,label:n,rung:!1}))}function p(n,e){return n.isFirst?n.isFirst(e):e.type===n.first}function m(n,e){return n.isLast?n.isLast(e):e.type===n.last}var k={},h={},v=()=>k,g=()=>"",y=()=>null,b=()=>{},O={isLockedBlock:()=>!1,duplicateBlocked:()=>null,nestDepth:()=>0,newSectionNode:()=>null,canAddTo:()=>null,blockIsOffered:()=>!0},j={labelAtLevel:(n,e,t)=>t,descriptions:{},categoryLabel:()=>{},firstSection:null,blockRowName:(n,e)=>e(n.type),plainText:n=>n,Icon:()=>null,Thumbnail:()=>null,useProducts:()=>null},w={options:[{id:"desktop",label:"Desktop",icon:/* @__PURE__ */s(l,{})}],initial:"desktop",fluid:"desktop",widths:{desktop:2e3}},D={read:()=>"sections",write:()=>{},forSelection:(n,e)=>n?"sections":e},L={first:null,last:null,firstGroup:null,lastGroup:null,isSectionGroup:()=>!1,sectionGroupZone:()=>"",panelOf:()=>null};function S(){/* @__PURE__ */
|
|
2
|
+
return s(t,{height:"fill"})}function G(){const{id:n,fields:e,values:t,readOnly:o,onChange:u}=r();/* @__PURE__ */
|
|
3
|
+
return s("div",{className:"es-sidepanel es-sidepanel--right",children:/* @__PURE__ */s(i,{fields:e,values:t,onChange:u,readOnly:o,idPrefix:n})})}var P=o({});function C({parts:n,children:e}){/* @__PURE__ */
|
|
4
|
+
return s(P.Provider,{value:n,children:e})}function K(){return u(P)}function N(){return(K().useOwnerName??g)()}function x(){return(K().useDocumentLabel??y)()}function B(n,e,t,r){return(K().useBridges??v)(n,e,t,r)}function I(n){return(K().useStandaloneBridges??v)(n)}function T(n,e){(K().useDocumentPass??b)(n,e)}function A(){return K().blockRules??O}function F(){return K().blockLook??j}function R(){return K().devices??w}function W(){return K().leftView??D}function E(){return K().pinned??L}function V(){return K().saveSwitch??!0}function Y(n){e(!0===K().pickFollowsSelection,n)}function H(){return K().add??h}function J(){return K().storageNamespace||void 0}function Q(){return K().styleClipboard??null}function Z(){return K().nodeKeys??!0}function q(){return K().notify??null}function z(){return K().Canvas??S}function M(){return K().CanvasHead??null}function U(){return K().canvasDrag??null}var X=o(null);function $({target:n,children:e}){/* @__PURE__ */
|
|
5
|
+
return s(X.Provider,{value:n,children:e})}function _(){return u(X)}function nn(){return K().Inspector??G}export{c as SELECTION_MODE,$ as ScreenCanvasTargetProvider,C as ScreenPartsProvider,p as isPinnedFirst,m as isPinnedLast,a as isSlotMode,f as sameInspectorMode,d as screenSlotsOf,H as useScreenAdd,F as useScreenBlockLook,A as useScreenBlockRules,B as useScreenBridges,U as useScreenCanvasDrag,z as useScreenCanvasFrame,M as useScreenCanvasHead,_ as useScreenCanvasTarget,R as useScreenDevices,x as useScreenDocumentLabel,T as useScreenDocumentPass,nn as useScreenInspectorPanel,W as useScreenLeftView,Z as useScreenNodeKeys,q as useScreenNotify,N as useScreenOwnerName,K as useScreenParts,Y as useScreenPickFollowsSelection,E as useScreenPinned,V as useScreenSaveSwitch,J as useScreenStorageNamespace,Q as useScreenStyleClipboard,I as useStandaloneScreenBridges};
|
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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-DOHYKMMH.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-2LBXIYF7.js";import{useSectionOps as x}from"./chunk-2QUWI67X.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 $}from"./chunk-LIH5SH6S.js";import{SidePanelHead as P,PanelShowStrip as T}from"./chunk-PFNIVZPN.js";import{MediaSidePanel as A}from"./chunk-COCSEEXP.js";import{useScreenSaveSwitch as M,useScreenNodeKeys as j,useScreenPinned as E,useScreenDocumentLabel as R,useScreenCanvasFrame as L,useScreenInspectorPanel as V,useScreenDevices as H,useScreenPickFollowsSelection as F,useScreenLeftView as W,useScreenAdd as D,SELECTION_MODE as U,sameInspectorMode as G,useScreenBridges as Y,useScreenBlockRules as J,useScreenBlockLook as X,useScreenStorageNamespace as K,useScreenNotify as _,useScreenCanvasHead as Q,isSlotMode as q,useScreenStyleClipboard as Z,useScreenDocumentPass as ee,useScreenCanvasDrag as ne,ScreenCanvasTargetProvider as te,isPinnedFirst as oe,isPinnedLast as re,screenSlotsOf as ie}from"./chunk-E3PD66A3.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-KYG35KKJ.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 $e}from"./chunk-WK3AFPXY.js";import{toItemSelector as Pe,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 He,EaselIconButton as Fe,TopBarDivider as We,DeviceSwitch as De,InspectorIconButton as Ue,PanelResizeHandle as Ge,MAX_PANEL_W as Ye,MIN_PANEL_W as Je,panelWidthVars as Xe,SaveState as Ke,SaveStateToggle as _e}from"./chunk-UB4TLWVJ.js";import{DEFAULT_CHROME_WORDS as Qe}from"./chunk-Y2G7CU6A.js";import{useWords as qe}from"./chunk-MFIRYGHW.js";import{insertSeams as Ze,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 En({saveState:e,notSaving:n,readOnlyReason:t,toggle:o,onToggle:r,onRetry:i,words:l,saveWords:s}){if(null!==t)/* @__PURE__ */return An(Ke,{tone:"off",label:t,role:"status"});if(n)/* @__PURE__ */
|
|
2
2
|
return An(Ke,{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(_e,{pressed:e.paused,onToggle:r,title:e.paused?l.autoSaveOff:l.autoSaveOn,children:/* @__PURE__ */An(Ke,{tone:d,label:c})}),a]}:{children:[
|
|
@@ -8,55 +8,55 @@ return An("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"
|
|
|
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
|
|
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(!Xt)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}}))},[Xt]),vn(()=>{!Rt&&Xt&&(po.current=!1,Kt())},[Rt]),vn(()=>{if(!Xt||!lo)return;const e=e=>{"Escape"===e.key&&Kt()};return lo.addEventListener("keydown",e),()=>lo.removeEventListener("keydown",e)},[Xt,lo]),ke(null!==Xt,()=>Kt());const mr=_(),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=
|
|
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(
|
|
14
|
-
return An(Oe,{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})})},
|
|
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 Hn="__rungs";var Fn="screen:band",Wn={duplicate:!0,delete:!0};function Dn(){const Re=ye(),{target:Ke,docId:_e,capabilities:dn,currentSlug:Dn,siteId:Un,onPublish:Gn,saveState:Yn,saveConflict:Jn,retrySave:Xn,toggleAutoSave:Kn,readOnly:_n,readOnlyReason:Qn=null}=B(),qn=M(),Zn=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=qe("screen",ve),wt=qe("tree",Ne),bt=qe("drag",tn),zt=qe("save",Ee),Bt=qe("menu",$e),Ct=qe("styleClipboard",Se),Ot=qe("chrome",Qe),It=R()??`/${Dn}`,Nt=L(),$t=V(),Pt=x({readOnly:_n}),Tt=x({readOnly:_n,foldIntoHistory:!0}),At=yn(null),Mt=we(),jt=kn(()=>({...Pt,select:e=>{At.current=e,Pt.select(e)},commitDocument:(e,n)=>{if(void 0!==n){const t=Mt.config;At.current=Pe(e,t,n)}Pt.commitDocument(e,n)}}),[Pt,Mt]),Et=ot.ui,Rt=Et.leftSideBarVisible,Lt=Et.rightSideBarVisible,{options:Vt,widths:Ht,initial:Ft,fluid:Wt,fit:Dt}=H(),[Ut,Gt]=Sn(Ft),Yt=he(),Jt=et&&null!==Yt,Xt=me(),Kt=ge();F(lt?.props.id);const{read:_t,write:Qt,forSelection:qt}=W(),[Zt,eo]=Sn(_t);vn(()=>{Qt(Zt)},[Zt]);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=>qt(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?qr(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=Y(Mo,{data:ot.data,selected:lt??null,zoneOf:e=>st(e)?.zone,readOnly:Boolean(_n),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:()=>{Rt||rt({type:"setUi",ui:{leftSideBarVisible:!0}})}}),Eo=jo.pinnedSource??!1,Ro=jo.resolveLeftView?jo.resolveLeftView(Zt,Jt):"media"===Zt&&Jt?Zt:"sections",Lo=J(),{isLockedBlock:Vo,duplicateBlocked:Ho,nestDepth:Fo,newSectionNode:Wo,canAddTo:Do,blockIsOffered:Uo}=Lo,Go=X(),{labelAtLevel:Yo,Icon:Jo,useProducts:Xo}=Go,Ko=Go.rowName?(e,n,t)=>Go.rowName(e,n,t):void 0,_o=xn(e=>{rt({type:"setUi",ui:{rightSideBarVisible:!0}}),a(e),No(e,{scroll:!0})},[rt,No]),{selectNode:Qo,openPartId:qo}=v({mode:ko,setMode:So,onOpenPart:_o}),[Zo,er]=Sn(null);ke(null!==Zo,()=>er(null));const nr=y(K()),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(!Xt)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}}))},[Xt]),vn(()=>{!Rt&&Xt&&(po.current=!1,Kt())},[Rt]),vn(()=>{if(!Xt||!lo)return;const e=e=>{"Escape"===e.key&&Kt()};return lo.addEventListener("keydown",e),()=>lo.removeEventListener("keydown",e)},[Xt,lo]),ke(null!==Xt,()=>Kt());const mr=_(),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=Q(),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=Ut===Wt?kr>0?kr:Ht[Wt]:Ht[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:!Rt}}),Tr=()=>rt({type:"setUi",ui:{rightSideBarVisible:!Lt}}),Ar=e=>{so&&(co(!1),fo(null),ao.current=!1,Rt&&Zt===e)||Xt&&(po.current=!1,Kt(),Rt&&Zt===e)||(Rt&&Zt===e?Pr():(eo(e),Rt||rt({type:"setUi",ui:{leftSideBarVisible:!0}})))},Mr=()=>{C(Re,{accept:"image/*",title:Ot.mediaLibrary})},jr=()=>{So(U),jt.select(null),u()},Er=()=>{So(gt??U),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,Hr=Lo.stripCopy,Fr=e=>i(e,Hr),Wr=w(),Dr=Te({data:ot.data,config:Vr,readOnly:Boolean(_n),clipboard:Wr,strip:Hr?e=>Hr(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?Kr(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},Yr=e=>Yo(e,"block",dt.components[e]?.label??e),Jr=xn(e=>dt.components[e]?.defaultProps??{},[dt]),Xr=e=>Yo(e,"section",Yr(e)),Kr=e=>l({type:e.type,props:e.props??{}},Xr(e.type),Ko),{nodeAddresses:_r,zoneItems:Qr}=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]),qr=xn(e=>Qr.get(e)??[],[Qr]),Zr=e=>{const n=_r.get(e);return n?qr(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=Zr(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(!q(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||!q(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=_r.get(e);n&&(n.zone===le?zi(n.index):el(n.zone,n.index,e,Zr(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(_n||!Lo.moveSlot)return;const o=Zr(e),r=o?ei(o).filter(e=>e.rung):[],i=r[n];if(!i)return;const l={parentId:e,slot:Hn,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=Xo(),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,Yr,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(!(!_n&&Zo?.zone===e&&Zo.index===n))return;const r=(t,o)=>{er(null),o&&((e,n,t)=>{const o=qr(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(Z(),Ct),fi=ui.scope({target:Ke,siteId:Un,docId:_e}),hi=dt,mi=(e,n)=>n===le?Xr(e):Yr(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:qr,nodeAt:(e,n)=>qr(e)[n]??null,labelOf:(e,n)=>n===le?Xr(e):Yr(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(_n),collapseAll:()=>ir(new Set(qr(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=>Ho(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=>_r.get(e)??null,rowNameOf:(e,n)=>n===le?Kr(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:Zn?{target:lo,selected:()=>{const e=ot.ui.itemSelector;return e?{zone:e.zone??le,index:e.index}:null},held:()=>Wr.get(),readOnly:Boolean(_n),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=qr(n)[e.index];return t?{zone:n,index:e.index,node:t}:null},readOnly:Boolean(_n)}});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,Ut,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(U),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(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=Wo(e,{nodeDefaults:Jr,newNodeId:fe,sectionLabel:Xr,blockIsOffered:Uo}),r=o?jt.insertNode(le,t,o):jt.insertSection(e,t);return Oi(t,r,Xr(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,Xt&&(ao.current=po.current,po.current=!1,Kt()),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,Fr(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",Yr(e.type)):Kr(e):ci(e):n?Xr(e.type):Yr(e.type),ji=e=>n=>{e()},Ei=()=>jo.editPinnedSource?.(),Ri=(e,n,t)=>{if(_n)return null;const o=qr(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=qr(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,Hi=(e,n,t)=>Go.rowActions?.(e,n,t)??null,Fi=(e,n,t,o)=>{if(_n)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:()=>Di(e,n,t),children:/* @__PURE__ */An(r?$n:Pn,{size:14,strokeWidth:1.8,strokeLinecap:void 0,strokeLinejoin:void 0})})},Wi=e=>{const n=Xr(Rr[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),Yi=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)}],Ji=e=>Lo.slotsOf?Yi(e).flatMap(e=>e.kids):Gi(e),Xi=e=>Boolean(Lo.slotsOf)&&ei(e).some(e=>e.rung),Ki=(e,n,t)=>null===t?void 0===n?Do(e):Do(e,n):Do(e,n,t),_i=(e,n,t)=>{const o=ue(dt,e.type,n)&&(t||Ji(e).length>0||Xi(e));return{collapsible:o,folded:o&&pr(String(e.props.id))}},Qi=(e,n,t)=>Yi(e).flatMap(o=>{const r=o.rung?n+1:n,i=o.kids.flatMap(({child:e})=>_i(e,r,t(e.type)).collapsible?[String(e.props.id),...Qi(e,r+1,t)]:[]);return o.rung?[`${e.props.id}:${o.rung.slot}`,...i]:i}),qi=e=>Ji(e).length>0||Xi(e)||Boolean(Do(e.type)),Zi=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(()=>{Rr.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(Jr)).forEach((e,t)=>Tt.seedChild(o,t,n.childType,e))})},[Rr,Tt,Jr]);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,Ui(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)||(qi(e)&&ul.push(String(e.props.id)),ul.push(...Qi(e,1,Zi)))}),ll&&(ul.push(String(ll.props.id)),ul.push(...Qi(ll,1,Zi)));const fl=ul.length>0&&ul.every(e=>rr.has(e)),hl=e=>{const n=Go.blockRowName(e,Yr);return Go.rowName?Go.rowName(e,"block",n):n},ml=(e,n,t,o)=>{const r=qr(e)[t];if(!r)return;const i={...hn(e),index:t},l={...hn(n),index:Math.min(Math.max(o,0),qr(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=_r.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=Zr(e.rung.nodeId),o=t?ei(t).filter(e=>e.rung).length:0;return n.parentId===e.rung.nodeId&&n.slot===Hn&&n.index>=0&&n.index<=o}if(n.slot===Hn)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<=qr(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>qr(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??qr(e)[t];if(!r)return!1;const i=n.split(":")[0],l=_r.get(i),s=l?qr(l.zone)[l.index]:void 0;if(!s)return!1;if(!o&&gl(r).has(n))return!1;const d=Do(s.type,Fo(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?.(qr(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=_r.get(n),o=t?qr(t.zone)[t.index]:void 0;if(!t||!o)return null;const r=Do(o.type,Fo(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:Yr(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<=qr(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?.(qr(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,Fr(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(_n),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=Xr(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=qr(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?Xr(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?[]:Ze(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(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,El=$l?.canDrop,Rl=El?(e,n)=>El(e,n,Sl,Pl()):Sl,Ll=$l?.drop,Vl=Ll?(e,n)=>Ll(e,n,bl,Pl()):bl,Hl=$l?.pick,Fl=Hl?e=>Hl(e,Nl,Pl()):Nl,Wl=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(Ie,{..._n?{}:Bl.seam({place:{...hn(e),index:n}}),onAdd:_n?void 0:t,label:o},`seam:${e}:${n}`),Ul={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=qr(o),i=pr(n),l=Yr(e.type),s=Go.rowName?Go.rowName(e,"section",l):l,d=e=>Dl(o,e,()=>Pi(o,e),xt.addSectionHere);/* @__PURE__ */
|
|
15
15
|
return Mn(jn,{children:[
|
|
16
|
-
/* @__PURE__ */An(be,{words:wt,icon:/* @__PURE__ */An(
|
|
16
|
+
/* @__PURE__ */An(be,{words:wt,icon:/* @__PURE__ */An(Jo,{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:Hi(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=Kr(n),l=qi(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(be,{words:wt,icon:/* @__PURE__ */An(
|
|
18
|
+
/* @__PURE__ */An(be,{words:wt,icon:/* @__PURE__ */An(Jo,{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),Hi(n,o,t),Fi(o,t,n,i)]}),rowProps:a}),l&&!s&&/* @__PURE__ */An(ze,{children:Xl(n,2)})]},r)}),d(r.length)]})]})},Yl=(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}:${Hn}`,index:t,type:e.type,rung:{nodeId:i,slot:n.slot}},place:{parentId:i,slot:Hn,index:t},into:a,canDrag:Boolean(Lo.moveSlot)&&!1!==n.movable&&o>1},{"data-slot-zone":l,onClick:ji(p)}),h=_n?null:Lo.slotActions?.(e,n.slot);/* @__PURE__ */
|
|
19
19
|
return Mn(bn,{children:[n.heading,
|
|
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(_n||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)},
|
|
21
|
-
return An(jn,{children:t.map(t=>{const i=t.kids,l=t.rung?n+1:n,s=Ki(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}=_i(n,l,
|
|
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(_n||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)},Jl=(e,n)=>{const t=Yi(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=Ki(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}=_i(n,l,Zi(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(be,{words:wt,icon:/* @__PURE__ */An(
|
|
24
|
-
return An(jn,{children:o.map(o=>{const l=o.kids,s=o.rung?n+1:n,d=Ki(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}=_i(n,s,
|
|
23
|
+
/* @__PURE__ */An(be,{words:wt,icon:/* @__PURE__ */An(Jo,{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),Hi(n,t,o),Fi(t,o,n,c)]}),rowProps:u}),i&&!s&&/* @__PURE__ */An(ze,{children:Jl(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?Yl(e,t.rung,r++,o,u):/* @__PURE__ */An(bn,{children:u},t.slot??"")})})},Xl=(e,n)=>{const t=Fo(ot?.data,e.type,String(e.props.id)),o=Yi(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=Ki(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}=_i(n,s,Zi(n.type)),a=Ui(n.type),p=1===a.length?`${l}:${a[0]}`:null,u=p?{...hn(p),index:qr(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(be,{words:wt,icon:/* @__PURE__ */An(
|
|
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?
|
|
28
|
-
return Mn(bn,{children:[n>0&&
|
|
29
|
-
/* @__PURE__ */An(be,{words:wt,icon:/* @__PURE__ */An(
|
|
26
|
+
/* @__PURE__ */An(be,{words:wt,icon:/* @__PURE__ */An(Jo,{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)?Hi(n,t,o)??void 0:/* @__PURE__ */Mn(jn,{children:[Ri(t,o,i),Hi(n,t,o),Fi(t,o,n,i)]}),rowProps:y}),d&&!c&&/* @__PURE__ */An(ze,{children:Xl(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?Yl(e,o.rung,i++,r,k):/* @__PURE__ */An(bn,{children:k},o.slot??"")})})},Kl=(()=>{if(!lt||!vo)return null;const e=String(lt.type),n=String(lt.props.id),t=Do(e,Fo(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:Yr(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)}}})(),_l=bo&&bo.zone!==le&&!kl(bo.zone)?bo.zone:null,Ql=!0===ho.blocksFirst,ql=_l?xl(_l):Ql&&bo?null:Kl,Zl=Boolean(uo&&_l)||Ql&&Boolean(ql&&ql.choices.length>0),es=so||null!==Xt,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():$i(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)];Jt?ts.push({id:"media",label:xt.railMedia,icon:/* @__PURE__ */An(je,{}),active:Rt&&!so&&(null!==Xt||"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(Fn),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=qi(e)||i,s=l&&pr(r),d=Ui(e.type),c=1===d.length?`${r}:${d[0]}`:null,a=c?{...hn(c),index:qr(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(Jo,{type:e.type,size:13}),name:Kr(e),preview:Li(e),marks:Vi(e),onSelect:()=>zi(n),nameSlot:pi(le,n,r,Kr(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,Kr(e)),Hi(e,le,n),Fi(le,n,e,Kr(e))]}),rowProps:f}),qi(e)&&!s&&/* @__PURE__ */Mn(ze,{children:[Xl(e,1),jo.partRows?.(e,Ul)]}),i&&!s&&/* @__PURE__ */An(ze,{children:jo.ownRows?.(e,n,Ul)})]},String(e.props.id??n))}),!Eo&&pl>0&&Wi(pl),vt?.addAtEnd&&!Eo&&!_n&&/* @__PURE__ */An(N,{small:!0,label:xt.addSection,blocked:null,onAdd:()=>$i(pl)})]}),ds=(e,n,t)=>{const o=String(e.props.id),r=Ji(e).length>0||Xi(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__ */
|
|
30
30
|
return Mn(jn,{children:[
|
|
31
|
-
/* @__PURE__ */An(be,{words:wt,icon:/* @__PURE__ */An(
|
|
31
|
+
/* @__PURE__ */An(be,{words:wt,icon:/* @__PURE__ */An(Jo,{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:Hi(e,le,n)??void 0,rowProps:{"data-node-id":o,onClick:ji(()=>zi(n))}}),r&&!i&&/* @__PURE__ */An(ze,{children:Jl(e,1)})]})};return(jo.wrap??(e=>e))(
|
|
32
32
|
/* @__PURE__ */An(te,{target:io,children:/* @__PURE__ */Mn("div",{ref:ro,className:"sf-editor es-editor",style:Xe(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
|
-
/* @__PURE__ */Mn(
|
|
35
|
+
/* @__PURE__ */Mn(He,{children:[
|
|
36
36
|
/* @__PURE__ */An(Fe,{label:xt.bar.undo,disabled:Boolean(_n)||!it.hasPast,onClick:()=>it.back(),children:/* @__PURE__ */An(On,{})}),
|
|
37
37
|
/* @__PURE__ */An(Fe,{label:xt.bar.redo,disabled:Boolean(_n)||!it.hasFuture,onClick:()=>it.forward(),children:/* @__PURE__ */An(In,{})}),
|
|
38
|
-
/* @__PURE__ */An(
|
|
39
|
-
/* @__PURE__ */An(De,{devices:Vt,value:Ut,onChange:
|
|
40
|
-
/* @__PURE__ */Mn(
|
|
41
|
-
/* @__PURE__ */An(En,{saveState:
|
|
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!==
|
|
38
|
+
/* @__PURE__ */An(We,{}),
|
|
39
|
+
/* @__PURE__ */An(De,{devices:Vt,value:Ut,onChange:Gt})]}),
|
|
40
|
+
/* @__PURE__ */Mn(He,{kind:"right",style:{minWidth:300},children:[
|
|
41
|
+
/* @__PURE__ */An(En,{saveState:Yn,notSaving:Boolean(_n)||null!=Jn,readOnlyReason:Qn,toggle:qn,onToggle:Kn,onRetry:Xn,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!==Qn,onClick:()=>{Gn(ot.data)},children:xt.done})]})]}),
|
|
43
43
|
/* @__PURE__ */An(z,{}),
|
|
44
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($,{blocks:ql,blocksOnly:
|
|
46
|
-
/* @__PURE__ */An(A,{panel:
|
|
45
|
+
/* @__PURE__ */An("aside",{className:"es-sidepanel es-sidepanel--left sf-panel sf-panel--left","aria-label":xt.leftPanel,children:so?/* @__PURE__ */An($,{blocks:ql,blocksOnly:Zl,at:uo?{label:(e=>{const n=kl(e.zone);if(n)return xt.add.addingTo({name:Go.rowName?Mi(n,!0):Yr(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,Fr(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)}Kl?.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(_n)}):Xt&&Yt?
|
|
46
|
+
/* @__PURE__ */An(A,{panel:Yt,pick:Xt,onHide:Pr}):os?os.panel({onHide:Pr,notify:gr}):"media"===Ro&&Yt?/* @__PURE__ */An(A,{panel:Yt,pick:null,onHide:Pr}):/* @__PURE__ */Mn(jn,{children:[
|
|
47
47
|
/* @__PURE__ */An(P,{icon:/* @__PURE__ */An(Me,{}),title:xt.layers,context:It,actions:
|
|
48
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(Rn,{expand:fl})}),onHide:Pr}),
|
|
49
49
|
/* @__PURE__ */Mn(Be,{className:"sf-tree sf-scroll",words:wt,children:[
|
|
50
|
-
/* @__PURE__ */An(be,{words:wt,icon:/* @__PURE__ */An(
|
|
51
|
-
/* @__PURE__ */An(Ce,{children:xt.header}),
|
|
52
|
-
/* @__PURE__ */An(Ce,{children:xt.header}),!St&&/* @__PURE__ */An(be,{words:wt,icon:/* @__PURE__ */An(
|
|
53
|
-
/* @__PURE__ */An(be,{words:wt,icon:null,name:is,fold:{open:!ls,label:is,onToggle:()=>ur(Fn)}}),!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(
|
|
54
|
-
/* @__PURE__ */An(
|
|
50
|
+
/* @__PURE__ */An(be,{words:wt,icon:/* @__PURE__ */An(Jo,{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(Jo,{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(Fn)}}),!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(Jo,{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:Je,max:Ye,defaultWidth:k.left,label:xt.resizeLeftPanel,onResize:cr})]}):/* @__PURE__ */An(T,{side:"left",onShow:Pr}),
|
|
55
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===
|
|
56
|
+
/* @__PURE__ */An("div",{className:"sf-frame-scaler",style:Nr,children:/* @__PURE__ */An("div",{className:"sf-frame "+(Ut===Wt?"":`sf-frame--${Ut}`),style:$r,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:Rl,onDrop:Vl,choose:Il,onPick:Fl,onZoneAdd:
|
|
58
|
+
/* @__PURE__ */An(en,{canvas:io,session:zl,model:Al,measure:jl,canDrop:Rl,onDrop:Vl,choose:Il,onPick:Fl,onZoneAdd:Wl,onSeamAdd:Wl,zoneAddLabel:xt.canvasAddBlock,words:bt.canvas,readOnly:Boolean(_n),revision:ot.data}),go.length>0&&/* @__PURE__ */An("div",{className:"sf-preview-gaps",children:go.map(e=>
|
|
59
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:
|
|
61
|
-
/* @__PURE__ */An(
|
|
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:Qo,onNotify:gr,onHidePanel:Tr,nodeActions:lt?se(dt,lt.type):Wn})}),
|
|
61
|
+
/* @__PURE__ */An(Ge,{side:"right",width:lr.right,min:Je,max:Ye,defaultWidth:k.right,label:xt.resizeSettingsPanel,onResize:ar})]}):
|
|
62
62
|
/* @__PURE__ */An(T,{side:"right",onShow:Tr})]}),yi.menu]})}))}export{Dn as ScreenChrome};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{SettingsSwitch as e}from"./chunk-QLD57GBB.js";import{jsxs as l,jsx as n,Fragment as a}from"react/jsx-runtime";import{isValidElement as i,cloneElement as s}from"react";function r({title:e,open:a,onToggle:i,count:s,level:r=3,id:c,children:d,className:o}){const t=c?`${c}-body`:void 0;/* @__PURE__ */
|
|
2
|
+
return l("div",{className:o?`es-group ${o}`:"es-group",children:[
|
|
3
|
+
/* @__PURE__ */n(`h${r}`,{className:"es-group-title",children:/* @__PURE__ */l("button",{type:"button",id:c,"aria-expanded":a,"aria-controls":t,className:"es-group-head",onClick:()=>i(!a),children:[e,"number"==typeof s&&s>0?/* @__PURE__ */n("span",{className:"es-group-count",children:s}):null,
|
|
4
|
+
/* @__PURE__ */n("span",{className:"es-group-sign","aria-hidden":"true"})]})}),
|
|
5
|
+
/* @__PURE__ */n("div",{id:t,className:"es-group-body",hidden:!a,children:d})]})}function c(e){return Array.isArray(e)?e.some(c):i(e)}function d(l,n,a){if(!i(l)||l.type!==e)return l;const r=l.props;return r.ariaLabel||r.ariaLabelledBy?l:s(l,a?{ariaLabelledBy:a}:{ariaLabel:n})}function o({label:e,labelId:i,icon:s,value:r,hint:o,changed:t,htmlFor:u,action:h,children:m,className:p}){const f=c(m),N=c(h);if(!f&&!N)return null;const b=["es-field"];f||b.push("is-inline"),t&&b.push("is-changed"),p&&b.push(p);const g=/* @__PURE__ */l(a,{children:[s?/* @__PURE__ */n("span",{className:"es-field-icon","aria-hidden":"true",children:s}):null,
|
|
6
|
+
/* @__PURE__ */n("span",{className:"es-field-label",id:i,children:e})]});/* @__PURE__ */
|
|
7
|
+
return l("div",{className:b.join(" "),children:[
|
|
8
|
+
/* @__PURE__ */l("div",{className:"es-field-head",children:[u?/* @__PURE__ */n("label",{className:"es-field-name",htmlFor:u,children:g}):/* @__PURE__ */n("span",{className:"es-field-name",children:g}),null!=r?/* @__PURE__ */n("span",{className:"es-field-value",children:r}):null,N?d(h,e,i):null]}),f?/* @__PURE__ */n("div",{className:"es-field-ctl",children:m}):null,o?/* @__PURE__ */n("p",{className:"es-field-hint",children:o}):null]})}var t=Object.freeze(["Design","Animation"]),u=Object.freeze(["Content","Size","Design","Layout","Position","Anchor"]);export{u as DESIGN_GROUPS,t as SETTINGS_BUCKETS,o as SettingsField,r as SettingsGroup};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{blockRuns as e}from"./chunk-HQ4VVRIC.js";import{useScreenBlockLook as r}from"./chunk-
|
|
1
|
+
import{blockRuns as e}from"./chunk-HQ4VVRIC.js";import{useScreenBlockLook as r}from"./chunk-E3PD66A3.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,7 +1,7 @@
|
|
|
1
|
-
import{DEFAULT_CANVAS_WORDS as e}from"./chunk-TBY3DFKS.js";import{useResolvedFields as t}from"./chunk-YRLPFZW3.js";import{toItemSelector as n,fromItemSelector as o,useNodeOps as r,parentStep as i,clickPick as a}from"./chunk-SOZUYCQZ.js";import{startCanvasTyping as s,textMap as l}from"./chunk-WQASXLXS.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{setCanvasNonce as d,isTypingTarget as u,frameRectToHost as p,CANVAS_TYPING_EVENT as f}from"./chunk-AWJUYMX7.js";import{find as h,ROOT_ID as m,getList as g,remove as v,parseZoneKey as y,move as w,duplicate as k,replaceNode as b,createNode as S,insert as I,normalizeData as C,createResolveCache as E,resolveNodeData as x,ROOT_SLOT as D}from"./chunk-KRXQM65X.js";import{topLevelSlotKeys as O,fieldsFrom as A,defaultsFrom as M}from"./chunk-NKB3KVAB.js";import{createContext as P,useEffect as z,useContext as Z,useRef as B,useSyncExternalStore as K,useState as R,useMemo as $,useCallback as j,useLayoutEffect as N}from"react";import{jsx as L,jsxs as V}from"react/jsx-runtime";import{createPortal as F}from"react-dom";import{FloatingBar as Y,TextToolbar as H}from"efficient-shell/ui";function T(e){return!["setData","setUi","set"].includes(e.type)}var W=(e,t,n,o)=>{const r=g(e,t,y(n));return r?.[o]??null},X=(e,t,n,o,r)=>{const i=W(e,t,n,o);if(!i)throw new Error(`${r}: nothing at ${n}[${o}]`);return i};function U(e,t){const{selection:o}=e;return{...e.ui,itemSelector:n(e.data,t,o),selectedSlot:o&&"slot"===o.kind?{parentId:o.parentId,slot:o.slot}:null}}function q(e,t,n){return n?"node"===n.kind?h(e,t,n.id)?n:null:n.parentId===m?g(e,t,n)?n:null:h(e,t,n.parentId)&&g(e,t,n)?n:null:null}function Q(e,t,n,r=!1){const{itemSelector:i,selectedSlot:a,...s}=n;let l=e.selection;var c;return"itemSelector"in n&&(l=o(e.data,t,i??null)),"selectedSlot"in n&&(a?l=(c=a)?{kind:"slot",parentId:c.parentId,slot:c.slot}:null:"slot"===l?.kind&&(l=null)),{...e,selection:l,ui:r?s:{...e.ui,...s}}}function G(e,t,n){const o=J(e,t,n);if(o===e)return e;const r=q(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function J(e,t,n){const{data:o}=e;switch(t.type){case"setData":{const n="function"==typeof t.data?t.data(o):t.data;return{...e,data:{...o,...n}}}case"setUi":return Q(e,n,"function"==typeof t.ui?t.ui(U(e,n)):t.ui);case"set":{const r={data:o,ui:U(e,n)},i="function"==typeof t.state?t.state(r):t.state;let a=i.data?{...e,data:i.data}:e;return i.ui&&(a=Q(a,n,i.ui,!0)),a}case"insert":{const r={...y(t.destinationZone),index:t.destinationIndex},i=S(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:I(o,n,r,i)}}case"replace":{const r=X(o,n,t.destinationZone,t.destinationIndex,"replace");if(r.props.id!==t.data.props.id)throw new Error("Can't change the id during a replace action. Use remove and insert for a new node.");return{...e,data:b(o,n,r.props.id,t.data)}}case"replaceRoot":{const n={...o.root,props:{...o.root.props,...t.root.props},readOnly:t.root.readOnly};return{...e,data:{...o,root:n}}}case"duplicate":{const r=X(o,n,t.sourceZone,t.sourceIndex,"duplicate"),i=k(o,n,r.props.id),a=W(i,n,t.sourceZone,t.sourceIndex+1);return{...e,data:i,selection:a?{kind:"node",id:a.props.id}:e.selection}}case"reorder":return J(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=W(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const i={...y(t.destinationZone),index:t.destinationIndex};return{...e,data:w(o,n,r.props.id,i)}}case"remove":{const r=X(o,n,t.zone,t.index,"remove");return{...e,data:v(o,n,r.props.id)}}default:return e}}var _={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},ee={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},te=0,ne=()=>`history-${te+=1}`;function oe(e){let t=e.config;const r=e.now??(()=>Date.now()),i=e.historyCoalesceMs??250;let a=e.permissions??{};const s=C(e.data,t);let l={data:s,selection:null,ui:{...ee}};if(e.ui){const{itemSelector:n,selectedSlot:r,...i}=e.ui;l={data:s,selection:r?{kind:"slot",...r}:o(s,t,n??null),ui:{...ee,...i}}}let c=[{core:l,at:-1/0,sealed:!0,id:ne()}],d=0;const u=e=>{const t=c[d],n=r();!e&&d===c.length-1&&d>0&&!t.sealed&&n-t.at<i?c=[...c.slice(0,d),{...t,core:l,at:n}]:(c=[...c.slice(0,d+1),{core:l,at:n,sealed:e,id:ne()}],d=c.length-1)},p=/* @__PURE__ */new Set;let f=null,m=null,v=0,y=null,w=!1;const k=()=>{for(const e of[...p])e()},S=()=>{c=[...c.slice(0,d),{...c[d],core:l},...c.slice(d+1)]},I=(t,n)=>{v>0?w=w||n:(n?u(!1):l!==t&&S(),l.data!==t.data&&e.onChange?.(l.data),l!==t&&k())},D=e=>{const n=l;if(l=G(l,e,t),l===n)return;const o=e.recordHistory??T(e);I(n,o&&l.data!==n.data)},O=t=>{0===v&&(y=l,w=!1),v+=1;try{t()}catch(e){throw v-=1,0===v&&y&&(l=y,y=null),e}if(v-=1,v>0||!y)return;const n=y;y=null,w&&l.data!==n.data?u(!0):l!==n&&S(),l.data!==n.data&&e.onChange?.(l.data),l!==n&&k()},A=e=>{const n=l,o=q(l.data,t,e);var r,i;(r=o,i=l.selection,r===i||r&&i&&r.kind===i.kind&&("node"===r.kind&&"node"===i.kind?r.id===i.id:"slot"===r.kind&&"slot"===i.kind&&r.parentId===i.parentId&&r.slot===i.slot))||(l={...l,selection:o},I(n,!1))},M=t=>{const n=l;d=t,l=c[d].core,l.data!==n.data&&e.onChange?.(l.data),l!==n&&k()},P=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{..._,...a,...n}};let z=P();const Z=E(),B={resolveCache:Z,async resolveAll({trigger:e="load",metadata:n}={}){const o=l.data,r={type:"root",props:{...o.root.props??{}}},i=[...o.content,...Object.values(o.zones??{}).flat()],[a,...s]=await Promise.all([x(r,t,{cache:Z,trigger:e,metadata:n}),...i.map(o=>x(o,t,{cache:Z,trigger:e,metadata:n}))]);O(()=>{const e=l;let n=l.data;s.forEach((e,r)=>{if(!e.didChange)return;const a=i[r].props.id,s=h(n,t,a)?.node;s&&s===h(o,t,a)?.node&&(n=b(n,t,a,e.node))}),a.didChange&&n.root===o.root&&(n={...n,root:{...n.root,props:a.node.props,readOnly:a.node.readOnly??n.root.readOnly}}),n!==l.data&&(l={...l,data:n,selection:q(n,t,l.selection)},I(e,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=h(l.data,t,e)?.node;if(!r)return!1;const i=await x(r,t,{cache:Z,trigger:n,metadata:o});if(!i.didChange)return!1;let a=!1;return O(()=>{const n=l;if(h(l.data,t,e)?.node!==r)return;const o=b(l.data,t,e,i.node);o!==l.data&&(l={...l,data:o,selection:q(o,t,l.selection)},I(n,!1),a=!0)}),a},get config(){return t},getState(){if(f&&m===l)return f;const e=l,o={data:e.data,ui:U(e,t)},r="node"===e.selection?.kind?h(e.data,t,e.selection.id)?.node??null:null;return f={appState:o,selection:e.selection,selectedItem:r,config:t,dispatch:D,history:{back:()=>B.undo(),forward:()=>B.redo(),hasPast:d>0,hasFuture:d<c.length-1,histories:c.map(e=>({id:e.id,state:{data:e.core.data,ui:U(e.core,t)}})),index:d,setHistoryIndex:e=>{e>=0&&e<c.length&&e!==d&&M(e)}},getPermissions:z,getItemById:n=>h(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return g(e,t,{parentId:o,slot:r})?.[n.index]}(e.data,t,n),getSelectorForId:o=>{const r=n(e.data,t,{kind:"node",id:o});return r?{index:r.index,zone:r.zone??"root:default-zone"}:void 0}},m=e,f},subscribe:e=>(p.add(e),()=>{p.delete(e)}),dispatch:D,batch:O,group:()=>{const e=d,t=c[e].id;let n=!0;return{close:()=>{if(!n)return;if(n=!1,c[e]?.id!==t)return;if(d<=e+1)return void(d===e+1&&(c=[...c.slice(0,d),{...c[d],sealed:!0},...c.slice(d+1)]));const o=c[d];c=[...c.slice(0,e+1),{...o,sealed:!0},...c.slice(d+1)],d=e+1}}},select:e=>A(e?{kind:"node",id:e}:null),selectSlot:e=>A(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){O(()=>{const n=l,o=void 0===e.select?l.selection:e.select;l={...l,data:e.data,selection:q(e.data,t,o)},I(n,e.data!==n.data)})},load(e,n={}){const o=l,r=C(e,t);l={...l,data:r,selection:q(r,t,n.selection??l.selection)},n.keepHistory||(c=[{core:l,at:-1/0,sealed:!0,id:ne()}],d=0),l!==o&&k()},undo(){d>0&&M(d-1)},redo(){d<c.length-1&&M(d+1)},setPermissions(e){(function(e,t){if(e===t)return!0;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])})(e,a)||(a=e,z=P(),f=null,k())},setConfig(e){e!==t&&(t=e,z=P(),f=null,k())}};return B}function re(e,t,n={}){const o=e=>{if(e.altKey)return;if(!(e.metaKey!==e.ctrlKey))return;const o="KeyZ"===e.code,r="KeyY"===e.code&&!e.shiftKey;(o||r)&&(n.leaveTyping&&u(e.target)||!1!==t.getState?.().getPermissions().edit&&(e.preventDefault(),r||e.shiftKey?t.redo():t.undo()))};return e.addEventListener("keydown",o),()=>e.removeEventListener("keydown",o)}var ie=P(null),ae=P(!0);function se({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return z(()=>{n&&e.resolveAll()},[e,n]),z(()=>{if(t&&"undefined"!=typeof document)return re(document,e)},[e,t]),/* @__PURE__ */L(ie.Provider,{value:e,children:/* @__PURE__ */L(ae.Provider,{value:t,children:o})})}function le(){const e=Z(ie);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function ce(e){const t=le(),n=B({view:null,selector:null,value:void 0,has:!1}),o=()=>{const o=t.getState(),r=n.current;if(r.has&&r.view===o&&r.selector===e)return r.value;const i=e(o);return r.has&&Object.is(r.value,i)?(n.current={view:o,selector:e,value:r.value,has:!0},r.value):(n.current={view:o,selector:e,value:i,has:!0},i)};return K(t.subscribe,o,o)}function de(){return function(e){return ce(e)}}var ue="data-puck-component",pe="data-puck-dropzone",fe={},he="data-es-mirror",me="undefined"==typeof window?z:N;function ge(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${he}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(he,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function ve({children:t,id:n="preview-frame",title:o,className:r,style:i,mirrorStyles:a=!0,onDocument:s,height:l="auto",nonce:u}){const p=c("canvas",e),f=B(null),[h,m]=R(null);return me(()=>{const e=f.current,t=h?.ownerDocument.defaultView;if("auto"!==l||!e||!h||!t)return;const n=()=>{e.style.height=`${Math.ceil(h.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(h),()=>r?.disconnect()},[h,l]),me(()=>{let e=f.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=f.current?.contentDocument??e),e.body||e.documentElement.appendChild(e.createElement("body")),e.body.style.margin="0";const t=e.createElement("div");t.setAttribute("data-puck-entry",""),t.id="frame-root","fill"===l&&t.classList.add("es-frame-fill"),e.body.appendChild(t),d(e,u),m(t),s?.(e);let n=null;const o=f.current?.ownerDocument;if(a&&o){ge(o,e,u);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>ge(o,e,u)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}return()=>{n?.disconnect(),t.remove(),m(null),s?.(null)}},[]),/* @__PURE__ */L("iframe",{ref:f,id:n,title:o??p.frame,className:["es-canvas-frame","fill"===l?"is-fill":"",r??""].filter(Boolean).join(" "),style:i,children:h?F(t,h):null})}var ye=P(null),we=P(fe),ke=[];function be({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:i=120}){const a=le(),s=ce(n=>g(n.appState.data,a.config,{parentId:e,slot:t})??ke),l=ce(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==m),c=ce(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),d=Z(ye),u=["es-zone"];return s.length&&u.push("has-children"),e===m&&u.push("is-root"),(l||c)&&u.push("is-area-selected"),null!==d&&d===e&&e!==m&&u.push("is-hovering-area"),n&&u.push(n),/* @__PURE__ */L("div",{className:u.join(" "),[pe]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${i}px`},children:s.map(e=>/* @__PURE__ */L(Ce,{node:e},e.props.id))})}function Se(e,t,n,o){const r="root"===t?e.root:e.components[t],i={...o};for(const e of O(A(r)))i[e]=function(t={}){/* @__PURE__ */
|
|
2
|
-
return L(be,{parentId:
|
|
3
|
-
return L(be,{parentId:e,slot:t,...n})}}function Ce({node:e}){const t=le().config
|
|
4
|
-
return L(we.Provider,{value:e??fe,children:
|
|
1
|
+
import{DEFAULT_CANVAS_WORDS as e}from"./chunk-TBY3DFKS.js";import{useResolvedFields as t}from"./chunk-YRLPFZW3.js";import{toItemSelector as n,fromItemSelector as o,useNodeOps as r,parentStep as i,clickPick as a}from"./chunk-SOZUYCQZ.js";import{startCanvasTyping as s,textMap as l}from"./chunk-WQASXLXS.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{setCanvasNonce as d,isTypingTarget as u,frameRectToHost as p,CANVAS_TYPING_EVENT as f}from"./chunk-AWJUYMX7.js";import{find as h,ROOT_ID as m,getList as g,remove as v,parseZoneKey as y,move as w,duplicate as k,replaceNode as b,createNode as S,insert as I,normalizeData as C,createResolveCache as E,resolveNodeData as x,ROOT_SLOT as D}from"./chunk-KRXQM65X.js";import{topLevelSlotKeys as O,fieldsFrom as A,defaultsFrom as M}from"./chunk-NKB3KVAB.js";import{createContext as P,useEffect as z,useContext as Z,useRef as B,useSyncExternalStore as K,useState as R,useMemo as $,useCallback as j,useLayoutEffect as N}from"react";import{jsx as L,jsxs as V}from"react/jsx-runtime";import{createPortal as F}from"react-dom";import{FloatingBar as Y,TextToolbar as H}from"efficient-shell/ui";function T(e){return!["setData","setUi","set"].includes(e.type)}var W=(e,t,n,o)=>{const r=g(e,t,y(n));return r?.[o]??null},X=(e,t,n,o,r)=>{const i=W(e,t,n,o);if(!i)throw new Error(`${r}: nothing at ${n}[${o}]`);return i};function U(e,t){const{selection:o}=e;return{...e.ui,itemSelector:n(e.data,t,o),selectedSlot:o&&"slot"===o.kind?{parentId:o.parentId,slot:o.slot}:null}}function q(e,t,n){return n?"node"===n.kind?h(e,t,n.id)?n:null:n.parentId===m?g(e,t,n)?n:null:h(e,t,n.parentId)&&g(e,t,n)?n:null:null}function Q(e,t,n,r=!1){const{itemSelector:i,selectedSlot:a,...s}=n;let l=e.selection;var c;return"itemSelector"in n&&(l=o(e.data,t,i??null)),"selectedSlot"in n&&(a?l=(c=a)?{kind:"slot",parentId:c.parentId,slot:c.slot}:null:"slot"===l?.kind&&(l=null)),{...e,selection:l,ui:r?s:{...e.ui,...s}}}function G(e,t,n){const o=J(e,t,n);if(o===e)return e;const r=q(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function J(e,t,n){const{data:o}=e;switch(t.type){case"setData":{const n="function"==typeof t.data?t.data(o):t.data;return{...e,data:{...o,...n}}}case"setUi":return Q(e,n,"function"==typeof t.ui?t.ui(U(e,n)):t.ui);case"set":{const r={data:o,ui:U(e,n)},i="function"==typeof t.state?t.state(r):t.state;let a=i.data?{...e,data:i.data}:e;return i.ui&&(a=Q(a,n,i.ui,!0)),a}case"insert":{const r={...y(t.destinationZone),index:t.destinationIndex},i=S(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:I(o,n,r,i)}}case"replace":{const r=X(o,n,t.destinationZone,t.destinationIndex,"replace");if(r.props.id!==t.data.props.id)throw new Error("Can't change the id during a replace action. Use remove and insert for a new node.");return{...e,data:b(o,n,r.props.id,t.data)}}case"replaceRoot":{const n={...o.root,props:{...o.root.props,...t.root.props},readOnly:t.root.readOnly};return{...e,data:{...o,root:n}}}case"duplicate":{const r=X(o,n,t.sourceZone,t.sourceIndex,"duplicate"),i=k(o,n,r.props.id),a=W(i,n,t.sourceZone,t.sourceIndex+1);return{...e,data:i,selection:a?{kind:"node",id:a.props.id}:e.selection}}case"reorder":return J(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=W(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const i={...y(t.destinationZone),index:t.destinationIndex};return{...e,data:w(o,n,r.props.id,i)}}case"remove":{const r=X(o,n,t.zone,t.index,"remove");return{...e,data:v(o,n,r.props.id)}}default:return e}}var _={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},ee={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},te=0,ne=()=>`history-${te+=1}`;function oe(e){let t=e.config;const r=e.now??(()=>Date.now()),i=e.historyCoalesceMs??250;let a=e.permissions??{};const s=C(e.data,t);let l={data:s,selection:null,ui:{...ee}};if(e.ui){const{itemSelector:n,selectedSlot:r,...i}=e.ui;l={data:s,selection:r?{kind:"slot",...r}:o(s,t,n??null),ui:{...ee,...i}}}let c=[{core:l,at:-1/0,sealed:!0,id:ne()}],d=0;const u=e=>{const t=c[d],n=r();!e&&d===c.length-1&&d>0&&!t.sealed&&n-t.at<i?c=[...c.slice(0,d),{...t,core:l,at:n}]:(c=[...c.slice(0,d+1),{core:l,at:n,sealed:e,id:ne()}],d=c.length-1)},p=/* @__PURE__ */new Set;let f=null,m=null,v=0,y=null,w=!1;const k=()=>{for(const e of[...p])e()},S=()=>{c=[...c.slice(0,d),{...c[d],core:l},...c.slice(d+1)]},I=(t,n)=>{v>0?w=w||n:(n?u(!1):l!==t&&S(),l.data!==t.data&&e.onChange?.(l.data),l!==t&&k())},D=e=>{const n=l;if(l=G(l,e,t),l===n)return;const o=e.recordHistory??T(e);I(n,o&&l.data!==n.data)},O=t=>{0===v&&(y=l,w=!1),v+=1;try{t()}catch(e){throw v-=1,0===v&&y&&(l=y,y=null),e}if(v-=1,v>0||!y)return;const n=y;y=null,w&&l.data!==n.data?u(!0):l!==n&&S(),l.data!==n.data&&e.onChange?.(l.data),l!==n&&k()},A=e=>{const n=l,o=q(l.data,t,e);var r,i;(r=o,i=l.selection,r===i||r&&i&&r.kind===i.kind&&("node"===r.kind&&"node"===i.kind?r.id===i.id:"slot"===r.kind&&"slot"===i.kind&&r.parentId===i.parentId&&r.slot===i.slot))||(l={...l,selection:o},I(n,!1))},M=t=>{const n=l;d=t,l=c[d].core,l.data!==n.data&&e.onChange?.(l.data),l!==n&&k()},P=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{..._,...a,...n}};let z=P();const Z=E(),B={resolveCache:Z,async resolveAll({trigger:e="load",metadata:n}={}){const o=l.data,r={type:"root",props:{...o.root.props??{}}},i=[...o.content,...Object.values(o.zones??{}).flat()],[a,...s]=await Promise.all([x(r,t,{cache:Z,trigger:e,metadata:n}),...i.map(o=>x(o,t,{cache:Z,trigger:e,metadata:n}))]);O(()=>{const e=l;let n=l.data;s.forEach((e,r)=>{if(!e.didChange)return;const a=i[r].props.id,s=h(n,t,a)?.node;s&&s===h(o,t,a)?.node&&(n=b(n,t,a,e.node))}),a.didChange&&n.root===o.root&&(n={...n,root:{...n.root,props:a.node.props,readOnly:a.node.readOnly??n.root.readOnly}}),n!==l.data&&(l={...l,data:n,selection:q(n,t,l.selection)},I(e,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=h(l.data,t,e)?.node;if(!r)return!1;const i=await x(r,t,{cache:Z,trigger:n,metadata:o});if(!i.didChange)return!1;let a=!1;return O(()=>{const n=l;if(h(l.data,t,e)?.node!==r)return;const o=b(l.data,t,e,i.node);o!==l.data&&(l={...l,data:o,selection:q(o,t,l.selection)},I(n,!1),a=!0)}),a},get config(){return t},getState(){if(f&&m===l)return f;const e=l,o={data:e.data,ui:U(e,t)},r="node"===e.selection?.kind?h(e.data,t,e.selection.id)?.node??null:null;return f={appState:o,selection:e.selection,selectedItem:r,config:t,dispatch:D,history:{back:()=>B.undo(),forward:()=>B.redo(),hasPast:d>0,hasFuture:d<c.length-1,histories:c.map(e=>({id:e.id,state:{data:e.core.data,ui:U(e.core,t)}})),index:d,setHistoryIndex:e=>{e>=0&&e<c.length&&e!==d&&M(e)}},getPermissions:z,getItemById:n=>h(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return g(e,t,{parentId:o,slot:r})?.[n.index]}(e.data,t,n),getSelectorForId:o=>{const r=n(e.data,t,{kind:"node",id:o});return r?{index:r.index,zone:r.zone??"root:default-zone"}:void 0}},m=e,f},subscribe:e=>(p.add(e),()=>{p.delete(e)}),dispatch:D,batch:O,group:()=>{const e=d,t=c[e].id;let n=!0;return{close:()=>{if(!n)return;if(n=!1,c[e]?.id!==t)return;if(d<=e+1)return void(d===e+1&&(c=[...c.slice(0,d),{...c[d],sealed:!0},...c.slice(d+1)]));const o=c[d];c=[...c.slice(0,e+1),{...o,sealed:!0},...c.slice(d+1)],d=e+1}}},select:e=>A(e?{kind:"node",id:e}:null),selectSlot:e=>A(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){O(()=>{const n=l,o=void 0===e.select?l.selection:e.select;l={...l,data:e.data,selection:q(e.data,t,o)},I(n,e.data!==n.data)})},load(e,n={}){const o=l,r=C(e,t);l={...l,data:r,selection:q(r,t,n.selection??l.selection)},n.keepHistory||(c=[{core:l,at:-1/0,sealed:!0,id:ne()}],d=0),l!==o&&k()},undo(){d>0&&M(d-1)},redo(){d<c.length-1&&M(d+1)},setPermissions(e){(function(e,t){if(e===t)return!0;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])})(e,a)||(a=e,z=P(),f=null,k())},setConfig(e){e!==t&&(t=e,z=P(),f=null,k())}};return B}function re(e,t,n={}){const o=e=>{if(e.altKey)return;if(!(e.metaKey!==e.ctrlKey))return;const o="KeyZ"===e.code,r="KeyY"===e.code&&!e.shiftKey;(o||r)&&(n.leaveTyping&&u(e.target)||!1!==t.getState?.().getPermissions().edit&&(e.preventDefault(),r||e.shiftKey?t.redo():t.undo()))};return e.addEventListener("keydown",o),()=>e.removeEventListener("keydown",o)}var ie=P(null),ae=P(!0);function se({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return z(()=>{n&&e.resolveAll()},[e,n]),z(()=>{if(t&&"undefined"!=typeof document)return re(document,e)},[e,t]),/* @__PURE__ */L(ie.Provider,{value:e,children:/* @__PURE__ */L(ae.Provider,{value:t,children:o})})}function le(){const e=Z(ie);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function ce(e){const t=le(),n=B({view:null,selector:null,value:void 0,has:!1}),o=()=>{const o=t.getState(),r=n.current;if(r.has&&r.view===o&&r.selector===e)return r.value;const i=e(o);return r.has&&Object.is(r.value,i)?(n.current={view:o,selector:e,value:r.value,has:!0},r.value):(n.current={view:o,selector:e,value:i,has:!0},i)};return K(t.subscribe,o,o)}function de(){return function(e){return ce(e)}}var ue="data-puck-component",pe="data-puck-dropzone",fe={},he="data-es-mirror",me="undefined"==typeof window?z:N;function ge(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${he}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(he,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function ve({children:t,id:n="preview-frame",title:o,className:r,style:i,mirrorStyles:a=!0,onDocument:s,height:l="auto",nonce:u}){const p=c("canvas",e),f=B(null),[h,m]=R(null);return me(()=>{const e=f.current,t=h?.ownerDocument.defaultView;if("auto"!==l||!e||!h||!t)return;const n=()=>{e.style.height=`${Math.ceil(h.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(h),()=>r?.disconnect()},[h,l]),me(()=>{let e=f.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=f.current?.contentDocument??e),e.body||e.documentElement.appendChild(e.createElement("body")),e.body.style.margin="0";const t=e.createElement("div");t.setAttribute("data-puck-entry",""),t.id="frame-root","fill"===l&&t.classList.add("es-frame-fill"),e.body.appendChild(t),d(e,u),m(t),s?.(e);let n=null;const o=f.current?.ownerDocument;if(a&&o){ge(o,e,u);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>ge(o,e,u)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}return()=>{n?.disconnect(),t.remove(),m(null),s?.(null)}},[]),/* @__PURE__ */L("iframe",{ref:f,id:n,title:o??p.frame,className:["es-canvas-frame","fill"===l?"is-fill":"",r??""].filter(Boolean).join(" "),style:i,children:h?F(t,h):null})}var ye=P(null),we=P(fe),ke=[];function be({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:i=120}){const a=le(),s=ce(n=>g(n.appState.data,a.config,{parentId:e,slot:t})??ke),l=ce(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==m),c=ce(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),d=Z(ye),u=["es-zone"];return s.length&&u.push("has-children"),e===m&&u.push("is-root"),(l||c)&&u.push("is-area-selected"),null!==d&&d===e&&e!==m&&u.push("is-hovering-area"),n&&u.push(n),/* @__PURE__ */L("div",{className:u.join(" "),[pe]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${i}px`},children:s.map(e=>/* @__PURE__ */L(Ce,{node:e},e.props.id))})}function Se(e,t){return $(()=>{const n={};for(const o of O(A(e)))n[o]=function(e={}){/* @__PURE__ */
|
|
2
|
+
return L(be,{parentId:t,slot:o,...e})};return n},[e,t])}function Ie(e){return $(()=>function({zone:t,...n}){/* @__PURE__ */
|
|
3
|
+
return L(be,{parentId:e,slot:t,...n})},[e])}function Ce({node:e}){const t=le().config.components[e.type],n=e.props.id,o=function(e){const t=B(null);return $(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(ue),o.removeAttribute("data-puck-dnd")),t.current=n,n&&(n.setAttribute(ue,e),n.setAttribute("data-puck-dnd",e),n.style.position="relative")},[e])}(n),r=Z(we),i=Se(t,n),a=Ie(n);if(!t?.render)return null;const s=t.render,l={...M(t),...e.props,...i},c={renderDropZone:a,isEditing:!0,dragRef:t.inline?o:null,metadata:{...r,...t.metadata}};return t.inline?/* @__PURE__ */L(s,{...l,puck:c,editMode:!0}):/* @__PURE__ */L("div",{[ue]:n,"data-puck-dnd":n,style:{position:"relative"},children:/* @__PURE__ */L(s,{...l,puck:c,editMode:!0})})}function Ee({metadata:e}){const t=ce(e=>e.config),n=ce(e=>e.appState.data.root).props??{},o=t.root?.render,r=Se(t.root,m),i=Ie(m),a=/* @__PURE__ */L(be,{parentId:m,slot:D}),s=o?/* @__PURE__ */L(o,{id:"puck-root",...n,...r,puck:{renderDropZone:i,isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:a}):a;/* @__PURE__ */
|
|
4
|
+
return L(we.Provider,{value:e??fe,children:s})}function xe(e,t,n){const[o,r]=R(null),i=B(t);return i.current=t,me(()=>{const t=e.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!i.current)return void r(null);let o=0;const a=()=>{o=0;const n=function(e,t){if(!e||!t)return null;const n=e.getBoundingClientRect(),o=t.getBoundingClientRect();return{top:n.top-o.top,left:n.left-o.left,width:n.width,height:n.height}}(i.current?i.current(t):null,e.current?.parentElement??null);r(e=>{return(t=e)===(o=n)||t&&o&&t.top===o.top&&t.left===o.left&&t.width===o.width&&t.height===o.height?e:n;var t,o})},s=()=>{o||(o=(n.requestAnimationFrame??(e=>n.setTimeout(e,16)))(a))};a();const l="MutationObserver"in n?new n.MutationObserver(s):null;l?.observe(t.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0});const c="ResizeObserver"in n?new n.ResizeObserver(s):null;return c?.observe(t.documentElement),n.addEventListener("resize",s),()=>{l?.disconnect(),c?.disconnect(),n.removeEventListener("resize",s),o&&(n.cancelAnimationFrame??n.clearTimeout)(o)}},[n]),o}function De({id:e,kind:t,overlay:n}){const o=B(null),r=xe(o,e?t=>t.querySelector(`[${ue}="${t.defaultView?.CSS?.escape?t.defaultView.CSS.escape(e):e}"]`):null,e),i=/* @__PURE__ */L("div",{ref:o,"aria-hidden":"true",className:`es-canvas-outline is-${t}`,style:r?{position:"absolute",top:r.top,left:r.left,width:r.width,height:r.height}:{display:"none"}});return n&&e?/* @__PURE__ */L(n,{componentId:e,kind:t,children:i}):i}function Oe(e,t,n){const o=l(e,n),r=o.text.length,i=e.ownerDocument;if(!t)return[r,r];let a=null;const s=i.caretPositionFromPoint?.(t.x,t.y);if(s&&e.contains(s.offsetNode))a=o.at(s.offsetNode,s.offset);else{const n=i.caretRangeFromPoint?.(t.x,t.y);n&&e.contains(n.startContainer)&&(a=o.at(n.startContainer,n.startOffset))}if(null===a)return[r,r];const c=o.text;let d=a,u=a;for(;d>0&&!/\s/.test(c[d-1]);)d-=1;for(;u<c.length&&!/\s/.test(c[u]);)u+=1;return[d,u]}function Ae({s:e,element:t,toolbar:n,label:o}){const r=e.pressed(),i=new Set(n.offered.filter(e=>"link"!==e));/* @__PURE__ */
|
|
5
5
|
return L(Y,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?p(o,{left:n.left,top:n.top,width:n.width,height:n.height}):{left:n.left,top:n.top,width:n.width,height:n.height};return{left:r.left-6,top:r.top-6,right:r.left+r.width+6,bottom:r.top+r.height+6}},bounds:()=>{const e=t(),n=e?.ownerDocument.defaultView?.frameElement,o=(n??e?.closest(".es-canvas")??e)?.getBoundingClientRect();return o?{left:o.left,top:o.top,right:o.right,bottom:o.bottom}:{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight}},"aria-label":o,children:/* @__PURE__ */L("div",{style:{width:"18rem"},children:/* @__PURE__ */L(H,{offered:i,pressed:r.marks,onMark:t=>{"link"!==t&&e.press(t)},list:{pressed:r.list,onList:t=>e.list(t)},alignment:n.alignment,letterCase:n.letterCase})})})}function Me({element:e}){const t=B(null),n=xe(t,()=>e(),e);/* @__PURE__ */
|
|
6
6
|
return L("div",{ref:t,"aria-hidden":"true",className:"es-canvas-outline is-typing",style:n?{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height}:{display:"none"}})}function Pe({frame:t=!0,className:n,style:o,metadata:r,mirrorStyles:l,onDocument:d,height:u,title:p,nonce:h,hotkeys:m,frameWrapper:g,overlay:v,children:y,typing:w}){const k=le(),b=Z(ae),S=c("canvas",e),I=m??b,[C,E]=R(void 0),x=ce(e=>"node"===e.selection?.kind?e.selection.id:null),[D,O]=R(null),[A,M]=R(null),P=B(null),[,K]=R(0),$=B(w);$.current=w;const j=B(null),N=e=>{const t=j.current?.ownerDocument,n=t?.defaultView?.CustomEvent;t&&n&&t.dispatchEvent(new n(f,{detail:{typing:e}}))},F=(e,t)=>{P.current?.s.stop("stop");const n=e.element();if(!n)return!1;const o=k.group(),r=e.element,i=s({element:r,value:e.value,rules:e.rules,multiline:e.multiline,skip:e.skip,caret:Oe(n,t,e.skip),write:e.write,remount:e.remount,onSelect:()=>K(e=>e+1),end:e=>{o.close(),P.current?.element===r&&(P.current=null),M(null),N(!1),$.current?.onChange?.({typing:!1,why:e})}});if(!i)return o.close(),!1;const a=n.closest?.(`[${ue}]`)?.getAttribute(ue);return a&&k.select(a),P.current={s:i,element:r,target:e},M(()=>r),O(null),N(!0),$.current?.onChange?.({typing:!0,element:n}),!0};z(()=>()=>P.current?.s.stop("stop"),[]);const Y=e=>{const t=P.current?.element();return Boolean(t&&t.contains(e))},H=e=>{const t=e.closest?.(`[${ue}]`)?.getAttribute(ue);if(!t)return;const n=k.getState(),o="node"===n.selection?.kind?n.selection.id:null;return a(n.appState.data,k.config,t,o)??t},T=e=>{if("Enter"!==e.key||e.defaultPrevented||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;if(P.current)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select, button"))return;const n=$.current?.atSelection?.();n&&F(n,null)&&e.preventDefault()},W=/* @__PURE__ */V("div",{ref:j,className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;if(t.closest?.("a[href]")&&e.preventDefault(),P.current){if(Y(t))return;P.current.s.stop("outside")}const n=H(t);void 0===n?t.hasAttribute?.(pe)||k.select(null):k.select(n)},onDoubleClick:e=>{const t=$.current;if(!t||Y(e.target))return;const n=t.at(e.target);n&&F(n,{x:e.clientX,y:e.clientY})&&e.preventDefault()},onKeyDown:e=>T(e),onMouseOver:e=>{if(P.current)return;const t=H(e.target)??null;t!==D&&O(t)},onMouseLeave:()=>O(null),children:[
|
|
7
7
|
/* @__PURE__ */L(ye.Provider,{value:D,children:/* @__PURE__ */L(Ee,{metadata:r})}),
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{blockTypesIn as e}from"./chunk-5ZBY24K7.js";import{buildPaletteSections as t,pinnedSection as o,paletteWithoutPinned as n,categoryLabel as i}from"./chunk-PA3PNTVV.js";import{sectionTemplatesOf as s}from"./chunk-BVN33R76.js";import{SidePanelHead as r,PanelModeExit as c}from"./chunk-PFNIVZPN.js";import{useEaselSession as l}from"./chunk-O7Q4DDJT.js";import{blockRuns as a}from"./chunk-HQ4VVRIC.js";import{useScreenBlockLook as p,useScreenBlockRules as m}from"./chunk-E3PD66A3.js";import{DEFAULT_SCREEN_WORDS as d}from"./chunk-5F3PKNT7.js";import{useEasel as f}from"./chunk-KYG35KKJ.js";import{useWords as u}from"./chunk-MFIRYGHW.js";import{AddPanel as k}from"./chunk-SSORUDHE.js";import{DEFAULT_DRAG_WORDS as h}from"./chunk-O2NLQBFX.js";import{useState as y,useEffect as b,useMemo as j}from"react";import{AddIcon as g}from"efficient-shell/icons/efficient";import{jsx as $,jsxs as O,Fragment as B}from"react/jsx-runtime";var N=e=>`section:${e}`,v=e=>`block:${e}`,x=e=>`template:${e}`;function F({blocks:F,blocksOnly:I,at:P,onAdd:V,itemFor:A,session:D,siteWide:H,onClose:K,onHide:L,readOnly:R}){const S=f(e=>e.config),T=p(),{labelAtLevel:w,categoryLabel:C,firstSection:E,Icon:Q,Thumbnail:Y}=T,{blockIsOffered:z}=m(),G=u("screen",d).add,J=u("drag",h).add,W=l(),[Z,M]=y([]);b(()=>{let t=!1;const o=e=>z(e,W);return s(W).list().then(n=>{if(t)return;const i=S.components;M(n.filter(t=>t.node?.type&&i[t.node.type]&&e(t.node).every(o)))}).catch(()=>{}),()=>{t=!0}},[S,W]);const U=j(()=>t(S,T),[S]),X=e=>({type:N(e.type),label:e.name,cover:/* @__PURE__ */$(Y,{type:e.type}),title:e.desc?`${e.name} — ${e.desc}`:G.tile({name:e.name}),keywords:[e.alias??"",e.desc,e.type,e.catLabel].filter(Boolean)}),q=j(()=>{const e=[];if(F&&F.choices.length>0&&a(F.choices).forEach((t,o)=>{e.push({key:`blocks:${o}`,title:0===o?`${G.inside({name:F.parentName})}${t.group?` · ${t.group}`:""}`:t.group??"",tiles:t.items.map(e=>({type:v(e.type),label:e.label,icon:/* @__PURE__ */$(Q,{type:e.type,size:18}),title:G.tile({name:e.label})}))})}),I)return e;const t=o(U,E);t&&e.push({key:"start",title:G.startBlank,tiles:[X(t)]}),Z.length>0&&e.push({key:"templates",title:G.templates,tiles:Z.map(e=>{return{type:x(e.id),label:e.name,cover:/* @__PURE__ */$(Y,{type:e.node.type}),keywords:[(t=e.node.type,w(t,"section",S.components[t]?.label??t)),e.node.type]};var t})});const s=n(U,E);for(const t of Object.keys(S.categories??{})){const o=s.filter(e=>e.cat===t);0!==o.length&&e.push({key:`category:${t}`,title:i(S,t,C),tiles:o.map(X)})}return e},[F,I,Z,U,S,G]),_=e=>{const t=e.indexOf(":"),o=e.slice(0,t),n=e.slice(t+1);if("section"===o)return{kind:"section",type:n};if("block"===o)return{kind:"block",type:n};if("template"===o){const e=Z.find(e=>e.id===n);return e?{kind:"template",template:e}:null}return null};/* @__PURE__ */
|
|
2
|
+
return O(B,{children:[
|
|
3
|
+
/* @__PURE__ */$(r,{icon:/* @__PURE__ */$(g,{size:15}),title:G.title,context:I?G.contextBlocks:G.contextAll,actions:/* @__PURE__ */$(c,{label:G.done,description:G.doneDescription,onClick:K}),onHide:L}),
|
|
4
|
+
/* @__PURE__ */O("div",{className:"sf-addside sf-scroll",children:[
|
|
5
|
+
/* @__PURE__ */$(k,{groups:q,session:D,itemFor:e=>A(_(e)??{kind:"section",type:e}),onInsert:e=>{const t=_(e);t&&V(t)},at:P,hint:I?G.hintBlocks:G.hint,searchLabel:I?G.searchBlocks:G.searchSections,readOnly:R,words:J}),H&&!I?H:null]})]})}export{F as AddSidePanel,v as blockKey,N as sectionKey,x as templateKey};
|