efficient-easel 26.1.0 → 26.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-2S7PJZWH.js +1 -0
- package/dist/{chunk-BBD3FLU3.js → chunk-53ME3GAI.js} +14 -14
- package/dist/{chunk-STQDOTHF.js → chunk-CP6KQP5A.js} +1 -1
- package/dist/{chunk-TTCUC2Q3.js → chunk-FIH23CB7.js} +1 -1
- package/dist/chunk-FT3O7X6U.js +5 -0
- package/dist/{chunk-UCZQWQNS.js → chunk-FYV6GZXP.js} +1 -1
- package/dist/{chunk-6BOOYHHK.js → chunk-I3KB7LH7.js} +3 -3
- package/dist/chunk-IHXQZDDW.js +64 -0
- package/dist/{chunk-BA5X67LQ.js → chunk-JYVQ62TL.js} +1 -1
- package/dist/{chunk-WOA775T4.js → chunk-LDXYMHYW.js} +1 -1
- package/dist/chunk-LUG22U5L.js +1 -0
- package/dist/chunk-M5IKANJ5.js +13 -0
- package/dist/{chunk-SQTVXE5D.js → chunk-MBEUSPIN.js} +4 -4
- package/dist/{chunk-5QUIXGQU.js → chunk-WQXAAVCE.js} +1 -1
- package/dist/chunk-X3EMJ2EX.js +1 -0
- package/dist/{chunk-QAVA4V2C.js → chunk-YDJZX2XS.js} +1 -1
- package/dist/{chunk-7PGO4K5M.js → chunk-ZIEINXSZ.js} +8 -8
- package/dist/{chunk-IMAN6IP5.js → chunk-ZJRMB5KN.js} +4 -4
- package/dist/drag/index.js +1 -1
- package/dist/draw/index.d.ts +1 -0
- package/dist/draw/index.js +1 -1
- package/dist/easel/index.js +1 -1
- package/dist/screen/components/AddBlockRow.js +1 -1
- package/dist/screen/components/AddSidePanel.js +1 -1
- package/dist/screen/components/NodeContextMenu.js +1 -1
- package/dist/screen/components/ScreenChrome.js +1 -1
- package/dist/screen/components/ScreenMount.js +1 -1
- package/dist/screen/components/ScreenStoreProvider.js +1 -1
- package/dist/screen/components/SectionScreenShell.js +16 -16
- package/dist/screen/components/usePartBridge.js +1 -1
- package/dist/screen/index.js +1 -1
- package/dist/screen/lib/content/block-size.d.ts +74 -0
- package/dist/screen/lib/content/block-size.js +1 -0
- package/dist/screen/lib/document/block-set-host.js +1 -1
- package/dist/screen/lib/document/block-size-fields.d.ts +48 -0
- package/dist/screen/lib/document/block-size-fields.js +1 -0
- package/dist/screen/lib/document/box-fields.d.ts +15 -5
- package/dist/screen/lib/document/box-fields.js +1 -1
- package/dist/screen/lib/document/button-fields.js +1 -1
- package/dist/screen/lib/document/image-fields.js +4 -4
- package/dist/screen/lib/document/style-clipboard.js +1 -1
- package/dist/screen/lib/document/style-fields.js +1 -1
- package/dist/screen/lib/document/use-section-ops.js +1 -1
- package/dist/screen/lib/key-scope.js +1 -1
- package/dist/screen/lib/screen-parts.js +1 -1
- package/package.json +13 -1
- package/dist/chunk-5OKOCRXT.js +0 -11
- package/dist/chunk-JQQFB7EZ.js +0 -1
- package/dist/chunk-LSGKADNV.js +0 -5
- package/dist/chunk-O4DQ6O6W.js +0 -1
- package/dist/chunk-VXAGXHKI.js +0 -64
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useSectionOps as o}from"./chunk-LDXYMHYW.js";import{SELECTION_MODE as e}from"./chunk-FT3O7X6U.js";import{decodePartId as r,encodePartId as t}from"./chunk-R4AUZVA3.js";import{useEasel as n}from"./chunk-53ME3GAI.js";import{usePreviewParts as p}from"./chunk-467WWV4I.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}=n(o=>o),I=o(),{setSelectedPartId:f,setSelectHandler:k}=p(),l=d(o=>{const t=r(o);if(!t)return;const{nodeId:n,propKey:p}=t;p?(i(o=>s(o)&&o.nodeId===n&&o.propKey===p?o:{kind:"part",nodeId:n,propKey:p}),a?.(n)):i(o=>"part"===o.kind?e:o)},[i,a]);c(()=>{k(l)},[k,l]);const h=s(m)?t(m.nodeId,m.propKey):null;c(()=>{f(h)},[h,f]);return{selectNode:d(o=>{i(()=>e);const r=u(o);r&&I.select(r)},[i,u,I]),openPartId:h}}export{m as usePartBridge};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import{findCopy as e,repeatCopyWithWrapper as t}from"./chunk-JQQFB7EZ.js";import{DEFAULT_CANVAS_WORDS as n}from"./chunk-TBY3DFKS.js";import{useResolvedFields as o}from"./chunk-K53PQAMP.js";import{toItemSelector as r,fromItemSelector as l,useNodeOps as i,parentStep as s,clickPickPart as a,clickPick as c}from"./chunk-QTHQPJWA.js";import{selectionBox as u,placeWindow as d,offsetOrigin as p,colorRunOf as f,ColorWindow as h,startCanvasTyping as m,textMap as g,richLayout as v}from"./chunk-HZSZT3BE.js";import{DEFAULT_COPY_WORDS as y}from"./chunk-PMRN5Z3T.js";import{useWords as w}from"./chunk-MFIRYGHW.js";import{CANVAS_TYPABLE_EVENT as b,CANVAS_TYPING_EVENT as k}from"./chunk-TOKMFZPB.js";import{setCanvasNonce as S,related as C,isTypingTarget as E,upsertCanvasStyle as x,removeCanvasStyle as I,WORDS_CLEAR as D,frameRectToHost as A,drawnBox as O}from"./chunk-FR7EEKFF.js";import{queryAllCopies as M}from"./chunk-7UFKEX72.js";import{find as $,ROOT_ID as P,getList as R,remove as z,parseZoneKey as N,move as j,duplicate as V,replaceNode as L,createNode as B,insert as K,normalizeData as Z,createResolveCache as F,slotsOf as T,resolveNodeData as H,ROOT_SLOT as W}from"./chunk-EUFDQ4KL.js";import{topLevelSlotKeys as q,fieldsFrom as Q,drawnBlockCount as Y,defaultsFrom as U}from"./chunk-KXM6YRG2.js";import{createContext as X,useEffect as G,useContext as J,useRef as _,useSyncExternalStore as ee,useState as te,useReducer as ne,useMemo as oe,useCallback as re,useLayoutEffect as le}from"react";import{jsx as ie,jsxs as se,Fragment as ae}from"react/jsx-runtime";import{createPortal as ce}from"react-dom";import{registerModalEscapeInterceptor as ue,FloatingBar as de,TextToolbar as pe,LinkPicker as fe}from"efficient-shell/ui";function he(e){return!["setData","setUi","set"].includes(e.type)}var me=(e,t,n,o)=>{const r=R(e,t,N(n));return r?.[o]??null},ge=(e,t,n,o,r)=>{const l=me(e,t,n,o);if(!l)throw new Error(`${r}: nothing at ${n}[${o}]`);return l};function ve(e,t){const{selection:n}=e;return{...e.ui,itemSelector:r(e.data,t,n),selectedSlot:n&&"slot"===n.kind?{parentId:n.parentId,slot:n.slot}:null}}function ye(e,t,n){return n?"node"===n.kind?$(e,t,n.id)?n:null:n.parentId===P?R(e,t,n)?n:null:$(e,t,n.parentId)&&R(e,t,n)?n:null:null}function we(e,t,n,o=!1){const{itemSelector:r,selectedSlot:i,...s}=n;let a=e.selection;var c;return"itemSelector"in n&&(a=l(e.data,t,r??null)),"selectedSlot"in n&&(i?a=(c=i)?{kind:"slot",parentId:c.parentId,slot:c.slot}:null:"slot"===a?.kind&&(a=null)),{...e,selection:a,ui:o?s:{...e.ui,...s}}}function be(e,t,n){const o=ke(e,t,n);if(o===e)return e;const r=ye(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function ke(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 we(e,n,"function"==typeof t.ui?t.ui(ve(e,n)):t.ui);case"set":{const r={data:o,ui:ve(e,n)},l="function"==typeof t.state?t.state(r):t.state;let i=l.data?{...e,data:l.data}:e;return l.ui&&(i=we(i,n,l.ui,!0)),i}case"insert":{const r={...N(t.destinationZone),index:t.destinationIndex},l=B(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:K(o,n,r,l)}}case"replace":{const r=ge(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:L(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=ge(o,n,t.sourceZone,t.sourceIndex,"duplicate"),l=V(o,n,r.props.id),i=me(l,n,t.sourceZone,t.sourceIndex+1);return{...e,data:l,selection:i?{kind:"node",id:i.props.id}:e.selection}}case"reorder":return ke(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=me(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const l={...N(t.destinationZone),index:t.destinationIndex};return{...e,data:j(o,n,r.props.id,l)}}case"remove":{const r=ge(o,n,t.zone,t.index,"remove");return{...e,data:z(o,n,r.props.id)}}default:return e}}var Se={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},Ce={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},Ee=0,xe=()=>`history-${Ee+=1}`;function Ie(e){let t=e.config;const n=e.now??(()=>Date.now()),o=e.historyCoalesceMs??250;let i=e.permissions??{};const s=Z(e.data,t);let a=s,c={data:s,selection:null,ui:{...Ce}};if(e.ui){const{itemSelector:n,selectedSlot:o,...r}=e.ui;c={data:s,selection:o?{kind:"slot",...o}:l(s,t,n??null),ui:{...Ce,...r}}}let u=[{core:c,at:-1/0,sealed:!0,id:xe()}],d=0;const p=e=>{const t=u[d],r=n();!e&&d===u.length-1&&d>0&&!t.sealed&&r-t.at<o?u=[...u.slice(0,d),{...t,core:c,at:r}]:(u=[...u.slice(0,d+1),{core:c,at:r,sealed:e,id:xe()}],d=u.length-1)},f=/* @__PURE__ */new Set;let h=null,m=null,g=0,v=null,y=!1;const w=()=>{for(const e of[...f])e()},b=()=>{u=[...u.slice(0,d),{...u[d],core:c},...u.slice(d+1)]},k=(t,n)=>{g>0?y=y||n:(n?p(!1):c!==t&&b(),c.data!==t.data&&e.onChange?.(c.data),c!==t&&w())},S=e=>{const n=c;if(c=be(c,e,t),c===n)return;const o=e.recordHistory??he(e);k(n,o&&c.data!==n.data)},C=t=>{0===g&&(v=c,y=!1),g+=1;try{t()}catch(e){throw g-=1,0===g&&v&&(c=v,v=null),e}if(g-=1,g>0||!v)return;const n=v;v=null,y&&c.data!==n.data?p(!0):c!==n&&b(),c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},E=e=>{const n=c,o=ye(c.data,t,e);var r,l;(r=o,l=c.selection,r===l||r&&l&&r.kind===l.kind&&("node"===r.kind&&"node"===l.kind?r.id===l.id:"slot"===r.kind&&"slot"===l.kind&&r.parentId===l.parentId&&r.slot===l.slot))||(c={...c,selection:o},k(n,!1))},x=t=>{const n=c;d=t,c=u[d].core,c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},I=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...Se,...i,...n}};let D=I();const A=F(),O={resolveCache:A,async resolveAll({trigger:e="load",metadata:n}={}){const o=c.data,r={type:"root",props:{...o.root.props??{}}},l=[...o.content,...Object.values(o.zones??{}).flat()],[i,...s]=await Promise.all([H(r,t,{cache:A,trigger:e,metadata:n}),...l.map(o=>H(o,t,{cache:A,trigger:e,metadata:n}))]);C(()=>{const n=c;let r=c.data;s.forEach((e,n)=>{if(!e.didChange)return;const i=l[n].props.id,s=$(r,t,i)?.node;s&&s===$(o,t,i)?.node&&(r=L(r,t,i,e.node))}),i.didChange&&r.root===o.root&&(r={...r,root:{...r.root,props:i.node.props,readOnly:i.node.readOnly??r.root.readOnly}}),r!==c.data&&("load"===e&&c.data===a&&(a=r),c={...c,data:r,selection:ye(r,t,c.selection)},k(n,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=$(c.data,t,e)?.node;if(!r)return!1;const l=await H(r,t,{cache:A,trigger:n,metadata:o});if(!l.didChange)return!1;let i=!1;return C(()=>{const n=c;if($(c.data,t,e)?.node!==r)return;const o=L(c.data,t,e,l.node);o!==c.data&&(c={...c,data:o,selection:ye(o,t,c.selection)},k(n,!1),i=!0)}),i},get config(){return t},get loaded(){return a},getState(){if(h&&m===c)return h;const e=c,n={data:e.data,ui:ve(e,t)},o="node"===e.selection?.kind?$(e.data,t,e.selection.id)?.node??null:null;return h={appState:n,selection:e.selection,selectedItem:o,config:t,dispatch:S,history:{back:()=>O.undo(),forward:()=>O.redo(),hasPast:d>0,hasFuture:d<u.length-1,histories:u.map(e=>({id:e.id,state:{data:e.core.data,ui:ve(e.core,t)}})),index:d,setHistoryIndex:e=>{e>=0&&e<u.length&&e!==d&&x(e)}},getPermissions:D,getItemById:n=>$(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return R(e,t,{parentId:o,slot:r})?.[n.index]}(e.data,t,n),getSelectorForId:n=>{const o=r(e.data,t,{kind:"node",id:n});return o?{index:o.index,zone:o.zone??"root:default-zone"}:void 0}},m=e,h},subscribe:e=>(f.add(e),()=>{f.delete(e)}),dispatch:S,batch:C,group:()=>{const e=d,t=u[e].id;let n=!0;return{close:()=>{if(!n)return;if(n=!1,u[e]?.id!==t)return;if(d<=e+1)return void(d===e+1&&(u=[...u.slice(0,d),{...u[d],sealed:!0},...u.slice(d+1)]));const o=u[d];u=[...u.slice(0,e+1),{...o,sealed:!0},...u.slice(d+1)],d=e+1}}},select:e=>E(e?{kind:"node",id:e}:null),selectSlot:e=>E(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){C(()=>{const n=c,o=void 0===e.select?c.selection:e.select;c={...c,data:e.data,selection:ye(e.data,t,o)},k(n,e.data!==n.data)})},load(e,n={}){const o=c,r=Z(e,t);c={...c,data:r,selection:ye(r,t,n.selection??c.selection)},a=r,n.keepHistory||(u=[{core:c,at:-1/0,sealed:!0,id:xe()}],d=0),c!==o&&w()},undo(){d>0&&x(d-1)},redo(){d<u.length-1&&x(d+1)},setPermissions(e){(function(e,t){if(e===t)return!0;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])})(e,i)||(i=e,D=I(),h=null,w())},setConfig(e){e!==t&&(t=e,D=I(),h=null,w())}};return O}function De(e,t,n={}){const o=e=>{if(e.altKey)return;if(!(e.metaKey!==e.ctrlKey))return;const o="KeyZ"===e.code,r="KeyY"===e.code&&!e.shiftKey;(o||r)&&(n.leaveTyping&&E(e.target)||!1!==t.getState?.().getPermissions().edit&&(e.preventDefault(),r||e.shiftKey?t.redo():t.undo()))};return e.addEventListener("keydown",o),()=>e.removeEventListener("keydown",o)}var Ae=X(null),Oe=X(!0);function Me({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return G(()=>{n&&e.resolveAll()},[e,n]),G(()=>{if(t&&"undefined"!=typeof document)return De(document,e)},[e,t]),/* @__PURE__ */ie(Ae.Provider,{value:e,children:/* @__PURE__ */ie(Oe.Provider,{value:t,children:o})})}function $e(){const e=J(Ae);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function Pe(e){const t=$e(),n=_({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 l=e(o);return r.has&&Object.is(r.value,l)?(n.current={view:o,selector:e,value:r.value,has:!0},r.value):(n.current={view:o,selector:e,value:l,has:!0},l)};return ee(t.subscribe,o,o)}function Re(){return function(e){return Pe(e)}}var ze=["--es-accent","--es-accent-tint","--es-accent-tint-strong","--es-accent-line","--es-accent-text","--es-accent-ring","--es-accent-shadow","--es-on-accent","--status-success-solid","--elevation-panel"],Ne="host-tokens";function je(e,t){const n=function(e){const t=e.ownerDocument.defaultView;if(!t)return"";const n=t.getComputedStyle(e),o=[];for(const e of ze){const t=n.getPropertyValue(e).trim();t&&o.push(`${e}: ${t};`)}return o.length?`:root { ${o.join(" ")} }`:""}(e);n?x(t,Ne,n):I(t,Ne)}var Ve="data-easel-block",Le="data-easel-dropzone",Be={},Ke="data-es-mirror",Ze="undefined"==typeof window?G:le;function Fe(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${Ke}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(Ke,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function Te({children:e,id:t="preview-frame",title:o,className:r,style:l,mirrorStyles:i=!0,onDocument:s,height:a="auto",nonce:c}){const u=w("canvas",n),d=_(null),[p,f]=te(null);return Ze(()=>{const e=d.current,t=p?.ownerDocument.defaultView;if("auto"!==a||!e||!p||!t)return;const n=()=>{e.style.height=`${Math.ceil(p.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(p),()=>r?.disconnect()},[p,a]),Ze(()=>{let e=d.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=d.current?.contentDocument??e),e.body||e.documentElement.appendChild(e.createElement("body")),e.body.style.margin="0";const t=e.createElement("div");t.setAttribute("data-easel-entry",""),t.id="frame-root","fill"===a&&t.classList.add("es-frame-fill"),e.body.appendChild(t),S(e,c),f(t),s?.(e);let n=null;const o=d.current?.ownerDocument;if(i&&o){Fe(o,e,c);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>Fe(o,e,c)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}let r=null;const l=d.current;if(l&&o){je(l,e);const t=o.defaultView;if(t&&"MutationObserver"in t){r=new t.MutationObserver(()=>je(l,e)),r.observe(o.head,{childList:!0,subtree:!0,characterData:!0});const n={attributes:!0,attributeFilter:["class","style","data-theme"]};for(const e of[o.documentElement,o.body,l.closest(".es-editor")])e&&r.observe(e,n)}}return()=>{n?.disconnect(),r?.disconnect(),t.remove(),f(null),s?.(null)}},[]),/* @__PURE__ */ie("iframe",{ref:d,id:t,title:o??u.frame,className:["es-canvas-frame","fill"===a?"is-fill":"",r??""].filter(Boolean).join(" "),style:l,children:p?ce(e,p):null})}var He=X(null),We=X(Be),qe=[];function Qe({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:l=120}){const i=$e(),s=Pe(n=>R(n.appState.data,i.config,{parentId:e,slot:t})??qe),a=Pe(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==P),c=Pe(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),u=J(He),d=["es-zone"];return s.length&&d.push("has-children"),e===P&&d.push("is-root"),(a||c)&&d.push("is-area-selected"),null!==u&&u===e&&e!==P&&d.push("is-hovering-area"),n&&d.push(n),/* @__PURE__ */ie("div",{className:d.join(" "),[Le]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${l}px`},children:s.map(e=>/* @__PURE__ */ie(tt,{node:e},e.props.id))})}function Ye(e,t,n,o){const r=oe(()=>{const n={};for(const o of q(Q(e)))n[o]=Object.assign(function(e={}){/* @__PURE__ */
|
|
2
|
-
return ie(
|
|
3
|
-
return ie(
|
|
4
|
-
/* @__PURE__ */ie("div",{ref:i,[
|
|
5
|
-
return ie(We.Provider,{value:e??
|
|
6
|
-
return ie("div",{ref:t,"aria-hidden":"true",className:"es-canvas-outline is-hover is-hover-part",style:n?{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height}:{display:"none"}})}var dt={"--es-words-clear":`${
|
|
7
|
-
return ie("div",{ref:n,"aria-hidden":"true",className:"es-canvas-outline is-selected is-selected-part"+(t?" is-words":""),style:o?{position:"absolute",top:o.top,left:o.left,width:o.width,height:o.height,...dt}:{display:"none"}})}function ft(e,t,n){return mt(e,t?e=>{const n=t(e);return n?[n]:[]}:null,n)[0]??null}var ht=[];function mt(e,t,n){const[o,r]=te(ht),l=_(t);return l.current=t,
|
|
8
|
-
/* @__PURE__ */ie("div",{ref:o,"aria-hidden":"true",className:c,style:s?u(s):{display:"none"}}),a.map((e,t)=>/* @__PURE__ */ie("div",{"aria-hidden":"true",className:c,style:u(e)},t))]});return n&&e?/* @__PURE__ */ie(n,{componentId:e,kind:t,children:d}):d}function vt(e,n){return Array.from(e.querySelectorAll(`[${
|
|
9
|
-
return ie(de,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?
|
|
1
|
+
import{findCopy as e,repeatCopyWithWrapper as t}from"./chunk-LUG22U5L.js";import{DEFAULT_CANVAS_WORDS as n}from"./chunk-TBY3DFKS.js";import{useResolvedFields as o}from"./chunk-K53PQAMP.js";import{toItemSelector as r,fromItemSelector as l,useNodeOps as i,parentStep as s,clickPickPart as a,clickPick as c}from"./chunk-QTHQPJWA.js";import{selectionBox as u,placeWindow as d,offsetOrigin as p,colorRunOf as f,ColorWindow as h,startCanvasTyping as m,textMap as g,richLayout as v}from"./chunk-HZSZT3BE.js";import{DEFAULT_COPY_WORDS as y}from"./chunk-PMRN5Z3T.js";import{useWords as w}from"./chunk-MFIRYGHW.js";import{find as b,ROOT_ID as k,getList as S,remove as C,parseZoneKey as E,move as x,duplicate as I,replaceNode as D,createNode as A,insert as O,normalizeData as M,createResolveCache as $,slotsOf as P,resolveNodeData as R,ROOT_SLOT as z}from"./chunk-EUFDQ4KL.js";import{topLevelSlotKeys as L,fieldsFrom as N,drawnBlockCount as j,defaultsFrom as V}from"./chunk-KXM6YRG2.js";import{CANVAS_TYPABLE_EVENT as K,CANVAS_TYPING_EVENT as B}from"./chunk-TOKMFZPB.js";import{setCanvasNonce as T,related as Z,isTypingTarget as F,upsertCanvasStyle as H,removeCanvasStyle as W,WORDS_CLEAR as q,frameRectToHost as U,drawnBox as Y}from"./chunk-FR7EEKFF.js";import{queryAllCopies as Q}from"./chunk-7UFKEX72.js";import{createContext as G,useEffect as X,useContext as J,useRef as _,useSyncExternalStore as ee,useState as te,useReducer as ne,useMemo as oe,useCallback as re,useLayoutEffect as le}from"react";import{jsx as ie,jsxs as se,Fragment as ae}from"react/jsx-runtime";import{createPortal as ce}from"react-dom";import{registerModalEscapeInterceptor as ue,FloatingBar as de,TextToolbar as pe,LinkPicker as fe}from"efficient-shell/ui";function he(e){return!["setData","setUi","set"].includes(e.type)}var me=(e,t,n,o)=>{const r=S(e,t,E(n));return r?.[o]??null},ge=(e,t,n,o,r)=>{const l=me(e,t,n,o);if(!l)throw new Error(`${r}: nothing at ${n}[${o}]`);return l};function ve(e,t){const{selection:n}=e;return{...e.ui,itemSelector:r(e.data,t,n),selectedSlot:n&&"slot"===n.kind?{parentId:n.parentId,slot:n.slot}:null}}function ye(e,t,n){return n?"node"===n.kind?b(e,t,n.id)?n:null:n.parentId===k?S(e,t,n)?n:null:b(e,t,n.parentId)&&S(e,t,n)?n:null:null}function we(e,t,n,o=!1){const{itemSelector:r,selectedSlot:i,...s}=n;let a=e.selection;var c;return"itemSelector"in n&&(a=l(e.data,t,r??null)),"selectedSlot"in n&&(i?a=(c=i)?{kind:"slot",parentId:c.parentId,slot:c.slot}:null:"slot"===a?.kind&&(a=null)),{...e,selection:a,ui:o?s:{...e.ui,...s}}}function be(e,t,n){const o=ke(e,t,n);if(o===e)return e;const r=ye(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function ke(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 we(e,n,"function"==typeof t.ui?t.ui(ve(e,n)):t.ui);case"set":{const r={data:o,ui:ve(e,n)},l="function"==typeof t.state?t.state(r):t.state;let i=l.data?{...e,data:l.data}:e;return l.ui&&(i=we(i,n,l.ui,!0)),i}case"insert":{const r={...E(t.destinationZone),index:t.destinationIndex},l=A(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:O(o,n,r,l)}}case"replace":{const r=ge(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:D(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=ge(o,n,t.sourceZone,t.sourceIndex,"duplicate"),l=I(o,n,r.props.id),i=me(l,n,t.sourceZone,t.sourceIndex+1);return{...e,data:l,selection:i?{kind:"node",id:i.props.id}:e.selection}}case"reorder":return ke(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=me(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const l={...E(t.destinationZone),index:t.destinationIndex};return{...e,data:x(o,n,r.props.id,l)}}case"remove":{const r=ge(o,n,t.zone,t.index,"remove");return{...e,data:C(o,n,r.props.id)}}default:return e}}var Se={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},Ce={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},Ee=0,xe=()=>`history-${Ee+=1}`;function Ie(e){let t=e.config;const n=e.now??(()=>Date.now()),o=e.historyCoalesceMs??250;let i=e.permissions??{};const s=M(e.data,t);let a=s,c={data:s,selection:null,ui:{...Ce}};if(e.ui){const{itemSelector:n,selectedSlot:o,...r}=e.ui;c={data:s,selection:o?{kind:"slot",...o}:l(s,t,n??null),ui:{...Ce,...r}}}let u=[{core:c,at:-1/0,sealed:!0,id:xe()}],d=0;const p=e=>{const t=u[d],r=n();!e&&d===u.length-1&&d>0&&!t.sealed&&r-t.at<o?u=[...u.slice(0,d),{...t,core:c,at:r}]:(u=[...u.slice(0,d+1),{core:c,at:r,sealed:e,id:xe()}],d=u.length-1)},f=/* @__PURE__ */new Set;let h=null,m=null,g=0,v=null,y=!1;const w=()=>{for(const e of[...f])e()},k=()=>{u=[...u.slice(0,d),{...u[d],core:c},...u.slice(d+1)]},C=(t,n)=>{g>0?y=y||n:(n?p(!1):c!==t&&k(),c.data!==t.data&&e.onChange?.(c.data),c!==t&&w())},E=e=>{const n=c;if(c=be(c,e,t),c===n)return;const o=e.recordHistory??he(e);C(n,o&&c.data!==n.data)},x=t=>{0===g&&(v=c,y=!1),g+=1;try{t()}catch(e){throw g-=1,0===g&&v&&(c=v,v=null),e}if(g-=1,g>0||!v)return;const n=v;v=null,y&&c.data!==n.data?p(!0):c!==n&&k(),c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},I=e=>{const n=c,o=ye(c.data,t,e);var r,l;(r=o,l=c.selection,r===l||r&&l&&r.kind===l.kind&&("node"===r.kind&&"node"===l.kind?r.id===l.id:"slot"===r.kind&&"slot"===l.kind&&r.parentId===l.parentId&&r.slot===l.slot))||(c={...c,selection:o},C(n,!1))},A=t=>{const n=c;d=t,c=u[d].core,c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},O=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...Se,...i,...n}};let P=O();const z=$(),L={resolveCache:z,async resolveAll({trigger:e="load",metadata:n}={}){const o=c.data,r={type:"root",props:{...o.root.props??{}}},l=[...o.content,...Object.values(o.zones??{}).flat()],[i,...s]=await Promise.all([R(r,t,{cache:z,trigger:e,metadata:n}),...l.map(o=>R(o,t,{cache:z,trigger:e,metadata:n}))]);x(()=>{const n=c;let r=c.data;s.forEach((e,n)=>{if(!e.didChange)return;const i=l[n].props.id,s=b(r,t,i)?.node;s&&s===b(o,t,i)?.node&&(r=D(r,t,i,e.node))}),i.didChange&&r.root===o.root&&(r={...r,root:{...r.root,props:i.node.props,readOnly:i.node.readOnly??r.root.readOnly}}),r!==c.data&&("load"===e&&c.data===a&&(a=r),c={...c,data:r,selection:ye(r,t,c.selection)},C(n,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=b(c.data,t,e)?.node;if(!r)return!1;const l=await R(r,t,{cache:z,trigger:n,metadata:o});if(!l.didChange)return!1;let i=!1;return x(()=>{const n=c;if(b(c.data,t,e)?.node!==r)return;const o=D(c.data,t,e,l.node);o!==c.data&&(c={...c,data:o,selection:ye(o,t,c.selection)},C(n,!1),i=!0)}),i},get config(){return t},get loaded(){return a},getState(){if(h&&m===c)return h;const e=c,n={data:e.data,ui:ve(e,t)},o="node"===e.selection?.kind?b(e.data,t,e.selection.id)?.node??null:null;return h={appState:n,selection:e.selection,selectedItem:o,config:t,dispatch:E,history:{back:()=>L.undo(),forward:()=>L.redo(),hasPast:d>0,hasFuture:d<u.length-1,histories:u.map(e=>({id:e.id,state:{data:e.core.data,ui:ve(e.core,t)}})),index:d,setHistoryIndex:e=>{e>=0&&e<u.length&&e!==d&&A(e)}},getPermissions:P,getItemById:n=>b(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return S(e,t,{parentId:o,slot:r})?.[n.index]}(e.data,t,n),getSelectorForId:n=>{const o=r(e.data,t,{kind:"node",id:n});return o?{index:o.index,zone:o.zone??"root:default-zone"}:void 0}},m=e,h},subscribe:e=>(f.add(e),()=>{f.delete(e)}),dispatch:E,batch:x,group:()=>{const e=d,t=u[e].id;let n=!0;return{close:()=>{if(!n)return;if(n=!1,u[e]?.id!==t)return;if(d<=e+1)return void(d===e+1&&(u=[...u.slice(0,d),{...u[d],sealed:!0},...u.slice(d+1)]));const o=u[d];u=[...u.slice(0,e+1),{...o,sealed:!0},...u.slice(d+1)],d=e+1}}},select:e=>I(e?{kind:"node",id:e}:null),selectSlot:e=>I(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){x(()=>{const n=c,o=void 0===e.select?c.selection:e.select;c={...c,data:e.data,selection:ye(e.data,t,o)},C(n,e.data!==n.data)})},load(e,n={}){const o=c,r=M(e,t);c={...c,data:r,selection:ye(r,t,n.selection??c.selection)},a=r,n.keepHistory||(u=[{core:c,at:-1/0,sealed:!0,id:xe()}],d=0),c!==o&&w()},undo(){d>0&&A(d-1)},redo(){d<u.length-1&&A(d+1)},setPermissions(e){(function(e,t){if(e===t)return!0;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])})(e,i)||(i=e,P=O(),h=null,w())},setConfig(e){e!==t&&(t=e,P=O(),h=null,w())}};return L}function De(e,t,n={}){const o=e=>{if(e.altKey)return;if(!(e.metaKey!==e.ctrlKey))return;const o="KeyZ"===e.code,r="KeyY"===e.code&&!e.shiftKey;(o||r)&&(n.leaveTyping&&F(e.target)||!1!==t.getState?.().getPermissions().edit&&(e.preventDefault(),r||e.shiftKey?t.redo():t.undo()))};return e.addEventListener("keydown",o),()=>e.removeEventListener("keydown",o)}var Ae=G(null),Oe=G(!0);function Me({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return X(()=>{n&&e.resolveAll()},[e,n]),X(()=>{if(t&&"undefined"!=typeof document)return De(document,e)},[e,t]),/* @__PURE__ */ie(Ae.Provider,{value:e,children:/* @__PURE__ */ie(Oe.Provider,{value:t,children:o})})}function $e(){const e=J(Ae);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function Pe(e){const t=$e(),n=_({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 l=e(o);return r.has&&Object.is(r.value,l)?(n.current={view:o,selector:e,value:r.value,has:!0},r.value):(n.current={view:o,selector:e,value:l,has:!0},l)};return ee(t.subscribe,o,o)}function Re(){return function(e){return Pe(e)}}var ze=["--es-accent","--es-accent-tint","--es-accent-tint-strong","--es-accent-line","--es-accent-text","--es-accent-ring","--es-accent-shadow","--es-on-accent","--status-success-solid","--elevation-panel"],Le="host-tokens";function Ne(e,t){const n=function(e){const t=e.ownerDocument.defaultView;if(!t)return"";const n=t.getComputedStyle(e),o=[];for(const e of ze){const t=n.getPropertyValue(e).trim();t&&o.push(`${e}: ${t};`)}return o.length?`:root { ${o.join(" ")} }`:""}(e);n?H(t,Le,n):W(t,Le)}var je="data-easel-block",Ve="data-easel-dropzone",Ke={},Be="data-es-mirror",Te="undefined"==typeof window?X:le;function Ze(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${Be}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(Be,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function Fe({children:e,id:t="preview-frame",title:o,className:r,style:l,mirrorStyles:i=!0,onDocument:s,height:a="auto",nonce:c}){const u=w("canvas",n),d=_(null),[p,f]=te(null);return Te(()=>{const e=d.current,t=p?.ownerDocument.defaultView;if("auto"!==a||!e||!p||!t)return;const n=()=>{e.style.height=`${Math.ceil(p.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(p),()=>r?.disconnect()},[p,a]),Te(()=>{let e=d.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=d.current?.contentDocument??e),e.body||e.documentElement.appendChild(e.createElement("body")),e.body.style.margin="0";const t=e.createElement("div");t.setAttribute("data-easel-entry",""),t.id="frame-root","fill"===a&&t.classList.add("es-frame-fill"),e.body.appendChild(t),T(e,c),f(t),s?.(e);let n=null;const o=d.current?.ownerDocument;if(i&&o){Ze(o,e,c);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>Ze(o,e,c)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}let r=null;const l=d.current;if(l&&o){Ne(l,e);const t=o.defaultView;if(t&&"MutationObserver"in t){r=new t.MutationObserver(()=>Ne(l,e)),r.observe(o.head,{childList:!0,subtree:!0,characterData:!0});const n={attributes:!0,attributeFilter:["class","style","data-theme"]};for(const e of[o.documentElement,o.body,l.closest(".es-editor")])e&&r.observe(e,n)}}return()=>{n?.disconnect(),r?.disconnect(),t.remove(),f(null),s?.(null)}},[]),/* @__PURE__ */ie("iframe",{ref:d,id:t,title:o??u.frame,className:["es-canvas-frame","fill"===a?"is-fill":"",r??""].filter(Boolean).join(" "),style:l,children:p?ce(e,p):null})}var He=G(null),We=G(Ke),qe=[];function Ue({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:l=120}){const i=$e(),s=Pe(n=>S(n.appState.data,i.config,{parentId:e,slot:t})??qe),a=Pe(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==k),c=Pe(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),u=J(He),d=["es-zone"];return s.length&&d.push("has-children"),e===k&&d.push("is-root"),(a||c)&&d.push("is-area-selected"),null!==u&&u===e&&e!==k&&d.push("is-hovering-area"),n&&d.push(n),/* @__PURE__ */ie("div",{className:d.join(" "),[Ve]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${l}px`},children:s.map(e=>/* @__PURE__ */ie(tt,{node:e},e.props.id))})}function Ye(e,t,n,o){const r=oe(()=>{const n={};for(const o of L(N(e)))n[o]=Object.assign(function(e={}){/* @__PURE__ */
|
|
2
|
+
return ie(Ue,{parentId:t,slot:o,...e})},{blockCount:0});return n},[e,t]);for(const e of Object.keys(r))r[e].blockCount=j(n[e],o);return r}function Qe(e){return oe(()=>function({zone:t,...n}){/* @__PURE__ */
|
|
3
|
+
return ie(Ue,{parentId:e,slot:t,...n})},[e])}var Ge=["top","bottom","zIndex"];function Xe(e,t,n){e.style[t]!==n&&(e.style[t]=n)}function Je(e){const t=function(e){const t=e?.ownerDocument.defaultView?.getComputedStyle(e);if(!t||"sticky"!==t.position)return null;const n=e=>"auto"===e?"":e;return{top:n(t.top),bottom:n(t.bottom),zIndex:n(t.zIndex)}}(function(e){const t=e.ownerDocument.defaultView;let n=null;for(const o of Array.from(e.children))if("none"!==t?.getComputedStyle(o).display){if(n)return null;n=o}return n}(e));Xe(e,"position",t?"sticky":"relative");for(const n of Ge)Xe(e,n,t?.[n]??"");return!!t}var _e="data-es-canvas-relative";function et(e){e.hasAttribute(_e)&&("relative"===e.style.position&&(e.style.position=""),e.removeAttribute(_e));const t=e.ownerDocument.defaultView?.getComputedStyle(e).position;return t&&"static"!==t?"sticky"===t:(e.style.position||(e.style.position="relative",e.setAttribute(_e,"")),!1)}function tt({node:e}){const t=$e().config,n=t.components[e.type],o=e.props.id,r=_(null),l=function(e,t){return oe(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(je),o.removeAttribute("data-easel-dnd")),t.current=n,n&&(n.setAttribute(je,e),n.setAttribute("data-easel-dnd",e),et(n))},[e,t])}(o,r),i=_(null),s=!!n?.inline;!function(e,t){const n=_(!1),o=_(()=>{});o.current=()=>{const o=e(),l=n.current;n.current=!!o&&t(o),l!==n.current&&r.current()};const r=_(()=>{});Te(()=>o.current()),Te(()=>{const t=e(),l=t?.ownerDocument.defaultView;if(!t||!l)return;const i=()=>o.current();l.addEventListener("resize",i);const s=l.ResizeObserver,a=s?new s(i):null;a?.observe(t);let c=null;return r.current=()=>{c?.disconnect(),c=null;const e=t.ownerDocument.documentElement;n.current&&e&&l.MutationObserver&&(c=new l.MutationObserver(i),c.observe(e,{attributes:!0}))},r.current(),()=>{l.removeEventListener("resize",i),a?.disconnect(),c?.disconnect(),r.current=()=>{}}},[])}(()=>s?r.current:i.current,e=>s?et(e):Je(e));const a=J(We),c=Ye(n,o,e.props,t.components),u=Qe(o);if(!n?.render)return null;const d=n.render,p={...V(n),...e.props,...c},f={renderDropZone:u,isEditing:!0,dragRef:n.inline?l:null,metadata:{...a,...n.metadata}};return n.inline?/* @__PURE__ */ie(d,{...p,editor:f,editMode:!0}):
|
|
4
|
+
/* @__PURE__ */ie("div",{ref:i,[je]:o,"data-easel-dnd":o,style:{position:"relative"},children:/* @__PURE__ */ie(d,{...p,editor:f,editMode:!0})})}function nt({metadata:e}){const t=Pe(e=>e.config),n=Pe(e=>e.appState.data.root).props??{},o=t.root?.render,r=Ye(t.root,k,n,t.components),l=Qe(k),i=/* @__PURE__ */ie(Ue,{parentId:k,slot:z}),s=o?/* @__PURE__ */ie(o,{id:"page-root",...n,...r,editor:{renderDropZone:l,isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:i}):i;/* @__PURE__ */
|
|
5
|
+
return ie(We.Provider,{value:e??Ke,children:s})}var ot=G(void 0),rt=G(void 0);function lt(e,t,n,o){const r=b(e,t,n);return!!r&&(P(r.node,t).length>0||!1===o.whole)}var it=G(void 0),st="data-es-chrome",at=G(void 0);function ct(e){const t=e?.closest?.(`[${st}]`)??null,n=t?.getAttribute(st);return t&&n?{id:n,element:t}:null}function ut({element:e}){const t=_(null),n=ft(t,e?()=>e:null,e);/* @__PURE__ */
|
|
6
|
+
return ie("div",{ref:t,"aria-hidden":"true",className:"es-canvas-outline is-hover is-hover-part",style:n?{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height}:{display:"none"}})}var dt={"--es-words-clear":`${q}px`};function pt({element:e,words:t=!1}){const n=_(null),o=ft(n,e?()=>e:null,e);/* @__PURE__ */
|
|
7
|
+
return ie("div",{ref:n,"aria-hidden":"true",className:"es-canvas-outline is-selected is-selected-part"+(t?" is-words":""),style:o?{position:"absolute",top:o.top,left:o.left,width:o.width,height:o.height,...dt}:{display:"none"}})}function ft(e,t,n){return mt(e,t?e=>{const n=t(e);return n?[n]:[]}:null,n)[0]??null}var ht=[];function mt(e,t,n){const[o,r]=te(ht),l=_(t);return l.current=t,Te(()=>{const t=e.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!l.current)return void r(ht);let o=0;const i=()=>{o=0;const n=e.current?.parentElement??null,i=(l.current?l.current(t):[]).map(e=>function(e,t){if(!e||!t)return null;const n=Y(e),o=t.getBoundingClientRect();return{top:n.top-o.top,left:n.left-o.left,width:n.width,height:n.height}}(e,n)).filter(e=>null!==e);r(e=>{return(t=e)===(n=i)||t.length===n.length&&t.every((e,t)=>function(e,t){return e===t||!!e&&!!t&&e.top===t.top&&e.left===t.left&&e.width===t.width&&e.height===t.height}(e,n[t]))?e:i.length?i:ht;var t,n})},s=()=>{o||(o=(n.requestAnimationFrame??(e=>n.setTimeout(e,16)))(i))};i();const a="MutationObserver"in n?new n.MutationObserver(s):null;a?.observe(t.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0});const c="ResizeObserver"in n?new n.ResizeObserver(s):null;return c?.observe(t.documentElement),n.addEventListener("resize",s),n.addEventListener("scroll",s,{capture:!0,passive:!0}),()=>{a?.disconnect(),c?.disconnect(),n.removeEventListener("resize",s),n.removeEventListener("scroll",s,{capture:!0}),o&&(n.cancelAnimationFrame??n.clearTimeout)(o)}},[n]),o}function gt({id:e,kind:t,overlay:n}){const o=_(null),r=J(rt),l=null!==e&&!0===r?.(e),i=mt(o,e?t=>Q(t,`[${je}="${t.defaultView?.CSS?.escape?t.defaultView.CSS.escape(e):e}"]`):null,e),[s,...a]=i,c=`es-canvas-outline is-${t}${l?" is-shared":""}`,u=e=>({position:"absolute",top:e.top,left:e.left,width:e.width,height:e.height}),d=/* @__PURE__ */se(ae,{children:[
|
|
8
|
+
/* @__PURE__ */ie("div",{ref:o,"aria-hidden":"true",className:c,style:s?u(s):{display:"none"}}),a.map((e,t)=>/* @__PURE__ */ie("div",{"aria-hidden":"true",className:c,style:u(e)},t))]});return n&&e?/* @__PURE__ */ie(n,{componentId:e,kind:t,children:d}):d}function vt(e,n){return Array.from(e.querySelectorAll(`[${je}]`)).find(o=>o.getAttribute(je)===n&&t(o)?.wrapper===e)??null}function yt(e,t,n){const o=g(e,n),r=o.text.length,l=e.ownerDocument;if(!t)return[r,r];let i=null;const s=l.caretPositionFromPoint?.(t.x,t.y);if(s&&e.contains(s.offsetNode))i=o.at(s.offsetNode,s.offset);else{const n=l.caretRangeFromPoint?.(t.x,t.y);n&&e.contains(n.startContainer)&&(i=o.at(n.startContainer,n.startOffset))}if(null===i)return[r,r];const a=o.text;let c=i,u=i;for(;c>0&&!/\s/.test(a[c-1]);)c-=1;for(;u<a.length&&!/\s/.test(a[u]);)u+=1;return[c,u]}function wt({s:e,element:t,toolbar:n,label:o,keys:r}){const l=w("copy",y),i=e.pressed(),s=new Set(n.offered),a=n.colors&&n.colors.length>0?n.colors:null,c=_(null),[m,g]=te(!1),[v,b]=te(null),k=m||null!==v,S=()=>{e.hold(),g(!1),b({href:e.pressed().href})},C=()=>{g(!1),b(null),e.resume()};le(()=>{r.current={escape:()=>!!k&&(C(),!0),link:()=>!!s.has("link")&&(S(),!0)}}),le(()=>()=>{r.current=null},[r]);const E=_(C);E.current=C,X(()=>{if(m)return ue(e=>{const t=c.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(E.current(),!0)},()=>c.current?.querySelector(".es-copy-colors"))},[m]),X(()=>{const n=c.current;if(!k||!n)return;const o=/* @__PURE__ */new Set([n.ownerDocument]),r=t();r&&o.add(r.ownerDocument);const l=o=>{const r=o.target;if(r&&n.contains(r))return;g(!1),b(null);const l=t();r&&l&&l.contains(r)?e.release():e.stop("outside")};for(const e of o)e.addEventListener("pointerdown",l,!0);return()=>{for(const e of o)e.removeEventListener("pointerdown",l,!0)}},[k,e,t]),le(()=>{const e=c.current,n=e?.querySelector(".rosh-tb-wrap > .es-copy-pop"),o=t();if(!(k&&e&&n&&o))return;const r=o.ownerDocument.defaultView?.getSelection()??null,l=r&&r.rangeCount>0&&o.contains(r.getRangeAt(0).startContainer)?r.getRangeAt(0):null,i=(l?u(l,o):null)??(()=>{const e=o.getBoundingClientRect();return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}})(),s=o.ownerDocument.defaultView?.frameElement,a=s?U(s,{left:i.left,top:i.top,width:i.right-i.left,height:i.bottom-i.top}):{left:i.left,top:i.top,width:i.right-i.left,height:i.bottom-i.top},f=o.getBoundingClientRect(),h=s?U(s,{left:f.left,top:f.top,width:f.width,height:f.height}):{left:f.left,top:f.top,width:f.width,height:f.height},m=(e.closest("[data-floating-bar]")??e).getBoundingClientRect(),g={left:a.left,right:a.left+a.width,top:Math.min(a.top,h.top-6,m.top),bottom:Math.max(a.top+a.height,h.top+h.height+6,m.bottom)},v=e.ownerDocument.documentElement,y=(s??o.closest(".es-canvas")??o).getBoundingClientRect(),w={left:Math.max(0,y.left),top:Math.max(0,y.top),right:Math.min(v.clientWidth||y.right,y.right),bottom:Math.min(v.clientHeight||y.bottom,y.bottom)};if(w.right<=w.left||w.bottom<=w.top||0===n.offsetWidth)return;const b=d({anchor:g,size:{width:n.offsetWidth,height:n.offsetHeight},within:{left:y.left,top:y.top,right:y.right,bottom:y.bottom},clip:w,parent:p(n)});n.style.top=`${b.top}px`,n.style.left=`${b.left}px`,n.style.setProperty("--es-pop-point",`${b.point}px`),n.dataset.side=b.above?"above":"below"});const x=a?{run:f(i.color,a),open:m,onToggle:()=>{b(null),m?C():(e.hold(),g(!0))}}:void 0;/* @__PURE__ */
|
|
9
|
+
return ie(de,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?U(o,{left:n.left,top:n.top,width:n.width,height:n.height}):{left:n.left,top:n.top,width:n.width,height:n.height};return{left:r.left-6,top:r.top-6,right:r.left+r.width+6,bottom:r.top+r.height+6}},bounds:()=>{const e=t(),n=e?.ownerDocument.defaultView?.frameElement,o=(n??e?.closest(".es-canvas")??e)?.getBoundingClientRect();return o?{left:o.left,top:o.top,right:o.right,bottom:o.bottom}:{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight}},"aria-label":o,children:/* @__PURE__ */ie("div",{ref:c,children:/* @__PURE__ */ie(pe,{layout:"row",offered:s,pressed:i.marks,onMark:t=>{"link"===t?S():e.press(t)},color:x,linkOpen:null!==v,list:{pressed:i.list,onList:t=>e.list(t)},clear:i.clearable?{onClear:()=>e.clear()}:void 0,alignment:n.alignment,letterCase:n.letterCase,last:n.lastTool?.({className:"rosh-tb-btn",disabled:!1,selected:i.selected,keepCaret:t=>{t.preventDefault(),e.hold()},insert:t=>e.insert(t)}),windows:/* @__PURE__ */se(ae,{children:[m&&a?/* @__PURE__ */ie(h,{colors:a,current:i.color,words:l.colors??y.colors,onPick:t=>e.color(t)}):null,v?
|
|
10
10
|
/* @__PURE__ */ie(fe,{className:"es-copy-link es-copy-pop",value:v.href??"",onApply:t=>{b(null),e.link(t)},onRemove:null!==v.href?()=>{b(null),e.link(null)}:void 0,onCancel:C}):null]})})})})}function bt({element:e,which:t}){const n=_(null),o=ft(n,()=>e(),t);/* @__PURE__ */
|
|
11
|
-
return ie("div",{ref:n,"aria-hidden":"true",className:"es-canvas-outline is-typing",style:o?{position:"absolute",top:o.top,left:o.left,width:o.width,height:o.height,...dt}:{display:"none"}})}function kt({frame:o=!0,className:r,style:l,metadata:i,mirrorStyles:u,onDocument:d,height:p,title:f,nonce:h,hotkeys:y,frameWrapper:
|
|
12
|
-
/* @__PURE__ */ie(He.Provider,{value:
|
|
11
|
+
return ie("div",{ref:n,"aria-hidden":"true",className:"es-canvas-outline is-typing",style:o?{position:"absolute",top:o.top,left:o.left,width:o.width,height:o.height,...dt}:{display:"none"}})}function kt({frame:o=!0,className:r,style:l,metadata:i,mirrorStyles:u,onDocument:d,height:p,title:f,nonce:h,hotkeys:y,frameWrapper:k,overlay:S,children:C,typing:E,passThrough:x}){const I=$e(),D=J(ot),A=x??D,O=J(Oe),M=w("canvas",n),$=y??O,[R,z]=te(void 0),L=Pe(e=>"node"===e.selection?.kind?e.selection.id:null),[N,j]=te(null),[V,T]=te(null),F=J(it),H=J(at),[W,q]=te(null),[,U]=ne(e=>e+1,0),[,Y]=ne(e=>e+1,0),Q=e=>{F?.select(e),Y()},[G,ee]=te(null),oe=_(null),re=_(null),[,le]=te(0),ae=_(E);ae.current=E;const ce=_(null),ue=_(null),de=()=>{if(!L)return null;const e=ae.current?.atSelection?.()?.element()??null;if(!e)return null;const t=ue.current?.ownerDocument;if(F){const n=F.selected()&&t?F.selectedPart?.(t)??null:null;return n&&Z(n.element,e)?n.element:null}const n=b(I.getState().appState.data,I.config,L);return n&&0===P(n.node,I.config).length?e:null},pe=Pe(e=>e.appState.data),fe=F?.selected()??null;X(()=>{const e=ue.current?.ownerDocument,t=e?.defaultView?.CustomEvent;if(!e||!t)return;const n=L&&!G&&ae.current?.atSelection?.()?L:null,o=n?de():null;e.dispatchEvent(new t(K,{detail:o?{id:n,words:o}:{id:n}}))},[L,G,pe,fe]);const he=e=>{const t=ue.current?.ownerDocument,n=t?.defaultView?.CustomEvent;t&&n&&t.dispatchEvent(new n(B,{detail:{typing:e}}))},me=(e,t)=>{oe.current?.s.stop("stop");const n=e.element();if(!n)return!1;const o=ge(e,n),r=I.group(),l=e.element,i=m({element:l,value:o?.value??e.value,rules:e.rules,multiline:e.multiline,skip:e.skip,caret:yt(n,t,e.skip),write:o?.write??e.write,remount:e.remount,onSelect:()=>le(e=>e+1),onEscape:()=>ce.current?.escape()??!1,onLinkKey:()=>ce.current?.link()??!1,end:e=>{r.close(),oe.current?.element===l&&(oe.current=null),ee(null),he(!1),ae.current?.onChange?.({typing:!1,why:e})}});if(!i)return r.close(),!1;const s=n.closest?.(`[${je}]`)?.getAttribute(je);return s&&I.select(s),oe.current={s:i,element:l,target:e},ee(()=>l),j(null),he(!0),ae.current?.onChange?.({typing:!0,element:n}),!0},ge=(e,n)=>{const o=e.key;if(!o||!ae.current?.onCopyText)return null;const r=t(n),l=n.closest?.(`[${je}]`),i=l?.getAttribute(je);if(!r||!i||!r.wrapper.contains(l))return null;const{copy:s}=r,a=ae.current.copyValue?.({...s,nodeId:i,key:o}),c=g(n,e.skip).text,u=a??(v(e.value,e.rules).text===c?e.value:c),d={ownerId:s.ownerId,slot:s.slot,index:s.index,...s.outer?{outer:s.outer}:{},nodeId:i,key:o};return{value:u,write:t=>{const n=ae.current?.onCopyText;n&&!1!==n({...d,text:t})||e.write(t)}}};X(()=>()=>oe.current?.s.stop("stop"),[]);const ve=e=>{const t=oe.current?.element();return Boolean(t&&t.contains(e))},ye=(e,t)=>lt(I.getState().appState.data,I.config,e,t),we=e=>{const t=e.closest?.(`[${je}]`)?.getAttribute(je);if(!t)return;const n=I.getState(),o="node"===n.selection?.kind?n.selection.id:null,r=F?.partAt(e,t)??null;if(r){const e=a(n.appState.data,I.config,t,r.id,o,F?.selected()??null,A);if(e)return{node:e.node,part:e.part?r:null}}return{node:c(n.appState.data,I.config,t,o,A)??t,part:null}},be=e=>{if("Enter"!==e.key||e.defaultPrevented||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;if(oe.current)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select, button"))return;const n=ke(),o=void 0===n?ae.current?.atSelection?.():n;o&&me(o,null)&&e.preventDefault()},ke=()=>{const t=ae.current,n=re.current;if(!t?.onCopyText||!n?.copy||n.node!==L)return;const o=ue.current,r=o?e(o,n.copy):null,l=r?vt(r,n.node):null;if(!l)return null;const i=t.atSelection?.()??null,s=i?.element()??null;if(!i||!s)return null;if(l.contains(s))return i;const a=function(e,t){const n=e.closest(`[${je}]`);if(!n||n.getAttribute(je)!==t.getAttribute(je))return null;const o=[];for(let t=e;t!==n;t=t.parentElement)o.unshift(Array.prototype.indexOf.call(t.parentElement.children,t));let r=t;for(const e of o)r=r?.children[e];return r&&r.tagName===e.tagName?r:null}(s,l);return a?t.at(a):null},Se=(e,n)=>{if(!ae.current?.onCopyText)return null;const o=t(e);return o&&vt(o.wrapper,n)?o.copy:null},Ce=ue.current?.ownerDocument??null,Ee=F?.selected()&&Ce&&L?F.selectedPart?.(Ce)??null:null,xe=Ee&&L&&ye(L,Ee)?Ee.element:null,Ie=H?.selected()??null,Ae=Ie&&Ce?Array.from(Ce.querySelectorAll(`[${st}]`)).find(e=>e.getAttribute(st)===Ie)??null:null,Me=G?null:de(),Re=/* @__PURE__ */se("div",{ref:ue,className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;if(t.closest?.("a[href]")&&e.preventDefault(),oe.current){if(ve(t))return;oe.current.s.stop("outside")}const n=t.ownerDocument?.getSelection?.();n&&n.rangeCount>0&&n.isCollapsed&&n.removeAllRanges();const o=H?ct(t):null;if(H&&o)return H.select(o.id),q(null),void U();const r=we(t);if(re.current=void 0!==r?{node:r.node,copy:Se(t,r.node)}:null,void 0!==r)return I.select(r.node),void(F&&(r.part?.id??null)!==F.selected()&&Q(r.part?.id??null));t.hasAttribute?.(Ve)||(I.select(null),F?.selected()&&Q(null))},onDoubleClick:e=>{const t=ae.current;if(!t||ve(e.target))return;const n=t.at(e.target);n&&me(n,{x:e.clientX,y:e.clientY})&&e.preventDefault()},onKeyDown:e=>be(e),onMouseOver:e=>{if(oe.current)return;const t=H?ct(e.target):null;if(t?.element!==W?.element&&q(t),t)return null!==N&&j(null),void(null!==V&&T(null));const n=we(e.target),o=!!n?.part&&ye(n.node,n.part),r=n?.part&&o&&n.part.id!==F?.selected()?n.part:null,l=!n||n.part&&o?null:n.node;l!==N&&j(l),r?.id===V?.id&&r?.element===V?.element||T(r)},onMouseLeave:()=>{j(null),T(null),q(null)},children:[
|
|
12
|
+
/* @__PURE__ */ie(He.Provider,{value:N,children:/* @__PURE__ */ie(nt,{metadata:i})}),
|
|
13
13
|
/* @__PURE__ */se("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
|
|
14
|
-
/* @__PURE__ */ie(gt,{id:!
|
|
15
|
-
/* @__PURE__ */ie(gt,{id:
|
|
16
|
-
return se("div",{className:"es-canvas"+(r?` ${r}`:""),style:l,"data-easel-preview":"","data-es-typing":
|
|
14
|
+
/* @__PURE__ */ie(gt,{id:!G&&N&&N!==L?N:null,kind:"hover",overlay:S}),F?/* @__PURE__ */ie(ut,{element:G||!V||V.id===F.selected()?null:V.element}):null,Me||xe?/* @__PURE__ */ie(pt,{element:G?null:Me??xe,words:null!==Me}):null,H?/* @__PURE__ */ie(ut,{element:G||!W||W.element===Ae?null:W.element}):null,Ae?/* @__PURE__ */ie(pt,{element:G?null:Ae}):null,
|
|
15
|
+
/* @__PURE__ */ie(gt,{id:G||xe||Me||Ae?null:L,kind:"selected",overlay:S}),G?/* @__PURE__ */ie(bt,{element:()=>{const e=G?.()??null;return e?Ee&&Z(Ee.element,e)?Ee.element:e:null},which:Ee?.element??G}):null]}),C]}),ze=k?/* @__PURE__ */ie(k,{document:R,children:Re}):Re;X(()=>{if(R&&$)return De(R,I)},[R,$,I]),X(()=>{if(!R)return;const e=e=>{if("Enter"===e.key)return void be(e);if("Escape"!==e.key||e.defaultPrevented)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select"))return;const n=I.getState();if("node"!==n.selection?.kind)return;if(F?.selected())return void Q(null);const o=s(n.appState.data,I.config,n.selection);"node"===o?.kind&&I.select(o.id)};return R.addEventListener("keydown",e),()=>R.removeEventListener("keydown",e)},[R,I,F]);/* @__PURE__ */
|
|
16
|
+
return se("div",{className:"es-canvas"+(r?` ${r}`:""),style:l,"data-easel-preview":"","data-es-typing":G?"":void 0,children:[G&&oe.current?.target.toolbar?/* @__PURE__ */ie(wt,{s:oe.current.s,element:oe.current.element,toolbar:oe.current.target.toolbar,label:M.textTools,keys:ce}):null,o?/* @__PURE__ */ie(Fe,{mirrorStyles:u,onDocument:e=>{z(e??void 0),d?.(e)},height:p,title:f,nonce:h,children:ze}):/* @__PURE__ */ie("div",{id:"preview-frame","data-easel-entry":"",children:ze})]})}function St(e={}){const t=$e(),n=Pe(e=>e.appState.data);return i({...e,data:n,config:t.config,commit:(e,{select:n})=>t.run({data:e,select:n})})}function Ct(){return It(Pe(e=>e.selectedItem))}function Et(){try{return Ct()}catch{return null}}function xt(){return It(null)}function It(e){const t=$e(),n=Pe(e=>e.config),r=t.resolveCache,l=Pe(e=>e.appState.data.root),i=e?e.props.id:"root",s=l.props??{},a=oe(()=>e||{type:"root",props:s},[e,s]),c=e?n.components[e.type]:n.root,u=t.getState(),d=e?b(u.appState.data,n,i):null,p=d&&"root"!==d.place.parentId?d.place.parentId:null,f=p?u.getItemById(p)??null:null,{fields:h}=o({id:i,node:a,block:c,parent:f,appState:u.appState}),m=Pe(t=>!1===t.getPermissions(e?{item:e}:{root:!0}).edit),g=re(e=>{(async()=>{const o=t.getState();if("root"!==i){const l=o.getItemById(i),s=o.getSelectorForId(i);if(!l||!s)return;const a={...l,props:{...l.props,...e}},{node:c}=await R(a,n,{cache:r,trigger:"replace"}),u=t.getState().getSelectorForId(i);if(!u)return;return void t.dispatch({type:"replace",destinationZone:u.zone??"root:default-zone",destinationIndex:u.index,data:c})}const l=o.appState.data.root.props??{},{node:s}=await R({type:"root",props:{...l,...e}},n,{cache:r,trigger:"replace"});t.dispatch({type:"replaceRoot",root:{props:s.props,readOnly:s.readOnly},recordHistory:!0})})()},[t,n,r,i]),v=re((e,t)=>g({[e]:t}),[g]);return{id:i,node:a,fields:h,values:a.props,readOnly:m,onChange:v,onChangeMany:g}}export{st as CHROME_ATTR,at as CanvasChromeContext,Fe as CanvasFrame,it as CanvasPartsContext,ot as CanvasPassThroughContext,rt as CanvasSharedContext,Ce as DEFAULT_UI,kt as EaselCanvas,Me as EaselProvider,nt as EditDocument,De as bindUndoKeys,Ie as createEasel,Re as createUseEasel,lt as partHasOwnBox,he as recordsByDefault,be as reduce,ve as uiView,Pe as useEasel,$e as useEaselApi,St as useEaselNodeOps,xt as useRootFields,Ct as useSelectedFields,Et as useSelectedHost,ye as validSelection};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEaselSession as e}from"./chunk-YM4UEGBV.js";import{useHostEscape as n}from"./chunk-LX23TCTP.js";import{DEFAULT_SCREEN_WORDS as t}from"./chunk-Q3VAJMXS.js";import{styleMenuItems as o}from"./chunk-CWELHADJ.js";import{ROOT_ZONE as l}from"./chunk-TCAAOYQY.js";import{repeatCopyAt as r}from"./chunk-
|
|
1
|
+
import{useEaselSession as e}from"./chunk-YM4UEGBV.js";import{useHostEscape as n}from"./chunk-LX23TCTP.js";import{DEFAULT_SCREEN_WORDS as t}from"./chunk-Q3VAJMXS.js";import{styleMenuItems as o}from"./chunk-CWELHADJ.js";import{ROOT_ZONE as l}from"./chunk-TCAAOYQY.js";import{repeatCopyAt as r}from"./chunk-LUG22U5L.js";import{easelMenuEntries as i,menuLabel as c}from"./chunk-FIVU2COQ.js";import{createNodeClipboard as s,nodeMenuItems as a}from"./chunk-P5VYGWYO.js";import{DEFAULT_NODE_MENU_WORDS as u}from"./chunk-WK3AFPXY.js";import{zoneKey as d,ROOT_SLOT as p,ROOT_ID as f}from"./chunk-EUFDQ4KL.js";import{useCanvasEvent as m}from"./chunk-TOKMFZPB.js";import{isTypingTarget as y,framePointToHost as h}from"./chunk-FR7EEKFF.js";import{useState as k,useCallback as b,useRef as v,useEffect as x}from"react";import{ContextMenu as g}from"efficient-shell/ui";import{TrashIcon as w,AddIcon as C,MoveUpIcon as O,MoveDownIcon as z,UndoIcon as A,RedoIcon as P,PasteIcon as j,StylesIcon as E,LayersIcon as M,CopyIcon as D}from"efficient-shell/icons/efficient";import{jsx as K}from"react/jsx-runtime";function L(e,n){const t=[],o=/* @__PURE__ */new Set;let r={zone:n.zone,index:n.index};for(;r;){const n=e.nodeAt(r.zone,r.index);if(!n||o.has(n.props.id))break;if(o.add(n.props.id),t.push({zone:r.zone,index:r.index,node:n,parentType:null}),r.zone===l)break;const i=r.zone.lastIndexOf(":");if(i<=0)break;r=e.locate(r.zone.slice(0,i))}for(let e=0;e<t.length-1;e+=1)t[e].parentType=t[e+1].node.type;return t}var T=s(),I=/* @__PURE__ */new WeakMap;function S(e){if(e.claimsPage)return T;const n=e.registry;if(!n)return e.cache("easel:node-clipboard",s);let t=I.get(n);return t||(t=s(),I.set(n,t)),t}function Y(){return S(e())}function X(e,n,t){if(n===l){const{floor:n,cap:o}=e.sectionBand();return{parentId:f,slot:p,index:Math.min(Math.max(t,n),o)}}const o=n.lastIndexOf(":");return{parentId:n.slice(0,o),slot:n.slice(o+1),index:t}}function F(e,n,t){const o=e.isPinned(n,t),l=!o&&!e.isLocked(n)&&!e.duplicateBlocked(n),r=e.permits?.(n)??{duplicate:!0,delete:!0};return{copy:!o&&r.duplicate,cut:l&&r.duplicate&&r.delete,delete:l&&r.delete}}function U(e,n,t){const o=e.canPasteAt;if(!o)return d(n.from)===t.zone?X(e,t.zone,t.index+1):null;for(const l of L(e,t)){const t=X(e,l.zone,l.index+1);if(o(n,t))return t}return null}function B(e){if(e.defaultPrevented||e.altKey||e.shiftKey)return null;if(y(e.target))return null;const n=e.target,t=n&&"ownerDocument"in n?n.ownerDocument??n:null,o=t?.getSelection?.();if(o&&!o.isCollapsed&&o.toString().trim())return null;if(!e.metaKey&&!e.ctrlKey)return"Delete"===e.key?"delete":null;const l=e.code||(1===e.key.length?`Key${e.key.toUpperCase()}`:"");return"KeyC"===l?"copy":"KeyX"===l?"cut":"KeyV"===l?"paste":null}function R(e,n,t,o){const l=e.nodeAt(t.zone,t.index);if(!l)return null;const r=l.props.id,i=e.labelOf(l.type,t.zone),c=F(e,l,t.zone);if("copy"===n)return c.copy?(e.nodeOps.copy(r,i),{done:"copied",name:i}):null;if(o.readOnly)return null;if("cut"===n)return c.cut?(e.nodeOps.cut(r,i),{done:"cut",name:i}):null;if("delete"===n)return c.delete?(e.nodeOps.remove(r),{done:"deleted",name:i}):null;const s=o.held;if(!s)return null;const a=e.isPinned(l,t.zone)?null:U(e,s,t);return a?(e.nodeOps.paste(a),{done:"pasted",name:s.label}):(e.onPasteRefused(s),{done:"refused",name:s.label})}function V(e,n){const{zone:t,index:r}=n,i=e.nodeAt(t,r);if(!i)return[];const c=i.props.id,s=e.labelOf(i.type,t),u=Boolean(i.props._hidden),d=e.nodeOps,p=e.isPinned(i,t),f=e.isLocked(i),m=!p&&!f&&!e.duplicateBlocked(i),y=e.permits?.(i)??{duplicate:!0,delete:!0},h=F(e,i,t),k=L(e,n),b=d.held,v=b&&!p?U(e,b,n):null,x=!e.readOnly,g=e.style?o({held:x?e.style.held():null,canCopy:e.style.canCopy(i,t),onCopy:()=>e.style?.copy(i,t),onPaste:()=>e.style?.paste(t,r,i),words:e.words?.styleClipboard}):[];return a({title:s,words:e.words?.menu,layer:{group:"pick",items:k.flatMap((n,t)=>{const o={label:e.rowNameOf(n.node,n.zone),checked:0===t,onClick:()=>e.selectAt(n.zone,n.index,n.node.props.id,n.parentType)},r=n.zone===l?null:e.slotRung?.(n.zone)??null;return r?[o,{label:r.label,checked:!1,onClick:r.select}]:[o]})},actions:{duplicate:x&&m&&y.duplicate?()=>d.duplicate(c):void 0,...W(x&&!p,e=>d.canStep(c,e),e=>d.step(c,e)),copy:h.copy?()=>d.copy(c,s):void 0,cut:x&&h.cut?()=>d.cut(c,s):void 0,paste:x&&b&&v?{label:b.label,run:()=>d.paste(v)}:void 0,rename:x&&e.renamePropOf(i,t)?()=>e.beginRename(t,r):void 0,hide:!x||f||p?void 0:{hidden:u,run:()=>d.setProps(c,{_hidden:!u})},delete:x&&m&&y.delete?()=>d.remove(c):void 0},style:g,extras:Q(x?N(e,n.copy):null,e.menuRows?.(i,t,r)),pinnedLine:p?G(e).pinned:void 0})}function N(e,n){const o=e.copyItem;if(!o||!n)return null;const l=G(e),r=t.menu,i=e=>l[e]??r[e]??"",c={ownerId:n.ownerId,slot:n.slot,index:n.index,...n.outer?{outer:n.outer}:{}},s=e=>()=>o({...c,action:e});return{make:[{label:i("itemAddAfter"),icon:/* @__PURE__ */K(C,{}),onClick:s("addAfter")},{label:i("itemMoveEarlier"),icon:/* @__PURE__ */K(O,{}),onClick:s("moveEarlier"),disabled:n.index<=0},{label:i("itemMoveLater"),icon:/* @__PURE__ */K(z,{}),onClick:s("moveLater"),disabled:n.index>=n.count-1}],remove:[{label:i("itemDelete"),icon:/* @__PURE__ */K(w,{}),danger:!0,onClick:s("delete")}]}}function Q(e,n){if(!e)return n??void 0;if(!n)return e;return Object.fromEntries(["pick","make","change","remove"].map(t=>[t,[...e[t]??[],...n[t]??[]]]).filter(([,e])=>e.length>0))}function W(e,n,t){return e?{moveUp:n(-1)?()=>t(-1):null,moveDown:n(1)?()=>t(1):null}:{}}var G=e=>e.words?.screen??t.menu;function Z(e){const n=G(e),o=!e.readOnly,r=[];o&&e.history.hasPast&&r.push({label:n.undo,icon:/* @__PURE__ */K(A,{}),shortcut:"⌘Z",onClick:e.history.back}),o&&e.history.hasFuture&&r.push({label:n.redo,icon:/* @__PURE__ */K(P,{}),shortcut:"⇧⌘Z",onClick:e.history.forward});const i=[],c=e.nodeOps.held,s=X(e,l,e.sectionBand().cap);if(o&&c&&(e.canPasteAt?e.canPasteAt(c,s):d(c.from)===l)){const n=s,t=e.words?.menu??u;i.push({label:t.pasteNamed({paste:t.paste,label:c.label}),icon:/* @__PURE__ */K(j,{}),shortcut:"⌘V",onClick:()=>e.nodeOps.paste(n)})}const a=[r,i,[...e.openPageStyles?[{label:e.pageStylesLabel??t.pageStyles,icon:/* @__PURE__ */K(E,{}),onClick:e.openPageStyles}]:[],{label:n.collapseAll,icon:/* @__PURE__ */K(M,{}),onClick:e.collapseAll}]].filter(e=>e.length>0),p={label:"—",onClick:()=>{}};return a.flatMap((e,n)=>n?[p,...e]:e)}function J(e,n){const t=n.selectionStart??0,o=n.selectionEnd??0,l=n.value.slice(t,o),r=e=>{n.focus(),n.setRangeText(e,t,o,"end"),n.dispatchEvent(new Event("input",{bubbles:!0}))},i=e.words?.menu??u,c=G(e),s=[];l&&(s.push({label:i.copy,icon:/* @__PURE__ */K(D,{}),shortcut:"⌘C",onClick:()=>navigator.clipboard?.writeText(l)}),s.push({label:i.cut,icon:/* @__PURE__ */K(D,{}),shortcut:"⌘X",onClick:()=>{navigator.clipboard?.writeText(l),r("")}})),s.push({label:i.paste,icon:/* @__PURE__ */K(j,{}),shortcut:"⌘V",onClick:()=>{navigator.clipboard?.readText().then(e=>{e&&r(e)}).catch(()=>e.onPasteRefused())}});const a=[s,n.value?[{label:c.selectAll,shortcut:"⌘A",onClick:()=>{n.focus(),n.select()}}]:[]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return a.flatMap((e,n)=>n?[d,...e]:e)}function _(e){return e.shiftKey}function H(e,t){const[o,l]=k(null),i=b(()=>l(null),[]);n(null!==o,i);const c=v(e);c.current=e;const s=b(e=>{const n=c.current,t=n.keys;if(!t)return;const o=B(e);if(!o)return;const l=t.selected();if(!l)return;const r=R(n,o,l,{readOnly:t.readOnly,held:t.held()});r&&(e.preventDefault(),t.onDone?.(r))},[]),a=e.keys?.target??null;x(()=>{if(!a)return;const e=e=>s(e);return a.addEventListener("keydown",e),()=>a.removeEventListener("keydown",e)},[a,s]),m(t,"keydown",s);const u=b(n=>{if(_(n))return;const t=n.target;if(t?.closest?.("[data-slot-zone]"))return n.preventDefault(),void l(null);const o=function(e){const n=e?.closest?.("input, textarea");return n&&("INPUT"!==n.tagName||["text","search","url","email","tel","number",""].includes(n.type))?n:null}(t);if(o)return n.preventDefault(),void l({kind:"input",x:n.clientX,y:n.clientY,el:o,owner:t});const r=t?.closest?.("[data-node-id]")?.getAttribute("data-node-id"),i=r?e.locate(r):null;n.preventDefault(),l(i?{kind:"node",x:n.clientX,y:n.clientY,...i,owner:t}:{kind:"empty",x:n.clientX,y:n.clientY,owner:t})},[e]);m(t,"contextmenu",n=>{if(_(n)||!t)return;const o=n.target?.closest?.("[data-easel-block]")??null,i=o?.getAttribute("data-easel-block"),c=i?e.locate(i):null;n.preventDefault();const s=h(t.frame,n.clientX,n.clientY),a=t.frame,u=o?r(o):null;l(c?{kind:"node",...s,...c,copy:u,owner:a}:{kind:"empty",...s,owner:a})}),m(t,"mousedown",i),m(t,"scroll",i,{on:"window"});return{onEditorContextMenu:u,menu:o?/* @__PURE__ */K($,{host:e,target:o,onClose:i}):null,closeMenu:i}}function $({host:e,target:n,onClose:t}){const o="node"===n.kind?V(e,n):"input"===n.kind?J(e,n.el):Z(e);return 0===o.length?null:/* @__PURE__ */K(g,{at:{x:n.x,y:n.y},owner:n.owner??null,onClose:t,"aria-label":c(o),items:i(o)})}export{T as EASEL_NODE_CLIPBOARD,L as ancestorChain,S as nodeClipboardOf,F as nodeClipboardRules,V as nodeMenuItems,B as nodeShortcut,Z as pageMenuItems,U as pastePlace,R as runNodeShortcut,J as textMenuItems,Y as useNodeClipboard,H as useNodeContextMenu};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{styleFieldBuilders as e,keptByRow as o}from"./chunk-
|
|
1
|
+
import{styleFieldBuilders as e,keptByRow as o}from"./chunk-ZJRMB5KN.js";import{boxFieldBuilders as s,PHONE_KEY_ACCESS as t,phoneTwinFields as l,section as r}from"./chunk-M5IKANJ5.js";import{deviceField as i}from"./chunk-7GGNFLHT.js";import{TextColorIcon as n,GroundIcon as c}from"efficient-shell/icons/efficient";import{jsx as d}from"react/jsx-runtime";var u={fill:"buttonColor",fillOpacity:"buttonFillOpacity",border:"buttonBorder",text:"buttonTextColor",corners:"buttonCorners",cornerSides:"buttonCornerSides"},a={top:"buttonPaddingTop",right:"buttonPaddingRight",bottom:"buttonPaddingBottom",left:"buttonPaddingLeft"};function f(f){const b=s(f.say),p=e(f.say),y=u,F=f.style,g=f.phone??t;return{_dSize:r("Size"),...b.sidesPaddingFields({keys:a,group:!1,...f.padding}),_dDesign:r("Design"),[y.fill]:p.colourField({key:y.fill,access:F,label:"Fill color",icon:/* @__PURE__ */d(c,{}),useFollows:f.follows.useFill,usePresets:f.usePresets,resetTo:f.resetTo,opacity:{key:y.fillOpacity,useUnset:f.follows.useFillOpacity}}),[y.fillOpacity]:o(y.fill),[y.border]:p.borderField({key:y.border,access:F,useFollows:f.follows.useBorder}),[y.text]:p.colourField({key:y.text,access:F,label:"Text color",icon:/* @__PURE__ */d(n,{}),useFollows:f.follows.useText,usePresets:f.usePresets,resetTo:f.resetTo}),[y.corners]:p.cornersField({key:y.corners,access:F,sidesKey:y.cornerSides,useFollows:f.follows.useCorners}),[y.cornerSides]:o(y.corners),_dLayout:r("Layout"),...l("align",b.blockAlignmentField({phone:!0},""),g),align:i("desktop",b.blockAlignmentField())}}export{a as BUTTON_PAD_KEYS,u as BUTTON_STYLE_KEYS,f as buttonFieldSet};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{usePickFollowsSelection as n}from"./chunk-NCXYC7WI.js";import{slotFieldsOf as e,slotChildrenIn as t}from"./chunk-TCAAOYQY.js";import{EaselCanvas as r,useSelectedFields as o}from"./chunk-53ME3GAI.js";import{Inspector as i}from"./chunk-R76XMEKT.js";import{fieldIsShown as u}from"./chunk-BPXEFVSQ.js";import{createContext as l,useContext as s}from"react";import{DesktopIcon as c}from"efficient-shell/icons/efficient";import{jsx as f}from"react/jsx-runtime";var a={kind:"selection"};function d(n){return"selection"===n.kind}function p(n,e){if(d(n)&&d(e))return!0;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 m(n){const e=n;return"string"==typeof e.nodeId&&"string"==typeof e.slot}function k(n,t){const r=n.components?.[t.type]?.fields??{};return e(n,t.type).filter(n=>u(r[n],{values:t.props}))}function h(n,e){return k(n,e).flatMap(n=>t(e,n))}function v(n,e,t){const r=n.slotsOf?.(t);return r||k(e,t).map(n=>({slot:n,label:n,rung:!1}))}function y(n,e){return n.isFirst?n.isFirst(e):e.type===n.first}function g(n,e){return n.isLast?n.isLast(e):e.type===n.last}var b={},O=()=>b,j=()=>"",w=()=>null,C=()=>{},S={isLockedBlock:()=>!1,duplicateBlocked:()=>null,nestDepth:()=>0,newSectionNode:()=>null,canAddTo:()=>null,blockIsOffered:()=>!0},L={labelAtLevel:(n,e,t)=>t,descriptions:{},categoryLabel:()=>{},firstSection:null,blockRowName:(n,e)=>e(n.type),plainText:n=>n,Icon:()=>null,Thumbnail:()=>null,useProducts:()=>null},I={options:[{id:"desktop",label:"Desktop",icon:/* @__PURE__ */f(c,{})}],initial:"desktop",fluid:"desktop",widths:{desktop:2e3}},N={read:()=>"sections",write:()=>{},forSelection:(n,e)=>n?"sections":e},P={first:null,last:null,firstGroup:null,lastGroup:null,isSectionGroup:()=>!1,sectionGroupZone:()=>"",panelOf:()=>null};function A(){/* @__PURE__ */
|
|
2
|
+
return f(r,{height:"fill"})}function B(){const{id:n,fields:e,values:t,readOnly:r,onChange:u}=o();/* @__PURE__ */
|
|
3
|
+
return f("div",{className:"es-sidepanel es-sidepanel--right",children:/* @__PURE__ */f(i,{fields:e,values:t,onChange:u,readOnly:r,idPrefix:n})})}var D=l({});function G({parts:n,children:e}){/* @__PURE__ */
|
|
4
|
+
return f(D.Provider,{value:n,children:e})}function T(){return s(D)}function x(){return(T().useOwnerName??j)()}function F(){return(T().useDocumentLabel??w)()}function E(n,e,t,r){return(T().useBridges??O)(n,e,t,r)}function M(n){return(T().useStandaloneBridges??O)(n)}function R(n,e){(T().useDocumentPass??C)(n,e)}function X(){return T().blockRules??S}function Y(){return T().blockLook??L}function K(){return T().devices??I}function Q(){return T().leftView??N}function V(){return T().pinned??P}function H(){return T().saveSwitch??!0}function W(e){n(!0===T().pickFollowsSelection,e)}function Z(){return T().storageNamespace||void 0}function q(){return T().styleClipboard??null}function z(){return T().nodeKeys??!0}function J(){return T().notify??null}function U(){return T().Canvas??A}function $(){return T().CanvasHead??null}function _(){return T().canvasDrag??null}var nn=l(null);function en({target:n,children:e}){/* @__PURE__ */
|
|
5
|
+
return f(nn.Provider,{value:n,children:e})}function tn(){return s(nn)}function rn(){return T().Inspector??B}export{a as SELECTION_MODE,en as ScreenCanvasTargetProvider,G as ScreenPartsProvider,y as isPinnedFirst,g as isPinnedLast,d as isSelectionMode,m as isSlotMode,p as sameInspectorMode,v as screenSlotsOf,h as shownChildSlotsOf,k as shownSlotFieldsOf,Y as useScreenBlockLook,X as useScreenBlockRules,E as useScreenBridges,_ as useScreenCanvasDrag,U as useScreenCanvasFrame,$ as useScreenCanvasHead,tn as useScreenCanvasTarget,K as useScreenDevices,F as useScreenDocumentLabel,R as useScreenDocumentPass,rn as useScreenInspectorPanel,Q as useScreenLeftView,z as useScreenNodeKeys,J as useScreenNotify,x as useScreenOwnerName,T as useScreenParts,W as useScreenPickFollowsSelection,V as useScreenPinned,H as useScreenSaveSwitch,Z as useScreenStorageNamespace,q as useScreenStyleClipboard,M as useStandaloneScreenBridges};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEaselHost as n}from"./chunk-LX23TCTP.js";import{useEaselApi as e,bindUndoKeys as t}from"./chunk-
|
|
1
|
+
import{useEaselHost as n}from"./chunk-LX23TCTP.js";import{useEaselApi as e,bindUndoKeys as t}from"./chunk-53ME3GAI.js";import{useState as r,useEffect as o,useRef as u}from"react";function c(e){const t=n(),[u,c]=r(null);return o(()=>c(e.current),[e]),t.ownsDocument?"undefined"==typeof document?null:document:u}function i(r,u){const i=n(),s=e(),f=c(r);o(()=>{if(!i.ownsDocument&&f)return t(f,s,{leaveTyping:!0})},[i,s,f]);const m=u?.document??null;o(()=>{if(!i.ownsDocument&&m)return t(m,s,{leaveTyping:!0})},[i,s,m])}function s(n){return n.ownsDocument?{}:{tabIndex:-1}}function f(n){return!n.altKey&&!n.shiftKey&&(!(!n.metaKey&&!n.ctrlKey)&&("s"===n.key||"S"===n.key||"KeyS"===n.code))}function m(n,e,t){const r=c(n),i=u(t);o(()=>{i.current=t}),o(()=>{if(!r)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return r.addEventListener("keydown",n),()=>r.removeEventListener("keydown",n)},[r]);const s=e?.document??null;o(()=>{if(!s)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return s.addEventListener("keydown",n),()=>s.removeEventListener("keydown",n)},[s])}export{s as editorRootFocus,f as isSaveShortcut,c as useEaselKeyTarget,m as useEaselSaveKey,i as useEaselUndoKeys};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenStoreProvider as n}from"./chunk-
|
|
1
|
+
import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenStoreProvider as n}from"./chunk-YDJZX2XS.js";import{ScreenChrome as e}from"./chunk-IHXQZDDW.js";import{ScreenDocumentProvider as i,useScreenDocument as a}from"./chunk-BYONFJVQ.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-Q3VAJMXS.js";import{documentPermissions as s}from"./chunk-YYD257TD.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{useMemo as t,useState as d,useRef as l,useEffect as m,useCallback as g}from"react";import{Dialog as h,Button as f}from"efficient-shell/ui";import{jsx as u,jsxs as p,Fragment as v}from"react/jsx-runtime";var k=r(n),C=r(e);function N({onCancel:r,onDiscard:n,onSave:e}){const i=c("screen",o).leave,[a,s]=d(!1),t=l(!0);m(()=>(t.current=!0,()=>{t.current=!1}),[]);const k=g(async()=>{s(!0);try{await e()}finally{t.current&&s(!1)}},[e]);/* @__PURE__ */
|
|
2
2
|
return u(h,{open:!0,role:"alertdialog",size:"sm",title:i.title,onClose:r,footer:/* @__PURE__ */p(v,{children:[
|
|
3
3
|
/* @__PURE__ */u(f,{variant:"secondary",onClick:r,children:i.cancel}),
|
|
4
4
|
/* @__PURE__ */u(f,{variant:"ghost-danger",onClick:n,children:i.discard}),
|
|
5
5
|
/* @__PURE__ */u(f,{variant:"primary",loading:a,onClick:()=>{k()},children:i.save})]}),children:i.body})}function j({target:r,addressing:n,onHostMessage:e,children:a}){/* @__PURE__ */
|
|
6
|
-
return u(i,{target:r,addressing:n,onHostMessage:e,children:a})}var y=(r,n)=>/* @__PURE__ */p(v,{children:[r,n]});function
|
|
7
|
-
/* @__PURE__ */u(k,{config:r,data:i,onChange:h,permissions:
|
|
6
|
+
return u(i,{target:r,addressing:n,onHostMessage:e,children:a})}var y=(r,n)=>/* @__PURE__ */p(v,{children:[r,n]});function D({config:r,parts:n,wrap:e=y}){const{data:i,error:d,redirecting:l,ready:m,readOnly:g,onChange:h,pendingNav:f,cancelPendingNav:p,discardAndNavigate:v,saveAndNavigate:j}=a(),D=t(()=>s(!g),[g]),X=c("screen",o);return l?/* @__PURE__ */u("div",{className:"sf-msg",children:X.loading}):d?/* @__PURE__ */u("div",{className:"sf-msg sf-msg--error",children:d}):m?i?e(
|
|
7
|
+
/* @__PURE__ */u(k,{config:r,data:i,onChange:h,permissions:D,parts:n,children:/* @__PURE__ */u(C,{})}),f&&/* @__PURE__ */u(N,{onCancel:p,onDiscard:v,onSave:j})):/* @__PURE__ */u("div",{className:"sf-msg",children:X.loading}):/* @__PURE__ */u("div",{className:"sf-msg",children:X.waitingForAuthorization})}export{D as DocumentScreen,j as ScreenMount};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import{dedupeSlotChildren as e}from"./chunk-7OCEPOEJ.js";import{styleClipboardOf as n}from"./chunk-JYVQ62TL.js";import{markedTreeNodeId as t,revealSelectedTreeRow as o,sameSelector as r}from"./chunk-UMBNBCL4.js";import{cloneNodeWithFreshIds as i}from"./chunk-OXZDSOZV.js";import{scrollPreviewToSection as l,gotoPreviewSlide as s}from"./chunk-LUOY3A3Q.js";import{useEaselKeyTarget as d,useEaselUndoKeys as a,useEaselSaveKey as c,editorRootFocus as p}from"./chunk-FYV6GZXP.js";import{SlotChildActionsProvider as u}from"./chunk-KCBEE2MC.js";import{screenStorageKeys as f,DEFAULT_PANEL_W as h,clampPanelWidth as m}from"./chunk-6EDVZBUO.js";import{usePartBridge as g}from"./chunk-2S7PJZWH.js";import{useSectionOps as y}from"./chunk-LDXYMHYW.js";import{PageEditGuardNotices as v}from"./chunk-TOEJCZUO.js";import{ScreenSaveIcon as b,ScreenMainButton as k}from"./chunk-PVBDKBJB.js";import{useBrowserOffline as S}from"./chunk-RKTF5XLP.js";import{useScreenDocument as w}from"./chunk-BYONFJVQ.js";import{requestMediaPick as x}from"./chunk-JIP5JNRB.js";import{AddChildRow as z}from"./chunk-5545A3PC.js";import{AddSidePanel as C}from"./chunk-ZIEINXSZ.js";import{keepsSharedSections as O,sharedSectionsOf as N}from"./chunk-N3MJOHAG.js";import{PanelHideButton as I,SidePanelHead as B,PanelShowStrip as P}from"./chunk-SBVIW3KJ.js";import{offeredChoices as $}from"./chunk-RUQOIQWI.js";import{useScreenSaveSwitch as M,useScreenNodeKeys as T,useScreenPinned as j,useScreenDocumentLabel as E,useScreenCanvasFrame as A,useScreenInspectorPanel as L,useScreenDevices as R,useScreenPickFollowsSelection as F,useScreenLeftView as D,SELECTION_MODE as V,isSelectionMode as W,sameInspectorMode as H,useScreenBridges as U,useScreenBlockRules as Y,useScreenBlockLook as J,useScreenStorageNamespace as X,useScreenNotify as Q,useScreenCanvasHead as Z,isSlotMode as K,useScreenStyleClipboard as G,useScreenDocumentPass as _,useScreenCanvasDrag as q,ScreenCanvasTargetProvider as ee,isPinnedFirst as ne,isPinnedLast as te,screenSlotsOf as oe,shownChildSlotsOf as re}from"./chunk-FT3O7X6U.js";import{MediaPopup as ie}from"./chunk-T2RINM7R.js";import{useMediaPanel as le,usePanelPick as se,useMediaBrowsing as de,useOpenMediaBrowse as ae,useMediaPlace as ce}from"./chunk-NCXYC7WI.js";import{useNodeClipboard as pe,useNodeContextMenu as ue}from"./chunk-CP6KQP5A.js";import{useEaselSession as fe}from"./chunk-YM4UEGBV.js";import{useEaselHost as he,useHostEscape as me}from"./chunk-LX23TCTP.js";import{LayersIcon as ge,MediaIcon as ye}from"./chunk-XFYFKITX.js";import{DEFAULT_SCREEN_WORDS as ve}from"./chunk-Q3VAJMXS.js";import{heldStyle as be,styleShortcut as ke}from"./chunk-CWELHADJ.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as Se}from"./chunk-6WY6ZXJG.js";import{rootRowName as we,slotChildRowName as xe,slotChildRenameProp as ze,sectionRenameProp as Ce}from"./chunk-5NHQ452C.js";import{ROOT_ZONE as Oe,blockNodeActions as Ne,TREE_MAX_DEPTH as Ie,childSlotsOf as Be,slotFieldsOf as Pe,newNodeId as $e,slotChildrenIn as Me,nestsInTree as Te}from"./chunk-TCAAOYQY.js";import{useEasel as je,useEaselApi as Ee,CanvasPartsContext as Ae,partHasOwnBox as Le,CanvasPassThroughContext as Re,CanvasSharedContext as Fe}from"./chunk-53ME3GAI.js";import{TreeRow as De,Subtree as Ve,LayersTree as We,TreeGroupLabel as He,TreeRowAction as Ue,TreeSeam as Ye}from"./chunk-WHS6Y55E.js";import{DEFAULT_TREE_WORDS as Je}from"./chunk-K56YDHYQ.js";import{DEFAULT_NODE_MENU_WORDS as Xe}from"./chunk-WK3AFPXY.js";import{toItemSelector as Qe,useNodeOps as Ze,clickPick as Ke}from"./chunk-QTHQPJWA.js";import{EaselTopBar as Ge,EaselIconButton as _e,TopBarCluster as qe,DeviceSwitch as en,InspectorIconButton as nn,PanelResizeHandle as tn,MAX_PANEL_W as on,MIN_PANEL_W_BY_SIDE as rn,panelWidthVars as ln}from"./chunk-VBEVZZTV.js";import{DEFAULT_NOTICE_WORDS as sn,DEFAULT_CHROME_WORDS as dn}from"./chunk-AJSDWWJW.js";import{holderOf as an,nameOrSomeone as cn}from"./chunk-YYD257TD.js";import{DEFAULT_LOCK_WORDS as pn}from"./chunk-RE4LP46F.js";import{useWords as un}from"./chunk-MFIRYGHW.js";import{insertSeams as fn,CanvasDragLayer as hn,CanvasInsert as mn}from"./chunk-MBEUSPIN.js";import{DEFAULT_DRAG_WORDS as gn}from"./chunk-TQ5Y6S2X.js";import{createDragSession as yn,useTreeDrag as vn,gapToMoveIndex as bn}from"./chunk-3XECMGXX.js";import{ROOT_ID as kn,ROOT_SLOT as Sn,zoneKey as wn,parseZoneKey as xn,find as zn,DataError as Cn}from"./chunk-EUFDQ4KL.js";import{useCanvasFrame as On,LIST_SELECTOR as Nn,BLOCK_SELECTOR as In,useCanvasTyping as Bn,useCanvasEvent as Pn}from"./chunk-TOKMFZPB.js";import{nodeIdAt as $n,frameRectToHost as Mn,BLOCK_ATTRIBUTE as Tn,drawnBox as jn}from"./chunk-FR7EEKFF.js";import{queryMainCopy as En}from"./chunk-7UFKEX72.js";import{useRef as An,useMemo as Ln,useState as Rn,useEffect as Fn,useCallback as Dn,useLayoutEffect as Vn,useContext as Wn,Fragment as Hn,useId as Un}from"react";import{ColoredBadge as Yn,Button as Jn,Tabs as Xn,toast as Qn,readMediaFileDrag as Zn,Tooltip as Kn,groupColors as Gn,Dialog as _n,FormField as qn,Input as et,MEDIA_FILE_DRAG_TYPE as nt}from"efficient-shell/ui";import{UndoIcon as tt,RedoIcon as ot,RefreshIcon as rt,AddIcon as it,TrashIcon as lt,EyeOffIcon as st,EyeIcon as dt,SharedIcon as at,DuplicateIcon as ct}from"efficient-shell/icons/efficient";import{jsx as pt,jsxs as ut,Fragment as ft}from"react/jsx-runtime";var ht="media-file";function mt({name:e,onMake:n,onCancel:t}){const o=un("screen",ve).shared,[r,i]=Rn(e),[l,s]=Rn(!1),d=Un(),a=An(null),c=async()=>{const e=r.trim();if(e&&!l){s(!0);try{await n(e)}finally{s(!1)}}};/* @__PURE__ */
|
|
2
|
+
return pt(_n,{open:!0,size:"sm",title:o.makeShared,description:o.makeSharedHint,onClose:t,initialFocus:a,footer:/* @__PURE__ */ut(ft,{children:[
|
|
3
|
+
/* @__PURE__ */pt(Jn,{variant:"secondary",onClick:t,children:o.cancel}),
|
|
4
|
+
/* @__PURE__ */pt(Jn,{variant:"primary",loading:l,disabled:!r.trim(),onClick:()=>{c()},children:o.makeShared})]}),children:/* @__PURE__ */pt("form",{onSubmit:e=>{e.preventDefault(),c()},children:/* @__PURE__ */pt(qn,{label:o.name,htmlFor:d,children:/* @__PURE__ */pt(et,{id:d,ref:a,value:r,onChange:e=>i(e.target.value)})})})})}var gt=/* @__PURE__ */new WeakSet;function yt(e,n,t){const o=zn(e,n,t);if(!o)return null;const r=o.path.find(e=>"root"!==e.parentId);return r?r.parentId:t}function vt({canvas:e,tabs:n,onSelect:t}){const o=An(null),[r,i]=Rn({}),l=n.map(e=>`${e.id}:${e.below?1:e.above?2:0}`).join("|");return Vn(()=>{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=Mn(l,{left:0,top:0,width:r.innerWidth,height:r.innerHeight},e),a={};for(const o of n){const n=En(t,`[${Tn}="${r.CSS?.escape?r.CSS.escape(o.id):o.id}"]`),i=n?jn(n):null;if(!i||0===i.height){a[o.id]=null;continue}const s=Mn(l,{left:i.left,top:i.top,width:i.width,height:i.height},e),c=s.top+s.height;if(c<d.top||s.top>d.top+d.height){a[o.id]=null;continue}const p=!0===o.above&&s.top-4>d.top,u=o.below?c+4:p?s.top-4:Math.max(s.top,d.top)+6;a[o.id]={left:Math.max(s.left,d.left)+(o.above?0:6),top:u,above:p}}i(a)},a=()=>{s||(s=r.requestAnimationFrame(d))};d(),r.addEventListener("scroll",a,!0),r.addEventListener("resize",a);const c=new r.MutationObserver(a);return c.observe(t.body,{childList:!0,subtree:!0,attributes:!0}),()=>{s&&r.cancelAnimationFrame(s),r.removeEventListener("scroll",a,!0),r.removeEventListener("resize",a),c.disconnect()}},[e,l]),/* @__PURE__ */pt("div",{ref:o,className:"es-band-tabs","aria-hidden":"true",children:n.map(e=>{const n=r[e.id];return n?/* @__PURE__ */pt("span",{className:"es-band-tab"+(n.above?" is-above":""),"data-band-tab":e.id,style:{left:n.left,top:n.top},onClick:n=>{n.stopPropagation(),t(e.id)},children:e.reach?
|
|
5
|
+
/* @__PURE__ */pt(Kn,{content:e.reach,children:/* @__PURE__ */ut(Yn,{colorClass:Gn("success","solid"),size:"sm",children:[
|
|
6
|
+
/* @__PURE__ */pt("span",{className:"es-band-tab-mark",children:/* @__PURE__ */pt(at,{size:12})}),e.label]})}):/* @__PURE__ */pt(Yn,{colorClass:Gn("info","solid"),size:"sm",children:e.label})},e.id):null})})}function bt({expand:e}){/* @__PURE__ */
|
|
7
|
+
return pt("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round",children:/* @__PURE__ */ut(ft,e?{children:[
|
|
8
|
+
/* @__PURE__ */pt("path",{d:"M8 9l4-4 4 4"}),
|
|
9
|
+
/* @__PURE__ */pt("path",{d:"M8 15l4 4 4-4"})]}:{children:[
|
|
10
|
+
/* @__PURE__ */pt("path",{d:"M8 4l4 4 4-4"}),
|
|
11
|
+
/* @__PURE__ */pt("path",{d:"M8 20l4-4 4 4"}),
|
|
12
|
+
/* @__PURE__ */pt("path",{d:"M5 12h14"})]})})}var kt=`${Nn}, ${In}`;function St(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 wt="__rungs",xt=e=>"template"===e.kind?e.template.id:"shared"===e.kind?e.section.id:"preset"===e.kind?e.preset.key:e.type;var zt="screen:band",Ct={duplicate:!0,delete:!0},Ot=()=>null;function Nt(){const Nn=he(),Mn=Nn.panels?.Toolbar,Tn=(Nn.panels?.useRight??Ot)(),{target:jn,docId:Un,capabilities:Kn,currentSlug:Gn,siteId:_n,onPublish:qn,saveState:et,saveConflict:at,retrySave:Nt,toggleAutoSave:It,flushSave:Bt,access:Pt,saveUnreachable:$t=!1,readOnly:Mt,readOnlyReason:Tt=null}=w(),jt=M(),Et=T(),{mediaEditing:At,hasEditGuard:Lt,hasPinnedChrome:Rt}=Kn,{appState:Ft,dispatch:Dt,history:Vt,selectedItem:Wt,getSelectorForId:Ht,config:Ut}=je(e=>e),Yt=j(),{first:Jt,firstGroup:Xt,lastGroup:Qt,isSectionGroup:Zt,sectionGroupZone:Kt,panelOf:Gt}=Yt,_t=Gt(Jt),qt=e=>ne(Yt,e),eo=e=>te(Yt,e),no="node"===Yt.firstRow,to=Yt.band??null,oo=un("screen",ve),ro=un("tree",Je),io=un("drag",gn),lo=un("notice",sn),so=un("lock",pn),ao=un("menu",Xe),co=un("styleClipboard",Se),po=un("chrome",dn),uo=E()??`/${Gn}`,fo=A(),ho=L(),mo=y({readOnly:Mt}),go=y({readOnly:Mt,foldIntoHistory:!0}),yo=An(null),vo=Ee(),bo=Ln(()=>({...mo,select:e=>{yo.current=e,mo.select(e)},commitDocument:(e,n)=>{if(void 0!==n){const t=vo.config;yo.current=Qe(e,t,n)}mo.commitDocument(e,n)}}),[mo,vo]),ko=Ft.ui,So=ko.leftSideBarVisible,wo=ko.rightSideBarVisible,{options:xo,widths:zo,initial:Co,fluid:Oo,fit:No}=R(),[Io,Bo]=Rn(Co),Po=le(),$o=At&&null!==Po;se(),de();const Mo=ae();F(Wt?.props.id);const{read:To,write:jo,forSelection:Eo}=D(),[Ao,Lo]=Rn(To);Fn(()=>{jo(Ao)},[Ao]);const[Ro,Fo]=Rn(0),Do=An(null),Vo=An(null),Wo=On(Vo,{readySelector:kt}),Ho=Bn(Wo),Uo=d(Vo);a(Vo,Wo);const Yo=S(),Jo=an(Pt),Xo={state:et,offline:Yo||et.failed&&$t,readOnlyReason:Tt,editing:Jo?lo.editing({name:cn(Jo.name,so),noun:oo.noun}):null,conflict:null!=at,notSaving:oo.bar.notSaving},Qo=()=>{Mt||(et.failed?Nt():Bt())};c(Vo,Wo,Qo);const[Zo,Ko]=Rn(!1),Go=An(!1),[_o,qo]=Rn(null),[er,nr]=Rn([]),[tr,or]=Rn(V);W(tr);const rr=t(tr,Wt?.props.id),[ir,lr]=Rn(null);Fn(()=>{ir&&(o(),lr(null))},[ir]);const sr=An(Ht);sr.current=Ht;const dr=Dn((e,{scroll:n})=>{Lo(n=>Eo(e,n)),n&&lr(e);const t=[];let o=e;for(let e=0;e<4;e++){const e=sr.current(o)?.zone;if(!e||!e.includes(":"))break;const n=e.split(":")[0];t.push(n),t.push(e),o=n}0!==t.length&&Rr(e=>{if(t.every(n=>!e.has(n)))return e;const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},[]),ar=An(null);Fn(()=>{const e=ar.current;ar.current=null;const n=null==Wt?.props.id?null:String(Wt.props.id);or(t=>e&&e.id===n?e.mode:"part"===t.kind&&"nodeId"in t&&t.nodeId===n?t:Gt(Wt?.type)??V);const t=Wt?.props.id,o=yo.current;if(yo.current=null,!t)return;const i=Ht(t);dr(String(t),{scroll:!r(o,i??null,Oe)})},[Wt?.props.id,dr]);const cr=Dn(e=>{or(n=>H(n,e)?n:e),Dt({type:"setUi",ui:{rightSideBarVisible:!0}})},[Dt]),pr=An(()=>{});pr.current=(e,n)=>{const t=e?Ti(e.zone??Oe)[e.index]?.props.id:null,o=null==t?null:String(t),r=null==Wt?.props.id?null:String(Wt.props.id);or(e=>H(e,n)?e:n),o!==r&&(ar.current={id:o,mode:n},bo.select(e))};const ur=Dn((e,n)=>pr.current(e,n),[]),fr={kind:tr.kind,mode:tr,open:cr,show:e=>or(e),reveal:()=>{wo||Dt({type:"setUi",ui:{rightSideBarVisible:!0}})},select:ur},hr=U(fr,{data:Ft.data,selected:Wt??null,zoneOf:e=>Ht(e)?.zone,readOnly:Boolean(Mt),select:e=>{or(V),bo.select({index:e})},replace:(e,n)=>bo.replaceComponent(Oe,e,n),scrollTo:e=>l(e)},{device:Io,refreshes:Ro},{setView:Lo,reveal:()=>{So||Dt({type:"setUi",ui:{leftSideBarVisible:!0}})}}),mr=hr.resolveLeftView?hr.resolveLeftView(Ao):"sections",gr=Y(),{isLockedBlock:yr,duplicateBlocked:vr,nestDepth:br,newSectionNode:kr,canAddTo:Sr,blockIsOffered:wr}=gr,xr=e=>({id:String(e.props.id??""),data:Ft?.data}),zr=J(),{labelAtLevel:Cr,Icon:Or,useProducts:Nr}=zr,Ir=zr.rowName?(e,n,t)=>zr.rowName(e,n,t):void 0,Br=Dn(e=>{Dt({type:"setUi",ui:{rightSideBarVisible:!0}}),l(e),dr(e,{scroll:!0})},[Dt,dr]),{selectNode:Pr,openPartId:$r}=g({mode:tr,setMode:or,onOpenPart:Br}),[Mr,Tr]=Rn(null);me(null!==Mr,()=>Tr(null));const jr=f(X()),Er=jr.collapsed,Ar=jr.panelWidths,[Lr,Rr]=Rn(()=>{if("undefined"==typeof window)/* @__PURE__ */return new Set;try{const e=window.localStorage.getItem(Er);return new Set(e?JSON.parse(e):[])}catch{/* @__PURE__ */
|
|
13
|
+
return new Set}});Fn(()=>{try{window.localStorage.setItem(Er,JSON.stringify([...Lr]))}catch{}},[Lr]);const[Fr,Dr]=Rn(()=>{if("undefined"==typeof window)return{...h};try{const e=window.localStorage.getItem(Ar);if(!e)return{...h};const n=JSON.parse(e);return{left:m(Number(n.left)||h.left,"left"),right:m(Number(n.right)||h.right,"right")}}catch{return{...h}}});Fn(()=>{const e=setTimeout(()=>{try{window.localStorage.setItem(Ar,JSON.stringify(Fr))}catch{}},300);return()=>clearTimeout(e)},[Fr]);const Vr=Dn((e,n)=>Dr(t=>{const o="function"==typeof n?n(t[e]):n;return t[e]===o?t:{...t,[e]:o}}),[]),Wr=Dn(e=>Vr("left",e),[Vr]),Hr=Dn(e=>Vr("right",e),[Vr]),Ur=e=>Lr.has(e),Yr=e=>Rr(n=>{const t=new Set(n);return t.has(e)?t.delete(e):t.add(e),t}),Jr=An(!1),Xr=An(null);Fn(()=>{if(Jr.current&&!Zo){const e=Xr.current,n=e&&e.isConnected&&!e.closest('[aria-hidden="true"]')?e:null;(n??Vo.current?.querySelector(`button[aria-label="${CSS.escape(oo.add.title)}"]`))?.focus(),Xr.current=null}Jr.current=Zo},[Zo]),Fn(()=>{if(!Zo||!Uo)return;const e=e=>{"Escape"===e.key&&ul()};return Uo.addEventListener("keydown",e),()=>Uo.removeEventListener("keydown",e)},[Zo,Uo]),me(Zo,()=>ul()),Fn(()=>{!So&&Zo&&(Ko(!1),qo(null),Go.current=!1)},[So]);const Qr=Q(),Zr=(e,n="success",t)=>{if(Qr)return void(t?Qr(e,"error"===n?"error":"info",t):Qr(e,"error"===n?"error":"info"));const o={sound:!1,action:t?.action,onClose:t?.onClose};"error"===n?Qn.error(e,{...o,duration:t?.duration??3200}):Qn.success(e,{...o,duration:t?.duration??1900})},Kr=An(null),[Gr,_r]=Rn(0),[qr,ei]=Rn(0),ni=Z(),ti=An(null),oi=e=>Math.max(0,e.clientHeight-(ti.current?.offsetHeight??0));Fn(()=>{const e=Kr.current;if(!e)return;const n=()=>{_r(e.clientWidth),ei(oi(e))};n();const t=new ResizeObserver(n);return t.observe(e),ti.current&&t.observe(ti.current),()=>t.disconnect()},[]),Vn(()=>{Kr.current&&(_r(Kr.current.clientWidth),ei(oi(Kr.current)))},[Fr,So,wo]);const ri=Io===Oo?Gr>0?Gr:zo[Oo]:zo[Io],ii=Gr>0?Math.min(Gr/ri,"shrink"===No?1:2):1,li=ri*ii,si=Gr>0&&li>Gr+1,di={width:li,height:qr||"100%",flex:"none",position:"relative"},ai={width:ri,height:qr?qr/ii:"100%",maxHeight:"none",transform:1!==ii?`scale(${ii})`:void 0,transformOrigin:"top left"},ci=()=>Dt({type:"setUi",ui:{leftSideBarVisible:!So}}),pi=()=>Dt({type:"setUi",ui:{rightSideBarVisible:!wo}}),ui=e=>{Zo&&(Ko(!1),qo(null),Go.current=!1,So&&Ao===e)||(Lo(e),So||Dt({type:"setUi",ui:{leftSideBarVisible:!0}}))},fi=()=>{or(_t??V),wo||Dt({type:"setUi",ui:{rightSideBarVisible:!0}})},hi=Ft.data.content??[],mi=()=>{const e=hi.findIndex(qt),n=hi.findIndex(eo);return{floor:e>=0?e+1:0,cap:n>=0?n:hi.length}},gi=Ut,yi=gr.stripCopy,vi=e=>i(e,yi),bi=pe(),ki=Ze({data:Ft.data,config:gi,readOnly:Boolean(Mt),clipboard:bi,strip:yi?e=>yi(e):void 0,afterRemove:"none",stepBounds:(e,n)=>{if(e.parentId!==kn||e.slot!==Sn)return{min:0,max:n-1};const{floor:t,cap:o}=mi();return{min:t,max:o-1}},commit:(e,{select:n})=>{void 0!==n&&or(V);const t=void 0===n||"node"===n?.kind?n:null;bo.commitDocument(e,t)}}),Si=fe(),[wi,xi]=Rn(null),zi=e=>{const n=hi.find(n=>String(n.props.id)===e),t=Yt.shared;n&&t&&ki.swap(e,t.detach(n))},Ci=e=>{const n=zn(Ft.data,Ut,e);if(!n)return!1;const t=wn(n.place),o=n.node,r=t===Oe?Pi(o):Yi(o),i=t===Oe?Yt.shared?.usedOn(o):null;return!!ki.remove(e)&&(Zr(i?oo.shared.removed({count:Math.max(0,i.length-1)}):oo.deleted({name:r}),"success",{duration:8e3,action:{label:oo.bar.undo,onClick:()=>{ki.restore(n.node,n.place)}}}),!0)},Oi={...ki,remove:Ci},Ni=e=>Cr(e,"block",Ut.components[e]?.label??e),Ii=Dn(e=>Ut.components[e]?.defaultProps??{},[Ut]),Bi=e=>Cr(e,"section",Ni(e)),Pi=e=>we({type:e.type,props:e.props??{}},Bi(e.type),Ir),{nodeAddresses:$i,zoneItems:Mi}=Ln(()=>{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>=Ie)return;const s=/* @__PURE__ */new Map;for(const{child:e,zone:t}of Be(Ut,n))s.set(t,[...s.get(t)??[],e]);for(const[e,n]of s)t(n,e,i+1)})};return t(hi,Oe,0),{nodeAddresses:e,zoneItems:n}},[hi,Ut]),Ti=Dn(e=>Mi.get(e)??[],[Mi]),ji=e=>{const n=$i.get(e);return n?Ti(n.zone)[n.index]:void 0},Ei=e=>oe(gr,Ut,e),Ai=e=>{if(!gr.slotsOf||e===Oe)return null;const n=e.lastIndexOf(":");if(n<=0)return null;const t=ji(e.slice(0,n));if(!t)return null;const o=Ei(t).filter(e=>e.rung),r=o.findIndex(t=>t.slot===e.slice(n+1));return r<0?null:{node:t,slot:o[r],position:r}},Li=(()=>{if(!K(tr))return null;const e=`${tr.nodeId}:${tr.slot}`;return Ai(e)?.slot.panel===tr.kind?e:null})(),Ri=An(null);Fn(()=>{const e=Ri.current;if(Ri.current=null,!Li||!K(tr))return;const n=tr.nodeId;dr(n,{scroll:e!==Li}),Rr(e=>{if(!e.has(n))return e;const t=new Set(e);return t.delete(n),t})},[tr]);const Fi=e=>{const n=$i.get(e);n&&(n.zone===Oe?il(n.index):Ml(n.zone,n.index,e,ji(n.zone.slice(0,n.zone.lastIndexOf(":")))?.type??""))},Di=(e,n,t)=>{const o=String(e.props.id);if(!n.panel)return void Fi(o);const r={kind:n.panel,nodeId:o,slot:n.slot},i=`${o}:${n.slot}`;t&&Li!==i&&(Ri.current=i),ur(null,r),wo||Dt({type:"setUi",ui:{rightSideBarVisible:!0}}),l(o)},Vi=(e,n,t)=>{const o=`${e}:${n}`;if(Rr(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;Li!==o&&(Ri.current=o);ur(null,{kind:t,nodeId:e,slot:n})},Wi=(e,n,t)=>{if(Mt||!gr.moveSlot)return;const o=ji(e),r=o?Ei(o).filter(e=>e.rung):[],i=r[n];if(!i)return;const l={parentId:e,slot:wt,index:n},s=bn(l,{...l,index:Math.min(Math.max(t,0),r.length)});if(s===n)return;const d=gr.moveSlot(e,n,s);"string"==typeof d&&Vi(e,d,i.panel)},Hi=Nr(),Ui=Ln(()=>{const e=/* @__PURE__ */new Map;for(const n of Hi??[])e.set(n.slug,n.name);return e},[Hi]),Yi=e=>xe(e,Ni,zr.plainText,e=>Ui.get(e),zr.rowName),Ji=(e,n)=>{const t=Ut.components[e.type]?.fields,o=n===Oe||rs(n)?"section":"block",r=n===Oe&&(qt(e)||eo(e)||Zt(e.type)),i="block"===o?ze(t):r?null:Ce(t);return zr.renamePropOf?zr.renamePropOf(e,o,i):i},Xi=(e,n,t,o)=>{if(!(!Mt&&Mr?.zone===e&&Mr.index===n))return;const r=(t,o)=>{Tr(null),o&&((e,n,t)=>{const o=Ti(e)[n];if(!o)return;const r=Ji(o,e);r&&bo.replaceComponent(e,n,{...o,props:{...o.props,[r]:t.trim()}})})(e,n,t)};/* @__PURE__ */
|
|
14
|
+
return pt("input",{className:"es-tree-rename",defaultValue:o,autoFocus:!0,"aria-label":oo.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)},Qi=n(G(),co),Zi=Qi.scope({target:jn,siteId:_n,docId:Un}),Ki=Ut,Gi=(e,n)=>n===Oe?Bi(e):Ni(e),_i=(e,n,t)=>{const o=Qi.plan(Zi,t,Gi(t.type,e),Ki);o&&(o.changed&&bo.replaceComponent(e,n,{...t,props:{...o.props,id:t.props.id}}),Zr(o.message))},qi=ue({nodesIn:Ti,nodeAt:(e,n)=>Ti(e)[n]??null,labelOf:(e,n)=>n===Oe?Bi(e):Ni(e),renamePropOf:Ji,beginRename:(e,n)=>Tr({zone:e,index:n}),history:{hasPast:Vt.hasPast,hasFuture:Vt.hasFuture,back:()=>Vt.back(),forward:()=>Vt.forward()},openPageStyles:hr.openPageStyles,pageStylesLabel:oo.pageStyles,words:{menu:ao,styleClipboard:co,screen:oo.menu},readOnly:Boolean(Mt),collapseAll:()=>Rr(new Set(Ti(Oe).map(e=>String(e.props.id)))),onPasteRefused:e=>Zr(e?oo.pasteRefused({name:e.label}):oo.menu.clipboardRefused,"error"),canPasteAt:(e,n)=>ss(e,n),copyItem:hr.onCopyItem,menuRows:(e,n,t)=>{const o=hr.menuRows?.(e,n,t)??null,r=((e,n)=>{const t=Yt.shared;if(!t||n!==Oe)return null;const o=t.usedOn(e);if(o){const n={pick:[{label:oo.shared.onPages({count:o.length}),onClick:()=>{},children:o.map(e=>({label:e.title,onClick:()=>t.openPage(e)}))}]};return Mt||yr(e.type,e)?n:{...n,change:[{label:oo.shared.detach,onClick:()=>zi(e.props.id)}],remove:[{label:oo.shared.removeFromPage,danger:!0,onClick:()=>{Ci(e.props.id)}}]}}return Mt||qt(e)||eo(e)||Zt(e.type)?null:O(Si)?{change:[{label:oo.shared.makeShared,onClick:()=>xi({id:e.props.id,name:Pi(e)})}]}:null})(e,n);if(!r)return o;return Object.fromEntries(["pick","make","change","remove"].map(e=>[e,[...o?.[e]??[],...r[e]??[]]]).filter(([,e])=>e.length>0))},isLocked:e=>yr(e.type,e),duplicateBlocked:e=>vr(Ft.data,e),permits:e=>{const n=Ne(Ut,e.type);return Yt.shared?.usedOn(e)?{...n,delete:!1}:n},nodeOps:Oi,isPinned:(e,n)=>n===Oe&&(qt(e)||eo(e)),sectionBand:mi,locate:e=>$i.get(e)??null,rowNameOf:(e,n)=>n===Oe?Pi(e):Yi(e),selectAt:(e,n,t,o)=>{e===Oe?il(n):Ml(e,n,t,o??"")},slotRung:e=>{const n=Ai(e);return n?.slot.panel?{label:n.slot.label,select:()=>Di(n.node,n.slot,!1)}:null},style:{held:()=>be(Zi),canCopy:e=>Qi.rows(Ki,e).some(e=>!1!==e.counted),copy:(e,n)=>Qi.copy(Zi,e,Gi(e.type,n),Ki),paste:(e,n,t)=>_i(e,n,t)},keys:Et?{target:Uo,selected:()=>{const e=Ft.ui.itemSelector;return e?{zone:e.zone??Oe,index:e.index}:null},held:()=>bi.get(),readOnly:Boolean(Mt),onDone:({done:e,name:n})=>{"copied"===e&&Zr(oo.copied({name:n}))}}:void 0},Wo),el=An({copy:(e,n)=>{},paste:(e,n,t)=>{},at:()=>null,readOnly:!1});Fn(()=>{el.current={copy:(e,n)=>Qi.copy(Zi,e,Gi(e.type,n),Ki),paste:_i,at:()=>{const e=Ft.ui.itemSelector;if(!e)return null;const n=e.zone??Oe,t=Ti(n)[e.index];return t?{zone:n,index:e.index,node:t}:null},readOnly:Boolean(Mt)}});const nl=Dn(e=>{const n=ke(e);if(!n)return;const t=el.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))},[]);Fn(()=>{if(!Uo)return;const e=e=>nl(e);return Uo.addEventListener("keydown",e),()=>Uo.removeEventListener("keydown",e)},[nl,Uo]),Pn(Wo,"keydown",nl);const tl=hi.map(e=>e.props.id).join("|");Fn(()=>{const e=Wo?.document??null,n=Wo?.window??null;let t=0;const o=[],r=()=>{if(!e)return void nr(e=>e.length?[]:e);const n=hi.findIndex(eo),t=n>=0?n:hi.length,o=n=>{const t=hi[n]?.props?.id;return null==t?null:En(e,`[data-easel-block="${CSS.escape(String(t))}"]`)},r=e=>e?[...e.querySelectorAll(In)].map(e=>e.getBoundingClientRect()).filter(e=>e.width>0||e.height>0):[],i=[];for(let e=hi.length>0&&!qt(hi[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=St(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})}nr(e=>function(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t].top!==n[t].top||e[t].index!==n[t].index||e[t].height!==n[t].height)return!1;return!0}(e,i)?e:i)},i=()=>{cancelAnimationFrame(t),t=requestAnimationFrame(r)};if(!e||!n)return void r();n.addEventListener("scroll",i,{passive:!0});const l=new ResizeObserver(i);return l.observe(e.documentElement),r(),o.push(setTimeout(r,150),setTimeout(r,450)),()=>{cancelAnimationFrame(t),o.forEach(clearTimeout),n.removeEventListener("scroll",i),l.disconnect()}},[Wo,tl,Io,ii,So,wo,Wt?.props.id]);const ol=Wo?.document??null,rl=Wo?.window??null;Fn(()=>{const e=Do.current;if(!e||!ol||!rl)return;const n=[],t=()=>{const n=En(ol,`[data-easel-block="${CSS.escape(e.id)}"]`);if(!n)return!1;const t=n.getBoundingClientRect().top-e.offset;return Math.abs(t)>1&&rl.scrollTo({left:rl.scrollX,top:rl.scrollY+t,behavior:"instant"}),!0};return Do.current=null,t()&&n.push(setTimeout(t,150),setTimeout(t,450)),()=>n.forEach(clearTimeout)},[ol,rl]);const il=e=>{or(V),bo.select({index:e}),hr.sectionPressed?.(hi[e]);const n=hi[e]?.props?.id;n&&l(n)},ll=e=>{const{floor:n,cap:t}=mi(),o=e=>Math.min(Math.max(n,e),t);if("number"==typeof e)return o(e);const r=Wt&&tr.kind!==_t?.kind?hi.findIndex(e=>e.props.id===Wt.props.id):-1;return o(r>=0?r+1:t)},sl=(e,n)=>{const{floor:t,cap:o}=mi(),r=Math.min(Math.max(n,t),o),i=e<r?r-1:r;return i===e?{moved:!1,dest:e}:(bo.reorderComponent(Oe,e,i),bo.select({index:i}),{moved:!0,dest:i})},dl=(e,n,t,o)=>{or(V),bo.select(o?{index:o.index,zone:o.zone}:{index:e}),l(n),Zr(oo.sectionAdded({name:t}))},al=(e,n)=>{const t=ll(n),o=kr(e,{nodeDefaults:Ii,newNodeId:$e,sectionLabel:Bi,blockIsOffered:wr}),r=o?bo.insertNode(Oe,t,o):bo.insertSection(e,t);return dl(t,r,Bi(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:a}of Be(Ut,e)){if(s.type===t&&(!o.at||n>o.at.depth)){const r=Sr(e.type,l,d.slice(d.lastIndexOf(":")+1),xr(e)),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:a,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},cl=e=>pl(Oe,e),pl=(e,n)=>{Xr.current=document.activeElement??null,qo(null===n?null:{zone:e,index:n}),Ko(!0),So||(Go.current=!0,Dt({type:"setUi",ui:{leftSideBarVisible:!0}}))},ul=()=>{Ko(!1),qo(null),Go.current&&Dt({type:"setUi",ui:{leftSideBarVisible:!1}}),Go.current=!1},fl=(e,n)=>zr.rowName?n?qt(e)?zr.rowName(e,"section",oo.header):eo(e)?zr.rowName(e,"section",oo.footer):Zt(e.type)?zr.rowName(e,"section",Ni(e.type)):Pi(e):Yi(e):n?Bi(e.type):Ni(e.type),hl=e=>n=>{e()},ml=(e,n,t)=>{if(Mt)return null;const o=Ti(e)[n];return o&&!Ne(Ut,o.type).delete||o&&yr(o.type,o)?null:/* @__PURE__ */pt(Ue,{kind:"delete",label:e===Oe&&o&&Yt.shared?.usedOn(o)?oo.shared.removeFromPage:oo.deleteNamed({name:t}),onClick:()=>((e,n)=>{const t=Ti(e)[n]?.props?.id;null!=t&&Ci(String(t))})(e,n),children:/* @__PURE__ */pt(lt,{size:15})})},gl=e=>zr.rowPreview?.(e)||void 0,yl=e=>zr.rowMarks?.(e)??void 0,vl=(e,n,t)=>zr.rowActions?.(e,n,t)??null,bl=(e,n,t,o)=>{if(Mt)return null;if(yr(t.type,t))return null;const r=Boolean(t.props._hidden);/* @__PURE__ */
|
|
15
|
+
return pt(Ue,{kind:"eye",label:r?oo.showNamed({name:o}):oo.hideNamed({name:o}),onClick:()=>Sl(e,n,t),children:/* @__PURE__ */pt(r?st:dt,{size:14,strokeWidth:1.8,strokeLinecap:void 0,strokeLinejoin:void 0})})},kl=e=>nd(Oe,e),Sl=(e,n,t)=>{bo.replaceComponent(e,n,{...t,props:{...t.props,_hidden:!t.props._hidden}})},wl=e=>Pe(Ut,e),xl=e=>Be(Ut,e),zl=e=>gr.slotsOf?Ei(e).map(n=>({slot:n.slot,rung:n.rung?n:null,kids:Me(e,n.slot)})):[{slot:null,rung:null,kids:re(Ut,e)}],Cl=e=>gr.slotsOf?zl(e).flatMap(e=>e.kids):re(Ut,e),Ol=e=>Boolean(gr.slotsOf)&&Ei(e).some(e=>e.rung),Nl=(e,n,t)=>Sr(e.type,n,t??void 0,xr(e)),Il=(e,n,t)=>{const o=Te(Ut,e.type,n)&&(t||Cl(e).length>0||Ol(e));return{collapsible:o,folded:o&&Ur(String(e.props.id))}},Bl=(e,n,t)=>zl(e).flatMap(o=>{const r=o.rung?n+1:n,i=o.kids.flatMap(({child:e})=>Il(e,r,t(e.type)).collapsible?[String(e.props.id),...Bl(e,r+1,t)]:[]);return o.rung?[`${e.props.id}:${o.rung.slot}`,...i]:i}),Pl=e=>Cl(e).length>0||Ol(e)||Boolean(Sr(e.type)),$l=e=>Boolean(Sr(e)),Ml=(e,n,t,o)=>{if(or(V),Sr(o)?.spec?.slider){const t=e.split(":")[0];s(t,n),bo.select({index:n,zone:e}),l(t)}else bo.select({index:n,zone:e}),l(t)},Tl=(e,n,t,o,r)=>{const i=`${e}:${n}`;bo.insertComponent(i,t,o),Sr(r)?.spec?.slider?requestAnimationFrame(()=>{s(e,o),bo.select({index:o,zone:i})}):bo.select({index:o,zone:i})},jl=An(/* @__PURE__ */new Set);Fn(()=>{hi.forEach(e=>{const n=Sr(e.type)?.spec;if(!n)return;const t=e.props.id;if(jl.current.has(t))return;jl.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(Ii)).forEach((e,t)=>go.seedChild(o,t,n.childType,e))})},[hi,go,Ii]);const El=An(/* @__PURE__ */new Set);Fn(()=>{hi.forEach((n,t)=>{const o=n.props.id;if(El.current.has(o))return;const r=e(n,wl(n.type));El.current.add(o),r&&go.replaceComponent(Oe,t,{...n,props:r})})},[hi,go]),_(go,Ut);const Al=hi.findIndex(eo),Ll=Al>=0?hi[Al]:null,Rl=no?hi.findIndex(qt):-1,Fl=Rl>=0?hi[Rl]:null,Dl=Yt.groupTab,Vl=Ln(()=>Dl?e=>Zt(e.type):void 0,[Dl]),Wl=Boolean(Yt.groupBadge),Hl=Yt.sharedReach,Ul=e=>Hl?.(e)??void 0,Yl=Ln(()=>Hl?new Set(hi.filter(e=>Ul(e)).map(e=>String(e.props.id))):null,[hi,Hl]),Jl=Ln(()=>Yl?e=>Yl.has(e):void 0,[Yl]),Xl=Yt.first?Hl?.({type:Yt.first,props:{id:""}})??void 0:void 0,Ql=Yt.groupBadge?/* @__PURE__ */pt("span",{className:"es-tree-group-badge",children:/* @__PURE__ */pt(Yn,{tone:"info",size:"xs",children:Yt.groupBadge})}):void 0,Zl=hi.find(e=>e.type===Xt)??null,Kl=hi.find(e=>e.type===Qt)??null,Gl=Al>=0?Al:hi.length,_l=[];hi.forEach(e=>{eo(e)||(Pl(e)&&_l.push(String(e.props.id)),_l.push(...Bl(e,1,$l)))}),Ll&&(_l.push(String(Ll.props.id)),_l.push(...Bl(Ll,1,$l)));const ql=_l.length>0&&_l.every(e=>Lr.has(e)),es=e=>{const n=zr.blockRowName(e,Ni);return zr.rowName?zr.rowName(e,"block",n):n},ns=(e,n,t,o)=>{const r=Ti(e)[t];if(!r)return;const i={...xn(e),index:t},l={...xn(n),index:Math.min(Math.max(o,0),Ti(n).length)},s=bn(i,l);if(e!==n||s!==t)try{ki.move(String(r.props.id),{...l,index:s})}catch(e){if(!(e instanceof Cn))throw e}},ts=e=>{const n=/* @__PURE__ */new Set,t=e=>{for(const{child:o,zone:r}of xl(e))n.add(r),t(o)};for(const t of wl(e.type))n.add(`${e.props.id}:${t}`);return t(e),n},os=e=>{let n=e.slice(0,e.indexOf(":"));for(let e=0;e<64;e++){const e=$i.get(n);if(!e)return null;if(e.zone===Oe)return n;n=e.zone.slice(0,e.zone.indexOf(":"))}return null},rs=e=>{const n=e.slice(0,e.indexOf(":")),t=hi.find(e=>Zt(e.type)&&String(e.props.id)===n);return t&&Kt(n)===e?t:null},is=(e,n)=>{const t=rs(e);return!t||(!Yt.groupAccepts||Yt.groupAccepts(t.type,n,Ti(e).length))},ls=(e,n,t)=>{if(e.rung){const t=ji(e.rung.nodeId),o=t?Ei(t).filter(e=>e.rung).length:0;return n.parentId===e.rung.nodeId&&n.slot===wt&&n.index>=0&&n.index<=o}if(n.slot===wt)return!1;if(e.add)return cs(e.add,n);const o=wn(n);if(Zt(e.type))return!1;const r=rs(o),i=rs(e.zone);if(r||i)return!(!r||!i)&&(!(r!==i&&!is(o,e.type))&&(n.index>=0&&n.index<=Ti(o).length));if(e.zone===Oe||o===Oe){if(e.zone!==o)return!1;const{floor:t,cap:r}=mi();return n.index>=t&&n.index<=r}if(n.index<0||n.index>Ti(o).length)return!1;if(e.zone===o)return!0;const l=Ll&&!Yt.lastIsOpen?String(Ll.props.id):null;return(!l||os(e.zone)!==l&&os(o)!==l)&&((e,n,t,o)=>{if(e===n)return!0;const r=o??Ti(e)[t];if(!r)return!1;const i=n.split(":")[0],l=$i.get(i),s=l?Ti(l.zone)[l.index]:void 0;if(!s)return!1;if(!o&&ts(r).has(n))return!1;const d=Sr(s.type,br(Ft?.data,s.type,i),n.slice(n.lastIndexOf(":")+1),xr(s));return!!d&&(!!(d.choices?d.choices.some(e=>e.type===r.type):d.spec?.childType===r.type)&&!d.spec?.addBlocked?.(Ti(n),r))})(e.zone,o,e.index,t)},ss=(e,n)=>{const t=wn(e.from),o=e.node;return t===wn(n)?is(t,o.type):ls({id:String(o.props?.id??""),zone:t,index:-1,type:o.type},n,o)},ds=e=>{const n=e.slice(0,e.indexOf(":")),t=$i.get(n),o=t?Ti(t.zone)[t.index]:void 0;if(!t||!o)return null;const r=Sr(o.type,br(Ft?.data,o.type,n),e.slice(e.lastIndexOf(":")+1),xr(o));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:Ni(r.spec.childType)}]:[])),l=Ai(e);return{parent:o,parentId:n,target:r,choices:i,parentName:l?l.slot.label:fl(o,t.zone===Oe)}},as=(e,n)=>{if("section"!==e.kind)return e;const t=wn(n);return t===Oe||rs(t)?e:ds(t)?.choices.some(n=>n.type===e.type)?{kind:"block",type:e.type}:e},cs=(e,n)=>{const t=as(e,n),o=wn(n);if("shared"===t.kind){if(o!==Oe||!Yt.shared?.nodeOf(t.section))return!1;const{floor:e,cap:r}=mi();return n.index>=e&&n.index<=r}if("block"!==t.kind){if(rs(o)){if("preset"===t.kind)return!1;const e="section"===t.kind?t.type:t.template.node.type;return is(o,e)&&n.index>=0&&n.index<=Ti(o).length}if(o!==Oe)return!1;const{floor:e,cap:r}=mi();return n.index>=e&&n.index<=r}if(o===Oe)return!1;const r=ds(o);return!(!r||!r.choices.some(e=>e.type===t.type))&&!r.target.spec?.addBlocked?.(Ti(o))},ps=(e,n)=>{const t=as(e,n);if("block"!==t.kind&&rs(wn(n)))return void((e,n,t)=>{const o="section"===e.kind?e.type:"template"===e.kind?e.template.node.type:null;if(o&&is(n,o)){if("section"===e.kind)bo.insertComponent(n,e.type,t);else{if("template"!==e.kind)return;bo.insertNode(n,t,vi(e.template.node))}or(V),bo.select({index:t,zone:n})}})(t,wn(n),n.index);if("section"===t.kind)return void al(t.type,n.index);if("template"===t.kind)return void((e,n,t)=>{const o=ll(t),r=bo.insertNode(Oe,o,n);dl(o,r,e)})(t.template.name,vi(t.template.node),n.index);if("preset"===t.kind)return void((e,n,t)=>{const o=n({nodeDefaults:Ii,newNodeId:$e,sectionLabel:Bi,blockIsOffered:wr});if(!o)return;const r=ll(t),i=bo.insertNode(Oe,r,o);dl(r,i,e)})(t.preset.label,t.preset.insert,n.index);if("shared"===t.kind){const e=Yt.shared?.nodeOf(t.section);if(!e)return;const o=ll(n.index);return void(ki.restore(e,{parentId:kn,slot:Sn,index:o})&&dl(o,e.props.id,t.section.title))}const o=wn(n),r=ds(o);r&&(r.target.spec?Tl(r.parentId,r.target.slot,t.type,n.index,r.parent.type):((e,n,t)=>{bo.insertComponent(e,n,t),or(V),bo.select({index:t,zone:e})})(o,t.type,n.index))},us=(e,n)=>{e.media?function(e){const n=Ks();if(!n||!Xs)return;_s(n).then(n=>{n&&function(e,n){if(!Xs)return;const t=Xs.create(e,{nodeDefaults:Ii,newNodeId:$e,sectionLabel:Bi,blockIsOffered:wr}),o=wn(n);if(o===Oe){const e=ll(n.index),o=bo.insertNode(Oe,e,t);return void dl(e,o,Bi(t.type))}bo.insertNode(o,n.index,t),or(V),bo.select({index:n.index,zone:o})}(n,e)})}(n):e.rung?Wi(e.rung.nodeId,e.index,n.index):e.add?ps(e.add,n):e.zone===Oe?sl(e.index,n.index):ns(e.zone,wn(n),e.index,n.index)},[fs]=Rn(()=>yn()),hs=vn({keyOf:e=>e.id,readOnly:Boolean(Mt),session:fs,canDrop:ls,onDrop:us,onStep:(e,n)=>{e.rung?Wi(e.rung.nodeId,e.index,n<0?e.index-1:e.index+2):e.zone===Oe?((e,n)=>{const t=Bi(hi[e]?.type??""),o=sl(e,n<0?e-1:e+2);if(!o.moved)return void Zr(n<0?oo.sectionFirst({name:t}):oo.sectionLast({name:t}));const{floor:r,cap:i}=mi();Zr(oo.sectionMoved({name:t,n:o.dest-r+1,total:i-r}))})(e.index,n):ns(e.zone,e.zone,e.index,n<0?e.index-1:e.index+2)}}),ms=Dn(e=>{const{floor:n,cap:t}=mi(),o=[];for(const r of e.nodes){const e=wn(r.place),i=Ti(e)[r.place.index];if(!i||String(i.props.id)!==r.id)continue;if(qt(i)||eo(i)||yr(i.type,i))continue;if(Zt(i.type))continue;const l=Boolean(rs(e)),s=e===Oe||l;e===Oe&&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?Bi(i.type):Yi(i),from:r.place})}const r=e.zones.flatMap(e=>{const n=wn(e.list);if(n===Oe&&0===e.children.length)return[{...e,addLabel:oo.addSection,addAlways:!0}];const t=ds(n),o=t?.target.spec?.addLabel;return e.children.length>0||Boolean(t?.choices.length)||Boolean(rs(n))?[o?{...e,addLabel:o}:e]:[]}),i=r.flatMap(e=>{const n=wn(e.list),t=n===Oe||rs(n)?null:ds(n);return t?.choices.length?fn(e,t.target.spec?.addLabel??oo.addBlockHere):[]});return{sources:o,zones:r,seams:i}},[Ft.data]),gs=null==Wt?.props.id?null:String(Wt.props.id),ys=Wn(Ae),vs=ys?.selected()&&Wo?.document&&gs?ys.selectedPart?.(Wo.document)??null:null,bs=vs&&gs&&Le(Ft.data,Ut,gs,vs)?vs:null,ks=bs?.label?{element:bs.element,label:bs.label}:null,Ss=null!==bs,ws=Dn(e=>{const n=Ut,t=e=>!e.item.rung&&null!==zn(Ft.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(gs);return i?Ss?null:i:r(Ke(Ft.data,n,o.item.id,gs,Vl))??o},[Ft.data,Ut,gs,Vl,Ss]),[xs,zs]=Rn(null),[Cs,Os]=Rn(null),Ns=zr.canvasTab,Is=Boolean(Dl||Hl||Ns);Pn(Wo,"mouseover",e=>{if(!Is)return;const n=$n(e.target),t=n?yt(Ft.data,Ut,n):null;t!==xs&&zs(t),Ns&&n!==Cs&&Os(n)}),Pn(Wo,"mouseout",e=>{Is&&!e.relatedTarget&&(zs(null),Os(null))});const Bs=e=>qt(e)||eo(e)||Zt(e.type),Ps=e=>{const n=Zt(e.type)?Ni(e.type):qt(e)?oo.header:eo(e)?oo.footer:null;return null===n?Pi(e):zr.rowName?zr.rowName(e,"section",n):n},$s=[];if(Is){const e=gs?yt(Ft.data,Ut,gs):null;for(const n of/* @__PURE__ */new Set([e,xs])){const e=n?hi.find(e=>String(e.props.id)===n):void 0;if(!e)continue;const t=qt(e)||e.type===Xt,o=Ul(e);if(o){$s.push({id:String(e.props.id),label:Ps(e),below:t,reach:o});continue}if(!Dl||!Bs(e))continue;const r=Dl(e);r&&$s.push({id:String(e.props.id),label:r,below:t})}for(const e of Ns?/* @__PURE__ */new Set([gs,Cs]):[]){const n=e?ji(e):void 0,t=n?Ns(n):null;t&&!$s.some(n=>n.id===e)&&$s.push({id:e,label:t,below:!1,above:!0})}}const Ms=fe(),Ts=An(null);Fn(()=>{const e=Yt.changeNotice;if(!e)return;const n=JSON.stringify(hi.filter(Bs)),t=Ts.current;if(Ts.current={doc:Un,bands:n,index:Vt.index},!t||t.doc!==Un||t.bands===n)return;Vt.hasPast&&Vt.index>=t.index&&!gt.has(Ms)&&(gt.add(Ms),Zr(e,"success",{action:{label:oo.bar.undo,onClick:()=>Vt.back()},duration:8e3}))},[hi]);const js=e=>{or(V),bo.select(e.zone===Oe?{index:e.index}:{index:e.index,zone:e.zone})},Es=q(),As=()=>({data:Ft.data,device:Io,ops:bo,inspector:fr}),Ls=Es?.model,Rs=Ln(()=>Ls?e=>Ls(e,ms(e),As()):ms,[Ls,ms,Io]),Fs=Es?.measure,Ds=Fs?(e,n)=>Fs(e,n,As()):void 0,Vs=Es?.canDrop,Ws=Vs?(e,n)=>Vs(e,n,ls,As()):ls,Hs=Es?.drop,Us=Hs?(e,n)=>Hs(e,n,us,As()):us,Ys=Es?.pick,Js=Ys?e=>Ys(e,js,As()):js,Xs=Es?.media??null,Qs=An(null),Zs=Ln(()=>Xs?{id:ht,zone:"",index:-1,type:Xs.adds.type,add:{kind:Xs.adds.kind,type:Xs.adds.type},media:!0}:null,[Xs]);Fn(()=>{if(!Zs||Mt||"undefined"==typeof document)return;const e=e=>{(e=>Array.from(e.dataTransfer?.types??[]).includes(nt))(e)&&(Qs.current=null,fs.start({key:ht,item:Zs}))},n=e=>{fs.get()?.item.media&&(Qs.current=Zn(e.dataTransfer))},t=()=>{fs.get()?.item.media&&fs.end()};return document.addEventListener("dragstart",e),document.addEventListener("drop",n,!0),document.addEventListener("dragend",t,!0),()=>{document.removeEventListener("dragstart",e),document.removeEventListener("drop",n,!0),document.removeEventListener("dragend",t,!0)}},[Zs,Mt,fs]);const Ks=()=>{const e=Qs.current;return Qs.current=null,e},Gs=ce(),_s=async e=>{if(!Gs)return e;const n=await Gs(e);return n?{...e,id:n.id,url:n.url}:null};const qs=(e,n)=>{if(!Xs)return;const t=zn(vo.getState().appState.data,gi,n);if(!t)return;const o=t.node;bo.replaceComponent(wn(t.place),t.place.index,{...o,props:{...Xs.replace(o,e),id:o.props.id}})},ed=e=>{const n=wn(e),t=Ai(n);t&&Di(t.node,t.slot,!1),pl(n,e.index)},nd=(e,n)=>/* @__PURE__ */pt(Ye,{...Mt?{}:hs.seam({place:{...xn(e),index:n}})},`seam:${e}:${n}`),td={rowClick:hl,isCollapsed:Ur,toggleCollapse:Yr},od=e=>{const n=String(e.props.id),t=hi.findIndex(e=>String(e.props.id)===n),o=Kt(n),r=Ti(o),i=Ur(n),l=Ni(e.type),s=zr.rowName?zr.rowName(e,"section",l):l,d=e=>nd(o,e);/* @__PURE__ */
|
|
16
|
+
return ut(ft,{children:[
|
|
17
|
+
/* @__PURE__ */pt(De,{words:ro,icon:/* @__PURE__ */pt(Or,{type:e.type,size:13}),name:s,preview:gl(e),marks:yl(e),onSelect:()=>il(t),nameSlot:Xi(Oe,t,n,s),selected:rr===n,badge:Ul(e)?void 0:Ql,shared:Ul(e),actions:vl(e,Oe,t)??void 0,rowProps:{"data-node-id":n,onClick:hl(()=>il(t))},fold:{open:!i,label:"section",onToggle:()=>Yr(n)}}),!i&&/* @__PURE__ */ut(Ve,{children:[r.map((n,t)=>{const r=String(n.props.id),i=Pi(n),l=Pl(n),s=l&&Ur(r),a=()=>Ml(o,t,r,e.type),{rowProps:c,...p}=hs.row({item:{id:r,zone:o,index:t,type:n.type},place:{...xn(o),index:t}},{"data-node-id":r,onClick:hl(a)});/* @__PURE__ */
|
|
18
|
+
return ut(Hn,{children:[d(t),
|
|
19
|
+
/* @__PURE__ */pt(De,{words:ro,icon:/* @__PURE__ */pt(Or,{type:n.type,size:13}),name:i,preview:gl(n),marks:yl(n),onSelect:a,nameSlot:Xi(o,t,r,i),selected:rr===r,hidden:Boolean(n.props._hidden),...p,fold:l?{open:!s,label:"section",onToggle:()=>Yr(r)}:void 0,actions:/* @__PURE__ */ut(ft,{children:[ml(o,t,i),vl(n,o,t),bl(o,t,n,i)]}),rowProps:c}),l&&!s&&/* @__PURE__ */pt(Ve,{children:ld(n,2)})]},r)}),d(r.length)]})]})},rd=(e,n,t,o,r)=>{const i=String(e.props.id),l=`${i}:${n.slot}`,s=hs.dragging,d=!Ur(l)&&s?.rung?.nodeId!==i,a={...xn(l),index:0},c=s&&!s.rung&&ls(s,a)?a:void 0,p=()=>Di(e,n,!0),{rowProps:u,...f}=hs.row({item:{id:`rung:${l}`,zone:`${i}:${wt}`,index:t,type:e.type,rung:{nodeId:i,slot:n.slot}},place:{parentId:i,slot:wt,index:t},into:c,canDrag:Boolean(gr.moveSlot)&&!1!==n.movable&&o>1},{"data-slot-zone":l,onClick:hl(p)}),h=Mt?null:gr.slotActions?.(e,n.slot);/* @__PURE__ */
|
|
20
|
+
return ut(Hn,{children:[n.heading,
|
|
21
|
+
/* @__PURE__ */pt(De,{words:ro,icon:n.glyph??null,name:n.label,badge:n.badge,onSelect:p,selected:Li===l,...f,dragHint:n.dragHint,fold:{open:d,label:n.label,onToggle:()=>Yr(l)},actions:h&&h.length>0?/* @__PURE__ */pt(ft,{children:h.map((t,o)=>/* @__PURE__ */pt(Ue,{kind:"delete"===t.kind?"delete":"plain",label:t.label,disabled:t.disabled,onClick:()=>((e,n,t)=>{if(Mt||t.disabled)return;const o=String(e.props.id),r=e=>{"string"==typeof e&&Vi(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__ */pt(lt,{size:15}):/* @__PURE__ */pt(ct,{size:15})},`${o}:${t.kind}`))}):void 0,rowProps:u}),d&&/* @__PURE__ */pt(Ve,{children:r})]},l)},id=(e,n)=>{const t=zl(e),o=t.filter(e=>e.rung).length;let r=0;/* @__PURE__ */
|
|
22
|
+
return pt(ft,{children:t.map(t=>{const i=t.kids,l=t.rung?n+1:n,s=Nl(e,void 0,t.slot),d=s?`${e.props.id}:${s.slot}`:null,a=null===t.slot?null:`${e.props.id}:${t.slot}`,c=(e,n)=>nd(e,n),p=/* @__PURE__ */ut(ft,{children:[i.map(({child:n,zone:t,index:o})=>{const r=rr===String(n.props.id),{collapsible:i,folded:s}=Il(n,l,$l(n.type)),d=String(n.props.id),a=es(n),p=()=>Ml(t,o,d,e.type),{rowProps:u,...f}=hs.row({item:{id:d,zone:t,index:o,type:n.type},place:{...xn(t),index:o}},{"data-node-id":d,onClick:hl(p)});/* @__PURE__ */
|
|
23
|
+
return ut(Hn,{children:[0===o&&c(t,0),
|
|
24
|
+
/* @__PURE__ */pt(De,{words:ro,icon:/* @__PURE__ */pt(Or,{type:n.type,size:13}),name:a,preview:gl(n),marks:yl(n),onSelect:p,nameSlot:Xi(t,o,d,a),selected:r,hidden:Boolean(n.props._hidden),...f,fold:i?{open:!s,label:"group",onToggle:()=>Yr(d)}:void 0,actions:/* @__PURE__ */ut(ft,{children:[ml(t,o,a),vl(n,t,o),bl(t,o,n,a)]}),rowProps:u}),i&&!s&&/* @__PURE__ */pt(Ve,{children:id(n,l+1)}),c(t,o+1)]},String(n.props.id??`${t}-${o}`))}),null===a?d&&!i.some(e=>e.zone===d)?c(d,0):null:0!==i.length||!t.rung&&d!==a?null:c(a,0)]});return t.rung?rd(e,t.rung,r++,o,p):/* @__PURE__ */pt(Hn,{children:p},t.slot??"")})})},ld=(e,n)=>{const t=br(Ft?.data,e.type,String(e.props.id)),o=zl(e),r=o.filter(e=>e.rung).length;let i=0;/* @__PURE__ */
|
|
25
|
+
return pt(ft,{children:o.map(o=>{const l=o.kids,s=o.rung?n+1:n,d=Nl(e,t,o.slot),a=d?.spec??null,c=a&&Array.isArray(e.props[a.slot])?e.props[a.slot]:[],p=d&&d.choices?{slot:d.slot,choices:d.choices}:null,u=String(e.props.id),f=a&&!a.fixed?`${u}:${a.slot}`:null,h=p?`${u}:${p.slot}`:null,m=(e,n)=>nd(e,n),g=null===o.slot?null:`${u}:${o.slot}`,y=Boolean(a&&!a.fixed&&(null===g||g===f)),v=/* @__PURE__ */ut(ft,{children:[l.map(({child:n,zone:t,index:o})=>{const r=rr===String(n.props.id),i=Yi(n),l=String(n.props.id),{collapsible:d,folded:a}=Il(n,s,$l(n.type)),c=wl(n.type),p=1===c.length?`${l}:${c[0]}`:null,u=p?{...xn(p),index:Ti(p).length}:void 0,f=hs.dragging,h=u&&f&&ls(f,u)?u:void 0,g=()=>Ml(t,o,l,e.type),{rowProps:y,...v}=hs.row({item:{id:l,zone:t,index:o,type:n.type},place:{...xn(t),index:o},into:h,canDrag:!yr(n.type,n)},{"data-node-id":l,onClick:hl(g)});/* @__PURE__ */
|
|
26
|
+
return ut(Hn,{children:[0===o&&m(t,0),
|
|
27
|
+
/* @__PURE__ */pt(De,{words:ro,icon:/* @__PURE__ */pt(Or,{type:n.type,size:13}),name:i,preview:gl(n),marks:yl(n),onSelect:g,nameSlot:Xi(t,o,l,i),selected:r,hidden:Boolean(n.props._hidden),...v,fold:d?{open:!a,label:"group",onToggle:()=>Yr(l)}:void 0,actions:yr(n.type,n)?vl(n,t,o)??void 0:/* @__PURE__ */ut(ft,{children:[ml(t,o,i),vl(n,t,o),bl(t,o,n,i)]}),rowProps:y}),d&&!a&&/* @__PURE__ */pt(Ve,{children:ld(n,s+1)}),m(t,o+1)]},String(n.props.id??`${t}-${o}`))}),y&&a&&
|
|
28
|
+
/* @__PURE__ */pt(z,{small:!0,label:a.addLabel,blocked:a.addBlocked?.(c)??null,onAdd:()=>Tl(e.props.id,a.slot,a.childType,c.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?rd(e,o.rung,i++,r,v):/* @__PURE__ */pt(Hn,{children:v},o.slot??"")})})},sd=Zo,dd=e=>"panel"in e?{id:e.id,label:e.label,icon:e.icon,active:So&&!sd&&mr===e.id,onSelect:()=>ui(e.id)}:e,ad=[...(hr.railLead??[]).map(dd),{id:"sections",label:oo.layers,icon:/* @__PURE__ */pt(ge,{}),active:So&&!sd&&"sections"===mr,onSelect:()=>ui("sections")},...(hr.railTrail??[]).map(dd)],cd=$o?{onPress:Mo}:At?{onPress:()=>{x(Nn,{accept:"image/*",title:po.mediaLibrary})}}:null,pd={value:ad.find(e=>!0===e.active)?.id??"",press:e=>{const n=ad.find(n=>n.id===e);n&&!n.disabled&&!0!==n.active&&n.onSelect?.()},items:ad.map(e=>({id:e.id,icon:e.icon,label:/* @__PURE__ */pt("span",{className:"sr-only",children:e.label}),tooltip:e.label,disabled:e.disabled}))},ud=[...hr.railLead??[],...hr.railTrail??[]].find(e=>"panel"in e&&e.id===mr),fd=Boolean(to?.foldable),hd=to?.label??(Lt?oo.pageSections:oo.templateSections),md=fd&&Ur(zt),gd=/* @__PURE__ */ut(ft,{children:[hi.map((e,n)=>{if(qt(e)||eo(e)||Zt(e.type))return null;const t=rr===String(e.props.id),o=Boolean(e.props._hidden);xl(e);const r=String(e.props.id),i=hr.hasOwnRows?.(e)??!1,l=Pl(e)||i,s=l&&Ur(r),d=wl(e.type),a=1===d.length?`${r}:${d[0]}`:null,c=a?{...xn(a),index:Ti(a).length}:void 0,p=hs.dragging,u=c&&p&&ls(p,c)?c:void 0,{rowProps:f,...h}=hs.row({item:{id:r,zone:Oe,index:n,type:e.type},place:{...xn(Oe),index:n},into:u,canDrag:!yr(e.type,e)},{"data-node-id":r,onClick:hl(()=>il(n))});/* @__PURE__ */
|
|
29
|
+
return ut(Hn,{children:[n>0&&kl(n),
|
|
30
|
+
/* @__PURE__ */pt(De,{words:ro,icon:/* @__PURE__ */pt(Or,{type:e.type,size:13}),name:Pi(e),preview:gl(e),marks:yl(e),shared:Ul(e),onSelect:()=>il(n),nameSlot:Xi(Oe,n,r,Pi(e)),selected:t,hidden:o,...h,fold:l?{open:!s,label:"section",onToggle:()=>Yr(r)}:void 0,actions:/* @__PURE__ */ut(ft,{children:[ml(Oe,n,Pi(e)),vl(e,Oe,n),bl(Oe,n,e,Pi(e))]}),rowProps:f}),Pl(e)&&!s&&/* @__PURE__ */ut(Ve,{children:[ld(e,1),hr.partRows?.(e,td)]}),i&&!s&&/* @__PURE__ */pt(Ve,{children:hr.ownRows?.(e,n,td)})]},String(e.props.id??n))}),Gl>0&&kl(Gl)]}),yd=(e,n,t)=>{const o=String(e.props.id),r=Cl(e).length>0||Ol(e)||Boolean(Sr(e.type)),i=r&&Ur(o),l="header"===t?oo.header:oo.footer,s=zr.rowName?zr.rowName(e,"section",l):l;/* @__PURE__ */
|
|
31
|
+
return ut(ft,{children:[
|
|
32
|
+
/* @__PURE__ */pt(De,{words:ro,icon:/* @__PURE__ */pt(Or,{type:t,size:13}),name:s,preview:gl(e),marks:yl(e),badge:Ul(e)?void 0:Ql,shared:Ul(e),onSelect:()=>il(n),nameSlot:Xi(Oe,n,o,s),selected:rr===String(e.props.id),fold:r?{open:!i,label:"section",onToggle:()=>Yr(o)}:void 0,actions:vl(e,Oe,n)??void 0,rowProps:{"data-node-id":o,onClick:hl(()=>il(n))}}),r&&!i&&/* @__PURE__ */pt(Ve,{children:id(e,1)})]})};return(hr.wrap??(e=>e))(
|
|
33
|
+
/* @__PURE__ */pt(ee,{target:Wo,children:/* @__PURE__ */ut("div",{ref:Vo,className:"sf-editor es-editor",style:ln(Fr),onContextMenu:qi.onEditorContextMenu,...p(Nn),children:[
|
|
34
|
+
/* @__PURE__ */ut(Ge,{children:[
|
|
35
|
+
/* @__PURE__ */ut("div",{className:"es-cluster es-cluster--left",children:[cd?/* @__PURE__ */pt(Jn,{variant:"secondary",className:"es-barbtn",leftIcon:/* @__PURE__ */pt(ye,{}),onClick:cd.onPress,children:oo.railMedia}):null,
|
|
36
|
+
/* @__PURE__ */pt(_e,{label:oo.bar.undo,disabled:Boolean(Mt)||!Vt.hasPast,onClick:()=>Vt.back(),children:/* @__PURE__ */pt(tt,{})}),
|
|
37
|
+
/* @__PURE__ */pt(_e,{label:oo.bar.redo,disabled:Boolean(Mt)||!Vt.hasFuture,onClick:()=>Vt.forward(),children:/* @__PURE__ */pt(ot,{})})]}),
|
|
38
|
+
/* @__PURE__ */ut(qe,{children:[
|
|
39
|
+
/* @__PURE__ */pt(en,{devices:xo,value:Io,onChange:Bo}),
|
|
40
|
+
/* @__PURE__ */pt(_e,{label:oo.bar.refresh,tip:oo.bar.refreshTip,onClick:()=>{Do.current=(()=>{const e=Wo?.document;if(!e)return null;const n=hi.findIndex(eo),t=n>=0?n:hi.length;let o=null;for(let n=0;n<t;n++){const t=hi[n]?.props?.id;if(null==t)continue;const r=En(e,`[data-easel-block="${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=Wt?.props?.id??hi[0]?.props?.id;null!=e&&(o={id:String(e),offset:0})}return o})(),Fo(e=>e+1)},children:/* @__PURE__ */pt(rt,{})}),hr.barView?.()]}),
|
|
41
|
+
/* @__PURE__ */ut(qe,{kind:"right",style:{minWidth:300},children:[
|
|
42
|
+
/* @__PURE__ */pt(b,{input:Xo,words:oo.saveStatus}),Mn?/* @__PURE__ */pt(Mn,{}):null,hr.barLead?.(),hr.barTrail?.(),hr.mainAction||!hr.barMain?/* @__PURE__ */pt(k,{input:Xo,action:hr.mainAction??{label:oo.done,onPress:()=>{qn(Ft.data)}},readOnly:Boolean(Mt),saveSwitch:jt,onToggleAutoSave:It,onSaveNow:Qo,bar:oo.bar,words:oo.saveStatus}):hr.barMain()]})]}),
|
|
43
|
+
/* @__PURE__ */pt(v,{}),
|
|
44
|
+
/* @__PURE__ */ut("div",{className:"sf-body",children:[So?/* @__PURE__ */ut(ft,{children:[
|
|
45
|
+
/* @__PURE__ */ut("aside",{className:"es-sidepanel es-sidepanel--left sf-panel sf-panel--left","aria-label":oo.leftPanel,children:[
|
|
46
|
+
/* @__PURE__ */ut("div",{className:"es-paneltabs es-paneltabs--with-hide",children:[
|
|
47
|
+
/* @__PURE__ */pt(I,{side:"left",onHide:ci}),
|
|
48
|
+
/* @__PURE__ */pt("span",{className:"es-paneltabs-divider","aria-hidden":"true"}),
|
|
49
|
+
/* @__PURE__ */pt(Xn,{variant:"underline",block:!0,"aria-label":oo.bar.views,value:pd.value,onChange:pd.press,items:pd.items})]}),Zo?/* @__PURE__ */pt(C,{at:_o?{label:(e=>{const n=rs(e.zone);if(n)return oo.add.addingTo({name:zr.rowName?fl(n,!0):Ni(n.type)});if(e.zone===Oe){const n=hi[e.index];return n&&!eo(n)?oo.add.addingBefore({name:fl(n,!0)}):oo.add.addingAtEnd}const t=ds(e.zone);return t?oo.add.addingTo({name:t.parentName}):oo.add.addingHere})(_o),onClear:()=>qo(null)}:void 0,placeBlocks:_o&&_o.zone!==Oe?ds(_o.zone)?.choices:void 0,canTake:_o?e=>{if(!_o)return null;const n={...xn(_o.zone),index:_o.index};if(cs(e,n))return null;if("shared"===e.kind&&_o.zone===Oe&&!Yt.shared?.nodeOf(e.section))return oo.shared.alreadyHere;const t=rs(_o.zone);if(t)return oo.add.notInside({name:fl(t,!0)});if(_o.zone===Oe)return oo.add.onlySections;const o=ds(_o.zone);return o?oo.add.notInside({name:o.parentName}):oo.add.onlySections}:void 0,onPick:_o?e=>{if(!_o)return;const n={...xn(_o.zone),index:_o.index};cs(e,n)&&(ps(e,n),ul())}:void 0,itemFor:e=>({id:`new:${e.kind}:${xt(e)}`,zone:"",index:-1,type:"template"===e.kind?e.template.node.type:"shared"===e.kind?e.section.node.type:xt(e),add:e}),session:fs,siteWide:hr.addPanelRow?.(ul),onClose:ul,readOnly:Boolean(Mt)}):ud?ud.panel({onHide:ci,notify:Zr}):/* @__PURE__ */ut(ft,{children:[
|
|
50
|
+
/* @__PURE__ */pt(B,{icon:/* @__PURE__ */pt(ge,{}),title:oo.layers,context:uo,actions:/* @__PURE__ */ut(ft,{children:[!Mt&&/* @__PURE__ */pt(nn,{label:oo.add.title,onClick:()=>cl(null),children:/* @__PURE__ */pt(it,{size:15})}),
|
|
51
|
+
/* @__PURE__ */pt(nn,{label:ql?oo.expandAll:oo.collapseAll,title:0===_l.length?oo.nothingToFold:void 0,disabled:0===_l.length,onClick:()=>Rr(e=>{const n=new Set(_l);return ql?new Set([...e].filter(e=>!n.has(e))):/* @__PURE__ */new Set([...e,..._l])}),children:/* @__PURE__ */pt(bt,{expand:ql})})]})}),
|
|
52
|
+
/* @__PURE__ */ut(We,{className:"sf-tree sf-scroll",words:ro,children:[Zl&&/* @__PURE__ */ut(ft,{children:[!Wl&&/* @__PURE__ */pt(He,{children:oo.header}),od(Zl)]}),Rt&&!(Wl&&Zl)&&/* @__PURE__ */ut(ft,{children:[!Wl&&/* @__PURE__ */pt(He,{children:oo.header}),!no&&/* @__PURE__ */pt(De,{words:ro,icon:/* @__PURE__ */pt(Or,{type:"header",size:13}),name:oo.header,badge:Xl?void 0:Ql,shared:Xl,onSelect:fi,selected:tr.kind===_t?.kind,rowProps:{onClick:hl(fi)}})]}),Fl&&!(Wl&&Zl)&&yd(Fl,Rl,"header"),!fd&&/* @__PURE__ */pt(He,{children:hd}),fd?/* @__PURE__ */ut(ft,{children:[
|
|
53
|
+
/* @__PURE__ */pt(De,{words:ro,icon:null,name:hd,fold:{open:!md,label:hd,onToggle:()=>Yr(zt)}}),!md&&/* @__PURE__ */pt(Ve,{children:gd})]}):gd,Rt&&!Wl&&/* @__PURE__ */pt(He,{children:oo.footer}),Ll&&!(Wl&&Kl)&&yd(Ll,Al,"footer"),Kl&&od(Kl),hr.treeFoot?.()]})]})]}),
|
|
54
|
+
/* @__PURE__ */pt(tn,{side:"left",width:Fr.left,min:rn.left,max:on,defaultWidth:h.left,label:oo.resizeLeftPanel,onResize:Wr})]}):/* @__PURE__ */pt(P,{side:"left",onShow:ci}),
|
|
55
|
+
/* @__PURE__ */ut("div",{ref:Kr,className:"sf-center sf-scroll","data-sf-canvas-head":ni?"":void 0,style:{overflowX:si?"auto":"hidden",overflowY:"hidden"},children:[ni&&/* @__PURE__ */pt("div",{ref:ti,className:"sf-canvas-head",children:/* @__PURE__ */pt(ni,{device:Io})}),
|
|
56
|
+
/* @__PURE__ */ut("div",{className:"sf-frame-scaler",style:di,children:[
|
|
57
|
+
/* @__PURE__ */pt("div",{className:"sf-frame "+(Io===Oo?"":`sf-frame--${Io}`),style:ai,children:/* @__PURE__ */ut("div",{className:"sf-preview-host",children:[
|
|
58
|
+
/* @__PURE__ */pt(Re.Provider,{value:Vl,children:/* @__PURE__ */pt(Fe.Provider,{value:Jl,children:/* @__PURE__ */pt(fo,{},Ro)})}),
|
|
59
|
+
/* @__PURE__ */pt(hn,{canvas:Wo,session:fs,model:Rs,measure:Ds,canDrop:Ws,onDrop:Us,choose:ws,tag:ks,onPick:Js,dropOn:Xs?{accepts:(e,n)=>{if(!e.media||!Xs||n.item.rung)return!1;const t=zn(Ft.data,gi,n.item.id);return null!==t&&Xs.takes(t.node)},onDrop:(e,n)=>(e=>{const n=Ks();n&&Xs&&_s(n).then(n=>{n&&qs(n,e.item.id)})})(n),label:()=>oo.canvasReplaceImage}:void 0,onZoneAdd:ed,onSeamAdd:ed,zoneAddLabel:oo.canvasAddBlock,words:io.canvas,readOnly:Boolean(Mt),revision:Ft.data}),er.length>0&&!Ho&&/* @__PURE__ */pt("div",{className:"sf-preview-gaps",children:er.map(e=>
|
|
60
|
+
/* @__PURE__ */pt(mn,{index:e.index,label:oo.addSectionHere,onInsert:()=>cl(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))})]})}),Is?/* @__PURE__ */pt(vt,{canvas:Wo,tabs:$s,onSelect:Fi}):null]})]}),wo?/* @__PURE__ */ut(ft,{children:[Tn?
|
|
61
|
+
/* @__PURE__ */pt("div",{className:"es-sidepanel es-sidepanel--right","data-es-host-panel":"",children:Tn}):/* @__PURE__ */pt(ft,{children:/* @__PURE__ */pt(u,{value:{selectChild:Ml,addChild:Tl,childRowName:Yi,blockRowName:es},children:/* @__PURE__ */pt(ho,{mode:tr,onOpenWebsiteSettings:hr.openSettings??(()=>{}),onOpenSiteStyles:hr.openStyles,onOpenPageStyles:hr.openPageStyles,onSelectNode:Pr,onNotify:Zr,onHidePanel:pi,nodeActions:Wt?Ne(Ut,Wt.type):Ct})})}),
|
|
62
|
+
/* @__PURE__ */pt(tn,{side:"right",width:Fr.right,min:rn.right,max:on,defaultWidth:h.right,label:oo.resizeSettingsPanel,onResize:Hr})]}):
|
|
63
|
+
/* @__PURE__ */pt(P,{side:"right",onShow:pi})]}),qi.menu,
|
|
64
|
+
/* @__PURE__ */pt(ie,{}),wi?/* @__PURE__ */pt(mt,{name:wi.name,onMake:e=>(async(e,n)=>{const t=hi.find(n=>String(n.props.id)===e),o=Yt.shared;if(!t||!o)return;let r;try{r=await N(Si).create(n,t)}catch{return void Zr(oo.shared.makeFailed,"error")}o.adopt(t,r),xi(null)})(wi.id,e),onCancel:()=>xi(null)}):null]})}))}export{Nt as ScreenChrome};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{panelFieldsOf as t}from"./chunk-5XL2RXFU.js";import{DESIGN_GROUP_KEY as o,BUCKET_KEY as n}from"./chunk-3QB2ZQXK.js";import{withoutDeviceGate as e}from"./chunk-7GGNFLHT.js";import{STYLE_KIND as r,fieldKind as s,copyStyle as c,heldStyle as i,planPaste as p,pasteMessage as u}from"./chunk-CWELHADJ.js";import{ANCHOR_FIELD_KEYS as f,foldMetaOf as a,MEDIA_FIELD_MARKER as l,TEXT_FIELD_MARKER as m,LINK_FIELD_MARKER as h}from"./chunk-ANPOR6EY.js";import{deviceMetaOf as y}from"./chunk-YCSZAP7T.js";var j=/* @__PURE__ */new Set([o.Size,o.Design,o.Layout,o.Position]),w=new Set(Object.values(o)),b=new Set(Object.values(n)),S=new Set(f),k=/* @__PURE__ */new Set(["focal","imageFocal"]),g=[l,m,h];function v(t){return`site:${t??""}`}function A(t){if(!t||"object"!=typeof t)return null;const o=t,n=e(t)??t,c=o[r]??n[r];if("string"==typeof c)return c;const i=o.options??n.options;if(Array.isArray(i)){return`choice:${i.map(t=>String(t?.value)).sort().join("|")}`}return s(n)}function L(t){const o=t,n=e(t);return g.some(t=>t in o||n&&t in n)}function O(o,e){const r=t(o,e)??{},s=[];let c=!0,i=!1;for(const[t,o]of Object.entries(r))b.has(t)?(c=t===n.Design,i=!1):w.has(t)?c&&(i=j.has(t)):i&&o&&"object"==typeof o&&!t.startsWith("_")&&(a(o)||S.has(t)||k.has(t)||L(o)||"slot"!==o.type&&s.push({path:[t],kind:A(o),counted:"mobile"!==y(o)?.tier}));return s}function d(t,o,n,e,r){c({scope:n,type:e.type,label:r,rows:t(o,e),props:e.props})}function D(t,o,n,e,r,s){const c=i(n);if(!c)return null;const f=p(c,{type:e.type,rows:t(o,e),props:e.props});return{...f,message:u(f,c.sourceLabel,r,s)}}function F(t,o,n,e){d(O,t,o,n,e)}function P(t,o,n,e,r){return D(O,t,o,n,e,r)}var X={scope:t=>v(t.siteId),rows:(t,o)=>O(t,o),copy:(t,o,n,e)=>F(e,t,o,n),plan:(t,o,n,e)=>P(e,t,o,n)};function C(t,o){if(!t&&!o)return X;const n=t?.rows,e=n?(t,o)=>n(t,o):O;return{scope:t?.scope??X.scope,rows:(t,o)=>e(t,o),copy:t?.copy??((t,o,n,r)=>d(e,r,t,o,n)),plan:t?.plan??((t,n,r,s)=>D(e,s,t,n,r,o))}}export{F as copyNodeStyle,O as nodeStyleRows,P as planNodePaste,A as shopFieldKind,v as siteStyleScope,C as styleClipboardOf};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useScreenBlockRules as e}from"./chunk-
|
|
1
|
+
import{useScreenBlockRules as e}from"./chunk-FT3O7X6U.js";import{newNodeId as t,ROOT_ZONE as n}from"./chunk-TCAAOYQY.js";import{useEasel as o,useEaselApi as r}from"./chunk-53ME3GAI.js";import{useMemo as s}from"react";function i(i={}){const{dispatch:p}=o(e=>e),d=r(),c=!0===i.readOnly,a=e().resolveOnInsert,l=!0===(i.resolveOnInsert??a),m=!0===i.foldIntoHistory;return s(()=>{const e=m?e=>p({...e,recordHistory:!1}):p,o=(n,o,r)=>{const s=t(o);return c||e({type:"insert",componentType:o,destinationZone:n,destinationIndex:r,id:s}),s},r=e=>(l&&!c&&d.resolveNode(e,{trigger:"insert"}),e),s=(t,n,o)=>{c||e({type:"replace",destinationZone:t,destinationIndex:n,data:o})},i=(e,t,n)=>r(o(e,t,n));return{insertComponent:i,insertSection:(e,t)=>i(n,e,t),replaceComponent:s,seedChild:(e,t,n,i)=>{const p=o(e,n,t);s(e,t,{type:n,props:{id:p,...i}}),r(p)},insertNode:(e,t,n)=>{const i=o(e,n.type,t);return s(e,t,{type:n.type,props:{...n.props,id:i}}),r(i)},removeComponent:(t,n)=>{c||e({type:"remove",index:n,zone:t})},reorderComponent:(t,n,o)=>{c||e({type:"reorder",sourceIndex:n,destinationIndex:o,destinationZone:t})},duplicateComponent:(t,n)=>{c||e({type:"duplicate",sourceIndex:n,sourceZone:t})},select:e=>p({type:"setUi",ui:{itemSelector:e}}),setDocument:t=>{c||e({type:"setData",data:t})},commitDocument:(t,n)=>{c||(m?d.batch(()=>{e({type:"setData",data:t}),void 0!==n&&("slot"===n?.kind?d.selectSlot({parentId:n.parentId,slot:n.slot}):d.select(n?n.id:null))}):d.run({data:t,select:n}))}}},[p,c,l,d,m])}export{i as useSectionOps};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{parseZoneKey as t}from"./chunk-EUFDQ4KL.js";import{repeatWrapperAt as e,REPEAT_ATTRIBUTE as r,REPEAT_INDEX_ATTRIBUTE as n}from"./chunk-7UFKEX72.js";var o=`[${r}][${n}]`;function l(l){const c=e(l);if(!c)return null;let i;try{i=t(c.zone)}catch{return null}if(!i.parentId||!i.slot)return null;const{wrapper:a,zone:p,index:f}=c;let s=a.parentElement;for(let t=a.parentElement;t;t=t.parentElement)if(t.getAttribute("data-easel-block")===i.parentId){s=t;break}const d=/* @__PURE__ */new Set;for(const t of Array.from(s?.querySelectorAll(o)??[]))t.getAttribute(r)===p&&d.add(t.getAttribute(n)??"");const m={ownerId:i.parentId,slot:i.slot,index:f,count:Math.max(d.size,f+1)},y=a.parentElement?u(a.parentElement):null;return y&&(m.outer=y),{copy:m,wrapper:a}}function u(t){return l(t)?.copy??null}function c(t,e){return t&&e?t.ownerId===e.ownerId&&t.slot===e.slot&&t.index===e.index&&c(t.outer,e.outer):t===e}function i(t,e){for(const r of Array.from(t.querySelectorAll(o))){if(r.getAttribute(n)!==String(e.index))continue;const t=l(r);if(t?.wrapper===r&&c(t.copy,e))return r}return null}export{i as findCopy,u as repeatCopyAt,l as repeatCopyWithWrapper};
|