efficient-easel 10.3.1 → 11.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -6
- package/dist/{canvas-typing-CJodefPO.d.ts → canvas-typing-DvoqQINU.d.ts} +43 -1
- package/dist/chunk-2PTAR4TA.js +56 -0
- package/dist/{chunk-BJNZKYK7.js → chunk-3KAQXJVI.js} +1 -1
- package/dist/{chunk-FCLW4LEN.js → chunk-47RGVCPH.js} +7 -7
- package/dist/{chunk-BGY4Q2SL.js → chunk-4MPCFKFG.js} +1 -1
- package/dist/{chunk-JSPZU7X2.js → chunk-7GYJG6CL.js} +1 -1
- package/dist/{chunk-P4CL4YQI.js → chunk-AFSSKGTD.js} +1 -1
- package/dist/{chunk-OGCROOTI.js → chunk-DGAXQTDW.js} +1 -1
- package/dist/chunk-FGJSCWUN.js +7 -0
- package/dist/chunk-GCCBEY2W.js +2 -0
- package/dist/chunk-GG4FGBFR.js +1 -0
- package/dist/chunk-HUI44HA5.js +5 -0
- package/dist/chunk-I55LUW3C.js +12 -0
- package/dist/{chunk-BRDCD4LK.js → chunk-IFS5P7CO.js} +1 -1
- package/dist/chunk-IOZKOGFR.js +1 -0
- package/dist/{chunk-545BRJIU.js → chunk-O66SKO3J.js} +1 -1
- package/dist/chunk-OHRS7Q3E.js +5 -0
- package/dist/{chunk-BPMLHWWM.js → chunk-PQMCHTVE.js} +1 -1
- package/dist/{chunk-535CJ7J4.js → chunk-UB5JFMRN.js} +1 -1
- package/dist/chunk-VWXUMVCD.js +1 -0
- package/dist/{chunk-26GHWMNN.js → chunk-XAF6J6TB.js} +12 -12
- package/dist/{chunk-QDAJKEG3.js → chunk-YJQYO6TA.js} +1 -1
- package/dist/{chunk-VYHA6EA6.js → chunk-YXIR3EI3.js} +4 -4
- package/dist/copy/index.d.ts +2 -2
- package/dist/copy/index.js +19 -25
- package/dist/drag/drag.css +11 -1
- package/dist/drag/index.d.ts +9 -3
- package/dist/drag/index.js +1 -1
- package/dist/easel/index.d.ts +8 -1
- package/dist/easel/index.js +1 -1
- package/dist/fields/index.js +1 -1
- package/dist/screen/components/AddBlockRow.js +1 -1
- package/dist/screen/components/AddChildRow.js +4 -1
- package/dist/screen/components/AddSidePanel.d.ts +13 -17
- package/dist/screen/components/AddSidePanel.js +1 -1
- package/dist/screen/components/MediaSidePanel.js +1 -1
- package/dist/screen/components/NodeContextMenu.d.ts +3 -15
- package/dist/screen/components/NodeContextMenu.js +1 -1
- package/dist/screen/components/PageEditGuardNotices.js +1 -1
- package/dist/screen/components/ScreenChrome.js +1 -1
- package/dist/screen/components/ScreenDocumentContext.js +1 -1
- package/dist/screen/components/ScreenMount.js +1 -1
- package/dist/screen/components/ScreenStoreProvider.js +1 -1
- package/dist/screen/components/SectionScreenShell.js +16 -16
- package/dist/screen/components/usePartBridge.js +1 -1
- package/dist/screen/index.d.ts +1 -1
- package/dist/screen/index.js +1 -1
- package/dist/screen/lib/key-scope.js +1 -1
- package/dist/screen/lib/puck/device-fields.js +1 -1
- package/dist/screen/lib/puck/style-clipboard.js +1 -1
- package/dist/screen/lib/puck/use-section-ops.js +1 -1
- package/dist/screen/lib/screen-parts.d.ts +6 -62
- package/dist/screen/lib/screen-parts.js +1 -1
- package/dist/screen/screen.css +2 -8
- package/dist/screen/words.d.ts +16 -23
- package/dist/screen/words.js +1 -1
- package/dist/strings/catalogue.js +1 -1
- package/dist/strings/index.js +1 -1
- package/dist/text-styles/index.js +19 -19
- package/package.json +1 -1
- package/dist/chunk-5545A3PC.js +0 -4
- package/dist/chunk-D6N77AOS.js +0 -1
- package/dist/chunk-EVY5SXFW.js +0 -5
- package/dist/chunk-G5MRFCCW.js +0 -5
- package/dist/chunk-JTUUIVBZ.js +0 -1
- package/dist/chunk-MMAC2VER.js +0 -57
- package/dist/chunk-O2NLQBFX.js +0 -1
- package/dist/chunk-PE6ZY5IW.js +0 -11
- package/dist/chunk-THZ46DC5.js +0 -2
- package/dist/chunk-TJ6NRHYF.js +0 -1
package/README.md
CHANGED
|
@@ -889,7 +889,7 @@ const drag = useTreeDrag({ …, session }); // the tree
|
|
|
889
889
|
</div>
|
|
890
890
|
|
|
891
891
|
<AddPanel groups={blocks} session={session} itemFor={(type) => ({ kind: 'new', type })}
|
|
892
|
-
onInsert={insertAtOpenPlace} at={openPlace && { label: 'Adding to Column 2', onClear }} />
|
|
892
|
+
onInsert={openPlace ? insertAtOpenPlace : undefined} at={openPlace && { label: 'Adding to Column 2', onClear }} />
|
|
893
893
|
```
|
|
894
894
|
|
|
895
895
|
- **The canvas measures itself:** `measureCanvas` reads the canvas's lists and
|
|
@@ -1188,11 +1188,16 @@ and confirms. `ScreenInspector.select(selector, mode)` moves the selection and
|
|
|
1188
1188
|
shows a panel in one step, the mode kept through the reset a change of
|
|
1189
1189
|
selection makes.
|
|
1190
1190
|
|
|
1191
|
-
Add
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1191
|
+
Add has TWO ways in, and no other (11.0.0, owner ruling A1 amended
|
|
1192
|
+
2026-10-14): a tile DRAGGED out of Add to its place, or a tile PRESSED after a
|
|
1193
|
+
canvas ➕ opened Add at that place, where it lands. The Layers head's "+" opens
|
|
1194
|
+
Add at no place — every tile is only dragged; the rail has no "+", the tree's
|
|
1195
|
+
gaps no "+", and no menu an add row. Add is ONE list wherever it opens: the
|
|
1196
|
+
catalogue's groups in their order, the blank section (`blockLook.firstSection`)
|
|
1197
|
+
leading its own, then the blocks the catalogue does not hold, from the
|
|
1198
|
+
registry (`canAddTo`), each once. At a place, what it cannot take is dimmed
|
|
1199
|
+
and says why. (`add.railTarget` and `add.blocksFirst`, 0.105.0, went with the
|
|
1200
|
+
rail's "+".) A category marked `visible: false` is not offered; Add's words are
|
|
1196
1201
|
`screen.add`. `styleClipboard` is Copy style / Paste style's scope and a
|
|
1197
1202
|
node's look (`scope`, `rows`, `copy`, `plan`); the bridges' `menuRows` are the
|
|
1198
1203
|
layer's own rows in a node's menu; ⌘C / ⌘X / ⌘V copy, cut and paste the
|
|
@@ -51,6 +51,12 @@ interface CopyThemeColor {
|
|
|
51
51
|
label: string;
|
|
52
52
|
value: string;
|
|
53
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* The colour the toolbar's A shows for `current` (a theme colour's name or a
|
|
56
|
+
* hex): the hex itself, or the theme colour's value. One rule for every bar
|
|
57
|
+
* that opens this window — the panel's text box and the canvas typing bar.
|
|
58
|
+
*/
|
|
59
|
+
declare function colorRunOf(current: string | null, colors: readonly CopyThemeColor[] | undefined): string | undefined;
|
|
54
60
|
declare function ColorWindow({ colors, current, words, onPick, }: {
|
|
55
61
|
colors: readonly CopyThemeColor[];
|
|
56
62
|
/** The colour the selection wears — a theme name or a hex — or null. */
|
|
@@ -434,6 +440,15 @@ interface CanvasTypingOptions {
|
|
|
434
440
|
/** What the toolbar shows may have changed (the selection moved, a press, a
|
|
435
441
|
* write): a host draws its buttons again from `pressed()`. */
|
|
436
442
|
onSelect?: () => void;
|
|
443
|
+
/**
|
|
444
|
+
* Escape was pressed in the words. A host whose toolbar has a window open
|
|
445
|
+
* (the link or the colour window) closes it and says `true`: typing goes on.
|
|
446
|
+
* `false`, or left out, and Escape ends typing, as always.
|
|
447
|
+
*/
|
|
448
|
+
onEscape?: () => boolean;
|
|
449
|
+
/** ⌘K / Ctrl+K in the words: a host that offers Link opens its link window
|
|
450
|
+
* and says `true` (the panel box's key). Left out, the key does nothing. */
|
|
451
|
+
onLinkKey?: () => boolean;
|
|
437
452
|
now?: () => number;
|
|
438
453
|
}
|
|
439
454
|
interface CanvasTypingSession {
|
|
@@ -450,6 +465,11 @@ interface CanvasTypingSession {
|
|
|
450
465
|
marks: Partial<Record<string, boolean>>;
|
|
451
466
|
list: 'bullet' | 'number' | null;
|
|
452
467
|
selected: boolean;
|
|
468
|
+
/** The address of the link the selection is in, or null: the link window opens on it. */
|
|
469
|
+
href: string | null;
|
|
470
|
+
/** The colour the selection wears (a theme colour's name or a hex, a
|
|
471
|
+
* pending one included), or null: the colour window shows it. */
|
|
472
|
+
color: string | null;
|
|
453
473
|
};
|
|
454
474
|
/** A mark button pressed (B, I, U, S, superscript, subscript): on the
|
|
455
475
|
* selected words, or for the words typed next — `markPress`, as the panel
|
|
@@ -471,8 +491,30 @@ interface CanvasTypingSession {
|
|
|
471
491
|
* typing (the canvas's `stop('outside')`).
|
|
472
492
|
*/
|
|
473
493
|
hold: () => void;
|
|
494
|
+
/** The hold is over (a window on the toolbar closed by a press in the words,
|
|
495
|
+
* which is placing the caret itself): leaving the words ends typing again. */
|
|
496
|
+
release: () => void;
|
|
497
|
+
/**
|
|
498
|
+
* A window on the toolbar closed without writing (Escape, Cancel): the hold
|
|
499
|
+
* is over, the focus goes back to the words and the selection the window
|
|
500
|
+
* was opened on is put back. Typing goes on.
|
|
501
|
+
*/
|
|
502
|
+
resume: () => void;
|
|
503
|
+
/**
|
|
504
|
+
* The link window's write (the panel box's, `linkOver` / `unlinkAt` on the
|
|
505
|
+
* selection held when it opened): an address links the words, null takes
|
|
506
|
+
* the link off them. One edit step; focus goes back to the words.
|
|
507
|
+
*/
|
|
508
|
+
link: (href: string | null) => void;
|
|
509
|
+
/**
|
|
510
|
+
* The colour window's write (the panel box's `colorOver`): a theme colour's
|
|
511
|
+
* NAME or a `#rrggbb` on the selected words, or null to take the colour
|
|
512
|
+
* off. At a bare caret it is for the words typed next. One edit step; the
|
|
513
|
+
* window stays open, so the focus is not moved.
|
|
514
|
+
*/
|
|
515
|
+
color: (color: string | null) => void;
|
|
474
516
|
}
|
|
475
517
|
/** Start typing in the words `element()` drew, or `null` where they are not the string's. */
|
|
476
518
|
declare function startCanvasTyping(o: CanvasTypingOptions): CanvasTypingSession | null;
|
|
477
519
|
|
|
478
|
-
export { type CopyBoxLastTool as C, MarkBar as M, type SelectionSource as S, type TextBoxHandle as T, type
|
|
520
|
+
export { type CopyBoxLastTool as C, MarkBar as M, type SelectionSource as S, type TextBoxHandle as T, type CopyThemeColor as a, type CanvasTypingEnd as b, type CopyBoxProps as c, type CopyCell as d, COPY_CELLS as e, type CanvasTypingOptions as f, type CanvasTypingSession as g, ColorWindow as h, type CopyBoxAlign as i, type CopyBoxFooter as j, type CopyCase as k, type CopyCellPreset as l, CopyCells as m, type MarkBarProps as n, type MarkWriter as o, type TextAreaHandle as p, type TextMap as q, type ToolbarMark as r, ariaShortcut as s, colorRunOf as t, insertSelection as u, markSelection as v, startCanvasTyping as w, textMap as x };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import{cloneNodeWithFreshIds as e}from"./chunk-2GVCAIPX.js";import{dedupeSlotChildren as n}from"./chunk-26OOWIJJ.js";import{styleClipboardOf as t}from"./chunk-IFS5P7CO.js";import{markedTreeNodeId as o,revealSelectedTreeRow as r,sameSelector as i}from"./chunk-FGNR22NY.js";import{rootRowName as l,slotChildRowName as s,slotChildRenameProp as d,sectionRenameProp as c}from"./chunk-BHRC3ASL.js";import{scrollPreviewToSection as a,gotoPreviewSlide as p,scrollPreviewToTop as u}from"./chunk-4ES5JGGX.js";import{useEaselKeyTarget as f,useEaselUndoKeys as h,useEaselSaveKey as m,editorRootFocus as g}from"./chunk-4MPCFKFG.js";import{SlotChildActionsProvider as y}from"./chunk-KCBEE2MC.js";import{screenStorageKeys as S,DEFAULT_PANEL_W as k,clampPanelWidth as v}from"./chunk-TZIIRGVY.js";import{usePartBridge as w}from"./chunk-YJQYO6TA.js";import{useSectionOps as b}from"./chunk-PQMCHTVE.js";import{useNodeClipboard as x,useNodeContextMenu as z}from"./chunk-IOZKOGFR.js";import{PageEditGuardNotices as C}from"./chunk-AFSSKGTD.js";import{ScreenSaveIcon as I,ScreenMainButton as B}from"./chunk-W4U4SHKW.js";import{useBrowserOffline as O}from"./chunk-RKTF5XLP.js";import{useScreenDocument as N}from"./chunk-GCCBEY2W.js";import{requestMediaPick as P}from"./chunk-KG7RJWOK.js";import{AddSidePanel as $}from"./chunk-HUI44HA5.js";import{SidePanelHead as M,PanelShowStrip as j}from"./chunk-PPL7GB7D.js";import{useEaselSession as T}from"./chunk-O7Q4DDJT.js";import{MediaSidePanel as A}from"./chunk-3KAQXJVI.js";import{useScreenSaveSwitch as R,useScreenNodeKeys as E,useScreenPinned as L,useScreenDocumentLabel as V,useScreenCanvasFrame as F,useScreenInspectorPanel as H,useScreenDevices as W,useScreenPickFollowsSelection as G,useScreenLeftView as D,SELECTION_MODE as U,sameInspectorMode as J,useScreenBridges as Y,useScreenBlockRules as K,useScreenBlockLook as X,useScreenStorageNamespace as q,useScreenNotify as _,useScreenCanvasHead as Q,isSlotMode as Z,useScreenStyleClipboard as ee,useScreenDocumentPass as ne,useScreenCanvasDrag as te,ScreenCanvasTargetProvider as oe,isPinnedFirst as re,isPinnedLast as ie,screenSlotsOf as le}from"./chunk-OHRS7Q3E.js";import{ROOT_ZONE as se,blockNodeActions as de,TREE_MAX_DEPTH as ce,childSlotsOf as ae,slotFieldsOf as pe,slotChildrenIn as ue,nestsInTree as fe,newNodeId as he}from"./chunk-PLVEGYK6.js";import{useMediaPanel as me,usePanelPick as ge,useCancelPanelPick as ye}from"./chunk-R6WTQWAC.js";import{useEaselHost as Se,useHostEscape as ke}from"./chunk-U3JP4VGF.js";import{DEFAULT_SCREEN_WORDS as ve}from"./chunk-VWXUMVCD.js";import{heldStyle as we,styleShortcut as be}from"./chunk-V7U33NF2.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as xe}from"./chunk-6WY6ZXJG.js";import{useEasel as ze,useEaselApi as Ce,CanvasPassThroughContext as Ie}from"./chunk-I55LUW3C.js";import{TreeRow as Be,Subtree as Oe,LayersTree as Ne,TreeGroupLabel as Pe,TreeRowAction as $e,TreeSeam as Me}from"./chunk-4JSBIW5H.js";import{DEFAULT_TREE_WORDS as je}from"./chunk-K56YDHYQ.js";import{DEFAULT_NODE_MENU_WORDS as Te}from"./chunk-WK3AFPXY.js";import{toItemSelector as Ae,useNodeOps as Re,clickPick as Ee}from"./chunk-ECM5F6JJ.js";import{LayersIcon as Le,MediaIcon as Ve}from"./chunk-4VJATVVR.js";import{EaselTopBar as Fe,TopBarRail as He,TopBarCluster as We,EaselIconButton as Ge,TopBarDivider as De,DeviceSwitch as Ue,InspectorIconButton as Je,PanelResizeHandle as Ye,MAX_PANEL_W as Ke,MIN_PANEL_W as Xe,panelWidthVars as qe}from"./chunk-IE55HNMA.js";import{DEFAULT_NOTICE_WORDS as _e,DEFAULT_CHROME_WORDS as Qe}from"./chunk-Z6PVRXVY.js";import{holderOf as Ze,nameOrSomeone as en}from"./chunk-THWO5YVZ.js";import{DEFAULT_LOCK_WORDS as nn}from"./chunk-RE4LP46F.js";import{useWords as tn}from"./chunk-MFIRYGHW.js";import{insertSeams as on,CanvasDragLayer as rn,CanvasInsert as ln}from"./chunk-47RGVCPH.js";import{DEFAULT_DRAG_WORDS as sn}from"./chunk-GG4FGBFR.js";import{createDragSession as dn,useTreeDrag as cn,gapToMoveIndex as an}from"./chunk-67GNT6PF.js";import{useCanvasFrame as pn,LIST_SELECTOR as un,BLOCK_SELECTOR as fn,useCanvasEvent as hn,nodeIdAt as mn,frameRectToHost as gn,BLOCK_ATTRIBUTE as yn,drawnBox as Sn}from"./chunk-ILXP5VX5.js";import{ROOT_ID as kn,ROOT_SLOT as vn,zoneKey as wn,parseZoneKey as bn,find as xn,DataError as zn}from"./chunk-KRXQM65X.js";import{useRef as Cn,useMemo as In,useState as Bn,useEffect as On,useCallback as Nn,useLayoutEffect as Pn,Fragment as $n}from"react";import{ColoredBadge as Mn,toast as jn,groupColors as Tn}from"efficient-shell/ui";import{UndoIcon as An,RedoIcon as Rn,RefreshIcon as En,AddIcon as Ln,TrashIcon as Vn,EyeOffIcon as Fn,EyeIcon as Hn,DuplicateIcon as Wn}from"efficient-shell/icons/efficient";import{jsx as Gn,jsxs as Dn,Fragment as Un}from"react/jsx-runtime";var Jn=/* @__PURE__ */new WeakSet;function Yn(e,n,t){const o=xn(e,n,t);if(!o)return null;const r=o.path.find(e=>"root"!==e.parentId);return r?r.parentId:t}function Kn({canvas:e,tabs:n,onSelect:t}){const o=Cn(null),[r,i]=Bn({}),l=n.map(e=>`${e.id}:${e.below?1:0}`).join("|");return Pn(()=>{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=gn(l,{left:0,top:0,width:r.innerWidth,height:r.innerHeight},e),c={};for(const o of n){const n=t.querySelector(`[${yn}="${r.CSS?.escape?r.CSS.escape(o.id):o.id}"]`),i=n?Sn(n):null;if(!i||0===i.height){c[o.id]=null;continue}const s=gn(l,{left:i.left,top:i.top,width:i.width,height:i.height},e),a=s.top+s.height;if(a<d.top||s.top>d.top+d.height){c[o.id]=null;continue}const p=o.below?a+4:Math.max(s.top,d.top)+6;c[o.id]={left:Math.max(s.left,d.left)+6,top:p}}i(c)},c=()=>{s||(s=r.requestAnimationFrame(d))};d(),r.addEventListener("scroll",c,!0),r.addEventListener("resize",c);const a=new r.MutationObserver(c);return a.observe(t.body,{childList:!0,subtree:!0,attributes:!0}),()=>{s&&r.cancelAnimationFrame(s),r.removeEventListener("scroll",c,!0),r.removeEventListener("resize",c),a.disconnect()}},[e,l]),/* @__PURE__ */Gn("div",{ref:o,className:"es-band-tabs","aria-hidden":"true",children:n.map(e=>{const n=r[e.id];return n?/* @__PURE__ */Gn("span",{className:"es-band-tab","data-band-tab":e.id,style:{left:n.left,top:n.top},onClick:n=>{n.stopPropagation(),t(e.id)},children:/* @__PURE__ */Gn(Mn,{colorClass:Tn("info","solid"),size:"sm",children:e.label})},e.id):null})})}function Xn({expand:e}){/* @__PURE__ */
|
|
2
|
+
return Gn("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round",children:/* @__PURE__ */Dn(Un,e?{children:[
|
|
3
|
+
/* @__PURE__ */Gn("path",{d:"M8 9l4-4 4 4"}),
|
|
4
|
+
/* @__PURE__ */Gn("path",{d:"M8 15l4 4 4-4"})]}:{children:[
|
|
5
|
+
/* @__PURE__ */Gn("path",{d:"M8 4l4 4 4-4"}),
|
|
6
|
+
/* @__PURE__ */Gn("path",{d:"M8 20l4-4 4 4"}),
|
|
7
|
+
/* @__PURE__ */Gn("path",{d:"M5 12h14"})]})})}var qn=`${un}, ${fn}`;function _n(e,n,t){const o=t-n;if(o<6)return null;if(o<24)return{top:Math.round((n+t)/2),height:Math.round(o)};return{top:Math.round(Math.min(Math.max(e,n+12),t-12))}}var Qn="__rungs";var Zn="screen:band",et={duplicate:!0,delete:!0};function nt(){const un=Se(),{target:gn,docId:yn,capabilities:Sn,currentSlug:Tn,siteId:nt,onPublish:tt,saveState:ot,saveConflict:rt,retrySave:it,toggleAutoSave:lt,flushSave:st,access:dt,saveUnreachable:ct=!1,readOnly:at,readOnlyReason:pt=null}=N(),ut=R(),ft=E(),{mediaEditing:ht,hasEditGuard:mt,hasPinnedChrome:gt}=Sn,{appState:yt,dispatch:St,history:kt,selectedItem:vt,getSelectorForId:wt,config:bt}=ze(e=>e),xt=L(),{first:zt,firstGroup:Ct,lastGroup:It,isSectionGroup:Bt,sectionGroupZone:Ot,panelOf:Nt}=xt,Pt=Nt(zt),$t=e=>re(xt,e),Mt=e=>ie(xt,e),jt="node"===xt.firstRow,Tt=xt.band??null,At=tn("screen",ve),Rt=tn("tree",je),Et=tn("drag",sn),Lt=tn("notice",_e),Vt=tn("lock",nn),Ft=tn("menu",Te),Ht=tn("styleClipboard",xe),Wt=tn("chrome",Qe),Gt=V()??`/${Tn}`,Dt=F(),Ut=H(),Jt=b({readOnly:at}),Yt=b({readOnly:at,foldIntoHistory:!0}),Kt=Cn(null),Xt=Ce(),qt=In(()=>({...Jt,select:e=>{Kt.current=e,Jt.select(e)},commitDocument:(e,n)=>{if(void 0!==n){const t=Xt.config;Kt.current=Ae(e,t,n)}Jt.commitDocument(e,n)}}),[Jt,Xt]),_t=yt.ui,Qt=_t.leftSideBarVisible,Zt=_t.rightSideBarVisible,{options:eo,widths:no,initial:to,fluid:oo,fit:ro}=W(),[io,lo]=Bn(to),so=me(),co=ht&&null!==so,ao=ge(),po=ye();G(vt?.props.id);const{read:uo,write:fo,forSelection:ho}=D(),[mo,go]=Bn(uo);On(()=>{fo(mo)},[mo]);const[yo,So]=Bn(0),ko=Cn(null),vo=Cn(null),wo=pn(vo,{readySelector:qn}),bo=f(vo);h(vo,wo);const xo=O(),zo=Ze(dt),Co={state:ot,offline:xo||ot.failed&&ct,readOnlyReason:pt,editing:zo?Lt.editing({name:en(zo.name,Vt),noun:At.noun}):null,conflict:null!=rt,notSaving:At.bar.notSaving},Io=()=>{at||(ot.failed?it():st())};m(vo,wo,Io);const[Bo,Oo]=Bn(!1),No=Cn(!1),Po=Cn(!1),[$o,Mo]=Bn(null),[jo,To]=Bn([]),[Ao,Ro]=Bn(U),Eo="puck"===Ao.kind,Lo=o(Ao,vt?.props.id),[Vo,Fo]=Bn(null);On(()=>{Vo&&(r(),Fo(null))},[Vo]);const Ho=Cn(wt);Ho.current=wt;const Wo=Nn((e,{scroll:n})=>{go(n=>ho(e,n)),n&&Fo(e);const t=[];let o=e;for(let e=0;e<4;e++){const e=Ho.current(o)?.zone;if(!e||!e.includes(":"))break;const n=e.split(":")[0];t.push(n),t.push(e),o=n}0!==t.length&&Sr(e=>{if(t.every(n=>!e.has(n)))return e;const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},[]),Go=Cn(null);On(()=>{const e=Go.current;Go.current=null;const n=null==vt?.props.id?null:String(vt.props.id);Ro(t=>e&&e.id===n?e.mode:"part"===t.kind&&"nodeId"in t&&t.nodeId===n?t:Nt(vt?.type)??U);const t=vt?.props.id,o=Kt.current;if(Kt.current=null,!t)return;const r=wt(t);Wo(String(t),{scroll:!i(o,r??null,se)})},[vt?.props.id,Wo]);const Do=Nn(e=>{Ro(n=>J(n,e)?n:e),St({type:"setUi",ui:{rightSideBarVisible:!0}})},[St]),Uo=Cn(()=>{});Uo.current=(e,n)=>{const t=e?pi(e.zone??se)[e.index]?.props.id:null,o=null==t?null:String(t),r=null==vt?.props.id?null:String(vt.props.id);Ro(e=>J(e,n)?e:n),o!==r&&(Go.current={id:o,mode:n},qt.select(e))};const Jo=Nn((e,n)=>Uo.current(e,n),[]),Yo={kind:Ao.kind,mode:Ao,open:Do,show:e=>Ro(e),reveal:()=>{Zt||St({type:"setUi",ui:{rightSideBarVisible:!0}})},select:Jo},Ko=Y(Yo,{data:yt.data,selected:vt??null,zoneOf:e=>wt(e)?.zone,readOnly:Boolean(at),select:e=>{Ro(U),qt.select({index:e})},replace:(e,n)=>qt.replaceComponent(se,e,n),scrollTo:e=>Ri(e)},{device:io,refreshes:yo},{setView:go,reveal:()=>{Qt||St({type:"setUi",ui:{leftSideBarVisible:!0}})}}),Xo=Ko.pinnedSource??!1,qo=Ko.resolveLeftView?Ko.resolveLeftView(mo,co):"media"===mo&&co?mo:"sections",_o=K(),{isLockedBlock:Qo,duplicateBlocked:Zo,nestDepth:er,newSectionNode:nr,canAddTo:tr,blockIsOffered:or}=_o,rr=X(),{labelAtLevel:ir,Icon:lr,useProducts:sr}=rr,dr=rr.rowName?(e,n,t)=>rr.rowName(e,n,t):void 0,cr=Nn(e=>{St({type:"setUi",ui:{rightSideBarVisible:!0}}),a(e),Wo(e,{scroll:!0})},[St,Wo]),{selectNode:ar,openPartId:pr}=w({mode:Ao,setMode:Ro,onOpenPart:cr}),[ur,fr]=Bn(null);ke(null!==ur,()=>fr(null));const hr=S(q()),mr=hr.collapsed,gr=hr.panelWidths,[yr,Sr]=Bn(()=>{if("undefined"==typeof window)/* @__PURE__ */return new Set;try{const e=window.localStorage.getItem(mr);return new Set(e?JSON.parse(e):[])}catch{/* @__PURE__ */
|
|
8
|
+
return new Set}});On(()=>{try{window.localStorage.setItem(mr,JSON.stringify([...yr]))}catch{}},[yr]);const[kr,vr]=Bn(()=>{if("undefined"==typeof window)return{...k};try{const e=window.localStorage.getItem(gr);if(!e)return{...k};const n=JSON.parse(e);return{left:v(Number(n.left)||k.left),right:v(Number(n.right)||k.right)}}catch{return{...k}}});On(()=>{const e=setTimeout(()=>{try{window.localStorage.setItem(gr,JSON.stringify(kr))}catch{}},300);return()=>clearTimeout(e)},[kr]);const wr=Nn((e,n)=>vr(t=>{const o="function"==typeof n?n(t[e]):n;return t[e]===o?t:{...t,[e]:o}}),[]),br=Nn(e=>wr("left",e),[wr]),xr=Nn(e=>wr("right",e),[wr]),zr=e=>yr.has(e),Cr=e=>Sr(n=>{const t=new Set(n);return t.has(e)?t.delete(e):t.add(e),t}),Ir=Cn(!1),Br=Cn(null);On(()=>{if(Ir.current&&!Bo){const e=Br.current,n=e&&e.isConnected&&!e.closest('[aria-hidden="true"]')?e:null;(n??vo.current?.querySelector(`button[aria-label="${CSS.escape(At.add.title)}"]`))?.focus(),Br.current=null}Ir.current=Bo},[Bo]),On(()=>{if(!Bo||!bo)return;const e=e=>{"Escape"===e.key&&Di()};return bo.addEventListener("keydown",e),()=>bo.removeEventListener("keydown",e)},[Bo,bo]),ke(Bo,()=>Di()),On(()=>{!Qt&&Bo&&(Oo(!1),Mo(null),No.current=!1)},[Qt]),On(()=>{if(!ao)return Po.current&&St({type:"setUi",ui:{leftSideBarVisible:!1}}),void(Po.current=!1);Bo&&(Oo(!1),Mo(null),Po.current=No.current,No.current=!1),Qt||(Po.current=!0,St({type:"setUi",ui:{leftSideBarVisible:!0}}))},[ao]),On(()=>{!Qt&&ao&&(Po.current=!1,po())},[Qt]),On(()=>{if(!ao||!bo)return;const e=e=>{"Escape"===e.key&&po()};return bo.addEventListener("keydown",e),()=>bo.removeEventListener("keydown",e)},[ao,bo]),ke(null!==ao,()=>po());const Or=_(),Nr=(e,n="success",t)=>{if(Or)return void(t?Or(e,"error"===n?"error":"info",t):Or(e,"error"===n?"error":"info"));const o={sound:!1,action:t?.action,onClose:t?.onClose};"error"===n?jn.error(e,{...o,duration:t?.duration??3200}):jn.success(e,{...o,duration:t?.duration??1900})},Pr=Cn(null),[$r,Mr]=Bn(0),[jr,Tr]=Bn(0),Ar=Q(),Rr=Cn(null),Er=e=>Math.max(0,e.clientHeight-(Rr.current?.offsetHeight??0));On(()=>{const e=Pr.current;if(!e)return;const n=()=>{Mr(e.clientWidth),Tr(Er(e))};n();const t=new ResizeObserver(n);return t.observe(e),Rr.current&&t.observe(Rr.current),()=>t.disconnect()},[]),Pn(()=>{Pr.current&&(Mr(Pr.current.clientWidth),Tr(Er(Pr.current)))},[kr,Qt,Zt]);const Lr=io===oo?$r>0?$r:no[oo]:no[io],Vr=$r>0?Math.min($r/Lr,"shrink"===ro?1:2):1,Fr=Lr*Vr,Hr=$r>0&&Fr>$r+1,Wr={width:Fr,height:jr||"100%",flex:"none",position:"relative"},Gr={width:Lr,height:jr?jr/Vr:"100%",maxHeight:"none",transform:1!==Vr?`scale(${Vr})`:void 0,transformOrigin:"top left"},Dr=()=>St({type:"setUi",ui:{leftSideBarVisible:!Qt}}),Ur=()=>St({type:"setUi",ui:{rightSideBarVisible:!Zt}}),Jr=e=>{Bo&&(Oo(!1),Mo(null),No.current=!1,Qt&&mo===e)||ao&&(Po.current=!1,po(),Qt&&mo===e)||(Qt&&mo===e?Dr():(go(e),Qt||St({type:"setUi",ui:{leftSideBarVisible:!0}})))},Yr=()=>{P(un,{accept:"image/*",title:Wt.mediaLibrary})},Kr=()=>{Ro(U),qt.select(null),u()},Xr=()=>{Ro(Pt??U),Zt||St({type:"setUi",ui:{rightSideBarVisible:!0}})},qr=yt.data.content??[],_r=()=>{const e=qr.findIndex($t),n=qr.findIndex(Mt);return{floor:e>=0?e+1:0,cap:n>=0?n:qr.length}},Qr=bt,Zr=_o.stripCopy,ei=n=>e(n,Zr),ni=x(),ti=Re({data:yt.data,config:Qr,readOnly:Boolean(at),clipboard:ni,strip:Zr?e=>Zr(e):void 0,afterRemove:"none",stepBounds:(e,n)=>{if(e.parentId!==kn||e.slot!==vn)return{min:0,max:n-1};const{floor:t,cap:o}=_r();return{min:t,max:o-1}},commit:(e,{select:n})=>{void 0!==n&&Ro(U);const t=void 0===n||"node"===n?.kind?n:null;qt.commitDocument(e,t)}}),oi=e=>{const n=xn(yt.data,bt,e);if(!n)return!1;const t=wn(n.place),o=n.node,r=t===se?di(o):bi(o);return!!ti.remove(e)&&(Nr(At.deleted({name:r}),"success",{duration:8e3,action:{label:At.bar.undo,onClick:()=>{ti.restore(n.node,n.place)}}}),!0)},ri={...ti,remove:oi},ii=e=>ir(e,"block",bt.components[e]?.label??e),li=Nn(e=>bt.components[e]?.defaultProps??{},[bt]),si=e=>ir(e,"section",ii(e)),di=e=>l({type:e.type,props:e.props??{}},si(e.type),dr),{nodeAddresses:ci,zoneItems:ai}=In(()=>{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>=ce)return;const s=/* @__PURE__ */new Map;for(const{child:e,zone:t}of ae(bt,n))s.set(t,[...s.get(t)??[],e]);for(const[e,n]of s)t(n,e,i+1)})};return t(qr,se,0),{nodeAddresses:e,zoneItems:n}},[qr,bt]),pi=Nn(e=>ai.get(e)??[],[ai]),ui=e=>{const n=ci.get(e);return n?pi(n.zone)[n.index]:void 0},fi=e=>le(_o,bt,e),hi=e=>{if(!_o.slotsOf||e===se)return null;const n=e.lastIndexOf(":");if(n<=0)return null;const t=ui(e.slice(0,n));if(!t)return null;const o=fi(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}},mi=(()=>{if(!Z(Ao))return null;const e=`${Ao.nodeId}:${Ao.slot}`;return hi(e)?.slot.panel===Ao.kind?e:null})(),gi=Cn(null);On(()=>{const e=gi.current;if(gi.current=null,!mi||!Z(Ao))return;const n=Ao.nodeId;Wo(n,{scroll:e!==mi}),Sr(e=>{if(!e.has(n))return e;const t=new Set(e);return t.delete(n),t})},[Ao]);const yi=(e,n,t)=>{const o=String(e.props.id);if(!n.panel)return void(e=>{const n=ci.get(e);n&&(n.zone===se?Ei(n.index):pl(n.zone,n.index,e,ui(n.zone.slice(0,n.zone.lastIndexOf(":")))?.type??""))})(o);const r={kind:n.panel,nodeId:o,slot:n.slot},i=`${o}:${n.slot}`;t&&mi!==i&&(gi.current=i),Jo(null,r),Zt||St({type:"setUi",ui:{rightSideBarVisible:!0}}),Ri(o)},Si=(e,n,t)=>{const o=`${e}:${n}`;if(Sr(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;mi!==o&&(gi.current=o);Jo(null,{kind:t,nodeId:e,slot:n})},ki=(e,n,t)=>{if(at||!_o.moveSlot)return;const o=ui(e),r=o?fi(o).filter(e=>e.rung):[],i=r[n];if(!i)return;const l={parentId:e,slot:Qn,index:n},s=an(l,{...l,index:Math.min(Math.max(t,0),r.length)});if(s===n)return;const d=_o.moveSlot(e,n,s);"string"==typeof d&&Si(e,d,i.panel)},vi=sr(),wi=In(()=>{const e=/* @__PURE__ */new Map;for(const n of vi??[])e.set(n.slug,n.name);return e},[vi]),bi=e=>s(e,ii,rr.plainText,e=>wi.get(e),rr.rowName),xi=(e,n)=>{const t=bt.components[e.type]?.fields,o=n===se||Ml(n)?"section":"block",r=n===se&&($t(e)||Mt(e)||Bt(e.type)),i="block"===o?d(t):r?null:c(t);return rr.renamePropOf?rr.renamePropOf(e,o,i):i},zi=(e,n,t,o)=>{if(!(!at&&ur?.zone===e&&ur.index===n))return;const r=(t,o)=>{fr(null),o&&((e,n,t)=>{const o=pi(e)[n];if(!o)return;const r=xi(o,e);r&&qt.replaceComponent(e,n,{...o,props:{...o.props,[r]:t.trim()}})})(e,n,t)};/* @__PURE__ */
|
|
9
|
+
return Gn("input",{className:"es-tree-rename",defaultValue:o,autoFocus:!0,"aria-label":At.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)},Ci=t(ee(),Ht),Ii=Ci.scope({target:gn,siteId:nt,docId:yn}),Bi=bt,Oi=(e,n)=>n===se?si(e):ii(e),Ni=(e,n,t)=>{const o=Ci.plan(Ii,t,Oi(t.type,e),Bi);o&&(o.changed&&qt.replaceComponent(e,n,{...t,props:{...o.props,id:t.props.id}}),Nr(o.message))},Pi=z({nodesIn:pi,nodeAt:(e,n)=>pi(e)[n]??null,labelOf:(e,n)=>n===se?si(e):ii(e),renamePropOf:xi,beginRename:(e,n)=>fr({zone:e,index:n}),history:{hasPast:kt.hasPast,hasFuture:kt.hasFuture,back:()=>kt.back(),forward:()=>kt.forward()},openPageSettings:()=>{qt.select(null),Ro(U)},pageSettingsLabel:At.pageSettings,words:{menu:Ft,styleClipboard:Ht,screen:At.menu},readOnly:Boolean(at),collapseAll:()=>Sr(new Set(pi(se).map(e=>String(e.props.id)))),onPasteRefused:e=>Nr(e?At.pasteRefused({name:e.label}):At.menu.clipboardRefused,"error"),canPasteAt:(e,n)=>Al(e,n),menuRows:Ko.menuRows,isLocked:e=>Qo(e.type),duplicateBlocked:e=>Zo(yt.data,e),permits:e=>de(bt,e.type),nodeOps:ri,isPinned:(e,n)=>n===se&&($t(e)||Mt(e)),sectionBand:_r,locate:e=>ci.get(e)??null,rowNameOf:(e,n)=>n===se?di(e):bi(e),selectAt:(e,n,t,o)=>{e===se?Ei(n):pl(e,n,t,o??"")},slotRung:e=>{const n=hi(e);return n?.slot.panel?{label:n.slot.label,select:()=>yi(n.node,n.slot,!1)}:null},style:{held:()=>we(Ii),canCopy:e=>Ci.rows(Bi,e).some(e=>!1!==e.counted),copy:(e,n)=>Ci.copy(Ii,e,Oi(e.type,n),Bi),paste:(e,n,t)=>Ni(e,n,t)},keys:ft?{target:bo,selected:()=>{const e=yt.ui.itemSelector;return e?{zone:e.zone??se,index:e.index}:null},held:()=>ni.get(),readOnly:Boolean(at),onDone:({done:e,name:n})=>{"copied"===e&&Nr(At.copied({name:n}))}}:void 0},wo),$i=Cn({copy:(e,n)=>{},paste:(e,n,t)=>{},at:()=>null,readOnly:!1});On(()=>{$i.current={copy:(e,n)=>Ci.copy(Ii,e,Oi(e.type,n),Bi),paste:Ni,at:()=>{const e=yt.ui.itemSelector;if(!e)return null;const n=e.zone??se,t=pi(n)[e.index];return t?{zone:n,index:e.index,node:t}:null},readOnly:Boolean(at)}});const Mi=Nn(e=>{const n=be(e);if(!n)return;const t=$i.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))},[]);On(()=>{if(!bo)return;const e=e=>Mi(e);return bo.addEventListener("keydown",e),()=>bo.removeEventListener("keydown",e)},[Mi,bo]),hn(wo,"keydown",Mi);const ji=qr.map(e=>e.props.id).join("|");On(()=>{const e=wo?.document??null,n=wo?.window??null;let t=0;const o=[],r=()=>{if(!e)return void To(e=>e.length?[]:e);const n=qr.findIndex(Mt),t=n>=0?n:qr.length,o=n=>{const t=qr[n]?.props?.id;return null==t?null:e.querySelector(`[data-puck-component="${CSS.escape(String(t))}"]`)},r=e=>e?[...e.querySelectorAll(fn)].map(e=>e.getBoundingClientRect()).filter(e=>e.width>0||e.height>0):[],i=[];for(let e=qr.length>0&&!$t(qr[0])?0:1;e<=t;e++){const n=o(e),t=o(e-1),l=n?.getBoundingClientRect()??null,s=t?.getBoundingClientRect()??null;if(!l&&!s)continue;const d=_n(l&&s?(s.bottom+l.top)/2:l?0===e?l.top+12:l.top:s.bottom,Math.max(0===e?0:-1/0,...r(t).map(e=>e.bottom)),Math.min(1/0,...r(n).map(e=>e.top)));d&&i.push({...d,index:e})}To(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,ji,io,Vr,Qt,Zt,vt?.props.id]);const Ti=wo?.document??null,Ai=wo?.window??null;On(()=>{const e=ko.current;if(!e||!Ti||!Ai)return;const n=[],t=()=>{const n=Ti.querySelector(`[data-puck-component="${CSS.escape(e.id)}"]`);if(!n)return!1;const t=n.getBoundingClientRect().top-e.offset;return Math.abs(t)>1&&Ai.scrollTo({left:Ai.scrollX,top:Ai.scrollY+t,behavior:"instant"}),!0};return ko.current=null,t()&&n.push(setTimeout(t,150),setTimeout(t,450)),()=>n.forEach(clearTimeout)},[Ti,Ai]);const Ri=e=>{Ko.holdCanvasOn?Ko.holdCanvasOn(e):a(e)},Ei=e=>{Ro(U),qt.select({index:e}),Ko.sectionPressed?.(qr[e]);const n=qr[e]?.props?.id;n&&Ri(n)},Li=e=>{const{floor:n,cap:t}=_r(),o=e=>Math.min(Math.max(n,e),t);if("number"==typeof e)return o(e);const r=vt&&Ao.kind!==Pt?.kind?qr.findIndex(e=>e.props.id===vt.props.id):-1;return o(r>=0?r+1:t)},Vi=(e,n)=>{const{floor:t,cap:o}=_r(),r=Math.min(Math.max(n,t),o),i=e<r?r-1:r;return i===e?{moved:!1,dest:e}:(qt.reorderComponent(se,e,i),qt.select({index:i}),{moved:!0,dest:i})},Fi=(e,n,t,o)=>{Ro(U),qt.select(o?{index:o.index,zone:o.zone}:{index:e}),a(n),Nr(At.sectionAdded({name:t}))},Hi=(e,n)=>{const t=Li(n),o=nr(e,{nodeDefaults:li,newNodeId:he,sectionLabel:si,blockIsOffered:or}),r=o?qt.insertNode(se,t,o):qt.insertSection(e,t);return Fi(t,r,si(e),o?((e,n,t)=>{if(e.type===t)return null;const o={at:null},r=(e,n,i)=>{const l=i.filter(n=>n===e.type).length;for(const{child:s,zone:d,index:c}of ae(bt,e)){if(s.type===t&&(!o.at||n>o.at.depth)){const r=tr(e.type,l,d.slice(d.lastIndexOf(":")+1)),i=r?.choices??(r?.spec?[{type:r.spec.childType,label:r.spec.childType}]:[]);null!==r&&"footer"!==r.source&&`${e.props.id}:${r.slot}`===d&&i.some(e=>e.type===t)&&(o.at={zone:d,index:c,depth:n})}r(s,n+1,[...i,e.type])}};return r({type:e.type,props:{...e.props,id:n}},1,[]),o.at?{zone:o.at.zone,index:o.at.index}:null})(o,r,e):null),t},Wi=e=>Gi(se,e),Gi=(e,n)=>{Br.current=document.activeElement??null,ao&&(No.current=Po.current,Po.current=!1,po()),Mo(null===n?null:{zone:e,index:n}),Oo(!0),Qt||(No.current=!0,St({type:"setUi",ui:{leftSideBarVisible:!0}}))},Di=()=>{Oo(!1),Mo(null),No.current&&St({type:"setUi",ui:{leftSideBarVisible:!1}}),No.current=!1},Ui=(e,n)=>rr.rowName?n?$t(e)?rr.rowName(e,"section",At.header):Mt(e)?rr.rowName(e,"section",At.footer):Bt(e.type)?rr.rowName(e,"section",ii(e.type)):di(e):bi(e):n?si(e.type):ii(e.type),Ji=e=>n=>{e()},Yi=()=>Ko.editPinnedSource?.(),Ki=(e,n,t)=>{if(at)return null;const o=pi(e)[n];return o&&!de(bt,o.type).delete?null:/* @__PURE__ */Gn($e,{kind:"delete",label:At.deleteNamed({name:t}),onClick:()=>((e,n)=>{const t=pi(e)[n]?.props?.id;null!=t&&oi(String(t))})(e,n),children:/* @__PURE__ */Gn(Vn,{size:15})})},Xi=e=>rr.rowPreview?.(e)||void 0,qi=e=>rr.rowMarks?.(e)??void 0,_i=(e,n,t)=>rr.rowActions?.(e,n,t)??null,Qi=(e,n,t,o)=>{if(at)return null;const r=Boolean(t.props._hidden);/* @__PURE__ */
|
|
10
|
+
return Gn($e,{kind:"eye",label:r?At.showNamed({name:o}):At.hideNamed({name:o}),onClick:()=>el(e,n,t),children:/* @__PURE__ */Gn(r?Fn:Hn,{size:14,strokeWidth:1.8,strokeLinecap:void 0,strokeLinejoin:void 0})})},Zi=e=>ps(se,e),el=(e,n,t)=>{qt.replaceComponent(e,n,{...t,props:{...t.props,_hidden:!t.props._hidden}})},nl=e=>pe(bt,e),tl=e=>ae(bt,e),ol=e=>_o.slotsOf?fi(e).map(n=>({slot:n.slot,rung:n.rung?n:null,kids:ue(e,n.slot)})):[{slot:null,rung:null,kids:tl(e)}],rl=e=>_o.slotsOf?ol(e).flatMap(e=>e.kids):tl(e),il=e=>Boolean(_o.slotsOf)&&fi(e).some(e=>e.rung),ll=(e,n,t)=>null===t?void 0===n?tr(e):tr(e,n):tr(e,n,t),sl=(e,n,t)=>{const o=fe(bt,e.type,n)&&(t||rl(e).length>0||il(e));return{collapsible:o,folded:o&&zr(String(e.props.id))}},dl=(e,n,t)=>ol(e).flatMap(o=>{const r=o.rung?n+1:n,i=o.kids.flatMap(({child:e})=>sl(e,r,t(e.type)).collapsible?[String(e.props.id),...dl(e,r+1,t)]:[]);return o.rung?[`${e.props.id}:${o.rung.slot}`,...i]:i}),cl=e=>rl(e).length>0||il(e)||Boolean(tr(e.type)),al=e=>Boolean(tr(e)),pl=(e,n,t,o)=>{if(Ro(U),tr(o)?.spec?.slider){const t=e.split(":")[0];p(t,n),qt.select({index:n,zone:e}),a(t)}else qt.select({index:n,zone:e}),Ri(t)},ul=(e,n,t,o,r)=>{const i=`${e}:${n}`;qt.insertComponent(i,t,o),tr(r)?.spec?.slider?requestAnimationFrame(()=>{p(e,o),qt.select({index:o,zone:i})}):qt.select({index:o,zone:i})},fl=Cn(/* @__PURE__ */new Set);On(()=>{qr.forEach(e=>{const n=tr(e.type)?.spec;if(!n)return;const t=e.props.id;if(fl.current.has(t))return;fl.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(li)).forEach((e,t)=>Yt.seedChild(o,t,n.childType,e))})},[qr,Yt,li]);const hl=Cn(/* @__PURE__ */new Set);On(()=>{qr.forEach((e,t)=>{const o=e.props.id;if(hl.current.has(o))return;const r=n(e,nl(e.type));hl.current.add(o),r&&Yt.replaceComponent(se,t,{...e,props:r})})},[qr,Yt]),ne(Yt,bt);const ml=qr.findIndex(Mt),gl=ml>=0?qr[ml]:null,yl=jt?qr.findIndex($t):-1,Sl=yl>=0?qr[yl]:null,kl=xt.groupTab,vl=In(()=>kl?e=>Bt(e.type):void 0,[kl]),wl=Boolean(xt.groupBadge),bl=xt.groupBadge?/* @__PURE__ */Gn("span",{className:"es-tree-group-badge",children:/* @__PURE__ */Gn(Mn,{tone:"info",size:"xs",children:xt.groupBadge})}):void 0,xl=qr.find(e=>e.type===Ct)??null,zl=qr.find(e=>e.type===It)??null,Cl=ml>=0?ml:qr.length,Il=[];qr.forEach(e=>{Mt(e)||(cl(e)&&Il.push(String(e.props.id)),Il.push(...dl(e,1,al)))}),gl&&(Il.push(String(gl.props.id)),Il.push(...dl(gl,1,al)));const Bl=Il.length>0&&Il.every(e=>yr.has(e)),Ol=e=>{const n=rr.blockRowName(e,ii);return rr.rowName?rr.rowName(e,"block",n):n},Nl=(e,n,t,o)=>{const r=pi(e)[t];if(!r)return;const i={...bn(e),index:t},l={...bn(n),index:Math.min(Math.max(o,0),pi(n).length)},s=an(i,l);if(e!==n||s!==t)try{ti.move(String(r.props.id),{...l,index:s})}catch(e){if(!(e instanceof zn))throw e}},Pl=e=>{const n=/* @__PURE__ */new Set,t=e=>{for(const{child:o,zone:r}of tl(e))n.add(r),t(o)};for(const t of nl(e.type))n.add(`${e.props.id}:${t}`);return t(e),n},$l=e=>{let n=e.slice(0,e.indexOf(":"));for(let e=0;e<64;e++){const e=ci.get(n);if(!e)return null;if(e.zone===se)return n;n=e.zone.slice(0,e.zone.indexOf(":"))}return null},Ml=e=>{const n=e.slice(0,e.indexOf(":")),t=qr.find(e=>Bt(e.type)&&String(e.props.id)===n);return t&&Ot(n)===e?t:null},jl=(e,n)=>{const t=Ml(e);return!t||(!xt.groupAccepts||xt.groupAccepts(t.type,n,pi(e).length))},Tl=(e,n,t)=>{if(e.rung){const t=ui(e.rung.nodeId),o=t?fi(t).filter(e=>e.rung).length:0;return n.parentId===e.rung.nodeId&&n.slot===Qn&&n.index>=0&&n.index<=o}if(n.slot===Qn)return!1;if(e.add)return El(e.add,n);const o=wn(n);if(Bt(e.type))return!1;const r=Ml(o),i=Ml(e.zone);if(r||i)return!(!r||!i)&&(!(r!==i&&!jl(o,e.type))&&(n.index>=0&&n.index<=pi(o).length));if(e.zone===se||o===se){if(e.zone!==o)return!1;const{floor:t,cap:r}=_r();return n.index>=t&&n.index<=r}if(n.index<0||n.index>pi(o).length)return!1;if(e.zone===o)return!0;const l=gl&&!xt.lastIsOpen?String(gl.props.id):null;return(!l||$l(e.zone)!==l&&$l(o)!==l)&&((e,n,t,o)=>{if(e===n)return!0;const r=o??pi(e)[t];if(!r)return!1;const i=n.split(":")[0],l=ci.get(i),s=l?pi(l.zone)[l.index]:void 0;if(!s)return!1;if(!o&&Pl(r).has(n))return!1;const d=tr(s.type,er(yt?.data,s.type,i),n.slice(n.lastIndexOf(":")+1));return!!d&&(!!(d.choices?d.choices.some(e=>e.type===r.type):d.spec?.childType===r.type)&&!d.spec?.addBlocked?.(pi(n),r))})(e.zone,o,e.index,t)},Al=(e,n)=>{const t=wn(e.from),o=e.node;return t===wn(n)?jl(t,o.type):Tl({id:String(o.props?.id??""),zone:t,index:-1,type:o.type},n,o)},Rl=e=>{const n=e.slice(0,e.indexOf(":")),t=ci.get(n),o=t?pi(t.zone)[t.index]:void 0;if(!t||!o)return null;const r=tr(o.type,er(yt?.data,o.type,n),e.slice(e.lastIndexOf(":")+1));if(!r||`${n}:${r.slot}`!==e)return null;if("footer"===r.source)return null;const i=r.choices??(r.spec?[{type:r.spec.childType,label:ii(r.spec.childType)}]:[]),l=hi(e);return{parent:o,parentId:n,target:r,choices:i,parentName:l?l.slot.label:Ui(o,t.zone===se)}},El=(e,n)=>{const t=wn(n);if("block"!==e.kind){if(Ml(t)){const o="section"===e.kind?e.type:e.template.node.type;return jl(t,o)&&n.index>=0&&n.index<=pi(t).length}if(t!==se)return!1;const{floor:o,cap:r}=_r();return n.index>=o&&n.index<=r}if(t===se)return!1;const o=Rl(t);return!(!o||!o.choices.some(n=>n.type===e.type))&&!o.target.spec?.addBlocked?.(pi(t))},Ll=(e,n)=>{if("block"!==e.kind&&Ml(wn(n)))return void((e,n,t)=>{const o="section"===e.kind?e.type:"template"===e.kind?e.template.node.type:null;if(o&&jl(n,o)){if("section"===e.kind)qt.insertComponent(n,e.type,t);else{if("template"!==e.kind)return;qt.insertNode(n,t,ei(e.template.node))}Ro(U),qt.select({index:t,zone:n})}})(e,wn(n),n.index);if("section"===e.kind)return void Hi(e.type,n.index);if("template"===e.kind)return void((e,n,t)=>{const o=Li(t),r=qt.insertNode(se,o,n);Fi(o,r,e)})(e.template.name,ei(e.template.node),n.index);const t=wn(n),o=Rl(t);o&&(o.target.spec?ul(o.parentId,o.target.slot,e.type,n.index,o.parent.type):((e,n,t)=>{qt.insertComponent(e,n,t),Ro(U),qt.select({index:t,zone:e})})(t,e.type,n.index))},Vl=(e,n)=>{e.rung?ki(e.rung.nodeId,e.index,n.index):e.add?Ll(e.add,n):e.zone===se?Vi(e.index,n.index):Nl(e.zone,wn(n),e.index,n.index)},[Fl]=Bn(()=>dn()),Hl=cn({keyOf:e=>e.id,readOnly:Boolean(at),session:Fl,canDrop:Tl,onDrop:Vl,onStep:(e,n)=>{e.rung?ki(e.rung.nodeId,e.index,n<0?e.index-1:e.index+2):e.zone===se?((e,n)=>{const t=si(qr[e]?.type??""),o=Vi(e,n<0?e-1:e+2);if(!o.moved)return void Nr(n<0?At.sectionFirst({name:t}):At.sectionLast({name:t}));const{floor:r,cap:i}=_r();Nr(At.sectionMoved({name:t,n:o.dest-r+1,total:i-r}))})(e.index,n):Nl(e.zone,e.zone,e.index,n<0?e.index-1:e.index+2)}}),Wl=Nn(e=>{const{floor:n,cap:t}=_r(),o=[];for(const r of e.nodes){const e=wn(r.place),i=pi(e)[r.place.index];if(!i||String(i.props.id)!==r.id)continue;if($t(i)||Mt(i)||Qo(i.type))continue;if(Bt(i.type))continue;const l=Boolean(Ml(e)),s=e===se||l;e===se&&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?si(i.type):bi(i),from:r.place})}const r=e.zones.flatMap(e=>{const n=wn(e.list);return n===se&&0===e.children.length?[{...e,addLabel:At.addSection,addAlways:!0}]:e.children.length>0||Boolean(Rl(n)?.choices.length)||Boolean(Ml(n))?[e]:[]}),i=r.flatMap(e=>{const n=wn(e.list);return n===se||Ml(n)||!Rl(n)?.choices.length?[]:on(e,At.addBlockHere)});return{sources:o,zones:r,seams:i}},[yt.data]),Gl=null==vt?.props.id?null:String(vt.props.id),Dl=Nn(e=>{const n=bt,t=e=>!e.item.rung&&null!==xn(yt.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(Gl);return i||(r(Ee(yt.data,n,o.item.id,Gl,vl))??o)},[yt.data,bt,Gl,vl]),[Ul,Jl]=Bn(null);hn(wo,"mouseover",e=>{if(!kl)return;const n=mn(e.target),t=n?Yn(yt.data,bt,n):null;t!==Ul&&Jl(t)}),hn(wo,"mouseout",e=>{kl&&!e.relatedTarget&&Jl(null)});const Yl=e=>$t(e)||Mt(e)||Bt(e.type),Kl=[];if(kl){const e=Gl?Yn(yt.data,bt,Gl):null;for(const n of/* @__PURE__ */new Set([e,Ul])){const e=n?qr.find(e=>String(e.props.id)===n):void 0;if(!e||!Yl(e))continue;const t=kl(e);t&&Kl.push({id:String(e.props.id),label:t,below:$t(e)||e.type===Ct})}}const Xl=T(),ql=Cn(null);On(()=>{const e=xt.changeNotice;if(!e)return;const n=JSON.stringify(qr.filter(Yl)),t=ql.current;if(ql.current={doc:yn,bands:n,index:kt.index},!t||t.doc!==yn||t.bands===n)return;kt.hasPast&&kt.index>=t.index&&!Jn.has(Xl)&&(Jn.add(Xl),Nr(e,"success",{action:{label:At.bar.undo,onClick:()=>kt.back()},duration:8e3}))},[qr]);const _l=e=>{Ro(U),qt.select(e.zone===se?{index:e.index}:{index:e.index,zone:e.zone})},Ql=te(),Zl=()=>({data:yt.data,device:io,ops:qt,inspector:Yo}),es=Ql?.model,ns=In(()=>es?e=>es(e,Wl(e),Zl()):Wl,[es,Wl,io]),ts=Ql?.measure,os=ts?(e,n)=>ts(e,n,Zl()):void 0,rs=Ql?.canDrop,is=rs?(e,n)=>rs(e,n,Tl,Zl()):Tl,ls=Ql?.drop,ss=ls?(e,n)=>ls(e,n,Vl,Zl()):Vl,ds=Ql?.pick,cs=ds?e=>ds(e,_l,Zl()):_l,as=e=>{const n=wn(e),t=hi(n);t&&yi(t.node,t.slot,!1),Gi(n,e.index)},ps=(e,n)=>/* @__PURE__ */Gn(Me,{...at?{}:Hl.seam({place:{...bn(e),index:n}})},`seam:${e}:${n}`),us={rowClick:Ji,isCollapsed:zr,toggleCollapse:Cr},fs=e=>{const n=String(e.props.id),t=qr.findIndex(e=>String(e.props.id)===n),o=Ot(n),r=pi(o),i=zr(n),l=ii(e.type),s=rr.rowName?rr.rowName(e,"section",l):l,d=e=>ps(o,e);/* @__PURE__ */
|
|
11
|
+
return Dn(Un,{children:[
|
|
12
|
+
/* @__PURE__ */Gn(Be,{words:Rt,icon:/* @__PURE__ */Gn(lr,{type:e.type,size:13}),name:s,preview:Xi(e),marks:qi(e),onSelect:()=>Ei(t),nameSlot:zi(se,t,n,s),selected:Lo===n,badge:bl,actions:_i(e,se,t)??void 0,rowProps:{"data-node-id":n,onClick:Ji(()=>Ei(t))},fold:{open:!i,label:"section",onToggle:()=>Cr(n)}}),!i&&/* @__PURE__ */Dn(Oe,{children:[r.map((n,t)=>{const r=String(n.props.id),i=di(n),l=cl(n),s=l&&zr(r),c=()=>pl(o,t,r,e.type),{rowProps:a,...p}=Hl.row({item:{id:r,zone:o,index:t,type:n.type},place:{...bn(o),index:t}},{"data-node-id":r,onClick:Ji(c)});/* @__PURE__ */
|
|
13
|
+
return Dn($n,{children:[d(t),
|
|
14
|
+
/* @__PURE__ */Gn(Be,{words:Rt,icon:/* @__PURE__ */Gn(lr,{type:n.type,size:13}),name:i,preview:Xi(n),marks:qi(n),onSelect:c,nameSlot:zi(o,t,r,i),selected:Lo===r,hidden:Boolean(n.props._hidden),...p,fold:l?{open:!s,label:"section",onToggle:()=>Cr(r)}:void 0,actions:/* @__PURE__ */Dn(Un,{children:[Ki(o,t,i),_i(n,o,t),Qi(o,t,n,i)]}),rowProps:a}),l&&!s&&/* @__PURE__ */Gn(Oe,{children:gs(n,2)})]},r)}),d(r.length)]})]})},hs=(e,n,t,o,r)=>{const i=String(e.props.id),l=`${i}:${n.slot}`,s=Hl.dragging,d=!zr(l)&&s?.rung?.nodeId!==i,c={...bn(l),index:0},a=s&&!s.rung&&Tl(s,c)?c:void 0,p=()=>yi(e,n,!0),{rowProps:u,...f}=Hl.row({item:{id:`rung:${l}`,zone:`${i}:${Qn}`,index:t,type:e.type,rung:{nodeId:i,slot:n.slot}},place:{parentId:i,slot:Qn,index:t},into:a,canDrag:Boolean(_o.moveSlot)&&!1!==n.movable&&o>1},{"data-slot-zone":l,onClick:Ji(p)}),h=at?null:_o.slotActions?.(e,n.slot);/* @__PURE__ */
|
|
15
|
+
return Dn($n,{children:[n.heading,
|
|
16
|
+
/* @__PURE__ */Gn(Be,{words:Rt,icon:n.glyph??null,name:n.label,badge:n.badge,onSelect:p,selected:mi===l,...f,dragHint:n.dragHint,fold:{open:d,label:n.label,onToggle:()=>Cr(l)},actions:h&&h.length>0?/* @__PURE__ */Gn(Un,{children:h.map((t,o)=>/* @__PURE__ */Gn($e,{kind:"delete"===t.kind?"delete":"plain",label:t.label,disabled:t.disabled,onClick:()=>((e,n,t)=>{if(at||t.disabled)return;const o=String(e.props.id),r=e=>{"string"==typeof e&&Si(o,e,n.panel)},i=t.run();i&&"function"==typeof i.then?i.then(r):r(i)})(e,n,t),children:"delete"===t.kind?/* @__PURE__ */Gn(Vn,{size:15}):/* @__PURE__ */Gn(Wn,{size:15})},`${o}:${t.kind}`))}):void 0,rowProps:u}),d&&/* @__PURE__ */Gn(Oe,{children:r})]},l)},ms=(e,n)=>{const t=ol(e),o=t.filter(e=>e.rung).length;let r=0;/* @__PURE__ */
|
|
17
|
+
return Gn(Un,{children:t.map(t=>{const i=t.kids,l=t.rung?n+1:n,s=ll(e.type,void 0,t.slot),d=s?`${e.props.id}:${s.slot}`:null,c=null===t.slot?null:`${e.props.id}:${t.slot}`,a=(e,n)=>ps(e,n),p=/* @__PURE__ */Dn(Un,{children:[i.map(({child:n,zone:t,index:o})=>{const r=Lo===String(n.props.id),{collapsible:i,folded:s}=sl(n,l,al(n.type)),d=String(n.props.id),c=Ol(n),p=()=>pl(t,o,d,e.type),{rowProps:u,...f}=Hl.row({item:{id:d,zone:t,index:o,type:n.type},place:{...bn(t),index:o}},{"data-node-id":d,onClick:Ji(p)});/* @__PURE__ */
|
|
18
|
+
return Dn($n,{children:[0===o&&a(t,0),
|
|
19
|
+
/* @__PURE__ */Gn(Be,{words:Rt,icon:/* @__PURE__ */Gn(lr,{type:n.type,size:13}),name:c,preview:Xi(n),marks:qi(n),onSelect:p,nameSlot:zi(t,o,d,c),selected:r,hidden:Boolean(n.props._hidden),...f,fold:i?{open:!s,label:"group",onToggle:()=>Cr(d)}:void 0,actions:/* @__PURE__ */Dn(Un,{children:[Ki(t,o,c),_i(n,t,o),Qi(t,o,n,c)]}),rowProps:u}),i&&!s&&/* @__PURE__ */Gn(Oe,{children:ms(n,l+1)}),a(t,o+1)]},String(n.props.id??`${t}-${o}`))}),null===c?d&&!i.some(e=>e.zone===d)?a(d,0):null:0!==i.length||!t.rung&&d!==c?null:a(c,0)]});return t.rung?hs(e,t.rung,r++,o,p):/* @__PURE__ */Gn($n,{children:p},t.slot??"")})})},gs=(e,n)=>{const t=er(yt?.data,e.type,String(e.props.id)),o=ol(e),r=o.filter(e=>e.rung).length;let i=0;/* @__PURE__ */
|
|
20
|
+
return Gn(Un,{children:o.map(o=>{const l=o.kids,s=o.rung?n+1:n,d=ll(e.type,t,o.slot),c=d?.spec??null;!c||!Array.isArray(e.props[c.slot])||e.props[c.slot];const a=d&&d.choices?{slot:d.slot,choices:d.choices}:null,p=String(e.props.id),u=c&&!c.fixed?`${p}:${c.slot}`:null,f=a?`${p}:${a.slot}`:null,h=(e,n)=>ps(e,n),m=null===o.slot?null:`${p}:${o.slot}`,g=Boolean(c&&!c.fixed&&(null===m||m===u)),y=/* @__PURE__ */Dn(Un,{children:[l.map(({child:n,zone:t,index:o})=>{const r=Lo===String(n.props.id),i=bi(n),l=String(n.props.id),{collapsible:d,folded:c}=sl(n,s,al(n.type)),a=nl(n.type),p=1===a.length?`${l}:${a[0]}`:null,u=p?{...bn(p),index:pi(p).length}:void 0,f=Hl.dragging,m=u&&f&&Tl(f,u)?u:void 0,g=()=>pl(t,o,l,e.type),{rowProps:y,...S}=Hl.row({item:{id:l,zone:t,index:o,type:n.type},place:{...bn(t),index:o},into:m,canDrag:!Qo(n.type)},{"data-node-id":l,onClick:Ji(g)});/* @__PURE__ */
|
|
21
|
+
return Dn($n,{children:[0===o&&h(t,0),
|
|
22
|
+
/* @__PURE__ */Gn(Be,{words:Rt,icon:/* @__PURE__ */Gn(lr,{type:n.type,size:13}),name:i,preview:Xi(n),marks:qi(n),onSelect:g,nameSlot:zi(t,o,l,i),selected:r,hidden:Boolean(n.props._hidden),...S,fold:d?{open:!c,label:"group",onToggle:()=>Cr(l)}:void 0,actions:Qo(n.type)?_i(n,t,o)??void 0:/* @__PURE__ */Dn(Un,{children:[Ki(t,o,i),_i(n,t,o),Qi(t,o,n,i)]}),rowProps:y}),d&&!c&&/* @__PURE__ */Gn(Oe,{children:gs(n,s+1)}),h(t,o+1)]},String(n.props.id??`${t}-${o}`))}),null===m?f&&!l.some(e=>e.zone===f)?h(f,0):null:0!==l.length||(o.rung?g:m!==f)?null:h(m,0)]});return o.rung?hs(e,o.rung,i++,r,y):/* @__PURE__ */Gn($n,{children:y},o.slot??"")})})},ys=Bo||null!==ao,Ss=e=>"panel"in e?{id:e.id,label:e.label,icon:e.icon,active:Qt&&!ys&&qo===e.id,onSelect:()=>Jr(e.id)}:e,ks=[...(Ko.railLead??[]).map(Ss),{id:"sections",label:At.layers,icon:/* @__PURE__ */Gn(Le,{}),active:Qt&&!ys&&"sections"===qo,onSelect:()=>Jr("sections")},...(Ko.railTrail??[]).map(Ss)];co?ks.push({id:"media",label:At.railMedia,icon:/* @__PURE__ */Gn(Ve,{}),active:Qt&&!Bo&&(null!==ao||"media"===qo),onSelect:()=>Jr("media")}):ht&&ks.push({id:"media",label:At.railMedia,icon:/* @__PURE__ */Gn(Ve,{}),onSelect:Yr});const vs=[...Ko.railLead??[],...Ko.railTrail??[]].find(e=>"panel"in e&&e.id===qo),ws=Boolean(Tt?.foldable)&&!Xo,bs=Tt?.label??(mt?At.pageSections:At.templateSections),xs=ws&&zr(Zn),zs=/* @__PURE__ */Dn(Un,{children:[qr.map((e,n)=>{if($t(e)||Mt(e)||Bt(e.type))return null;const t=Lo===String(e.props.id),o=Boolean(e.props._hidden);tl(e);const r=String(e.props.id),i=Ko.hasOwnRows?.(e)??!1,l=cl(e)||i,s=l&&zr(r),d=nl(e.type),c=1===d.length?`${r}:${d[0]}`:null,a=c?{...bn(c),index:pi(c).length}:void 0,p=Hl.dragging,u=a&&p&&Tl(p,a)?a:void 0,{rowProps:f,...h}=Hl.row({item:{id:r,zone:se,index:n,type:e.type},place:{...bn(se),index:n},into:u},{"data-node-id":r,onClick:Ji(()=>Ei(n))});/* @__PURE__ */
|
|
23
|
+
return Dn($n,{children:[n>0&&Zi(n),
|
|
24
|
+
/* @__PURE__ */Gn(Be,{words:Rt,icon:/* @__PURE__ */Gn(lr,{type:e.type,size:13}),name:di(e),preview:Xi(e),marks:qi(e),onSelect:()=>Ei(n),nameSlot:zi(se,n,r,di(e)),selected:t,hidden:o,...h,fold:l?{open:!s,label:"section",onToggle:()=>Cr(r)}:void 0,actions:/* @__PURE__ */Dn(Un,{children:[Ki(se,n,di(e)),_i(e,se,n),Qi(se,n,e,di(e))]}),rowProps:f}),cl(e)&&!s&&/* @__PURE__ */Dn(Oe,{children:[gs(e,1),Ko.partRows?.(e,us)]}),i&&!s&&/* @__PURE__ */Gn(Oe,{children:Ko.ownRows?.(e,n,us)})]},String(e.props.id??n))}),!Xo&&Cl>0&&Zi(Cl)]}),Cs=(e,n,t)=>{const o=String(e.props.id),r=rl(e).length>0||il(e)||Boolean(tr(e.type)),i=r&&zr(o),l="header"===t?At.header:At.footer,s=rr.rowName?rr.rowName(e,"section",l):l;/* @__PURE__ */
|
|
25
|
+
return Dn(Un,{children:[
|
|
26
|
+
/* @__PURE__ */Gn(Be,{words:Rt,icon:/* @__PURE__ */Gn(lr,{type:t,size:13}),name:s,preview:Xi(e),marks:qi(e),badge:bl,onSelect:()=>Ei(n),nameSlot:zi(se,n,o,s),selected:Lo===String(e.props.id),fold:r?{open:!i,label:"section",onToggle:()=>Cr(o)}:void 0,actions:_i(e,se,n)??void 0,rowProps:{"data-node-id":o,onClick:Ji(()=>Ei(n))}}),r&&!i&&/* @__PURE__ */Gn(Oe,{children:ms(e,1)})]})};return(Ko.wrap??(e=>e))(
|
|
27
|
+
/* @__PURE__ */Gn(oe,{target:wo,children:/* @__PURE__ */Dn("div",{ref:vo,className:"sf-editor es-editor",style:qe(kr),onContextMenu:Pi.onEditorContextMenu,...g(un),children:[
|
|
28
|
+
/* @__PURE__ */Dn(Fe,{children:[
|
|
29
|
+
/* @__PURE__ */Gn(He,{items:ks,ariaLabel:At.bar.views}),
|
|
30
|
+
/* @__PURE__ */Dn(We,{children:[
|
|
31
|
+
/* @__PURE__ */Gn(Ge,{label:At.bar.undo,disabled:Boolean(at)||!kt.hasPast,onClick:()=>kt.back(),children:/* @__PURE__ */Gn(An,{})}),
|
|
32
|
+
/* @__PURE__ */Gn(Ge,{label:At.bar.redo,disabled:Boolean(at)||!kt.hasFuture,onClick:()=>kt.forward(),children:/* @__PURE__ */Gn(Rn,{})}),
|
|
33
|
+
/* @__PURE__ */Gn(De,{}),
|
|
34
|
+
/* @__PURE__ */Gn(Ue,{devices:eo,value:io,onChange:lo}),
|
|
35
|
+
/* @__PURE__ */Gn(Ge,{label:At.bar.refresh,tip:At.bar.refreshTip,onClick:()=>{ko.current=(()=>{const e=wo?.document;if(!e)return null;const n=qr.findIndex(Mt),t=n>=0?n:qr.length;let o=null;for(let n=0;n<t;n++){const t=qr[n]?.props?.id;if(null==t)continue;const r=e.querySelector(`[data-puck-component="${CSS.escape(String(t))}"]`);if(!r)continue;const i=r.getBoundingClientRect().top;i<=4&&(null===o||i>o.offset)&&(o={id:String(t),offset:i})}if(!o){const e=vt?.props?.id??qr[0]?.props?.id;null!=e&&(o={id:String(e),offset:0})}return o})(),So(e=>e+1)},children:/* @__PURE__ */Gn(En,{})})]}),
|
|
36
|
+
/* @__PURE__ */Dn(We,{kind:"right",style:{minWidth:300},children:[
|
|
37
|
+
/* @__PURE__ */Gn(I,{input:Co,words:At.saveStatus}),Ko.barLead?.(),Ko.barTrail?.(),Ko.mainAction||!Ko.barMain?/* @__PURE__ */Gn(B,{input:Co,action:Ko.mainAction??{label:At.done,onPress:()=>{tt(yt.data)}},readOnly:Boolean(at),saveSwitch:ut,onToggleAutoSave:lt,onSaveNow:Io,bar:At.bar,words:At.saveStatus}):Ko.barMain()]})]}),
|
|
38
|
+
/* @__PURE__ */Gn(C,{}),
|
|
39
|
+
/* @__PURE__ */Dn("div",{className:"sf-body",children:[Qt?/* @__PURE__ */Dn(Un,{children:[
|
|
40
|
+
/* @__PURE__ */Gn("aside",{className:"es-sidepanel es-sidepanel--left sf-panel sf-panel--left","aria-label":At.leftPanel,children:Bo?/* @__PURE__ */Gn($,{at:$o?{label:(e=>{const n=Ml(e.zone);if(n)return At.add.addingTo({name:rr.rowName?Ui(n,!0):ii(n.type)});if(e.zone===se){const n=qr[e.index];return n&&!Mt(n)?At.add.addingBefore({name:Ui(n,!0)}):At.add.addingAtEnd}const t=Rl(e.zone);return t?At.add.addingTo({name:t.parentName}):At.add.addingHere})($o),onClear:()=>Mo(null)}:void 0,placeBlocks:$o&&$o.zone!==se?Rl($o.zone)?.choices:void 0,canTake:$o?e=>{if(!$o)return null;const n={...bn($o.zone),index:$o.index};if(El(e,n))return null;const t=Ml($o.zone);if(t)return At.add.notInside({name:Ui(t,!0)});if($o.zone===se)return At.add.onlySections;const o=Rl($o.zone);return o?At.add.notInside({name:o.parentName}):At.add.onlySections}:void 0,onPick:$o?e=>{if(!$o)return;const n={...bn($o.zone),index:$o.index};El(e,n)&&(Ll(e,n),Di())}:void 0,itemFor:e=>({id:`new:${e.kind}:${"template"===e.kind?e.template.id:e.type}`,zone:"",index:-1,type:"template"===e.kind?e.template.node.type:e.type,add:e}),session:Fl,siteWide:Ko.addPanelRow?.(Di),onClose:Di,onHide:Dr,readOnly:Boolean(at)}):ao&&so?
|
|
41
|
+
/* @__PURE__ */Gn(A,{panel:so,pick:ao,onHide:Dr}):vs?vs.panel({onHide:Dr,notify:Nr}):"media"===qo&&so?/* @__PURE__ */Gn(A,{panel:so,pick:null,onHide:Dr}):/* @__PURE__ */Dn(Un,{children:[
|
|
42
|
+
/* @__PURE__ */Gn(M,{icon:/* @__PURE__ */Gn(Le,{}),title:At.layers,context:Gt,actions:/* @__PURE__ */Dn(Un,{children:[!at&&/* @__PURE__ */Gn(Je,{label:At.add.title,onClick:()=>Wi(null),children:/* @__PURE__ */Gn(Ln,{size:15})}),
|
|
43
|
+
/* @__PURE__ */Gn(Je,{label:Bl?At.expandAll:At.collapseAll,title:0===Il.length?At.nothingToFold:void 0,disabled:0===Il.length,onClick:()=>Sr(e=>{const n=new Set(Il);return Bl?new Set([...e].filter(e=>!n.has(e))):/* @__PURE__ */new Set([...e,...Il])}),children:/* @__PURE__ */Gn(Xn,{expand:Bl})})]}),onHide:Dr}),
|
|
44
|
+
/* @__PURE__ */Dn(Ne,{className:"sf-tree sf-scroll",words:Rt,children:[
|
|
45
|
+
/* @__PURE__ */Gn(Be,{words:Rt,icon:/* @__PURE__ */Gn(lr,{type:"page",size:13}),name:At.pageSettings,onSelect:Kr,selected:!vt&&Eo,rowProps:{onClick:Ji(Kr)}}),xl&&/* @__PURE__ */Dn(Un,{children:[!wl&&/* @__PURE__ */Gn(Pe,{children:At.header}),fs(xl)]}),!Xo&>&&!(wl&&xl)&&/* @__PURE__ */Dn(Un,{children:[!wl&&/* @__PURE__ */Gn(Pe,{children:At.header}),!jt&&/* @__PURE__ */Gn(Be,{words:Rt,icon:/* @__PURE__ */Gn(lr,{type:"header",size:13}),name:At.header,badge:bl,onSelect:Xr,selected:Ao.kind===Pt?.kind,rowProps:{onClick:Ji(Xr)}})]}),!Xo&&Sl&&!(wl&&xl)&&Cs(Sl,yl,"header"),!Xo&&!ws&&/* @__PURE__ */Gn(Pe,{children:bs}),ws?/* @__PURE__ */Dn(Un,{children:[
|
|
46
|
+
/* @__PURE__ */Gn(Be,{words:Rt,icon:null,name:bs,fold:{open:!xs,label:bs,onToggle:()=>Cr(Zn)}}),!xs&&/* @__PURE__ */Gn(Oe,{children:zs})]}):zs,gt&&!wl&&/* @__PURE__ */Gn(Pe,{children:At.footer}),gl&&!(wl&&zl)&&Cs(gl,ml,"footer"),!Xo&&!gl&>&&!wl&&/* @__PURE__ */Gn(Be,{words:Rt,icon:/* @__PURE__ */Gn(lr,{type:"footer",size:13}),name:At.footer,onSelect:Yi,rowProps:{onClick:Ji(Yi),title:At.editFooter}}),zl&&fs(zl),Ko.treeFoot?.()]})]})}),
|
|
47
|
+
/* @__PURE__ */Gn(Ye,{side:"left",width:kr.left,min:Xe,max:Ke,defaultWidth:k.left,label:At.resizeLeftPanel,onResize:br})]}):/* @__PURE__ */Gn(j,{side:"left",onShow:Dr}),
|
|
48
|
+
/* @__PURE__ */Dn("div",{ref:Pr,className:"sf-center sf-scroll","data-sf-canvas-head":Ar?"":void 0,style:{overflowX:Hr?"auto":"hidden",overflowY:"hidden"},children:[Ar&&/* @__PURE__ */Gn("div",{ref:Rr,className:"sf-canvas-head",children:/* @__PURE__ */Gn(Ar,{device:io})}),
|
|
49
|
+
/* @__PURE__ */Dn("div",{className:"sf-frame-scaler",style:Wr,children:[
|
|
50
|
+
/* @__PURE__ */Gn("div",{className:"sf-frame "+(io===oo?"":`sf-frame--${io}`),style:Gr,children:/* @__PURE__ */Dn("div",{className:"sf-preview-host",children:[
|
|
51
|
+
/* @__PURE__ */Gn(Ie.Provider,{value:vl,children:/* @__PURE__ */Gn(Dt,{},yo)}),
|
|
52
|
+
/* @__PURE__ */Gn(rn,{canvas:wo,session:Fl,model:ns,measure:os,canDrop:is,onDrop:ss,choose:Dl,onPick:cs,onZoneAdd:as,onSeamAdd:as,zoneAddLabel:At.canvasAddBlock,words:Et.canvas,readOnly:Boolean(at),revision:yt.data}),jo.length>0&&/* @__PURE__ */Gn("div",{className:"sf-preview-gaps",children:jo.map(e=>
|
|
53
|
+
/* @__PURE__ */Gn(ln,{index:e.index,label:At.addSectionHere,onInsert:()=>Wi(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))})]})}),kl?/* @__PURE__ */Gn(Kn,{canvas:wo,tabs:Kl,onSelect:e=>{const n=qr.findIndex(n=>String(n.props.id)===e);n>=0&&Ei(n)}}):null]})]}),Zt?/* @__PURE__ */Dn(Un,{children:[
|
|
54
|
+
/* @__PURE__ */Gn(y,{value:{selectChild:pl,addChild:ul,childRowName:bi,blockRowName:Ol},children:/* @__PURE__ */Gn(Ut,{mode:Ao,onOpenWebsiteSettings:Ko.openSettings??(()=>{}),onOpenSiteStyles:Ko.openStyles,onSelectNode:ar,onNotify:Nr,onHidePanel:Ur,nodeActions:vt?de(bt,vt.type):et})}),
|
|
55
|
+
/* @__PURE__ */Gn(Ye,{side:"right",width:kr.right,min:Xe,max:Ke,defaultWidth:k.right,label:At.resizeSettingsPanel,onResize:xr})]}):
|
|
56
|
+
/* @__PURE__ */Gn(j,{side:"right",onShow:Ur})]}),Pi.menu]})}))}export{nt as ScreenChrome};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{useScreenOwnerName as e}from"./chunk-
|
|
1
|
+
import{useScreenOwnerName as e}from"./chunk-OHRS7Q3E.js";import{settlePanelPick as n}from"./chunk-R6WTQWAC.js";import{MediaPanelHead as i,mediaPickKind as c}from"./chunk-IE55HNMA.js";import{jsxs as o,Fragment as r,jsx as t}from"react/jsx-runtime";function l({panel:l,pick:d,onHide:m}){const p=e();/* @__PURE__ */
|
|
2
2
|
return o(r,{children:[
|
|
3
3
|
/* @__PURE__ */t(i,{context:p,pick:d?{kind:c(d.accept),field:d.title||void 0}:null,onCancel:()=>d&&n(d.requestId,null),onHide:m}),
|
|
4
4
|
/* @__PURE__ */t("div",{className:"sf-media-panel",children:/* @__PURE__ */t(l,{pick:d,onPick:e=>d&&n(d.requestId,e)})})]})}export{l as MediaSidePanel};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{DEFAULT_DRAG_WORDS as e}from"./chunk-
|
|
1
|
+
import{DEFAULT_DRAG_WORDS as e}from"./chunk-GG4FGBFR.js";import{dropEffectFor as t,scrollBoxOf as n,frameScrollBox as l,startAutoScroll as a,isNoOpDrop as r}from"./chunk-67GNT6PF.js";import{useCanvasLayout as o,useCanvasEvent as s,CANVAS_TYPING_EVENT as i,framePointToHost as c,elementScale as d,frameRectToLayer as u,clientPointToLayer as h}from"./chunk-ILXP5VX5.js";import{withTip as f}from"./chunk-P2VEMZH5.js";import{parseZoneKey as p}from"./chunk-KRXQM65X.js";import{useRef as m,useEffect as g,useState as b,useCallback as x,useMemo as y,useSyncExternalStore as v,useId as w,useLayoutEffect as k}from"react";import{Tooltip as N,IconButton as z,Input as A}from"efficient-shell/ui";import{AddIcon as D,CloseIcon as T,SearchIcon as $}from"efficient-shell/icons/efficient";import{jsxs as C,jsx as M}from"react/jsx-runtime";function S({label:e,onInsert:t,style:n,axis:l="y",className:a,index:r}){const o=["es-canvas-insert","x"===l?"is-x":"",a??""].filter(Boolean).join(" ");/* @__PURE__ */
|
|
2
2
|
return C("div",{className:o,style:n,"data-index":r,children:[
|
|
3
3
|
/* @__PURE__ */M("span",{className:"es-canvas-insert-line","aria-hidden":"true"}),
|
|
4
|
-
/* @__PURE__ */M("span",{className:"es-canvas-insert-chip",children:/* @__PURE__ */M(N,{content:e,children:/* @__PURE__ */M(z,{variant:"ghost",size:"sm","aria-label":e,onClick:t,children:/* @__PURE__ */M(D,{})})})})]})}var E=(e,t,n)=>t>=e.left&&t<=e.left+e.width&&n>=e.top&&n<=e.top+e.height,
|
|
5
|
-
/* @__PURE__ */M(S,{className:"es-canvas-seam",axis:e.axis,index:e.place.index,label:e.label??u.seamLabel??z.addSection,onInsert:()=>u.onSeamAdd?.(e.place),style:"x"===e.axis?{left:e.box.left+e.box.width/2-12,top:e.box.top,width:24,height:e.box.height}:{left:e.box.left,top:e.box.top+e.box.height/2-12,width:e.box.width,height:24}},e.key)),de.length?de.map(e=>/* @__PURE__ */M("button",{type:"button",className:["es-canvas-empty",e.addAlways?"is-always":"",W?.zoneKey===e.key?"is-over":""].filter(Boolean).join(" "),style:
|
|
6
|
-
/* @__PURE__ */M("div",{className:"es-canvas-handle-spot",style:
|
|
7
|
-
/* @__PURE__ */M("span",{className:"es-canvas-grip","aria-hidden":"true",children:"⋮⋮"}),
|
|
4
|
+
/* @__PURE__ */M("span",{className:"es-canvas-insert-chip",children:/* @__PURE__ */M(N,{content:e,children:/* @__PURE__ */M(z,{variant:"ghost",size:"sm","aria-label":e,onClick:t,children:/* @__PURE__ */M(D,{})})})})]})}var E=(e,t,n)=>t>=e.left&&t<=e.left+e.width&&n>=e.top&&n<=e.top+e.height,j=e=>e.width*e.height;function L(e,t,n){return e.map((e,t)=>({s:e,at:t})).filter(({s:e})=>E(e.box,t,n)).sort((e,t)=>j(t.s.box)-j(e.s.box)||e.at-t.at).map(({s:e})=>e)}function B(e,t,n){return L(e,t,n).at(-1)??null}function K(e,t,n){const l="x"===e.axis?t:n;let a=0;for(const t of e.children){l>("x"===e.axis?t.left+t.width/2:t.top+t.height/2)&&(a+=1)}return a}function X(e,t){const n=e.children;if("x"===e.axis){const l=n[t-1],a=n[t],r=l&&a?(l.left+l.width+a.left)/2:l?l.left+l.width:a?a.left:e.box.left,o=a??l??e.box;return{left:r-1,top:o.top,width:2,height:o.height}}const l=n[t-1],a=n[t],r=l&&a?(l.top+l.height+a.top)/2:l?l.top+l.height:a?a.top:e.box.top;return{left:e.box.left,top:r-1,width:e.box.width,height:2}}function q(e,t,n,l,a=()=>!1,r=()=>!0){const o=e.filter(e=>E(e.box,t,n)).sort((e,t)=>j(e.box)-j(t.box));for(const e of o){const o=K(e,t,n),s={...e.list,index:o};if(a(s))return null;if(l(s))return{zone:e,to:s,line:X(e,o)};if(!r(s))return null}return null}function I(e,t,n=12){const l=e.children;if(0===l.length)return[];const a=e.box,r="x"===e.axis,o=r?a.left:a.top,s=o+(r?a.width:a.height),i=e=>r?e.left:e.top,c=e=>r?e.left+e.width:e.top+e.height,d=[];for(let u=0;u<=l.length;u++){const h=l[u-1],f=l[u];let p,m;if(h&&f)p=c(h),m=Math.max(i(f)-p,0);else{const e=h?(c(h)+s)/2:(o+i(f))/2;p=Math.min(Math.max(e,o+n),s-n),m=0}const g=r?{left:p,top:a.top,width:m,height:a.height}:{left:a.left,top:p,width:a.width,height:m};d.push({key:`${e.key}:+${u}`,place:{...e.list,index:u},box:g,axis:e.axis,label:t})}return d}function P(e,t=e.key){const n=[];for(let l=1;l<e.children.length;l++){const a=e.children[l-1],r=e.children[l],o=a.top+a.height;n.push({key:`${t}:${l}`,place:{...e.list,index:l},box:{left:e.box.left,top:o,width:e.box.width,height:Math.max(r.top-o,0)}})}return n}var F={nodes:[],zones:[]},G="data-puck-dropzone",O="data-puck-component";function R(e,t){if(e.length>=2){const[t,n]=e;return Math.abs(n.top-t.top)<Math.min(t.height,n.height)/2&&n.left>t.left?"x":"y"}const n=t.ownerDocument.defaultView?.getComputedStyle(t);return n&&n.display.includes("flex")&&n.flexDirection.startsWith("row")?"x":"y"}function V(e,t){const{frame:n,document:l}=e,a=e=>u(n,function(e){const t=e.getBoundingClientRect();return{left:t.left,top:t.top,width:t.width,height:t.height}}(e),t),r=[],o=[];for(const e of l.querySelectorAll(`[${G}]`)){const t=e.getAttribute(G)??"";let n;try{n=p(t)}catch{continue}const l=[...e.querySelectorAll(`[${O}]`)].filter(t=>t.parentElement?.closest(`[${G}]`)===e),s=l.map(a);o.push({key:t,list:n,box:a(e),axis:R(s,e),children:s}),l.forEach((e,t)=>{const l=e.getAttribute(O);l&&r.push({id:l,place:{...n,index:t},box:s[t]})})}return{nodes:r,zones:o}}var Z="data-es-empty-cell",Y="data-puck-dropzone",H=140;var Q=e=>({left:e.left,top:e.top,width:e.width,height:e.height});function W(u){const{canvas:f,session:p,readOnly:w,words:z=e.canvas}=u,A=m(u);g(()=>{A.current=u});const D=m(null),T=o(f),[$,E]=b(0),j=x(()=>E(e=>e+1),[]),[B,K]=b(F);g(()=>{const e=D.current;f&&e&&K((A.current.measure??V)(f,e))},[f,T,u.revision,$]);const X=u.model,I=y(()=>X(B),[X,B]),P=v(p.subscribe,p.shown,p.shown),G=u.choose,O=(e,t)=>{const n=L(I.sources,e,t);return 0===n.length?null:G?G(n):n[n.length-1]},[R,H]=b(null),[W,J]=b(null),U=m(null),_=()=>{U.current&&clearTimeout(U.current),U.current=null},ee=()=>{_(),U.current=setTimeout(()=>{p.get()||H(null)},140)};g(()=>_,[]);const te=m(null),ne=m(!1);s(f,i,e=>{ne.current=Boolean(e.detail?.typing),ne.current&&(_(),H(null))}),s(f,"mousemove",e=>{const t=D.current;if(!f||!t)return;const n=c(f.frame,e.clientX,e.clientY,t),l=d(t),a={x:n.x/l,y:n.y/l};if(te.current=a,A.current.readOnly||p.get()||ne.current)return;_();const r=O(a.x,a.y);H(e=>e?.key===r?.key&&e?.box===r?.box?e:r)}),s(f,"mouseout",e=>{e.relatedTarget||(te.current=null,ee())}),s(f,"mouseover",e=>{e.relatedTarget||j()});const le=m(null),ae=x(()=>{le.current?.(),le.current=null,J(null)},[]);g(()=>p.subscribe(()=>{p.get()?j():ae()}),[p,ae,j]),g(()=>ae,[ae]),("undefined"==typeof document?g:k)(()=>{if(p.get())return;const e=te.current;H(t=>w||ne.current?null:e?O(e.x,e.y):t?I.sources.find(e=>e.key===t.key)??null:null)},[I,P,p,w,G]);const re=e=>{const t=p.get(),n=D.current;if(!t||!n)return null;const l=h(n,e.clientX,e.clientY);te.current=l;const a=q(I.zones,l.x,l.y,e=>A.current.canDrop(t.item,e),e=>!!t.from&&r(t.from,e),e=>A.current.fallThrough?.(t.item,e,t.from)??!0);return a?{h:t,t:a}:null},oe={onDragEnter:e=>{if(le.current)return;const t=n(e.currentTarget.parentElement?.parentElement??null),r=f?l(f.document):null,o=[];t&&o.push(a(t)),r&&f&&o.push(a(r,f.frame)),le.current=o.length?()=>o.forEach(e=>e()):null},onDragOver:e=>{const n=re(e);if(!n)return void J(null);e.preventDefault(),e.dataTransfer.dropEffect=t(e.dataTransfer.effectAllowed);const l={zoneKey:n.t.zone.key,line:n.t.line,axis:n.t.zone.axis};J(e=>e&&e.zoneKey===l.zoneKey&&e.line.left===l.line.left&&e.line.top===l.line.top?e:l)},onDragLeave:e=>{const t=e.relatedTarget;t&&e.currentTarget.contains(t)||(te.current=null,J(null))},onDrop:e=>{const t=re(e);t&&(e.preventDefault(),p.end(),ae(),A.current.onDrop(t.h.item,t.t.to))}},se={draggable:!w&&!!R,onMouseEnter:_,onMouseLeave:()=>!p.get()&&ee(),onDragStart:e=>{if(R&&!w){p.start({key:R.key,item:R.item,from:R.from}),e.dataTransfer.effectAllowed="move";try{e.dataTransfer.setData("text/plain",R.key)}catch{}}else e.preventDefault()},onDragEnd:()=>{p.end(),ae()},onClick:()=>{R&&!w&&A.current.onPick?.(R.item)}},{seams:ie=[]}=I,ce=I.zones.filter(e=>0===e.children.length),de=u.onZoneAdd&&!w?ce:[],ue=de.map(e=>e.key).join("\n");return g(()=>{const e=f?.document;if(!e)return;const t=new Set(ue?ue.split("\n"):[]);for(const n of e.querySelectorAll(`[${Y}]`))n.toggleAttribute(Z,t.has(n.getAttribute(Y)??""));return()=>{for(const t of e.querySelectorAll(`[${Z}]`))t.removeAttribute(Z)}},[f,ue,B,T,$]),/* @__PURE__ */C("div",{ref:D,className:"es-canvas-layer",children:[P||!u.onSeamAdd||w?null:ie.map(e=>
|
|
5
|
+
/* @__PURE__ */M(S,{className:"es-canvas-seam",axis:e.axis,index:e.place.index,label:e.label??u.seamLabel??z.addSection,onInsert:()=>u.onSeamAdd?.(e.place),style:"x"===e.axis?{left:e.box.left+e.box.width/2-12,top:e.box.top,width:24,height:e.box.height}:{left:e.box.left,top:e.box.top+e.box.height/2-12,width:e.box.width,height:24}},e.key)),de.length?de.map(e=>/* @__PURE__ */M("button",{type:"button",className:["es-canvas-empty",e.addAlways?"is-always":"",W?.zoneKey===e.key?"is-over":""].filter(Boolean).join(" "),style:Q(e.box),onClick:()=>u.onZoneAdd?.({...e.list,index:0}),children:/* @__PURE__ */M("span",{className:"es-canvas-empty-add",children:z.addButton({label:e.addLabel??u.zoneAddLabel??z.addBlock})})},e.key)):null,P?/* @__PURE__ */M("div",{className:"es-canvas-catch",...oe}):null,W&&!ce.some(e=>e.key===W.zoneKey)?/* @__PURE__ */M("div",{className:`es-canvas-line is-${W.axis}`,style:Q(W.line)}):null,
|
|
6
|
+
/* @__PURE__ */M("div",{className:"es-canvas-handle-spot",style:R?{"--es-handle-x":`${R.box.left+2}px`,"--es-handle-y":`${Math.max(R.box.top-11,0)}px`}:void 0,children:/* @__PURE__ */M(N,{className:"es-canvas-handle-tip",side:"top",content:!R||w||P?null:R.title??z.handle({label:R.label}),children:/* @__PURE__ */C("div",{className:["es-canvas-handle",R&&!w?"is-shown":"",P?"is-dragging":""].filter(Boolean).join(" "),...se,children:[
|
|
7
|
+
/* @__PURE__ */M("span",{className:"es-canvas-grip","aria-hidden":"true",children:"⋮⋮"}),R?.label]})})})]})}var J=e=>e.tiles.length>0&&e.tiles.every(e=>null!=e.cover);function U({groups:t,session:n,itemFor:l,onInsert:a,at:r,hint:o,searchLabel:s,readOnly:i,words:c=e.add}){const d=o??c.hint,u=s??c.search,[h,p]=b(""),m=w(),g=h.trim().toLowerCase(),x=function(e){const t=/* @__PURE__ */new Map;return e.map(e=>{const n=e.key??e.title,l=t.get(n)??0;return t.set(n,l+1),0===l?n:`${n}\0${l}`})}(t),y=t.map((e,t)=>({...e,key:x[t],tiles:g?e.tiles.filter(e=>((e,t)=>e.label.toLowerCase().includes(t)||(e.keywords??[]).some(e=>e.toLowerCase().includes(t)))(e,g)):e.tiles})).filter(e=>e.tiles.length>0),v=(e,t)=>a=>{if(t)a.preventDefault();else{n.start({key:`new:${e}`,item:l(e)}),a.dataTransfer.effectAllowed="copy";try{a.dataTransfer.setData("text/plain",e)}catch{}}};/* @__PURE__ */
|
|
8
8
|
return C("div",{className:"es-add",children:[r?/* @__PURE__ */C("div",{className:"es-add-at",role:"status",children:[
|
|
9
9
|
/* @__PURE__ */M("span",{children:r.label}),f(c.stop,/* @__PURE__ */M("button",{type:"button",className:"es-add-at-clear","aria-label":c.stop,onClick:r.onClear,children:/* @__PURE__ */M(T,{size:12,"aria-hidden":"true"})}))]}):null,
|
|
10
10
|
/* @__PURE__ */M("p",{className:"es-add-hint",children:d}),
|
|
@@ -14,5 +14,5 @@ return C("div",{className:"es-add",children:[r?/* @__PURE__ */C("div",{className
|
|
|
14
14
|
/* @__PURE__ */C("div",{className:"es-add-group-head",children:[
|
|
15
15
|
/* @__PURE__ */M("span",{className:"es-add-group-title",children:e.title}),
|
|
16
16
|
/* @__PURE__ */M("span",{className:"es-add-group-count",children:e.tiles.length})]}),
|
|
17
|
-
/* @__PURE__ */M("div",{className:J(e)?"es-add-grid is-cards":"es-add-grid",children:e.tiles.map(e=>{const t=Boolean(i||e.disabled),l=i?void 0:e.disabled?e.disabledReason:e.title??c.tile({label:e.label});return f(l,/* @__PURE__ */C("button",{type:"button",className:null!=e.cover?"es-add-tile has-cover":"es-add-tile",draggable:!t,"aria-disabled":t||void 0,"aria-label":c.tile({label:e.label}),onDragStart:v(e.type,t),onDragEnd:()=>n.end(),onClick:()=>!t&&a(e.type),children:[null!=e.cover?/* @__PURE__ */M("span",{className:"es-add-tile-cover","aria-hidden":"true",children:e.cover}):e.icon?/* @__PURE__ */M("span",{className:"es-add-tile-glyph","aria-hidden":"true",children:e.icon}):null,
|
|
18
|
-
/* @__PURE__ */M("span",{className:"es-add-tile-label",children:e.label})]},e.type))})})]},e.key))]})}export{U as AddPanel,W as CanvasDragLayer,S as CanvasInsert,
|
|
17
|
+
/* @__PURE__ */M("div",{className:J(e)?"es-add-grid is-cards":"es-add-grid",children:e.tiles.map(e=>{const t=Boolean(i||e.disabled),l=i?void 0:e.disabled?e.disabledReason:e.title??c.tile({label:e.label});return f(l,/* @__PURE__ */C("button",{type:"button",className:null!=e.cover?"es-add-tile has-cover":"es-add-tile",draggable:!t,"aria-disabled":t||void 0,"aria-label":c.tile({label:e.label}),onDragStart:v(e.type,t),onDragEnd:()=>n.end(),onClick:()=>!t&&a?.(e.type),children:[null!=e.cover?/* @__PURE__ */M("span",{className:"es-add-tile-cover","aria-hidden":"true",children:e.cover}):e.icon?/* @__PURE__ */M("span",{className:"es-add-tile-glyph","aria-hidden":"true",children:e.icon}):null,
|
|
18
|
+
/* @__PURE__ */M("span",{className:"es-add-tile-label",children:e.label})]},e.type))})})]},e.key))]})}export{U as AddPanel,W as CanvasDragLayer,S as CanvasInsert,F as EMPTY_MEASURE,H as HANDLE_GRACE_MS,q as canvasTarget,E as contains,K as gapInZone,X as gapLine,I as insertSeams,V as measureCanvas,B as pickSource,P as seamsBetween,L as sourcesAt};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEaselHost as n}from"./chunk-U3JP4VGF.js";import{useEaselApi as e,bindUndoKeys as t}from"./chunk-
|
|
1
|
+
import{useEaselHost as n}from"./chunk-U3JP4VGF.js";import{useEaselApi as e,bindUndoKeys as t}from"./chunk-I55LUW3C.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 +1 @@
|
|
|
1
|
-
import{DEFAULT_TEXT_STYLES_WORDS as o}from"./chunk-OGH6CC3E.js";import{DEFAULT_PICK_WORDS as r}from"./chunk-ZAOM6PFH.js";import{
|
|
1
|
+
import{DEFAULT_TEXT_STYLES_WORDS as o}from"./chunk-OGH6CC3E.js";import{DEFAULT_PICK_WORDS as r}from"./chunk-ZAOM6PFH.js";import{DEFAULT_SCREEN_WORDS as t}from"./chunk-VWXUMVCD.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as m}from"./chunk-6WY6ZXJG.js";import{DEFAULT_CANVAS_WORDS as n}from"./chunk-TBY3DFKS.js";import{DEFAULT_TREE_WORDS as c}from"./chunk-K56YDHYQ.js";import{DEFAULT_PANEL_WORDS as s}from"./chunk-KFV7N2DJ.js";import{DEFAULT_NODE_MENU_WORDS as f}from"./chunk-WK3AFPXY.js";import{DEFAULT_SAVE_WORDS as p}from"./chunk-H6DDIBQ4.js";import{DEFAULT_CHROME_WORDS as e,DEFAULT_NOTICE_WORDS as i}from"./chunk-Z6PVRXVY.js";import{DEFAULT_LOCK_WORDS as u}from"./chunk-RE4LP46F.js";import{DEFAULT_RAIL_WORDS as k}from"./chunk-2OAZYSWJ.js";import{DEFAULT_COPY_WORDS as j}from"./chunk-Q6AM43CA.js";import{DEFAULT_FIELDS_WORDS as h}from"./chunk-FFYXVAAL.js";import{DEFAULT_DRAG_WORDS as l}from"./chunk-GG4FGBFR.js";var F={notice:i,lock:u,save:p,chrome:e,rail:k,tree:c,panel:s,fields:h,pick:r,drag:l,menu:f,styleClipboard:m,copy:j,canvas:n,textStyles:o,screen:t},a=o=>"object"==typeof o&&null!==o;function Y(o,r){const t={};for(const m of Object.keys(o)){const n=o[m],c=r[m];null==c?t[m]=n:a(n)?t[m]=a(c)?Y(n,c):n:t[m]=typeof c==typeof n?c:n}return t}function y(o,r){return r?Y(o,r):o}export{F as DEFAULT_EASEL_STRINGS,y as mergeEaselStrings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useScreenDocument as n}from"./chunk-
|
|
1
|
+
import{useScreenDocument as n}from"./chunk-GCCBEY2W.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-VWXUMVCD.js";import{EditNotice as r}from"./chunk-IE55HNMA.js";import{useWords as e}from"./chunk-MFIRYGHW.js";import{jsx as i}from"react/jsx-runtime";function t(){const{capabilities:t,access:c,takeOverEditing:a,viewReadOnly:s,saveConflict:m,reloadFromServer:u}=n(),{noun:l}=e("screen",o);return t.hasEditGuard?/* @__PURE__ */i(r,{access:c,conflict:m,noun:l,onTakeOver:a,onViewReadOnly:s,onReload:u}):null}export{t as PageEditGuardNotices};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{noControlField as e}from"./chunk-7F52SZOI.js";import{usePreviewDevice as n}from"./chunk-BSPCSC45.js";import{DEFAULT_SCREEN_WORDS as r}from"./chunk-
|
|
1
|
+
import{noControlField as e}from"./chunk-7F52SZOI.js";import{usePreviewDevice as n}from"./chunk-BSPCSC45.js";import{DEFAULT_SCREEN_WORDS as r}from"./chunk-VWXUMVCD.js";import{useWords as t}from"./chunk-MFIRYGHW.js";import{jsx as o}from"react/jsx-runtime";function i(e){return"mobile"===e?"mobile":"desktop"}var c={desktop:null,tablet:r.deviceNote.tablet,mobile:r.deviceNote.mobile},u="data-sf-device-hidden";function d(){/* @__PURE__ */
|
|
2
2
|
return o("span",{hidden:!0,[u]:""})}function s({tier:e,render:r,...t}){return i(n())===e?/* @__PURE__ */o(r,{...t}):/* @__PURE__ */o(d,{})}var m="__device";function f(e){const n=e?.[m];return n??null}function l(e){return f(e)?.inner??e}function a(e,n){const r=n.render;return{...n,[m]:{tier:e,inner:n},render:n=>/* @__PURE__ */o(s,{tier:e,render:r,...n})}}function p(){const e=t("screen",r).deviceNote,i=n(),c="desktop"===i?null:e[i];return c?/* @__PURE__ */o("div",{className:"sf-device-scope",children:c}):/* @__PURE__ */o(d,{})}function v(){return e({type:"custom",render:()=>/* @__PURE__ */o(p,{})},"always")}export{m as DEVICE_FIELD_MARKER,u as DEVICE_HIDDEN_ATTR,c as DEVICE_NOTE,a as deviceField,f as deviceMetaOf,v as deviceNote,i as shownTier,l as withoutDeviceGate};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{STANDARD_MARKUP as t,writeMarkedLines as e,sameMarks as n,markedLines as l,spanFor as r,marksIn as o,toggleMark as i,listIn as a,setList as s,colorOver as c,unlinkAt as u,linkOver as d,colorIn as h,findLink as f,isSafeLinkHref as p}from"./chunk-546BBOPE.js";import{Tooltip as m,ColorSwatch as g,ColorPickerPanel as b,Button as k}from"efficient-shell/ui";import{jsxs as v,jsx as y}from"react/jsx-runtime";var x=/* @__PURE__ */new Set(["script","style","head","title","meta","link","template","noscript","svg","math","object","iframe"]),w=/* @__PURE__ */new Set(["p","div","li","ul","ol","dl","dt","dd","h1","h2","h3","h4","h5","h6","blockquote","pre","table","thead","tbody","tfoot","tr","section","article","header","footer","aside","nav","figure","figcaption","address","hr"]);function D(r,o){const i=o.rules??t,a=r.html&&""!==r.html.trim()?function(t,r,o){const i=r.createElement("template");i.innerHTML=t;const a=[[]],s=()=>a[a.length-1],c=()=>{const t=s();for(;t.length>0&&" "===t[t.length-1].ch;)t.pop();t.length>0&&a.push([])},u=(t,e,n,l)=>{if(3===t.nodeType){for(const r of t.textContent??""){const t=/\s/.test(r)?" ":r,o=s();" "===t&&(0===o.length&&a.length>1||" "===o[o.length-1]?.ch)||o.push({ch:t,bold:e,italic:n,href:l})}return}if(1!==t.nodeType&&11!==t.nodeType)return;const r=t,o=1===t.nodeType?r.localName:"";if(x.has(o))return;if("br"===o)return void a.push([]);let i=e,d=n,h=l;if("b"!==o&&"strong"!==o||(i=!0),"i"!==o&&"em"!==o||(d=!0),"a"===o){const t=(r.getAttribute("href")??"").trim();h=p(t)?t:null}const f=1===t.nodeType?r.style:null;if(f){const t=f.fontWeight;"bold"===t||"bolder"===t||Number(t)>=600?i=!0:("normal"===t||"lighter"===t||""!==t&&Number(t)<600)&&(i=!1),"italic"===f.fontStyle||"oblique"===f.fontStyle?d=!0:"normal"===f.fontStyle&&(d=!1)}const m=w.has(o);m&&c();for(const e of[...t.childNodes])u(e,i,d,h);m&&c()};u(i.content,!1,!1,null);for(;a.length>1&&0===a[a.length-1].length;)a.pop();return a.map(t=>function(t,r){const o=e=>t.map((n,l)=>n[e]&&(" "!==n.ch||Boolean(t[l-1]?.[e])&&Boolean(t[l+1]?.[e]))),i=[{bold:!0,italic:!0,links:!0},{bold:!0,italic:!1,links:!0},{bold:!1,italic:!1,links:!0},{bold:!1,italic:!1,links:!1}];for(const a of i){const i=M(t,a.bold?o("bold"):null,a.italic?o("italic"):null,a.links),s=e([i]).text;if(n([i],l(s,r)))return s}return t.map(t=>t.ch).join("")}(t,o))}(r.html,o.doc,i):(r.text??"").replace(/\r\n?/g,"\n").split("\n");return o.multiline?a.join("\n"):1===a.length?a[0]:a.map(t=>t.trim()).filter(t=>""!==t).join(" ")}function M(t,e,n,l){let o=0,i=null,a=null,s=null;return{bullet:!1,chars:t.map((t,c)=>{const u=l?t.href:null;return i=null===u?null:i&&i.href===u?i:r(++o,"link",u),a=e?.[c]?a??r(++o,"bold"):null,s=n?.[c]?s??r(++o,"italic"):null,{ch:t.ch,at:-1,marks:[i,a,s].filter(t=>null!==t)}})}}var T="application/x-efficient-markup",N=/^([0-9]{1,3})\. $/;function C(t,e){const n=t.split("\n"),r=l(t,e);let o=0,i=0;const a=r.map((t,e)=>{const l=!t.bullet&&null==t.number&&"- "===n[e],r=null!=t.number||t.bullet?null:N.exec(n[e]),a=t.bullet||l,s=r?r[1]:t.number??null,c=l||r?[]:t.chars,u=c.map(t=>t.ch).join(""),d=null!=s?s.length+2:a?2:0,h={bullet:a,number:s,chars:c,start:o,src:o+d,vis:i,text:u};return o+=n[e].length+1,i+=u.length+1,h});return{lines:a,text:a.map(t=>t.text).join("\n")}}function E(t,e){const{lines:n}=t;for(let t=0;t<n.length;t+=1){const l=n[t];if(e<=l.vis+l.text.length||t===n.length-1)return[l,Math.max(0,Math.min(e-l.vis,l.text.length)),t]}return[n[0],0,0]}function S(t,e){const[n,l]=E(t,e);if(0===l)return n.src;let r=0;for(const t of n.chars){if(l<=r+t.ch.length)return t.at+(l-r);r+=t.ch.length}return n.src}function A(t,e){const[n,l]=E(t,e);let r=0;for(const t of n.chars){if(l===r)return t.at;r+=t.ch.length}return S(t,e)}function B(t,e){const{lines:n}=t;let l=n[0];for(const t of n)e>=t.start&&(l=t);let r=0;for(const t of l.chars){if(!(e>=t.at+t.ch.length)){e>t.at&&(r+=e-t.at);break}r+=t.ch.length}return l.vis+r}function L(t,e,n){return[B(t,e),B(t,n)]}function R(t,e,n){return e===n?[S(t,e),S(t,e)]:[A(t,e),S(t,n)]}function W(t,e){let n=0;for(let l=0;l<t.chars.length;l+=1){if(n>=e)return l;n+=t.chars[l].ch.length}return t.chars.length}function j(t,o,i,a,s){const c=C(t,o),[u,d,h]=E(c,Math.min(i,a)),[f,p,m]=E(c,Math.max(i,a)),g=W(u,d),b=W(f,p),k=u.chars.slice(0,g),v=f.chars.slice(b),y=i!==a&&u.chars[g]&&(h!==m||g<b)?u.chars[g].marks:function(t,e){const n=t.chars[e-1],l=t.chars[e],r=(t,e)=>{const n=t.findIndex(t=>"link"===t.kind);return-1===n||e?t:t.slice(0,n)};if(n){const t=n.marks.find(t=>"link"===t.kind),e=Boolean(t&&l?.marks.some(e=>e.id===t.id));return r(n.marks,e)}return l?r(l.marks,!1):[]}(u,g);let x=(w=c.lines,Math.max(0,...w.flatMap(t=>t.chars.flatMap(t=>t.marks.map(t=>t.id))))+1);var w;const D=t=>{let e;if(void 0!==s.markup){const t=x;e=l(s.markup,o).map(e=>({bullet:e.bullet,number:e.number??null,chars:e.chars.map(e=>({...e,at:-1,marks:e.marks.map(e=>({...e,id:e.id+t}))}))}))}else{let n=u.number??null;e=(s.text??"").split("\n").map((e,l)=>(l>0&&null!=n&&(n=function(t){return String(Number(t)+1).padStart(t.length,"0")}(n)),{bullet:u.bullet,number:n,chars:[...e].map(e=>({ch:e,at:-1,marks:t??[]}))}))}const n=e.map(t=>t.chars.map(t=>t.ch).join("")).join("\n"),r={bullet:u.bullet,number:u.number??null,chars:[...k,...e[0].chars]},i=e.slice(1);if(i.length>0){const t=i[i.length-1];i[i.length-1]={...t,chars:[...t.chars,...v]}}else r.chars.push(...v);return{lines:[...c.lines.slice(0,h).map(({bullet:t,number:e,chars:n})=>({bullet:t,number:e,chars:n})),r,...i,...c.lines.slice(m+1).map(({bullet:t,number:e,chars:n})=>({bullet:t,number:e,chars:n}))],shown:n}},M=void 0!==s.markup?[null]:[(t=>{let e=t.filter(t=>!s.drop?.some(e=>t.kind===e||"highlight"===e&&"accent"===t.kind));for(const t of s.add??[]){if(e.some(e=>e.kind===t))continue;const n=r(x++,t);n&&(e=[...e,n])}if(void 0!==s.color){e=e.filter(t=>"color"!==t.kind);const t=null===s.color?null:r(x++,"color",s.color);t&&(e=[...e,t])}return e})(y),y,[]];let T="",N="";for(const t of M){const l=D(t),r=e(l.lines).text;if(T=r,N=l.shown,n(l.lines,C(r,o).lines))break}return{text:T,caret:Math.min(i,a)+N.length}}function P(t,e,n,l){const r=C(t,e),[o,,i]=E(r,n);return n!==l||!o.bullet&&null==o.number||""!==o.text?j(t,e,n,l,{text:"\n"}):K(t,e,i,!1,n)}function K(t,n,l,r,o){const i=C(t,n).lines.map(({bullet:t,number:e,chars:n},o)=>o===l?{bullet:r,number:null,chars:n}:{bullet:t,number:e,chars:n});return{text:e(i).text,caret:o}}function V(t,n,l,r){const o=C(t,n),[i,a,s]=E(o,Math.min(l,r)),[c,u,d]=E(o,Math.max(l,r)),h=o.lines.slice(s,d+1).map(({bullet:t,number:e,chars:n},l)=>{const r=0===l?W(i,a):0,o=l===d-s?W(c,u):n.length;return{bullet:t,number:e,chars:n.slice(r,o)}});return e(h).text}function q(t,e,n){if(n<0){const n=t.charCodeAt(e-1);return e-(n>=56320&&n<=57343&&e>=2?2:1)}const l=t.charCodeAt(e);return e+(l>=55296&&l<=56319?2:1)}function F(t){const{value:e,rules:n,multiline:l,inputType:r,pending:o}=t;let[i,a]=t.sel;t.target&&t.target[0]!==t.target[1]&&r.startsWith("delete")&&([i,a]=t.target);const s=[i,a];if("historyUndo"===r||"historyRedo"===r)return{kind:"history",dir:"historyUndo"===r?"undo":"redo"};if("formatBold"===r||"formatItalic"===r||"formatStrikeThrough"===r)return{kind:"format",style:"formatBold"===r?"bold":"formatItalic"===r?"italic":"strike"};if("insertParagraph"===r||"insertLineBreak"===r)return l?{kind:"edit",edit:P(e,n,i,a),range:s}:null;if(r.startsWith("insert")){if("insertTranspose"===r)return null;let c=t.data??"";if("insertFromDrop"===r||"insertFromPaste"===r){const r=D({html:t.html??void 0,text:c},{doc:t.doc,multiline:l,rules:n});return{kind:"edit",edit:j(e,n,i,a,{markup:r}),range:s}}return l||(c=c.replace(/\s*\r?\n\s*/g," ")),{kind:"type",edit:j(e,n,i,a,{text:c,add:o?.add,drop:o?.drop,color:o?.color}),range:s}}if(r.startsWith("delete")){const t=C(e,n),l=t.text;if(i===a){const o=r.includes("Backward"),c=t.lines.findIndex(t=>i>=t.vis&&i<=t.vis+t.text.length),u=t.lines[c];if(o&&u&&i===u.vis&&(u.bullet||null!=u.number))return{kind:"edit",edit:K(e,n,c,!1,i),range:s};if(o?0===i:i===l.length)return null;o?i=q(l,i,-1):a=q(l,a,1)}return{kind:"type",edit:j(e,n,i,a,{text:""}),range:[i,a]}}return null}var O=1e3;function I(t=200){let e=[],n=[],l=null,r=0;return{record(o,i,a){const s="type"===i&&"type"===l&&a-r<1e3;l=i,r=a,n=[],s||(e.push(o),e.length>t&&e.shift())},undo(t){const r=e.pop();return r?(n.push(t),l=null,r):null},redo(t){const r=n.pop();return r?(e.push(t),l=null,r):null},reset(){e=[],n=[],l=null}}}var z=t=>t.preventDefault();function U(t,e){if(t)return t.startsWith("#")?t:e?.find(e=>e.name===t)?.value}function $({colors:t,current:e,words:n,onPick:l}){const r=null===e?null:e.startsWith("#")?e.toLowerCase():t.find(t=>t.name===e)?.value.toLowerCase()??null;/* @__PURE__ */
|
|
2
|
+
return v("div",{className:"es-copy-pop es-copy-colors",role:"dialog","aria-label":n.title,onMouseDown:t=>{"INPUT"!==t.target.tagName&&t.preventDefault()},children:[
|
|
3
|
+
/* @__PURE__ */y("span",{className:"es-copy-pop-label",children:n.theme}),
|
|
4
|
+
/* @__PURE__ */y("div",{className:"es-copy-theme",role:"group","aria-label":n.theme,children:t.map(t=>/* @__PURE__ */y(m,{content:`${t.label} · ${t.value.toUpperCase()}`,children:/* @__PURE__ */y(g,{color:t.value,size:"sm",className:"es-copy-theme-swatch","data-color":t.name,"aria-label":t.label,selected:e===t.name,onMouseDown:z,onClick:()=>l(t.name)})},t.name))}),
|
|
5
|
+
/* @__PURE__ */y("span",{className:"es-copy-pop-label",children:n.any}),
|
|
6
|
+
/* @__PURE__ */y(b,{className:"es-copy-any",value:r??"",onChange:t=>{t!==e&&l(t)},label:n.title,dragWrites:"end"}),
|
|
7
|
+
/* @__PURE__ */y("div",{className:"es-copy-pop-foot",children:/* @__PURE__ */y(k,{variant:"ghost-danger",size:"sm","data-window-action":"remove",onMouseDown:z,onClick:()=>l(null),children:n.remove})})]})}var H={sup:"sub",sub:"sup"};function X(t){const{value:e,rules:n,start:l,end:r,style:a,pending:s}=t,c=H[a];if(l===r){const t=o(e,l,r,n),i=s&&s.at===l?s:null,u=t.has(a),d=!!i?.add.includes(a)||!i?.drop.includes(a)&&u;let h=(i?.add??[]).filter(t=>t!==a),f=(i?.drop??[]).filter(t=>t!==a);return d&&u?f.push(a):d||u||h.push(a),!d&&c&&(h=h.filter(t=>t!==c),t.has(c)&&(f=[...f.filter(t=>t!==c),c])),{kind:"pending",pending:h.length||f.length||void 0!==i?.color?{add:h,drop:f,color:i?.color,at:l}:null}}let u=e,d=l,h=r;if(c&&!o(u,d,h,n).has(a)&&o(u,d,h,n).has(c)){const t=i(u,d,h,c,n);({text:u,selectionStart:d,selectionEnd:h}=t)}return{kind:"edit",result:i(u,d,h,a,n)}}var Y=/^(block|list-item|flex|grid|table|flow-root)$/;function Z(t){const e=t.ownerDocument.defaultView;return!!e&&Y.test(e.getComputedStyle(t).display)}function G(t,e){const n=[],l=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map;let o="",i=!1;const a=()=>{i&&(o+="\n",i=!1)},s=t=>{for(const c of Array.from(t.childNodes)){if(3===c.nodeType){c.data.length>0&&a(),l.set(c,o.length),n.push({node:c,start:o.length,length:c.data.length}),o+=c.data,r.set(c,o.length);continue}if(1!==c.nodeType)continue;const t=c;if(e&&t.matches(e)){l.set(t,o.length),r.set(t,o.length);continue}if("BR"===t.tagName){a(),l.set(t,o.length),o+="\n",r.set(t,o.length);continue}const u=Z(t);u&&((i||o.length>0&&!o.endsWith("\n"))&&(o+="\n"),i=!1),l.set(t,o.length);const d=o.length;s(t),u&&o.length===d&&!i&&n.push({node:t,start:d,length:0}),r.set(t,o.length),u&&(i=!0)}};l.set(t,0),s(t),r.set(t,o.length);return{text:o,at:(t,e)=>{if(3===t.nodeType)return(l.get(t)??0)+Math.min(e,t.data.length);const n=t.childNodes;return e<n.length?l.get(n[e])??r.get(t)??0:r.get(t)??o.length},dom:e=>{for(let t=0;t<n.length;t+=1){const l=n[t],r=l.start+l.length;if(e<l.start)return[l.node,0];if(e<r||e===r&&(t===n.length-1||n[t+1].start>e))return 3===l.node.nodeType?[l.node,e-l.start]:[l.node,0]}const l=n[n.length-1];return l?3===l.node.nodeType?[l.node,l.length]:[l.node,0]:[t,0]}}}function J(t){const e=t.element();if(!e)return null;let n=t.value;const l=t.rules;if(G(e,t.skip).text!==C(n,l).text)return null;const r=t.now??(()=>Date.now()),i=I();let p=e,m=!1,g=null,b=null,k=[t.caret[0],t.caret[1]],v=null,y=!1,x=!1;const w=()=>{x||t.onSelect?.()},M={contenteditable:e.getAttribute("contenteditable"),spellcheck:e.getAttribute("spellcheck")},N=()=>p.ownerDocument,E=()=>N().defaultView?.getSelection()??null,S=()=>{if(!b)return!0;nt();const e=G(p,t.skip);if(e.text!==C(n,l).text)return!1;const[r,o]=b,[i,a]=e.dom(r),[s,c]=e.dom(o);return y||N().activeElement===p||p.focus({preventScroll:!0}),E()?.setBaseAndExtent(i,a,s,c),k=b,A=b,b=null,w(),!0};let A=null;const B=()=>{if(!A)return!1;const t=E(),e=t?.anchorNode??null;return!(e&&e.isConnected&&p.contains(e))||e===p&&0===t.anchorOffset&&(0!==A[0]||0!==A[1])},W=()=>{b=A,S()},P=()=>{S(),N().activeElement===p&&B()&&W();const e=E();if(!(e&&e.anchorNode&&e.focusNode&&p.contains(e.anchorNode)&&p.contains(e.focusNode)))return k;const n=G(p,t.skip),l=n.at(e.anchorNode,e.anchorOffset),r=n.at(e.focusNode,e.focusOffset);return k=l<=r?[l,r]:[r,l],k},K=t=>{const e=N().defaultView;t<=0||!e?A=null:e.requestAnimationFrame(()=>{m||b||(nt(),N().activeElement===p?(B()&&(W(),w()),K(t-1)):A=null)})},q=(t,e)=>{b=[t,e];const n=t=>{if(m)return;if(S())return void K(3);const e=N().defaultView;t>0&&e&&e.requestAnimationFrame(()=>n(t-1))};n(30)},O=(e,l,o)=>{e.text!==n?(i.record({text:n,start:l[0],end:l[1]},o,r()),n=e.text,t.write(n),q(e.caret,e.caret),w()):q(e.caret,e.caret)},z=t=>R(C(n,l),t[0],t[1]),U=(e,o)=>{if(e.text===n)return;i.record({text:n,start:o[0],end:o[1]},"edit",r()),n=e.text,t.write(n);const[a,s]=L(C(n,l),e.selectionStart,e.selectionEnd);q(a,s),w()},$=t=>{if(m)return;const e=P(),[r,o]=z(e),i=X({value:n,rules:l,start:r,end:o,style:t,pending:v});if("pending"===i.kind)return v=i.pending,void w();U(i.result,e)},H=e=>{n=e.text,t.write(n),q(e.start,e.end)},Y=e=>{m||(m=!0,lt.removeEventListener("selectionchange",rt),et(p),t.end(e))},Z=(t,e)=>{const r=P();!m&&r[0]!==r[1]&&t.clipboardData&&(t.preventDefault(),t.clipboardData.setData("text/plain",C(n,l).text.slice(r[0],r[1])),t.clipboardData.setData(T,V(n,l,r[0],r[1])),e&&O(j(n,l,r[0],r[1],{text:""}),r,"edit"))},J=t=>t.preventDefault(),Q=()=>{t.remount?.()},_=[["keydown",e=>{if(m||e.isComposing)return;const l=e.metaKey||e.ctrlKey;if("Escape"!==e.key){if(l&&!e.altKey&&!e.shiftKey&&("k"===e.key||"K"===e.key)&&t.onLinkKey?.())return e.preventDefault(),void e.stopPropagation();if("Enter"===e.key&&(!e.shiftKey||l))return e.preventDefault(),e.stopPropagation(),void Y("enter");if(l&&("z"===e.key||"Z"===e.key||"y"===e.key)){e.preventDefault(),e.stopPropagation();const t=P(),l={text:n,start:t[0],end:t[1]},r="y"===e.key||e.shiftKey?i.redo(l):i.undo(l);r&&H(r)}}else{if(e.preventDefault(),e.stopPropagation(),t.onEscape?.())return;Y("escape")}}],["beforeinput",e=>{if(m)return;if("insertCompositionText"===e.inputType)return;e.preventDefault();const r=P(),o=G(p,t.skip),a="function"==typeof e.getTargetRanges?e.getTargetRanges()[0]:void 0,s=a&&!a.collapsed?[o.at(a.startContainer,a.startOffset),o.at(a.endContainer,a.endOffset)]:null,c=F({value:n,rules:l,multiline:t.multiline,inputType:e.inputType,data:e.data??e.dataTransfer?.getData("text/plain")??"",html:e.dataTransfer?.getData("text/html"),doc:N(),sel:r,target:s,pending:v&&v.at===z(r)[0]?v:null});if(c){if("type"!==c.kind&&"edit"!==c.kind||(v=null),"history"===c.kind){const t={text:n,start:r[0],end:r[1]},e="undo"===c.dir?i.undo(t):i.redo(t);return void(e&&H(e))}"format"!==c.kind?O(c.edit,c.range,c.kind):$(c.style)}}],["compositionstart",()=>{g=P()}],["compositionend",e=>{const o=g;if(g=null,!m&&o)if(e.data){const a=j(n,l,o[0],o[1],{text:e.data});i.record({text:n,start:o[0],end:o[1]},"type",r()),n=a.text,t.write(n),Q(),q(a.caret,a.caret)}else Q(),q(o[0],o[0])}],["paste",e=>{if(m)return;e.preventDefault();const r=P(),o=e.clipboardData,i=o?.getData(T)??"",a=i?t.multiline?i:i.replace(/\s*\r?\n\s*/g," "):D({html:o?.getData("text/html")??"",text:o?.getData("text/plain")??""},{doc:N(),multiline:t.multiline,rules:l});O(j(n,l,r[0],r[1],{markup:a}),r,"edit")}],["copy",t=>Z(t,!1)],["cut",t=>Z(t,!0)],["drop",J],["dragstart",J],["blur",e=>{if(m||null!==g||y)return;const n=e.target,l=n.ownerDocument.defaultView,r=()=>{m||(n.isConnected&&n===t.element()?y||n.ownerDocument.activeElement===n||Y("blur"):q(k[0],k[1]))};l?.requestAnimationFrame?l.requestAnimationFrame(r):setTimeout(r,0)}],["focus",()=>{y=!1}]];function tt(t){t.setAttribute("contenteditable","true"),t.setAttribute("spellcheck","false"),t.setAttribute("data-es-typing","");for(const[e,n]of _)t.addEventListener(e,n)}function et(t){for(const[e,n]of _)t.removeEventListener(e,n);null===M.contenteditable?t.removeAttribute("contenteditable"):t.setAttribute("contenteditable",M.contenteditable),null===M.spellcheck?t.removeAttribute("spellcheck"):t.setAttribute("spellcheck",M.spellcheck),t.removeAttribute("data-es-typing")}function nt(){const e=t.element();e&&e!==p&&(et(p),p=e,tt(p))}const lt=p.ownerDocument;function rt(){m||w()}return lt.addEventListener("selectionchange",rt),tt(p),p.focus({preventScroll:!0}),q(t.caret[0],t.caret[1]),{get value(){return n},update(t){if(t===n)return;const e=C(t,l).text.length,[r,o]=P();n=t,i.reset(),q(Math.min(r,e),Math.min(o,e))},stop(t="stop"){Y(t)},pressed(){let t;x=!0;try{t=P()}finally{x=!1}const[e,r]=z(t),i=o(n,e,r,l),s={};for(const t of["bold","italic","underline","strike","sup","sub","link"]){const n=i.has(t),l=v&&v.at===e?v:null;s[t]=!!l?.add.includes(t)||!l?.drop.includes(t)&&n}const c=v&&v.at===e&&void 0!==v.color?v:null;return{marks:s,list:a(n,e,r,l),selected:r>e,href:f(n,e,r)?.href??null,color:c?c.color??null:h(n,e,r,l)}},press:$,insert(t){if(m)return;y=!1;const e=P(),[l,r]=z(e),o=l+t.length;U({text:n.slice(0,l)+t+n.slice(r),selectionStart:o,selectionEnd:o},e),nt(),p.focus({preventScroll:!0})},hold(){m||(P(),y=!0)},release(){y=!1},resume(){m||(y=!1,nt(),p.focus({preventScroll:!0}),q(k[0],k[1]))},link(t){if(m)return;y=!1;const e=P(),[r,o]=z(e),i=null===t?u(n,r,o,l):d(n,r,o,t,l),a=i.text===n;U(i,e),nt(),p.focus({preventScroll:!0}),a&&q(e[0],e[1])},color(t){if(m)return;const e=P(),[r,o]=z(e);if(r===o){const e=v&&v.at===r?v:null;return v={add:e?.add??[],drop:e?.drop??[],color:t,at:r},void w()}U(c(n,r,o,t,l),e)},list(e){if(m||!t.multiline)return;const r=P(),[o,i]=z(r),c=a(n,o,i,l);U(s(n,o,i,c===e?null:e,l),r)}}}var Q=(t,e,n)=>Math.min(Math.max(t,e),Math.max(e,n));function _({anchor:t,size:e,within:n,clip:l,parent:r,gap:o=8}){const i=Math.max(n.left,l.left),a=Math.min(n.right,l.right)-e.width,s=Q(t.left,i,a),c=l.bottom-(t.bottom+o),u=t.top-o-l.top,d=e.height>c&&(e.height<=u||u>c),h=d?t.top-o-e.height:t.bottom+o,f=t.left+Math.min((t.right-t.left)/2,10),p=Q(f-5-s,10,e.width-10-10);return{top:h-r.top,left:s-r.left,above:d,point:p}}var tt=t=>({left:t.left,top:t.top,right:t.right,bottom:t.bottom});function et(t,e){const n=("function"==typeof t.getClientRects?[...t.getClientRects()]:[]).filter(t=>t.height>0);if(n.length>0){const e="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():n[0];return e.height>0?tt(e):tt(n[0])}if(!e)return null;const l=e.getBoundingClientRect();return{left:l.left,top:l.top,right:l.left,bottom:l.bottom}}function nt(t){const e=t.ownerDocument,n=e.documentElement,l={left:0,top:0,right:n.clientWidth,bottom:n.clientHeight},r=e.defaultView?.getComputedStyle.bind(e.defaultView);for(let o=t.parentElement;o&&o!==n&&o!==e.body;o=o.parentElement){const t=r?.(o);if(!t||"visible"===t.overflowX&&"visible"===t.overflowY)continue;const e=o.getBoundingClientRect();if(0===e.width&&0===e.height)continue;const n=e.left+o.clientLeft,i=e.top+o.clientTop;l.left=Math.max(l.left,n),l.top=Math.max(l.top,i),l.right=Math.min(l.right,n+(o.clientWidth||e.width)),l.bottom=Math.min(l.bottom,i+(o.clientHeight||e.height))}return l}function lt(t){const e=t.offsetParent??t.parentElement;if(!e)return{left:0,top:0};const n=e.getBoundingClientRect();return{left:n.left+e.clientLeft-e.scrollLeft,top:n.top+e.clientTop-e.scrollTop}}function rt(t,e,n){const l=t.ownerDocument,r=l.createTreeWalker(t,4),o=t=>{let e=t,n=null;for(let t=r.nextNode();t;t=r.nextNode()){if(e<=t.data.length)return[t,e];e-=t.data.length,n=t}return n?[n,n.data.length]:null},i=o(e);r.currentNode=t;const a=o(n);if(!i||!a)return null;const s=l.createRange();return s.setStart(i[0],i[1]),s.setEnd(a[0],a[1]),s}export{$ as ColorWindow,T as MARKUP_CLIPBOARD_TYPE,O as TYPING_BURST_MS,U as colorRunOf,I as createHistory,j as editVisible,X as markPress,V as markupOfRange,P as newLine,lt as offsetOrigin,D as pasteToMarkup,_ as placeWindow,F as richInput,C as richLayout,et as selectionBox,R as selectionToSource,L as selectionToVisible,K as setBullet,J as startCanvasTyping,G as textMap,rt as textRange,S as toSource,A as toSourceStart,B as toVisible,nt as visibleArea};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{editLockOf as e}from"./chunk-GMCZXMOV.js";import{isExpiredSession as r,readEaselFailure as n}from"./chunk-CLOS6SSX.js";import{routeSharedHostMessage as t}from"./chunk-S4AWJX4Q.js";import{describeLoadFailure as o,hostLoadRefusal as u}from"./chunk-ERR437B5.js";import{useAdminBridge as a}from"./chunk-VPFNZ7TB.js";import{NO_DOCUMENT_ADDRESSING as s}from"./chunk-RLBXE4EU.js";import{saveStatusOf as i,resetForDocumentSwitch as l}from"./chunk-HNKB2ZYR.js";import{STATUS_UNREACHABLE as c}from"./chunk-KCOBHPN6.js";import{useEaselSession as d}from"./chunk-O7Q4DDJT.js";import{backendOf as f,setSessionDocumentSite as m}from"./chunk-RSCMJIWS.js";import{useEaselHost as k}from"./chunk-U3JP4VGF.js";import{DEFAULT_SCREEN_WORDS as g}from"./chunk-VWXUMVCD.js";import{useAutosave as v}from"./chunk-NDRZP6YR.js";import{canWriteDocument as p,newEaselClientId as h,reloadIfVersionMoved as y,openUnansweredClaim as w,FAIL_OPEN_RETRY_MS as S,CLAIM_FAIL_OPEN_MS as b,holderOf as P}from"./chunk-THWO5YVZ.js";import{useWords as I}from"./chunk-MFIRYGHW.js";import{createContext as j,useContext as R,useState as B,useMemo as C,useCallback as O,useEffect as H,useRef as E}from"react";import{jsx as T}from"react/jsx-runtime";var D={content:[],root:{},zones:{}};var M=j(null);function V(){const e=R(M);if(!e)throw new Error("useStorefrontDocument must be used within StorefrontDocumentProvider");return e}function A({target:j,addressing:R=s,onHostMessage:V,children:A}){const N=R,{homeSlug:F,entryMayBounce:L,entryBounce:W,onSwitch:U,tellsHost:X,adapterFor:Y,migrateRenamedProps:Z,describeMissing:J,onLoadFailed:x}=N,[G,K]=B(j),Q=k(),z=d(),_=C(()=>f(z),[z]),q=C(()=>e(z),[z]),$="template"===G.kind,ee="template"===G.kind?G.id:null,re="template"===G.kind?G.pageSlug??F??"":"document"===G.kind?G.slug??"":G.slug,ne="page"===G.kind?G.siteId??null:null,te=z.blocks,oe=C(()=>Y(G,_,te),[Y,_,te,G.kind,"template"===G.kind?G.id:"document"===G.kind?G.record:G.siteId]),ue=oe.capabilities,ae=O(e=>z.documentHooks?.stored?.(e)??e,[z]),se="page"===G.kind?G.originSlug??null:null;H(()=>{m(z,ne)},[z,ne]);const ie=E(G);H(()=>{ie.current=G},[G]);const{token:le,tokenRef:ce,capabilities:de}=a({onMessage:e=>{if(V?.(e)||t(e))return;const r=e;if("storefront-editor:navigate"===r?.type){const r=e;r?.target&&Cr(r.target)}}}),fe=!z.usesBridgedToken||null!==le,me=oe.lock,ke=Boolean(_.lock),[ge,ve]=B(null),[pe,he]=B(null),[ye,we]=B(null),[Se,be]=B(null),Pe=I("screen",g),Ie=Se?function(e,r){if(null!==e.sentence)return e.sentence;if(!e.missing)return r.loadFailed({cause:e.cause});switch(e.target.kind){case"template":return r.missingTemplatePage;case"document":return r.missingDocument;default:return r.missingPage({slug:e.slug})}}(Se,Pe):null,[je,Re]=B(null),Be=E(null),Ce=E(null),[Oe,He]=B(!1),Ee=E(null),[Te,De]=B(null),Me=E(null),[Ve,Ae]=B(null),[Ne,Fe]=B(!1),Le=E(null);H(()=>{Le.current=Ve},[Ve]);const[We,Ue]=B(ue.hasEditLock?{kind:"checking"}:{kind:"editing"}),Xe=E(We);H(()=>{Xe.current=We},[We]);const Ye=E(()=>Promise.resolve(!1)),Ze=O(e=>{Ce.current=e,He(!0)},[]),Je=v({save:async({id:e,data:r})=>{if(p(Xe.current)){if(!await Ye.current(e,r)){if(!p(Xe.current))return void Ze({id:e,data:r});throw new Error("page save did not land")}}else Ze({id:e,data:r})},onFailure:(e,r)=>{0===r&&Q.send("storefront-editor:save-failed")}}),{state:xe,push:Ge,flush:Ke,pause:Qe,resume:ze,stop:_e,reset:qe,retryNow:$e,hasPending:er}=Je,rr=E(xe);H(()=>{rr.current=xe},[xe]);const nr=i(xe),tr=O(()=>{const e=Ce.current;e&&(Ce.current=null,He(!1),Ge(e))},[Ge]),or=E("");or.current||(or.current=h());const[ur,ar]=B(0),sr=E(!1),[ir,lr]=B(L(j)),cr=E(!1);H(()=>{if(cr.current)return;cr.current=!0;const e=Q.address.search(),r=W(j,e);r?Q.address.load(r):L(j)&&lr(!1)},[j,Q]);const dr=Q.send;H(()=>{if(!fe)return;let e=!1;const r=ie.current,n=oe.resolve(re),t=z.documentHooks?.opening?.({slug:re,isTemplate:$,capabilities:ue});return n.then(async n=>{if(e)return;if(!n)return"page"===r.kind&&null!==F&&re!==F?void Q.address.load({kind:"page",slug:F,siteId:ne??void 0}):(be({target:r,slug:re,missing:!0,sentence:J?.(r)??null}),void x?.(r,null));const o=n.readOnlyReason?n.readOnlyReason:null;Be.current=o,Re(o),ve(n.id),he(n.kind??null),Me.current=n.version??null;const u=n.layout,a=u&&Object.keys(u).length?u:D,s=Z(a),i=t?await t(s):s;e||we(i)}).catch(n=>{e||(console.error("[storefront-editor] document load failed",n),be({target:r,slug:re,missing:!1,sentence:u(n,{slug:re},z),cause:o(n,z)}),x?.(r,n))}),()=>{e=!0}},[fe,le,$,oe,re]);const fr=O(e=>new Promise(r=>{const n=Date.now(),t=setInterval(()=>{const o=ce.current;o&&o!==e?(clearInterval(t),r(o)):Date.now()-n>6e3&&(clearInterval(t),r(null))},200)}),[]),mr=O(async e=>{const n=ce.current;if(!n&&z.usesBridgedToken)return{ok:!1,error:new Error("no editor token")};try{return{ok:!0,value:await e(n??"")}}catch(t){if(r(t,z)){dr("storefront-editor:auth-expired");const r=n?await fr(n):null;if(r)try{return{ok:!0,value:await e(r)}}catch(e){return{ok:!1,error:e}}}return{ok:!1,error:t}}},[dr,fr,z]),kr=O(async e=>{const r=ce.current?await mr(e):{ok:!1};return r.ok||dr("storefront-editor:save-failed"),r.ok},[dr,mr]),gr=O(async(e,r,t=!1)=>{if(null!==Be.current)return!1;if(!p(Xe.current))return!1;if(Le.current)return!1;const o=await mr(()=>oe.saveLayout(e,r,Me.current,or.current));if(o.ok)return Me.current=o.value.version??Me.current,Fe(!1),!0;const u=q.readLockTaken(o.error);if(u){const e={kind:"takenover",holder:u};return Xe.current=e,Ue(e),!1}const a=q.readSaveConflict(o.error);if(a){if(a.savedByYou&&!t&&oe.rereadVersion){const n=await mr(()=>oe.rereadVersion(e));if(n.ok&&n.value)return Me.current=n.value,Ye.current(e,r,!0)}_e(),Le.current=a,Ae(a)}return Fe(n(o.error,z)?.status===c),!1},[oe,mr,_e,z]);H(()=>{Ye.current=gr},[gr]);const vr=O(e=>{if(null!==Be.current)return;if(dr("storefront-editor:dirty"),!ge)return;const r=ae(e);Ee.current=r,p(Xe.current)?Ge({id:ge,data:r}):Ze({id:ge,data:r})},[ge,dr,Ze,Ge,ae]),pr=O(async()=>{p(Xe.current)&&tr();return await Ke()&&null==Ce.current},[tr,Ke]),hr=E(pr);H(()=>{hr.current=pr},[pr]);const yr=E(mr);H(()=>{yr.current=mr},[mr]);const wr=O(()=>{Q.address.reload()},[Q]),Sr=E(()=>Promise.resolve(!1));H(()=>{Sr.current=()=>{const e=oe.rereadVersion;return ge&&e?y({ours:Me.current,stored:async()=>{const r=await yr.current(()=>e(ge));return r.ok?r.value:null},hasPending:()=>null!=Ce.current||er(),reload:wr}):Promise.resolve(!1)}},[oe,ge,er,wr]);const br=null!==je;H(()=>{if(!me||!ge||!fe||br)return;let e=!1,r=null,n=null;const t=or.current,o={claim:async e=>{const r=await yr.current(()=>me.claim(ge,t,e));if(r.ok)return{heartbeat_seconds:r.value.heartbeatSeconds};throw r.error},cancelled:()=>e,currentAccess:()=>Xe.current,heldWrite:()=>({pending:null!=Ce.current||er(),autoSaveEnabled:!rr.current.paused,saveConflict:null!=Le.current}),setAccess:e=>{Xe.current=e,Ue(e)},releaseHeldWrite:()=>{hr.current()},startHeartbeat:e=>{r&&clearInterval(r),r=setInterval(()=>{u(!1)},e)},stopHeartbeat:()=>{r&&(clearInterval(r),r=null)},reloadIfMoved:()=>{Sr.current()}},u=q.makeClaimBeat(o),a=sr.current;return sr.current=!1,a||(Ue({kind:"checking"}),n=setTimeout(()=>{n=null,w(o)&&o.startHeartbeat(S)},b)),u(a).finally(()=>{n&&clearTimeout(n),n=null}),()=>{e=!0,n&&clearTimeout(n),r&&clearInterval(r),me.release(ge,t).catch(()=>{})}},[ge,me,fe,le,ur,br]);const Pr=O(()=>{me&&ge&&(sr.current=!0,ar(e=>e+1))},[ge,me]),Ir=O(()=>{Ue(e=>{const r="blocked"===e.kind||"takenover"===e.kind?e.holder:null;return r?{kind:"readonly",holder:r}:e})},[]),jr=O(()=>{rr.current.paused?(p(Xe.current)&&tr(),ze()):Qe()},[tr,Qe,ze]),Rr=O(()=>{$e()},[$e]),Br=O(e=>{Ee.current=null,l("template"!==e.kind&&ke,{resetAutosave:()=>{qe(),Ce.current=null,He(!1)},setVersion:e=>{Me.current=e},setSaveConflict:Ae,setAccess:Ue}),U(e),K(e),Be.current=null,Re(null),ve(null),he(null),we(null),be(null),Q.address.show(e),"document"!==e.kind&&X(e)&&Q.send("storefront-editor:navigated",{target:e})},[qe,Q,ke,U,X]),Cr=O(e=>{if(function(e,r,n){if(e.kind!==r.kind)return!1;if("template"===e.kind){const t=r;return e.id===t.id&&(e.pageSlug??n)===(t.pageSlug??n)}if("document"===e.kind){const n=r;return e.record===n.record&&(e.slug??"")===(n.slug??"")}const t=r;return e.slug===t.slug&&e.siteId===t.siteId}(e,ie.current,F))return;const r=null!=Ce.current;if(!r&&!er())return void Br(e);const n=rr.current;r||n.paused||n.failed||n.stopped?De(e):Ke().then(r=>{r?Br(e):De(e)})},[Br,er,Ke,F]),Or=O(()=>De(null),[]),Hr=O(()=>{De(e=>(e&&Br(e),null))},[Br]),Er=O(async()=>{const e=Te;if(!e)return;await pr()&&(De(null),Br(e))},[Te,pr,Br]),Tr=O(async e=>{if(null!==Be.current)return;if(!ge)return;if(!p(Xe.current)||Le.current)return;const r=ae(e);if(!await gr(ge,r))return void(Le.current||dr("storefront-editor:save-failed"));const n=oe.publish;if(!ue.canPublish||!n)return void dr("storefront-editor:saved");const t=await mr(()=>n(ge,Me.current??void 0));t.ok?(Me.current=t.value.version??Me.current,dr("storefront-editor:published")):dr("storefront-editor:save-failed")},[ge,oe,ue.canPublish,dr,gr,mr,ae]);/* @__PURE__ */
|
|
2
|
+
return T(M.Provider,{value:{target:G,adapter:oe,capabilities:ue,templateId:ee,currentSlug:re,currentKind:pe,siteId:ne,ready:fe,token:le,tokenRef:ce,notifyParent:dr,bridgeCapabilities:de,runAuthed:kr,docId:ge,data:ye,getLiveData:()=>Ee.current??ye,footerOriginSlug:se,error:Ie,redirecting:ir,saveStatus:nr,saveState:xe,autoSaveEnabled:!xe.paused,autoSaveStoppedByConflict:xe.stopped,hasUnsavedEdits:xe.pending||Oe,toggleAutoSave:jr,retrySave:Rr,onChange:vr,flushSave:pr,onPublish:Tr,access:We,readOnly:null!==P(We)||null!==je||null!==Ve,readOnlyReason:je,takeOverEditing:Pr,viewReadOnly:Ir,saveConflict:Ve,saveUnreachable:Ne,reloadFromServer:wr,navigate:Cr,pendingNav:Te,cancelPendingNav:Or,discardAndNavigate:Hr,saveAndNavigate:Er},children:A})}export{M as ScreenDocumentContext,A as ScreenDocumentProvider,V as useScreenDocument};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={add:{stop:"Stop adding here",hint:"Drag onto the page.",search:"Search blocks",searchPlaceholder:({label:e})=>`${e}…`,clearSearch:"Clear search",nothing:({query:e})=>`Nothing matches “${e}”`,tryAnother:"Try another word.",tile:({label:e})=>`Add ${e}`},canvas:{addSection:"Add section",addBlock:"Add block",addButton:({label:e})=>`+ ${e}`,handle:({label:e})=>`Drag to move this ${e.toLowerCase()}`}};export{e as DEFAULT_DRAG_WORDS};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{buildPaletteSections as e,pinnedSection as t,categoryLabel as o}from"./chunk-PA3PNTVV.js";import{blockTypesIn as n}from"./chunk-5ZBY24K7.js";import{sectionTemplatesOf as s}from"./chunk-BVN33R76.js";import{SidePanelHead as i,PanelModeExit as r}from"./chunk-PPL7GB7D.js";import{useEaselSession as l}from"./chunk-O7Q4DDJT.js";import{blockRuns as c}from"./chunk-HQ4VVRIC.js";import{useScreenBlockLook as a,useScreenBlockRules as p}from"./chunk-OHRS7Q3E.js";import{DEFAULT_SCREEN_WORDS as m}from"./chunk-VWXUMVCD.js";import{useEasel as d}from"./chunk-I55LUW3C.js";import{useWords as f}from"./chunk-MFIRYGHW.js";import{AddPanel as y}from"./chunk-47RGVCPH.js";import{DEFAULT_DRAG_WORDS as h}from"./chunk-GG4FGBFR.js";import{useState as u,useEffect as k,useMemo as b}from"react";import{AddIcon as g}from"efficient-shell/icons/efficient";import{jsx as j,jsxs as v,Fragment as V}from"react/jsx-runtime";var B=e=>`section:${e}`,O=e=>`block:${e}`,R=e=>`template:${e}`;function $({at:$,placeBlocks:w,canTake:C,onPick:E,itemFor:G,session:H,siteWide:I,onClose:L,onHide:P,readOnly:x}){const D=d(e=>e.config),F=a(),{labelAtLevel:T,categoryLabel:W,firstSection:A,Icon:N,Thumbnail:M}=F,{blockIsOffered:Q,canAddTo:S}=p(),z=f("screen",m).add,U=f("drag",h).add,Y=l(),[J,K]=u([]);k(()=>{let e=!1;const t=e=>Q(e,Y);return s(Y).list().then(o=>{if(e)return;const s=D.components;K(o.filter(e=>e.node?.type&&s[e.node.type]&&n(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[D,Y]);const X=b(()=>e(D,F),[D]),Z=e=>({type:B(e.type),label:e.name,cover:/* @__PURE__ */j(M,{type:e.type}),title:e.desc?`${e.name} — ${e.desc}`:z.tile({name:e.name}),keywords:[e.alias??"",e.desc,e.type,e.catLabel].filter(Boolean)}),q=e=>{const t=e.indexOf(":"),o=e.slice(0,t),n=e.slice(t+1);if("section"===o)return{kind:"section",type:n};if("block"===o)return{kind:"block",type:n};if("template"===o){const e=J.find(e=>e.id===n);return e?{kind:"template",template:e}:null}return null},_=e=>/* @__PURE__ */j("span",{className:"es-add-glyph-cover",children:/* @__PURE__ */j(N,{type:e,size:26})}),ee=b(()=>{const e=t(X,A),n=/* @__PURE__ */new Map,s=e=>{!n.has(e.type)&&Q(e.type,Y)&&n.set(e.type,e)};for(const t of e?[e]:X){const e=S(t.type)?.choices??[];e.forEach(s),e.forEach(e=>S(e.type,1)?.choices?.forEach(s))}w?.forEach(s);const i=new Set(X.map(e=>e.type)),r=[...n.values()].filter(e=>!i.has(e.type)),l=e=>({type:O(e.type),label:e.label,cover:_(e.type),title:z.tile({name:e.label}),keywords:[e.group??"",e.type].filter(Boolean)}),a=e=>n.has(e.type)?{...Z(e),cover:_(e.type)}:Z(e),p=[];J.length>0&&p.push({key:"templates",title:z.templates,tiles:J.map(e=>{return{type:R(e.id),label:e.name,cover:/* @__PURE__ */j(M,{type:e.node.type}),keywords:[(t=e.node.type,T(t,"section",D.components[t]?.label??t)),e.node.type]};var t})});const m=r.filter(e=>!e.group);let d=!1;for(const t of Object.keys(D.categories??{})){const n=X.filter(e=>e.cat===t);if(0===n.length)continue;const s=e&&n.some(t=>t.type===e.type)?e:null,i=(s?[s,...n.filter(e=>e.type!==s.type)]:n).map(a);s&&!d&&(i.splice(1,0,...m.map(l)),d=!0),p.push({key:`category:${t}`,title:o(D,t,W),tiles:i})}const f=p.find(e=>e.key?.startsWith("category:"));if(!d&&f&&m.length>0&&(f.tiles=[...f.tiles,...m.map(l)],d=!0),c(r.filter(e=>e.group||!d)).forEach((e,t)=>{p.push({key:`blocks:${t}`,title:e.group??"",tiles:e.items.map(l)})}),!C)return p;const y=p.map(e=>({...e,tiles:e.tiles.map(e=>{const t=q(e.type),o=t?C(t):null;return o?{...e,disabled:!0,disabledReason:o}:e})})),h=e=>e.tiles.some(e=>!e.disabled);return[...y.filter(h),...y.filter(e=>!h(e))]},[J,X,D,z,C,w,Y]);/* @__PURE__ */
|
|
2
|
+
return v(V,{children:[
|
|
3
|
+
/* @__PURE__ */j(i,{icon:/* @__PURE__ */j(g,{size:15}),title:z.title,context:z.contextAll,actions:/* @__PURE__ */j(r,{label:z.done,description:z.doneDescription,onClick:L}),onHide:P}),
|
|
4
|
+
/* @__PURE__ */v("div",{className:"sf-addside sf-scroll",children:[
|
|
5
|
+
/* @__PURE__ */j(y,{groups:ee,session:H,itemFor:e=>G(q(e)??{kind:"section",type:e}),onInsert:E?e=>{const t=q(e);t&&E(t)}:void 0,at:$,hint:z.hint,searchLabel:z.search,readOnly:x,words:U}),I??null]})]})}export{$ as AddSidePanel,O as blockKey,B as sectionKey,R as templateKey};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import{DEFAULT_CANVAS_WORDS as e}from"./chunk-TBY3DFKS.js";import{useResolvedFields as t}from"./chunk-YRLPFZW3.js";import{toItemSelector as n,fromItemSelector as o,useNodeOps as r,parentStep as i,clickPick as l}from"./chunk-ECM5F6JJ.js";import{selectionBox as s,placeWindow as a,offsetOrigin as c,colorRunOf as d,ColorWindow as u,startCanvasTyping as p,textMap as f}from"./chunk-FGJSCWUN.js";import{DEFAULT_COPY_WORDS as h}from"./chunk-Q6AM43CA.js";import{useWords as m}from"./chunk-MFIRYGHW.js";import{setCanvasNonce as g,isTypingTarget as v,frameRectToHost as y,CANVAS_TYPING_EVENT as w,drawnBox as b}from"./chunk-ILXP5VX5.js";import{find as k,ROOT_ID as S,getList as C,remove as I,parseZoneKey as E,move as x,duplicate as D,replaceNode as M,createNode as A,insert as O,normalizeData as R,createResolveCache as P,resolveNodeData as B,ROOT_SLOT as N}from"./chunk-KRXQM65X.js";import{topLevelSlotKeys as $,fieldsFrom as z,defaultsFrom as K}from"./chunk-NKB3KVAB.js";import{createContext as L,useEffect as j,useContext as V,useRef as Z,useSyncExternalStore as F,useState as T,useMemo as H,useCallback as W,useLayoutEffect as q}from"react";import{jsx as Y,jsxs as X,Fragment as U}from"react/jsx-runtime";import{createPortal as J}from"react-dom";import{registerModalEscapeInterceptor as G,FloatingBar as Q,TextToolbar as _,LinkPicker as ee}from"efficient-shell/ui";function te(e){return!["setData","setUi","set"].includes(e.type)}var ne=(e,t,n,o)=>{const r=C(e,t,E(n));return r?.[o]??null},oe=(e,t,n,o,r)=>{const i=ne(e,t,n,o);if(!i)throw new Error(`${r}: nothing at ${n}[${o}]`);return i};function re(e,t){const{selection:o}=e;return{...e.ui,itemSelector:n(e.data,t,o),selectedSlot:o&&"slot"===o.kind?{parentId:o.parentId,slot:o.slot}:null}}function ie(e,t,n){return n?"node"===n.kind?k(e,t,n.id)?n:null:n.parentId===S?C(e,t,n)?n:null:k(e,t,n.parentId)&&C(e,t,n)?n:null:null}function le(e,t,n,r=!1){const{itemSelector:i,selectedSlot:l,...s}=n;let a=e.selection;var c;return"itemSelector"in n&&(a=o(e.data,t,i??null)),"selectedSlot"in n&&(l?a=(c=l)?{kind:"slot",parentId:c.parentId,slot:c.slot}:null:"slot"===a?.kind&&(a=null)),{...e,selection:a,ui:r?s:{...e.ui,...s}}}function se(e,t,n){const o=ae(e,t,n);if(o===e)return e;const r=ie(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function ae(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 le(e,n,"function"==typeof t.ui?t.ui(re(e,n)):t.ui);case"set":{const r={data:o,ui:re(e,n)},i="function"==typeof t.state?t.state(r):t.state;let l=i.data?{...e,data:i.data}:e;return i.ui&&(l=le(l,n,i.ui,!0)),l}case"insert":{const r={...E(t.destinationZone),index:t.destinationIndex},i=A(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:O(o,n,r,i)}}case"replace":{const r=oe(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:M(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=oe(o,n,t.sourceZone,t.sourceIndex,"duplicate"),i=D(o,n,r.props.id),l=ne(i,n,t.sourceZone,t.sourceIndex+1);return{...e,data:i,selection:l?{kind:"node",id:l.props.id}:e.selection}}case"reorder":return ae(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=ne(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const i={...E(t.destinationZone),index:t.destinationIndex};return{...e,data:x(o,n,r.props.id,i)}}case"remove":{const r=oe(o,n,t.zone,t.index,"remove");return{...e,data:I(o,n,r.props.id)}}default:return e}}var ce={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},de={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},ue=0,pe=()=>`history-${ue+=1}`;function fe(e){let t=e.config;const r=e.now??(()=>Date.now()),i=e.historyCoalesceMs??250;let l=e.permissions??{};const s=R(e.data,t);let a={data:s,selection:null,ui:{...de}};if(e.ui){const{itemSelector:n,selectedSlot:r,...i}=e.ui;a={data:s,selection:r?{kind:"slot",...r}:o(s,t,n??null),ui:{...de,...i}}}let c=[{core:a,at:-1/0,sealed:!0,id:pe()}],d=0;const u=e=>{const t=c[d],n=r();!e&&d===c.length-1&&d>0&&!t.sealed&&n-t.at<i?c=[...c.slice(0,d),{...t,core:a,at:n}]:(c=[...c.slice(0,d+1),{core:a,at:n,sealed:e,id:pe()}],d=c.length-1)},p=/* @__PURE__ */new Set;let f=null,h=null,m=0,g=null,v=!1;const y=()=>{for(const e of[...p])e()},w=()=>{c=[...c.slice(0,d),{...c[d],core:a},...c.slice(d+1)]},b=(t,n)=>{m>0?v=v||n:(n?u(!1):a!==t&&w(),a.data!==t.data&&e.onChange?.(a.data),a!==t&&y())},S=e=>{const n=a;if(a=se(a,e,t),a===n)return;const o=e.recordHistory??te(e);b(n,o&&a.data!==n.data)},I=t=>{0===m&&(g=a,v=!1),m+=1;try{t()}catch(e){throw m-=1,0===m&&g&&(a=g,g=null),e}if(m-=1,m>0||!g)return;const n=g;g=null,v&&a.data!==n.data?u(!0):a!==n&&w(),a.data!==n.data&&e.onChange?.(a.data),a!==n&&y()},E=e=>{const n=a,o=ie(a.data,t,e);var r,i;(r=o,i=a.selection,r===i||r&&i&&r.kind===i.kind&&("node"===r.kind&&"node"===i.kind?r.id===i.id:"slot"===r.kind&&"slot"===i.kind&&r.parentId===i.parentId&&r.slot===i.slot))||(a={...a,selection:o},b(n,!1))},x=t=>{const n=a;d=t,a=c[d].core,a.data!==n.data&&e.onChange?.(a.data),a!==n&&y()},D=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...ce,...l,...n}};let A=D();const O=P(),N={resolveCache:O,async resolveAll({trigger:e="load",metadata:n}={}){const o=a.data,r={type:"root",props:{...o.root.props??{}}},i=[...o.content,...Object.values(o.zones??{}).flat()],[l,...s]=await Promise.all([B(r,t,{cache:O,trigger:e,metadata:n}),...i.map(o=>B(o,t,{cache:O,trigger:e,metadata:n}))]);I(()=>{const e=a;let n=a.data;s.forEach((e,r)=>{if(!e.didChange)return;const l=i[r].props.id,s=k(n,t,l)?.node;s&&s===k(o,t,l)?.node&&(n=M(n,t,l,e.node))}),l.didChange&&n.root===o.root&&(n={...n,root:{...n.root,props:l.node.props,readOnly:l.node.readOnly??n.root.readOnly}}),n!==a.data&&(a={...a,data:n,selection:ie(n,t,a.selection)},b(e,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=k(a.data,t,e)?.node;if(!r)return!1;const i=await B(r,t,{cache:O,trigger:n,metadata:o});if(!i.didChange)return!1;let l=!1;return I(()=>{const n=a;if(k(a.data,t,e)?.node!==r)return;const o=M(a.data,t,e,i.node);o!==a.data&&(a={...a,data:o,selection:ie(o,t,a.selection)},b(n,!1),l=!0)}),l},get config(){return t},getState(){if(f&&h===a)return f;const e=a,o={data:e.data,ui:re(e,t)},r="node"===e.selection?.kind?k(e.data,t,e.selection.id)?.node??null:null;return f={appState:o,selection:e.selection,selectedItem:r,config:t,dispatch:S,history:{back:()=>N.undo(),forward:()=>N.redo(),hasPast:d>0,hasFuture:d<c.length-1,histories:c.map(e=>({id:e.id,state:{data:e.core.data,ui:re(e.core,t)}})),index:d,setHistoryIndex:e=>{e>=0&&e<c.length&&e!==d&&x(e)}},getPermissions:A,getItemById:n=>k(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return C(e,t,{parentId:o,slot:r})?.[n.index]}(e.data,t,n),getSelectorForId:o=>{const r=n(e.data,t,{kind:"node",id:o});return r?{index:r.index,zone:r.zone??"root:default-zone"}:void 0}},h=e,f},subscribe:e=>(p.add(e),()=>{p.delete(e)}),dispatch:S,batch:I,group:()=>{const e=d,t=c[e].id;let n=!0;return{close:()=>{if(!n)return;if(n=!1,c[e]?.id!==t)return;if(d<=e+1)return void(d===e+1&&(c=[...c.slice(0,d),{...c[d],sealed:!0},...c.slice(d+1)]));const o=c[d];c=[...c.slice(0,e+1),{...o,sealed:!0},...c.slice(d+1)],d=e+1}}},select:e=>E(e?{kind:"node",id:e}:null),selectSlot:e=>E(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){I(()=>{const n=a,o=void 0===e.select?a.selection:e.select;a={...a,data:e.data,selection:ie(e.data,t,o)},b(n,e.data!==n.data)})},load(e,n={}){const o=a,r=R(e,t);a={...a,data:r,selection:ie(r,t,n.selection??a.selection)},n.keepHistory||(c=[{core:a,at:-1/0,sealed:!0,id:pe()}],d=0),a!==o&&y()},undo(){d>0&&x(d-1)},redo(){d<c.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,l)||(l=e,A=D(),f=null,y())},setConfig(e){e!==t&&(t=e,A=D(),f=null,y())}};return N}function he(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&&v(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 me=L(null),ge=L(!0);function ve({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return j(()=>{n&&e.resolveAll()},[e,n]),j(()=>{if(t&&"undefined"!=typeof document)return he(document,e)},[e,t]),/* @__PURE__ */Y(me.Provider,{value:e,children:/* @__PURE__ */Y(ge.Provider,{value:t,children:o})})}function ye(){const e=V(me);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function we(e){const t=ye(),n=Z({view:null,selector:null,value:void 0,has:!1}),o=()=>{const o=t.getState(),r=n.current;if(r.has&&r.view===o&&r.selector===e)return r.value;const i=e(o);return r.has&&Object.is(r.value,i)?(n.current={view:o,selector:e,value:r.value,has:!0},r.value):(n.current={view:o,selector:e,value:i,has:!0},i)};return F(t.subscribe,o,o)}function be(){return function(e){return we(e)}}var ke="data-puck-component",Se="data-puck-dropzone",Ce={},Ie="data-es-mirror",Ee="undefined"==typeof window?j:q;function xe(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${Ie}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(Ie,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function De({children:t,id:n="preview-frame",title:o,className:r,style:i,mirrorStyles:l=!0,onDocument:s,height:a="auto",nonce:c}){const d=m("canvas",e),u=Z(null),[p,f]=T(null);return Ee(()=>{const e=u.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]),Ee(()=>{let e=u.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=u.current?.contentDocument??e),e.body||e.documentElement.appendChild(e.createElement("body")),e.body.style.margin="0";const t=e.createElement("div");t.setAttribute("data-puck-entry",""),t.id="frame-root","fill"===a&&t.classList.add("es-frame-fill"),e.body.appendChild(t),g(e,c),f(t),s?.(e);let n=null;const o=u.current?.ownerDocument;if(l&&o){xe(o,e,c);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>xe(o,e,c)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}return()=>{n?.disconnect(),t.remove(),f(null),s?.(null)}},[]),/* @__PURE__ */Y("iframe",{ref:u,id:n,title:o??d.frame,className:["es-canvas-frame","fill"===a?"is-fill":"",r??""].filter(Boolean).join(" "),style:i,children:p?J(t,p):null})}var Me=L(null),Ae=L(Ce),Oe=[];function Re({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:i=120}){const l=ye(),s=we(n=>C(n.appState.data,l.config,{parentId:e,slot:t})??Oe),a=we(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==S),c=we(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),d=V(Me),u=["es-zone"];return s.length&&u.push("has-children"),e===S&&u.push("is-root"),(a||c)&&u.push("is-area-selected"),null!==d&&d===e&&e!==S&&u.push("is-hovering-area"),n&&u.push(n),/* @__PURE__ */Y("div",{className:u.join(" "),[Se]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${i}px`},children:s.map(e=>/* @__PURE__ */Y(Ne,{node:e},e.props.id))})}function Pe(e,t){return H(()=>{const n={};for(const o of $(z(e)))n[o]=function(e={}){/* @__PURE__ */
|
|
2
|
+
return Y(Re,{parentId:t,slot:o,...e})};return n},[e,t])}function Be(e){return H(()=>function({zone:t,...n}){/* @__PURE__ */
|
|
3
|
+
return Y(Re,{parentId:e,slot:t,...n})},[e])}function Ne({node:e}){const t=ye().config.components[e.type],n=e.props.id,o=function(e){const t=Z(null);return H(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(ke),o.removeAttribute("data-puck-dnd")),t.current=n,n&&(n.setAttribute(ke,e),n.setAttribute("data-puck-dnd",e),n.style.position="relative")},[e])}(n),r=V(Ae),i=Pe(t,n),l=Be(n);if(!t?.render)return null;const s=t.render,a={...K(t),...e.props,...i},c={renderDropZone:l,isEditing:!0,dragRef:t.inline?o:null,metadata:{...r,...t.metadata}};return t.inline?/* @__PURE__ */Y(s,{...a,puck:c,editMode:!0}):/* @__PURE__ */Y("div",{[ke]:n,"data-puck-dnd":n,style:{position:"relative"},children:/* @__PURE__ */Y(s,{...a,puck:c,editMode:!0})})}function $e({metadata:e}){const t=we(e=>e.config),n=we(e=>e.appState.data.root).props??{},o=t.root?.render,r=Pe(t.root,S),i=Be(S),l=/* @__PURE__ */Y(Re,{parentId:S,slot:N}),s=o?/* @__PURE__ */Y(o,{id:"puck-root",...n,...r,puck:{renderDropZone:i,isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:l}):l;/* @__PURE__ */
|
|
4
|
+
return Y(Ae.Provider,{value:e??Ce,children:s})}var ze=L(void 0);function Ke(e,t,n){const[o,r]=T(null),i=Z(t);return i.current=t,Ee(()=>{const t=e.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!i.current)return void r(null);let o=0;const l=()=>{o=0;const n=function(e,t){if(!e||!t)return null;const n=b(e),o=t.getBoundingClientRect();return{top:n.top-o.top,left:n.left-o.left,width:n.width,height:n.height}}(i.current?i.current(t):null,e.current?.parentElement??null);r(e=>{return(t=e)===(o=n)||t&&o&&t.top===o.top&&t.left===o.left&&t.width===o.width&&t.height===o.height?e:n;var t,o})},s=()=>{o||(o=(n.requestAnimationFrame??(e=>n.setTimeout(e,16)))(l))};l();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),()=>{a?.disconnect(),c?.disconnect(),n.removeEventListener("resize",s),o&&(n.cancelAnimationFrame??n.clearTimeout)(o)}},[n]),o}function Le({id:e,kind:t,overlay:n}){const o=Z(null),r=Ke(o,e?t=>t.querySelector(`[${ke}="${t.defaultView?.CSS?.escape?t.defaultView.CSS.escape(e):e}"]`):null,e),i=/* @__PURE__ */Y("div",{ref:o,"aria-hidden":"true",className:`es-canvas-outline is-${t}`,style:r?{position:"absolute",top:r.top,left:r.left,width:r.width,height:r.height}:{display:"none"}});return n&&e?/* @__PURE__ */Y(n,{componentId:e,kind:t,children:i}):i}function je(e,t,n){const o=f(e,n),r=o.text.length,i=e.ownerDocument;if(!t)return[r,r];let l=null;const s=i.caretPositionFromPoint?.(t.x,t.y);if(s&&e.contains(s.offsetNode))l=o.at(s.offsetNode,s.offset);else{const n=i.caretRangeFromPoint?.(t.x,t.y);n&&e.contains(n.startContainer)&&(l=o.at(n.startContainer,n.startOffset))}if(null===l)return[r,r];const a=o.text;let c=l,d=l;for(;c>0&&!/\s/.test(a[c-1]);)c-=1;for(;d<a.length&&!/\s/.test(a[d]);)d+=1;return[c,d]}function Ve({s:e,element:t,toolbar:n,label:o,keys:r}){const i=m("copy",h),l=e.pressed(),p=new Set(n.offered),f=n.colors&&n.colors.length>0?n.colors:null,g=Z(null),[v,w]=T(!1),[b,k]=T(null),S=v||null!==b,C=()=>{e.hold(),w(!1),k({href:e.pressed().href})},I=()=>{w(!1),k(null),e.resume()};q(()=>{r.current={escape:()=>!!S&&(I(),!0),link:()=>!!p.has("link")&&(C(),!0)}}),q(()=>()=>{r.current=null},[r]);const E=Z(I);E.current=I,j(()=>{if(v)return G(e=>{const t=g.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(E.current(),!0)},()=>g.current?.querySelector(".es-copy-colors"))},[v]),j(()=>{const n=g.current;if(!S||!n)return;const o=/* @__PURE__ */new Set([n.ownerDocument]),r=t();r&&o.add(r.ownerDocument);const i=o=>{const r=o.target;if(r&&n.contains(r))return;w(!1),k(null);const i=t();r&&i&&i.contains(r)?e.release():e.stop("outside")};for(const e of o)e.addEventListener("pointerdown",i,!0);return()=>{for(const e of o)e.removeEventListener("pointerdown",i,!0)}},[S,e,t]),q(()=>{const e=g.current,n=e?.querySelector(".rosh-tb-wrap > .es-copy-pop"),o=t();if(!(S&&e&&n&&o))return;const r=o.ownerDocument.defaultView?.getSelection()??null,i=r&&r.rangeCount>0&&o.contains(r.getRangeAt(0).startContainer)?r.getRangeAt(0):null,l=(i?s(i,o):null)??(()=>{const e=o.getBoundingClientRect();return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}})(),d=o.ownerDocument.defaultView?.frameElement,u=d?y(d,{left:l.left,top:l.top,width:l.right-l.left,height:l.bottom-l.top}):{left:l.left,top:l.top,width:l.right-l.left,height:l.bottom-l.top},p=o.getBoundingClientRect(),f=d?y(d,{left:p.left,top:p.top,width:p.width,height:p.height}):{left:p.left,top:p.top,width:p.width,height:p.height},h=(e.closest("[data-floating-bar]")??e).getBoundingClientRect(),m={left:u.left,right:u.left+u.width,top:Math.min(u.top,f.top-6,h.top),bottom:Math.max(u.top+u.height,f.top+f.height+6,h.bottom)},v=e.ownerDocument.documentElement,w=(d??o.closest(".es-canvas")??o).getBoundingClientRect(),b={left:Math.max(0,w.left),top:Math.max(0,w.top),right:Math.min(v.clientWidth||w.right,w.right),bottom:Math.min(v.clientHeight||w.bottom,w.bottom)};if(b.right<=b.left||b.bottom<=b.top||0===n.offsetWidth)return;const k=a({anchor:m,size:{width:n.offsetWidth,height:n.offsetHeight},within:{left:w.left,top:w.top,right:w.right,bottom:w.bottom},clip:b,parent:c(n)});n.style.top=`${k.top}px`,n.style.left=`${k.left}px`,n.style.setProperty("--es-pop-point",`${k.point}px`),n.dataset.side=k.above?"above":"below"});const x=f?{run:d(l.color,f),open:v,onToggle:()=>{k(null),v?I():(e.hold(),w(!0))}}:void 0;/* @__PURE__ */
|
|
5
|
+
return Y(Q,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?y(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__ */Y("div",{ref:g,style:{width:"18rem"},children:/* @__PURE__ */Y(_,{offered:p,pressed:l.marks,onMark:t=>{"link"===t?C():e.press(t)},color:x,linkOpen:null!==b,list:{pressed:l.list,onList:t=>e.list(t)},alignment:n.alignment,letterCase:n.letterCase,last:n.lastTool?.({className:"rosh-tb-btn",disabled:!1,selected:l.selected,keepCaret:t=>{t.preventDefault(),e.hold()},insert:t=>e.insert(t)}),windows:/* @__PURE__ */X(U,{children:[v&&f?/* @__PURE__ */Y(u,{colors:f,current:l.color,words:i.colors??h.colors,onPick:t=>e.color(t)}):null,b?
|
|
6
|
+
/* @__PURE__ */Y(ee,{className:"es-copy-link es-copy-pop",value:b.href??"",onApply:t=>{k(null),e.link(t)},onRemove:null!==b.href?()=>{k(null),e.link(null)}:void 0,onCancel:I}):null]})})})})}function Ze({element:e}){const t=Z(null),n=Ke(t,()=>e(),e);/* @__PURE__ */
|
|
7
|
+
return Y("div",{ref:t,"aria-hidden":"true",className:"es-canvas-outline is-typing",style:n?{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height}:{display:"none"}})}function Fe({frame:t=!0,className:n,style:o,metadata:r,mirrorStyles:s,onDocument:a,height:c,title:d,nonce:u,hotkeys:f,frameWrapper:h,overlay:g,children:v,typing:y,passThrough:b}){const k=ye(),S=V(ze),C=b??S,I=V(ge),E=m("canvas",e),x=f??I,[D,M]=T(void 0),A=we(e=>"node"===e.selection?.kind?e.selection.id:null),[O,R]=T(null),[P,B]=T(null),N=Z(null),[,$]=T(0),z=Z(y);z.current=y;const K=Z(null),L=Z(null),F=e=>{const t=L.current?.ownerDocument,n=t?.defaultView?.CustomEvent;t&&n&&t.dispatchEvent(new n(w,{detail:{typing:e}}))},H=(e,t)=>{N.current?.s.stop("stop");const n=e.element();if(!n)return!1;const o=k.group(),r=e.element,i=p({element:r,value:e.value,rules:e.rules,multiline:e.multiline,skip:e.skip,caret:je(n,t,e.skip),write:e.write,remount:e.remount,onSelect:()=>$(e=>e+1),onEscape:()=>K.current?.escape()??!1,onLinkKey:()=>K.current?.link()??!1,end:e=>{o.close(),N.current?.element===r&&(N.current=null),B(null),F(!1),z.current?.onChange?.({typing:!1,why:e})}});if(!i)return o.close(),!1;const l=n.closest?.(`[${ke}]`)?.getAttribute(ke);return l&&k.select(l),N.current={s:i,element:r,target:e},B(()=>r),R(null),F(!0),z.current?.onChange?.({typing:!0,element:n}),!0};j(()=>()=>N.current?.s.stop("stop"),[]);const W=e=>{const t=N.current?.element();return Boolean(t&&t.contains(e))},q=e=>{const t=e.closest?.(`[${ke}]`)?.getAttribute(ke);if(!t)return;const n=k.getState(),o="node"===n.selection?.kind?n.selection.id:null;return l(n.appState.data,k.config,t,o,C)??t},U=e=>{if("Enter"!==e.key||e.defaultPrevented||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;if(N.current)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select, button"))return;const n=z.current?.atSelection?.();n&&H(n,null)&&e.preventDefault()},J=/* @__PURE__ */X("div",{ref:L,className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;if(t.closest?.("a[href]")&&e.preventDefault(),N.current){if(W(t))return;N.current.s.stop("outside")}const n=q(t);void 0===n?t.hasAttribute?.(Se)||k.select(null):k.select(n)},onDoubleClick:e=>{const t=z.current;if(!t||W(e.target))return;const n=t.at(e.target);n&&H(n,{x:e.clientX,y:e.clientY})&&e.preventDefault()},onKeyDown:e=>U(e),onMouseOver:e=>{if(N.current)return;const t=q(e.target)??null;t!==O&&R(t)},onMouseLeave:()=>R(null),children:[
|
|
8
|
+
/* @__PURE__ */Y(Me.Provider,{value:O,children:/* @__PURE__ */Y($e,{metadata:r})}),
|
|
9
|
+
/* @__PURE__ */X("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
|
|
10
|
+
/* @__PURE__ */Y(Le,{id:!P&&O&&O!==A?O:null,kind:"hover",overlay:g}),
|
|
11
|
+
/* @__PURE__ */Y(Le,{id:P?null:A,kind:"selected",overlay:g}),P?/* @__PURE__ */Y(Ze,{element:P}):null]}),v]}),G=h?/* @__PURE__ */Y(h,{document:D,children:J}):J;j(()=>{if(D&&x)return he(D,k)},[D,x,k]),j(()=>{if(!D)return;const e=e=>{if("Enter"===e.key)return void U(e);if("Escape"!==e.key||e.defaultPrevented)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select"))return;const n=k.getState();if("node"!==n.selection?.kind)return;const o=i(n.appState.data,k.config,n.selection);"node"===o?.kind&&k.select(o.id)};return D.addEventListener("keydown",e),()=>D.removeEventListener("keydown",e)},[D,k]);/* @__PURE__ */
|
|
12
|
+
return X("div",{className:"es-canvas"+(n?` ${n}`:""),style:o,"data-puck-preview":"","data-es-typing":P?"":void 0,children:[P&&N.current?.target.toolbar?/* @__PURE__ */Y(Ve,{s:N.current.s,element:N.current.element,toolbar:N.current.target.toolbar,label:E.textTools,keys:K}):null,t?/* @__PURE__ */Y(De,{mirrorStyles:s,onDocument:e=>{M(e??void 0),a?.(e)},height:c,title:d,nonce:u,children:G}):/* @__PURE__ */Y("div",{id:"preview-frame","data-puck-entry":"",children:G})]})}function Te(e={}){const t=ye(),n=we(e=>e.appState.data);return r({...e,data:n,config:t.config,commit:(e,{select:n})=>t.run({data:e,select:n})})}function He(){const e=ye(),n=we(e=>e.config),o=e.resolveCache,r=we(e=>e.selectedItem),i=we(e=>e.appState.data.root),l=r?r.props.id:"root",s=i.props??{},a=H(()=>r||{type:"root",props:s},[r,s]),c=r?n.components[r.type]:n.root,d=e.getState(),u=r?k(d.appState.data,n,l):null,p=u&&"root"!==u.place.parentId?u.place.parentId:null,f=p?d.getItemById(p)??null:null,{fields:h}=t({id:l,node:a,block:c,parent:f,appState:d.appState}),m=we(e=>!1===e.getPermissions(r?{item:r}:{root:!0}).edit),g=W(t=>{(async()=>{const r=e.getState();if("root"!==l){const i=r.getItemById(l),s=r.getSelectorForId(l);if(!i||!s)return;const a={...i,props:{...i.props,...t}},{node:c}=await B(a,n,{cache:o,trigger:"replace"}),d=e.getState().getSelectorForId(l);if(!d)return;return void e.dispatch({type:"replace",destinationZone:d.zone??"root:default-zone",destinationIndex:d.index,data:c})}const i=r.appState.data.root.props??{},{node:s}=await B({type:"root",props:{...i,...t}},n,{cache:o,trigger:"replace"});e.dispatch({type:"replaceRoot",root:{props:s.props,readOnly:s.readOnly},recordHistory:!0})})()},[e,n,o,l]),v=W((e,t)=>g({[e]:t}),[g]);return{id:l,node:a,fields:h,values:a.props,readOnly:m,onChange:v,onChangeMany:g}}export{De as CanvasFrame,ze as CanvasPassThroughContext,de as DEFAULT_UI,Fe as EaselCanvas,ve as EaselProvider,$e as EditDocument,he as bindUndoKeys,fe as createEasel,be as createUseEasel,te as recordsByDefault,se as reduce,re as uiView,we as useEasel,ye as useEaselApi,Te as useEaselNodeOps,He as useSelectedFields,ie as validSelection};
|