efficient-easel 10.3.0 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -6
- package/dist/{chunk-FCLW4LEN.js → chunk-47RGVCPH.js} +7 -7
- package/dist/{chunk-YMEN4KVE.js → chunk-6FFSDH62.js} +1 -1
- package/dist/chunk-77DQCEEF.js +5 -0
- package/dist/chunk-7LP3OD2E.js +56 -0
- package/dist/{chunk-P4CL4YQI.js → chunk-AFSSKGTD.js} +1 -1
- package/dist/{chunk-74ZFATLG.js → chunk-BGY4Q2SL.js} +1 -1
- package/dist/{chunk-OGCROOTI.js → chunk-DGAXQTDW.js} +1 -1
- package/dist/{chunk-JSPZU7X2.js → chunk-FAAZZXIS.js} +1 -1
- package/dist/chunk-GCCBEY2W.js +2 -0
- package/dist/chunk-GG4FGBFR.js +1 -0
- package/dist/{chunk-ERA3XM2U.js → chunk-GJC6SNQC.js} +1 -1
- package/dist/{chunk-BRDCD4LK.js → chunk-IFS5P7CO.js} +1 -1
- package/dist/{chunk-A5OEGP7B.js → chunk-ISZI4T6A.js} +4 -4
- package/dist/{chunk-IZ2QRXSE.js → chunk-JTOZJXD7.js} +1 -1
- package/dist/{chunk-M32O2WRM.js → chunk-PE6ZY5IW.js} +11 -11
- package/dist/chunk-PPHUWGLZ.js +1 -0
- package/dist/{chunk-TROOTMAD.js → chunk-PZHQVOTU.js} +1 -1
- package/dist/chunk-QOYOE5CU.js +1 -0
- package/dist/{chunk-IL6QCPO6.js → chunk-TJ6NRHYF.js} +1 -1
- package/dist/chunk-VWXUMVCD.js +1 -0
- package/dist/chunk-XZDHQ4DN.js +5 -0
- package/dist/copy/index.js +12 -12
- package/dist/drag/drag.css +11 -1
- package/dist/drag/index.d.ts +9 -3
- package/dist/drag/index.js +1 -1
- package/dist/easel/index.js +1 -1
- package/dist/screen/components/AddBlockRow.js +1 -1
- package/dist/screen/components/AddChildRow.js +4 -1
- package/dist/screen/components/AddSidePanel.d.ts +13 -17
- package/dist/screen/components/AddSidePanel.js +1 -1
- package/dist/screen/components/MediaSidePanel.js +1 -1
- package/dist/screen/components/NodeContextMenu.d.ts +3 -15
- 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.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 +16 -16
- package/dist/screen/components/usePartBridge.js +1 -1
- package/dist/screen/index.d.ts +1 -1
- package/dist/screen/index.js +1 -1
- package/dist/screen/lib/key-scope.js +1 -1
- package/dist/screen/lib/puck/device-fields.js +1 -1
- package/dist/screen/lib/puck/style-clipboard.js +1 -1
- package/dist/screen/lib/puck/use-section-ops.js +1 -1
- package/dist/screen/lib/screen-parts.d.ts +6 -62
- package/dist/screen/lib/screen-parts.js +1 -1
- package/dist/screen/screen.css +2 -8
- package/dist/screen/words.d.ts +16 -23
- 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-5545A3PC.js +0 -4
- package/dist/chunk-7O6MDCDU.js +0 -5
- package/dist/chunk-D6N77AOS.js +0 -1
- package/dist/chunk-FJ3ZJJ5Z.js +0 -57
- package/dist/chunk-ICN6COBK.js +0 -5
- package/dist/chunk-JTUUIVBZ.js +0 -1
- package/dist/chunk-O2NLQBFX.js +0 -1
- package/dist/chunk-OWK7DGWG.js +0 -1
- package/dist/chunk-THZ46DC5.js +0 -2
package/dist/chunk-FJ3ZJJ5Z.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import{cloneNodeWithFreshIds as e}from"./chunk-2GVCAIPX.js";import{dedupeSlotChildren as n}from"./chunk-26OOWIJJ.js";import{styleClipboardOf as t}from"./chunk-BRDCD4LK.js";import{markedTreeNodeId as o,revealSelectedTreeRow as r,sameSelector as i}from"./chunk-FGNR22NY.js";import{rootRowName as l,slotChildRowName as s,slotChildRenameProp as d,sectionRenameProp as c}from"./chunk-BHRC3ASL.js";import{scrollPreviewToSection as a,gotoPreviewSlide as p,scrollPreviewToTop as u}from"./chunk-4ES5JGGX.js";import{useEaselKeyTarget as f,useEaselUndoKeys as h,useEaselSaveKey as m,editorRootFocus as g}from"./chunk-74ZFATLG.js";import{SlotChildActionsProvider as y}from"./chunk-KCBEE2MC.js";import{screenStorageKeys as k,DEFAULT_PANEL_W as S,clampPanelWidth as v}from"./chunk-TZIIRGVY.js";import{usePartBridge as b}from"./chunk-OWK7DGWG.js";import{useSectionOps as x}from"./chunk-ERA3XM2U.js";import{useNodeClipboard as w,useNodeContextMenu as z}from"./chunk-D6N77AOS.js";import{PageEditGuardNotices as B}from"./chunk-P4CL4YQI.js";import{ScreenSaveIcon as C,ScreenMainButton as I}from"./chunk-W4U4SHKW.js";import{useBrowserOffline as O}from"./chunk-RKTF5XLP.js";import{useScreenDocument as N}from"./chunk-THZ46DC5.js";import{requestMediaPick as $}from"./chunk-KG7RJWOK.js";import{heldStyle as P,styleShortcut as A}from"./chunk-V7U33NF2.js";import{AddChildRow as T}from"./chunk-5545A3PC.js";import{AddSidePanel as M}from"./chunk-ICN6COBK.js";import{SidePanelHead as j,PanelShowStrip as L}from"./chunk-PPL7GB7D.js";import{useEaselSession as E}from"./chunk-O7Q4DDJT.js";import{MediaSidePanel as R}from"./chunk-YMEN4KVE.js";import{useScreenSaveSwitch as V,useScreenNodeKeys as F,useScreenPinned as D,useScreenDocumentLabel as H,useScreenCanvasFrame as W,useScreenInspectorPanel as U,useScreenDevices as G,useScreenPickFollowsSelection as J,useScreenLeftView as K,useScreenAdd as X,SELECTION_MODE as Y,sameInspectorMode as q,useScreenBridges as Z,useScreenBlockRules as _,useScreenBlockLook as Q,useScreenStorageNamespace as ee,useScreenNotify as ne,useScreenCanvasHead as te,isSlotMode as oe,useScreenStyleClipboard as re,useScreenDocumentPass as ie,useScreenCanvasDrag as le,ScreenCanvasTargetProvider as se,isPinnedFirst as de,isPinnedLast as ce,screenSlotsOf as ae}from"./chunk-7O6MDCDU.js";import{ROOT_ZONE as pe,blockNodeActions as ue,TREE_MAX_DEPTH as fe,childSlotsOf as he,slotFieldsOf as me,slotChildrenIn as ge,nestsInTree as ye,newNodeId as ke}from"./chunk-PLVEGYK6.js";import{useMediaPanel as Se,usePanelPick as ve,useCancelPanelPick as be}from"./chunk-R6WTQWAC.js";import{useEaselHost as xe,useHostEscape as we}from"./chunk-U3JP4VGF.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as ze}from"./chunk-6WY6ZXJG.js";import{DEFAULT_SCREEN_WORDS as Be}from"./chunk-JTUUIVBZ.js";import{useEasel as Ce,useEaselApi as Ie,CanvasPassThroughContext as Oe}from"./chunk-M32O2WRM.js";import{TreeRow as Ne,Subtree as $e,LayersTree as Pe,TreeGroupLabel as Ae,TreeRowAction as Te,TreeSeam as Me}from"./chunk-4JSBIW5H.js";import{DEFAULT_TREE_WORDS as je}from"./chunk-K56YDHYQ.js";import{DEFAULT_NODE_MENU_WORDS as Le}from"./chunk-WK3AFPXY.js";import{toItemSelector as Ee,useNodeOps as Re,clickPick as Ve}from"./chunk-ECM5F6JJ.js";import{LayersIcon as Fe,MediaIcon as De}from"./chunk-4VJATVVR.js";import{EaselTopBar as He,TopBarRail as We,TopBarCluster as Ue,EaselIconButton as Ge,TopBarDivider as Je,DeviceSwitch as Ke,InspectorIconButton as Xe,PanelResizeHandle as Ye,MAX_PANEL_W as qe,MIN_PANEL_W as Ze,panelWidthVars as _e}from"./chunk-IE55HNMA.js";import{DEFAULT_NOTICE_WORDS as Qe,DEFAULT_CHROME_WORDS as en}from"./chunk-Z6PVRXVY.js";import{holderOf as nn,nameOrSomeone as tn}from"./chunk-THWO5YVZ.js";import{DEFAULT_LOCK_WORDS as on}from"./chunk-RE4LP46F.js";import{useWords as rn}from"./chunk-MFIRYGHW.js";import{insertSeams as ln,CanvasDragLayer as sn,CanvasInsert as dn}from"./chunk-FCLW4LEN.js";import{DEFAULT_DRAG_WORDS as cn}from"./chunk-O2NLQBFX.js";import{createDragSession as an,useTreeDrag as pn,gapToMoveIndex as un}from"./chunk-67GNT6PF.js";import{useCanvasFrame as fn,LIST_SELECTOR as hn,BLOCK_SELECTOR as mn,useCanvasEvent as gn,nodeIdAt as yn,frameRectToHost as kn,BLOCK_ATTRIBUTE as Sn,drawnBox as vn}from"./chunk-ILXP5VX5.js";import{zoneKey as bn,ROOT_ID as xn,ROOT_SLOT as wn,parseZoneKey as zn,find as Bn,DataError as Cn}from"./chunk-KRXQM65X.js";import{useRef as In,useMemo as On,useState as Nn,useEffect as $n,useCallback as Pn,useLayoutEffect as An,Fragment as Tn}from"react";import{ColoredBadge as Mn,toast as jn,groupColors as Ln}from"efficient-shell/ui";import{UndoIcon as En,RedoIcon as Rn,RefreshIcon as Vn,TrashIcon as Fn,EyeOffIcon as Dn,EyeIcon as Hn,DuplicateIcon as Wn}from"efficient-shell/icons/efficient";import{jsx as Un,jsxs as Gn,Fragment as Jn}from"react/jsx-runtime";var Kn=/* @__PURE__ */new WeakSet;function Xn(e,n,t){const o=Bn(e,n,t);if(!o)return null;const r=o.path.find(e=>"root"!==e.parentId);return r?r.parentId:t}function Yn({canvas:e,tabs:n,onSelect:t}){const o=In(null),[r,i]=Nn({}),l=n.map(e=>`${e.id}:${e.below?1:0}`).join("|");return An(()=>{const t=e?.document,r=e?.window,l=e?.frame;if(!t||!r||!l||0===n.length)return void i({});let s=0;const d=()=>{s=0;const e=o.current;if(!e)return;const d=kn(l,{left:0,top:0,width:r.innerWidth,height:r.innerHeight},e),c={};for(const o of n){const n=t.querySelector(`[${Sn}="${r.CSS?.escape?r.CSS.escape(o.id):o.id}"]`),i=n?vn(n):null;if(!i||0===i.height){c[o.id]=null;continue}const s=kn(l,{left:i.left,top:i.top,width:i.width,height:i.height},e),a=s.top+s.height;if(a<d.top||s.top>d.top+d.height){c[o.id]=null;continue}const p=o.below?a+4:Math.max(s.top,d.top)+6;c[o.id]={left:Math.max(s.left,d.left)+6,top:p}}i(c)},c=()=>{s||(s=r.requestAnimationFrame(d))};d(),r.addEventListener("scroll",c,!0),r.addEventListener("resize",c);const a=new r.MutationObserver(c);return a.observe(t.body,{childList:!0,subtree:!0,attributes:!0}),()=>{s&&r.cancelAnimationFrame(s),r.removeEventListener("scroll",c,!0),r.removeEventListener("resize",c),a.disconnect()}},[e,l]),/* @__PURE__ */Un("div",{ref:o,className:"es-band-tabs","aria-hidden":"true",children:n.map(e=>{const n=r[e.id];return n?/* @__PURE__ */Un("span",{className:"es-band-tab","data-band-tab":e.id,style:{left:n.left,top:n.top},onClick:n=>{n.stopPropagation(),t(e.id)},children:/* @__PURE__ */Un(Mn,{colorClass:Ln("info","solid"),size:"sm",children:e.label})},e.id):null})})}function qn({expand:e}){/* @__PURE__ */
|
|
2
|
-
return Un("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round",children:/* @__PURE__ */Gn(Jn,e?{children:[
|
|
3
|
-
/* @__PURE__ */Un("path",{d:"M8 9l4-4 4 4"}),
|
|
4
|
-
/* @__PURE__ */Un("path",{d:"M8 15l4 4 4-4"})]}:{children:[
|
|
5
|
-
/* @__PURE__ */Un("path",{d:"M8 4l4 4 4-4"}),
|
|
6
|
-
/* @__PURE__ */Un("path",{d:"M8 20l4-4 4 4"}),
|
|
7
|
-
/* @__PURE__ */Un("path",{d:"M5 12h14"})]})})}var Zn=`${hn}, ${mn}`;function _n(e,n,t){const o=t-n;if(o<6)return null;if(o<24)return{top:Math.round((n+t)/2),height:Math.round(o)};return{top:Math.round(Math.min(Math.max(e,n+12),t-12))}}var Qn="__rungs";var et="screen:band",nt={duplicate:!0,delete:!0};function tt(){const hn=xe(),{target:kn,docId:Sn,capabilities:vn,currentSlug:Ln,siteId:tt,onPublish:ot,saveState:rt,saveConflict:it,retrySave:lt,toggleAutoSave:st,flushSave:dt,access:ct,saveUnreachable:at=!1,readOnly:pt,readOnlyReason:ut=null}=N(),ft=V(),ht=F(),{mediaEditing:mt,hasEditGuard:gt,hasPinnedChrome:yt}=vn,{appState:kt,dispatch:St,history:vt,selectedItem:bt,getSelectorForId:xt,config:wt}=Ce(e=>e),zt=D(),{first:Bt,firstGroup:Ct,lastGroup:It,isSectionGroup:Ot,sectionGroupZone:Nt,panelOf:$t}=zt,Pt=$t(Bt),At=e=>de(zt,e),Tt=e=>ce(zt,e),Mt="node"===zt.firstRow,jt=zt.band??null,Lt=rn("screen",Be),Et=rn("tree",je),Rt=rn("drag",cn),Vt=rn("notice",Qe),Ft=rn("lock",on),Dt=rn("menu",Le),Ht=rn("styleClipboard",ze),Wt=rn("chrome",en),Ut=H()??`/${Ln}`,Gt=W(),Jt=U(),Kt=x({readOnly:pt}),Xt=x({readOnly:pt,foldIntoHistory:!0}),Yt=In(null),qt=Ie(),Zt=On(()=>({...Kt,select:e=>{Yt.current=e,Kt.select(e)},commitDocument:(e,n)=>{if(void 0!==n){const t=qt.config;Yt.current=Ee(e,t,n)}Kt.commitDocument(e,n)}}),[Kt,qt]),_t=kt.ui,Qt=_t.leftSideBarVisible,eo=_t.rightSideBarVisible,{options:no,widths:to,initial:oo,fluid:ro,fit:io}=G(),[lo,so]=Nn(oo),co=Se(),ao=mt&&null!==co,po=ve(),uo=be();J(bt?.props.id);const{read:fo,write:ho,forSelection:mo}=K(),[go,yo]=Nn(fo);$n(()=>{ho(go)},[go]);const[ko,So]=Nn(0),vo=In(null),bo=In(null),xo=fn(bo,{readySelector:Zn}),wo=f(bo);h(bo,xo);const zo=O(),Bo=nn(ct),Co={state:rt,offline:zo||rt.failed&&at,readOnlyReason:ut,editing:Bo?Vt.editing({name:tn(Bo.name,Ft),noun:Lt.noun}):null,conflict:null!=it,notSaving:Lt.bar.notSaving},Io=()=>{pt||(rt.failed?lt():dt())};m(bo,xo,Io);const[Oo,No]=Nn(!1),$o=In(!1),Po=In(!1),[Ao,To]=Nn(null),Mo=X(),jo=e=>To(null===e?null:{zone:pe,index:e}),[Lo,Eo]=Nn([]),[Ro,Vo]=Nn(Y),Fo="puck"===Ro.kind,Do=Oo&&!Ao&&Mo.railTarget?Mo.railTarget(kt.data,{node:bt??null,mode:Ro}):null,Ho=Do?{zone:bn(Do),index:Do.index}:null,Wo=Ao??Ho,Uo=Wo&&Wo.zone===pe?Wo.index:null,Go=o(Ro,bt?.props.id),[Jo,Ko]=Nn(null);$n(()=>{Jo&&(r(),Ko(null))},[Jo]);const Xo=In(xt);Xo.current=xt;const Yo=Pn((e,{scroll:n})=>{yo(n=>mo(e,n)),n&&Ko(e);const t=[];let o=e;for(let e=0;e<4;e++){const e=Xo.current(o)?.zone;if(!e||!e.includes(":"))break;const n=e.split(":")[0];t.push(n),t.push(e),o=n}0!==t.length&&Br(e=>{if(t.every(n=>!e.has(n)))return e;const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},[]),qo=In(null);$n(()=>{const e=qo.current;qo.current=null;const n=null==bt?.props.id?null:String(bt.props.id);Vo(t=>e&&e.id===n?e.mode:"part"===t.kind&&"nodeId"in t&&t.nodeId===n?t:$t(bt?.type)??Y);const t=bt?.props.id,o=Yt.current;if(Yt.current=null,!t)return;const r=xt(t);Yo(String(t),{scroll:!i(o,r??null,pe)})},[bt?.props.id,Yo]);const Zo=Pn(e=>{Vo(n=>q(n,e)?n:e),St({type:"setUi",ui:{rightSideBarVisible:!0}})},[St]),_o=In(()=>{});_o.current=(e,n)=>{const t=e?ki(e.zone??pe)[e.index]?.props.id:null,o=null==t?null:String(t),r=null==bt?.props.id?null:String(bt.props.id);Vo(e=>q(e,n)?e:n),o!==r&&(qo.current={id:o,mode:n},Zt.select(e))};const Qo=Pn((e,n)=>_o.current(e,n),[]),er={kind:Ro.kind,mode:Ro,open:Zo,show:e=>Vo(e),reveal:()=>{eo||St({type:"setUi",ui:{rightSideBarVisible:!0}})},select:Qo},nr=Z(er,{data:kt.data,selected:bt??null,zoneOf:e=>xt(e)?.zone,readOnly:Boolean(pt),select:e=>{Vo(Y),Zt.select({index:e})},replace:(e,n)=>Zt.replaceComponent(pe,e,n),scrollTo:e=>Wi(e)},{device:lo,refreshes:ko},{setView:yo,reveal:()=>{Qt||St({type:"setUi",ui:{leftSideBarVisible:!0}})}}),tr=nr.pinnedSource??!1,or=nr.resolveLeftView?nr.resolveLeftView(go,ao):"media"===go&&ao?go:"sections",rr=_(),{isLockedBlock:ir,duplicateBlocked:lr,nestDepth:sr,newSectionNode:dr,canAddTo:cr,blockIsOffered:ar}=rr,pr=Q(),{labelAtLevel:ur,Icon:fr,useProducts:hr}=pr,mr=pr.rowName?(e,n,t)=>pr.rowName(e,n,t):void 0,gr=Pn(e=>{St({type:"setUi",ui:{rightSideBarVisible:!0}}),a(e),Yo(e,{scroll:!0})},[St,Yo]),{selectNode:yr,openPartId:kr}=b({mode:Ro,setMode:Vo,onOpenPart:gr}),[Sr,vr]=Nn(null);we(null!==Sr,()=>vr(null));const br=k(ee()),xr=br.collapsed,wr=br.panelWidths,[zr,Br]=Nn(()=>{if("undefined"==typeof window)/* @__PURE__ */return new Set;try{const e=window.localStorage.getItem(xr);return new Set(e?JSON.parse(e):[])}catch{/* @__PURE__ */
|
|
8
|
-
return new Set}});$n(()=>{try{window.localStorage.setItem(xr,JSON.stringify([...zr]))}catch{}},[zr]);const[Cr,Ir]=Nn(()=>{if("undefined"==typeof window)return{...S};try{const e=window.localStorage.getItem(wr);if(!e)return{...S};const n=JSON.parse(e);return{left:v(Number(n.left)||S.left),right:v(Number(n.right)||S.right)}}catch{return{...S}}});$n(()=>{const e=setTimeout(()=>{try{window.localStorage.setItem(wr,JSON.stringify(Cr))}catch{}},300);return()=>clearTimeout(e)},[Cr]);const Or=Pn((e,n)=>Ir(t=>{const o="function"==typeof n?n(t[e]):n;return t[e]===o?t:{...t,[e]:o}}),[]),Nr=Pn(e=>Or("left",e),[Or]),$r=Pn(e=>Or("right",e),[Or]),Pr=e=>zr.has(e),Ar=e=>Br(n=>{const t=new Set(n);return t.has(e)?t.delete(e):t.add(e),t}),Tr=In(!1),Mr=In(null);$n(()=>{if(Tr.current&&!Oo){const e=Mr.current,n=e&&e.isConnected&&!e.closest('[aria-hidden="true"]')?e:null;(n??bo.current?.querySelector(`button[aria-label="${CSS.escape(Lt.add.title)}"]`))?.focus(),Mr.current=null}Tr.current=Oo},[Oo]),$n(()=>{if(!Oo||!wo)return;const e=e=>{"Escape"===e.key&&_i()};return wo.addEventListener("keydown",e),()=>wo.removeEventListener("keydown",e)},[Oo,wo]),we(Oo,()=>_i()),$n(()=>{!Qt&&Oo&&(No(!1),To(null),$o.current=!1)},[Qt]),$n(()=>{if(!po)return Po.current&&St({type:"setUi",ui:{leftSideBarVisible:!1}}),void(Po.current=!1);Oo&&(No(!1),To(null),Po.current=$o.current,$o.current=!1),Qt||(Po.current=!0,St({type:"setUi",ui:{leftSideBarVisible:!0}}))},[po]),$n(()=>{!Qt&&po&&(Po.current=!1,uo())},[Qt]),$n(()=>{if(!po||!wo)return;const e=e=>{"Escape"===e.key&&uo()};return wo.addEventListener("keydown",e),()=>wo.removeEventListener("keydown",e)},[po,wo]),we(null!==po,()=>uo());const jr=ne(),Lr=(e,n="success",t)=>{if(jr)return void(t?jr(e,"error"===n?"error":"info",t):jr(e,"error"===n?"error":"info"));const o={sound:!1,action:t?.action,onClose:t?.onClose};"error"===n?jn.error(e,{...o,duration:t?.duration??3200}):jn.success(e,{...o,duration:t?.duration??1900})},Er=In(null),[Rr,Vr]=Nn(0),[Fr,Dr]=Nn(0),Hr=te(),Wr=In(null),Ur=e=>Math.max(0,e.clientHeight-(Wr.current?.offsetHeight??0));$n(()=>{const e=Er.current;if(!e)return;const n=()=>{Vr(e.clientWidth),Dr(Ur(e))};n();const t=new ResizeObserver(n);return t.observe(e),Wr.current&&t.observe(Wr.current),()=>t.disconnect()},[]),An(()=>{Er.current&&(Vr(Er.current.clientWidth),Dr(Ur(Er.current)))},[Cr,Qt,eo]);const Gr=lo===ro?Rr>0?Rr:to[ro]:to[lo],Jr=Rr>0?Math.min(Rr/Gr,"shrink"===io?1:2):1,Kr=Gr*Jr,Xr=Rr>0&&Kr>Rr+1,Yr={width:Kr,height:Fr||"100%",flex:"none",position:"relative"},qr={width:Gr,height:Fr?Fr/Jr:"100%",maxHeight:"none",transform:1!==Jr?`scale(${Jr})`:void 0,transformOrigin:"top left"},Zr=()=>St({type:"setUi",ui:{leftSideBarVisible:!Qt}}),_r=()=>St({type:"setUi",ui:{rightSideBarVisible:!eo}}),Qr=e=>{Oo&&(No(!1),To(null),$o.current=!1,Qt&&go===e)||po&&(Po.current=!1,uo(),Qt&&go===e)||(Qt&&go===e?Zr():(yo(e),Qt||St({type:"setUi",ui:{leftSideBarVisible:!0}})))},ei=()=>{$(hn,{accept:"image/*",title:Wt.mediaLibrary})},ni=()=>{Vo(Y),Zt.select(null),u()},ti=()=>{Vo(Pt??Y),eo||St({type:"setUi",ui:{rightSideBarVisible:!0}})},oi=kt.data.content??[],ri=()=>{const e=oi.findIndex(At),n=oi.findIndex(Tt);return{floor:e>=0?e+1:0,cap:n>=0?n:oi.length}},ii=wt,li=rr.stripCopy,si=n=>e(n,li),di=w(),ci=Re({data:kt.data,config:ii,readOnly:Boolean(pt),clipboard:di,strip:li?e=>li(e):void 0,afterRemove:"none",stepBounds:(e,n)=>{if(e.parentId!==xn||e.slot!==wn)return{min:0,max:n-1};const{floor:t,cap:o}=ri();return{min:t,max:o-1}},commit:(e,{select:n})=>{void 0!==n&&Vo(Y);const t=void 0===n||"node"===n?.kind?n:null;Zt.commitDocument(e,t)}}),ai=e=>{const n=Bn(kt.data,wt,e);if(!n)return!1;const t=bn(n.place),o=n.node,r=t===pe?mi(o):Ni(o);return!!ci.remove(e)&&(Lr(Lt.deleted({name:r}),"success",{duration:8e3,action:{label:Lt.bar.undo,onClick:()=>{ci.restore(n.node,n.place)}}}),!0)},pi={...ci,remove:ai},ui=e=>ur(e,"block",wt.components[e]?.label??e),fi=Pn(e=>wt.components[e]?.defaultProps??{},[wt]),hi=e=>ur(e,"section",ui(e)),mi=e=>l({type:e.type,props:e.props??{}},hi(e.type),mr),{nodeAddresses:gi,zoneItems:yi}=On(()=>{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>=fe)return;const s=/* @__PURE__ */new Map;for(const{child:e,zone:t}of he(wt,n))s.set(t,[...s.get(t)??[],e]);for(const[e,n]of s)t(n,e,i+1)})};return t(oi,pe,0),{nodeAddresses:e,zoneItems:n}},[oi,wt]),ki=Pn(e=>yi.get(e)??[],[yi]),Si=e=>{const n=gi.get(e);return n?ki(n.zone)[n.index]:void 0},vi=e=>ae(rr,wt,e),bi=e=>{if(!rr.slotsOf||e===pe)return null;const n=e.lastIndexOf(":");if(n<=0)return null;const t=Si(e.slice(0,n));if(!t)return null;const o=vi(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}},xi=(()=>{if(!oe(Ro))return null;const e=`${Ro.nodeId}:${Ro.slot}`;return bi(e)?.slot.panel===Ro.kind?e:null})(),wi=In(null);$n(()=>{const e=wi.current;if(wi.current=null,!xi||!oe(Ro))return;const n=Ro.nodeId;Yo(n,{scroll:e!==xi}),Br(e=>{if(!e.has(n))return e;const t=new Set(e);return t.delete(n),t})},[Ro]);const zi=(e,n,t)=>{const o=String(e.props.id);if(!n.panel)return void(e=>{const n=gi.get(e);n&&(n.zone===pe?Ui(n.index):vl(n.zone,n.index,e,Si(n.zone.slice(0,n.zone.lastIndexOf(":")))?.type??""))})(o);const r={kind:n.panel,nodeId:o,slot:n.slot},i=`${o}:${n.slot}`;t&&xi!==i&&(wi.current=i),Qo(null,r),eo||St({type:"setUi",ui:{rightSideBarVisible:!0}}),Wi(o)},Bi=(e,n,t)=>{const o=`${e}:${n}`;if(Br(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;xi!==o&&(wi.current=o);Qo(null,{kind:t,nodeId:e,slot:n})},Ci=(e,n,t)=>{if(pt||!rr.moveSlot)return;const o=Si(e),r=o?vi(o).filter(e=>e.rung):[],i=r[n];if(!i)return;const l={parentId:e,slot:Qn,index:n},s=un(l,{...l,index:Math.min(Math.max(t,0),r.length)});if(s===n)return;const d=rr.moveSlot(e,n,s);"string"==typeof d&&Bi(e,d,i.panel)},Ii=hr(),Oi=On(()=>{const e=/* @__PURE__ */new Map;for(const n of Ii??[])e.set(n.slug,n.name);return e},[Ii]),Ni=e=>s(e,ui,pr.plainText,e=>Oi.get(e),pr.rowName),$i=(e,n)=>{const t=wt.components[e.type]?.fields,o=n===pe||Hl(n)?"section":"block",r=n===pe&&(At(e)||Tt(e)||Ot(e.type)),i="block"===o?d(t):r?null:c(t);return pr.renamePropOf?pr.renamePropOf(e,o,i):i},Pi=(e,n,t,o)=>{if(!(!pt&&Sr?.zone===e&&Sr.index===n))return;const r=(t,o)=>{vr(null),o&&((e,n,t)=>{const o=ki(e)[n];if(!o)return;const r=$i(o,e);r&&Zt.replaceComponent(e,n,{...o,props:{...o.props,[r]:t.trim()}})})(e,n,t)};/* @__PURE__ */
|
|
9
|
-
return Un("input",{className:"es-tree-rename",defaultValue:o,autoFocus:!0,"aria-label":Lt.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)},Ai=t(re(),Ht),Ti=Ai.scope({target:kn,siteId:tt,docId:Sn}),Mi=wt,ji=(e,n)=>n===pe?hi(e):ui(e),Li=(e,n,t)=>{const o=Ai.plan(Ti,t,ji(t.type,e),Mi);o&&(o.changed&&Zt.replaceComponent(e,n,{...t,props:{...o.props,id:t.props.id}}),Lr(o.message))},Ei=z({nodesIn:ki,nodeAt:(e,n)=>ki(e)[n]??null,labelOf:(e,n)=>n===pe?hi(e):ui(e),renamePropOf:$i,beginRename:(e,n)=>vr({zone:e,index:n}),history:{hasPast:vt.hasPast,hasFuture:vt.hasFuture,back:()=>vt.back(),forward:()=>vt.forward()},openAddSection:()=>{Zt.select(null),qi(null)},openPageSettings:()=>{Zt.select(null),Vo(Y)},pageSettingsLabel:Lt.pageSettings,words:{menu:Dt,styleClipboard:Ht,screen:Lt.menu},readOnly:Boolean(pt),collapseAll:()=>Br(new Set(ki(pe).map(e=>String(e.props.id)))),onPasteRefused:e=>Lr(e?Lt.pasteRefused({name:e.label}):Lt.menu.clipboardRefused,"error"),canPasteAt:(e,n)=>Gl(e,n),menuRows:nr.menuRows,isLocked:e=>ir(e.type),duplicateBlocked:e=>lr(kt.data,e),permits:e=>ue(wt,e.type),canAddTo:cr,nodeOps:pi,isPinned:(e,n)=>n===pe&&(At(e)||Tt(e)),sectionBand:ri,openAddInside:(e,n)=>{e===pe?Ui(n):Zt.select({zone:e,index:n}),qi(null)},locate:e=>gi.get(e)??null,rowNameOf:(e,n)=>n===pe?mi(e):Ni(e),selectAt:(e,n,t,o)=>{e===pe?Ui(n):vl(e,n,t,o??"")},slotRung:e=>{const n=bi(e);return n?.slot.panel?{label:n.slot.label,select:()=>zi(n.node,n.slot,!1)}:null},style:{held:()=>P(Ti),canCopy:e=>Ai.rows(Mi,e).some(e=>!1!==e.counted),copy:(e,n)=>Ai.copy(Ti,e,ji(e.type,n),Mi),paste:(e,n,t)=>Li(e,n,t)},keys:ht?{target:wo,selected:()=>{const e=kt.ui.itemSelector;return e?{zone:e.zone??pe,index:e.index}:null},held:()=>di.get(),readOnly:Boolean(pt),onDone:({done:e,name:n})=>{"copied"===e&&Lr(Lt.copied({name:n}))}}:void 0},xo),Ri=In({copy:(e,n)=>{},paste:(e,n,t)=>{},at:()=>null,readOnly:!1});$n(()=>{Ri.current={copy:(e,n)=>Ai.copy(Ti,e,ji(e.type,n),Mi),paste:Li,at:()=>{const e=kt.ui.itemSelector;if(!e)return null;const n=e.zone??pe,t=ki(n)[e.index];return t?{zone:n,index:e.index,node:t}:null},readOnly:Boolean(pt)}});const Vi=Pn(e=>{const n=A(e);if(!n)return;const t=Ri.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))},[]);$n(()=>{if(!wo)return;const e=e=>Vi(e);return wo.addEventListener("keydown",e),()=>wo.removeEventListener("keydown",e)},[Vi,wo]),gn(xo,"keydown",Vi);const Fi=oi.map(e=>e.props.id).join("|");$n(()=>{const e=xo?.document??null,n=xo?.window??null;let t=0;const o=[],r=()=>{if(!e)return void Eo(e=>e.length?[]:e);const n=oi.findIndex(Tt),t=n>=0?n:oi.length,o=n=>{const t=oi[n]?.props?.id;return null==t?null:e.querySelector(`[data-puck-component="${CSS.escape(String(t))}"]`)},r=e=>e?[...e.querySelectorAll(mn)].map(e=>e.getBoundingClientRect()).filter(e=>e.width>0||e.height>0):[],i=[];for(let e=oi.length>0&&!At(oi[0])?0:1;e<=t;e++){const n=o(e),t=o(e-1),l=n?.getBoundingClientRect()??null,s=t?.getBoundingClientRect()??null;if(!l&&!s)continue;const d=_n(l&&s?(s.bottom+l.top)/2:l?0===e?l.top+12:l.top:s.bottom,Math.max(0===e?0:-1/0,...r(t).map(e=>e.bottom)),Math.min(1/0,...r(n).map(e=>e.top)));d&&i.push({...d,index:e})}Eo(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()}},[xo,Fi,lo,Jr,Qt,eo,bt?.props.id]);const Di=xo?.document??null,Hi=xo?.window??null;$n(()=>{const e=vo.current;if(!e||!Di||!Hi)return;const n=[],t=()=>{const n=Di.querySelector(`[data-puck-component="${CSS.escape(e.id)}"]`);if(!n)return!1;const t=n.getBoundingClientRect().top-e.offset;return Math.abs(t)>1&&Hi.scrollTo({left:Hi.scrollX,top:Hi.scrollY+t,behavior:"instant"}),!0};return vo.current=null,t()&&n.push(setTimeout(t,150),setTimeout(t,450)),()=>n.forEach(clearTimeout)},[Di,Hi]);const Wi=e=>{nr.holdCanvasOn?nr.holdCanvasOn(e):a(e)},Ui=e=>{Vo(Y),Zt.select({index:e}),nr.sectionPressed?.(oi[e]);const n=oi[e]?.props?.id;n&&Wi(n)},Gi=e=>{const{floor:n,cap:t}=ri(),o=e=>Math.min(Math.max(n,e),t);if("number"==typeof e)return o(e);const r=bt&&Ro.kind!==Pt?.kind?oi.findIndex(e=>e.props.id===bt.props.id):-1;return o(r>=0?r+1:t)},Ji=(e,n)=>{const{floor:t,cap:o}=ri(),r=Math.min(Math.max(n,t),o),i=e<r?r-1:r;return i===e?{moved:!1,dest:e}:(Zt.reorderComponent(pe,e,i),Zt.select({index:i}),{moved:!0,dest:i})},Ki=(e,n,t,o)=>{Vo(Y),Zt.select(o?{index:o.index,zone:o.zone}:{index:e}),a(n),Lr(Lt.sectionAdded({name:t}))},Xi=(e,n)=>{const t=Gi(n),o=dr(e,{nodeDefaults:fi,newNodeId:ke,sectionLabel:hi,blockIsOffered:ar}),r=o?Zt.insertNode(pe,t,o):Zt.insertSection(e,t);return Ki(t,r,hi(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 he(wt,e)){if(s.type===t&&(!o.at||n>o.at.depth)){const r=cr(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},Yi=(e,n,t)=>{const o=Gi(t),r=Zt.insertNode(pe,o,n);return Ki(o,r,e),o},qi=e=>Zi(pe,e),Zi=(e,n)=>{Mr.current=document.activeElement??null,po&&($o.current=Po.current,Po.current=!1,uo()),To(null===n?null:{zone:e,index:n}),No(!0),Qt||($o.current=!0,St({type:"setUi",ui:{leftSideBarVisible:!0}}))},_i=()=>{No(!1),To(null),$o.current&&St({type:"setUi",ui:{leftSideBarVisible:!1}}),$o.current=!1},Qi=(e,n,t)=>{const o="section"===e.kind?e.type:"template"===e.kind?e.template.node.type:null;if(o&&Wl(n,o)){if("section"===e.kind)Zt.insertComponent(n,e.type,t);else{if("template"!==e.kind)return;Zt.insertNode(n,t,si(e.template.node))}Vo(Y),Zt.select({index:t,zone:n})}},el=(e,n)=>pr.rowName?n?At(e)?pr.rowName(e,"section",Lt.header):Tt(e)?pr.rowName(e,"section",Lt.footer):Ot(e.type)?pr.rowName(e,"section",ui(e.type)):mi(e):Ni(e):n?hi(e.type):ui(e.type),nl=e=>n=>{e()},tl=()=>nr.editPinnedSource?.(),ol=(e,n,t)=>{if(pt)return null;const o=ki(e)[n];return o&&!ue(wt,o.type).delete?null:/* @__PURE__ */Un(Te,{kind:"delete",label:Lt.deleteNamed({name:t}),onClick:()=>((e,n)=>{const t=ki(e)[n]?.props?.id;null!=t&&ai(String(t))})(e,n),children:/* @__PURE__ */Un(Fn,{size:15})})},rl=e=>pr.rowPreview?.(e)||void 0,il=e=>pr.rowMarks?.(e)??void 0,ll=(e,n,t)=>pr.rowActions?.(e,n,t)??null,sl=(e,n,t,o)=>{if(pt)return null;const r=Boolean(t.props._hidden);/* @__PURE__ */
|
|
10
|
-
return Un(Te,{kind:"eye",label:r?Lt.showNamed({name:o}):Lt.hideNamed({name:o}),onClick:()=>cl(e,n,t),children:/* @__PURE__ */Un(r?Dn:Hn,{size:14,strokeWidth:1.8,strokeLinecap:void 0,strokeLinejoin:void 0})})},dl=e=>{const n=hi(oi[e]?.type??""),t=n?Lt.addSectionBefore({name:n}):Lt.addSectionHere;return vs(pe,e,()=>qi(e),t)},cl=(e,n,t)=>{Zt.replaceComponent(e,n,{...t,props:{...t.props,_hidden:!t.props._hidden}})},al=e=>me(wt,e),pl=e=>he(wt,e),ul=e=>rr.slotsOf?vi(e).map(n=>({slot:n.slot,rung:n.rung?n:null,kids:ge(e,n.slot)})):[{slot:null,rung:null,kids:pl(e)}],fl=e=>rr.slotsOf?ul(e).flatMap(e=>e.kids):pl(e),hl=e=>Boolean(rr.slotsOf)&&vi(e).some(e=>e.rung),ml=(e,n,t)=>null===t?void 0===n?cr(e):cr(e,n):cr(e,n,t),gl=(e,n,t)=>{const o=ye(wt,e.type,n)&&(t||fl(e).length>0||hl(e));return{collapsible:o,folded:o&&Pr(String(e.props.id))}},yl=(e,n,t)=>ul(e).flatMap(o=>{const r=o.rung?n+1:n,i=o.kids.flatMap(({child:e})=>gl(e,r,t(e.type)).collapsible?[String(e.props.id),...yl(e,r+1,t)]:[]);return o.rung?[`${e.props.id}:${o.rung.slot}`,...i]:i}),kl=e=>fl(e).length>0||hl(e)||Boolean(cr(e.type)),Sl=e=>Boolean(cr(e)),vl=(e,n,t,o)=>{if(Vo(Y),cr(o)?.spec?.slider){const t=e.split(":")[0];p(t,n),Zt.select({index:n,zone:e}),a(t)}else Zt.select({index:n,zone:e}),Wi(t)},bl=(e,n,t,o,r)=>{const i=`${e}:${n}`;Zt.insertComponent(i,t,o),cr(r)?.spec?.slider?requestAnimationFrame(()=>{p(e,o),Zt.select({index:o,zone:i})}):Zt.select({index:o,zone:i})},xl=(e,n,t)=>{Zt.insertComponent(e,n,t),Vo(Y),Zt.select({index:t,zone:e})},wl=In(/* @__PURE__ */new Set);$n(()=>{oi.forEach(e=>{const n=cr(e.type)?.spec;if(!n)return;const t=e.props.id;if(wl.current.has(t))return;wl.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(fi)).forEach((e,t)=>Xt.seedChild(o,t,n.childType,e))})},[oi,Xt,fi]);const zl=In(/* @__PURE__ */new Set);$n(()=>{oi.forEach((e,t)=>{const o=e.props.id;if(zl.current.has(o))return;const r=n(e,al(e.type));zl.current.add(o),r&&Xt.replaceComponent(pe,t,{...e,props:r})})},[oi,Xt]),ie(Xt,wt);const Bl=oi.findIndex(Tt),Cl=Bl>=0?oi[Bl]:null,Il=Mt?oi.findIndex(At):-1,Ol=Il>=0?oi[Il]:null,Nl=zt.groupTab,$l=On(()=>Nl?e=>Ot(e.type):void 0,[Nl]),Pl=Boolean(zt.groupBadge),Al=zt.groupBadge?/* @__PURE__ */Un("span",{className:"es-tree-group-badge",children:/* @__PURE__ */Un(Mn,{tone:"info",size:"xs",children:zt.groupBadge})}):void 0,Tl=oi.find(e=>e.type===Ct)??null,Ml=oi.find(e=>e.type===It)??null,jl=Bl>=0?Bl:oi.length,Ll=[];oi.forEach(e=>{Tt(e)||(kl(e)&&Ll.push(String(e.props.id)),Ll.push(...yl(e,1,Sl)))}),Cl&&(Ll.push(String(Cl.props.id)),Ll.push(...yl(Cl,1,Sl)));const El=Ll.length>0&&Ll.every(e=>zr.has(e)),Rl=e=>{const n=pr.blockRowName(e,ui);return pr.rowName?pr.rowName(e,"block",n):n},Vl=(e,n,t,o)=>{const r=ki(e)[t];if(!r)return;const i={...zn(e),index:t},l={...zn(n),index:Math.min(Math.max(o,0),ki(n).length)},s=un(i,l);if(e!==n||s!==t)try{ci.move(String(r.props.id),{...l,index:s})}catch(e){if(!(e instanceof Cn))throw e}},Fl=e=>{const n=/* @__PURE__ */new Set,t=e=>{for(const{child:o,zone:r}of pl(e))n.add(r),t(o)};for(const t of al(e.type))n.add(`${e.props.id}:${t}`);return t(e),n},Dl=e=>{let n=e.slice(0,e.indexOf(":"));for(let e=0;e<64;e++){const e=gi.get(n);if(!e)return null;if(e.zone===pe)return n;n=e.zone.slice(0,e.zone.indexOf(":"))}return null},Hl=e=>{const n=e.slice(0,e.indexOf(":")),t=oi.find(e=>Ot(e.type)&&String(e.props.id)===n);return t&&Nt(n)===e?t:null},Wl=(e,n)=>{const t=Hl(e);return!t||(!zt.groupAccepts||zt.groupAccepts(t.type,n,ki(e).length))},Ul=(e,n,t)=>{if(e.rung){const t=Si(e.rung.nodeId),o=t?vi(t).filter(e=>e.rung).length:0;return n.parentId===e.rung.nodeId&&n.slot===Qn&&n.index>=0&&n.index<=o}if(n.slot===Qn)return!1;if(e.add)return Kl(e.add,n);const o=bn(n);if(Ot(e.type))return!1;const r=Hl(o),i=Hl(e.zone);if(r||i)return!(!r||!i)&&(!(r!==i&&!Wl(o,e.type))&&(n.index>=0&&n.index<=ki(o).length));if(e.zone===pe||o===pe){if(e.zone!==o)return!1;const{floor:t,cap:r}=ri();return n.index>=t&&n.index<=r}if(n.index<0||n.index>ki(o).length)return!1;if(e.zone===o)return!0;const l=Cl&&!zt.lastIsOpen?String(Cl.props.id):null;return(!l||Dl(e.zone)!==l&&Dl(o)!==l)&&((e,n,t,o)=>{if(e===n)return!0;const r=o??ki(e)[t];if(!r)return!1;const i=n.split(":")[0],l=gi.get(i),s=l?ki(l.zone)[l.index]:void 0;if(!s)return!1;if(!o&&Fl(r).has(n))return!1;const d=cr(s.type,sr(kt?.data,s.type,i),n.slice(n.lastIndexOf(":")+1));return!!d&&(!!(d.choices?d.choices.some(e=>e.type===r.type):d.spec?.childType===r.type)&&!d.spec?.addBlocked?.(ki(n),r))})(e.zone,o,e.index,t)},Gl=(e,n)=>{const t=bn(e.from),o=e.node;return t===bn(n)?Wl(t,o.type):Ul({id:String(o.props?.id??""),zone:t,index:-1,type:o.type},n,o)},Jl=e=>{const n=e.slice(0,e.indexOf(":")),t=gi.get(n),o=t?ki(t.zone)[t.index]:void 0;if(!t||!o)return null;const r=cr(o.type,sr(kt?.data,o.type,n),e.slice(e.lastIndexOf(":")+1));if(!r||`${n}:${r.slot}`!==e)return null;if("footer"===r.source)return null;const i=r.choices??(r.spec?[{type:r.spec.childType,label:ui(r.spec.childType)}]:[]),l=bi(e);return{parent:o,parentId:n,target:r,choices:i,parentName:l?l.slot.label:el(o,t.zone===pe)}},Kl=(e,n)=>{const t=bn(n);if("block"!==e.kind){if(Hl(t)){const o="section"===e.kind?e.type:e.template.node.type;return Wl(t,o)&&n.index>=0&&n.index<=ki(t).length}if(t!==pe)return!1;const{floor:o,cap:r}=ri();return n.index>=o&&n.index<=r}if(t===pe)return!1;const o=Jl(t);return!(!o||!o.choices.some(n=>n.type===e.type))&&!o.target.spec?.addBlocked?.(ki(t))},Xl=(e,n)=>{e.rung?Ci(e.rung.nodeId,e.index,n.index):e.add?((e,n)=>{if("block"!==e.kind&&Hl(bn(n)))return void Qi(e,bn(n),n.index);if("section"===e.kind)return void Xi(e.type,n.index);if("template"===e.kind)return void Yi(e.template.name,si(e.template.node),n.index);const t=bn(n),o=Jl(t);o&&(o.target.spec?bl(o.parentId,o.target.slot,e.type,n.index,o.parent.type):xl(t,e.type,n.index))})(e.add,n):e.zone===pe?Ji(e.index,n.index):Vl(e.zone,bn(n),e.index,n.index)},[Yl]=Nn(()=>an()),ql=pn({keyOf:e=>e.id,readOnly:Boolean(pt),session:Yl,canDrop:Ul,onDrop:Xl,onStep:(e,n)=>{e.rung?Ci(e.rung.nodeId,e.index,n<0?e.index-1:e.index+2):e.zone===pe?((e,n)=>{const t=hi(oi[e]?.type??""),o=Ji(e,n<0?e-1:e+2);if(!o.moved)return void Lr(n<0?Lt.sectionFirst({name:t}):Lt.sectionLast({name:t}));const{floor:r,cap:i}=ri();Lr(Lt.sectionMoved({name:t,n:o.dest-r+1,total:i-r}))})(e.index,n):Vl(e.zone,e.zone,e.index,n<0?e.index-1:e.index+2)}}),Zl=Pn(e=>{const{floor:n,cap:t}=ri(),o=[];for(const r of e.nodes){const e=bn(r.place),i=ki(e)[r.place.index];if(!i||String(i.props.id)!==r.id)continue;if(At(i)||Tt(i)||ir(i.type))continue;if(Ot(i.type))continue;const l=Boolean(Hl(e)),s=e===pe||l;e===pe&&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?hi(i.type):Ni(i),from:r.place})}const r=e.zones.flatMap(e=>{const n=bn(e.list);return n===pe&&0===e.children.length?[{...e,addLabel:Lt.addSection,addAlways:!0}]:e.children.length>0||Boolean(Jl(n)?.choices.length)||Boolean(Hl(n))?[e]:[]}),i=r.flatMap(e=>{const n=bn(e.list);return n===pe||Hl(n)||!Jl(n)?.choices.length?[]:ln(e,Lt.addBlockHere)});return{sources:o,zones:r,seams:i}},[kt.data]),_l=null==bt?.props.id?null:String(bt.props.id),Ql=Pn(e=>{const n=wt,t=e=>!e.item.rung&&null!==Bn(kt.data,n,e.item.id),o=e[e.length-1];if(!t(o))return o;const r=n=>e.find(e=>t(e)&&e.item.id===n),i=r(_l);return i||(r(Ve(kt.data,n,o.item.id,_l,$l))??o)},[kt.data,wt,_l,$l]),[es,ns]=Nn(null);gn(xo,"mouseover",e=>{if(!Nl)return;const n=yn(e.target),t=n?Xn(kt.data,wt,n):null;t!==es&&ns(t)}),gn(xo,"mouseout",e=>{Nl&&!e.relatedTarget&&ns(null)});const ts=e=>At(e)||Tt(e)||Ot(e.type),os=[];if(Nl){const e=_l?Xn(kt.data,wt,_l):null;for(const n of/* @__PURE__ */new Set([e,es])){const e=n?oi.find(e=>String(e.props.id)===n):void 0;if(!e||!ts(e))continue;const t=Nl(e);t&&os.push({id:String(e.props.id),label:t,below:At(e)||e.type===Ct})}}const rs=E(),is=In(null);$n(()=>{const e=zt.changeNotice;if(!e)return;const n=JSON.stringify(oi.filter(ts)),t=is.current;if(is.current={doc:Sn,bands:n,index:vt.index},!t||t.doc!==Sn||t.bands===n)return;vt.hasPast&&vt.index>=t.index&&!Kn.has(rs)&&(Kn.add(rs),Lr(e,"success",{action:{label:Lt.bar.undo,onClick:()=>vt.back()},duration:8e3}))},[oi]);const ls=e=>{Vo(Y),Zt.select(e.zone===pe?{index:e.index}:{index:e.index,zone:e.zone})},ss=le(),ds=()=>({data:kt.data,device:lo,ops:Zt,inspector:er}),cs=ss?.model,as=On(()=>cs?e=>cs(e,Zl(e),ds()):Zl,[cs,Zl,lo]),ps=ss?.measure,us=ps?(e,n)=>ps(e,n,ds()):void 0,fs=ss?.canDrop,hs=fs?(e,n)=>fs(e,n,Ul,ds()):Ul,ms=ss?.drop,gs=ms?(e,n)=>ms(e,n,Xl,ds()):Xl,ys=ss?.pick,ks=ys?e=>ys(e,ls,ds()):ls,Ss=e=>{const n=bn(e),t=bi(n);t&&zi(t.node,t.slot,!1),Zi(n,e.index)},vs=(e,n,t,o)=>/* @__PURE__ */Un(Me,{...pt?{}:ql.seam({place:{...zn(e),index:n}}),onAdd:pt?void 0:t,label:o},`seam:${e}:${n}`),bs={rowClick:nl,isCollapsed:Pr,toggleCollapse:Ar},xs=e=>{const n=String(e.props.id),t=oi.findIndex(e=>String(e.props.id)===n),o=Nt(n),r=ki(o),i=Pr(n),l=ui(e.type),s=pr.rowName?pr.rowName(e,"section",l):l,d=e=>vs(o,e,()=>Zi(o,e),Lt.addSectionHere);/* @__PURE__ */
|
|
11
|
-
return Gn(Jn,{children:[
|
|
12
|
-
/* @__PURE__ */Un(Ne,{words:Et,icon:/* @__PURE__ */Un(fr,{type:e.type,size:13}),name:s,preview:rl(e),marks:il(e),onSelect:()=>Ui(t),nameSlot:Pi(pe,t,n,s),selected:Go===n,badge:Al,actions:ll(e,pe,t)??void 0,rowProps:{"data-node-id":n,onClick:nl(()=>Ui(t))},fold:{open:!i,label:"section",onToggle:()=>Ar(n)}}),!i&&/* @__PURE__ */Gn($e,{children:[r.map((n,t)=>{const r=String(n.props.id),i=mi(n),l=kl(n),s=l&&Pr(r),c=()=>vl(o,t,r,e.type),{rowProps:a,...p}=ql.row({item:{id:r,zone:o,index:t,type:n.type},place:{...zn(o),index:t}},{"data-node-id":r,onClick:nl(c)});/* @__PURE__ */
|
|
13
|
-
return Gn(Tn,{children:[d(t),
|
|
14
|
-
/* @__PURE__ */Un(Ne,{words:Et,icon:/* @__PURE__ */Un(fr,{type:n.type,size:13}),name:i,preview:rl(n),marks:il(n),onSelect:c,nameSlot:Pi(o,t,r,i),selected:Go===r,hidden:Boolean(n.props._hidden),...p,fold:l?{open:!s,label:"section",onToggle:()=>Ar(r)}:void 0,actions:/* @__PURE__ */Gn(Jn,{children:[ol(o,t,i),ll(n,o,t),sl(o,t,n,i)]}),rowProps:a}),l&&!s&&/* @__PURE__ */Un($e,{children:Bs(n,2)})]},r)}),d(r.length)]})]})},ws=(e,n,t,o,r)=>{const i=String(e.props.id),l=`${i}:${n.slot}`,s=ql.dragging,d=!Pr(l)&&s?.rung?.nodeId!==i,c={...zn(l),index:0},a=s&&!s.rung&&Ul(s,c)?c:void 0,p=()=>zi(e,n,!0),{rowProps:u,...f}=ql.row({item:{id:`rung:${l}`,zone:`${i}:${Qn}`,index:t,type:e.type,rung:{nodeId:i,slot:n.slot}},place:{parentId:i,slot:Qn,index:t},into:a,canDrag:Boolean(rr.moveSlot)&&!1!==n.movable&&o>1},{"data-slot-zone":l,onClick:nl(p)}),h=pt?null:rr.slotActions?.(e,n.slot);/* @__PURE__ */
|
|
15
|
-
return Gn(Tn,{children:[n.heading,
|
|
16
|
-
/* @__PURE__ */Un(Ne,{words:Et,icon:n.glyph??null,name:n.label,badge:n.badge,onSelect:p,selected:xi===l,...f,dragHint:n.dragHint,fold:{open:d,label:n.label,onToggle:()=>Ar(l)},actions:h&&h.length>0?/* @__PURE__ */Un(Jn,{children:h.map((t,o)=>/* @__PURE__ */Un(Te,{kind:"delete"===t.kind?"delete":"plain",label:t.label,disabled:t.disabled,onClick:()=>((e,n,t)=>{if(pt||t.disabled)return;const o=String(e.props.id),r=e=>{"string"==typeof e&&Bi(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__ */Un(Fn,{size:15}):/* @__PURE__ */Un(Wn,{size:15})},`${o}:${t.kind}`))}):void 0,rowProps:u}),d&&/* @__PURE__ */Un($e,{children:r})]},l)},zs=(e,n)=>{const t=ul(e),o=t.filter(e=>e.rung).length;let r=0;/* @__PURE__ */
|
|
17
|
-
return Un(Jn,{children:t.map(t=>{const i=t.kids,l=t.rung?n+1:n,s=ml(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(Jl(c)?.choices.length),p=(e,n)=>a?vs(e,n,()=>Zi(e,n),Lt.addBlockHere):vs(e,n),u=/* @__PURE__ */Gn(Jn,{children:[i.map(({child:n,zone:t,index:o})=>{const r=Go===String(n.props.id),{collapsible:i,folded:s}=gl(n,l,Sl(n.type)),d=String(n.props.id),c=Rl(n),a=()=>vl(t,o,d,e.type),{rowProps:u,...f}=ql.row({item:{id:d,zone:t,index:o,type:n.type},place:{...zn(t),index:o}},{"data-node-id":d,onClick:nl(a)});/* @__PURE__ */
|
|
18
|
-
return Gn(Tn,{children:[0===o&&p(t,0),
|
|
19
|
-
/* @__PURE__ */Un(Ne,{words:Et,icon:/* @__PURE__ */Un(fr,{type:n.type,size:13}),name:c,preview:rl(n),marks:il(n),onSelect:a,nameSlot:Pi(t,o,d,c),selected:r,hidden:Boolean(n.props._hidden),...f,fold:i?{open:!s,label:"group",onToggle:()=>Ar(d)}:void 0,actions:/* @__PURE__ */Gn(Jn,{children:[ol(t,o,c),ll(n,t,o),sl(t,o,n,c)]}),rowProps:u}),i&&!s&&/* @__PURE__ */Un($e,{children:zs(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?ws(e,t.rung,r++,o,u):/* @__PURE__ */Un(Tn,{children:u},t.slot??"")})})},Bs=(e,n)=>{const t=sr(kt?.data,e.type,String(e.props.id)),o=ul(e),r=o.filter(e=>e.rung).length;let i=0;/* @__PURE__ */
|
|
20
|
-
return Un(Jn,{children:o.map(o=>{const l=o.kids,s=o.rung?n+1:n,d=ml(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)?()=>bl(e.props.id,c.slot,c.childType,t,e.type):n===h?()=>Zi(n,t):void 0;return vs(n,t,o,n===f&&c?c.addLabel:Lt.addBlockHere)},g=null===o.slot?null:`${u}:${o.slot}`,y=Boolean(c&&!c.fixed&&(null===g||g===f)),k=/* @__PURE__ */Gn(Jn,{children:[l.map(({child:n,zone:t,index:o})=>{const r=Go===String(n.props.id),i=Ni(n),l=String(n.props.id),{collapsible:d,folded:c}=gl(n,s,Sl(n.type)),a=al(n.type),p=1===a.length?`${l}:${a[0]}`:null,u=p?{...zn(p),index:ki(p).length}:void 0,f=ql.dragging,h=u&&f&&Ul(f,u)?u:void 0,g=()=>vl(t,o,l,e.type),{rowProps:y,...k}=ql.row({item:{id:l,zone:t,index:o,type:n.type},place:{...zn(t),index:o},into:h,canDrag:!ir(n.type)},{"data-node-id":l,onClick:nl(g)});/* @__PURE__ */
|
|
21
|
-
return Gn(Tn,{children:[0===o&&m(t,0),
|
|
22
|
-
/* @__PURE__ */Un(Ne,{words:Et,icon:/* @__PURE__ */Un(fr,{type:n.type,size:13}),name:i,preview:rl(n),marks:il(n),onSelect:g,nameSlot:Pi(t,o,l,i),selected:r,hidden:Boolean(n.props._hidden),...k,fold:d?{open:!c,label:"group",onToggle:()=>Ar(l)}:void 0,actions:ir(n.type)?ll(n,t,o)??void 0:/* @__PURE__ */Gn(Jn,{children:[ol(t,o,i),ll(n,t,o),sl(t,o,n,i)]}),rowProps:y}),d&&!c&&/* @__PURE__ */Un($e,{children:Bs(n,s+1)}),m(t,o+1)]},String(n.props.id??`${t}-${o}`))}),y&&c&&
|
|
23
|
-
/* @__PURE__ */Un(T,{small:!0,label:c.addLabel,blocked:c.addBlocked?.(a)??null,onAdd:()=>bl(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?ws(e,o.rung,i++,r,k):/* @__PURE__ */Un(Tn,{children:k},o.slot??"")})})},Cs=(()=>{if(!bt||!Fo)return null;const e=String(bt.type),n=String(bt.props.id),t=cr(e,sr(kt?.data,e,n));if(!t||"footer"===t.source)return null;const o=oi.some(e=>String(e.props?.id)===n),r=Array.isArray(bt.props[t.slot])?bt.props[t.slot]:[];if(t.spec?.addBlocked?.(r))return null;const i=t.choices??(t.spec?[{type:t.spec.childType,label:ui(t.spec.childType)}]:[]);return 0===i.length?null:{parentName:el(bt,o),choices:i,onPick:o=>{t.spec?bl(n,t.slot,o,r.length,e):xl(`${n}:${t.slot}`,o,r.length)}}})(),Is=Wo&&Wo.zone!==pe&&!Hl(Wo.zone)?Wo.zone:null,Os=!0===Mo.blocksFirst,Ns=Is?Jl(Is):Os&&Wo?null:Cs,$s=Wo&&Hl(Wo.zone)?Wo.zone:null,Ps=$s&&zt.groupAccepts?e=>Wl($s,e):void 0,As=Boolean(Ao&&Is)||Os&&Boolean(Ns&&Ns.choices.length>0),Ts=Oo||null!==po,Ms=e=>"panel"in e?{id:e.id,label:e.label,icon:e.icon,active:Qt&&!Ts&&or===e.id,onSelect:()=>Qr(e.id)}:e,js=[{id:"add",label:Lt.add.title,icon:/* @__PURE__ */Un("span",{className:"sf-rail-plus","aria-hidden":"true",children:"+"}),active:Oo,onSelect:()=>Oo?_i():qi(null)},...(nr.railLead??[]).map(Ms),{id:"sections",label:Lt.layers,icon:/* @__PURE__ */Un(Fe,{}),active:Qt&&!Ts&&"sections"===or,onSelect:()=>Qr("sections")},...(nr.railTrail??[]).map(Ms)];ao?js.push({id:"media",label:Lt.railMedia,icon:/* @__PURE__ */Un(De,{}),active:Qt&&!Oo&&(null!==po||"media"===or),onSelect:()=>Qr("media")}):mt&&js.push({id:"media",label:Lt.railMedia,icon:/* @__PURE__ */Un(De,{}),onSelect:ei});const Ls=[...nr.railLead??[],...nr.railTrail??[]].find(e=>"panel"in e&&e.id===or),Es=Boolean(jt?.foldable)&&!tr,Rs=jt?.label??(gt?Lt.pageSections:Lt.templateSections),Vs=Es&&Pr(et),Fs=/* @__PURE__ */Gn(Jn,{children:[oi.map((e,n)=>{if(At(e)||Tt(e)||Ot(e.type))return null;const t=Go===String(e.props.id),o=Boolean(e.props._hidden);pl(e);const r=String(e.props.id),i=nr.hasOwnRows?.(e)??!1,l=kl(e)||i,s=l&&Pr(r),d=al(e.type),c=1===d.length?`${r}:${d[0]}`:null,a=c?{...zn(c),index:ki(c).length}:void 0,p=ql.dragging,u=a&&p&&Ul(p,a)?a:void 0,{rowProps:f,...h}=ql.row({item:{id:r,zone:pe,index:n,type:e.type},place:{...zn(pe),index:n},into:u},{"data-node-id":r,onClick:nl(()=>Ui(n))});/* @__PURE__ */
|
|
24
|
-
return Gn(Tn,{children:[n>0&&dl(n),
|
|
25
|
-
/* @__PURE__ */Un(Ne,{words:Et,icon:/* @__PURE__ */Un(fr,{type:e.type,size:13}),name:mi(e),preview:rl(e),marks:il(e),onSelect:()=>Ui(n),nameSlot:Pi(pe,n,r,mi(e)),selected:t,hidden:o,...h,fold:l?{open:!s,label:"section",onToggle:()=>Ar(r)}:void 0,actions:/* @__PURE__ */Gn(Jn,{children:[ol(pe,n,mi(e)),ll(e,pe,n),sl(pe,n,e,mi(e))]}),rowProps:f}),kl(e)&&!s&&/* @__PURE__ */Gn($e,{children:[Bs(e,1),nr.partRows?.(e,bs)]}),i&&!s&&/* @__PURE__ */Un($e,{children:nr.ownRows?.(e,n,bs)})]},String(e.props.id??n))}),!tr&&jl>0&&dl(jl),jt?.addAtEnd&&!tr&&!pt&&/* @__PURE__ */Un(T,{small:!0,label:Lt.addSection,blocked:null,onAdd:()=>qi(jl)})]}),Ds=(e,n,t)=>{const o=String(e.props.id),r=fl(e).length>0||hl(e)||Boolean(cr(e.type)),i=r&&Pr(o),l="header"===t?Lt.header:Lt.footer,s=pr.rowName?pr.rowName(e,"section",l):l;/* @__PURE__ */
|
|
26
|
-
return Gn(Jn,{children:[
|
|
27
|
-
/* @__PURE__ */Un(Ne,{words:Et,icon:/* @__PURE__ */Un(fr,{type:t,size:13}),name:s,preview:rl(e),marks:il(e),badge:Al,onSelect:()=>Ui(n),nameSlot:Pi(pe,n,o,s),selected:Go===String(e.props.id),fold:r?{open:!i,label:"section",onToggle:()=>Ar(o)}:void 0,actions:ll(e,pe,n)??void 0,rowProps:{"data-node-id":o,onClick:nl(()=>Ui(n))}}),r&&!i&&/* @__PURE__ */Un($e,{children:zs(e,1)})]})};return(nr.wrap??(e=>e))(
|
|
28
|
-
/* @__PURE__ */Un(se,{target:xo,children:/* @__PURE__ */Gn("div",{ref:bo,className:"sf-editor es-editor",style:_e(Cr),onContextMenu:Ei.onEditorContextMenu,...g(hn),children:[
|
|
29
|
-
/* @__PURE__ */Gn(He,{children:[
|
|
30
|
-
/* @__PURE__ */Un(We,{items:js,ariaLabel:Lt.bar.views}),
|
|
31
|
-
/* @__PURE__ */Gn(Ue,{children:[
|
|
32
|
-
/* @__PURE__ */Un(Ge,{label:Lt.bar.undo,disabled:Boolean(pt)||!vt.hasPast,onClick:()=>vt.back(),children:/* @__PURE__ */Un(En,{})}),
|
|
33
|
-
/* @__PURE__ */Un(Ge,{label:Lt.bar.redo,disabled:Boolean(pt)||!vt.hasFuture,onClick:()=>vt.forward(),children:/* @__PURE__ */Un(Rn,{})}),
|
|
34
|
-
/* @__PURE__ */Un(Je,{}),
|
|
35
|
-
/* @__PURE__ */Un(Ke,{devices:no,value:lo,onChange:so}),
|
|
36
|
-
/* @__PURE__ */Un(Ge,{label:Lt.bar.refresh,tip:Lt.bar.refreshTip,onClick:()=>{vo.current=(()=>{const e=xo?.document;if(!e)return null;const n=oi.findIndex(Tt),t=n>=0?n:oi.length;let o=null;for(let n=0;n<t;n++){const t=oi[n]?.props?.id;if(null==t)continue;const r=e.querySelector(`[data-puck-component="${CSS.escape(String(t))}"]`);if(!r)continue;const i=r.getBoundingClientRect().top;i<=4&&(null===o||i>o.offset)&&(o={id:String(t),offset:i})}if(!o){const e=bt?.props?.id??oi[0]?.props?.id;null!=e&&(o={id:String(e),offset:0})}return o})(),So(e=>e+1)},children:/* @__PURE__ */Un(Vn,{})})]}),
|
|
37
|
-
/* @__PURE__ */Gn(Ue,{kind:"right",style:{minWidth:300},children:[
|
|
38
|
-
/* @__PURE__ */Un(C,{input:Co,words:Lt.saveStatus}),nr.barLead?.(),nr.barTrail?.(),nr.mainAction||!nr.barMain?/* @__PURE__ */Un(I,{input:Co,action:nr.mainAction??{label:Lt.done,onPress:()=>{ot(kt.data)}},readOnly:Boolean(pt),saveSwitch:ft,onToggleAutoSave:st,onSaveNow:Io,bar:Lt.bar,words:Lt.saveStatus}):nr.barMain()]})]}),
|
|
39
|
-
/* @__PURE__ */Un(B,{}),
|
|
40
|
-
/* @__PURE__ */Gn("div",{className:"sf-body",children:[Qt?/* @__PURE__ */Gn(Jn,{children:[
|
|
41
|
-
/* @__PURE__ */Un("aside",{className:"es-sidepanel es-sidepanel--left sf-panel sf-panel--left","aria-label":Lt.leftPanel,children:Oo?/* @__PURE__ */Un(M,{blocks:Ns,blocksOnly:As,sectionAccepts:Ps,at:Ao?{label:(e=>{const n=Hl(e.zone);if(n)return Lt.add.addingTo({name:pr.rowName?el(n,!0):ui(n.type)});if(e.zone===pe){const n=oi[e.index];return n&&!Tt(n)?Lt.add.addingBefore({name:el(n,!0)}):Lt.add.addingAtEnd}const t=Jl(e.zone);return t?Lt.add.addingTo({name:t.parentName}):Lt.add.addingHere})(Ao),onClear:()=>To(null)}:void 0,onAdd:e=>{const n=Wo,t=(e,n)=>{Ao&&To({zone:e,index:n})};if(n&&"block"!==e.kind&&Hl(n.zone))return Qi(e,n.zone,n.index),void t(n.zone,n.index+1);if("section"===e.kind)return(e=>{if(null===Uo)return void Xi(e);const n=Xi(e,Uo);Ao&&jo(n+1)})(e.type);if("template"===e.kind)return((e,n)=>{if(null===Uo)return void Yi(e,n);const t=Yi(e,n,Uo);Ao&&jo(t+1)})(e.template.name,si(e.template.node));if(n&&n.zone!==pe){const o=Jl(n.zone);if(!o)return;return o.target.spec?bl(o.parentId,o.target.slot,e.type,n.index,o.parent.type):xl(n.zone,e.type,n.index),void t(n.zone,n.index+1)}Cs?.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:Yl,siteWide:nr.addPanelRow?.(_i),onClose:_i,onHide:Zr,readOnly:Boolean(pt)}):po&&co?
|
|
42
|
-
/* @__PURE__ */Un(R,{panel:co,pick:po,onHide:Zr}):Ls?Ls.panel({onHide:Zr,notify:Lr}):"media"===or&&co?/* @__PURE__ */Un(R,{panel:co,pick:null,onHide:Zr}):/* @__PURE__ */Gn(Jn,{children:[
|
|
43
|
-
/* @__PURE__ */Un(j,{icon:/* @__PURE__ */Un(Fe,{}),title:Lt.layers,context:Ut,actions:
|
|
44
|
-
/* @__PURE__ */Un(Xe,{label:El?Lt.expandAll:Lt.collapseAll,title:0===Ll.length?Lt.nothingToFold:void 0,disabled:0===Ll.length,onClick:()=>Br(e=>{const n=new Set(Ll);return El?new Set([...e].filter(e=>!n.has(e))):/* @__PURE__ */new Set([...e,...Ll])}),children:/* @__PURE__ */Un(qn,{expand:El})}),onHide:Zr}),
|
|
45
|
-
/* @__PURE__ */Gn(Pe,{className:"sf-tree sf-scroll",words:Et,children:[
|
|
46
|
-
/* @__PURE__ */Un(Ne,{words:Et,icon:/* @__PURE__ */Un(fr,{type:"page",size:13}),name:Lt.pageSettings,onSelect:ni,selected:!bt&&Fo,rowProps:{onClick:nl(ni)}}),Tl&&/* @__PURE__ */Gn(Jn,{children:[!Pl&&/* @__PURE__ */Un(Ae,{children:Lt.header}),xs(Tl)]}),!tr&&yt&&!(Pl&&Tl)&&/* @__PURE__ */Gn(Jn,{children:[!Pl&&/* @__PURE__ */Un(Ae,{children:Lt.header}),!Mt&&/* @__PURE__ */Un(Ne,{words:Et,icon:/* @__PURE__ */Un(fr,{type:"header",size:13}),name:Lt.header,badge:Al,onSelect:ti,selected:Ro.kind===Pt?.kind,rowProps:{onClick:nl(ti)}})]}),!tr&&Ol&&!(Pl&&Tl)&&Ds(Ol,Il,"header"),!tr&&!Es&&/* @__PURE__ */Un(Ae,{children:Rs}),Es?/* @__PURE__ */Gn(Jn,{children:[
|
|
47
|
-
/* @__PURE__ */Un(Ne,{words:Et,icon:null,name:Rs,fold:{open:!Vs,label:Rs,onToggle:()=>Ar(et)}}),!Vs&&/* @__PURE__ */Un($e,{children:Fs})]}):Fs,yt&&!Pl&&/* @__PURE__ */Un(Ae,{children:Lt.footer}),Cl&&!(Pl&&Ml)&&Ds(Cl,Bl,"footer"),!tr&&!Cl&&yt&&!Pl&&/* @__PURE__ */Un(Ne,{words:Et,icon:/* @__PURE__ */Un(fr,{type:"footer",size:13}),name:Lt.footer,onSelect:tl,rowProps:{onClick:nl(tl),title:Lt.editFooter}}),Ml&&xs(Ml),nr.treeFoot?.()]})]})}),
|
|
48
|
-
/* @__PURE__ */Un(Ye,{side:"left",width:Cr.left,min:Ze,max:qe,defaultWidth:S.left,label:Lt.resizeLeftPanel,onResize:Nr})]}):/* @__PURE__ */Un(L,{side:"left",onShow:Zr}),
|
|
49
|
-
/* @__PURE__ */Gn("div",{ref:Er,className:"sf-center sf-scroll","data-sf-canvas-head":Hr?"":void 0,style:{overflowX:Xr?"auto":"hidden",overflowY:"hidden"},children:[Hr&&/* @__PURE__ */Un("div",{ref:Wr,className:"sf-canvas-head",children:/* @__PURE__ */Un(Hr,{device:lo})}),
|
|
50
|
-
/* @__PURE__ */Gn("div",{className:"sf-frame-scaler",style:Yr,children:[
|
|
51
|
-
/* @__PURE__ */Un("div",{className:"sf-frame "+(lo===ro?"":`sf-frame--${lo}`),style:qr,children:/* @__PURE__ */Gn("div",{className:"sf-preview-host",children:[
|
|
52
|
-
/* @__PURE__ */Un(Oe.Provider,{value:$l,children:/* @__PURE__ */Un(Gt,{},ko)}),
|
|
53
|
-
/* @__PURE__ */Un(sn,{canvas:xo,session:Yl,model:as,measure:us,canDrop:hs,onDrop:gs,choose:Ql,onPick:ks,onZoneAdd:Ss,onSeamAdd:Ss,zoneAddLabel:Lt.canvasAddBlock,words:Rt.canvas,readOnly:Boolean(pt),revision:kt.data}),Lo.length>0&&/* @__PURE__ */Un("div",{className:"sf-preview-gaps",children:Lo.map(e=>
|
|
54
|
-
/* @__PURE__ */Un(dn,{index:e.index,label:Lt.addSectionHere,onInsert:()=>qi(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))})]})}),Nl?/* @__PURE__ */Un(Yn,{canvas:xo,tabs:os,onSelect:e=>{const n=oi.findIndex(n=>String(n.props.id)===e);n>=0&&Ui(n)}}):null]})]}),eo?/* @__PURE__ */Gn(Jn,{children:[
|
|
55
|
-
/* @__PURE__ */Un(y,{value:{selectChild:vl,addChild:bl,childRowName:Ni,blockRowName:Rl},children:/* @__PURE__ */Un(Jt,{mode:Ro,onOpenWebsiteSettings:nr.openSettings??(()=>{}),onOpenSiteStyles:nr.openStyles,onSelectNode:yr,onNotify:Lr,onHidePanel:_r,nodeActions:bt?ue(wt,bt.type):nt})}),
|
|
56
|
-
/* @__PURE__ */Un(Ye,{side:"right",width:Cr.right,min:Ze,max:qe,defaultWidth:S.right,label:Lt.resizeSettingsPanel,onResize:$r})]}):
|
|
57
|
-
/* @__PURE__ */Un(L,{side:"right",onShow:_r})]}),Ei.menu]})}))}export{tt as ScreenChrome};
|
package/dist/chunk-ICN6COBK.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{buildPaletteSections as e,pinnedSection as t,paletteWithoutPinned as o,categoryLabel as n}from"./chunk-PA3PNTVV.js";import{blockTypesIn as i}from"./chunk-5ZBY24K7.js";import{sectionTemplatesOf as s}from"./chunk-BVN33R76.js";import{SidePanelHead as r,PanelModeExit as c}from"./chunk-PPL7GB7D.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-7O6MDCDU.js";import{DEFAULT_SCREEN_WORDS as d}from"./chunk-JTUUIVBZ.js";import{useEasel as f}from"./chunk-M32O2WRM.js";import{useWords as u}from"./chunk-MFIRYGHW.js";import{AddPanel as k}from"./chunk-FCLW4LEN.js";import{DEFAULT_DRAG_WORDS as y}from"./chunk-O2NLQBFX.js";import{useState as h,useEffect as b,useMemo as j}from"react";import{AddIcon as g}from"efficient-shell/icons/efficient";import{jsx as B,jsxs as O,Fragment as $}from"react/jsx-runtime";var L=e=>`section:${e}`,v=e=>`block:${e}`,x=e=>`template:${e}`;function D({blocks:D,blocksOnly:I,at:N,sectionAccepts:V,onAdd:A,itemFor:C,session:F,siteWide:H,onClose:M,onHide:P,readOnly:R}){const T=f(e=>e.config),W=p(),{labelAtLevel:w,categoryLabel:Q,firstSection:U,Icon:z,Thumbnail:E}=W,{blockIsOffered:G}=m(),J=u("screen",d).add,S=u("drag",y).add,Y=l(),[Z,K]=h([]);b(()=>{let e=!1;const t=e=>G(e,Y);return s(Y).list().then(o=>{if(e)return;const n=T.components;K(o.filter(e=>e.node?.type&&n[e.node.type]&&i(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[T,Y]);const X=j(()=>e(T,W),[T]),q=e=>({type:L(e.type),label:e.name,cover:/* @__PURE__ */B(E,{type:e.type}),title:e.desc?`${e.name} — ${e.desc}`:J.tile({name:e.name}),keywords:[e.alias??"",e.desc,e.type,e.catLabel].filter(Boolean)}),_=j(()=>{const e=[];if(D&&D.choices.length>0&&a(D.choices).forEach((t,o)=>{e.push({key:`blocks:${o}`,title:0===o?`${J.inside({name:D.parentName})}${t.group?` · ${t.group}`:""}`:t.group??"",tiles:t.items.map(e=>({type:v(e.type),label:e.label,icon:/* @__PURE__ */B(z,{type:e.type,size:18}),title:J.tile({name:e.label})}))})}),I)return e;const i=e=>!V||V(e),s=t(X,U);s&&i(s.type)&&e.push({key:"start",title:J.startBlank,tiles:[q(s)]});const r=Z.filter(e=>i(e.node.type));r.length>0&&e.push({key:"templates",title:J.templates,tiles:r.map(e=>{return{type:x(e.id),label:e.name,cover:/* @__PURE__ */B(E,{type:e.node.type}),keywords:[(t=e.node.type,w(t,"section",T.components[t]?.label??t)),e.node.type]};var t})});const c=o(X,U);for(const t of Object.keys(T.categories??{})){const o=c.filter(e=>e.cat===t&&i(e.type));0!==o.length&&e.push({key:`category:${t}`,title:n(T,t,Q),tiles:o.map(q)})}return e},[D,I,Z,X,T,J,V]),ee=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($,{children:[
|
|
3
|
-
/* @__PURE__ */B(r,{icon:/* @__PURE__ */B(g,{size:15}),title:J.title,context:I?J.contextBlocks:J.contextAll,actions:/* @__PURE__ */B(c,{label:J.done,description:J.doneDescription,onClick:M}),onHide:P}),
|
|
4
|
-
/* @__PURE__ */O("div",{className:"sf-addside sf-scroll",children:[
|
|
5
|
-
/* @__PURE__ */B(k,{groups:_,session:F,itemFor:e=>C(ee(e)??{kind:"section",type:e}),onInsert:e=>{const t=ee(e);t&&A(t)},at:N,hint:I?J.hintBlocks:J.hint,searchLabel:I?J.searchBlocks:J.searchSections,readOnly:R,words:S}),H&&!I?H:null]})]})}export{D as AddSidePanel,v as blockKey,L as sectionKey,x as templateKey};
|
package/dist/chunk-JTUUIVBZ.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e={title:"Add",contextBlocks:"Blocks for this place",contextAll:"Sections and blocks",done:"Done",doneDescription:"Close Add and go back",startBlank:"Start blank",templates:"Your templates",inside:({name:e})=>`Inside ${e}`,tile:({name:e})=>`Add ${e}`,hintBlocks:"Drag into the page, or click to add.",hint:"Drag onto the page, or click to add.",searchBlocks:"Search blocks",searchSections:"Search sections",addingTo:({name:e})=>`Adding to ${e}`,addingBefore:({name:e})=>`Adding before ${e}`,addingAtEnd:"Adding at the end of the page",addingHere:"Adding here"};var a={savedAgo:function({seconds:e}){const a=Math.max(0,Math.floor(e));if(a<1)return"Saved just now";if(a<60)return`Saved ${a} second${1===a?"":"s"} ago`;const o=Math.floor(a/60);if(o<60)return`Saved ${o} minute${1===o?"":"s"} ago`;const t=Math.floor(o/60);return`Saved ${t} hour${1===t?"":"s"} ago`},saved:"All changes saved",saving:"Saving",pending:"Changes not saved yet — saving in a moment",failedIn:({seconds:e})=>`Not saved — trying again in ${e} s`,failedSoon:"Not saved — trying again soon",offline:"You’re offline — we’ll save when you’re back",pausedHeld:"Auto-save is off — changes not saved",paused:"Auto-save is off",locked:({editing:e})=>`Not saving — ${e}`,blockedOffline:"You’re offline. Try again when you’re back online.",blockedFailed:"Your last changes are not saved yet. Try again when they are.",blockedConflict:"Your last save was refused. See the notice below."},o={loading:"Loading…",waitingForAuthorization:"Waiting for editor authorization…",missingTemplatePage:"Couldn’t open a page in this template.",missingPage:({slug:e})=>`No page with slug "${e}".`,missingDocument:"Couldn’t open this document.",loadFailed:({cause:e})=>`Could not load the document — ${e}`,noun:"page",pageSettings:"Page settings",header:"Header",footer:"Footer",pageSections:"Page",templateSections:"Template",addSection:"Add section",addSectionBefore:({name:e})=>`Add section before ${e}`,addSectionHere:"Add section here",done:"Done",copied:({name:e})=>`Copied ${e}`,pasteRefused:({name:e})=>`${e} can’t be pasted here.`,add:e,canvasAddBlock:"Add block",railMedia:"Media library",leftPanel:"Left panel",resizeLeftPanel:"Resize left panel",leave:{title:"Unsaved changes",body:"Your most recent edits haven’t finished saving yet. Save them before switching, or leave and discard them.",cancel:"Cancel",discard:"Discard & leave",save:"Save & leave",saving:"Saving…"},bar:{undo:"Undo",redo:"Redo",refresh:"Reload the preview",refreshTip:"Reload the preview (keeps your place)",notSaving:"Not saving — see the notice below",retry:"Retry now",autoSaveOff:"Auto-save is off — click to turn it back on (saves your held edits)",autoSaveOn:"Auto-save is on — click to pause it",views:"Left panel views",saveOptions:"Save options",autoSave:"Auto-save",saveNow:"Save now"},saveStatus:a,menu:{undo:"Undo",redo:"Redo",addSection:"Add section",collapseAll:"Collapse all layers",selectAll:"Select all",pinned:"Pinned — can’t be moved or deleted",clipboardRefused:"Your browser won’t let us read the clipboard — press ⌘V"},layers:"Layers",expandAll:"Expand all sections",collapseAll:"Collapse all sections",nothingToFold:"Nothing to fold on this page",editFooter:"Edit the site footer",rename:"Rename",deleteNamed:({name:e})=>`Delete ${e}`,hideNamed:({name:e})=>`Hide ${e}`,showNamed:({name:e})=>`Show ${e}`,addBlockHere:"Add block here",sectionFirst:({name:e})=>`“${e}” is already first`,sectionLast:({name:e})=>`“${e}” is already last`,sectionMoved:({name:e,n:a,total:o})=>`Moved “${e}” to position ${a} of ${o}`,sectionAdded:({name:e})=>`Added “${e}” section`,deleted:({name:e})=>`Deleted “${e}”`,resizeSettingsPanel:"Resize settings panel",sectionSettings:({name:e})=>`${e} settings`,headerSettings:"Header settings",addBlockMenu:"Add block",deviceNote:{tablet:"Tablet uses the desktop settings.",mobile:"Showing the phone settings for this section."}};export{e as DEFAULT_SCREEN_ADD_WORDS,a as DEFAULT_SCREEN_SAVE_STATUS_WORDS,o as DEFAULT_SCREEN_WORDS};
|
package/dist/chunk-O2NLQBFX.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e={add:{stop:"Stop adding here",hint:"Drag onto the page, or click to add.",search:"Search blocks",searchPlaceholder:({label:e})=>`${e}…`,clearSearch:"Clear search",nothing:({query:e})=>`Nothing matches “${e}”`,tryAnother:"Try another word.",tile:({label:e})=>`Add ${e}`},canvas:{addSection:"Add section",addBlock:"Add block",addButton:({label:e})=>`+ ${e}`,handle:({label:e})=>`Drag to move this ${e.toLowerCase()}`}};export{e as DEFAULT_DRAG_WORDS};
|
package/dist/chunk-OWK7DGWG.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{useSectionOps as o}from"./chunk-ERA3XM2U.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-7O6MDCDU.js";import{useEasel as p}from"./chunk-M32O2WRM.js";import{useCallback as d,useEffect as c}from"react";var s=o=>"part"===o.kind;function m({mode:m,setMode:i,onOpenPart:a}){const{getSelectorForId:u}=p(o=>o),I=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}),a?.(t)):i(o=>"part"===o.kind?n:o)},[i,a]);c(()=>{k(l)},[k,l]);const h=s(m)?r(m.nodeId,m.propKey):null;c(()=>{f(h)},[h,f]);return{selectNode:d(o=>{i(()=>n);const e=u(o);e&&I.select(e)},[i,u,I]),openPartId:h}}export{m as usePartBridge};
|
package/dist/chunk-THZ46DC5.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{editLockOf as e}from"./chunk-GMCZXMOV.js";import{isExpiredSession as r,readEaselFailure as n}from"./chunk-CLOS6SSX.js";import{routeSharedHostMessage as t}from"./chunk-S4AWJX4Q.js";import{describeLoadFailure as o,hostLoadRefusal as u}from"./chunk-ERR437B5.js";import{useAdminBridge as a}from"./chunk-VPFNZ7TB.js";import{NO_DOCUMENT_ADDRESSING as s}from"./chunk-RLBXE4EU.js";import{saveStatusOf as i,resetForDocumentSwitch as l}from"./chunk-HNKB2ZYR.js";import{STATUS_UNREACHABLE as c}from"./chunk-KCOBHPN6.js";import{useEaselSession as d}from"./chunk-O7Q4DDJT.js";import{backendOf as f,setSessionDocumentSite as m}from"./chunk-RSCMJIWS.js";import{useEaselHost as k}from"./chunk-U3JP4VGF.js";import{DEFAULT_SCREEN_WORDS as g}from"./chunk-JTUUIVBZ.js";import{useAutosave as v}from"./chunk-NDRZP6YR.js";import{canWriteDocument as p,newEaselClientId as h,reloadIfVersionMoved as y,openUnansweredClaim as w,FAIL_OPEN_RETRY_MS as S,CLAIM_FAIL_OPEN_MS as b,holderOf as P}from"./chunk-THWO5YVZ.js";import{useWords as I}from"./chunk-MFIRYGHW.js";import{createContext as j,useContext as R,useState as B,useMemo as O,useCallback as C,useEffect as H,useRef as T}from"react";import{jsx as E}from"react/jsx-runtime";var A={content:[],root:{},zones:{}};var D=j(null);function M(){const e=R(D);if(!e)throw new Error("useStorefrontDocument must be used within StorefrontDocumentProvider");return e}function N({target:j,addressing:R=s,onHostMessage:M,children:N}){const V=R,{homeSlug:F,entryMayBounce:L,entryBounce:U,onSwitch:W,tellsHost:Z,adapterFor:J,migrateRenamedProps:Y,describeMissing:X,onLoadFailed:x}=V,[G,K]=B(j),Q=k(),z=d(),_=O(()=>f(z),[z]),q=O(()=>e(z),[z]),$="template"===G.kind,ee="template"===G.kind?G.id:null,re="template"===G.kind?G.pageSlug??F??"":"document"===G.kind?G.slug??"":G.slug,ne="page"===G.kind?G.siteId??null:null,te=z.blocks,oe=O(()=>J(G,_,te),[J,_,te,G.kind,"template"===G.kind?G.id:"document"===G.kind?G.record:G.siteId]),ue=oe.capabilities,ae=C(e=>z.documentHooks?.stored?.(e)??e,[z]),se="page"===G.kind?G.originSlug??null:null;H(()=>{m(z,ne)},[z,ne]);const ie=T(G);H(()=>{ie.current=G},[G]);const{token:le,tokenRef:ce,capabilities:de}=a({onMessage:e=>{if(M?.(e)||t(e))return;const r=e;if("storefront-editor:navigate"===r?.type){const r=e;r?.target&&Or(r.target)}}}),fe=!z.usesBridgedToken||null!==le,me=oe.lock,ke=Boolean(_.lock),[ge,ve]=B(null),[pe,he]=B(null),[ye,we]=B(null),[Se,be]=B(null),Pe=I("screen",g),Ie=Se?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})}}(Se,Pe):null,[je,Re]=B(null),Be=T(null),Oe=T(null),[Ce,He]=B(!1),Te=T(null),[Ee,Ae]=B(null),De=T(null),[Me,Ne]=B(null),[Ve,Fe]=B(!1),Le=T(null);H(()=>{Le.current=Me},[Me]);const[Ue,We]=B(ue.hasEditLock?{kind:"checking"}:{kind:"editing"}),Ze=T(Ue);H(()=>{Ze.current=Ue},[Ue]);const Je=T(()=>Promise.resolve(!1)),Ye=C(e=>{Oe.current=e,He(!0)},[]),Xe=v({save:async({id:e,data:r})=>{if(p(Ze.current)){if(!await Je.current(e,r)){if(!p(Ze.current))return void Ye({id:e,data:r});throw new Error("page save did not land")}}else Ye({id:e,data:r})},onFailure:(e,r)=>{0===r&&Q.send("storefront-editor:save-failed")}}),{state:xe,push:Ge,flush:Ke,pause:Qe,resume:ze,stop:_e,reset:qe,retryNow:$e,hasPending:er}=Xe,rr=T(xe);H(()=>{rr.current=xe},[xe]);const nr=i(xe),tr=C(()=>{const e=Oe.current;e&&(Oe.current=null,He(!1),Ge(e))},[Ge]),or=T("");or.current||(or.current=h());const[ur,ar]=B(0),sr=T(!1),[ir,lr]=B(L(j)),cr=T(!1);H(()=>{if(cr.current)return;cr.current=!0;const e=Q.address.search(),r=U(j,e);r?Q.address.load(r):L(j)&&lr(!1)},[j,Q]);const dr=Q.send;H(()=>{if(!fe)return;let e=!1;const r=ie.current,n=oe.resolve(re),t=z.documentHooks?.opening?.({slug:re,isTemplate:$,capabilities:ue});return n.then(async n=>{if(e)return;if(!n)return"page"===r.kind&&null!==F&&re!==F?void Q.address.load({kind:"page",slug:F,siteId:ne??void 0}):(be({target:r,slug:re,missing:!0,sentence:X?.(r)??null}),void x?.(r,null));const o=n.readOnlyReason?n.readOnlyReason:null;Be.current=o,Re(o),ve(n.id),he(n.kind??null),De.current=n.version??null;const u=n.layout,a=u&&Object.keys(u).length?u:A,s=Y(a),i=t?await t(s):s;e||we(i)}).catch(n=>{e||(console.error("[storefront-editor] document load failed",n),be({target:r,slug:re,missing:!1,sentence:u(n,{slug:re},z),cause:o(n,z)}),x?.(r,n))}),()=>{e=!0}},[fe,le,$,oe,re]);const fr=C(e=>new Promise(r=>{const n=Date.now(),t=setInterval(()=>{const o=ce.current;o&&o!==e?(clearInterval(t),r(o)):Date.now()-n>6e3&&(clearInterval(t),r(null))},200)}),[]),mr=C(async e=>{const n=ce.current;if(!n&&z.usesBridgedToken)return{ok:!1,error:new Error("no editor token")};try{return{ok:!0,value:await e(n??"")}}catch(t){if(r(t,z)){dr("storefront-editor:auth-expired");const r=n?await fr(n):null;if(r)try{return{ok:!0,value:await e(r)}}catch(e){return{ok:!1,error:e}}}return{ok:!1,error:t}}},[dr,fr,z]),kr=C(async e=>{const r=ce.current?await mr(e):{ok:!1};return r.ok||dr("storefront-editor:save-failed"),r.ok},[dr,mr]),gr=C(async(e,r,t=!1)=>{if(null!==Be.current)return!1;if(!p(Ze.current))return!1;if(Le.current)return!1;const o=await mr(()=>oe.saveLayout(e,r,De.current,or.current));if(o.ok)return De.current=o.value.version??De.current,Fe(!1),!0;const u=q.readLockTaken(o.error);if(u){const e={kind:"takenover",holder:u};return Ze.current=e,We(e),!1}const a=q.readSaveConflict(o.error);if(a){if(a.savedByYou&&!t&&oe.rereadVersion){const n=await mr(()=>oe.rereadVersion(e));if(n.ok&&n.value)return De.current=n.value,Je.current(e,r,!0)}_e(),Le.current=a,Ne(a)}return Fe(n(o.error,z)?.status===c),!1},[oe,mr,_e,z]);H(()=>{Je.current=gr},[gr]);const vr=C(e=>{if(null!==Be.current)return;if(dr("storefront-editor:dirty"),!ge)return;const r=ae(e);Te.current=r,p(Ze.current)?Ge({id:ge,data:r}):Ye({id:ge,data:r})},[ge,dr,Ye,Ge,ae]),pr=C(async()=>{p(Ze.current)&&tr();return await Ke()&&null==Oe.current},[tr,Ke]),hr=T(pr);H(()=>{hr.current=pr},[pr]);const yr=T(mr);H(()=>{yr.current=mr},[mr]);const wr=C(()=>{Q.address.reload()},[Q]),Sr=T(()=>Promise.resolve(!1));H(()=>{Sr.current=()=>{const e=oe.rereadVersion;return ge&&e?y({ours:De.current,stored:async()=>{const r=await yr.current(()=>e(ge));return r.ok?r.value:null},hasPending:()=>null!=Oe.current||er(),reload:wr}):Promise.resolve(!1)}},[oe,ge,er,wr]);const br=null!==je;H(()=>{if(!me||!ge||!fe||br)return;let e=!1,r=null,n=null;const t=or.current,o={claim:async e=>{const r=await yr.current(()=>me.claim(ge,t,e));if(r.ok)return{heartbeat_seconds:r.value.heartbeatSeconds};throw r.error},cancelled:()=>e,currentAccess:()=>Ze.current,heldWrite:()=>({pending:null!=Oe.current||er(),autoSaveEnabled:!rr.current.paused,saveConflict:null!=Le.current}),setAccess:e=>{Ze.current=e,We(e)},releaseHeldWrite:()=>{hr.current()},startHeartbeat:e=>{r&&clearInterval(r),r=setInterval(()=>{u(!1)},e)},stopHeartbeat:()=>{r&&(clearInterval(r),r=null)},reloadIfMoved:()=>{Sr.current()}},u=q.makeClaimBeat(o),a=sr.current;return sr.current=!1,a||(We({kind:"checking"}),n=setTimeout(()=>{n=null,w(o)&&o.startHeartbeat(S)},b)),u(a).finally(()=>{n&&clearTimeout(n),n=null}),()=>{e=!0,n&&clearTimeout(n),r&&clearInterval(r),me.release(ge,t).catch(()=>{})}},[ge,me,fe,le,ur,br]);const Pr=C(()=>{me&&ge&&(sr.current=!0,ar(e=>e+1))},[ge,me]),Ir=C(()=>{We(e=>{const r="blocked"===e.kind||"takenover"===e.kind?e.holder:null;return r?{kind:"readonly",holder:r}:e})},[]),jr=C(()=>{rr.current.paused?(p(Ze.current)&&tr(),ze()):Qe()},[tr,Qe,ze]),Rr=C(()=>{$e()},[$e]),Br=C(e=>{Te.current=null,l("template"!==e.kind&&ke,{resetAutosave:()=>{qe(),Oe.current=null,He(!1)},setVersion:e=>{De.current=e},setSaveConflict:Ne,setAccess:We}),W(e),K(e),Be.current=null,Re(null),ve(null),he(null),we(null),be(null),Q.address.show(e),"document"!==e.kind&&Z(e)&&Q.send("storefront-editor:navigated",{target:e})},[qe,Q,ke,W,Z]),Or=C(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,ie.current,F))return;const r=null!=Oe.current;if(!r&&!er())return void Br(e);const n=rr.current;r||n.paused||n.failed||n.stopped?Ae(e):Ke().then(r=>{r?Br(e):Ae(e)})},[Br,er,Ke,F]),Cr=C(()=>Ae(null),[]),Hr=C(()=>{Ae(e=>(e&&Br(e),null))},[Br]),Tr=C(async()=>{const e=Ee;if(!e)return;await pr()&&(Ae(null),Br(e))},[Ee,pr,Br]),Er=C(async e=>{if(null!==Be.current)return;if(!ge)return;if(!p(Ze.current)||Le.current)return;const r=ae(e);if(!await gr(ge,r))return void(Le.current||dr("storefront-editor:save-failed"));const n=oe.publish;if(!ue.canPublish||!n)return void dr("storefront-editor:saved");const t=await mr(()=>n(ge,De.current??void 0));t.ok?(De.current=t.value.version??De.current,dr("storefront-editor:published")):dr("storefront-editor:save-failed")},[ge,oe,ue.canPublish,dr,gr,mr,ae]);/* @__PURE__ */
|
|
2
|
-
return E(D.Provider,{value:{target:G,adapter:oe,capabilities:ue,templateId:ee,currentSlug:re,currentKind:pe,siteId:ne,ready:fe,token:le,tokenRef:ce,notifyParent:dr,bridgeCapabilities:de,runAuthed:kr,docId:ge,data:ye,getLiveData:()=>Te.current??ye,footerOriginSlug:se,error:Ie,redirecting:ir,saveStatus:nr,saveState:xe,autoSaveEnabled:!xe.paused,autoSaveStoppedByConflict:xe.stopped,hasUnsavedEdits:xe.pending||Ce,toggleAutoSave:jr,retrySave:Rr,onChange:vr,flushSave:pr,onPublish:Er,access:Ue,readOnly:null!==P(Ue)||null!==je||null!==Me,readOnlyReason:je,takeOverEditing:Pr,viewReadOnly:Ir,saveConflict:Me,saveUnreachable:Ve,reloadFromServer:wr,navigate:Or,pendingNav:Ee,cancelPendingNav:Cr,discardAndNavigate:Hr,saveAndNavigate:Tr},children:N})}export{D as ScreenDocumentContext,N as ScreenDocumentProvider,M as useScreenDocument};
|