efficient-easel 26.13.0 → 26.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{canvas-typing-DOBx8dD3.d.ts → canvas-typing--FlIZwbT.d.ts} +15 -1
- package/dist/{chunk-XE5LSM3G.js → chunk-2EDOL4IW.js} +33 -33
- package/dist/chunk-3BQT7FC7.js +7 -0
- package/dist/{chunk-DTVOOBD4.js → chunk-3ZGOVNVH.js} +1 -1
- package/dist/chunk-5OYP3C2K.js +1 -0
- package/dist/{chunk-FDIGXBUW.js → chunk-7U4HEUZM.js} +1 -1
- package/dist/{chunk-QPZQFWS6.js → chunk-IHOTVWDE.js} +3 -3
- package/dist/{chunk-DX7UGNIP.js → chunk-K6TDOXHR.js} +12 -12
- package/dist/chunk-L4DFCNDQ.js +5 -0
- package/dist/{chunk-ZWQKRSOI.js → chunk-M4SOZEZR.js} +4 -4
- package/dist/{chunk-ITRBDUAM.js → chunk-NUJEHA6A.js} +9 -9
- package/dist/{chunk-JREIRJVH.js → chunk-PG7G7ELT.js} +1 -1
- package/dist/{chunk-YIZIW6GJ.js → chunk-RWGOCHH7.js} +1 -1
- package/dist/{chunk-KR2JYQLM.js → chunk-VVHDUTAE.js} +7 -7
- package/dist/{chunk-6FOXOYXW.js → chunk-YMK3MZJK.js} +1 -1
- package/dist/copy/index.d.ts +2 -2
- package/dist/copy/index.js +29 -29
- package/dist/easel/index.d.ts +1 -1
- package/dist/easel/index.js +1 -1
- package/dist/screen/components/AddBlockRow.js +1 -1
- package/dist/screen/components/AddSidePanel.js +1 -1
- package/dist/screen/components/ScreenChrome.js +1 -1
- package/dist/screen/components/ScreenMount.js +1 -1
- package/dist/screen/components/ScreenStoreProvider.js +1 -1
- package/dist/screen/components/SectionScreenShell.js +17 -17
- package/dist/screen/components/usePartBridge.js +1 -1
- package/dist/screen/index.js +1 -1
- package/dist/screen/lib/document/block-set-host.js +1 -1
- package/dist/screen/lib/document/block-size-fields.js +1 -1
- package/dist/screen/lib/document/box-fields.js +1 -1
- package/dist/screen/lib/document/button-fields.js +1 -1
- package/dist/screen/lib/document/image-fields.js +4 -4
- package/dist/screen/lib/document/shadow-fields.js +1 -1
- package/dist/screen/lib/document/style-fields.js +1 -1
- package/dist/screen/lib/document/use-section-ops.js +1 -1
- package/dist/screen/lib/key-scope.js +1 -1
- package/dist/screen/lib/screen-parts.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-CLJ3KXYF.js +0 -5
- package/dist/chunk-HZSZT3BE.js +0 -7
- package/dist/chunk-QYQG36CI.js +0 -1
|
@@ -147,7 +147,8 @@ interface CopyBoxFooter {
|
|
|
147
147
|
/**
|
|
148
148
|
* What a host needs to draw its OWN control in row 1's 9th cell of the final
|
|
149
149
|
* toolbar ({@link CopyBoxProps.lastTool}) — the campaign designer's Insert
|
|
150
|
-
* (merge tags), owner ruling 2026-10-07
|
|
150
|
+
* (merge tags), owner ruling 2026-10-07, and the website editor's text style
|
|
151
|
+
* button (Lewis 2026-10-29, B).
|
|
151
152
|
*
|
|
152
153
|
* `className` makes it a cell that looks like its neighbours; `keepCaret` on
|
|
153
154
|
* its mousedown keeps the caret and the selection in the box; `insert` writes
|
|
@@ -164,6 +165,11 @@ interface CopyBoxLastTool {
|
|
|
164
165
|
}) => void;
|
|
165
166
|
/** Put a literal string where the caret is, replacing any selection. */
|
|
166
167
|
insert: (text: string) => void;
|
|
168
|
+
/** The one site text style every selected word wears; null with none selected. */
|
|
169
|
+
style: string | null;
|
|
170
|
+
/** Put a site text style on the selected words (`[words]{style=id}`), or
|
|
171
|
+
* take it off with null. Nothing selected changes nothing. */
|
|
172
|
+
applyStyle: (id: string | null) => void;
|
|
167
173
|
}
|
|
168
174
|
/**
|
|
169
175
|
* The alignment strip, when the host has an alignment to offer.
|
|
@@ -381,6 +387,8 @@ interface CanvasTypingSession {
|
|
|
381
387
|
/** The colour the selection wears (a theme colour's name or a hex, a
|
|
382
388
|
* pending one included), or null: the colour window shows it. */
|
|
383
389
|
color: string | null;
|
|
390
|
+
/** The one site text style every selected word wears; null with none selected. */
|
|
391
|
+
style: string | null;
|
|
384
392
|
/** Whether the selected words wear a mark or a colour that Clear
|
|
385
393
|
* formatting would take off (a link stays): the button shows only then. */
|
|
386
394
|
clearable: boolean;
|
|
@@ -427,6 +435,12 @@ interface CanvasTypingSession {
|
|
|
427
435
|
* window stays open, so the focus is not moved.
|
|
428
436
|
*/
|
|
429
437
|
color: (color: string | null) => void;
|
|
438
|
+
/**
|
|
439
|
+
* A host tool's text style (`styleOver`): the site style `id` on the selected
|
|
440
|
+
* words, or null to take it off. One edit step. The tool's menu had focus, so
|
|
441
|
+
* the focus goes back to the words, as {@link insert} does.
|
|
442
|
+
*/
|
|
443
|
+
textStyle: (id: string | null) => void;
|
|
430
444
|
/**
|
|
431
445
|
* Clear formatting (Lewis 2026-10-26): every mark and colour off the
|
|
432
446
|
* selected words, back to the text's own style (`clearStyle`, which keeps a
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
import{markedTreeNodeId as e,revealSelectedTreeRow as n,sameSelector as t}from"./chunk-UMBNBCL4.js";import{cloneNodeWithFreshIds as o}from"./chunk-OXZDSOZV.js";import{dedupeSlotChildren as r}from"./chunk-7OCEPOEJ.js";import{styleClipboardOf as i}from"./chunk-U4TG43PD.js";import{scrollPreviewToSection as l,gotoPreviewSlide as s}from"./chunk-LUOY3A3Q.js";import{useEaselKeyTarget as d,useEaselUndoKeys as a,useEaselSaveKey as c,editorRootFocus as p}from"./chunk-
|
|
1
|
+
import{markedTreeNodeId as e,revealSelectedTreeRow as n,sameSelector as t}from"./chunk-UMBNBCL4.js";import{cloneNodeWithFreshIds as o}from"./chunk-OXZDSOZV.js";import{dedupeSlotChildren as r}from"./chunk-7OCEPOEJ.js";import{styleClipboardOf as i}from"./chunk-U4TG43PD.js";import{scrollPreviewToSection as l,gotoPreviewSlide as s}from"./chunk-LUOY3A3Q.js";import{useEaselKeyTarget as d,useEaselUndoKeys as a,useEaselSaveKey as c,editorRootFocus as p}from"./chunk-PG7G7ELT.js";import{SlotChildActionsProvider as u}from"./chunk-KCBEE2MC.js";import{screenStorageKeys as f,DEFAULT_PANEL_W as h,clampPanelWidth as m}from"./chunk-6EDVZBUO.js";import{usePartBridge as g}from"./chunk-5OYP3C2K.js";import{useSectionOps as y}from"./chunk-3ZGOVNVH.js";import{PageEditGuardNotices as b}from"./chunk-MGEXTIZH.js";import{ScreenSaveIcon as v,ScreenMainButton as k}from"./chunk-PVBDKBJB.js";import{useBrowserOffline as S}from"./chunk-RKTF5XLP.js";import{useScreenDocument as w}from"./chunk-CPIWSFGR.js";import{requestMediaPick as x}from"./chunk-JIP5JNRB.js";import{AddChildRow as z}from"./chunk-5545A3PC.js";import{AddSidePanel as C}from"./chunk-VVHDUTAE.js";import{keepsSharedSections as O,sharedSectionsOf as N}from"./chunk-N3MJOHAG.js";import{PanelHideButton as B,SidePanelHead as I,PanelShowStrip as P}from"./chunk-SBVIW3KJ.js";import{offeredChoices as $}from"./chunk-RUQOIQWI.js";import{useScreenSaveSwitch as T,useScreenNodeKeys as M,useScreenPinned as j,useScreenDocumentLabel as E,useScreenCanvasFrame as L,useScreenInspectorPanel as A,useScreenDevices as R,useScreenPickFollowsSelection as D,useScreenLeftView as F,SELECTION_MODE as V,isSelectionMode as H,sameInspectorMode as W,useScreenBridges as U,useScreenBlockRules as J,useScreenBlockLook as Y,useScreenStorageNamespace as G,useScreenNotify as X,useScreenCanvasHead as K,isSlotMode as Q,useScreenStyleClipboard as Z,useScreenDocumentPass as _,useScreenCanvasDrag as q,ScreenCanvasTargetProvider as ee,isPinnedFirst as ne,isPinnedLast as te,screenSlotsOf as oe,shownChildSlotsOf as re}from"./chunk-L4DFCNDQ.js";import{MediaPopup as ie}from"./chunk-T2RINM7R.js";import{useMediaPanel as le,usePanelPick as se,useMediaBrowsing as de,useOpenMediaBrowse as ae,useMediaPlace as ce}from"./chunk-NCXYC7WI.js";import{useNodeClipboard as pe,useNodeContextMenu as ue}from"./chunk-H4TUOPI7.js";import{useEaselSession as fe}from"./chunk-YM4UEGBV.js";import{useEaselHost as he,useHostEscape as me}from"./chunk-LX23TCTP.js";import{LayersIcon as ge,MediaIcon as ye}from"./chunk-XFYFKITX.js";import{DEFAULT_SCREEN_WORDS as be}from"./chunk-C4TJN6GR.js";import{heldStyle as ve,styleShortcut as ke}from"./chunk-CWELHADJ.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as Se}from"./chunk-6WY6ZXJG.js";import{rootRowName as we,slotChildRowName as xe,slotChildRenameProp as ze,sectionRenameProp as Ce}from"./chunk-5NHQ452C.js";import{ROOT_ZONE as Oe,blockNodeActions as Ne,TREE_MAX_DEPTH as Be,childSlotsOf as Ie,slotFieldsOf as Pe,newNodeId as $e,slotChildrenIn as Te,nestsInTree as Me}from"./chunk-TCAAOYQY.js";import{useEasel as je,useEaselApi as Ee,useSettledAction as Le,subscribeLateWrites as Ae,CanvasPartsContext as Re,partHasOwnBox as De,CanvasPassThroughContext as Fe,CanvasSharedContext as Ve}from"./chunk-NUJEHA6A.js";import{TreeRow as He,Subtree as We,LayersTree as Ue,TreeGroupLabel as Je,TreeRowAction as Ye,TreeSeam as Ge}from"./chunk-WHS6Y55E.js";import{DEFAULT_TREE_WORDS as Xe}from"./chunk-K56YDHYQ.js";import{DEFAULT_NODE_MENU_WORDS as Ke}from"./chunk-WK3AFPXY.js";import{toItemSelector as Qe,useNodeOps as Ze,clickPick as _e}from"./chunk-QTHQPJWA.js";import{EaselTopBar as qe,EaselIconButton as en,TopBarCluster as nn,DeviceSwitch as tn,InspectorIconButton as on,PanelResizeHandle as rn,MAX_PANEL_W as ln,MIN_PANEL_W_BY_SIDE as sn,panelWidthVars as dn}from"./chunk-VBEVZZTV.js";import{DEFAULT_NOTICE_WORDS as an,DEFAULT_CHROME_WORDS as cn}from"./chunk-AJSDWWJW.js";import{holderOf as pn,nameOrSomeone as un}from"./chunk-YYD257TD.js";import{DEFAULT_LOCK_WORDS as fn}from"./chunk-RE4LP46F.js";import{useWords as hn}from"./chunk-MFIRYGHW.js";import{insertSeams as mn,CanvasDragLayer as gn,CanvasInsert as yn}from"./chunk-SQTVXE5D.js";import{DEFAULT_DRAG_WORDS as bn}from"./chunk-TQ5Y6S2X.js";import{createDragSession as vn,useTreeDrag as kn,gapToMoveIndex as Sn}from"./chunk-3XECMGXX.js";import{useCanvasFrame as wn,LIST_SELECTOR as xn,BLOCK_SELECTOR as zn,useCanvasTyping as Cn,useCanvasEvent as On}from"./chunk-TOKMFZPB.js";import{nodeIdAt as Nn,frameRectToHost as Bn,BLOCK_ATTRIBUTE as In,drawnBox as Pn}from"./chunk-FR7EEKFF.js";import{queryMainCopy as $n}from"./chunk-7UFKEX72.js";import{ROOT_ID as Tn,ROOT_SLOT as Mn,zoneKey as jn,parseZoneKey as En,find as Ln,DataError as An}from"./chunk-EUFDQ4KL.js";import{useRef as Rn,useMemo as Dn,useState as Fn,useEffect as Vn,useCallback as Hn,useLayoutEffect as Wn,useContext as Un,Fragment as Jn,useId as Yn}from"react";import{ColoredBadge as Gn,Button as Xn,Tabs as Kn,toast as Qn,readMediaFileDrag as Zn,Tooltip as _n,groupColors as qn,Dialog as et,FormField as nt,Input as tt,MEDIA_FILE_DRAG_TYPE as ot}from"efficient-shell/ui";import{UndoIcon as rt,RedoIcon as it,RefreshIcon as lt,AddIcon as st,TrashIcon as dt,EyeOffIcon as at,EyeIcon as ct,SharedIcon as pt,DuplicateIcon as ut}from"efficient-shell/icons/efficient";import{jsx as ft,jsxs as ht,Fragment as mt}from"react/jsx-runtime";var gt="media-file";function yt({name:e,onMake:n,onCancel:t}){const o=hn("screen",be).shared,[r,i]=Fn(e),[l,s]=Fn(!1),d=Yn(),a=Rn(null),c=async()=>{const e=r.trim();if(e&&!l){s(!0);try{await n(e)}finally{s(!1)}}};/* @__PURE__ */
|
|
2
2
|
return ft(et,{open:!0,size:"sm",title:o.makeShared,description:o.makeSharedHint,onClose:t,initialFocus:a,footer:/* @__PURE__ */ht(mt,{children:[
|
|
3
|
-
/* @__PURE__ */ft(
|
|
4
|
-
/* @__PURE__ */ft(
|
|
5
|
-
/* @__PURE__ */ft(_n,{content:e.reach,children:/* @__PURE__ */ht(
|
|
6
|
-
/* @__PURE__ */ft("span",{className:"es-band-tab-mark",children:/* @__PURE__ */ft(pt,{size:12})}),e.label]})}):/* @__PURE__ */ft(
|
|
3
|
+
/* @__PURE__ */ft(Xn,{variant:"secondary",onClick:t,children:o.cancel}),
|
|
4
|
+
/* @__PURE__ */ft(Xn,{variant:"primary",loading:l,disabled:!r.trim(),onClick:()=>{c()},children:o.makeShared})]}),children:/* @__PURE__ */ft("form",{onSubmit:e=>{e.preventDefault(),c()},children:/* @__PURE__ */ft(nt,{label:o.name,htmlFor:d,children:/* @__PURE__ */ft(tt,{id:d,ref:a,value:r,onChange:e=>i(e.target.value)})})})})}var bt=/* @__PURE__ */new WeakSet;function vt(e,n,t){const o=Ln(e,n,t);if(!o)return null;const r=o.path.find(e=>"root"!==e.parentId);return r?r.parentId:t}function kt(e,n,t){const o=o=>o>=t.left&&o+e.width<=t.left+t.width&&n.every(n=>n.right<=o||n.left>=o+e.width||n.bottom<=e.top||n.top>=e.top+e.height);if(n.every(n=>n.right<=e.left||n.left>=e.left+e.width||n.bottom<=e.top||n.top>=e.top+e.height))return e.left;const r=n.map(e=>e.right+4).filter(n=>n>e.left&&o(n));if(r.length)return Math.min(...r);const i=n.map(n=>n.left-4-e.width).filter(n=>n<e.left&&o(n));return i.length?Math.max(...i):e.left}function St({canvas:e,tabs:n,onSelect:t,onPointer:o}){const r=Rn(null),[i,l]=Fn({}),s=Rn({id:null,places:{},measure:null});s.current.places=i;const d=!(null===s.current.id||n.some(e=>e.id===s.current.id)&&i[s.current.id]);Vn(()=>{d&&(s.current.id=null,o(null))},[d,o]),Vn(()=>()=>{null!==s.current.id&&o(null)},[o]);const a=n.map(e=>`${e.id}:${e.below?1:e.above?2:0}:${e.label}:${e.reach??""}`).join("|");return Wn(()=>{const t=e?.document,o=e?.window,i=e?.frame;if(!t||!o||!i||0===n.length)return void l(e=>0===Object.keys(e).length?e:{});let d=0;const a=()=>{d=0;const e=r.current;if(!e)return;const a=Bn(i,{left:0,top:0,width:o.innerWidth,height:o.innerHeight},e),p={};let u=!1;const f=e.getBoundingClientRect(),h=[...e.parentElement?.querySelectorAll(".es-canvas-handle.is-shown:not(.is-dragging), .es-canvas-tag, .es-canvas-hint")??[]].map(e=>{const n=e.getBoundingClientRect();return{left:n.left-f.left,top:n.top-f.top,right:n.right-f.left,bottom:n.bottom-f.top}});for(const r of n){const n=o.CSS?.escape?o.CSS.escape(r.id):JSON.stringify(r.id).slice(1,-1),l=$n(t,`[${In}="${n}"]`),d=l?Pn(l):null;if(!d||0===d.height){p[r.id]=null;continue}const c=Bn(i,{left:d.left,top:d.top,width:d.width,height:d.height},e),f=c.top+c.height;if(f<a.top||c.top>a.top+a.height){p[r.id]=null;continue}const m=!0===r.above&&c.top-4>a.top,g=r.below?f+4:m?c.top-4:Math.max(c.top,a.top)+6,y=e.querySelector(`[data-band-tab="${n}"]`);y||(u=!0);const b=Math.max(c.left,a.left)+(r.above?0:6),v=y?.offsetHeight??0,k=y?.offsetWidth??0,S=m?g-v:g,w=s.current.id===r.id?s.current.places[r.id]:null,x=w?w.left:kt({left:b,top:S,width:k,height:v},h,a);k>0&&v>0&&h.push({left:x,top:S,right:x+k,bottom:S+v}),p[r.id]={left:x,top:g,above:m}}l(e=>function(e,n){const t=Object.keys(e);return t.length===Object.keys(n).length&&t.every(t=>{const o=e[t],r=n[t];return o===r||!!o&&!!r&&o.left===r.left&&o.top===r.top&&o.above===r.above})}(e,p)?e:p),u&&c()},c=()=>{d||(d=o.requestAnimationFrame(a))};s.current.measure=c,a(),o.addEventListener("scroll",c,!0),o.addEventListener("resize",c);const p=new o.MutationObserver(c);p.observe(t.body,{childList:!0,subtree:!0,attributes:!0});const u=r.current?.parentElement,f=u?.ownerDocument.defaultView?.MutationObserver,h=f?new f(c):null;return u&&h?.observe(u,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style"]}),()=>{d&&o.cancelAnimationFrame(d),o.removeEventListener("scroll",c,!0),o.removeEventListener("resize",c),p.disconnect(),h?.disconnect(),s.current.measure=null}},[e,a]),/* @__PURE__ */ft("div",{ref:r,className:"es-band-tabs","aria-hidden":"true",children:n.map(e=>{const n=i[e.id];return n?/* @__PURE__ */ft("span",{className:"es-band-tab"+(n.above?" is-above":""),"data-band-tab":e.id,style:{left:n.left,top:n.top},onMouseEnter:()=>{s.current.id=e.id,o(e.id)},onMouseLeave:()=>{s.current.id=null,o(null),s.current.measure?.()},onClick:n=>{n.stopPropagation(),t(e.id)},children:e.reach?
|
|
5
|
+
/* @__PURE__ */ft(_n,{content:e.reach,children:/* @__PURE__ */ht(Gn,{colorClass:qn("success","solid"),size:"sm",children:[
|
|
6
|
+
/* @__PURE__ */ft("span",{className:"es-band-tab-mark",children:/* @__PURE__ */ft(pt,{size:12})}),e.label]})}):/* @__PURE__ */ft(Gn,{colorClass:qn("info","solid"),size:"sm",children:e.label})},e.id):null})})}function wt({expand:e}){/* @__PURE__ */
|
|
7
7
|
return ft("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round",children:/* @__PURE__ */ht(mt,e?{children:[
|
|
8
8
|
/* @__PURE__ */ft("path",{d:"M8 9l4-4 4 4"}),
|
|
9
9
|
/* @__PURE__ */ft("path",{d:"M8 15l4 4 4-4"})]}:{children:[
|
|
10
10
|
/* @__PURE__ */ft("path",{d:"M8 4l4 4 4-4"}),
|
|
11
11
|
/* @__PURE__ */ft("path",{d:"M8 20l4-4 4 4"}),
|
|
12
|
-
/* @__PURE__ */ft("path",{d:"M5 12h14"})]})})}var
|
|
13
|
-
return new Set}});Vn(()=>{try{window.localStorage.setItem(Ar,JSON.stringify([...Dr]))}catch{}},[Dr]);const[Vr,Hr]=Fn(()=>{if("undefined"==typeof window)return{...h};try{const e=window.localStorage.getItem(Rr);if(!e)return{...h};const n=JSON.parse(e);return{left:m(Number(n.left)||h.left,"left"),right:m(Number(n.right)||h.right,"right")}}catch{return{...h}}});Vn(()=>{const e=setTimeout(()=>{try{window.localStorage.setItem(Rr,JSON.stringify(Vr))}catch{}},300);return()=>clearTimeout(e)},[Vr]);const Wr=Hn((e,n)=>Hr(t=>{const o="function"==typeof n?n(t[e]):n;return t[e]===o?t:{...t,[e]:o}}),[]),Ur=Hn(e=>Wr("left",e),[Wr]),Jr=Hn(e=>Wr("right",e),[Wr]),Yr=e=>Dr.has(e),
|
|
14
|
-
return ft("input",{className:"es-tree-rename",defaultValue:o,autoFocus:!0,"aria-label":io.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)},_i=i(Z(),uo),qi=_i.scope({target:Pn,siteId:et,docId:Yn}),el=Yt,nl=(e,n)=>n===
|
|
15
|
-
return ft(Ye,{kind:"eye",label:r?io.showNamed({name:o}):io.hideNamed({name:o}),onClick:()=>Cl(e,n,t),children:/* @__PURE__ */ft(r?at:ct,{size:14,strokeWidth:1.8,strokeLinecap:void 0,strokeLinejoin:void 0})})},zl=e=>id(Ie,e),Cl=(e,n,t)=>{So.replaceComponent(e,n,{...t,props:{...t.props,_hidden:!t.props._hidden}})},Il=e=>Pe(Yt,e),Ol=e=>Ne(Yt,e),Bl=e=>vr.slotsOf?Di(e).map(n=>({slot:n.slot,rung:n.rung?n:null,kids:$e(e,n.slot)})):[{slot:null,rung:null,kids:re(Yt,e)}],Nl=e=>vr.slotsOf?Bl(e).flatMap(e=>e.kids):re(Yt,e),Pl=e=>Boolean(vr.slotsOf)&&Di(e).some(e=>e.rung),Tl=(e,n,t)=>xr(e.type,n,t??void 0,Cr(e)),$l=(e,n,t)=>{const o=Me(Yt,e.type,n)&&(t||Nl(e).length>0||Pl(e));return{collapsible:o,folded:o&&Yr(String(e.props.id))}},Ml=(e,n,t)=>Bl(e).flatMap(o=>{const r=o.rung?n+1:n,i=o.kids.flatMap(({child:e})=>$l(e,r,t(e.type)).collapsible?[String(e.props.id),...Ml(e,r+1,t)]:[]);return o.rung?[`${e.props.id}:${o.rung.slot}`,...i]:i}),jl=e=>Nl(e).length>0||Pl(e)||Boolean(xr(e.type)),El=e=>Boolean(xr(e)),Ll=(e,n,t,o)=>{if(ir(V),xr(o)?.spec?.slider){const t=e.split(":")[0];s(t,n),So.select({index:n,zone:e}),l(t)}else So.select({index:n,zone:e}),l(t)},Al=(e,n,t,o,r)=>{const i=`${e}:${n}`;So.insertComponent(i,t,o),xr(r)?.spec?.slider?requestAnimationFrame(()=>{s(e,o),So.select({index:o,zone:i})}):So.select({index:o,zone:i})},Rl=Rn(/* @__PURE__ */new Set);Vn(()=>{vi.forEach(e=>{const n=xr(e.type)?.spec;if(!n)return;const t=e.props.id;if(Rl.current.has(t))return;Rl.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($i)).forEach((e,t)=>vo.seedChild(o,t,n.childType,e))})},[vi,vo,$i]);const Dl=Rn(/* @__PURE__ */new Set);Vn(()=>{vi.forEach((e,n)=>{const t=e.props.id;if(Dl.current.has(t))return;const o=r(e,Il(e.type));Dl.current.add(t),o&&vo.replaceComponent(Ie,n,{...e,props:o})})},[vi,vo]),_(vo,Yt);const Fl=vi.findIndex(to),Vl=Fl>=0?vi[Fl]:null,Hl=oo?vi.findIndex(no):-1,Wl=Hl>=0?vi[Hl]:null,Ul=Xt.groupTab,Jl=Dn(()=>Ul?e=>Zt(e.type):void 0,[Ul]),Yl=Boolean(Xt.groupBadge),Xl=Xt.sharedReach,Gl=e=>Xl?.(e)??void 0,Kl=Dn(()=>Xl?new Set(vi.filter(e=>Gl(e)).map(e=>String(e.props.id))):null,[vi,Xl]),Ql=Dn(()=>Kl?e=>Kl.has(e):void 0,[Kl]),Zl=Xt.first?Xl?.({type:Xt.first,props:{id:""}})??void 0:void 0,_l=Xt.groupBadge?/* @__PURE__ */ft("span",{className:"es-tree-group-badge",children:/* @__PURE__ */ft(Xn,{tone:"info",size:"xs",children:Xt.groupBadge})}):void 0,ql=vi.find(e=>e.type===Kt)??null,es=vi.find(e=>e.type===Qt)??null,ns=Fl>=0?Fl:vi.length,ts=[];vi.forEach(e=>{to(e)||(jl(e)&&ts.push(String(e.props.id)),ts.push(...Ml(e,1,El)))}),Vl&&(ts.push(String(Vl.props.id)),ts.push(...Ml(Vl,1,El)));const os=ts.length>0&&ts.every(e=>Dr.has(e)),rs=e=>{const n=Ir.blockRowName(e,Ti);return Ir.rowName?Ir.rowName(e,"block",n):n},is=(e,n,t,o)=>{const r=Ai(e)[t];if(!r)return;const i={...En(e),index:t},l={...En(n),index:Math.min(Math.max(o,0),Ai(n).length)},s=Sn(i,l);if(e!==n||s!==t)try{zi.move(String(r.props.id),{...l,index:s})}catch(e){if(!(e instanceof An))throw e}},ls=e=>{const n=/* @__PURE__ */new Set,t=e=>{for(const{child:o,zone:r}of Ol(e))n.add(r),t(o)};for(const t of Il(e.type))n.add(`${e.props.id}:${t}`);return t(e),n},ss=e=>{let n=e.slice(0,e.indexOf(":"));for(let e=0;e<64;e++){const e=Ei.get(n);if(!e)return null;if(e.zone===Ie)return n;n=e.zone.slice(0,e.zone.indexOf(":"))}return null},ds=e=>{const n=e.slice(0,e.indexOf(":")),t=vi.find(e=>Zt(e.type)&&String(e.props.id)===n);return t&&_t(n)===e?t:null},as=(e,n)=>{const t=ds(e);return!t||(!Xt.groupAccepts||Xt.groupAccepts(t.type,n,Ai(e).length))},cs=(e,n,t)=>{if(e.rung){const t=Ri(e.rung.nodeId),o=t?Di(t).filter(e=>e.rung).length:0;return n.parentId===e.rung.nodeId&&n.slot===zt&&n.index>=0&&n.index<=o}if(n.slot===zt)return!1;if(e.add)return hs(e.add,n);const o=jn(n);if(Zt(e.type))return!1;const r=ds(o),i=ds(e.zone);if(r||i)return!(!r||!i)&&(!(r!==i&&!as(o,e.type))&&(n.index>=0&&n.index<=Ai(o).length));if(e.zone===Ie||o===Ie){if(e.zone!==o)return!1;const{floor:t,cap:r}=bi();return n.index>=t&&n.index<=r}if(n.index<0||n.index>Ai(o).length)return!1;if(e.zone===o)return!0;const l=Vl&&!Xt.lastIsOpen?String(Vl.props.id):null;return(!l||ss(e.zone)!==l&&ss(o)!==l)&&((e,n,t,o)=>{if(e===n)return!0;const r=o??Ai(e)[t];if(!r)return!1;const i=n.split(":")[0],l=Ei.get(i),s=l?Ai(l.zone)[l.index]:void 0;if(!s)return!1;if(!o&&ls(r).has(n))return!1;const d=xr(s.type,Sr(Vt?.data,s.type,i),n.slice(n.lastIndexOf(":")+1),Cr(s));return!!d&&(!!(d.choices?d.choices.some(e=>e.type===r.type):d.spec?.childType===r.type)&&!d.spec?.addBlocked?.(Ai(n),r))})(e.zone,o,e.index,t)},ps=(e,n)=>{const t=jn(e.from),o=e.node;return t===jn(n)?as(t,o.type):cs({id:String(o.props?.id??""),zone:t,index:-1,type:o.type},n,o)},us=e=>{const n=e.slice(0,e.indexOf(":")),t=Ei.get(n),o=t?Ai(t.zone)[t.index]:void 0;if(!t||!o)return null;const r=xr(o.type,Sr(Vt?.data,o.type,n),e.slice(e.lastIndexOf(":")+1),Cr(o));if(!r||`${n}:${r.slot}`!==e)return null;if("footer"===r.source)return null;const i=T(r.choices??(r.spec?[{type:r.spec.childType,label:Ti(r.spec.childType)}]:[])),l=Fi(e);return{parent:o,parentId:n,target:r,choices:i,parentName:l?l.slot.label:yl(o,t.zone===Ie)}},fs=(e,n)=>{if("section"!==e.kind)return e;const t=jn(n);return t===Ie||ds(t)?e:us(t)?.choices.some(n=>n.type===e.type)?{kind:"block",type:e.type}:e},hs=(e,n)=>{const t=fs(e,n),o=jn(n);if("shared"===t.kind){if(o!==Ie||!Xt.shared?.nodeOf(t.section))return!1;const{floor:e,cap:r}=bi();return n.index>=e&&n.index<=r}if("block"!==t.kind){if(ds(o)){if("preset"===t.kind)return!1;const e="section"===t.kind?t.type:t.template.node.type;return as(o,e)&&n.index>=0&&n.index<=Ai(o).length}if(o!==Ie)return!1;const{floor:e,cap:r}=bi();return n.index>=e&&n.index<=r}if(o===Ie)return!1;const r=us(o);return!(!r||!r.choices.some(e=>e.type===t.type))&&!r.target.spec?.addBlocked?.(Ai(o))},ms=(e,n)=>{const t=fs(e,n);if("block"!==t.kind&&ds(jn(n)))return void((e,n,t)=>{const o="section"===e.kind?e.type:"template"===e.kind?e.template.node.type:null;if(o&&as(n,o)){if("section"===e.kind)So.insertComponent(n,e.type,t);else{if("template"!==e.kind)return;So.insertNode(n,t,wi(e.template.node))}ir(V),So.select({index:t,zone:n})}})(t,jn(n),n.index);if("section"===t.kind)return void fl(t.type,n.index);if("template"===t.kind)return void((e,n,t)=>{const o=cl(t),r=So.insertNode(Ie,o,n);ul(o,r,e)})(t.template.name,wi(t.template.node),n.index);if("preset"===t.kind)return void((e,n,t)=>{const o=n({nodeDefaults:$i,newNodeId:Te,sectionLabel:Mi,blockIsOffered:zr});if(!o)return;const r=cl(t),i=So.insertNode(Ie,r,o);ul(r,i,e)})(t.preset.label,t.preset.insert,n.index);if("shared"===t.kind){const e=Xt.shared?.nodeOf(t.section);if(!e)return;const o=cl(n.index);return void(zi.restore(e,{parentId:$n,slot:Mn,index:o})&&ul(o,e.props.id,t.section.title))}const o=jn(n),r=us(o);r&&(r.target.spec?Al(r.parentId,r.target.slot,t.type,n.index,r.parent.type):((e,n,t)=>{So.insertComponent(e,n,t),ir(V),So.select({index:t,zone:e})})(o,t.type,n.index))},gs=(e,n)=>{e.media?function(e){const n=ed();if(!n||!Zs)return;td(n).then(n=>{n&&function(e,n){if(!Zs)return;const t=Zs.create(e,{nodeDefaults:$i,newNodeId:Te,sectionLabel:Mi,blockIsOffered:zr}),o=jn(n);if(o===Ie){const e=cl(n.index),o=So.insertNode(Ie,e,t);return void ul(e,o,Mi(t.type))}So.insertNode(o,n.index,t),ir(V),So.select({index:n.index,zone:o})}(n,e)})}(n):e.rung?Yi(e.rung.nodeId,e.index,n.index):e.add?ms(e.add,n):e.zone===Ie?pl(e.index,n.index):is(e.zone,jn(n),e.index,n.index)},[ys]=Fn(()=>bn()),vs=kn({keyOf:e=>e.id,readOnly:Boolean(jt),session:ys,canDrop:cs,onDrop:gs,onStep:(e,n)=>{e.rung?Yi(e.rung.nodeId,e.index,n<0?e.index-1:e.index+2):e.zone===Ie?((e,n)=>{const t=Mi(vi[e]?.type??""),o=pl(e,n<0?e-1:e+2);if(!o.moved)return void Zr(n<0?io.sectionFirst({name:t}):io.sectionLast({name:t}));const{floor:r,cap:i}=bi();Zr(io.sectionMoved({name:t,n:o.dest-r+1,total:i-r}))})(e.index,n):is(e.zone,e.zone,e.index,n<0?e.index-1:e.index+2)}}),bs=Hn(e=>{const{floor:n,cap:t}=bi(),o=[];for(const r of e.nodes){const e=jn(r.place),i=Ai(e)[r.place.index];if(!i||String(i.props.id)!==r.id)continue;if(no(i)||to(i)||br(i.type,i))continue;if(Zt(i.type))continue;const l=Boolean(ds(e)),s=e===Ie||l;e===Ie&&t-n<2||o.push({key:r.id,item:{id:r.id,zone:e,index:r.place.index,type:i.type},box:r.box,label:s?Mi(i.type):Ki(i),from:r.place})}const r=e.zones.flatMap(e=>{const n=jn(e.list);if(n===Ie&&0===e.children.length)return[{...e,addLabel:io.addSection,addAlways:!0}];const t=us(n),o=t?.target.spec?.addLabel;return e.children.length>0||Boolean(t?.choices.length)||Boolean(ds(n))?[o?{...e,addLabel:o}:e]:[]}),i=r.flatMap(e=>{const n=jn(e.list),t=n===Ie||ds(n)?null:us(n);return t?.choices.length?mn(e,t.target.spec?.addLabel??io.addBlockHere):[]});return{sources:o,zones:r,seams:i}},[Vt.data]),ks=null==Ut?.props.id?null:String(Ut.props.id),Ss=Un(Re),ws=Ss?.selected()&&Uo?.document&&ks?Ss.selectedPart?.(Uo.document)??null:null,xs=ws&&ks&&De(Vt.data,Yt,ks,ws)?ws:null,zs=xs?.label?{element:xs.element,label:xs.label}:null,Cs=null!==xs,Is=Hn(e=>{const n=Yt,t=e=>!e.item.rung&&null!==Ln(Vt.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(ks);return i?Cs?null:i:r(_e(Vt.data,n,o.item.id,ks,Jl))??o},[Vt.data,Yt,ks,Jl,Cs]),[Os,Bs]=Fn(null),[Ns,Ps]=Fn(null),Ts=Ir.canvasTab,$s=Boolean(Ul||Xl||Ts);In(Uo,"mouseover",e=>{if(!$s)return;const n=On(e.target),t=n?bt(Vt.data,Yt,n):null;t!==Os&&Bs(t),Ts&&n!==Ns&&Ps(n)}),In(Uo,"mouseout",e=>{$s&&!e.relatedTarget&&(Bs(null),Ps(null))});const Ms=e=>no(e)||to(e)||Zt(e.type),js=e=>{const n=Zt(e.type)?Ti(e.type):no(e)?io.header:to(e)?io.footer:null;return null===n?ji(e):Ir.rowName?Ir.rowName(e,"section",n):n},Es=[];if($s){const e=ks?bt(Vt.data,Yt,ks):null;for(const n of/* @__PURE__ */new Set([e,Os])){const e=n?vi.find(e=>String(e.props.id)===n):void 0;if(!e)continue;const t=no(e)||e.type===Kt,o=Gl(e);if(o){Es.push({id:String(e.props.id),label:js(e),below:t,reach:o});continue}if(!Ul||!Ms(e))continue;const r=Ul(e);r&&Es.push({id:String(e.props.id),label:r,below:t})}for(const e of Ts?/* @__PURE__ */new Set([ks,Ns]):[]){const n=e?Ri(e):void 0,t=n?Ts(n):null;t&&!Es.some(n=>n.id===e)&&Es.push({id:e,label:t,below:!1,above:!0})}}const Ls=fe(),As=Rn(null);Vn(()=>{const e=Xt.changeNotice;if(!e)return;const n=JSON.stringify(vi.filter(Ms)),t=As.current;if(As.current={doc:Yn,bands:n,index:Wt.index},!t||t.doc!==Yn||t.bands===n)return;Wt.hasPast&&Wt.index>=t.index&&!vt.has(Ls)&&(vt.add(Ls),Zr(e,"success",{action:{label:io.bar.undo,onClick:()=>Wt.back()},duration:8e3}))},[vi]);const Rs=e=>{ir(V),So.select(e.zone===Ie?{index:e.index}:{index:e.index,zone:e.zone})},Ds=q(),Fs=()=>({data:Vt.data,device:Po,ops:So,inspector:mr}),Vs=Ds?.model,Hs=Dn(()=>Vs?e=>Vs(e,bs(e),Fs()):bs,[Vs,bs,Po]),Ws=Ds?.measure,Us=Ws?(e,n)=>Ws(e,n,Fs()):void 0,Js=Ds?.canDrop,Ys=Js?(e,n)=>Js(e,n,cs,Fs()):cs,Xs=Ds?.drop,Gs=Xs?(e,n)=>Xs(e,n,gs,Fs()):gs,Ks=Ds?.pick,Qs=Ks?e=>Ks(e,Rs,Fs()):Rs,Zs=Ds?.media??null,_s=Rn(null),qs=Dn(()=>Zs?{id:gt,zone:"",index:-1,type:Zs.adds.type,add:{kind:Zs.adds.kind,type:Zs.adds.type},media:!0}:null,[Zs]);Vn(()=>{if(!qs||jt||"undefined"==typeof document)return;const e=e=>{(e=>Array.from(e.dataTransfer?.types??[]).includes(ot))(e)&&(_s.current=null,ys.start({key:gt,item:qs}))},n=e=>{ys.get()?.item.media&&(_s.current=Zn(e.dataTransfer))},t=()=>{ys.get()?.item.media&&ys.end()};return document.addEventListener("dragstart",e),document.addEventListener("drop",n,!0),document.addEventListener("dragend",t,!0),()=>{document.removeEventListener("dragstart",e),document.removeEventListener("drop",n,!0),document.removeEventListener("dragend",t,!0)}},[qs,jt,ys]);const ed=()=>{const e=_s.current;return _s.current=null,e},nd=ce(),td=async e=>{if(!nd)return e;const n=await nd(e);return n?{...e,id:n.id,url:n.url}:null};const od=(e,n)=>{if(!Zs)return;const t=Ln(ko.getState().appState.data,ki,n);if(!t)return;const o=t.node;So.replaceComponent(jn(t.place),t.place.index,{...o,props:{...Zs.replace(o,e),id:o.props.id}})},rd=e=>{const n=jn(e),t=Fi(n);t&&Ui(t.node,t.slot,!1),ml(n,e.index)},id=(e,n)=>/* @__PURE__ */ft(Xe,{...jt?{}:vs.seam({place:{...En(e),index:n}})},`seam:${e}:${n}`),ld={rowClick:vl,isCollapsed:Yr,toggleCollapse:Xr},sd=e=>{const n=String(e.props.id),t=vi.findIndex(e=>String(e.props.id)===n),o=_t(n),r=Ai(o),i=Yr(n),l=Ti(e.type),s=Ir.rowName?Ir.rowName(e,"section",l):l,d=e=>id(o,e);/* @__PURE__ */
|
|
12
|
+
/* @__PURE__ */ft("path",{d:"M5 12h14"})]})})}var xt=`${xn}, ${zn}`;function zt(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 Ct="__rungs",Ot=e=>"template"===e.kind?e.template.id:"shared"===e.kind?e.section.id:"preset"===e.kind?e.preset.key:e.type;var Nt="screen:band",Bt={duplicate:!0,delete:!0},It=()=>null;function Pt(){const xn=he(),Bn=xn.panels?.Toolbar,In=(xn.panels?.useRight??It)(),{target:Pn,docId:Yn,capabilities:_n,currentSlug:qn,siteId:et,onPublish:nt,saveState:tt,saveConflict:pt,retrySave:kt,toggleAutoSave:Pt,flushSave:$t,access:Tt,saveUnreachable:Mt=!1,readOnly:jt,readOnlyReason:Et=null}=w(),Lt=T(),At=M(),{mediaEditing:Rt,hasEditGuard:Dt,hasPinnedChrome:Ft}=_n,{appState:Vt,dispatch:Ht,history:Wt,selectedItem:Ut,getSelectorForId:Jt,config:Yt}=je(e=>e),Gt=j(),{first:Xt,firstGroup:Kt,lastGroup:Qt,isSectionGroup:Zt,sectionGroupZone:_t,panelOf:qt}=Gt,eo=qt(Xt),no=e=>ne(Gt,e),to=e=>te(Gt,e),oo="node"===Gt.firstRow,ro=Gt.band??null,io=hn("screen",be),lo=hn("tree",Xe),so=hn("drag",bn),ao=hn("notice",an),co=hn("lock",fn),po=hn("menu",Ke),uo=hn("styleClipboard",Se),fo=hn("chrome",cn),ho=E()??`/${qn}`,mo=L(),go=A(),yo=y({readOnly:jt}),bo=y({readOnly:jt,foldIntoHistory:!0}),vo=Rn(null),ko=Ee(),So=Dn(()=>({...yo,select:e=>{vo.current=e,yo.select(e)},commitDocument:(e,n)=>{if(void 0!==n){const t=ko.config;vo.current=Qe(e,t,n)}yo.commitDocument(e,n)}}),[yo,ko]),wo=Vt.ui,xo=wo.leftSideBarVisible,zo=wo.rightSideBarVisible,{options:Co,widths:Oo,initial:No,fluid:Bo,fit:Io}=R(),[Po,$o]=Fn(No),To=le(),Mo=Rt&&null!==To;se(),de();const jo=ae();D(Ut?.props.id);const{read:Eo,write:Lo,forSelection:Ao}=F(),[Ro,Do]=Fn(Eo);Vn(()=>{Lo(Ro)},[Ro]);const[Fo,Vo]=Fn(0),Ho=Rn(null),Wo=Rn(null),Uo=wn(Wo,{readySelector:xt}),Jo=Cn(Uo),Yo=d(Wo);a(Wo,Uo);const Go=S(),Xo=pn(Tt),Ko={state:tt,offline:Go||tt.failed&&Mt,readOnlyReason:Et,editing:Xo?ao.editing({name:un(Xo.name,co),noun:io.noun}):null,conflict:null!=pt,notSaving:io.bar.notSaving},Qo=Le({onPress:()=>{jt||(tt.failed?kt():$t())}}).onPress;c(Wo,Uo,Qo);const[Zo,_o]=Fn(!1),qo=Rn(!1),[er,nr]=Fn(null),[tr,or]=Fn([]),[rr,ir]=Fn(V);H(rr);const lr=e(rr,Ut?.props.id),[sr,dr]=Fn(null);Vn(()=>{sr&&(n(),dr(null))},[sr]);const ar=Rn(Jt);ar.current=Jt;const cr=Hn((e,{scroll:n})=>{Do(n=>Ao(e,n)),n&&dr(e);const t=[];let o=e;for(let e=0;e<4;e++){const e=ar.current(o)?.zone;if(!e||!e.includes(":"))break;const n=e.split(":")[0];t.push(n),t.push(e),o=n}0!==t.length&&Fr(e=>{if(t.every(n=>!e.has(n)))return e;const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},[]),pr=Rn(null);Vn(()=>{const e=pr.current;pr.current=null;const n=null==Ut?.props.id?null:String(Ut.props.id);ir(t=>e&&e.id===n?e.mode:"part"===t.kind&&"nodeId"in t&&t.nodeId===n?t:qt(Ut?.type)??V);const o=Ut?.props.id,r=vo.current;if(vo.current=null,!o)return;const i=Jt(o);cr(String(o),{scroll:!t(r,i??null,Oe)})},[Ut?.props.id,cr]);const ur=Hn(e=>{ir(n=>W(n,e)?n:e),Ht({type:"setUi",ui:{rightSideBarVisible:!0}})},[Ht]),fr=Rn(()=>{});fr.current=(e,n)=>{const t=e?Ai(e.zone??Oe)[e.index]?.props.id:null,o=null==t?null:String(t),r=null==Ut?.props.id?null:String(Ut.props.id);ir(e=>W(e,n)?e:n),o!==r&&(pr.current={id:o,mode:n},So.select(e))};const hr=Hn((e,n)=>fr.current(e,n),[]),mr={kind:rr.kind,mode:rr,open:ur,show:e=>ir(e),reveal:()=>{zo||Ht({type:"setUi",ui:{rightSideBarVisible:!0}})},select:hr},gr=U(mr,{data:Vt.data,selected:Ut??null,zoneOf:e=>Jt(e)?.zone,readOnly:Boolean(jt),select:e=>{ir(V),So.select({index:e})},replace:(e,n)=>So.replaceComponent(Oe,e,n),scrollTo:e=>l(e)},{device:Po,refreshes:Fo},{setView:Do,reveal:()=>{xo||Ht({type:"setUi",ui:{leftSideBarVisible:!0}})}}),yr=gr.resolveLeftView?gr.resolveLeftView(Ro):"sections",br=J(),{isLockedBlock:vr,duplicateBlocked:kr,nestDepth:Sr,newSectionNode:wr,canAddTo:xr,blockIsOffered:zr}=br,Cr=e=>({id:String(e.props.id??""),data:Vt?.data}),Or=Y(),{labelAtLevel:Nr,Icon:Br,useProducts:Ir}=Or,Pr=Or.rowName?(e,n,t)=>Or.rowName(e,n,t):void 0,$r=Hn(e=>{Ht({type:"setUi",ui:{rightSideBarVisible:!0}}),l(e),cr(e,{scroll:!0})},[Ht,cr]),{selectNode:Tr,openPartId:Mr}=g({mode:rr,setMode:ir,onOpenPart:$r}),[jr,Er]=Fn(null);me(null!==jr,()=>Er(null));const Lr=f(G()),Ar=Lr.collapsed,Rr=Lr.panelWidths,[Dr,Fr]=Fn(()=>{if("undefined"==typeof window)/* @__PURE__ */return new Set;try{const e=window.localStorage.getItem(Ar);return new Set(e?JSON.parse(e):[])}catch{/* @__PURE__ */
|
|
13
|
+
return new Set}});Vn(()=>{try{window.localStorage.setItem(Ar,JSON.stringify([...Dr]))}catch{}},[Dr]);const[Vr,Hr]=Fn(()=>{if("undefined"==typeof window)return{...h};try{const e=window.localStorage.getItem(Rr);if(!e)return{...h};const n=JSON.parse(e);return{left:m(Number(n.left)||h.left,"left"),right:m(Number(n.right)||h.right,"right")}}catch{return{...h}}});Vn(()=>{const e=setTimeout(()=>{try{window.localStorage.setItem(Rr,JSON.stringify(Vr))}catch{}},300);return()=>clearTimeout(e)},[Vr]);const Wr=Hn((e,n)=>Hr(t=>{const o="function"==typeof n?n(t[e]):n;return t[e]===o?t:{...t,[e]:o}}),[]),Ur=Hn(e=>Wr("left",e),[Wr]),Jr=Hn(e=>Wr("right",e),[Wr]),Yr=e=>Dr.has(e),Gr=e=>Fr(n=>{const t=new Set(n);return t.has(e)?t.delete(e):t.add(e),t}),Xr=Rn(!1),Kr=Rn(null);Vn(()=>{if(Xr.current&&!Zo){const e=Kr.current,n=e&&e.isConnected&&!e.closest('[aria-hidden="true"]')?e:null;(n??Wo.current?.querySelector(`button[aria-label="${CSS.escape(io.add.title)}"]`))?.focus(),Kr.current=null}Xr.current=Zo},[Zo]),Vn(()=>{if(!Zo||!Yo)return;const e=e=>{"Escape"===e.key&&gl()};return Yo.addEventListener("keydown",e),()=>Yo.removeEventListener("keydown",e)},[Zo,Yo]),me(Zo,()=>gl()),Vn(()=>{!xo&&Zo&&(_o(!1),nr(null),qo.current=!1)},[xo]);const Qr=X(),Zr=(e,n="success",t)=>{if(Qr)return void(t?Qr(e,"error"===n?"error":"info",t):Qr(e,"error"===n?"error":"info"));const o={sound:!1,action:t?.action,onClose:t?.onClose};"error"===n?Qn.error(e,{...o,duration:t?.duration??3200}):Qn.success(e,{...o,duration:t?.duration??1900})},_r=Le(gr.mainAction??{label:io.done,onPress:()=>{nt(ko.getState().appState.data)}}),qr=Rn(Zr);qr.current=Zr,Vn(()=>Ae(ko,()=>qr.current(io.writeLate,"error")),[ko,io]);const ei=Rn(null),[ni,ti]=Fn(0),[oi,ri]=Fn(0),ii=K(),li=Rn(null),si=e=>Math.max(0,e.clientHeight-(li.current?.offsetHeight??0));Vn(()=>{const e=ei.current;if(!e)return;const n=()=>{ti(e.clientWidth),ri(si(e))};n();const t=new ResizeObserver(n);return t.observe(e),li.current&&t.observe(li.current),()=>t.disconnect()},[]),Wn(()=>{ei.current&&(ti(ei.current.clientWidth),ri(si(ei.current)))},[Vr,xo,zo]);const di=Po===Bo?ni>0?ni:Oo[Bo]:Oo[Po],ai=ni>0?Math.min(ni/di,"shrink"===Io?1:2):1,ci=di*ai,pi=ni>0&&ci>ni+1,ui={width:ci,height:oi||"100%",flex:"none",position:"relative"},fi={width:di,height:oi?oi/ai:"100%",maxHeight:"none",transform:1!==ai?`scale(${ai})`:void 0,transformOrigin:"top left"},hi=()=>Ht({type:"setUi",ui:{leftSideBarVisible:!xo}}),mi=()=>Ht({type:"setUi",ui:{rightSideBarVisible:!zo}}),gi=e=>{Zo&&(_o(!1),nr(null),qo.current=!1,xo&&Ro===e)||(Do(e),xo||Ht({type:"setUi",ui:{leftSideBarVisible:!0}}))},yi=()=>{ir(eo??V),zo||Ht({type:"setUi",ui:{rightSideBarVisible:!0}})},bi=Vt.data.content??[],vi=()=>{const e=bi.findIndex(no),n=bi.findIndex(to);return{floor:e>=0?e+1:0,cap:n>=0?n:bi.length}},ki=Yt,Si=br.stripCopy,wi=e=>o(e,Si),xi=pe(),zi=Ze({data:Vt.data,config:ki,readOnly:Boolean(jt),clipboard:xi,strip:Si?e=>Si(e):void 0,afterRemove:"none",stepBounds:(e,n)=>{if(e.parentId!==Tn||e.slot!==Mn)return{min:0,max:n-1};const{floor:t,cap:o}=vi();return{min:t,max:o-1}},commit:(e,{select:n})=>{void 0!==n&&ir(V);const t=void 0===n||"node"===n?.kind?n:null;So.commitDocument(e,t)}}),Ci=fe(),[Oi,Ni]=Fn(null),Bi=e=>{const n=bi.find(n=>String(n.props.id)===e),t=Gt.shared;n&&t&&zi.swap(e,t.detach(n))},Ii=e=>{const n=Ln(Vt.data,Yt,e);if(!n)return!1;const t=jn(n.place),o=n.node,r=t===Oe?ji(o):Ki(o),i=t===Oe?Gt.shared?.usedOn(o):null;return!!zi.remove(e)&&(Zr(i?io.shared.removed({count:Math.max(0,i.length-1)}):io.deleted({name:r}),"success",{duration:8e3,action:{label:io.bar.undo,onClick:()=>{zi.restore(n.node,n.place)}}}),!0)},Pi={...zi,remove:Ii},$i=e=>Nr(e,"block",Yt.components[e]?.label??e),Ti=Hn(e=>Yt.components[e]?.defaultProps??{},[Yt]),Mi=e=>Nr(e,"section",$i(e)),ji=e=>we({type:e.type,props:e.props??{}},Mi(e.type),Pr),{nodeAddresses:Ei,zoneItems:Li}=Dn(()=>{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>=Be)return;const s=/* @__PURE__ */new Map;for(const{child:e,zone:t}of Ie(Yt,n))s.set(t,[...s.get(t)??[],e]);for(const[e,n]of s)t(n,e,i+1)})};return t(bi,Oe,0),{nodeAddresses:e,zoneItems:n}},[bi,Yt]),Ai=Hn(e=>Li.get(e)??[],[Li]),Ri=e=>{const n=Ei.get(e);return n?Ai(n.zone)[n.index]:void 0},Di=e=>oe(br,Yt,e),Fi=e=>{if(!br.slotsOf||e===Oe)return null;const n=e.lastIndexOf(":");if(n<=0)return null;const t=Ri(e.slice(0,n));if(!t)return null;const o=Di(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}},Vi=(()=>{if(!Q(rr))return null;const e=`${rr.nodeId}:${rr.slot}`;return Fi(e)?.slot.panel===rr.kind?e:null})(),Hi=Rn(null);Vn(()=>{const e=Hi.current;if(Hi.current=null,!Vi||!Q(rr))return;const n=rr.nodeId;cr(n,{scroll:e!==Vi}),Fr(e=>{if(!e.has(n))return e;const t=new Set(e);return t.delete(n),t})},[rr]);const Wi=e=>{const n=Ei.get(e);n&&(n.zone===Oe?al(n.index):Ll(n.zone,n.index,e,Ri(n.zone.slice(0,n.zone.lastIndexOf(":")))?.type??""))},Ui=(e,n,t)=>{const o=String(e.props.id);if(!n.panel)return void Wi(o);const r={kind:n.panel,nodeId:o,slot:n.slot},i=`${o}:${n.slot}`;t&&Vi!==i&&(Hi.current=i),hr(null,r),zo||Ht({type:"setUi",ui:{rightSideBarVisible:!0}}),l(o)},Ji=(e,n,t)=>{const o=`${e}:${n}`;if(Fr(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;Vi!==o&&(Hi.current=o);hr(null,{kind:t,nodeId:e,slot:n})},Yi=(e,n,t)=>{if(jt||!br.moveSlot)return;const o=Ri(e),r=o?Di(o).filter(e=>e.rung):[],i=r[n];if(!i)return;const l={parentId:e,slot:Ct,index:n},s=Sn(l,{...l,index:Math.min(Math.max(t,0),r.length)});if(s===n)return;const d=br.moveSlot(e,n,s);"string"==typeof d&&Ji(e,d,i.panel)},Gi=Ir(),Xi=Dn(()=>{const e=/* @__PURE__ */new Map;for(const n of Gi??[])e.set(n.slug,n.name);return e},[Gi]),Ki=e=>xe(e,$i,Or.plainText,e=>Xi.get(e),Or.rowName),Qi=(e,n)=>{const t=Yt.components[e.type]?.fields,o=n===Oe||ds(n)?"section":"block",r=n===Oe&&(no(e)||to(e)||Zt(e.type)),i="block"===o?ze(t):r?null:Ce(t);return Or.renamePropOf?Or.renamePropOf(e,o,i):i},Zi=(e,n,t,o)=>{if(!(!jt&&jr?.zone===e&&jr.index===n))return;const r=(t,o)=>{Er(null),o&&((e,n,t)=>{const o=Ai(e)[n];if(!o)return;const r=Qi(o,e);r&&So.replaceComponent(e,n,{...o,props:{...o.props,[r]:t.trim()}})})(e,n,t)};/* @__PURE__ */
|
|
14
|
+
return ft("input",{className:"es-tree-rename",defaultValue:o,autoFocus:!0,"aria-label":io.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)},_i=i(Z(),uo),qi=_i.scope({target:Pn,siteId:et,docId:Yn}),el=Yt,nl=(e,n)=>n===Oe?Mi(e):$i(e),tl=(e,n,t)=>{const o=_i.plan(qi,t,nl(t.type,e),el);o&&(o.changed&&So.replaceComponent(e,n,{...t,props:{...o.props,id:t.props.id}}),Zr(o.message))},ol=ue({nodesIn:Ai,nodeAt:(e,n)=>Ai(e)[n]??null,labelOf:(e,n)=>n===Oe?Mi(e):$i(e),renamePropOf:Qi,beginRename:(e,n)=>Er({zone:e,index:n}),history:{hasPast:Wt.hasPast,hasFuture:Wt.hasFuture,back:()=>Wt.back(),forward:()=>Wt.forward()},openPageStyles:gr.openPageStyles,pageStylesLabel:io.pageStyles,words:{menu:po,styleClipboard:uo,screen:io.menu},readOnly:Boolean(jt),collapseAll:()=>Fr(new Set(Ai(Oe).map(e=>String(e.props.id)))),onPasteRefused:e=>Zr(e?io.pasteRefused({name:e.label}):io.menu.clipboardRefused,"error"),canPasteAt:(e,n)=>ps(e,n),copyItem:gr.onCopyItem,menuRows:(e,n,t)=>{const o=gr.menuRows?.(e,n,t)??null,r=((e,n)=>{const t=Gt.shared;if(!t||n!==Oe)return null;const o=t.usedOn(e);if(o){const n={pick:[{label:io.shared.onPages({count:o.length}),onClick:()=>{},children:o.map(e=>({label:e.title,onClick:()=>t.openPage(e)}))}]};return jt||vr(e.type,e)?n:{...n,change:[{label:io.shared.detach,onClick:()=>Bi(e.props.id)}],remove:[{label:io.shared.removeFromPage,danger:!0,onClick:()=>{Ii(e.props.id)}}]}}return jt||no(e)||to(e)||Zt(e.type)?null:O(Ci)?{change:[{label:io.shared.makeShared,onClick:()=>Ni({id:e.props.id,name:ji(e)})}]}:null})(e,n);if(!r)return o;return Object.fromEntries(["pick","make","change","remove"].map(e=>[e,[...o?.[e]??[],...r[e]??[]]]).filter(([,e])=>e.length>0))},isLocked:e=>vr(e.type,e),duplicateBlocked:e=>kr(Vt.data,e),permits:e=>{const n=Ne(Yt,e.type);return Gt.shared?.usedOn(e)?{...n,delete:!1}:n},nodeOps:Pi,isPinned:(e,n)=>n===Oe&&(no(e)||to(e)),sectionBand:vi,locate:e=>Ei.get(e)??null,rowNameOf:(e,n)=>n===Oe?ji(e):Ki(e),selectAt:(e,n,t,o)=>{e===Oe?al(n):Ll(e,n,t,o??"")},slotRung:e=>{const n=Fi(e);return n?.slot.panel?{label:n.slot.label,select:()=>Ui(n.node,n.slot,!1)}:null},style:{held:()=>ve(qi),canCopy:e=>_i.rows(el,e).some(e=>!1!==e.counted),copy:(e,n)=>_i.copy(qi,e,nl(e.type,n),el),paste:(e,n,t)=>tl(e,n,t)},keys:At?{target:Yo,selected:()=>{const e=Vt.ui.itemSelector;return e?{zone:e.zone??Oe,index:e.index}:null},held:()=>xi.get(),readOnly:Boolean(jt),onDone:({done:e,name:n})=>{"copied"===e&&Zr(io.copied({name:n}))}}:void 0},Uo),rl=Rn({copy:(e,n)=>{},paste:(e,n,t)=>{},at:()=>null,readOnly:!1});Vn(()=>{rl.current={copy:(e,n)=>_i.copy(qi,e,nl(e.type,n),el),paste:tl,at:()=>{const e=Vt.ui.itemSelector;if(!e)return null;const n=e.zone??Oe,t=Ai(n)[e.index];return t?{zone:n,index:e.index,node:t}:null},readOnly:Boolean(jt)}});const il=Hn(e=>{const n=ke(e);if(!n)return;const t=rl.current,o=t.at();o&&(e.preventDefault(),"copy"===n?t.copy(o.node,o.zone):t.readOnly||t.paste(o.zone,o.index,o.node))},[]);Vn(()=>{if(!Yo)return;const e=e=>il(e);return Yo.addEventListener("keydown",e),()=>Yo.removeEventListener("keydown",e)},[il,Yo]),On(Uo,"keydown",il);const ll=bi.map(e=>e.props.id).join("|");Vn(()=>{const e=Uo?.document??null,n=Uo?.window??null;let t=0;const o=[],r=()=>{if(!e)return void or(e=>e.length?[]:e);const n=bi.findIndex(to),t=n>=0?n:bi.length,o=n=>{const t=bi[n]?.props?.id;return null==t?null:$n(e,`[data-easel-block="${CSS.escape(String(t))}"]`)},r=e=>e?[...e.querySelectorAll(zn)].map(e=>e.getBoundingClientRect()).filter(e=>e.width>0||e.height>0):[],i=[];for(let e=bi.length>0&&!no(bi[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=zt(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})}or(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()}},[Uo,ll,Po,ai,xo,zo,Ut?.props.id]);const sl=Uo?.document??null,dl=Uo?.window??null;Vn(()=>{const e=Ho.current;if(!e||!sl||!dl)return;const n=[],t=()=>{const n=$n(sl,`[data-easel-block="${CSS.escape(e.id)}"]`);if(!n)return!1;const t=n.getBoundingClientRect().top-e.offset;return Math.abs(t)>1&&dl.scrollTo({left:dl.scrollX,top:dl.scrollY+t,behavior:"instant"}),!0};return Ho.current=null,t()&&n.push(setTimeout(t,150),setTimeout(t,450)),()=>n.forEach(clearTimeout)},[sl,dl]);const al=e=>{ir(V),So.select({index:e}),gr.sectionPressed?.(bi[e]);const n=bi[e]?.props?.id;n&&l(n)},cl=e=>{const{floor:n,cap:t}=vi(),o=e=>Math.min(Math.max(n,e),t);if("number"==typeof e)return o(e);const r=Ut&&rr.kind!==eo?.kind?bi.findIndex(e=>e.props.id===Ut.props.id):-1;return o(r>=0?r+1:t)},pl=(e,n)=>{const{floor:t,cap:o}=vi(),r=Math.min(Math.max(n,t),o),i=e<r?r-1:r;return i===e?{moved:!1,dest:e}:(So.reorderComponent(Oe,e,i),So.select({index:i}),{moved:!0,dest:i})},ul=(e,n,t,o)=>{ir(V),So.select(o?{index:o.index,zone:o.zone}:{index:e}),l(n),Zr(io.sectionAdded({name:t}))},fl=(e,n)=>{const t=cl(n),o=wr(e,{nodeDefaults:Ti,newNodeId:$e,sectionLabel:Mi,blockIsOffered:zr}),r=o?So.insertNode(Oe,t,o):So.insertSection(e,t);return ul(t,r,Mi(e),o?((e,n,t)=>{if(e.type===t)return null;const o={at:null},r=(e,n,i)=>{const l=i.filter(n=>n===e.type).length;for(const{child:s,zone:d,index:a}of Ie(Yt,e)){if(s.type===t&&(!o.at||n>o.at.depth)){const r=xr(e.type,l,d.slice(d.lastIndexOf(":")+1),Cr(e)),i=r?.choices??(r?.spec?[{type:r.spec.childType,label:r.spec.childType}]:[]);null!==r&&"footer"!==r.source&&`${e.props.id}:${r.slot}`===d&&i.some(e=>e.type===t)&&(o.at={zone:d,index:a,depth:n})}r(s,n+1,[...i,e.type])}};return r({type:e.type,props:{...e.props,id:n}},1,[]),o.at?{zone:o.at.zone,index:o.at.index}:null})(o,r,e):null),t},hl=e=>ml(Oe,e),ml=(e,n)=>{Kr.current=document.activeElement??null,nr(null===n?null:{zone:e,index:n}),_o(!0),xo||(qo.current=!0,Ht({type:"setUi",ui:{leftSideBarVisible:!0}}))},gl=()=>{_o(!1),nr(null),qo.current&&Ht({type:"setUi",ui:{leftSideBarVisible:!1}}),qo.current=!1},yl=(e,n)=>Or.rowName?n?no(e)?Or.rowName(e,"section",io.header):to(e)?Or.rowName(e,"section",io.footer):Zt(e.type)?Or.rowName(e,"section",$i(e.type)):ji(e):Ki(e):n?Mi(e.type):$i(e.type),bl=e=>n=>{e()},vl=(e,n,t)=>{if(jt)return null;const o=Ai(e)[n];return o&&!Ne(Yt,o.type).delete||o&&vr(o.type,o)?null:/* @__PURE__ */ft(Ye,{kind:"delete",label:e===Oe&&o&&Gt.shared?.usedOn(o)?io.shared.removeFromPage:io.deleteNamed({name:t}),onClick:()=>((e,n)=>{const t=Ai(e)[n]?.props?.id;null!=t&&Ii(String(t))})(e,n),children:/* @__PURE__ */ft(dt,{size:15})})},kl=e=>Or.rowPreview?.(e)||void 0,Sl=e=>Or.rowMarks?.(e)??void 0,wl=(e,n,t)=>Or.rowActions?.(e,n,t)??null,xl=(e,n,t,o)=>{if(jt)return null;if(vr(t.type,t))return null;const r=Boolean(t.props._hidden);/* @__PURE__ */
|
|
15
|
+
return ft(Ye,{kind:"eye",label:r?io.showNamed({name:o}):io.hideNamed({name:o}),onClick:()=>Cl(e,n,t),children:/* @__PURE__ */ft(r?at:ct,{size:14,strokeWidth:1.8,strokeLinecap:void 0,strokeLinejoin:void 0})})},zl=e=>sd(Oe,e),Cl=(e,n,t)=>{So.replaceComponent(e,n,{...t,props:{...t.props,_hidden:!t.props._hidden}})},Ol=e=>Pe(Yt,e),Nl=e=>Ie(Yt,e),Bl=e=>br.slotsOf?Di(e).map(n=>({slot:n.slot,rung:n.rung?n:null,kids:Te(e,n.slot)})):[{slot:null,rung:null,kids:re(Yt,e)}],Il=e=>br.slotsOf?Bl(e).flatMap(e=>e.kids):re(Yt,e),Pl=e=>Boolean(br.slotsOf)&&Di(e).some(e=>e.rung),$l=(e,n,t)=>xr(e.type,n,t??void 0,Cr(e)),Tl=(e,n,t)=>{const o=Me(Yt,e.type,n)&&(t||Il(e).length>0||Pl(e));return{collapsible:o,folded:o&&Yr(String(e.props.id))}},Ml=(e,n,t)=>Bl(e).flatMap(o=>{const r=o.rung?n+1:n,i=o.kids.flatMap(({child:e})=>Tl(e,r,t(e.type)).collapsible?[String(e.props.id),...Ml(e,r+1,t)]:[]);return o.rung?[`${e.props.id}:${o.rung.slot}`,...i]:i}),jl=e=>Il(e).length>0||Pl(e)||Boolean(xr(e.type)),El=e=>Boolean(xr(e)),Ll=(e,n,t,o)=>{if(ir(V),xr(o)?.spec?.slider){const t=e.split(":")[0];s(t,n),So.select({index:n,zone:e}),l(t)}else So.select({index:n,zone:e}),l(t)},Al=(e,n,t,o,r)=>{const i=`${e}:${n}`;So.insertComponent(i,t,o),xr(r)?.spec?.slider?requestAnimationFrame(()=>{s(e,o),So.select({index:o,zone:i})}):So.select({index:o,zone:i})},Rl=Rn(/* @__PURE__ */new Set);Vn(()=>{bi.forEach(e=>{const n=xr(e.type)?.spec;if(!n)return;const t=e.props.id;if(Rl.current.has(t))return;Rl.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(Ti)).forEach((e,t)=>bo.seedChild(o,t,n.childType,e))})},[bi,bo,Ti]);const Dl=Rn(/* @__PURE__ */new Set);Vn(()=>{bi.forEach((e,n)=>{const t=e.props.id;if(Dl.current.has(t))return;const o=r(e,Ol(e.type));Dl.current.add(t),o&&bo.replaceComponent(Oe,n,{...e,props:o})})},[bi,bo]),_(bo,Yt);const Fl=bi.findIndex(to),Vl=Fl>=0?bi[Fl]:null,Hl=oo?bi.findIndex(no):-1,Wl=Hl>=0?bi[Hl]:null,Ul=Gt.groupTab,Jl=Dn(()=>Ul?e=>Zt(e.type):void 0,[Ul]),Yl=Boolean(Gt.groupBadge),Gl=Gt.sharedReach,Xl=e=>Gl?.(e)??void 0,Kl=Dn(()=>Gl?new Set(bi.filter(e=>Xl(e)).map(e=>String(e.props.id))):null,[bi,Gl]),Ql=Dn(()=>Kl?e=>Kl.has(e):void 0,[Kl]),Zl=Gt.first?Gl?.({type:Gt.first,props:{id:""}})??void 0:void 0,_l=Gt.groupBadge?/* @__PURE__ */ft("span",{className:"es-tree-group-badge",children:/* @__PURE__ */ft(Gn,{tone:"info",size:"xs",children:Gt.groupBadge})}):void 0,ql=bi.find(e=>e.type===Kt)??null,es=bi.find(e=>e.type===Qt)??null,ns=Fl>=0?Fl:bi.length,ts=[];bi.forEach(e=>{to(e)||(jl(e)&&ts.push(String(e.props.id)),ts.push(...Ml(e,1,El)))}),Vl&&(ts.push(String(Vl.props.id)),ts.push(...Ml(Vl,1,El)));const os=ts.length>0&&ts.every(e=>Dr.has(e)),rs=e=>{const n=Or.blockRowName(e,$i);return Or.rowName?Or.rowName(e,"block",n):n},is=(e,n,t,o)=>{const r=Ai(e)[t];if(!r)return;const i={...En(e),index:t},l={...En(n),index:Math.min(Math.max(o,0),Ai(n).length)},s=Sn(i,l);if(e!==n||s!==t)try{zi.move(String(r.props.id),{...l,index:s})}catch(e){if(!(e instanceof An))throw e}},ls=e=>{const n=/* @__PURE__ */new Set,t=e=>{for(const{child:o,zone:r}of Nl(e))n.add(r),t(o)};for(const t of Ol(e.type))n.add(`${e.props.id}:${t}`);return t(e),n},ss=e=>{let n=e.slice(0,e.indexOf(":"));for(let e=0;e<64;e++){const e=Ei.get(n);if(!e)return null;if(e.zone===Oe)return n;n=e.zone.slice(0,e.zone.indexOf(":"))}return null},ds=e=>{const n=e.slice(0,e.indexOf(":")),t=bi.find(e=>Zt(e.type)&&String(e.props.id)===n);return t&&_t(n)===e?t:null},as=(e,n)=>{const t=ds(e);return!t||(!Gt.groupAccepts||Gt.groupAccepts(t.type,n,Ai(e).length))},cs=(e,n,t)=>{if(e.rung){const t=Ri(e.rung.nodeId),o=t?Di(t).filter(e=>e.rung).length:0;return n.parentId===e.rung.nodeId&&n.slot===Ct&&n.index>=0&&n.index<=o}if(n.slot===Ct)return!1;if(e.add)return hs(e.add,n);const o=jn(n);if(Zt(e.type))return!1;const r=ds(o),i=ds(e.zone);if(r||i)return!(!r||!i)&&(!(r!==i&&!as(o,e.type))&&(n.index>=0&&n.index<=Ai(o).length));if(e.zone===Oe||o===Oe){if(e.zone!==o)return!1;const{floor:t,cap:r}=vi();return n.index>=t&&n.index<=r}if(n.index<0||n.index>Ai(o).length)return!1;if(e.zone===o)return!0;const l=Vl&&!Gt.lastIsOpen?String(Vl.props.id):null;return(!l||ss(e.zone)!==l&&ss(o)!==l)&&((e,n,t,o)=>{if(e===n)return!0;const r=o??Ai(e)[t];if(!r)return!1;const i=n.split(":")[0],l=Ei.get(i),s=l?Ai(l.zone)[l.index]:void 0;if(!s)return!1;if(!o&&ls(r).has(n))return!1;const d=xr(s.type,Sr(Vt?.data,s.type,i),n.slice(n.lastIndexOf(":")+1),Cr(s));return!!d&&(!!(d.choices?d.choices.some(e=>e.type===r.type):d.spec?.childType===r.type)&&!d.spec?.addBlocked?.(Ai(n),r))})(e.zone,o,e.index,t)},ps=(e,n)=>{const t=jn(e.from),o=e.node;return t===jn(n)?as(t,o.type):cs({id:String(o.props?.id??""),zone:t,index:-1,type:o.type},n,o)},us=e=>{const n=e.slice(0,e.indexOf(":")),t=Ei.get(n),o=t?Ai(t.zone)[t.index]:void 0;if(!t||!o)return null;const r=xr(o.type,Sr(Vt?.data,o.type,n),e.slice(e.lastIndexOf(":")+1),Cr(o));if(!r||`${n}:${r.slot}`!==e)return null;if("footer"===r.source)return null;const i=$(r.choices??(r.spec?[{type:r.spec.childType,label:$i(r.spec.childType)}]:[])),l=Fi(e);return{parent:o,parentId:n,target:r,choices:i,parentName:l?l.slot.label:yl(o,t.zone===Oe)}},fs=(e,n)=>{if("section"!==e.kind)return e;const t=jn(n);return t===Oe||ds(t)?e:us(t)?.choices.some(n=>n.type===e.type)?{kind:"block",type:e.type}:e},hs=(e,n)=>{const t=fs(e,n),o=jn(n);if("shared"===t.kind){if(o!==Oe||!Gt.shared?.nodeOf(t.section))return!1;const{floor:e,cap:r}=vi();return n.index>=e&&n.index<=r}if("block"!==t.kind){if(ds(o)){if("preset"===t.kind)return!1;const e="section"===t.kind?t.type:t.template.node.type;return as(o,e)&&n.index>=0&&n.index<=Ai(o).length}if(o!==Oe)return!1;const{floor:e,cap:r}=vi();return n.index>=e&&n.index<=r}if(o===Oe)return!1;const r=us(o);return!(!r||!r.choices.some(e=>e.type===t.type))&&!r.target.spec?.addBlocked?.(Ai(o))},ms=(e,n)=>{const t=fs(e,n);if("block"!==t.kind&&ds(jn(n)))return void((e,n,t)=>{const o="section"===e.kind?e.type:"template"===e.kind?e.template.node.type:null;if(o&&as(n,o)){if("section"===e.kind)So.insertComponent(n,e.type,t);else{if("template"!==e.kind)return;So.insertNode(n,t,wi(e.template.node))}ir(V),So.select({index:t,zone:n})}})(t,jn(n),n.index);if("section"===t.kind)return void fl(t.type,n.index);if("template"===t.kind)return void((e,n,t)=>{const o=cl(t),r=So.insertNode(Oe,o,n);ul(o,r,e)})(t.template.name,wi(t.template.node),n.index);if("preset"===t.kind)return void((e,n,t)=>{const o=n({nodeDefaults:Ti,newNodeId:$e,sectionLabel:Mi,blockIsOffered:zr});if(!o)return;const r=cl(t),i=So.insertNode(Oe,r,o);ul(r,i,e)})(t.preset.label,t.preset.insert,n.index);if("shared"===t.kind){const e=Gt.shared?.nodeOf(t.section);if(!e)return;const o=cl(n.index);return void(zi.restore(e,{parentId:Tn,slot:Mn,index:o})&&ul(o,e.props.id,t.section.title))}const o=jn(n),r=us(o);r&&(r.target.spec?Al(r.parentId,r.target.slot,t.type,n.index,r.parent.type):((e,n,t)=>{So.insertComponent(e,n,t),ir(V),So.select({index:t,zone:e})})(o,t.type,n.index))},gs=(e,n)=>{e.media?function(e){const n=td();if(!n||!qs)return;rd(n).then(n=>{n&&function(e,n){if(!qs)return;const t=qs.create(e,{nodeDefaults:Ti,newNodeId:$e,sectionLabel:Mi,blockIsOffered:zr}),o=jn(n);if(o===Oe){const e=cl(n.index),o=So.insertNode(Oe,e,t);return void ul(e,o,Mi(t.type))}So.insertNode(o,n.index,t),ir(V),So.select({index:n.index,zone:o})}(n,e)})}(n):e.rung?Yi(e.rung.nodeId,e.index,n.index):e.add?ms(e.add,n):e.zone===Oe?pl(e.index,n.index):is(e.zone,jn(n),e.index,n.index)},[ys]=Fn(()=>vn()),bs=kn({keyOf:e=>e.id,readOnly:Boolean(jt),session:ys,canDrop:cs,onDrop:gs,onStep:(e,n)=>{e.rung?Yi(e.rung.nodeId,e.index,n<0?e.index-1:e.index+2):e.zone===Oe?((e,n)=>{const t=Mi(bi[e]?.type??""),o=pl(e,n<0?e-1:e+2);if(!o.moved)return void Zr(n<0?io.sectionFirst({name:t}):io.sectionLast({name:t}));const{floor:r,cap:i}=vi();Zr(io.sectionMoved({name:t,n:o.dest-r+1,total:i-r}))})(e.index,n):is(e.zone,e.zone,e.index,n<0?e.index-1:e.index+2)}}),vs=Hn(e=>{const{floor:n,cap:t}=vi(),o=[];for(const r of e.nodes){const e=jn(r.place),i=Ai(e)[r.place.index];if(!i||String(i.props.id)!==r.id)continue;if(no(i)||to(i)||vr(i.type,i))continue;if(Zt(i.type))continue;const l=Boolean(ds(e)),s=e===Oe||l;e===Oe&&t-n<2||o.push({key:r.id,item:{id:r.id,zone:e,index:r.place.index,type:i.type},box:r.box,label:s?Mi(i.type):Ki(i),from:r.place})}const r=e.zones.flatMap(e=>{const n=jn(e.list);if(n===Oe&&0===e.children.length)return[{...e,addLabel:io.addSection,addAlways:!0}];const t=us(n),o=t?.target.spec?.addLabel;return e.children.length>0||Boolean(t?.choices.length)||Boolean(ds(n))?[o?{...e,addLabel:o}:e]:[]}),i=r.flatMap(e=>{const n=jn(e.list),t=n===Oe||ds(n)?null:us(n);return t?.choices.length?mn(e,t.target.spec?.addLabel??io.addBlockHere):[]});return{sources:o,zones:r,seams:i}},[Vt.data]),ks=null==Ut?.props.id?null:String(Ut.props.id),Ss=Un(Re),ws=Ss?.selected()&&Uo?.document&&ks?Ss.selectedPart?.(Uo.document)??null:null,xs=ws&&ks&&De(Vt.data,Yt,ks,ws)?ws:null,zs=xs?.label?{element:xs.element,label:xs.label}:null,Cs=null!==xs,Os=Hn(e=>{const n=Yt,t=e=>!e.item.rung&&null!==Ln(Vt.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(ks);return i?Cs?null:i:r(_e(Vt.data,n,o.item.id,ks,Jl))??o},[Vt.data,Yt,ks,Jl,Cs]),[Ns,Bs]=Fn(null),[Is,Ps]=Fn(null),[$s,Ts]=Fn(null),Ms=Or.canvasTab,js=Boolean(Ul||Gl||Ms);On(Uo,"mouseover",e=>{if(!js)return;const n=Nn(e.target),t=n?vt(Vt.data,Yt,n):null;t!==Ns&&Bs(t),Ms&&n!==$s&&Ts(n)}),On(Uo,"mouseout",e=>{js&&!e.relatedTarget&&(Bs(null),Ts(null))});const Es=e=>no(e)||to(e)||Zt(e.type),Ls=e=>{const n=Zt(e.type)?$i(e.type):no(e)?io.header:to(e)?io.footer:null;return null===n?ji(e):Or.rowName?Or.rowName(e,"section",n):n},As=[];if(js){const e=ks?vt(Vt.data,Yt,ks):null;for(const n of/* @__PURE__ */new Set([e,Ns,Is])){const e=n?bi.find(e=>String(e.props.id)===n):void 0;if(!e)continue;const t=no(e)||e.type===Kt,o=Xl(e);if(o){As.push({id:String(e.props.id),label:Ls(e),below:t,reach:o});continue}if(!Ul||!Es(e))continue;const r=Ul(e);r&&As.push({id:String(e.props.id),label:r,below:t})}for(const e of Ms?/* @__PURE__ */new Set([ks,$s]):[]){const n=e?Ri(e):void 0,t=n?Ms(n):null;t&&!As.some(n=>n.id===e)&&As.push({id:e,label:t,below:!1,above:!0})}}const Rs=fe(),Ds=Rn(null);Vn(()=>{const e=Gt.changeNotice;if(!e)return;const n=JSON.stringify(bi.filter(Es)),t=Ds.current;if(Ds.current={doc:Yn,bands:n,index:Wt.index},!t||t.doc!==Yn||t.bands===n)return;Wt.hasPast&&Wt.index>=t.index&&!bt.has(Rs)&&(bt.add(Rs),Zr(e,"success",{action:{label:io.bar.undo,onClick:()=>Wt.back()},duration:8e3}))},[bi]);const Fs=e=>{ir(V),So.select(e.zone===Oe?{index:e.index}:{index:e.index,zone:e.zone})},Vs=q(),Hs=()=>({data:Vt.data,device:Po,ops:So,inspector:mr}),Ws=Vs?.model,Us=Dn(()=>Ws?e=>Ws(e,vs(e),Hs()):vs,[Ws,vs,Po]),Js=Vs?.measure,Ys=Js?(e,n)=>Js(e,n,Hs()):void 0,Gs=Vs?.canDrop,Xs=Gs?(e,n)=>Gs(e,n,cs,Hs()):cs,Ks=Vs?.drop,Qs=Ks?(e,n)=>Ks(e,n,gs,Hs()):gs,Zs=Vs?.pick,_s=Zs?e=>Zs(e,Fs,Hs()):Fs,qs=Vs?.media??null,ed=Rn(null),nd=Dn(()=>qs?{id:gt,zone:"",index:-1,type:qs.adds.type,add:{kind:qs.adds.kind,type:qs.adds.type},media:!0}:null,[qs]);Vn(()=>{if(!nd||jt||"undefined"==typeof document)return;const e=e=>{(e=>Array.from(e.dataTransfer?.types??[]).includes(ot))(e)&&(ed.current=null,ys.start({key:gt,item:nd}))},n=e=>{ys.get()?.item.media&&(ed.current=Zn(e.dataTransfer))},t=()=>{ys.get()?.item.media&&ys.end()};return document.addEventListener("dragstart",e),document.addEventListener("drop",n,!0),document.addEventListener("dragend",t,!0),()=>{document.removeEventListener("dragstart",e),document.removeEventListener("drop",n,!0),document.removeEventListener("dragend",t,!0)}},[nd,jt,ys]);const td=()=>{const e=ed.current;return ed.current=null,e},od=ce(),rd=async e=>{if(!od)return e;const n=await od(e);return n?{...e,id:n.id,url:n.url}:null};const id=(e,n)=>{if(!qs)return;const t=Ln(ko.getState().appState.data,ki,n);if(!t)return;const o=t.node;So.replaceComponent(jn(t.place),t.place.index,{...o,props:{...qs.replace(o,e),id:o.props.id}})},ld=e=>{const n=jn(e),t=Fi(n);t&&Ui(t.node,t.slot,!1),ml(n,e.index)},sd=(e,n)=>/* @__PURE__ */ft(Ge,{...jt?{}:bs.seam({place:{...En(e),index:n}})},`seam:${e}:${n}`),dd={rowClick:bl,isCollapsed:Yr,toggleCollapse:Gr},ad=e=>{const n=String(e.props.id),t=bi.findIndex(e=>String(e.props.id)===n),o=_t(n),r=Ai(o),i=Yr(n),l=$i(e.type),s=Or.rowName?Or.rowName(e,"section",l):l,d=e=>sd(o,e);/* @__PURE__ */
|
|
16
16
|
return ht(mt,{children:[
|
|
17
|
-
/* @__PURE__ */ft(He,{words:lo,icon:/* @__PURE__ */ft(Br,{type:e.type,size:13}),name:s,preview:kl(e),marks:Sl(e),onSelect:()=>al(t),nameSlot:Zi(
|
|
17
|
+
/* @__PURE__ */ft(He,{words:lo,icon:/* @__PURE__ */ft(Br,{type:e.type,size:13}),name:s,preview:kl(e),marks:Sl(e),onSelect:()=>al(t),nameSlot:Zi(Oe,t,n,s),selected:lr===n,badge:Xl(e)?void 0:_l,shared:Xl(e),actions:wl(e,Oe,t)??void 0,rowProps:{"data-node-id":n,onClick:bl(()=>al(t))},fold:{open:!i,label:"section",onToggle:()=>Gr(n)}}),!i&&/* @__PURE__ */ht(We,{children:[r.map((n,t)=>{const r=String(n.props.id),i=ji(n),l=jl(n),s=l&&Yr(r),a=()=>Ll(o,t,r,e.type),{rowProps:c,...p}=bs.row({item:{id:r,zone:o,index:t,type:n.type},place:{...En(o),index:t}},{"data-node-id":r,onClick:bl(a)});/* @__PURE__ */
|
|
18
18
|
return ht(Jn,{children:[d(t),
|
|
19
|
-
/* @__PURE__ */ft(He,{words:lo,icon:/* @__PURE__ */ft(Br,{type:n.type,size:13}),name:i,preview:kl(n),marks:Sl(n),onSelect:a,nameSlot:Zi(o,t,r,i),selected:lr===r,hidden:Boolean(n.props._hidden),...p,fold:l?{open:!s,label:"section",onToggle:()=>
|
|
19
|
+
/* @__PURE__ */ft(He,{words:lo,icon:/* @__PURE__ */ft(Br,{type:n.type,size:13}),name:i,preview:kl(n),marks:Sl(n),onSelect:a,nameSlot:Zi(o,t,r,i),selected:lr===r,hidden:Boolean(n.props._hidden),...p,fold:l?{open:!s,label:"section",onToggle:()=>Gr(r)}:void 0,actions:/* @__PURE__ */ht(mt,{children:[vl(o,t,i),wl(n,o,t),xl(o,t,n,i)]}),rowProps:c}),l&&!s&&/* @__PURE__ */ft(We,{children:ud(n,2)})]},r)}),d(r.length)]})]})},cd=(e,n,t,o,r)=>{const i=String(e.props.id),l=`${i}:${n.slot}`,s=bs.dragging,d=!Yr(l)&&s?.rung?.nodeId!==i,a={...En(l),index:0},c=s&&!s.rung&&cs(s,a)?a:void 0,p=()=>Ui(e,n,!0),{rowProps:u,...f}=bs.row({item:{id:`rung:${l}`,zone:`${i}:${Ct}`,index:t,type:e.type,rung:{nodeId:i,slot:n.slot}},place:{parentId:i,slot:Ct,index:t},into:c,canDrag:Boolean(br.moveSlot)&&!1!==n.movable&&o>1},{"data-slot-zone":l,onClick:bl(p)}),h=jt?null:br.slotActions?.(e,n.slot);/* @__PURE__ */
|
|
20
20
|
return ht(Jn,{children:[n.heading,
|
|
21
|
-
/* @__PURE__ */ft(He,{words:lo,icon:n.glyph??null,name:n.label,badge:n.badge,onSelect:p,selected:Vi===l,...f,dragHint:n.dragHint,fold:{open:d,label:n.label,onToggle:()=>
|
|
22
|
-
return ft(mt,{children:t.map(t=>{const i=t.kids,l=t.rung?n+1:n,s
|
|
21
|
+
/* @__PURE__ */ft(He,{words:lo,icon:n.glyph??null,name:n.label,badge:n.badge,onSelect:p,selected:Vi===l,...f,dragHint:n.dragHint,fold:{open:d,label:n.label,onToggle:()=>Gr(l)},actions:h&&h.length>0?/* @__PURE__ */ft(mt,{children:h.map((t,o)=>/* @__PURE__ */ft(Ye,{kind:"delete"===t.kind?"delete":"plain",label:t.label,disabled:t.disabled,onClick:()=>((e,n,t)=>{if(jt||t.disabled)return;const o=String(e.props.id),r=e=>{"string"==typeof e&&Ji(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__ */ft(dt,{size:15}):/* @__PURE__ */ft(ut,{size:15})},`${o}:${t.kind}`))}):void 0,rowProps:u}),d&&/* @__PURE__ */ft(We,{children:r})]},l)},pd=(e,n)=>{const t=Bl(e),o=t.filter(e=>e.rung).length;let r=0;/* @__PURE__ */
|
|
22
|
+
return ft(mt,{children:t.map(t=>{const i=t.kids,l=t.rung?n+1:n,s=$l(e,void 0,t.slot),d=s?`${e.props.id}:${s.slot}`:null,a=null===t.slot?null:`${e.props.id}:${t.slot}`,c=(e,n)=>sd(e,n),p=/* @__PURE__ */ht(mt,{children:[i.map(({child:n,zone:t,index:o})=>{const r=lr===String(n.props.id),{collapsible:i,folded:s}=Tl(n,l,El(n.type)),d=String(n.props.id),a=rs(n),p=()=>Ll(t,o,d,e.type),{rowProps:u,...f}=bs.row({item:{id:d,zone:t,index:o,type:n.type},place:{...En(t),index:o}},{"data-node-id":d,onClick:bl(p)});/* @__PURE__ */
|
|
23
23
|
return ht(Jn,{children:[0===o&&c(t,0),
|
|
24
|
-
/* @__PURE__ */ft(He,{words:lo,icon:/* @__PURE__ */ft(Br,{type:n.type,size:13}),name:a,preview:kl(n),marks:Sl(n),onSelect:p,nameSlot:Zi(t,o,d,a),selected:r,hidden:Boolean(n.props._hidden),...f,fold:i?{open:!s,label:"group",onToggle:()=>
|
|
25
|
-
return ft(mt,{children:o.map(o=>{const l=o.kids,s=o.rung?n+1:n,d
|
|
24
|
+
/* @__PURE__ */ft(He,{words:lo,icon:/* @__PURE__ */ft(Br,{type:n.type,size:13}),name:a,preview:kl(n),marks:Sl(n),onSelect:p,nameSlot:Zi(t,o,d,a),selected:r,hidden:Boolean(n.props._hidden),...f,fold:i?{open:!s,label:"group",onToggle:()=>Gr(d)}:void 0,actions:/* @__PURE__ */ht(mt,{children:[vl(t,o,a),wl(n,t,o),xl(t,o,n,a)]}),rowProps:u}),i&&!s&&/* @__PURE__ */ft(We,{children:pd(n,l+1)}),c(t,o+1)]},String(n.props.id??`${t}-${o}`))}),null===a?d&&!i.some(e=>e.zone===d)?c(d,0):null:0!==i.length||!t.rung&&d!==a?null:c(a,0)]});return t.rung?cd(e,t.rung,r++,o,p):/* @__PURE__ */ft(Jn,{children:p},t.slot??"")})})},ud=(e,n)=>{const t=Sr(Vt?.data,e.type,String(e.props.id)),o=Bl(e),r=o.filter(e=>e.rung).length;let i=0;/* @__PURE__ */
|
|
25
|
+
return ft(mt,{children:o.map(o=>{const l=o.kids,s=o.rung?n+1:n,d=$l(e,t,o.slot),a=d?.spec??null,c=a&&Array.isArray(e.props[a.slot])?e.props[a.slot]:[],p=d&&d.choices?{slot:d.slot,choices:d.choices}:null,u=String(e.props.id),f=a&&!a.fixed?`${u}:${a.slot}`:null,h=p?`${u}:${p.slot}`:null,m=(e,n)=>sd(e,n),g=null===o.slot?null:`${u}:${o.slot}`,y=Boolean(a&&!a.fixed&&(null===g||g===f)),b=/* @__PURE__ */ht(mt,{children:[l.map(({child:n,zone:t,index:o})=>{const r=lr===String(n.props.id),i=Ki(n),l=String(n.props.id),{collapsible:d,folded:a}=Tl(n,s,El(n.type)),c=Ol(n.type),p=1===c.length?`${l}:${c[0]}`:null,u=p?{...En(p),index:Ai(p).length}:void 0,f=bs.dragging,h=u&&f&&cs(f,u)?u:void 0,g=()=>Ll(t,o,l,e.type),{rowProps:y,...b}=bs.row({item:{id:l,zone:t,index:o,type:n.type},place:{...En(t),index:o},into:h,canDrag:!vr(n.type,n)},{"data-node-id":l,onClick:bl(g)});/* @__PURE__ */
|
|
26
26
|
return ht(Jn,{children:[0===o&&m(t,0),
|
|
27
|
-
/* @__PURE__ */ft(He,{words:lo,icon:/* @__PURE__ */ft(Br,{type:n.type,size:13}),name:i,preview:kl(n),marks:Sl(n),onSelect:g,nameSlot:Zi(t,o,l,i),selected:r,hidden:Boolean(n.props._hidden),...
|
|
28
|
-
/* @__PURE__ */ft(z,{small:!0,label:a.addLabel,blocked:a.addBlocked?.(c)??null,onAdd:()=>Al(e.props.id,a.slot,a.childType,c.length,e.type)}),null===g?h&&!l.some(e=>e.zone===h)?m(h,0):null:0!==l.length||(o.rung?y:g!==h)?null:m(g,0)]});return o.rung?
|
|
27
|
+
/* @__PURE__ */ft(He,{words:lo,icon:/* @__PURE__ */ft(Br,{type:n.type,size:13}),name:i,preview:kl(n),marks:Sl(n),onSelect:g,nameSlot:Zi(t,o,l,i),selected:r,hidden:Boolean(n.props._hidden),...b,fold:d?{open:!a,label:"group",onToggle:()=>Gr(l)}:void 0,actions:vr(n.type,n)?wl(n,t,o)??void 0:/* @__PURE__ */ht(mt,{children:[vl(t,o,i),wl(n,t,o),xl(t,o,n,i)]}),rowProps:y}),d&&!a&&/* @__PURE__ */ft(We,{children:ud(n,s+1)}),m(t,o+1)]},String(n.props.id??`${t}-${o}`))}),y&&a&&
|
|
28
|
+
/* @__PURE__ */ft(z,{small:!0,label:a.addLabel,blocked:a.addBlocked?.(c)??null,onAdd:()=>Al(e.props.id,a.slot,a.childType,c.length,e.type)}),null===g?h&&!l.some(e=>e.zone===h)?m(h,0):null:0!==l.length||(o.rung?y:g!==h)?null:m(g,0)]});return o.rung?cd(e,o.rung,i++,r,b):/* @__PURE__ */ft(Jn,{children:b},o.slot??"")})})},fd=Zo,hd=e=>"panel"in e?{id:e.id,label:e.label,icon:e.icon,active:xo&&!fd&&yr===e.id,onSelect:()=>gi(e.id)}:e,md=[...(gr.railLead??[]).map(hd),{id:"sections",label:io.layers,icon:/* @__PURE__ */ft(ge,{}),active:xo&&!fd&&"sections"===yr,onSelect:()=>gi("sections")},...(gr.railTrail??[]).map(hd)],gd=Mo?{onPress:jo}:Rt?{onPress:()=>{x(xn,{accept:"image/*",title:fo.mediaLibrary})}}:null,yd={value:md.find(e=>!0===e.active)?.id??"",press:e=>{const n=md.find(n=>n.id===e);n&&!n.disabled&&!0!==n.active&&n.onSelect?.()},items:md.map(e=>({id:e.id,icon:e.icon,label:/* @__PURE__ */ft("span",{className:"sr-only",children:e.label}),tooltip:e.label,disabled:e.disabled}))},bd=[...gr.railLead??[],...gr.railTrail??[]].find(e=>"panel"in e&&e.id===yr),vd=Boolean(ro?.foldable),kd=ro?.label??(Dt?io.pageSections:io.templateSections),Sd=vd&&Yr(Nt),wd=/* @__PURE__ */ht(mt,{children:[bi.map((e,n)=>{if(no(e)||to(e)||Zt(e.type))return null;const t=lr===String(e.props.id),o=Boolean(e.props._hidden);Nl(e);const r=String(e.props.id),i=gr.hasOwnRows?.(e)??!1,l=jl(e)||i,s=l&&Yr(r),d=Ol(e.type),a=1===d.length?`${r}:${d[0]}`:null,c=a?{...En(a),index:Ai(a).length}:void 0,p=bs.dragging,u=c&&p&&cs(p,c)?c:void 0,{rowProps:f,...h}=bs.row({item:{id:r,zone:Oe,index:n,type:e.type},place:{...En(Oe),index:n},into:u,canDrag:!vr(e.type,e)},{"data-node-id":r,onClick:bl(()=>al(n))});/* @__PURE__ */
|
|
29
29
|
return ht(Jn,{children:[n>0&&zl(n),
|
|
30
|
-
/* @__PURE__ */ft(He,{words:lo,icon:/* @__PURE__ */ft(Br,{type:e.type,size:13}),name:ji(e),preview:kl(e),marks:Sl(e),shared:
|
|
30
|
+
/* @__PURE__ */ft(He,{words:lo,icon:/* @__PURE__ */ft(Br,{type:e.type,size:13}),name:ji(e),preview:kl(e),marks:Sl(e),shared:Xl(e),onSelect:()=>al(n),nameSlot:Zi(Oe,n,r,ji(e)),selected:t,hidden:o,...h,fold:l?{open:!s,label:"section",onToggle:()=>Gr(r)}:void 0,actions:/* @__PURE__ */ht(mt,{children:[vl(Oe,n,ji(e)),wl(e,Oe,n),xl(Oe,n,e,ji(e))]}),rowProps:f}),jl(e)&&!s&&/* @__PURE__ */ht(We,{children:[ud(e,1),gr.partRows?.(e,dd)]}),i&&!s&&/* @__PURE__ */ft(We,{children:gr.ownRows?.(e,n,dd)})]},String(e.props.id??n))}),ns>0&&zl(ns)]}),xd=(e,n,t)=>{const o=String(e.props.id),r=Il(e).length>0||Pl(e)||Boolean(xr(e.type)),i=r&&Yr(o),l="header"===t?io.header:io.footer,s=Or.rowName?Or.rowName(e,"section",l):l;/* @__PURE__ */
|
|
31
31
|
return ht(mt,{children:[
|
|
32
|
-
/* @__PURE__ */ft(He,{words:lo,icon:/* @__PURE__ */ft(Br,{type:t,size:13}),name:s,preview:kl(e),marks:Sl(e),badge:
|
|
32
|
+
/* @__PURE__ */ft(He,{words:lo,icon:/* @__PURE__ */ft(Br,{type:t,size:13}),name:s,preview:kl(e),marks:Sl(e),badge:Xl(e)?void 0:_l,shared:Xl(e),onSelect:()=>al(n),nameSlot:Zi(Oe,n,o,s),selected:lr===String(e.props.id),fold:r?{open:!i,label:"section",onToggle:()=>Gr(o)}:void 0,actions:wl(e,Oe,n)??void 0,rowProps:{"data-node-id":o,onClick:bl(()=>al(n))}}),r&&!i&&/* @__PURE__ */ft(We,{children:pd(e,1)})]})};return(gr.wrap??(e=>e))(
|
|
33
33
|
/* @__PURE__ */ft(ee,{target:Uo,children:/* @__PURE__ */ht("div",{ref:Wo,className:"sf-editor es-editor",style:dn(Vr),onContextMenu:ol.onEditorContextMenu,...p(xn),children:[
|
|
34
34
|
/* @__PURE__ */ht(qe,{children:[
|
|
35
|
-
/* @__PURE__ */ht("div",{className:"es-cluster es-cluster--left",children:[
|
|
35
|
+
/* @__PURE__ */ht("div",{className:"es-cluster es-cluster--left",children:[gd?/* @__PURE__ */ft(Xn,{variant:"secondary",className:"es-barbtn",leftIcon:/* @__PURE__ */ft(ye,{}),onClick:gd.onPress,children:io.railMedia}):null,
|
|
36
36
|
/* @__PURE__ */ft(en,{label:io.bar.undo,disabled:Boolean(jt)||!Wt.hasPast,onClick:()=>Wt.back(),children:/* @__PURE__ */ft(rt,{})}),
|
|
37
37
|
/* @__PURE__ */ft(en,{label:io.bar.redo,disabled:Boolean(jt)||!Wt.hasFuture,onClick:()=>Wt.forward(),children:/* @__PURE__ */ft(it,{})})]}),
|
|
38
38
|
/* @__PURE__ */ht(nn,{children:[
|
|
39
|
-
/* @__PURE__ */ft(tn,{devices:Co,value:Po,onChange
|
|
40
|
-
/* @__PURE__ */ft(en,{label:io.bar.refresh,tip:io.bar.refreshTip,onClick:()=>{Ho.current=(()=>{const e=Uo?.document;if(!e)return null;const n=
|
|
39
|
+
/* @__PURE__ */ft(tn,{devices:Co,value:Po,onChange:$o}),
|
|
40
|
+
/* @__PURE__ */ft(en,{label:io.bar.refresh,tip:io.bar.refreshTip,onClick:()=>{Ho.current=(()=>{const e=Uo?.document;if(!e)return null;const n=bi.findIndex(to),t=n>=0?n:bi.length;let o=null;for(let n=0;n<t;n++){const t=bi[n]?.props?.id;if(null==t)continue;const r=$n(e,`[data-easel-block="${CSS.escape(String(t))}"]`);if(!r)continue;const i=r.getBoundingClientRect().top;i<=4&&(null===o||i>o.offset)&&(o={id:String(t),offset:i})}if(!o){const e=Ut?.props?.id??bi[0]?.props?.id;null!=e&&(o={id:String(e),offset:0})}return o})(),Vo(e=>e+1)},children:/* @__PURE__ */ft(lt,{})}),gr.barView?.()]}),
|
|
41
41
|
/* @__PURE__ */ht(nn,{kind:"right",style:{minWidth:300},children:[
|
|
42
|
-
/* @__PURE__ */ft(
|
|
43
|
-
/* @__PURE__ */ft(
|
|
42
|
+
/* @__PURE__ */ft(v,{input:Ko,words:io.saveStatus}),Bn?/* @__PURE__ */ft(Bn,{}):null,gr.barLead?.(),gr.barTrail?.(),gr.mainAction||!gr.barMain?/* @__PURE__ */ft(k,{input:Ko,action:_r,readOnly:Boolean(jt),saveSwitch:Lt,onToggleAutoSave:Pt,onSaveNow:Qo,bar:io.bar,words:io.saveStatus}):gr.barMain()]})]}),
|
|
43
|
+
/* @__PURE__ */ft(b,{}),
|
|
44
44
|
/* @__PURE__ */ht("div",{className:"sf-body",children:[xo?/* @__PURE__ */ht(mt,{children:[
|
|
45
45
|
/* @__PURE__ */ht("aside",{className:"es-sidepanel es-sidepanel--left sf-panel sf-panel--left","aria-label":io.leftPanel,children:[
|
|
46
46
|
/* @__PURE__ */ht("div",{className:"es-paneltabs es-paneltabs--with-hide",children:[
|
|
47
47
|
/* @__PURE__ */ft(B,{side:"left",onHide:hi}),
|
|
48
48
|
/* @__PURE__ */ft("span",{className:"es-paneltabs-divider","aria-hidden":"true"}),
|
|
49
|
-
/* @__PURE__ */ft(Kn,{variant:"underline",block:!0,"aria-label":io.bar.views,value:
|
|
50
|
-
/* @__PURE__ */ft(
|
|
51
|
-
/* @__PURE__ */ft(on,{label:os?io.expandAll:io.collapseAll,title:0===ts.length?io.nothingToFold:void 0,disabled:0===ts.length,onClick:()=>Fr(e=>{const n=new Set(ts);return os?new Set([...e].filter(e=>!n.has(e))):/* @__PURE__ */new Set([...e,...ts])}),children:/* @__PURE__ */ft(
|
|
52
|
-
/* @__PURE__ */ht(Ue,{className:"sf-tree sf-scroll",words:lo,children:[ql&&/* @__PURE__ */ht(mt,{children:[!Yl&&/* @__PURE__ */ft(Je,{children:io.header}),
|
|
53
|
-
/* @__PURE__ */ft(He,{words:lo,icon:null,name:
|
|
49
|
+
/* @__PURE__ */ft(Kn,{variant:"underline",block:!0,"aria-label":io.bar.views,value:yd.value,onChange:yd.press,items:yd.items})]}),Zo?/* @__PURE__ */ft(C,{at:er?{label:(e=>{const n=ds(e.zone);if(n)return io.add.addingTo({name:Or.rowName?yl(n,!0):$i(n.type)});if(e.zone===Oe){const n=bi[e.index];return n&&!to(n)?io.add.addingBefore({name:yl(n,!0)}):io.add.addingAtEnd}const t=us(e.zone);return t?io.add.addingTo({name:t.parentName}):io.add.addingHere})(er),onClear:()=>nr(null)}:void 0,placeBlocks:er&&er.zone!==Oe?us(er.zone)?.choices:void 0,canTake:er?e=>{if(!er)return null;const n={...En(er.zone),index:er.index};if(hs(e,n))return null;if("shared"===e.kind&&er.zone===Oe&&!Gt.shared?.nodeOf(e.section))return io.shared.alreadyHere;const t=ds(er.zone);if(t)return io.add.notInside({name:yl(t,!0)});if(er.zone===Oe)return io.add.onlySections;const o=us(er.zone);return o?io.add.notInside({name:o.parentName}):io.add.onlySections}:void 0,onPick:er?e=>{if(!er)return;const n={...En(er.zone),index:er.index};hs(e,n)&&(ms(e,n),gl())}:void 0,itemFor:e=>({id:`new:${e.kind}:${Ot(e)}`,zone:"",index:-1,type:"template"===e.kind?e.template.node.type:"shared"===e.kind?e.section.node.type:Ot(e),add:e}),session:ys,siteWide:gr.addPanelRow?.(gl),onClose:gl,readOnly:Boolean(jt)}):bd?bd.panel({onHide:hi,notify:Zr}):/* @__PURE__ */ht(mt,{children:[
|
|
50
|
+
/* @__PURE__ */ft(I,{icon:/* @__PURE__ */ft(ge,{}),title:io.layers,context:ho,actions:/* @__PURE__ */ht(mt,{children:[!jt&&/* @__PURE__ */ft(on,{label:io.add.title,onClick:()=>hl(null),children:/* @__PURE__ */ft(st,{size:15})}),
|
|
51
|
+
/* @__PURE__ */ft(on,{label:os?io.expandAll:io.collapseAll,title:0===ts.length?io.nothingToFold:void 0,disabled:0===ts.length,onClick:()=>Fr(e=>{const n=new Set(ts);return os?new Set([...e].filter(e=>!n.has(e))):/* @__PURE__ */new Set([...e,...ts])}),children:/* @__PURE__ */ft(wt,{expand:os})})]})}),
|
|
52
|
+
/* @__PURE__ */ht(Ue,{className:"sf-tree sf-scroll",words:lo,children:[ql&&/* @__PURE__ */ht(mt,{children:[!Yl&&/* @__PURE__ */ft(Je,{children:io.header}),ad(ql)]}),Ft&&!(Yl&&ql)&&/* @__PURE__ */ht(mt,{children:[!Yl&&/* @__PURE__ */ft(Je,{children:io.header}),!oo&&/* @__PURE__ */ft(He,{words:lo,icon:/* @__PURE__ */ft(Br,{type:"header",size:13}),name:io.header,badge:Zl?void 0:_l,shared:Zl,onSelect:yi,selected:rr.kind===eo?.kind,rowProps:{onClick:bl(yi)}})]}),Wl&&!(Yl&&ql)&&xd(Wl,Hl,"header"),!vd&&/* @__PURE__ */ft(Je,{children:kd}),vd?/* @__PURE__ */ht(mt,{children:[
|
|
53
|
+
/* @__PURE__ */ft(He,{words:lo,icon:null,name:kd,fold:{open:!Sd,label:kd,onToggle:()=>Gr(Nt)}}),!Sd&&/* @__PURE__ */ft(We,{children:wd})]}):wd,Ft&&!Yl&&/* @__PURE__ */ft(Je,{children:io.footer}),Vl&&!(Yl&&es)&&xd(Vl,Fl,"footer"),es&&ad(es),gr.treeFoot?.()]})]})]}),
|
|
54
54
|
/* @__PURE__ */ft(rn,{side:"left",width:Vr.left,min:sn.left,max:ln,defaultWidth:h.left,label:io.resizeLeftPanel,onResize:Ur})]}):/* @__PURE__ */ft(P,{side:"left",onShow:hi}),
|
|
55
55
|
/* @__PURE__ */ht("div",{ref:ei,className:"sf-center sf-scroll","data-sf-canvas-head":ii?"":void 0,style:{overflowX:pi?"auto":"hidden",overflowY:"hidden"},children:[ii&&/* @__PURE__ */ft("div",{ref:li,className:"sf-canvas-head",children:/* @__PURE__ */ft(ii,{device:Po})}),
|
|
56
56
|
/* @__PURE__ */ht("div",{className:"sf-frame-scaler",style:ui,children:[
|
|
57
57
|
/* @__PURE__ */ft("div",{className:"sf-frame "+(Po===Bo?"":`sf-frame--${Po}`),style:fi,children:/* @__PURE__ */ht("div",{className:"sf-preview-host",children:[
|
|
58
58
|
/* @__PURE__ */ft(Fe.Provider,{value:Jl,children:/* @__PURE__ */ft(Ve.Provider,{value:Ql,children:/* @__PURE__ */ft(mo,{},Fo)})}),
|
|
59
|
-
/* @__PURE__ */ft(gn,{canvas:Uo,session:ys,model:
|
|
60
|
-
/* @__PURE__ */ft(yn,{index:e.index,label:io.addSectionHere,onInsert:()=>hl(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))})]})})
|
|
61
|
-
/* @__PURE__ */ft("div",{className:"es-sidepanel es-sidepanel--right","data-es-host-panel":"",children:
|
|
59
|
+
/* @__PURE__ */ft(gn,{canvas:Uo,session:ys,model:Us,measure:Ys,canDrop:Xs,onDrop:Qs,choose:Os,tag:zs,onPick:_s,dropOn:qs?{accepts:(e,n)=>{if(!e.media||!qs||n.item.rung)return!1;const t=Ln(Vt.data,ki,n.item.id);return null!==t&&qs.takes(t.node)},onDrop:(e,n)=>(e=>{const n=td();n&&qs&&rd(n).then(n=>{n&&id(n,e.item.id)})})(n),label:()=>io.canvasReplaceImage}:void 0,onZoneAdd:ld,onSeamAdd:ld,zoneAddLabel:io.canvasAddBlock,words:so.canvas,readOnly:Boolean(jt),revision:Vt.data}),tr.length>0&&!Jo&&/* @__PURE__ */ft("div",{className:"sf-preview-gaps",children:tr.map(e=>
|
|
60
|
+
/* @__PURE__ */ft(yn,{index:e.index,label:io.addSectionHere,onInsert:()=>hl(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))})]})}),js?/* @__PURE__ */ft(St,{canvas:Uo,tabs:As,onSelect:Wi,onPointer:Ps}):null]})]}),zo?/* @__PURE__ */ht(mt,{children:[In?
|
|
61
|
+
/* @__PURE__ */ft("div",{className:"es-sidepanel es-sidepanel--right","data-es-host-panel":"",children:In}):/* @__PURE__ */ft(mt,{children:/* @__PURE__ */ft(u,{value:{selectChild:Ll,addChild:Al,childRowName:Ki,blockRowName:rs},children:/* @__PURE__ */ft(go,{mode:rr,onOpenWebsiteSettings:gr.openSettings??(()=>{}),onOpenSiteStyles:gr.openStyles,onOpenPageStyles:gr.openPageStyles,onSelectNode:Tr,onNotify:Zr,onHidePanel:mi,nodeActions:Ut?Ne(Yt,Ut.type):Bt})})}),
|
|
62
62
|
/* @__PURE__ */ft(rn,{side:"right",width:Vr.right,min:sn.right,max:ln,defaultWidth:h.right,label:io.resizeSettingsPanel,onResize:Jr})]}):
|
|
63
63
|
/* @__PURE__ */ft(P,{side:"right",onShow:mi})]}),ol.menu,
|
|
64
|
-
/* @__PURE__ */ft(ie,{}),
|
|
64
|
+
/* @__PURE__ */ft(ie,{}),Oi?/* @__PURE__ */ft(yt,{name:Oi.name,onMake:e=>(async(e,n)=>{const t=bi.find(n=>String(n.props.id)===e),o=Gt.shared;if(!t||!o)return;let r;try{r=await N(Ci).create(n,t)}catch{return void Zr(io.shared.makeFailed,"error")}o.adopt(t,r),Ni(null)})(Oi.id,e),onCancel:()=>Ni(null)}):null]})}))}export{Pt as ScreenChrome};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{STANDARD_MARKUP as t,writeMarkedLines as e,sameMarks as n,markedLines as r,spanFor as l,marksIn as o,toggleMark as i,styleIn as a,styleOver as s,listIn as c,setList as u,colorOver as d,unlinkAt as f,linkOver as h,colorIn as p,findLink as m,clearStyle as g,isSafeLinkHref as b}from"efficient-shell/markup";import{Tooltip as v,ColorSwatch as k,ColorPickerPanel as y,Button as x}from"efficient-shell/ui";import{jsxs as w,jsx as D}from"react/jsx-runtime";function M(t,e){return t&&t.start!==t.end?t:{start:0,end:e}}var N=/* @__PURE__ */new Set(["script","style","head","title","meta","link","template","noscript","svg","math","object","iframe"]),T=/* @__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 C(l,o){const i=o.rules??t,a=l.html&&""!==l.html.trim()?function(t,l,o){const i=l.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,r)=>{if(3===t.nodeType){for(const l of t.textContent??""){const t=/\s/.test(l)?" ":l,o=s();" "===t&&(0===o.length&&a.length>1||" "===o[o.length-1]?.ch)||o.push({ch:t,bold:e,italic:n,href:r})}return}if(1!==t.nodeType&&11!==t.nodeType)return;const l=t,o=1===t.nodeType?l.localName:"";if(N.has(o))return;if("br"===o)return void a.push([]);let i=e,d=n,f=r;if("b"!==o&&"strong"!==o||(i=!0),"i"!==o&&"em"!==o||(d=!0),"a"===o){const t=(l.getAttribute("href")??"").trim();f=b(t)?t:null}const h=1===t.nodeType?l.style:null;if(h){const t=h.fontWeight;"bold"===t||"bolder"===t||Number(t)>=600?i=!0:("normal"===t||"lighter"===t||""!==t&&Number(t)<600)&&(i=!1),"italic"===h.fontStyle||"oblique"===h.fontStyle?d=!0:"normal"===h.fontStyle&&(d=!1)}const p=T.has(o);p&&c();for(const e of[...t.childNodes])u(e,i,d,f);p&&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,l){const o=e=>t.map((n,r)=>n[e]&&(" "!==n.ch||Boolean(t[r-1]?.[e])&&Boolean(t[r+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=S(t,a.bold?o("bold"):null,a.italic?o("italic"):null,a.links),s=e([i]).text;if(n([i],r(s,l)))return s}return t.map(t=>t.ch).join("")}(t,o))}(l.html,o.doc,i):(l.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 S(t,e,n,r){let o=0,i=null,a=null,s=null;return{bullet:!1,chars:t.map((t,c)=>{const u=r?t.href:null;return i=null===u?null:i&&i.href===u?i:l(++o,"link",u),a=e?.[c]?a??l(++o,"bold"):null,s=n?.[c]?s??l(++o,"italic"):null,{ch:t.ch,at:-1,marks:[i,a,s].filter(t=>null!==t)}})}}var A="application/x-efficient-markup",E=/^([0-9]{1,3})\. $/;function B(t,e){const n=t.split("\n"),l=r(t,e);let o=0,i=0;const a=l.map((t,e)=>{const r=!t.bullet&&null==t.number&&"- "===n[e],l=null!=t.number||t.bullet?null:E.exec(n[e]),a=t.bullet||r,s=l?l[1]:t.number??null,c=r||l?[]:t.chars,u=c.map(t=>t.ch).join(""),d=null!=s?s.length+2:a?2:0,f={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,f});return{lines:a,text:a.map(t=>t.text).join("\n")}}function R(t,e){const{lines:n}=t;for(let t=0;t<n.length;t+=1){const r=n[t];if(e<=r.vis+r.text.length||t===n.length-1)return[r,Math.max(0,Math.min(e-r.vis,r.text.length)),t]}return[n[0],0,0]}function L(t,e){const[n,r]=R(t,e);if(0===r)return n.src;let l=0;for(const t of n.chars){if(r<=l+t.ch.length)return t.at+(r-l);l+=t.ch.length}return n.src}function K(t,e){const[n,r]=R(t,e);let l=0;for(const t of n.chars){if(r===l)return t.at;l+=t.ch.length}return L(t,e)}function W(t,e){const{lines:n}=t;let r=n[0];for(const t of n)e>=t.start&&(r=t);let l=0;for(const t of r.chars){if(!(e>=t.at+t.ch.length)){e>t.at&&(l+=e-t.at);break}l+=t.ch.length}return r.vis+l}function P(t,e,n){return[W(t,e),W(t,n)]}function j(t,e,n){return e===n?[L(t,e),L(t,e)]:[K(t,e),L(t,n)]}function V(t,e){let n=0;for(let r=0;r<t.chars.length;r+=1){if(n>=e)return r;n+=t.chars[r].ch.length}return t.chars.length}function q(t,o,i,a,s){const c=B(t,o),[u,d,f]=R(c,Math.min(i,a)),[h,p,m]=R(c,Math.max(i,a)),g=V(u,d),b=V(h,p),v=u.chars.slice(0,g),k=h.chars.slice(b),y=i!==a&&u.chars[g]&&(f!==m||g<b)?u.chars[g].marks:function(t,e){const n=t.chars[e-1],r=t.chars[e],l=(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&&r?.marks.some(e=>e.id===t.id));return l(n.marks,e)}return r?l(r.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=r(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,r)=>(r>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"),l={bullet:u.bullet,number:u.number??null,chars:[...v,...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,...k]}}else l.chars.push(...k);return{lines:[...c.lines.slice(0,f).map(({bullet:t,number:e,chars:n})=>({bullet:t,number:e,chars:n})),l,...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=l(x++,t);n&&(e=[...e,n])}if(void 0!==s.color){e=e.filter(t=>"color"!==t.kind);const t=null===s.color?null:l(x++,"color",s.color);t&&(e=[...e,t])}return e})(y),y,[]];let N="",T="";for(const t of M){const r=D(t),l=e(r.lines).text;if(N=l,T=r.shown,n(r.lines,B(l,o).lines))break}return{text:N,caret:Math.min(i,a)+T.length}}function F(t,e,n,r){const l=B(t,e),[o,,i]=R(l,n);return n!==r||!o.bullet&&null==o.number||""!==o.text?q(t,e,n,r,{text:"\n"}):I(t,e,i,!1,n)}function I(t,n,r,l,o){const i=B(t,n).lines.map(({bullet:t,number:e,chars:n},o)=>o===r?{bullet:l,number:null,chars:n}:{bullet:t,number:e,chars:n});return{text:e(i).text,caret:o}}function O(t,n,r,l){const o=B(t,n),[i,a,s]=R(o,Math.min(r,l)),[c,u,d]=R(o,Math.max(r,l)),f=o.lines.slice(s,d+1).map(({bullet:t,number:e,chars:n},r)=>{const l=0===r?V(i,a):0,o=r===d-s?V(c,u):n.length;return{bullet:t,number:e,chars:n.slice(l,o)}});return e(f).text}function z(t,e,n){if(n<0){const n=t.charCodeAt(e-1);return e-(n>=56320&&n<=57343&&e>=2?2:1)}const r=t.charCodeAt(e);return e+(r>=55296&&r<=56319?2:1)}function U(t){const{value:e,rules:n,multiline:r,inputType:l,pending:o}=t;let[i,a]=t.sel;t.target&&t.target[0]!==t.target[1]&&l.startsWith("delete")&&([i,a]=t.target);const s=[i,a];if("historyUndo"===l||"historyRedo"===l)return{kind:"history",dir:"historyUndo"===l?"undo":"redo"};if("formatBold"===l||"formatItalic"===l||"formatStrikeThrough"===l)return{kind:"format",style:"formatBold"===l?"bold":"formatItalic"===l?"italic":"strike"};if("insertParagraph"===l||"insertLineBreak"===l)return r?{kind:"edit",edit:F(e,n,i,a),range:s}:null;if(l.startsWith("insert")){if("insertTranspose"===l)return null;let c=t.data??"";if("insertFromDrop"===l||"insertFromPaste"===l){const l=C({html:t.html??void 0,text:c},{doc:t.doc,multiline:r,rules:n});return{kind:"edit",edit:q(e,n,i,a,{markup:l}),range:s}}return r||(c=c.replace(/\s*\r?\n\s*/g," ")),{kind:"type",edit:q(e,n,i,a,{text:c,add:o?.add,drop:o?.drop,color:o?.color}),range:s}}if(l.startsWith("delete")){const t=B(e,n),r=t.text;if(i===a){const o=l.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:I(e,n,c,!1,i),range:s};if(o?0===i:i===r.length)return null;o?i=z(r,i,-1):a=z(r,a,1)}return{kind:"type",edit:q(e,n,i,a,{text:""}),range:[i,a]}}return null}var $=1e3;function H(t=200){let e=[],n=[],r=null,l=0;return{record(o,i,a){const s="type"===i&&"type"===r&&a-l<1e3;r=i,l=a,n=[],s||(e.push(o),e.length>t&&e.shift())},undo(t){const l=e.pop();return l?(n.push(t),r=null,l):null},redo(t){const l=n.pop();return l?(e.push(t),r=null,l):null},reset(){e=[],n=[],r=null}}}var X=t=>t.preventDefault();function Y(t,e){if(t)return t.startsWith("#")?t:e?.find(e=>e.name===t)?.value}function Z({colors:t,current:e,words:n,onPick:r}){const l=null===e?null:e.startsWith("#")?e.toLowerCase():t.find(t=>t.name===e)?.value.toLowerCase()??null;/* @__PURE__ */
|
|
2
|
+
return w("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__ */D("span",{className:"es-copy-pop-label",children:n.theme}),
|
|
4
|
+
/* @__PURE__ */D("div",{className:"es-copy-theme",role:"group","aria-label":n.theme,children:t.map(t=>/* @__PURE__ */D(v,{content:`${t.label} · ${t.value.toUpperCase()}`,children:/* @__PURE__ */D(k,{color:t.value,size:"sm",className:"es-copy-theme-swatch","data-color":t.name,"aria-label":t.label,selected:e===t.name,onMouseDown:X,onClick:()=>r(t.name)})},t.name))}),
|
|
5
|
+
/* @__PURE__ */D("span",{className:"es-copy-pop-label",children:n.any}),
|
|
6
|
+
/* @__PURE__ */D(y,{className:"es-copy-any",value:l??"",onChange:t=>{t!==e&&r(t)},label:n.title,dragWrites:"end"}),
|
|
7
|
+
/* @__PURE__ */D("div",{className:"es-copy-pop-foot",children:/* @__PURE__ */D(x,{variant:"ghost-danger",size:"sm","data-window-action":"remove",onMouseDown:X,onClick:()=>r(null),children:n.remove})})]})}var G={sup:"sub",sub:"sup"};function J(t){const{value:e,rules:n,start:r,end:l,style:a,pending:s}=t,c=G[a];if(r===l){const t=o(e,r,l,n),i=s&&s.at===r?s:null,u=t.has(a),d=!!i?.add.includes(a)||!i?.drop.includes(a)&&u;let f=(i?.add??[]).filter(t=>t!==a),h=(i?.drop??[]).filter(t=>t!==a);return d&&u?h.push(a):d||u||f.push(a),!d&&c&&(f=f.filter(t=>t!==c),t.has(c)&&(h=[...h.filter(t=>t!==c),c])),{kind:"pending",pending:f.length||h.length||void 0!==i?.color?{add:f,drop:h,color:i?.color,at:r}:null}}let u=e,d=r,f=l;if(c&&!o(u,d,f,n).has(a)&&o(u,d,f,n).has(c)){const t=i(u,d,f,c,n);({text:u,selectionStart:d,selectionEnd:f}=t)}return{kind:"edit",result:i(u,d,f,a,n)}}function Q(t){if(null!==t.id&&a(t.value,t.start,t.end,t.rules)===t.id)return null;const e=s(t.value,t.start,t.end,t.id,t.rules);return e.text===t.value?null:e}var _=/^(block|list-item|flex|grid|table|flow-root)$/;function tt(t){const e=t.ownerDocument.defaultView;return!!e&&_.test(e.getComputedStyle(t).display)}function et(t,e){const n=[],r=/* @__PURE__ */new Map,l=/* @__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(),r.set(c,o.length),n.push({node:c,start:o.length,length:c.data.length}),o+=c.data,l.set(c,o.length);continue}if(1!==c.nodeType)continue;const t=c;if(e&&t.matches(e)){r.set(t,o.length),l.set(t,o.length);continue}if("BR"===t.tagName){a(),r.set(t,o.length),o+="\n",l.set(t,o.length);continue}const u=tt(t);u&&((i||o.length>0&&!o.endsWith("\n"))&&(o+="\n"),i=!1),r.set(t,o.length);const d=o.length;s(t),u&&o.length===d&&!i&&n.push({node:t,start:d,length:0}),l.set(t,o.length),u&&(i=!0)}};r.set(t,0),s(t),l.set(t,o.length);return{text:o,at:(t,e)=>{if(3===t.nodeType)return(r.get(t)??0)+Math.min(e,t.data.length);const n=t.childNodes;return e<n.length?r.get(n[e])??l.get(t)??0:l.get(t)??o.length},dom:e=>{for(let t=0;t<n.length;t+=1){const r=n[t],l=r.start+r.length;if(e<r.start)return[r.node,0];if(e<l||e===l&&(t===n.length-1||n[t+1].start>e))return 3===r.node.nodeType?[r.node,e-r.start]:[r.node,0]}const r=n[n.length-1];return r?3===r.node.nodeType?[r.node,r.length]:[r.node,0]:[t,0]}}}function nt(t){const e=t.element();if(!e)return null;let n=t.value;const r=t.rules;if(et(e,t.skip).text!==B(n,r).text)return null;const l=t.now??(()=>Date.now()),i=H();let s=e,b=!1,v=null,k=null,y=[t.caret[0],t.caret[1]],x=null,w=!1,D=!1;const N=()=>{D||t.onSelect?.()},T={contenteditable:e.getAttribute("contenteditable"),spellcheck:e.getAttribute("spellcheck")},S=()=>s.ownerDocument,E=()=>S().defaultView?.getSelection()??null,R=()=>{if(!k)return!0;at();const e=et(s,t.skip);if(e.text!==B(n,r).text)return!1;const[l,o]=k,[i,a]=e.dom(l),[c,u]=e.dom(o);return w||S().activeElement===s||s.focus({preventScroll:!0}),E()?.setBaseAndExtent(i,a,c,u),y=k,L=k,k=null,N(),!0};let L=null;const K=()=>{if(!L)return!1;const t=E(),e=t?.anchorNode??null;return!(e&&e.isConnected&&s.contains(e))||e===s&&0===t.anchorOffset&&(0!==L[0]||0!==L[1])},W=()=>{k=L,R()},V=()=>{R(),S().activeElement===s&&K()&&W();const e=E();if(!(e&&e.anchorNode&&e.focusNode&&s.contains(e.anchorNode)&&s.contains(e.focusNode)))return y;const n=et(s,t.skip),r=n.at(e.anchorNode,e.anchorOffset),l=n.at(e.focusNode,e.focusOffset);return y=r<=l?[r,l]:[l,r],y},F=t=>{const e=S().defaultView;t<=0||!e?L=null:e.requestAnimationFrame(()=>{b||k||(at(),S().activeElement===s?(K()&&(W(),N()),F(t-1)):L=null)})},I=(t,e)=>{k=[t,e];const n=t=>{if(b)return;if(R())return void F(3);const e=S().defaultView;t>0&&e&&e.requestAnimationFrame(()=>n(t-1))};n(30)},z=(e,r,o)=>{e.text!==n?(i.record({text:n,start:r[0],end:r[1]},o,l()),n=e.text,t.write(n),I(e.caret,e.caret),N()):I(e.caret,e.caret)},$=t=>j(B(n,r),t[0],t[1]),X=(t,e)=>{const l=M({start:t,end:e},n.length);return g(n,l.start,l.end,r)},Y=(e,o)=>{if(e.text===n)return;i.record({text:n,start:o[0],end:o[1]},"edit",l()),n=e.text,t.write(n);const[a,s]=P(B(n,r),e.selectionStart,e.selectionEnd);I(a,s),N()},Z=t=>{if(b)return;const e=V(),[l,o]=$(e),i=J({value:n,rules:r,start:l,end:o,style:t,pending:x});if("pending"===i.kind)return x=i.pending,void N();Y(i.result,e)},G=e=>{n=e.text,t.write(n),I(e.start,e.end)},_=e=>{if(b)return;b=!0,st.removeEventListener("selectionchange",ct),it(s);const n=E();n&&n.rangeCount>0&&s.contains(n.anchorNode)&&s.contains(n.focusNode)&&n.removeAllRanges(),t.end(e)},tt=(t,e)=>{const l=V();!b&&l[0]!==l[1]&&t.clipboardData&&(t.preventDefault(),t.clipboardData.setData("text/plain",B(n,r).text.slice(l[0],l[1])),t.clipboardData.setData(A,O(n,r,l[0],l[1])),e&&z(q(n,r,l[0],l[1],{text:""}),l,"edit"))},nt=t=>t.preventDefault(),rt=()=>{t.remount?.()},lt=[["keydown",e=>{if(b||e.isComposing)return;const r=e.metaKey||e.ctrlKey;if("Escape"!==e.key){if(r&&!e.altKey&&!e.shiftKey&&("k"===e.key||"K"===e.key)&&t.onLinkKey?.())return e.preventDefault(),void e.stopPropagation();if(r&&!e.altKey&&!e.shiftKey&&("KeyA"===e.code||"a"===e.key||"A"===e.key))return e.preventDefault(),e.stopPropagation(),I(0,et(s,t.skip).text.length),void N();if("Enter"===e.key&&(!e.shiftKey||r))return e.preventDefault(),e.stopPropagation(),void _("enter");if(r&&("z"===e.key||"Z"===e.key||"y"===e.key)){e.preventDefault(),e.stopPropagation();const t=V(),r={text:n,start:t[0],end:t[1]},l="y"===e.key||e.shiftKey?i.redo(r):i.undo(r);l&&G(l)}}else{if(e.preventDefault(),e.stopPropagation(),t.onEscape?.())return;_("escape")}}],["beforeinput",e=>{if(b)return;if("insertCompositionText"===e.inputType)return;e.preventDefault();const l=V(),o=et(s,t.skip),a="function"==typeof e.getTargetRanges?e.getTargetRanges()[0]:void 0,c=a&&!a.collapsed?[o.at(a.startContainer,a.startOffset),o.at(a.endContainer,a.endOffset)]:null,u=U({value:n,rules:r,multiline:t.multiline,inputType:e.inputType,data:e.data??e.dataTransfer?.getData("text/plain")??"",html:e.dataTransfer?.getData("text/html"),doc:S(),sel:l,target:c,pending:x&&x.at===$(l)[0]?x:null});if(u){if("type"!==u.kind&&"edit"!==u.kind||(x=null),"history"===u.kind){const t={text:n,start:l[0],end:l[1]},e="undo"===u.dir?i.undo(t):i.redo(t);return void(e&&G(e))}"format"!==u.kind?z(u.edit,u.range,u.kind):Z(u.style)}}],["compositionstart",()=>{v=V()}],["compositionend",e=>{const o=v;if(v=null,!b&&o)if(e.data){const a=q(n,r,o[0],o[1],{text:e.data});i.record({text:n,start:o[0],end:o[1]},"type",l()),n=a.text,t.write(n),rt(),I(a.caret,a.caret)}else rt(),I(o[0],o[0])}],["paste",e=>{if(b)return;e.preventDefault();const l=V(),o=e.clipboardData,i=o?.getData(A)??"",a=i?t.multiline?i:i.replace(/\s*\r?\n\s*/g," "):C({html:o?.getData("text/html")??"",text:o?.getData("text/plain")??""},{doc:S(),multiline:t.multiline,rules:r});z(q(n,r,l[0],l[1],{markup:a}),l,"edit")}],["copy",t=>tt(t,!1)],["cut",t=>tt(t,!0)],["drop",nt],["dragstart",nt],["blur",e=>{if(b||null!==v||w)return;const n=e.target,r=n.ownerDocument.defaultView,l=()=>{b||(n.isConnected&&n===t.element()?w||n.ownerDocument.activeElement===n||_("blur"):I(y[0],y[1]))};r?.requestAnimationFrame?r.requestAnimationFrame(l):setTimeout(l,0)}],["focus",()=>{w=!1}]];function ot(t){t.setAttribute("contenteditable","true"),t.setAttribute("spellcheck","false"),t.setAttribute("data-es-typing","");for(const[e,n]of lt)t.addEventListener(e,n)}function it(t){for(const[e,n]of lt)t.removeEventListener(e,n);null===T.contenteditable?t.removeAttribute("contenteditable"):t.setAttribute("contenteditable",T.contenteditable),null===T.spellcheck?t.removeAttribute("spellcheck"):t.setAttribute("spellcheck",T.spellcheck),t.removeAttribute("data-es-typing")}function at(){const e=t.element();e&&e!==s&&(it(s),s=e,ot(s))}const st=s.ownerDocument;function ct(){b||N()}return st.addEventListener("selectionchange",ct),ot(s),s.focus({preventScroll:!0}),I(t.caret[0],t.caret[1]),{get value(){return n},update(t){if(t===n)return;const e=B(t,r).text.length,[l,o]=V();n=t,i.reset(),I(Math.min(l,e),Math.min(o,e))},stop(t="stop"){_(t)},pressed(){let t;D=!0;try{t=V()}finally{D=!1}const[e,l]=$(t),i=o(n,e,l,r),s={};for(const t of["bold","italic","underline","strike","sup","sub","link"]){const n=i.has(t),r=x&&x.at===e?x:null;s[t]=!!r?.add.includes(t)||!r?.drop.includes(t)&&n}const u=x&&x.at===e&&void 0!==x.color?x:null;return{marks:s,list:c(n,e,l,r),selected:l>e,href:m(n,e,l)?.href??null,color:u?u.color??null:p(n,e,l,r),style:l>e?a(n,e,l,r):null,clearable:X(e,l).text!==n}},press:Z,insert(t){if(b)return;w=!1;const e=V(),[r,l]=$(e),o=r+t.length;Y({text:n.slice(0,r)+t+n.slice(l),selectionStart:o,selectionEnd:o},e),at(),s.focus({preventScroll:!0})},hold(){b||(V(),w=!0)},release(){w=!1},resume(){b||(w=!1,at(),s.focus({preventScroll:!0}),I(y[0],y[1]))},link(t){if(b)return;w=!1;const e=V(),[l,o]=$(e),i=null===t?f(n,l,o,r):h(n,l,o,t,r),a=i.text===n;Y(i,e),at(),s.focus({preventScroll:!0}),a&&I(e[0],e[1])},color(t){if(b)return;const e=V(),[l,o]=$(e);if(l===o){const e=x&&x.at===l?x:null;return x={add:e?.add??[],drop:e?.drop??[],color:t,at:l},void N()}Y(d(n,l,o,t,r),e)},textStyle(t){if(b)return;w=!1;const e=V(),[l,o]=$(e),i=Q({value:n,start:l,end:o,id:t,rules:r});i&&Y(i,e),at(),s.focus({preventScroll:!0}),i||I(e[0],e[1])},clear(){if(b)return;const t=V(),[e,n]=$(t);Y(X(e,n),t)},list(e){if(b||!t.multiline)return;const l=V(),[o,i]=$(l),a=c(n,o,i,r);Y(u(n,o,i,a===e?null:e,r),l)}}}var rt=(t,e,n)=>Math.min(Math.max(t,e),Math.max(e,n));function lt({anchor:t,size:e,within:n,clip:r,parent:l,gap:o=8}){const i=Math.max(n.left,r.left),a=Math.min(n.right,r.right)-e.width,s=rt(t.left,i,a),c=r.bottom-(t.bottom+o),u=t.top-o-r.top,d=e.height>c&&(e.height<=u||u>c),f=d?t.top-o-e.height:t.bottom+o,h=t.left+Math.min((t.right-t.left)/2,10),p=rt(h-5-s,10,e.width-10-10);return{top:f-l.top,left:s-l.left,above:d,point:p}}var ot=t=>({left:t.left,top:t.top,right:t.right,bottom:t.bottom});function it(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?ot(e):ot(n[0])}if(!e)return null;const r=e.getBoundingClientRect();return{left:r.left,top:r.top,right:r.left,bottom:r.bottom}}function at(t){const e=t.ownerDocument,n=e.documentElement,r={left:0,top:0,right:n.clientWidth,bottom:n.clientHeight},l=e.defaultView?.getComputedStyle.bind(e.defaultView);for(let o=t.parentElement;o&&o!==n&&o!==e.body;o=o.parentElement){const t=l?.(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;r.left=Math.max(r.left,n),r.top=Math.max(r.top,i),r.right=Math.min(r.right,n+(o.clientWidth||e.width)),r.bottom=Math.min(r.bottom,i+(o.clientHeight||e.height))}return r}function st(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 ct(t,e,n){const r=t.ownerDocument,l=r.createTreeWalker(t,4),o=t=>{let e=t,n=null;for(let t=l.nextNode();t;t=l.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);l.currentNode=t;const a=o(n);if(!i||!a)return null;const s=r.createRange();return s.setStart(i[0],i[1]),s.setEnd(a[0],a[1]),s}export{Z as ColorWindow,A as MARKUP_CLIPBOARD_TYPE,$ as TYPING_BURST_MS,M as clearRangeOf,Y as colorRunOf,H as createHistory,q as editVisible,J as markPress,O as markupOfRange,F as newLine,st as offsetOrigin,C as pasteToMarkup,lt as placeWindow,U as richInput,B as richLayout,it as selectionBox,j as selectionToSource,P as selectionToVisible,I as setBullet,nt as startCanvasTyping,Q as styleChange,et as textMap,ct as textRange,L as toSource,K as toSourceStart,W as toVisible,at as visibleArea};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useScreenBlockRules as e}from"./chunk-
|
|
1
|
+
import{useScreenBlockRules as e}from"./chunk-L4DFCNDQ.js";import{newNodeId as t,ROOT_ZONE as n}from"./chunk-TCAAOYQY.js";import{useEasel as o,useEaselApi as r}from"./chunk-NUJEHA6A.js";import{useMemo as s}from"react";function i(i={}){const{dispatch:p}=o(e=>e),d=r(),c=!0===i.readOnly,a=e().resolveOnInsert,l=!0===(i.resolveOnInsert??a),m=!0===i.foldIntoHistory;return s(()=>{const e=m?e=>p({...e,recordHistory:!1}):p,o=(n,o,r)=>{const s=t(o);return c||e({type:"insert",componentType:o,destinationZone:n,destinationIndex:r,id:s}),s},r=e=>(l&&!c&&d.resolveNode(e,{trigger:"insert"}),e),s=(t,n,o)=>{c||e({type:"replace",destinationZone:t,destinationIndex:n,data:o})},i=(e,t,n)=>r(o(e,t,n));return{insertComponent:i,insertSection:(e,t)=>i(n,e,t),replaceComponent:s,seedChild:(e,t,n,i)=>{const p=o(e,n,t);s(e,t,{type:n,props:{id:p,...i}}),r(p)},insertNode:(e,t,n)=>{const i=o(e,n.type,t);return s(e,t,{type:n.type,props:{...n.props,id:i}}),r(i)},removeComponent:(t,n)=>{c||e({type:"remove",index:n,zone:t})},reorderComponent:(t,n,o)=>{c||e({type:"reorder",sourceIndex:n,destinationIndex:o,destinationZone:t})},duplicateComponent:(t,n)=>{c||e({type:"duplicate",sourceIndex:n,sourceZone:t})},select:e=>p({type:"setUi",ui:{itemSelector:e}}),setDocument:t=>{c||e({type:"setData",data:t})},commitDocument:(t,n)=>{c||(m?d.batch(()=>{e({type:"setData",data:t}),void 0!==n&&("slot"===n?.kind?d.selectSlot({parentId:n.parentId,slot:n.slot}):d.select(n?n.id:null))}):d.run({data:t,select:n}))}}},[p,c,l,d,m])}export{i as useSectionOps};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useSectionOps as o}from"./chunk-3ZGOVNVH.js";import{SELECTION_MODE as e}from"./chunk-L4DFCNDQ.js";import{decodePartId as r,encodePartId as t}from"./chunk-R4AUZVA3.js";import{useEasel as n}from"./chunk-NUJEHA6A.js";import{usePreviewParts as p}from"./chunk-467WWV4I.js";import{useCallback as d,useEffect as c}from"react";var s=o=>"part"===o.kind;function m({mode:m,setMode:i,onOpenPart:a}){const{getSelectorForId:u}=n(o=>o),f=o(),{setSelectedPartId:k,setSelectHandler:l}=p(),I=d(o=>{const t=r(o);if(!t)return;const{nodeId:n,propKey:p}=t;p?(i(o=>s(o)&&o.nodeId===n&&o.propKey===p?o:{kind:"part",nodeId:n,propKey:p}),a?.(n)):i(o=>"part"===o.kind?e:o)},[i,a]);c(()=>{l(I)},[l,I]);const h=s(m)?t(m.nodeId,m.propKey):null;c(()=>{k(h)},[h,k]);return{selectNode:d(o=>{i(()=>e);const r=u(o);r&&f.select(r)},[i,u,f]),openPartId:h}}export{m as usePartBridge};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{blockRuns as e,offeredChoices as s}from"./chunk-RUQOIQWI.js";import{useScreenBlockLook as t}from"./chunk-
|
|
1
|
+
import{blockRuns as e,offeredChoices as s}from"./chunk-RUQOIQWI.js";import{useScreenBlockLook as t}from"./chunk-L4DFCNDQ.js";import{DEFAULT_SCREEN_WORDS as l}from"./chunk-C4TJN6GR.js";import{useWords as r}from"./chunk-MFIRYGHW.js";import{ItemCount as n,DropdownMenu as c}from"efficient-shell/ui";import{jsxs as a,jsx as o,Fragment as i}from"react/jsx-runtime";function m({choices:m,onPick:p}){const{Icon:u}=t(),f=r("screen",l),h=e(s(m)).flatMap(e=>[...e.group?[{type:"label",key:`group:${e.group}`,label:/* @__PURE__ */a("span",{className:"flex w-full items-center gap-2",children:[
|
|
2
2
|
/* @__PURE__ */o("span",{children:e.group}),
|
|
3
3
|
/* @__PURE__ */o(n,{count:e.items.length,label:f.blockCount({count:e.items.length}),className:"ml-auto"})]})}]:[],...e.items.map(e=>({key:e.type,label:e.label,icon:/* @__PURE__ */o("span",{className:"sf-chip",children:/* @__PURE__ */o(u,{type:e.type,size:13})}),onSelect:()=>p(e.type)}))]);/* @__PURE__ */
|
|
4
4
|
return o(c,{align:"start",triggerClassName:"sf-add-card",items:h,trigger:/* @__PURE__ */a(i,{children:[
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenStoreProvider as n}from"./chunk-
|
|
1
|
+
import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenStoreProvider as n}from"./chunk-YMK3MZJK.js";import{ScreenChrome as e}from"./chunk-2EDOL4IW.js";import{ScreenDocumentProvider as i,useScreenDocument as a}from"./chunk-CPIWSFGR.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-C4TJN6GR.js";import{documentPermissions as s}from"./chunk-YYD257TD.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{useMemo as t,useState as d,useRef as l,useEffect as m,useCallback as g}from"react";import{Dialog as h,Button as f}from"efficient-shell/ui";import{jsx as u,jsxs as p,Fragment as v}from"react/jsx-runtime";var C=r(n),k=r(e);function N({onCancel:r,onDiscard:n,onSave:e}){const i=c("screen",o).leave,[a,s]=d(!1),t=l(!0);m(()=>(t.current=!0,()=>{t.current=!1}),[]);const C=g(async()=>{s(!0);try{await e()}finally{t.current&&s(!1)}},[e]);/* @__PURE__ */
|
|
2
2
|
return u(h,{open:!0,role:"alertdialog",size:"sm",title:i.title,onClose:r,footer:/* @__PURE__ */p(v,{children:[
|
|
3
3
|
/* @__PURE__ */u(f,{variant:"secondary",onClick:r,children:i.cancel}),
|
|
4
4
|
/* @__PURE__ */u(f,{variant:"ghost-danger",onClick:n,children:i.discard}),
|
|
5
5
|
/* @__PURE__ */u(f,{variant:"primary",loading:a,onClick:()=>{C()},children:i.save})]}),children:i.body})}function j({target:r,addressing:n,onHostMessage:e,children:a}){/* @__PURE__ */
|
|
6
|
-
return u(i,{target:r,addressing:n,onHostMessage:e,children:a})}var y=(r,n)=>/* @__PURE__ */p(v,{children:[r,n]});function
|
|
7
|
-
/* @__PURE__ */u(C,{config:r,data:i,onChange:h,permissions:
|
|
6
|
+
return u(i,{target:r,addressing:n,onHostMessage:e,children:a})}var y=(r,n)=>/* @__PURE__ */p(v,{children:[r,n]});function D({config:r,parts:n,wrap:e=y}){const{data:i,error:d,redirecting:l,ready:m,readOnly:g,onChange:h,pendingNav:f,cancelPendingNav:p,discardAndNavigate:v,saveAndNavigate:j}=a(),D=t(()=>s(!g),[g]),M=c("screen",o);return l?/* @__PURE__ */u("div",{className:"sf-msg",children:M.loading}):d?/* @__PURE__ */u("div",{className:"sf-msg sf-msg--error",children:d}):m?i?e(
|
|
7
|
+
/* @__PURE__ */u(C,{config:r,data:i,onChange:h,permissions:D,parts:n,children:/* @__PURE__ */u(k,{})}),f&&/* @__PURE__ */u(N,{onCancel:p,onDiscard:v,onSave:j})):/* @__PURE__ */u("div",{className:"sf-msg",children:M.loading}):/* @__PURE__ */u("div",{className:"sf-msg",children:M.waitingForAuthorization})}export{D as DocumentScreen,j as ScreenMount};
|