efficient-easel 0.105.1 → 0.106.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -0
- package/dist/chunk-2GVCAIPX.js +1 -0
- package/dist/chunk-37OCQYNX.js +65 -0
- package/dist/chunk-6WH7FA2M.js +9 -0
- package/dist/chunk-C6BJB5AC.js +2 -0
- package/dist/{chunk-TTJ54QGG.js → chunk-DX4XELD6.js} +6 -6
- package/dist/{chunk-PQXIFBDY.js → chunk-E2O2MRZR.js} +1 -1
- package/dist/{chunk-V4LF7D4F.js → chunk-FS5BLARH.js} +1 -1
- package/dist/{chunk-QH6LCNOX.js → chunk-I6T4TZ5Q.js} +1 -1
- package/dist/{chunk-NYKIQJT2.js → chunk-JWMNPRTT.js} +1 -1
- package/dist/chunk-LY4K2ECT.js +1 -0
- package/dist/chunk-M7N2V4TG.js +2 -0
- package/dist/chunk-MHKBLPQ2.js +1 -0
- package/dist/chunk-MS4QRBJ6.js +5 -0
- package/dist/chunk-ND55LTCA.js +5 -0
- package/dist/{chunk-NWIW7AWH.js → chunk-PBSEUZD6.js} +1 -1
- package/dist/{chunk-Q4N7C6CT.js → chunk-UEVTQBM7.js} +3 -3
- package/dist/{chunk-BXZ6WLHC.js → chunk-VCQVNPTG.js} +16 -16
- package/dist/{chunk-SARZN4M7.js → chunk-VINYARYJ.js} +1 -1
- package/dist/chunk-WTMHT7BI.js +1 -0
- package/dist/chunk-Z6SOLDWV.js +1 -0
- package/dist/copy/index.js +9 -9
- package/dist/drag/index.d.ts +10 -0
- package/dist/drag/index.js +1 -1
- package/dist/easel/index.d.ts +10 -1
- package/dist/easel/index.js +1 -1
- package/dist/fields/index.js +1 -1
- package/dist/{host-BQ_b9Qzk.d.ts → host-CiuzZJXj.d.ts} +11 -1
- package/dist/index.js +1 -1
- package/dist/screen/components/AddBlockRow.js +1 -1
- package/dist/screen/components/AddSidePanel.js +1 -1
- package/dist/screen/components/MediaSidePanel.d.ts +1 -1
- package/dist/screen/components/MediaSidePanel.js +1 -1
- package/dist/screen/components/NodeContextMenu.d.ts +19 -1
- package/dist/screen/components/NodeContextMenu.js +1 -1
- package/dist/screen/components/PageEditGuardNotices.js +1 -1
- package/dist/screen/components/ScreenChrome.js +1 -1
- package/dist/screen/components/ScreenDocumentContext.d.ts +1 -1
- package/dist/screen/components/ScreenDocumentContext.js +1 -1
- package/dist/screen/components/ScreenMount.d.ts +1 -1
- package/dist/screen/components/ScreenMount.js +1 -1
- package/dist/screen/components/ScreenStoreProvider.d.ts +1 -1
- package/dist/screen/components/ScreenStoreProvider.js +1 -1
- package/dist/screen/components/SectionScreenShell.js +16 -16
- package/dist/screen/components/panel-widths.d.ts +15 -1
- package/dist/screen/components/panel-widths.js +1 -1
- package/dist/screen/components/usePartBridge.d.ts +1 -1
- package/dist/screen/components/usePartBridge.js +1 -1
- package/dist/screen/index.d.ts +2 -2
- package/dist/screen/index.js +1 -1
- package/dist/screen/lib/document-addressing.d.ts +1 -1
- package/dist/screen/lib/host.d.ts +1 -1
- package/dist/screen/lib/key-scope.d.ts +31 -2
- package/dist/screen/lib/key-scope.js +1 -1
- package/dist/screen/lib/media-panel.d.ts +1 -1
- package/dist/screen/lib/media-picker.d.ts +1 -1
- package/dist/screen/lib/puck/section-doc.d.ts +5 -1
- package/dist/screen/lib/puck/section-doc.js +1 -1
- package/dist/screen/lib/puck/style-clipboard.d.ts +1 -1
- package/dist/screen/lib/puck/use-section-ops.js +1 -1
- package/dist/screen/lib/screen-parts.d.ts +38 -2
- package/dist/screen/lib/screen-parts.js +1 -1
- package/dist/screen/screen.css +21 -0
- package/dist/screen/words.d.ts +17 -1
- package/dist/screen/words.js +1 -1
- package/dist/strings/catalogue.js +1 -1
- package/dist/strings/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-53G47SWO.js +0 -1
- package/dist/chunk-7FBDZTUD.js +0 -2
- package/dist/chunk-7V5WZ46F.js +0 -2
- package/dist/chunk-FMGFZNPW.js +0 -1
- package/dist/chunk-HLEET6NV.js +0 -65
- package/dist/chunk-IE4GFYKO.js +0 -1
- package/dist/chunk-N7VRF7PR.js +0 -5
- package/dist/chunk-P67FP7PG.js +0 -9
- package/dist/chunk-VSHV6KJQ.js +0 -5
- package/dist/chunk-VSOP4GUM.js +0 -1
- package/dist/chunk-ZTTWFAAC.js +0 -1
package/dist/chunk-7V5WZ46F.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{routeSharedHostMessage as e}from"./chunk-S4AWJX4Q.js";import{describeLoadFailure as r,hostLoadRefusal as n}from"./chunk-ERR437B5.js";import{editLockOf as t}from"./chunk-GMCZXMOV.js";import{NO_DOCUMENT_ADDRESSING as o}from"./chunk-RLBXE4EU.js";import{saveStatusOf as u,resetForDocumentSwitch as a}from"./chunk-HNKB2ZYR.js";import{isExpiredSession as s}from"./chunk-CLOS6SSX.js";import{useAdminBridge as i}from"./chunk-3P6AMTOS.js";import{useEaselSession as l}from"./chunk-O7Q4DDJT.js";import{backendOf as c,setSessionDocumentSite as d}from"./chunk-RSCMJIWS.js";import{useEaselHost as f}from"./chunk-U3JP4VGF.js";import{DEFAULT_SCREEN_WORDS as m}from"./chunk-PQXIFBDY.js";import{useAutosave as g}from"./chunk-BDTITTMW.js";import{canWriteDocument as k,newEaselClientId as v,reloadIfVersionMoved as p,openUnansweredClaim as h,FAIL_OPEN_RETRY_MS as y,CLAIM_FAIL_OPEN_MS as S,holderOf as w}from"./chunk-THWO5YVZ.js";import{useWords as b}from"./chunk-MFIRYGHW.js";import{createContext as I,useContext as P,useState as j,useMemo as T,useCallback as B,useEffect as O,useRef as R}from"react";import{jsx as C}from"react/jsx-runtime";var E={content:[],root:{},zones:{}};var H=I(null);function M(){const e=P(H);if(!e)throw new Error("useStorefrontDocument must be used within StorefrontDocumentProvider");return e}function A({target:I,addressing:P=o,onHostMessage:M,children:A}){const D=P,{homeSlug:F,entryMayBounce:L,entryBounce:V,onSwitch:W,tellsHost:N,adapterFor:X,migrateRenamedProps:Y,describeMissing:J,onLoadFailed:x}=D,[G,Q]=j(I),U=f(),Z=l(),K=T(()=>c(Z),[Z]),z=T(()=>t(Z),[Z]),_="template"===G.kind,q="template"===G.kind?G.id:null,$="template"===G.kind?G.pageSlug??F??"":"document"===G.kind?G.slug??"":G.slug,ee="page"===G.kind?G.siteId??null:null,re=Z.blocks,ne=T(()=>X(G,K,re),[X,K,re,G.kind,"template"===G.kind?G.id:"document"===G.kind?G.record:G.siteId]),te=ne.capabilities,oe=B(e=>Z.documentHooks?.stored?.(e)??e,[Z]),ue="page"===G.kind?G.originSlug??null:null;O(()=>{d(Z,ee)},[Z,ee]);const ae=R(G);O(()=>{ae.current=G},[G]);const{token:se,tokenRef:ie,capabilities:le}=i({onMessage:r=>{if(M?.(r)||e(r))return;const n=r;if("storefront-editor:navigate"===n?.type){const e=r;e?.target&&Pr(e.target)}}}),ce=!Z.usesBridgedToken||null!==se,de=ne.lock,fe=Boolean(K.lock),[me,ge]=j(null),[ke,ve]=j(null),[pe,he]=j(null),[ye,Se]=j(null),we=b("screen",m),be=ye?function(e,r){if(null!==e.sentence)return e.sentence;if(!e.missing)return r.loadFailed({cause:e.cause});switch(e.target.kind){case"template":return r.missingTemplatePage;case"document":return r.missingDocument;default:return r.missingPage({slug:e.slug})}}(ye,we):null,[Ie,Pe]=j(null),je=R(null),Te=R(null),[Be,Oe]=j(!1),Re=R(null),[Ce,Ee]=j(null),He=R(null),[Me,Ae]=j(null),De=R(null);O(()=>{De.current=Me},[Me]);const[Fe,Le]=j(te.hasEditLock?{kind:"checking"}:{kind:"editing"}),Ve=R(Fe);O(()=>{Ve.current=Fe},[Fe]);const We=R(()=>Promise.resolve(!1)),Ne=B(e=>{Te.current=e,Oe(!0)},[]),Xe=g({save:async({id:e,data:r})=>{if(k(Ve.current)){if(!await We.current(e,r)){if(!k(Ve.current))return void Ne({id:e,data:r});throw new Error("page save did not land")}}else Ne({id:e,data:r})},onFailure:(e,r)=>{0===r&&U.send("storefront-editor:save-failed")}}),{state:Ye,push:Je,flush:xe,pause:Ge,resume:Qe,stop:Ue,reset:Ze,retryNow:Ke,hasPending:ze}=Xe,_e=R(Ye);O(()=>{_e.current=Ye},[Ye]);const qe=u(Ye),$e=B(()=>{const e=Te.current;e&&(Te.current=null,Oe(!1),Je(e))},[Je]),er=R("");er.current||(er.current=v());const[rr,nr]=j(0),tr=R(!1),[or,ur]=j(L(I)),ar=R(!1);O(()=>{if(ar.current)return;ar.current=!0;const e=U.address.search(),r=V(I,e);r?U.address.load(r):L(I)&&ur(!1)},[I,U]);const sr=U.send;O(()=>{if(!ce)return;let e=!1;const t=ae.current,o=ne.resolve($),u=Z.documentHooks?.opening?.({slug:$,isTemplate:_,capabilities:te});return o.then(async r=>{if(e)return;if(!r)return"page"===t.kind&&null!==F&&$!==F?void U.address.load({kind:"page",slug:F,siteId:ee??void 0}):(Se({target:t,slug:$,missing:!0,sentence:J?.(t)??null}),void x?.(t,null));const n=r.readOnlyReason?r.readOnlyReason:null;je.current=n,Pe(n),ge(r.id),ve(r.kind??null),He.current=r.version??null;const o=r.layout,a=o&&Object.keys(o).length?o:E,s=Y(a),i=u?await u(s):s;e||he(i)}).catch(o=>{e||(console.error("[storefront-editor] document load failed",o),Se({target:t,slug:$,missing:!1,sentence:n(o,{slug:$},Z),cause:r(o,Z)}),x?.(t,o))}),()=>{e=!0}},[ce,se,_,ne,$]);const ir=B(e=>new Promise(r=>{const n=Date.now(),t=setInterval(()=>{const o=ie.current;o&&o!==e?(clearInterval(t),r(o)):Date.now()-n>6e3&&(clearInterval(t),r(null))},200)}),[]),lr=B(async e=>{const r=ie.current;if(!r&&Z.usesBridgedToken)return{ok:!1,error:new Error("no editor token")};try{return{ok:!0,value:await e(r??"")}}catch(n){if(s(n,Z)){sr("storefront-editor:auth-expired");const n=r?await ir(r):null;if(n)try{return{ok:!0,value:await e(n)}}catch(e){return{ok:!1,error:e}}}return{ok:!1,error:n}}},[sr,ir,Z]),cr=B(async e=>{const r=ie.current?await lr(e):{ok:!1};return r.ok||sr("storefront-editor:save-failed"),r.ok},[sr,lr]),dr=B(async(e,r,n=!1)=>{if(null!==je.current)return!1;if(!k(Ve.current))return!1;if(De.current)return!1;const t=await lr(()=>ne.saveLayout(e,r,He.current,er.current));if(t.ok)return He.current=t.value.version??He.current,!0;const o=z.readLockTaken(t.error);if(o){const e={kind:"takenover",holder:o};return Ve.current=e,Le(e),!1}const u=z.readSaveConflict(t.error);if(u){if(u.savedByYou&&!n&&ne.rereadVersion){const n=await lr(()=>ne.rereadVersion(e));if(n.ok&&n.value)return He.current=n.value,We.current(e,r,!0)}Ue(),De.current=u,Ae(u)}return!1},[ne,lr,Ue]);O(()=>{We.current=dr},[dr]);const fr=B(e=>{if(null!==je.current)return;if(sr("storefront-editor:dirty"),!me)return;const r=oe(e);Re.current=r,k(Ve.current)?Je({id:me,data:r}):Ne({id:me,data:r})},[me,sr,Ne,Je,oe]),mr=B(async()=>{k(Ve.current)&&$e();return await xe()&&null==Te.current},[$e,xe]),gr=R(mr);O(()=>{gr.current=mr},[mr]);const kr=R(lr);O(()=>{kr.current=lr},[lr]);const vr=B(()=>{U.address.reload()},[U]),pr=R(()=>Promise.resolve(!1));O(()=>{pr.current=()=>{const e=ne.rereadVersion;return me&&e?p({ours:He.current,stored:async()=>{const r=await kr.current(()=>e(me));return r.ok?r.value:null},hasPending:()=>null!=Te.current||ze(),reload:vr}):Promise.resolve(!1)}},[ne,me,ze,vr]);const hr=null!==Ie;O(()=>{if(!de||!me||!ce||hr)return;let e=!1,r=null,n=null;const t=er.current,o={claim:async e=>{const r=await kr.current(()=>de.claim(me,t,e));if(r.ok)return{heartbeat_seconds:r.value.heartbeatSeconds};throw r.error},cancelled:()=>e,currentAccess:()=>Ve.current,heldWrite:()=>({pending:null!=Te.current||ze(),autoSaveEnabled:!_e.current.paused,saveConflict:null!=De.current}),setAccess:e=>{Ve.current=e,Le(e)},releaseHeldWrite:()=>{gr.current()},startHeartbeat:e=>{r&&clearInterval(r),r=setInterval(()=>{u(!1)},e)},stopHeartbeat:()=>{r&&(clearInterval(r),r=null)},reloadIfMoved:()=>{pr.current()}},u=z.makeClaimBeat(o),a=tr.current;return tr.current=!1,a||(Le({kind:"checking"}),n=setTimeout(()=>{n=null,h(o)&&o.startHeartbeat(y)},S)),u(a).finally(()=>{n&&clearTimeout(n),n=null}),()=>{e=!0,n&&clearTimeout(n),r&&clearInterval(r),de.release(me,t).catch(()=>{})}},[me,de,ce,se,rr,hr]);const yr=B(()=>{de&&me&&(tr.current=!0,nr(e=>e+1))},[me,de]),Sr=B(()=>{Le(e=>{const r="blocked"===e.kind||"takenover"===e.kind?e.holder:null;return r?{kind:"readonly",holder:r}:e})},[]),wr=B(()=>{_e.current.paused?(k(Ve.current)&&$e(),Qe()):Ge()},[$e,Ge,Qe]),br=B(()=>{Ke()},[Ke]),Ir=B(e=>{Re.current=null,a("template"!==e.kind&&fe,{resetAutosave:()=>{Ze(),Te.current=null,Oe(!1)},setVersion:e=>{He.current=e},setSaveConflict:Ae,setAccess:Le}),W(e),Q(e),je.current=null,Pe(null),ge(null),ve(null),he(null),Se(null),U.address.show(e),"document"!==e.kind&&N(e)&&U.send("storefront-editor:navigated",{target:e})},[Ze,U,fe,W,N]),Pr=B(e=>{if(function(e,r,n){if(e.kind!==r.kind)return!1;if("template"===e.kind){const t=r;return e.id===t.id&&(e.pageSlug??n)===(t.pageSlug??n)}if("document"===e.kind){const n=r;return e.record===n.record&&(e.slug??"")===(n.slug??"")}const t=r;return e.slug===t.slug&&e.siteId===t.siteId}(e,ae.current,F))return;const r=null!=Te.current;if(!r&&!ze())return void Ir(e);const n=_e.current;r||n.paused||n.failed||n.stopped?Ee(e):xe().then(r=>{r?Ir(e):Ee(e)})},[Ir,ze,xe,F]),jr=B(()=>Ee(null),[]),Tr=B(()=>{Ee(e=>(e&&Ir(e),null))},[Ir]),Br=B(async()=>{const e=Ce;if(!e)return;await mr()&&(Ee(null),Ir(e))},[Ce,mr,Ir]),Or=B(async e=>{if(null!==je.current)return;if(!me)return;if(!k(Ve.current)||De.current)return;const r=oe(e);if(!await dr(me,r))return void(De.current||sr("storefront-editor:save-failed"));const n=ne.publish;if(!te.canPublish||!n)return void sr("storefront-editor:saved");const t=await lr(()=>n(me,He.current??void 0));t.ok?(He.current=t.value.version??He.current,sr("storefront-editor:published")):sr("storefront-editor:save-failed")},[me,ne,te.canPublish,sr,dr,lr,oe]);/* @__PURE__ */
|
|
2
|
-
return C(H.Provider,{value:{target:G,adapter:ne,capabilities:te,templateId:q,currentSlug:$,currentKind:ke,siteId:ee,ready:ce,token:se,tokenRef:ie,notifyParent:sr,bridgeCapabilities:le,runAuthed:cr,docId:me,data:pe,getLiveData:()=>Re.current??pe,footerOriginSlug:ue,error:be,redirecting:or,saveStatus:qe,saveState:Ye,autoSaveEnabled:!Ye.paused,autoSaveStoppedByConflict:Ye.stopped,hasUnsavedEdits:Ye.pending||Be,toggleAutoSave:wr,retrySave:br,onChange:fr,flushSave:mr,onPublish:Or,access:Fe,readOnly:null!==w(Fe)||null!==Ie,readOnlyReason:Ie,takeOverEditing:yr,viewReadOnly:Sr,saveConflict:Me,reloadFromServer:vr,navigate:Pr,pendingNav:Ce,cancelPendingNav:jr,discardAndNavigate:Tr,saveAndNavigate:Br},children:A})}export{H as ScreenDocumentContext,A as ScreenDocumentProvider,M as useScreenDocument};
|
package/dist/chunk-FMGFZNPW.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{useSectionOps as o}from"./chunk-NWIW7AWH.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-VSHV6KJQ.js";import{useEasel as p}from"./chunk-P67FP7PG.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 P=s(m)?r(m.nodeId,m.propKey):null;c(()=>{f(P)},[P,f]);return{selectNode:d(o=>{i(()=>n);const e=a(o);e&&u.select(e)},[i,a,u]),openPartId:P}}export{m as usePartBridge};
|
package/dist/chunk-HLEET6NV.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import{dedupeSlotChildren as e}from"./chunk-26OOWIJJ.js";import{styleClipboardOf as n}from"./chunk-SQTY6CJD.js";import{markedTreeNodeId as t,revealSelectedTreeRow as o,sameSelector as r}from"./chunk-FGNR22NY.js";import{cloneNodeWithFreshIds as i}from"./chunk-IE4GFYKO.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}from"./chunk-VSOP4GUM.js";import{SlotChildActionsProvider as m}from"./chunk-KCBEE2MC.js";import{UiIcon as g}from"./chunk-5MZ3RNQQ.js";import{DEFAULT_PANEL_W as y,PANEL_WIDTHS_KEY as k,clampPanelWidth as S}from"./chunk-ZTTWFAAC.js";import{usePartBridge as v}from"./chunk-FMGFZNPW.js";import{useSectionOps as b}from"./chunk-NWIW7AWH.js";import{useNodeClipboard as x,useNodeContextMenu as w}from"./chunk-7FBDZTUD.js";import{PageEditGuardNotices as z}from"./chunk-V4LF7D4F.js";import{useScreenDocument as B}from"./chunk-7V5WZ46F.js";import{requestMediaPick as C}from"./chunk-KG7RJWOK.js";import{heldStyle as N,styleShortcut as $}from"./chunk-57DJOKXT.js";import{AddChildRow as I}from"./chunk-3QVB4AG2.js";import{AddSidePanel as O}from"./chunk-N7VRF7PR.js";import{SidePanelHead as T,PanelShowStrip as P}from"./chunk-5ZBBXZPV.js";import{MediaSidePanel as A}from"./chunk-NYKIQJT2.js";import{useScreenSaveSwitch as R,useScreenNodeKeys as j,useScreenPinned as M,useScreenDocumentLabel as E,useScreenCanvasFrame as V,useScreenInspectorPanel as D,useScreenDevices as F,useScreenPickFollowsSelection as L,useScreenLeftView as G,useScreenAdd as H,SELECTION_MODE as W,sameInspectorMode as U,useScreenBridges as J,useScreenBlockRules as Y,useScreenBlockLook as Q,useScreenNotify as K,useScreenCanvasHead as Z,isSlotMode as _,useScreenStyleClipboard as X,useScreenDocumentPass as q,useScreenCanvasDrag as ee,ScreenCanvasTargetProvider as ne,isPinnedFirst as te,isPinnedLast as oe,screenSlotsOf as re}from"./chunk-VSHV6KJQ.js";import{ROOT_ZONE as ie,blockNodeActions as le,TREE_MAX_DEPTH as se,childSlotsOf as de,slotFieldsOf as ce,slotChildrenIn as ae,nestsInTree as pe,newNodeId as ue}from"./chunk-PLVEGYK6.js";import{useMediaPanel as fe,usePanelPick as he,useCancelPanelPick as me}from"./chunk-R6WTQWAC.js";import{useEaselHost as ge,useHostEscape as ye}from"./chunk-U3JP4VGF.js";import{DEFAULT_SCREEN_WORDS as ke}from"./chunk-PQXIFBDY.js";import{useEasel as Se,useEaselApi as ve}from"./chunk-P67FP7PG.js";import{TreeRow as be,Subtree as xe,LayersTree as we,TreeGroupLabel as ze,TreeRowAction as Be,TreeSeam as Ce}from"./chunk-ZFDCDJNZ.js";import{toItemSelector as Ne,useNodeOps as $e}from"./chunk-D2BCHTQR.js";import{saveIndicator as Ie}from"./chunk-H6DDIBQ4.js";import{EaselTopBar as Oe,TopBarRail as Te,TopBarCluster as Pe,EaselIconButton as Ae,TopBarDivider as Re,DeviceSwitch as je,InspectorIconButton as Me,PanelResizeHandle as Ee,MAX_PANEL_W as Ve,MIN_PANEL_W as De,panelWidthVars as Fe,SaveState as Le,SaveStateToggle as Ge}from"./chunk-YC4TB3CJ.js";import{useWords as He}from"./chunk-MFIRYGHW.js";import{CanvasDragLayer as We}from"./chunk-TTJ54QGG.js";import{createDragSession as Ue,useTreeDrag as Je,gapToMoveIndex as Ye}from"./chunk-67GNT6PF.js";import{useCanvasFrame as Qe,BLOCK_SELECTOR as Ke,useCanvasEvent as Ze}from"./chunk-PAELDYYS.js";import{LayersIcon as _e,UndoIcon as Xe,RedoIcon as qe,TrashIcon as en,MediaIcon as nn,DuplicateIcon as tn}from"./chunk-L5KW4HG5.js";import{zoneKey as on,ROOT_ID as rn,ROOT_SLOT as ln,parseZoneKey as sn,DataError as dn}from"./chunk-KRXQM65X.js";import{useRef as cn,useMemo as an,useState as pn,useEffect as un,useCallback as fn,useLayoutEffect as hn,Fragment as mn}from"react";import{jsx as gn,jsxs as yn,Fragment as kn}from"react/jsx-runtime";function Sn({saveState:e,notSaving:n,readOnlyReason:t,toggle:o,onToggle:r,onRetry:i}){if(null!==t)/* @__PURE__ */return gn(Le,{tone:"off",label:t,role:"status"});if(n)/* @__PURE__ */
|
|
2
|
-
return gn(Le,{tone:e.pending?"off-unsaved":"off",label:"Not saving — see the notice above",role:"status"});const{tone:l,label:s}=Ie(e),d=e.failed&&!e.paused&&/* @__PURE__ */gn("button",{type:"button",className:"es-btn-ghost",onClick:i,children:"Retry now"});/* @__PURE__ */
|
|
3
|
-
return yn(kn,o?{children:[
|
|
4
|
-
/* @__PURE__ */gn(Ge,{pressed:e.paused,onToggle:r,title:e.paused?"Auto-save is off — click to turn it back on (saves your held edits)":"Auto-save is on — click to pause it",children:/* @__PURE__ */gn(Le,{tone:l,label:s})}),d]}:{children:[
|
|
5
|
-
/* @__PURE__ */gn(Le,{tone:l,label:s,role:"status"}),d]})}function vn({expand:e}){/* @__PURE__ */
|
|
6
|
-
return gn("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round",children:/* @__PURE__ */yn(kn,e?{children:[
|
|
7
|
-
/* @__PURE__ */gn("path",{d:"M8 9l4-4 4 4"}),
|
|
8
|
-
/* @__PURE__ */gn("path",{d:"M8 15l4 4 4-4"})]}:{children:[
|
|
9
|
-
/* @__PURE__ */gn("path",{d:"M8 4l4 4 4-4"}),
|
|
10
|
-
/* @__PURE__ */gn("path",{d:"M8 20l4-4 4 4"}),
|
|
11
|
-
/* @__PURE__ */gn("path",{d:"M5 12h14"})]})})}var bn="__rungs";var xn="screen:band",wn={duplicate:!0,delete:!0};function zn(){const Ie=ge(),{target:Le,docId:Ge,capabilities:zn,currentSlug:Bn,siteId:Cn,onPublish:Nn,saveState:$n,saveConflict:In,retrySave:On,toggleAutoSave:Tn,readOnly:Pn,readOnlyReason:An=null}=B(),Rn=R(),jn=j(),{mediaEditing:Mn,hasEditGuard:En,hasPinnedChrome:Vn}=zn,{appState:Dn,dispatch:Fn,history:Ln,selectedItem:Gn,getSelectorForId:Hn,config:Wn}=Se(e=>e),Un=M(),{first:Jn,firstGroup:Yn,lastGroup:Qn,isSectionGroup:Kn,sectionGroupZone:Zn,panelOf:_n}=Un,Xn=_n(Jn),qn=e=>te(Un,e),et=e=>oe(Un,e),nt="node"===Un.firstRow,tt=Un.band??null,ot=He("screen",ke),rt=E()??`/${Bn}`,it=V(),lt=D(),st=b({readOnly:Pn}),dt=cn(null),ct=ve(),at=an(()=>({...st,select:e=>{dt.current=e,st.select(e)},commitDocument:(e,n)=>{if(void 0!==n){const t=ct.config;dt.current=Ne(e,t,n)}st.commitDocument(e,n)}}),[st,ct]),pt=Dn.ui,ut=pt.leftSideBarVisible,ft=pt.rightSideBarVisible,{options:ht,widths:mt,initial:gt,fluid:yt,fit:kt}=F(),[St,vt]=pn(gt),bt=fe(),xt=Mn&&null!==bt,wt=he(),zt=me();L(Gn?.props.id);const{read:Bt,write:Ct,forSelection:Nt}=G(),[$t,It]=pn(Bt);un(()=>{Ct($t)},[$t]);const[Ot,Tt]=pn(0),Pt=cn(null),At=cn(null),Rt=Qe(At,{readySelector:Ke}),jt=f(At);h(At);const[Mt,Et]=pn(!1),Vt=cn(!1),Dt=cn(!1),[Ft,Lt]=pn(null),Gt=H(),Ht=e=>Lt(null===e?null:{zone:ie,index:e}),[Wt,Ut]=pn([]),[Jt,Yt]=pn(W),Qt="puck"===Jt.kind,Kt=Mt&&!Ft&&Gt.railTarget?Gt.railTarget(Dn.data,{node:Gn??null,mode:Jt}):null,Zt=Kt?{zone:on(Kt),index:Kt.index}:null,_t=Ft??Zt,Xt=_t&&_t.zone===ie?_t.index:null,qt=t(Jt,Gn?.props.id),[eo,no]=pn(null);un(()=>{eo&&(o(),no(null))},[eo]);const to=cn(Hn);to.current=Hn;const oo=fn((e,{scroll:n})=>{It(n=>Nt(e,n)),n&&no(e);const t=[];let o=e;for(let e=0;e<4;e++){const e=to.current(o)?.zone;if(!e||!e.includes(":"))break;const n=e.split(":")[0];t.push(n),t.push(e),o=n}0!==t.length&&Po(e=>{if(t.every(n=>!e.has(n)))return e;const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},[]),ro=cn(null);un(()=>{const e=ro.current;ro.current=null;const n=null==Gn?.props.id?null:String(Gn.props.id);Yt(e&&e.id===n?e.mode:_n(Gn?.type)??W);const t=Gn?.props.id,o=dt.current;if(dt.current=null,!t)return;const i=Hn(t);oo(String(t),{scroll:!r(o,i??null,ie)})},[Gn?.props.id,oo]);const io=fn(e=>{Yt(n=>U(n,e)?n:e),Fn({type:"setUi",ui:{rightSideBarVisible:!0}})},[Fn]),lo=cn(()=>{});lo.current=(e,n)=>{const t=e?Cr(e.zone??ie)[e.index]?.props.id:null,o=null==t?null:String(t),r=null==Gn?.props.id?null:String(Gn.props.id);Yt(e=>U(e,n)?e:n),o!==r&&(ro.current={id:o,mode:n},at.select(e))};const so=fn((e,n)=>lo.current(e,n),[]),co={kind:Jt.kind,mode:Jt,open:io,show:e=>Yt(e),reveal:()=>{ft||Fn({type:"setUi",ui:{rightSideBarVisible:!0}})},select:so},ao=J(co,{data:Dn.data,selected:Gn??null,zoneOf:e=>Hn(e)?.zone,readOnly:Boolean(Pn),select:e=>{Yt(W),at.select({index:e})},replace:(e,n)=>at.replaceComponent(ie,e,n),scrollTo:e=>_r(e)},{device:St,refreshes:Ot},{setView:It,reveal:()=>{ut||Fn({type:"setUi",ui:{leftSideBarVisible:!0}})}}),po=ao.pinnedSource??!1,uo=ao.resolveLeftView?ao.resolveLeftView($t,xt):"media"===$t&&xt?$t:"sections",fo=Y(),{isLockedBlock:ho,duplicateBlocked:mo,nestDepth:go,newSectionNode:yo,canAddTo:ko,blockIsOffered:So}=fo,vo=Q(),{labelAtLevel:bo,Icon:xo,useProducts:wo}=vo,zo=vo.rowName?(e,n,t)=>vo.rowName(e,n,t):void 0,Bo=fn(e=>{Fn({type:"setUi",ui:{rightSideBarVisible:!0}}),a(e),oo(e,{scroll:!0})},[Fn,oo]),{selectNode:Co,openPartId:No}=v({mode:Jt,setMode:Yt,onOpenPart:Bo}),[$o,Io]=pn(null);ye(null!==$o,()=>Io(null));const Oo="sf-editor-collapsed-sections",[To,Po]=pn(()=>{if("undefined"==typeof window)/* @__PURE__ */return new Set;try{const e=window.localStorage.getItem(Oo);return new Set(e?JSON.parse(e):[])}catch{/* @__PURE__ */
|
|
12
|
-
return new Set}});un(()=>{try{window.localStorage.setItem(Oo,JSON.stringify([...To]))}catch{}},[To]);const[Ao,Ro]=pn(()=>{if("undefined"==typeof window)return{...y};try{const e=window.localStorage.getItem(k);if(!e)return{...y};const n=JSON.parse(e);return{left:S(Number(n.left)||y.left),right:S(Number(n.right)||y.right)}}catch{return{...y}}});un(()=>{const e=setTimeout(()=>{try{window.localStorage.setItem(k,JSON.stringify(Ao))}catch{}},300);return()=>clearTimeout(e)},[Ao]);const jo=fn((e,n)=>Ro(t=>{const o="function"==typeof n?n(t[e]):n;return t[e]===o?t:{...t,[e]:o}}),[]),Mo=fn(e=>jo("left",e),[jo]),Eo=fn(e=>jo("right",e),[jo]),Vo=e=>To.has(e),Do=e=>Po(n=>{const t=new Set(n);return t.has(e)?t.delete(e):t.add(e),t}),Fo=cn(!1),Lo=cn(null);un(()=>{if(Fo.current&&!Mt){const e=Lo.current,n=e&&e.isConnected&&!e.closest('[aria-hidden="true"]')?e:null;(n??At.current?.querySelector(`button[aria-label="${CSS.escape(ot.add.title)}"]`))?.focus(),Lo.current=null}Fo.current=Mt},[Mt]),un(()=>{if(!Mt||!jt)return;const e=e=>{"Escape"===e.key&&li()};return jt.addEventListener("keydown",e),()=>jt.removeEventListener("keydown",e)},[Mt,jt]),ye(Mt,()=>li()),un(()=>{!ut&&Mt&&(Et(!1),Lt(null),Vt.current=!1)},[ut]),un(()=>{if(!wt)return Dt.current&&Fn({type:"setUi",ui:{leftSideBarVisible:!1}}),void(Dt.current=!1);Mt&&(Et(!1),Lt(null),Dt.current=Vt.current,Vt.current=!1),ut||(Dt.current=!0,Fn({type:"setUi",ui:{leftSideBarVisible:!0}}))},[wt]),un(()=>{!ut&&wt&&(Dt.current=!1,zt())},[ut]),un(()=>{if(!wt||!jt)return;const e=e=>{"Escape"===e.key&&zt()};return jt.addEventListener("keydown",e),()=>jt.removeEventListener("keydown",e)},[wt,jt]),ye(null!==wt,()=>zt());const Go=K(),[Ho,Wo]=pn(null),[Uo,Jo]=pn(0),Yo=cn(null),Qo=(e,n="success")=>{Go?Go(e,"error"===n?"error":"info"):(Wo({msg:e,tone:n}),Jo(e=>e+1),Yo.current&&clearTimeout(Yo.current),Yo.current=setTimeout(()=>Wo(null),"error"===n?3200:1900))};un(()=>()=>{Yo.current&&clearTimeout(Yo.current)},[]);const Ko=cn(null),[Zo,_o]=pn(0),[Xo,qo]=pn(0),er=Z(),nr=cn(null),tr=e=>Math.max(0,e.clientHeight-(nr.current?.offsetHeight??0));un(()=>{const e=Ko.current;if(!e)return;const n=()=>{_o(e.clientWidth),qo(tr(e))};n();const t=new ResizeObserver(n);return t.observe(e),nr.current&&t.observe(nr.current),()=>t.disconnect()},[]),hn(()=>{Ko.current&&(_o(Ko.current.clientWidth),qo(tr(Ko.current)))},[Ao,ut,ft]);const or=St===yt?Zo>0?Zo:mt[yt]:mt[St],rr=Zo>0?Math.min(Zo/or,"shrink"===kt?1:2):1,ir=or*rr,lr=Zo>0&&ir>Zo+1,sr={width:ir,height:Xo||"100%",flex:"none",position:"relative"},dr={width:or,height:Xo?Xo/rr:"100%",maxHeight:"none",transform:1!==rr?`scale(${rr})`:void 0,transformOrigin:"top left"},cr=()=>Fn({type:"setUi",ui:{leftSideBarVisible:!ut}}),ar=()=>Fn({type:"setUi",ui:{rightSideBarVisible:!ft}}),pr=e=>{Mt&&(Et(!1),Lt(null),Vt.current=!1,ut&&$t===e)||wt&&(Dt.current=!1,zt(),ut&&$t===e)||(ut&&$t===e?cr():(It(e),ut||Fn({type:"setUi",ui:{leftSideBarVisible:!0}})))},ur=()=>{C(Ie,{accept:"image/*",title:"Media library"})},fr=()=>{Yt(W),at.select(null),u()},hr=()=>{Yt(Xn??W),ft||Fn({type:"setUi",ui:{rightSideBarVisible:!0}})},mr=Dn.data.content??[],gr=()=>{const e=mr.findIndex(qn),n=mr.findIndex(et);return{floor:e>=0?e+1:0,cap:n>=0?n:mr.length}},yr=Wn,kr=x(),Sr=$e({data:Dn.data,config:yr,readOnly:Boolean(Pn),clipboard:kr,afterRemove:"none",stepBounds:(e,n)=>{if(e.parentId!==rn||e.slot!==ln)return{min:0,max:n-1};const{floor:t,cap:o}=gr();return{min:t,max:o-1}},commit:(e,{select:n})=>{void 0!==n&&Yt(W);const t=void 0===n||"node"===n?.kind?n:null;at.commitDocument(e,t)}}),vr=e=>Wn.components[e]?.label??e,br=fn(e=>Wn.components[e]?.defaultProps??{},[Wn]),xr=e=>bo(e,"section",vr(e)),wr=e=>l({type:e.type,props:e.props??{}},xr(e.type),zo),{nodeAddresses:zr,zoneItems:Br}=an(()=>{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>=se)return;const s=/* @__PURE__ */new Map;for(const{child:e,zone:t}of de(Wn,n))s.set(t,[...s.get(t)??[],e]);for(const[e,n]of s)t(n,e,i+1)})};return t(mr,ie,0),{nodeAddresses:e,zoneItems:n}},[mr,Wn]),Cr=fn(e=>Br.get(e)??[],[Br]),Nr=e=>{const n=zr.get(e);return n?Cr(n.zone)[n.index]:void 0},$r=e=>re(fo,Wn,e),Ir=e=>{if(!fo.slotsOf||e===ie)return null;const n=e.lastIndexOf(":");if(n<=0)return null;const t=Nr(e.slice(0,n));if(!t)return null;const o=$r(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}},Or=(()=>{if(!_(Jt))return null;const e=`${Jt.nodeId}:${Jt.slot}`;return Ir(e)?.slot.panel===Jt.kind?e:null})(),Tr=cn(null);un(()=>{const e=Tr.current;if(Tr.current=null,!Or||!_(Jt))return;const n=Jt.nodeId;oo(n,{scroll:e!==Or}),Po(e=>{if(!e.has(n))return e;const t=new Set(e);return t.delete(n),t})},[Jt]);const Pr=(e,n,t)=>{const o=String(e.props.id);if(!n.panel)return void(e=>{const n=zr.get(e);n&&(n.zone===ie?Xr(n.index):Ni(n.zone,n.index,e,Nr(n.zone.slice(0,n.zone.lastIndexOf(":")))?.type??""))})(o);const r={kind:n.panel,nodeId:o,slot:n.slot},i=`${o}:${n.slot}`;t&&Or!==i&&(Tr.current=i),so(null,r),ft||Fn({type:"setUi",ui:{rightSideBarVisible:!0}}),_r(o)},Ar=(e,n,t)=>{const o=`${e}:${n}`;if(Po(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;Or!==o&&(Tr.current=o);so(null,{kind:t,nodeId:e,slot:n})},Rr=(e,n,t)=>{if(Pn||!fo.moveSlot)return;const o=Nr(e),r=o?$r(o).filter(e=>e.rung):[],i=r[n];if(!i)return;const l={parentId:e,slot:bn,index:n},s=Ye(l,{...l,index:Math.min(Math.max(t,0),r.length)});if(s===n)return;const d=fo.moveSlot(e,n,s);"string"==typeof d&&Ar(e,d,i.panel)},jr=wo(),Mr=an(()=>{const e=/* @__PURE__ */new Map;for(const n of jr??[])e.set(n.slug,n.name);return e},[jr]),Er=e=>s(e,vr,vo.plainText,e=>Mr.get(e),vo.rowName),Vr=(e,n)=>{const t=Wn.components[e.type]?.fields,o=n===ie||Ui(n)?"section":"block",r=n===ie&&(qn(e)||et(e)||Kn(e.type)),i="block"===o?d(t):r?null:c(t);return vo.renamePropOf?vo.renamePropOf(e,o,i):i},Dr=(e,n,t,o)=>{if(!($o?.zone===e&&$o.index===n))return;const r=(t,o)=>{Io(null),o&&((e,n,t)=>{const o=Cr(e)[n];if(!o)return;const r=Vr(o,e);r&&at.replaceComponent(e,n,{...o,props:{...o.props,[r]:t.trim()}})})(e,n,t)};/* @__PURE__ */
|
|
13
|
-
return gn("input",{className:"es-tree-rename",defaultValue:o,autoFocus:!0,"aria-label":"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)},Fr=n(X()),Lr=Fr.scope({target:Le,siteId:Cn,docId:Ge}),Gr=Wn,Hr=(e,n)=>n===ie?xr(e):vr(e),Wr=(e,n,t)=>{const o=Fr.plan(Lr,t,Hr(t.type,e),Gr);o&&(o.changed&&at.replaceComponent(e,n,{...t,props:{...o.props,id:t.props.id}}),Qo(o.message))},Ur=w({nodesIn:Cr,nodeAt:(e,n)=>Cr(e)[n]??null,labelOf:(e,n)=>n===ie?xr(e):vr(e),renamePropOf:Vr,beginRename:(e,n)=>Io({zone:e,index:n}),history:{hasPast:Ln.hasPast,hasFuture:Ln.hasFuture,back:()=>Ln.back(),forward:()=>Ln.forward()},openAddSection:()=>{at.select(null),ri(null)},openPageSettings:()=>{at.select(null),Yt(W)},collapseAll:()=>Po(new Set(Cr(ie).map(e=>String(e.props.id)))),onPasteRefused:e=>Qo(e?ot.pasteRefused({name:e.label}):"Your browser won’t let us read the clipboard — press ⌘V","error"),canPasteAt:(e,n)=>Yi(e,n),menuRows:ao.menuRows,isLocked:e=>ho(e.type),duplicateBlocked:e=>mo(Dn.data,e),permits:e=>le(Wn,e.type),canAddTo:ko,nodeOps:Sr,isPinned:(e,n)=>n===ie&&(qn(e)||et(e)),sectionBand:gr,openAddInside:(e,n)=>{e===ie?Xr(n):at.select({zone:e,index:n}),ri(null)},locate:e=>zr.get(e)??null,rowNameOf:(e,n)=>n===ie?wr(e):Er(e),selectAt:(e,n,t,o)=>{e===ie?Xr(n):Ni(e,n,t,o??"")},slotRung:e=>{const n=Ir(e);return n?.slot.panel?{label:n.slot.label,select:()=>Pr(n.node,n.slot,!1)}:null},style:{held:()=>N(Lr),canCopy:e=>Fr.rows(Gr,e).some(e=>!1!==e.counted),copy:(e,n)=>Fr.copy(Lr,e,Hr(e.type,n),Gr),paste:(e,n,t)=>Wr(e,n,t)},keys:jn?{target:jt,selected:()=>{const e=Dn.ui.itemSelector;return e?{zone:e.zone??ie,index:e.index}:null},held:()=>kr.get(),readOnly:Boolean(Pn),onDone:({done:e,name:n})=>{"copied"===e&&Qo(ot.copied({name:n}))}}:void 0},Rt),Jr=cn({copy:(e,n)=>{},paste:(e,n,t)=>{},at:()=>null,readOnly:!1});un(()=>{Jr.current={copy:(e,n)=>Fr.copy(Lr,e,Hr(e.type,n),Gr),paste:Wr,at:()=>{const e=Dn.ui.itemSelector;if(!e)return null;const n=e.zone??ie,t=Cr(n)[e.index];return t?{zone:n,index:e.index,node:t}:null},readOnly:Boolean(Pn)}});const Yr=fn(e=>{const n=$(e);if(!n)return;const t=Jr.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))},[]);un(()=>{if(!jt)return;const e=e=>Yr(e);return jt.addEventListener("keydown",e),()=>jt.removeEventListener("keydown",e)},[Yr,jt]),Ze(Rt,"keydown",Yr);const Qr=mr.map(e=>e.props.id).join("|");un(()=>{const e=Rt?.document??null,n=Rt?.window??null;let t=0;const o=[],r=()=>{if(!e)return void Ut(e=>e.length?[]:e);const n=mr.findIndex(et),t=n>=0?n:mr.length,o=n=>{const t=mr[n]?.props?.id;if(null==t)return null;const o=e.querySelector(`[data-puck-component="${CSS.escape(String(t))}"]`);return o?o.getBoundingClientRect():null},r=[];for(let e=1;e<=t;e++){const n=o(e),t=o(e-1);(n||t)&&r.push({top:Math.round(n?n.top:t.bottom),index:e})}Ut(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)return!1;return!0}(e,r)?e:r)},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()}},[Rt,Qr,St,rr,ut,ft,Gn?.props.id]);const Kr=Rt?.document??null,Zr=Rt?.window??null;un(()=>{const e=Pt.current;if(!e||!Kr||!Zr)return;const n=[],t=()=>{const n=Kr.querySelector(`[data-puck-component="${CSS.escape(e.id)}"]`);if(!n)return!1;const t=n.getBoundingClientRect().top-e.offset;return Math.abs(t)>1&&Zr.scrollTo({left:Zr.scrollX,top:Zr.scrollY+t,behavior:"instant"}),!0};return Pt.current=null,t()&&n.push(setTimeout(t,150),setTimeout(t,450)),()=>n.forEach(clearTimeout)},[Kr,Zr]);const _r=e=>{ao.holdCanvasOn?ao.holdCanvasOn(e):a(e)},Xr=e=>{Yt(W),at.select({index:e}),ao.sectionPressed?.(mr[e]);const n=mr[e]?.props?.id;n&&_r(n)},qr=e=>{const{floor:n,cap:t}=gr(),o=e=>Math.min(Math.max(n,e),t);if("number"==typeof e)return o(e);const r=Gn&&Jt.kind!==Xn?.kind?mr.findIndex(e=>e.props.id===Gn.props.id):-1;return o(r>=0?r+1:t)},ei=(e,n)=>{const{floor:t,cap:o}=gr(),r=Math.min(Math.max(n,t),o),i=e<r?r-1:r;return i===e?{moved:!1,dest:e}:(at.reorderComponent(ie,e,i),at.select({index:i}),{moved:!0,dest:i})},ni=(e,n,t)=>{Yt(W),at.select({index:e}),a(n),Qo(`Added “${t}” section`)},ti=(e,n)=>{const t=qr(n),o=yo(e,{nodeDefaults:br,newNodeId:ue,sectionLabel:xr,blockIsOffered:So}),r=o?at.insertNode(ie,t,o):at.insertSection(e,t);return ni(t,r,xr(e)),t},oi=(e,n,t)=>{const o=qr(t),r=at.insertNode(ie,o,n);return ni(o,r,e),o},ri=e=>ii(ie,e),ii=(e,n)=>{Lo.current=document.activeElement??null,wt&&(Vt.current=Dt.current,Dt.current=!1,zt()),Lt(null===n?null:{zone:e,index:n}),Et(!0),ut||(Vt.current=!0,Fn({type:"setUi",ui:{leftSideBarVisible:!0}}))},li=()=>{Et(!1),Lt(null),Vt.current&&Fn({type:"setUi",ui:{leftSideBarVisible:!1}}),Vt.current=!1},si=(e,n,t)=>{if("section"===e.kind)at.insertComponent(n,e.type,t);else{if("template"!==e.kind)return;at.insertNode(n,t,i(e.template.node))}Yt(W),at.select({index:t,zone:n})},di=e=>n=>{n.target.closest(".es-tree-select")||e()},ci=()=>ao.editPinnedSource?.(),ai=(e,n,t)=>{const o=Cr(e)[n];return o&&!le(Wn,o.type).delete?null:/* @__PURE__ */gn(Be,{kind:"delete",label:`Delete ${t}`,onClick:()=>((e,n)=>{const t=Cr(e)[n]?.props?.id;null!=t&&Sr.remove(String(t))})(e,n),children:/* @__PURE__ */gn(en,{size:15})})},pi=e=>vo.rowPreview?.(e)||void 0,ui=e=>vo.rowMarks?.(e)??void 0,fi=(e,n,t)=>vo.rowActions?.(e,n,t)??null,hi=(e,n,t,o)=>{const r=Boolean(t.props._hidden);/* @__PURE__ */
|
|
14
|
-
return gn(Be,{kind:"eye",label:r?`Show ${o}`:`Hide ${o}`,onClick:()=>gi(e,n,t),children:/* @__PURE__ */gn(g,r?{name:"eye-off",size:14}:{name:"eye",size:14})})},mi=e=>{const n=xr(mr[e]?.type??""),t=n?ot.addSectionBefore({name:n}):ot.addSectionHere;return fl(ie,e,()=>ri(e),t)},gi=(e,n,t)=>{at.replaceComponent(e,n,{...t,props:{...t.props,_hidden:!t.props._hidden}})},yi=e=>ce(Wn,e),ki=e=>de(Wn,e),Si=e=>fo.slotsOf?$r(e).map(n=>({slot:n.slot,rung:n.rung?n:null,kids:ae(e,n.slot)})):[{slot:null,rung:null,kids:ki(e)}],vi=e=>fo.slotsOf?Si(e).flatMap(e=>e.kids):ki(e),bi=e=>Boolean(fo.slotsOf)&&$r(e).some(e=>e.rung),xi=(e,n,t)=>null===t?void 0===n?ko(e):ko(e,n):ko(e,n,t),wi=(e,n,t)=>{const o=pe(Wn,e.type,n)&&(t||vi(e).length>0||bi(e));return{collapsible:o,folded:o&&Vo(String(e.props.id))}},zi=(e,n,t)=>Si(e).flatMap(o=>{const r=o.rung?n+1:n,i=o.kids.flatMap(({child:e})=>wi(e,r,t(e.type)).collapsible?[String(e.props.id),...zi(e,r+1,t)]:[]);return o.rung?[`${e.props.id}:${o.rung.slot}`,...i]:i}),Bi=e=>vi(e).length>0||bi(e)||Boolean(ko(e.type)),Ci=e=>Boolean(ko(e)),Ni=(e,n,t,o)=>{if(Yt(W),ko(o)?.spec?.slider){const t=e.split(":")[0];p(t,n),at.select({index:n,zone:e}),a(t)}else at.select({index:n,zone:e}),_r(t)},$i=(e,n,t,o,r)=>{const i=`${e}:${n}`;at.insertComponent(i,t,o),ko(r)?.spec?.slider?requestAnimationFrame(()=>{p(e,o),at.select({index:o,zone:i})}):at.select({index:o,zone:i})},Ii=(e,n,t)=>{at.insertComponent(e,n,t),Yt(W),at.select({index:t,zone:e})},Oi=cn(/* @__PURE__ */new Set);un(()=>{mr.forEach(e=>{const n=ko(e.type)?.spec;if(!n)return;const t=e.props.id;if(Oi.current.has(t))return;Oi.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(br)).forEach((e,t)=>at.seedChild(o,t,n.childType,e))})},[mr,at,br]);const Ti=cn(/* @__PURE__ */new Set);un(()=>{mr.forEach((n,t)=>{const o=n.props.id;if(Ti.current.has(o))return;const r=e(n,yi(n.type));Ti.current.add(o),r&&at.replaceComponent(ie,t,{...n,props:r})})},[mr,at]),q(at,Wn);const Pi=mr.findIndex(et),Ai=Pi>=0?mr[Pi]:null,Ri=nt?mr.findIndex(qn):-1,ji=Ri>=0?mr[Ri]:null,Mi=mr.find(e=>e.type===Yn)??null,Ei=mr.find(e=>e.type===Qn)??null,Vi=Pi>=0?Pi:mr.length,Di=[];mr.forEach(e=>{et(e)||(Bi(e)&&Di.push(String(e.props.id)),Di.push(...zi(e,1,Ci)))}),Ai&&(Di.push(String(Ai.props.id)),Di.push(...zi(Ai,1,Ci)));const Fi=Di.length>0&&Di.every(e=>To.has(e)),Li=e=>{const n=vo.blockRowName(e,vr);return vo.rowName?vo.rowName(e,"block",n):n},Gi=(e,n,t,o)=>{const r=Cr(e)[t];if(!r)return;const i={...sn(e),index:t},l={...sn(n),index:Math.min(Math.max(o,0),Cr(n).length)},s=Ye(i,l);if(e!==n||s!==t)try{Sr.move(String(r.props.id),{...l,index:s})}catch(e){if(!(e instanceof dn))throw e}},Hi=e=>{const n=/* @__PURE__ */new Set,t=e=>{for(const{child:o,zone:r}of ki(e))n.add(r),t(o)};for(const t of yi(e.type))n.add(`${e.props.id}:${t}`);return t(e),n},Wi=e=>{let n=e.slice(0,e.indexOf(":"));for(let e=0;e<64;e++){const e=zr.get(n);if(!e)return null;if(e.zone===ie)return n;n=e.zone.slice(0,e.zone.indexOf(":"))}return null},Ui=e=>{const n=e.slice(0,e.indexOf(":")),t=mr.find(e=>Kn(e.type)&&String(e.props.id)===n);return t&&Zn(n)===e?t:null},Ji=(e,n,t)=>{if(e.rung){const t=Nr(e.rung.nodeId),o=t?$r(t).filter(e=>e.rung).length:0;return n.parentId===e.rung.nodeId&&n.slot===bn&&n.index>=0&&n.index<=o}if(n.slot===bn)return!1;if(e.add)return Ki(e.add,n);const o=on(n);if(Kn(e.type))return!1;const r=Ui(o),i=Ui(e.zone);if(r||i)return!(!r||!i)&&(n.index>=0&&n.index<=Cr(o).length);if(e.zone===ie||o===ie){if(e.zone!==o)return!1;const{floor:t,cap:r}=gr();return n.index>=t&&n.index<=r}if(n.index<0||n.index>Cr(o).length)return!1;if(e.zone===o)return!0;const l=Ai?String(Ai.props.id):null;return(!l||Wi(e.zone)!==l&&Wi(o)!==l)&&((e,n,t,o)=>{if(e===n)return!0;const r=o??Cr(e)[t];if(!r)return!1;const i=n.split(":")[0],l=zr.get(i),s=l?Cr(l.zone)[l.index]:void 0;if(!s)return!1;if(!o&&Hi(r).has(n))return!1;const d=ko(s.type,go(Dn?.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?.(Cr(n),r))})(e.zone,o,e.index,t)},Yi=(e,n)=>{const t=on(e.from);if(t===on(n))return!0;const o=e.node;return Ji({id:String(o.props?.id??""),zone:t,index:-1,type:o.type},n,o)},Qi=e=>{const n=e.slice(0,e.indexOf(":")),t=zr.get(n),o=t?Cr(t.zone)[t.index]:void 0;if(!t||!o)return null;const r=ko(o.type,go(Dn?.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:vr(r.spec.childType)}]:[]),l=Ir(e);return{parent:o,parentId:n,target:r,choices:i,parentName:l?l.slot.label:t.zone===ie?xr(o.type):vr(o.type)}},Ki=(e,n)=>{const t=on(n);if("block"!==e.kind){if(Ui(t))return n.index>=0&&n.index<=Cr(t).length;if(t!==ie)return!1;const{floor:e,cap:o}=gr();return n.index>=e&&n.index<=o}if(t===ie)return!1;const o=Qi(t);return!(!o||!o.choices.some(n=>n.type===e.type))&&!o.target.spec?.addBlocked?.(Cr(t))},Zi=(e,n)=>{e.rung?Rr(e.rung.nodeId,e.index,n.index):e.add?((e,n)=>{if("block"!==e.kind&&Ui(on(n)))return void si(e,on(n),n.index);if("section"===e.kind)return void ti(e.type,n.index);if("template"===e.kind)return void oi(e.template.name,i(e.template.node),n.index);const t=on(n),o=Qi(t);o&&(o.target.spec?$i(o.parentId,o.target.slot,e.type,n.index,o.parent.type):Ii(t,e.type,n.index))})(e.add,n):e.zone===ie?ei(e.index,n.index):Gi(e.zone,on(n),e.index,n.index)},[_i]=pn(()=>Ue()),Xi=Je({keyOf:e=>e.id,readOnly:Boolean(Pn),session:_i,canDrop:Ji,onDrop:Zi,onStep:(e,n)=>{e.rung?Rr(e.rung.nodeId,e.index,n<0?e.index-1:e.index+2):e.zone===ie?((e,n)=>{const t=xr(mr[e]?.type??""),o=ei(e,n<0?e-1:e+2);if(!o.moved)return void Qo(`“${t}” is already ${n<0?"first":"last"}`);const{floor:r,cap:i}=gr();Qo(`Moved “${t}” to position ${o.dest-r+1} of ${i-r}`)})(e.index,n):Gi(e.zone,e.zone,e.index,n<0?e.index-1:e.index+2)}}),qi=fn(e=>{const{floor:n,cap:t}=gr(),o=[];for(const r of e.nodes){const e=on(r.place),i=Cr(e)[r.place.index];if(!i||String(i.props.id)!==r.id)continue;if(qn(i)||et(i)||ho(i.type))continue;if(Kn(i.type))continue;const l=Boolean(Ui(e)),s=e===ie||l;e===ie&&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):Er(i),from:r.place})}return{sources:o,zones:e.zones.filter(e=>e.children.length>0||Boolean(Qi(on(e.list))?.choices.length)||Boolean(Ui(on(e.list))))}},[Dn.data]),el=e=>{Yt(W),at.select(e.zone===ie?{index:e.index}:{index:e.index,zone:e.zone})},nl=ee(),tl=()=>({data:Dn.data,device:St,ops:at,inspector:co}),ol=nl?.model,rl=an(()=>ol?e=>ol(e,qi(e),tl()):qi,[ol,qi,St]),il=nl?.measure,ll=il?(e,n)=>il(e,n,tl()):void 0,sl=nl?.canDrop,dl=sl?(e,n)=>sl(e,n,Ji,tl()):Ji,cl=nl?.drop,al=cl?(e,n)=>cl(e,n,Zi,tl()):Zi,pl=nl?.pick,ul=pl?e=>pl(e,el,tl()):el,fl=(e,n,t,o)=>/* @__PURE__ */gn(Ce,{...Pn?{}:Xi.seam({place:{...sn(e),index:n}}),onAdd:Pn?void 0:t,label:o},`seam:${e}:${n}`),hl={rowClick:di,isCollapsed:Vo,toggleCollapse:Do},ml=e=>{const n=String(e.props.id),t=mr.findIndex(e=>String(e.props.id)===n),o=Zn(n),r=Cr(o),i=Vo(n),l=vr(e.type),s=vo.rowName?vo.rowName(e,"section",l):l,d=e=>fl(o,e,()=>ii(o,e),ot.addSectionHere);/* @__PURE__ */
|
|
15
|
-
return yn(kn,{children:[
|
|
16
|
-
/* @__PURE__ */gn(be,{icon:/* @__PURE__ */gn(xo,{type:e.type,size:13}),name:s,preview:pi(e),marks:ui(e),onSelect:()=>Xr(t),nameSlot:Dr(ie,t,n,s),selected:qt===n,actions:fi(e,ie,t)??void 0,rowProps:{"data-node-id":n,onClick:di(()=>Xr(t))},fold:{open:!i,label:"section",onToggle:()=>Do(n)}}),!i&&/* @__PURE__ */yn(xe,{children:[r.map((n,t)=>{const r=String(n.props.id),i=wr(n),l=Bi(n),s=l&&Vo(r),c=()=>Ni(o,t,r,e.type),{rowProps:a,...p}=Xi.row({item:{id:r,zone:o,index:t,type:n.type},place:{...sn(o),index:t}},{"data-node-id":r,onClick:di(c)});/* @__PURE__ */
|
|
17
|
-
return yn(mn,{children:[d(t),
|
|
18
|
-
/* @__PURE__ */gn(be,{icon:/* @__PURE__ */gn(xo,{type:n.type,size:13}),name:i,preview:pi(n),marks:ui(n),onSelect:c,nameSlot:Dr(o,t,r,i),selected:qt===r,hidden:Boolean(n.props._hidden),...p,fold:l?{open:!s,label:"section",onToggle:()=>Do(r)}:void 0,actions:/* @__PURE__ */yn(kn,{children:[ai(o,t,i),fi(n,o,t),hi(o,t,n,i)]}),rowProps:a}),l&&!s&&/* @__PURE__ */gn(xe,{children:kl(n,2)})]},r)}),d(r.length)]})]})},gl=(e,n,t,o,r)=>{const i=String(e.props.id),l=`${i}:${n.slot}`,s=Xi.dragging,d=!Vo(l)&&s?.rung?.nodeId!==i,c={...sn(l),index:0},a=s&&!s.rung&&Ji(s,c)?c:void 0,p=()=>Pr(e,n,!0),{rowProps:u,...f}=Xi.row({item:{id:`rung:${l}`,zone:`${i}:${bn}`,index:t,type:e.type,rung:{nodeId:i,slot:n.slot}},place:{parentId:i,slot:bn,index:t},into:a,canDrag:Boolean(fo.moveSlot)&&!1!==n.movable&&o>1},{"data-slot-zone":l,onClick:di(p)}),h=Pn?null:fo.slotActions?.(e,n.slot);/* @__PURE__ */
|
|
19
|
-
return yn(mn,{children:[n.heading,
|
|
20
|
-
/* @__PURE__ */gn(be,{icon:n.glyph??null,name:n.label,badge:n.badge,onSelect:p,selected:Or===l,...f,dragHint:n.dragHint,fold:{open:d,label:n.label,onToggle:()=>Do(l)},actions:h&&h.length>0?/* @__PURE__ */gn(kn,{children:h.map((t,o)=>/* @__PURE__ */gn(Be,{kind:"delete"===t.kind?"delete":"plain",label:t.label,disabled:t.disabled,onClick:()=>((e,n,t)=>{if(Pn||t.disabled)return;const o=String(e.props.id),r=e=>{"string"==typeof e&&Ar(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__ */gn(en,{size:15}):/* @__PURE__ */gn(tn,{size:15})},`${o}:${t.kind}`))}):void 0,rowProps:u}),d&&/* @__PURE__ */gn(xe,{children:r})]},l)},yl=(e,n)=>{const t=Si(e),o=t.filter(e=>e.rung).length;let r=0;/* @__PURE__ */
|
|
21
|
-
return gn(kn,{children:t.map(t=>{const i=t.kids,l=t.rung?n+1:n,s=xi(e.type,void 0,t.slot),d=s?`${e.props.id}:${s.slot}`:null,c=null===t.slot?null:`${e.props.id}:${t.slot}`,a=null!==c&&Boolean(Qi(c)?.choices.length),p=(e,n)=>a?fl(e,n,()=>ii(e,n),"Add block here"):fl(e,n),u=/* @__PURE__ */yn(kn,{children:[i.map(({child:n,zone:t,index:o})=>{const r=qt===String(n.props.id),{collapsible:i,folded:s}=wi(n,l,Ci(n.type)),d=String(n.props.id),c=Li(n),a=()=>Ni(t,o,d,e.type),{rowProps:u,...f}=Xi.row({item:{id:d,zone:t,index:o,type:n.type},place:{...sn(t),index:o}},{"data-node-id":d,onClick:di(a)});/* @__PURE__ */
|
|
22
|
-
return yn(mn,{children:[0===o&&p(t,0),
|
|
23
|
-
/* @__PURE__ */gn(be,{icon:/* @__PURE__ */gn(xo,{type:n.type,size:13}),name:c,preview:pi(n),marks:ui(n),onSelect:a,nameSlot:Dr(t,o,d,c),selected:r,hidden:Boolean(n.props._hidden),...f,fold:i?{open:!s,label:"group",onToggle:()=>Do(d)}:void 0,actions:/* @__PURE__ */yn(kn,{children:[ai(t,o,c),fi(n,t,o),hi(t,o,n,c)]}),rowProps:u}),i&&!s&&/* @__PURE__ */gn(xe,{children:yl(n,l+1)}),p(t,o+1)]},String(n.props.id??`${t}-${o}`))}),null===c?d&&!i.some(e=>e.zone===d)?p(d,0):null:0!==i.length||!t.rung&&d!==c?null:p(c,0)]});return t.rung?gl(e,t.rung,r++,o,u):/* @__PURE__ */gn(mn,{children:u},t.slot??"")})})},kl=(e,n)=>{const t=go(Dn?.data,e.type,String(e.props.id)),o=Si(e),r=o.filter(e=>e.rung).length;let i=0;/* @__PURE__ */
|
|
24
|
-
return gn(kn,{children:o.map(o=>{const l=o.kids,s=o.rung?n+1:n,d=xi(e.type,t,o.slot),c=d?.spec??null,a=c&&Array.isArray(e.props[c.slot])?e.props[c.slot]:[],p=d&&d.choices?{slot:d.slot,choices:d.choices}:null,u=String(e.props.id),f=c&&!c.fixed?`${u}:${c.slot}`:null,h=p?`${u}:${p.slot}`:null,m=(n,t)=>{const o=n===f&&c&&!c.addBlocked?.(a)?()=>$i(e.props.id,c.slot,c.childType,t,e.type):n===h?()=>ii(n,t):void 0;return fl(n,t,o,n===f&&c?c.addLabel:"Add block here")},g=null===o.slot?null:`${u}:${o.slot}`,y=Boolean(c&&!c.fixed&&(null===g||g===f)),k=/* @__PURE__ */yn(kn,{children:[l.map(({child:n,zone:t,index:o})=>{const r=qt===String(n.props.id),i=Er(n),l=String(n.props.id),{collapsible:d,folded:c}=wi(n,s,Ci(n.type)),a=yi(n.type),p=1===a.length?`${l}:${a[0]}`:null,u=p?{...sn(p),index:Cr(p).length}:void 0,f=Xi.dragging,h=u&&f&&Ji(f,u)?u:void 0,g=()=>Ni(t,o,l,e.type),{rowProps:y,...k}=Xi.row({item:{id:l,zone:t,index:o,type:n.type},place:{...sn(t),index:o},into:h,canDrag:!ho(n.type)},{"data-node-id":l,onClick:di(g)});/* @__PURE__ */
|
|
25
|
-
return yn(mn,{children:[0===o&&m(t,0),
|
|
26
|
-
/* @__PURE__ */gn(be,{icon:/* @__PURE__ */gn(xo,{type:n.type,size:13}),name:i,preview:pi(n),marks:ui(n),onSelect:g,nameSlot:Dr(t,o,l,i),selected:r,hidden:Boolean(n.props._hidden),...k,fold:d?{open:!c,label:"group",onToggle:()=>Do(l)}:void 0,actions:ho(n.type)?fi(n,t,o)??void 0:/* @__PURE__ */yn(kn,{children:[ai(t,o,i),fi(n,t,o),hi(t,o,n,i)]}),rowProps:y}),d&&!c&&/* @__PURE__ */gn(xe,{children:kl(n,s+1)}),m(t,o+1)]},String(n.props.id??`${t}-${o}`))}),y&&c&&
|
|
27
|
-
/* @__PURE__ */gn(I,{small:!0,label:c.addLabel,blocked:c.addBlocked?.(a)??null,onAdd:()=>$i(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?gl(e,o.rung,i++,r,k):/* @__PURE__ */gn(mn,{children:k},o.slot??"")})})},Sl=(()=>{if(!Gn||!Qt)return null;const e=String(Gn.type),n=String(Gn.props.id),t=ko(e,go(Dn?.data,e,n));if(!t||"footer"===t.source)return null;const o=mr.some(e=>String(e.props?.id)===n),r=Array.isArray(Gn.props[t.slot])?Gn.props[t.slot]:[];if(t.spec?.addBlocked?.(r))return null;const i=t.choices??(t.spec?[{type:t.spec.childType,label:vr(t.spec.childType)}]:[]);return 0===i.length?null:{parentName:o?xr(e):vr(e),choices:i,onPick:o=>{t.spec?$i(n,t.slot,o,r.length,e):Ii(`${n}:${t.slot}`,o,r.length)}}})(),vl=_t&&_t.zone!==ie&&!Ui(_t.zone)?_t.zone:null,bl=!0===Gt.blocksFirst,xl=vl?Qi(vl):bl&&_t?null:Sl,wl=Boolean(Ft&&vl)||bl&&Boolean(xl&&xl.choices.length>0),zl=Mt||null!==wt,Bl=e=>"panel"in e?{id:e.id,label:e.label,icon:e.icon,active:ut&&!zl&&uo===e.id,onSelect:()=>pr(e.id)}:e,Cl=[{id:"add",label:ot.add.title,icon:/* @__PURE__ */gn("span",{className:"sf-rail-plus","aria-hidden":"true",children:"+"}),active:Mt,onSelect:()=>Mt?li():ri(null)},...(ao.railLead??[]).map(Bl),{id:"sections",label:"Layers",icon:/* @__PURE__ */gn(_e,{}),active:ut&&!zl&&"sections"===uo,onSelect:()=>pr("sections")},...(ao.railTrail??[]).map(Bl)];xt?Cl.push({id:"media",label:"Media library",icon:/* @__PURE__ */gn(nn,{}),active:ut&&!Mt&&(null!==wt||"media"===uo),onSelect:()=>pr("media")}):Mn&&Cl.push({id:"media",label:"Media library",icon:/* @__PURE__ */gn(nn,{}),onSelect:ur});const Nl=[...ao.railLead??[],...ao.railTrail??[]].find(e=>"panel"in e&&e.id===uo),$l=Boolean(tt?.foldable)&&!po,Il=tt?.label??(En?ot.pageSections:ot.templateSections),Ol=$l&&Vo(xn),Tl=/* @__PURE__ */yn(kn,{children:[mr.map((e,n)=>{if(qn(e)||et(e)||Kn(e.type))return null;const t=qt===String(e.props.id),o=Boolean(e.props._hidden);ki(e);const r=String(e.props.id),i=ao.hasOwnRows?.(e)??!1,l=Bi(e)||i,s=l&&Vo(r),{rowProps:d,...c}=Xi.row({item:{id:r,zone:ie,index:n,type:e.type},place:{...sn(ie),index:n}},{"data-node-id":r,onClick:di(()=>Xr(n))});/* @__PURE__ */
|
|
28
|
-
return yn(mn,{children:[n>0&&mi(n),
|
|
29
|
-
/* @__PURE__ */gn(be,{icon:/* @__PURE__ */gn(xo,{type:e.type,size:13}),name:wr(e),preview:pi(e),marks:ui(e),onSelect:()=>Xr(n),nameSlot:Dr(ie,n,r,wr(e)),selected:t,hidden:o,...c,fold:l?{open:!s,label:"section",onToggle:()=>Do(r)}:void 0,actions:/* @__PURE__ */yn(kn,{children:[ai(ie,n,wr(e)),fi(e,ie,n),hi(ie,n,e,wr(e))]}),rowProps:d}),Bi(e)&&!s&&/* @__PURE__ */yn(xe,{children:[kl(e,1),ao.partRows?.(e,hl)]}),i&&!s&&/* @__PURE__ */gn(xe,{children:ao.ownRows?.(e,n,hl)})]},String(e.props.id??n))}),!po&&Vi>0&&mi(Vi),tt?.addAtEnd&&!po&&!Pn&&/* @__PURE__ */gn(I,{small:!0,label:ot.addSection,blocked:null,onAdd:()=>ri(Vi)})]}),Pl=(e,n,t)=>{const o=String(e.props.id),r=vi(e).length>0||bi(e)||Boolean(ko(e.type)),i=r&&Vo(o),l="header"===t?ot.header:ot.footer,s=vo.rowName?vo.rowName(e,"section",l):l;/* @__PURE__ */
|
|
30
|
-
return yn(kn,{children:[
|
|
31
|
-
/* @__PURE__ */gn(be,{icon:/* @__PURE__ */gn(xo,{type:t,size:13}),name:s,preview:pi(e),marks:ui(e),onSelect:()=>Xr(n),nameSlot:Dr(ie,n,o,s),selected:qt===String(e.props.id),fold:r?{open:!i,label:"section",onToggle:()=>Do(o)}:void 0,actions:fi(e,ie,n)??void 0,rowProps:{onClick:di(()=>Xr(n))}}),r&&!i&&/* @__PURE__ */gn(xe,{children:yl(e,1)})]})};return(ao.wrap??(e=>e))(
|
|
32
|
-
/* @__PURE__ */gn(ne,{target:Rt,children:/* @__PURE__ */yn("div",{ref:At,className:"sf-editor es-editor",style:Fe(Ao),onContextMenu:Ur.onEditorContextMenu,children:[
|
|
33
|
-
/* @__PURE__ */yn(Oe,{children:[
|
|
34
|
-
/* @__PURE__ */gn(Te,{items:Cl,ariaLabel:"Left panel views"}),
|
|
35
|
-
/* @__PURE__ */yn(Pe,{children:[
|
|
36
|
-
/* @__PURE__ */gn(Ae,{label:"Undo",disabled:!Ln.hasPast,onClick:()=>Ln.back(),children:/* @__PURE__ */gn(Xe,{})}),
|
|
37
|
-
/* @__PURE__ */gn(Ae,{label:"Redo",disabled:!Ln.hasFuture,onClick:()=>Ln.forward(),children:/* @__PURE__ */gn(qe,{})}),
|
|
38
|
-
/* @__PURE__ */gn(Re,{}),
|
|
39
|
-
/* @__PURE__ */gn(je,{devices:ht,value:St,onChange:vt})]}),
|
|
40
|
-
/* @__PURE__ */yn(Pe,{kind:"right",style:{minWidth:300},children:[
|
|
41
|
-
/* @__PURE__ */gn(Sn,{saveState:$n,notSaving:Boolean(Pn)||null!=In,readOnlyReason:An,toggle:Rn,onToggle:Tn,onRetry:On}),ao.barLead?.(),
|
|
42
|
-
/* @__PURE__ */gn("button",{type:"button",className:"es-btn-ghost",title:"Refresh the preview (reloads the canvas, keeps your place)",onClick:()=>{Pt.current=(()=>{const e=Rt?.document;if(!e)return null;const n=mr.findIndex(et),t=n>=0?n:mr.length;let o=null;for(let n=0;n<t;n++){const t=mr[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=Gn?.props?.id??mr[0]?.props?.id;null!=e&&(o={id:String(e),offset:0})}return o})(),Tt(e=>e+1)},children:"Refresh"}),ao.barTrail?.(),ao.barMain?ao.barMain():/* @__PURE__ */gn("button",{type:"button",className:"es-btn-primary",disabled:null!==An,onClick:()=>{Nn(Dn.data)},children:ot.done})]})]}),
|
|
43
|
-
/* @__PURE__ */gn(z,{}),
|
|
44
|
-
/* @__PURE__ */yn("div",{className:"sf-body",children:[ut?/* @__PURE__ */yn(kn,{children:[
|
|
45
|
-
/* @__PURE__ */gn("div",{className:"es-sidepanel es-sidepanel--left sf-panel sf-panel--left",children:Mt?/* @__PURE__ */gn(O,{blocks:xl,blocksOnly:wl,at:Ft?{label:(e=>{const n=Ui(e.zone);if(n)return ot.add.addingTo({name:vr(n.type)});if(e.zone===ie){const n=mr[e.index];return n&&!et(n)?ot.add.addingBefore({name:xr(n.type)}):ot.add.addingAtEnd}const t=Qi(e.zone);return t?ot.add.addingTo({name:t.parentName}):ot.add.addingHere})(Ft),onClear:()=>Lt(null)}:void 0,onAdd:e=>{const n=_t,t=(e,n)=>{Ft&&Lt({zone:e,index:n})};if(n&&"block"!==e.kind&&Ui(n.zone))return si(e,n.zone,n.index),void t(n.zone,n.index+1);if("section"===e.kind)return(e=>{if(null===Xt)return void ti(e);const n=ti(e,Xt);Ft&&Ht(n+1)})(e.type);if("template"===e.kind)return((e,n)=>{if(null===Xt)return void oi(e,n);const t=oi(e,n,Xt);Ft&&Ht(t+1)})(e.template.name,i(e.template.node));if(n&&n.zone!==ie){const o=Qi(n.zone);if(!o)return;return o.target.spec?$i(o.parentId,o.target.slot,e.type,n.index,o.parent.type):Ii(n.zone,e.type,n.index),void t(n.zone,n.index+1)}Sl?.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:_i,siteWide:ao.addPanelRow?.(li),onClose:li,onHide:cr,readOnly:Boolean(Pn)}):wt&&bt?
|
|
46
|
-
/* @__PURE__ */gn(A,{panel:bt,pick:wt,onHide:cr}):Nl?Nl.panel({onHide:cr,notify:Qo}):"media"===uo&&bt?/* @__PURE__ */gn(A,{panel:bt,pick:null,onHide:cr}):/* @__PURE__ */yn(kn,{children:[
|
|
47
|
-
/* @__PURE__ */gn(T,{icon:/* @__PURE__ */gn(_e,{}),title:"Layers",context:rt,actions:Di.length>0?/* @__PURE__ */gn(Me,{label:Fi?"Expand all sections":"Collapse all sections",onClick:()=>Po(e=>{const n=new Set(Di);return Fi?new Set([...e].filter(e=>!n.has(e))):/* @__PURE__ */new Set([...e,...Di])}),children:/* @__PURE__ */gn(vn,{expand:Fi})}):void 0,onHide:cr}),
|
|
48
|
-
/* @__PURE__ */yn(we,{className:"sf-tree sf-scroll",children:[
|
|
49
|
-
/* @__PURE__ */gn(be,{icon:/* @__PURE__ */gn(xo,{type:"page",size:13}),name:ot.pageSettings,onSelect:fr,selected:!Gn&&Qt,rowProps:{onClick:di(fr)}}),Mi&&/* @__PURE__ */yn(kn,{children:[
|
|
50
|
-
/* @__PURE__ */gn(ze,{children:ot.header}),ml(Mi)]}),!po&&Vn&&/* @__PURE__ */yn(kn,{children:[
|
|
51
|
-
/* @__PURE__ */gn(ze,{children:ot.header}),!nt&&/* @__PURE__ */gn(be,{icon:/* @__PURE__ */gn(xo,{type:"header",size:13}),name:ot.header,onSelect:hr,selected:Jt.kind===Xn?.kind,rowProps:{onClick:di(hr)}})]}),!po&&ji&&Pl(ji,Ri,"header"),!po&&!$l&&/* @__PURE__ */gn(ze,{children:Il}),$l?/* @__PURE__ */yn(kn,{children:[
|
|
52
|
-
/* @__PURE__ */gn(be,{icon:null,name:Il,fold:{open:!Ol,label:Il,onToggle:()=>Do(xn)}}),!Ol&&/* @__PURE__ */gn(xe,{children:Tl})]}):Tl,Vn&&/* @__PURE__ */gn(ze,{children:ot.footer}),Ai&&Pl(Ai,Pi,"footer"),!po&&!Ai&&Vn&&/* @__PURE__ */gn(be,{icon:/* @__PURE__ */gn(xo,{type:"footer",size:13}),name:ot.footer,onSelect:ci,rowProps:{onClick:di(ci),title:"Edit the site footer"}}),Ei&&ml(Ei),ao.treeFoot?.()]})]})}),
|
|
53
|
-
/* @__PURE__ */gn(Ee,{side:"left",width:Ao.left,min:De,max:Ve,defaultWidth:y.left,label:"Resize Sections panel",onResize:Mo})]}):/* @__PURE__ */gn(P,{side:"left",onShow:cr}),
|
|
54
|
-
/* @__PURE__ */yn("div",{ref:Ko,className:"sf-center sf-scroll","data-sf-canvas-head":er?"":void 0,style:{overflowX:lr?"auto":"hidden",overflowY:"hidden"},children:[er&&/* @__PURE__ */gn("div",{ref:nr,className:"sf-canvas-head",children:/* @__PURE__ */gn(er,{device:St})}),
|
|
55
|
-
/* @__PURE__ */gn("div",{className:"sf-frame-scaler",style:sr,children:/* @__PURE__ */gn("div",{className:"sf-frame "+(St===yt?"":`sf-frame--${St}`),style:dr,children:/* @__PURE__ */yn("div",{className:"sf-preview-host",children:[
|
|
56
|
-
/* @__PURE__ */gn(it,{},Ot),
|
|
57
|
-
/* @__PURE__ */gn(We,{canvas:Rt,session:_i,model:rl,measure:ll,canDrop:dl,onDrop:al,onPick:ul,onZoneAdd:e=>ii(on(e),0),readOnly:Boolean(Pn),revision:Dn.data}),Wt.length>0&&/* @__PURE__ */gn("div",{className:"sf-preview-gaps","aria-hidden":"true",children:Wt.map(e=>/* @__PURE__ */yn("button",{type:"button",tabIndex:-1,className:"sf-preview-gap",style:{top:e.top},title:"Add section here",onClick:()=>ri(e.index),children:[
|
|
58
|
-
/* @__PURE__ */gn("span",{className:"sf-preview-gap-line"}),
|
|
59
|
-
/* @__PURE__ */yn("span",{className:"sf-preview-gap-pill",children:[
|
|
60
|
-
/* @__PURE__ */gn("span",{className:"sf-preview-gap-plus",children:"+"}),
|
|
61
|
-
/* @__PURE__ */gn("span",{className:"sf-preview-gap-label",children:"Add section"})]})]},e.index))})]})})})]}),ft?/* @__PURE__ */yn(kn,{children:[
|
|
62
|
-
/* @__PURE__ */gn(m,{value:{selectChild:Ni,addChild:$i,childRowName:Er,blockRowName:Li},children:/* @__PURE__ */gn(lt,{mode:Jt,onOpenWebsiteSettings:ao.openSettings??(()=>{}),onOpenSiteStyles:ao.openStyles,onSelectNode:Co,onNotify:Qo,onHidePanel:ar,nodeActions:Gn?le(Wn,Gn.type):wn})}),
|
|
63
|
-
/* @__PURE__ */gn(Ee,{side:"right",width:Ao.right,min:De,max:Ve,defaultWidth:y.right,label:"Resize settings panel",onResize:Eo})]}):
|
|
64
|
-
/* @__PURE__ */gn(P,{side:"right",onShow:ar})]}),Ho&&/* @__PURE__ */yn("div",{className:"sf-toast "+("error"===Ho.tone?"sf-toast--error":""),role:"status",children:[
|
|
65
|
-
/* @__PURE__ */gn("span",{className:"sf-toast-check","aria-hidden":"true",children:"error"===Ho.tone?"!":"✓"}),Ho.msg]},Uo),Ur.menu]})}))}export{zn as ScreenChrome};
|
package/dist/chunk-IE4GFYKO.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{newNodeId as t}from"./chunk-PLVEGYK6.js";function o(t){return{root:{props:{}},content:[t],zones:{}}}function n(t){return(t.content??[])[0]??null}function r(t){return Array.isArray(t)&&t.length>0&&t.every(t=>!!t&&"object"==typeof t&&"string"==typeof t.type&&"object"==typeof t.props)}function e(o){const n={...o.props,id:t(o.type)};for(const[t,o]of Object.entries(n))r(o)&&(n[t]=o.map(e));return{type:o.type,props:n}}export{e as cloneNodeWithFreshIds,n as docToNode,o as nodeToDoc};
|
package/dist/chunk-N7VRF7PR.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{blockTypesIn as e}from"./chunk-5ZBY24K7.js";import{buildPaletteSections as t,pinnedSection as n,paletteWithoutPinned as o,categoryLabel as i}from"./chunk-PA3PNTVV.js";import{sectionTemplatesOf as s}from"./chunk-BVN33R76.js";import{SidePanelHead as r,PanelModeExit as c}from"./chunk-5ZBBXZPV.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-VSHV6KJQ.js";import{DEFAULT_SCREEN_WORDS as d}from"./chunk-PQXIFBDY.js";import{useEasel as u}from"./chunk-P67FP7PG.js";import{useWords as f}from"./chunk-MFIRYGHW.js";import{AddPanel as h}from"./chunk-TTJ54QGG.js";import{AddIcon as k}from"./chunk-L5KW4HG5.js";import{useState as y,useEffect as b,useMemo as j}from"react";import{jsx as g,jsxs as B,Fragment as V}from"react/jsx-runtime";var $=e=>`section:${e}`,v=e=>`block:${e}`,O=e=>`template:${e}`;function P({blocks:P,blocksOnly:x,at:H,onAdd:I,itemFor:F,session:G,siteWide:L,onClose:Q,onHide:T,readOnly:A}){const D=u(e=>e.config),N=p(),{labelAtLevel:C,categoryLabel:J,firstSection:K,Icon:R,Thumbnail:S}=N,{blockIsOffered:W}=m(),Y=f("screen",d).add,Z=l(),[w,z]=y([]);b(()=>{let t=!1;const n=e=>W(e,Z);return s(Z).list().then(o=>{if(t)return;const i=D.components;z(o.filter(t=>t.node?.type&&i[t.node.type]&&e(t.node).every(n)))}).catch(()=>{}),()=>{t=!0}},[D,Z]);const X=j(()=>t(D,N),[D]),E=e=>({type:$(e.type),label:e.name,cover:/* @__PURE__ */g(S,{type:e.type}),title:e.desc?`${e.name} — ${e.desc}`:Y.tile({name:e.name}),keywords:[e.alias??"",e.desc,e.type,e.catLabel].filter(Boolean)}),M=j(()=>{const e=[];if(P&&P.choices.length>0&&a(P.choices).forEach((t,n)=>{e.push({title:0===n?`${Y.inside({name:P.parentName})}${t.group?` · ${t.group}`:""}`:t.group??"",tiles:t.items.map(e=>({type:v(e.type),label:e.label,icon:/* @__PURE__ */g(R,{type:e.type,size:18}),title:Y.tile({name:e.label})}))})}),x)return e;const t=n(X,K);t&&e.push({title:Y.startBlank,tiles:[E(t)]}),w.length>0&&e.push({title:Y.templates,tiles:w.map(e=>{return{type:O(e.id),label:e.name,cover:/* @__PURE__ */g(S,{type:e.node.type}),keywords:[(t=e.node.type,C(t,"section",D.components[t]?.label??t)),e.node.type]};var t})});const s=o(X,K);for(const t of Object.keys(D.categories??{})){const n=s.filter(e=>e.cat===t);0!==n.length&&e.push({title:i(D,t,J),tiles:n.map(E)})}return e},[P,x,w,X,D,Y]),q=e=>{const t=e.indexOf(":"),n=e.slice(0,t),o=e.slice(t+1);if("section"===n)return{kind:"section",type:o};if("block"===n)return{kind:"block",type:o};if("template"===n){const e=w.find(e=>e.id===o);return e?{kind:"template",template:e}:null}return null};/* @__PURE__ */
|
|
2
|
-
return B(V,{children:[
|
|
3
|
-
/* @__PURE__ */g(r,{icon:/* @__PURE__ */g(k,{size:15}),title:Y.title,context:x?Y.contextBlocks:Y.contextAll,actions:/* @__PURE__ */g(c,{label:Y.done,description:Y.doneDescription,onClick:Q}),onHide:T}),
|
|
4
|
-
/* @__PURE__ */B("div",{className:"sf-addside sf-scroll",children:[
|
|
5
|
-
/* @__PURE__ */g(h,{groups:M,session:G,itemFor:e=>F(q(e)??{kind:"section",type:e}),onInsert:e=>{const t=q(e);t&&I(t)},at:H,hint:x?Y.hintBlocks:Y.hint,searchLabel:x?Y.searchBlocks:Y.searchSections,readOnly:A}),L&&!x?L:null]})]})}export{P as AddSidePanel,v as blockKey,$ as sectionKey,O as templateKey};
|
package/dist/chunk-P67FP7PG.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import{DEFAULT_CANVAS_WORDS as e}from"./chunk-AELNNAFM.js";import{useResolvedFields as t}from"./chunk-YRLPFZW3.js";import{toItemSelector as n,fromItemSelector as o,useNodeOps as r}from"./chunk-D2BCHTQR.js";import{useWords as a}from"./chunk-MFIRYGHW.js";import{setCanvasNonce as i}from"./chunk-ZNCEOSXO.js";import{find as s,ROOT_ID as d,getList as l,remove as c,parseZoneKey as u,move as p,duplicate as f,replaceNode as h,createNode as m,insert as v,normalizeData as y,createResolveCache as g,resolveNodeData as k,ROOT_SLOT as b}from"./chunk-KRXQM65X.js";import{topLevelSlotKeys as w,fieldsFrom as S,defaultsFrom as I}from"./chunk-NKB3KVAB.js";import{createContext as C,useEffect as O,useContext as x,useRef as E,useSyncExternalStore as A,useState as D,useMemo as z,useCallback as M,useLayoutEffect as Z}from"react";import{jsx as N,jsxs as $}from"react/jsx-runtime";import{createPortal as j}from"react-dom";function R(e){return!["setData","setUi","set"].includes(e.type)}var B=(e,t,n,o)=>{const r=l(e,t,u(n));return r?.[o]??null},P=(e,t,n,o,r)=>{const a=B(e,t,n,o);if(!a)throw new Error(`${r}: nothing at ${n}[${o}]`);return a};function L(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 K(e,t,n){return n?"node"===n.kind?s(e,t,n.id)?n:null:n.parentId===d?l(e,t,n)?n:null:s(e,t,n.parentId)&&l(e,t,n)?n:null:null}function F(e,t,n,r=!1){const{itemSelector:a,selectedSlot:i,...s}=n;let d=e.selection;var l;return"itemSelector"in n&&(d=o(e.data,t,a??null)),"selectedSlot"in n&&(i?d=(l=i)?{kind:"slot",parentId:l.parentId,slot:l.slot}:null:"slot"===d?.kind&&(d=null)),{...e,selection:d,ui:r?s:{...e.ui,...s}}}function H(e,t,n){const o=V(e,t,n);if(o===e)return e;const r=K(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function V(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 F(e,n,"function"==typeof t.ui?t.ui(L(e,n)):t.ui);case"set":{const r={data:o,ui:L(e,n)},a="function"==typeof t.state?t.state(r):t.state;let i=a.data?{...e,data:a.data}:e;return a.ui&&(i=F(i,n,a.ui,!0)),i}case"insert":{const r={...u(t.destinationZone),index:t.destinationIndex},a=m(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:v(o,n,r,a)}}case"replace":{const r=P(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:h(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=P(o,n,t.sourceZone,t.sourceIndex,"duplicate"),a=f(o,n,r.props.id),i=B(a,n,t.sourceZone,t.sourceIndex+1);return{...e,data:a,selection:i?{kind:"node",id:i.props.id}:e.selection}}case"reorder":return V(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=B(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const a={...u(t.destinationZone),index:t.destinationIndex};return{...e,data:p(o,n,r.props.id,a)}}case"remove":{const r=P(o,n,t.zone,t.index,"remove");return{...e,data:c(o,n,r.props.id)}}default:return e}}var T={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},q={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},Y=0,U=()=>`history-${Y+=1}`;function W(e){let t=e.config;const r=e.now??(()=>Date.now()),a=e.historyCoalesceMs??250;let i=e.permissions??{};const d=y(e.data,t);let c={data:d,selection:null,ui:{...q}};if(e.ui){const{itemSelector:n,selectedSlot:r,...a}=e.ui;c={data:d,selection:r?{kind:"slot",...r}:o(d,t,n??null),ui:{...q,...a}}}let u=[{core:c,at:-1/0,sealed:!0,id:U()}],p=0;const f=e=>{const t=u[p],n=r();!e&&p===u.length-1&&p>0&&!t.sealed&&n-t.at<a?u=[...u.slice(0,p),{...t,core:c,at:n}]:(u=[...u.slice(0,p+1),{core:c,at:n,sealed:e,id:U()}],p=u.length-1)},m=/* @__PURE__ */new Set;let v=null,b=null,w=0,S=null,I=!1;const C=()=>{for(const e of[...m])e()},O=()=>{u=[...u.slice(0,p),{...u[p],core:c},...u.slice(p+1)]},x=(t,n)=>{w>0?I=I||n:(n?f(!1):c!==t&&O(),c.data!==t.data&&e.onChange?.(c.data),c!==t&&C())},E=e=>{const n=c;if(c=H(c,e,t),c===n)return;const o=e.recordHistory??R(e);x(n,o&&c.data!==n.data)},A=t=>{0===w&&(S=c,I=!1),w+=1;try{t()}catch(e){throw w-=1,0===w&&S&&(c=S,S=null),e}if(w-=1,w>0||!S)return;const n=S;S=null,I&&c.data!==n.data?f(!0):c!==n&&O(),c.data!==n.data&&e.onChange?.(c.data),c!==n&&C()},D=e=>{const n=c,o=K(c.data,t,e);var r,a;(r=o,a=c.selection,r===a||r&&a&&r.kind===a.kind&&("node"===r.kind&&"node"===a.kind?r.id===a.id:"slot"===r.kind&&"slot"===a.kind&&r.parentId===a.parentId&&r.slot===a.slot))||(c={...c,selection:o},x(n,!1))},z=t=>{const n=c;p=t,c=u[p].core,c.data!==n.data&&e.onChange?.(c.data),c!==n&&C()},M=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...T,...i,...n}};let Z=M();const N=g(),$={resolveCache:N,async resolveAll({trigger:e="load",metadata:n}={}){const o=c.data,r={type:"root",props:{...o.root.props??{}}},a=[...o.content,...Object.values(o.zones??{}).flat()],[i,...d]=await Promise.all([k(r,t,{cache:N,trigger:e,metadata:n}),...a.map(o=>k(o,t,{cache:N,trigger:e,metadata:n}))]);A(()=>{const e=c;let n=c.data;d.forEach((e,r)=>{if(!e.didChange)return;const i=a[r].props.id,d=s(n,t,i)?.node;d&&d===s(o,t,i)?.node&&(n=h(n,t,i,e.node))}),i.didChange&&n.root===o.root&&(n={...n,root:{...n.root,props:i.node.props,readOnly:i.node.readOnly??n.root.readOnly}}),n!==c.data&&(c={...c,data:n,selection:K(n,t,c.selection)},x(e,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=s(c.data,t,e)?.node;if(!r)return!1;const a=await k(r,t,{cache:N,trigger:n,metadata:o});if(!a.didChange)return!1;let i=!1;return A(()=>{const n=c;if(s(c.data,t,e)?.node!==r)return;const o=h(c.data,t,e,a.node);o!==c.data&&(c={...c,data:o,selection:K(o,t,c.selection)},x(n,!1),i=!0)}),i},get config(){return t},getState(){if(v&&b===c)return v;const e=c,o={data:e.data,ui:L(e,t)},r="node"===e.selection?.kind?s(e.data,t,e.selection.id)?.node??null:null;return v={appState:o,selection:e.selection,selectedItem:r,config:t,dispatch:E,history:{back:()=>$.undo(),forward:()=>$.redo(),hasPast:p>0,hasFuture:p<u.length-1,histories:u.map(e=>({id:e.id,state:{data:e.core.data,ui:L(e.core,t)}})),index:p,setHistoryIndex:e=>{e>=0&&e<u.length&&e!==p&&z(e)}},getPermissions:Z,getItemById:n=>s(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return l(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}},b=e,v},subscribe:e=>(m.add(e),()=>{m.delete(e)}),dispatch:E,batch:A,select:e=>D(e?{kind:"node",id:e}:null),selectSlot:e=>D(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){A(()=>{const n=c,o=void 0===e.select?c.selection:e.select;c={...c,data:e.data,selection:K(e.data,t,o)},x(n,e.data!==n.data)})},load(e,n={}){const o=c,r=y(e,t);c={...c,data:r,selection:K(r,t,n.selection??c.selection)},n.keepHistory||(u=[{core:c,at:-1/0,sealed:!0,id:U()}],p=0),c!==o&&C()},undo(){p>0&&z(p-1)},redo(){p<u.length-1&&z(p+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,i)||(i=e,Z=M(),v=null,C())},setConfig(e){e!==t&&(t=e,Z=M(),v=null,C())}};return $}function X(e,t){const n=e=>{if(e.altKey)return;if(!(e.metaKey!==e.ctrlKey))return;const n="KeyZ"===e.code,o="KeyY"===e.code&&!e.shiftKey;(n||o)&&!1!==t.getState?.().getPermissions().edit&&(e.preventDefault(),o||e.shiftKey?t.redo():t.undo())};return e.addEventListener("keydown",n),()=>e.removeEventListener("keydown",n)}var Q=C(null),G=C(!0);function J({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return O(()=>{n&&e.resolveAll()},[e,n]),O(()=>{if(t&&"undefined"!=typeof document)return X(document,e)},[e,t]),/* @__PURE__ */N(Q.Provider,{value:e,children:/* @__PURE__ */N(G.Provider,{value:t,children:o})})}function _(){const e=x(Q);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function ee(e){const t=_(),n=E({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 a=e(o);return r.has&&Object.is(r.value,a)?(n.current={view:o,selector:e,value:r.value,has:!0},r.value):(n.current={view:o,selector:e,value:a,has:!0},a)};return A(t.subscribe,o,o)}function te(){return function(e){return ee(e)}}var ne="data-puck-component",oe="data-puck-dropzone",re={},ae="data-es-mirror",ie="undefined"==typeof window?O:Z;function se(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${ae}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(ae,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function de({children:t,id:n="preview-frame",title:o,className:r,style:s,mirrorStyles:d=!0,onDocument:l,height:c="auto",nonce:u}){const p=a("canvas",e),f=E(null),[h,m]=D(null);return ie(()=>{const e=f.current,t=h?.ownerDocument.defaultView;if("auto"!==c||!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,c]),ie(()=>{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"===c&&t.classList.add("es-frame-fill"),e.body.appendChild(t),i(e,u),m(t),l?.(e);let n=null;const o=f.current?.ownerDocument;if(d&&o){se(o,e,u);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>se(o,e,u)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}return()=>{n?.disconnect(),t.remove(),m(null),l?.(null)}},[]),/* @__PURE__ */N("iframe",{ref:f,id:n,title:o??p.frame,className:["es-canvas-frame","fill"===c?"is-fill":"",r??""].filter(Boolean).join(" "),style:s,children:h?j(t,h):null})}var le=C(null),ce=C(re),ue=[];function pe({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128}){const a=_(),i=ee(n=>l(n.appState.data,a.config,{parentId:e,slot:t})??ue),s=ee(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==d),c=ee(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),u=x(le),p=["es-zone"];return i.length&&p.push("has-children"),e===d&&p.push("is-root"),(s||c)&&p.push("is-area-selected"),null!==u&&u===e&&e!==d&&p.push("is-hovering-area"),n&&p.push(n),/* @__PURE__ */N("div",{className:p.join(" "),[oe]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`},children:i.map(e=>/* @__PURE__ */N(me,{node:e},e.props.id))})}function fe(e,t,n,o){const r="root"===t?e.root:e.components[t],a={...o};for(const e of w(S(r)))a[e]=function(t={}){/* @__PURE__ */
|
|
2
|
-
return N(pe,{parentId:n,slot:e,...t})};return a}function he(e){return function({zone:t,...n}){/* @__PURE__ */
|
|
3
|
-
return N(pe,{parentId:e,slot:t,...n})}}function me({node:e}){const t=_().config,n=t.components[e.type],o=e.props.id,r=function(e){const t=E(null);return z(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(ne),o.removeAttribute("data-puck-dnd")),t.current=n,n&&(n.setAttribute(ne,e),n.setAttribute("data-puck-dnd",e),n.style.position="relative")},[e])}(o),a=x(ce);if(!n?.render)return null;const i=n.render,s=fe(t,e.type,o,{...I(n),...e.props}),d={renderDropZone:he(o),isEditing:!0,dragRef:n.inline?r:null,metadata:{...a,...n.metadata}};return n.inline?/* @__PURE__ */N(i,{...s,puck:d,editMode:!0}):/* @__PURE__ */N("div",{[ne]:o,"data-puck-dnd":o,style:{position:"relative"},children:/* @__PURE__ */N(i,{...s,puck:d,editMode:!0})})}function ve({metadata:e}){const t=ee(e=>e.config),n=ee(e=>e.appState.data.root).props??{},o=t.root?.render,r=/* @__PURE__ */N(pe,{parentId:d,slot:b}),a=o?/* @__PURE__ */N(o,{id:"puck-root",...fe(t,"root",d,n),puck:{renderDropZone:he(d),isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:r}):r;/* @__PURE__ */
|
|
4
|
-
return N(ce.Provider,{value:e??re,children:a})}function ye({id:e,kind:t,overlay:n}){const o=E(null),[r,a]=D(null);ie(()=>{const t=o.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!e)return void a(null);let r=0;const i=()=>{r=0;const i=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}}(t.querySelector(`[${ne}="${n.CSS?.escape?n.CSS.escape(e):e}"]`),o.current?.parentElement??null);a(e=>{return(t=e)===(n=i)||t&&n&&t.top===n.top&&t.left===n.left&&t.width===n.width&&t.height===n.height?e:i;var t,n})},s=()=>{r||(r=(n.requestAnimationFrame??(e=>n.setTimeout(e,16)))(i))};i();const d="MutationObserver"in n?new n.MutationObserver(s):null;d?.observe(t.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0});const l="ResizeObserver"in n?new n.ResizeObserver(s):null;return l?.observe(t.documentElement),n.addEventListener("resize",s),()=>{d?.disconnect(),l?.disconnect(),n.removeEventListener("resize",s),r&&(n.cancelAnimationFrame??n.clearTimeout)(r)}},[e]);const i=/* @__PURE__ */N("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__ */N(n,{componentId:e,kind:t,children:i}):i}function ge({frame:e=!0,className:t,style:n,metadata:o,mirrorStyles:r,onDocument:a,height:i,title:s,nonce:d,hotkeys:l,frameWrapper:c,overlay:u,children:p}){const f=_(),h=x(G),m=l??h,[v,y]=D(void 0),g=ee(e=>"node"===e.selection?.kind?e.selection.id:null),[k,b]=D(null),w=/* @__PURE__ */$("div",{className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;t.closest?.("a[href]")&&e.preventDefault();const n=t.closest?.(`[${ne}]`);n?f.select(n.getAttribute(ne)):t.hasAttribute?.(oe)||f.select(null)},onMouseOver:e=>{const t=e.target.closest?.(`[${ne}]`),n=t?.getAttribute(ne)??null;n!==k&&b(n)},onMouseLeave:()=>b(null),children:[
|
|
5
|
-
/* @__PURE__ */N(le.Provider,{value:k,children:/* @__PURE__ */N(ve,{metadata:o})}),
|
|
6
|
-
/* @__PURE__ */$("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
|
|
7
|
-
/* @__PURE__ */N(ye,{id:k&&k!==g?k:null,kind:"hover",overlay:u}),
|
|
8
|
-
/* @__PURE__ */N(ye,{id:g,kind:"selected",overlay:u})]}),p]}),S=c?/* @__PURE__ */N(c,{document:v,children:w}):w;O(()=>{if(v&&m)return X(v,f)},[v,m,f]);/* @__PURE__ */
|
|
9
|
-
return N("div",{className:"es-canvas"+(t?` ${t}`:""),style:n,"data-puck-preview":"",children:e?/* @__PURE__ */N(de,{mirrorStyles:r,onDocument:e=>{y(e??void 0),a?.(e)},height:i,title:s,nonce:d,children:S}):/* @__PURE__ */N("div",{id:"preview-frame","data-puck-entry":"",children:S})})}function ke(e={}){const t=_(),n=ee(e=>e.appState.data);return r({...e,data:n,config:t.config,commit:(e,{select:n})=>t.run({data:e,select:n})})}function be(){const e=_(),n=ee(e=>e.config),o=e.resolveCache,r=ee(e=>e.selectedItem),a=ee(e=>e.appState.data.root),i=r?r.props.id:"root",d=a.props??{},l=z(()=>r||{type:"root",props:d},[r,d]),c=r?n.components[r.type]:n.root,u=e.getState(),p=r?s(u.appState.data,n,i):null,f=p&&"root"!==p.place.parentId?p.place.parentId:null,h=f?u.getItemById(f)??null:null,{fields:m}=t({id:i,node:l,block:c,parent:h,appState:u.appState}),v=ee(e=>!1===e.getPermissions(r?{item:r}:{root:!0}).edit),y=M((t,r)=>{(async()=>{const a=e.getState();if("root"!==i){const s=a.getItemById(i),d=a.getSelectorForId(i);if(!s||!d)return;const l={...s,props:{...s.props,[t]:r}},{node:c}=await k(l,n,{cache:o,trigger:"replace"}),u=e.getState().getSelectorForId(i);if(!u)return;return void e.dispatch({type:"replace",destinationZone:u.zone??"root:default-zone",destinationIndex:u.index,data:c})}const s=a.appState.data.root.props??{},{node:d}=await k({type:"root",props:{...s,[t]:r}},n,{cache:o,trigger:"replace"});e.dispatch({type:"replaceRoot",root:{props:d.props,readOnly:d.readOnly},recordHistory:!0})})()},[e,n,o,i]);return{id:i,node:l,fields:m,values:l.props,readOnly:v,onChange:y}}export{de as CanvasFrame,q as DEFAULT_UI,ge as EaselCanvas,J as EaselProvider,ve as EditDocument,X as bindUndoKeys,W as createEasel,te as createUseEasel,R as recordsByDefault,H as reduce,L as uiView,ee as useEasel,_ as useEaselApi,ke as useEaselNodeOps,be as useSelectedFields,K as validSelection};
|
package/dist/chunk-VSHV6KJQ.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
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-P67FP7PG.js";import{Inspector as o}from"./chunk-BXZ6WLHC.js";import{DesktopIcon as u}from"./chunk-L5KW4HG5.js";import{createContext as i,useContext as l}from"react";import{jsx as s}from"react/jsx-runtime";var c={kind:"puck"};function f(n,e){const t=n,r=e,o=Object.keys(t);return o.length===Object.keys(r).length&&o.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 o=e.slotsOf?.(r);return o||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 k(n,e){return n.isLast?n.isLast(e):e.type===n.last}var m={},h={},v=()=>m,y=()=>"",b=()=>null,g=()=>{},L={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},O={options:[{id:"desktop",label:"Desktop",icon:/* @__PURE__ */s(u,{})}],initial:"desktop",fluid:"desktop",widths:{desktop:2e3}},P={read:()=>"sections",write:()=>{},forSelection:(n,e)=>n?"sections":e},w={first:null,last:null,firstGroup:null,lastGroup:null,isSectionGroup:()=>!1,sectionGroupZone:()=>"",panelOf:()=>null};function C(){/* @__PURE__ */
|
|
2
|
-
return s(t,{height:"fill"})}function G(){const{id:n,fields:e,values:t,readOnly:u,onChange:i}=r();/* @__PURE__ */
|
|
3
|
-
return s("div",{className:"es-sidepanel es-sidepanel--right",children:/* @__PURE__ */s(o,{fields:e,values:t,onChange:i,readOnly:u,idPrefix:n})})}var S=i({});function B({parts:n,children:e}){/* @__PURE__ */
|
|
4
|
-
return s(S.Provider,{value:n,children:e})}function D(){return l(S)}function x(){return(D().useOwnerName??y)()}function F(){return(D().useDocumentLabel??b)()}function I(n,e,t,r){return(D().useBridges??v)(n,e,t,r)}function N(n){return(D().useStandaloneBridges??v)(n)}function T(n,e){(D().useDocumentPass??g)(n,e)}function W(){return D().blockRules??L}function A(){return D().blockLook??j}function H(){return D().devices??O}function K(){return D().leftView??P}function R(){return D().pinned??w}function V(){return D().saveSwitch??!0}function Z(n){e(!0===D().pickFollowsSelection,n)}function E(){return D().add??h}function Q(){return D().styleClipboard??null}function X(){return D().nodeKeys??!0}function Y(){return D().notify??null}function q(){return D().Canvas??C}function z(){return D().CanvasHead??null}function J(){return D().canvasDrag??null}var M=i(null);function U({target:n,children:e}){/* @__PURE__ */
|
|
5
|
-
return s(M.Provider,{value:n,children:e})}function $(){return l(M)}function _(){return D().Inspector??G}export{c as SELECTION_MODE,U as ScreenCanvasTargetProvider,B as ScreenPartsProvider,p as isPinnedFirst,k as isPinnedLast,a as isSlotMode,f as sameInspectorMode,d as screenSlotsOf,E as useScreenAdd,A as useScreenBlockLook,W as useScreenBlockRules,I as useScreenBridges,J as useScreenCanvasDrag,q as useScreenCanvasFrame,z as useScreenCanvasHead,$ as useScreenCanvasTarget,H as useScreenDevices,F as useScreenDocumentLabel,T as useScreenDocumentPass,_ as useScreenInspectorPanel,K as useScreenLeftView,X as useScreenNodeKeys,Y as useScreenNotify,x as useScreenOwnerName,D as useScreenParts,Z as useScreenPickFollowsSelection,R as useScreenPinned,V as useScreenSaveSwitch,Q as useScreenStyleClipboard,N as useStandaloneScreenBridges};
|
package/dist/chunk-VSOP4GUM.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{useEaselHost as n}from"./chunk-U3JP4VGF.js";import{useEaselApi as o,bindUndoKeys as t}from"./chunk-P67FP7PG.js";import{useState as r,useEffect as u}from"react";function c(o){const t=n(),[c,e]=r(null);return u(()=>e(o.current),[o]),t.ownsDocument?"undefined"==typeof document?null:document:c}function e(r){const e=n(),m=o(),f=c(r);u(()=>{if(!e.ownsDocument&&f)return t(f,m)},[e,m,f])}export{c as useEaselKeyTarget,e as useEaselUndoKeys};
|
package/dist/chunk-ZTTWFAAC.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{DEFAULT_PANEL_W as a,clampPanelWidth as r}from"./chunk-YC4TB3CJ.js";var s="sf-editor-panel-widths",t={...a},e=a=>r(a);export{t as DEFAULT_PANEL_W,s as PANEL_WIDTHS_KEY,e as clampPanelWidth};
|