efficient-easel 11.8.0 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{canvas-typing-CC0wA-ys.d.ts → canvas-typing-CZ11Y5tb.d.ts} +1 -1
- package/dist/{chunk-UBAYMWCX.js → chunk-2SOOKBHH.js} +13 -13
- package/dist/{chunk-PS5BWS4I.js → chunk-47JTYRQC.js} +2 -2
- package/dist/{chunk-HRUMNRYI.js → chunk-5NM5TPAX.js} +1 -1
- package/dist/{chunk-URC5Y5G2.js → chunk-5QP7ZE35.js} +1 -1
- package/dist/chunk-5R7FE4VT.js +57 -0
- package/dist/{chunk-7BRKNQF7.js → chunk-CZYR5V77.js} +1 -1
- package/dist/chunk-KE2CXEIK.js +13 -0
- package/dist/chunk-KR4OCYRP.js +1 -0
- package/dist/{chunk-H6IXH4A3.js → chunk-O3RLI7XE.js} +1 -1
- package/dist/chunk-UX7UJPC5.js +5 -0
- package/dist/chunk-WDQY6JMM.js +7 -0
- package/dist/chunk-WP7AZDCV.js +5 -0
- package/dist/{chunk-6TJ2CIMY.js → chunk-WUO2GBPO.js} +1 -1
- package/dist/chunk-WY5U4XFO.js +7 -0
- package/dist/{chunk-ATF2T5CI.js → chunk-X4VIDPKV.js} +1 -1
- package/dist/{chunk-6IT5H37Y.js → chunk-XY5ZHRMR.js} +1 -1
- package/dist/copy/index.d.ts +4 -4
- package/dist/copy/index.js +18 -18
- package/dist/easel/index.d.ts +2 -2
- package/dist/easel/index.js +1 -1
- package/dist/fields/index.js +1 -1
- package/dist/panel/index.js +1 -1
- package/dist/pick/index.d.ts +30 -8
- package/dist/pick/index.js +3 -7
- package/dist/pick/pick.css +6 -80
- package/dist/screen/components/AddBlockRow.js +1 -1
- package/dist/screen/components/AddSidePanel.js +1 -1
- package/dist/screen/components/MediaSidePanel.js +1 -1
- package/dist/screen/components/PageEditGuardNotices.js +1 -1
- package/dist/screen/components/ScreenChrome.js +1 -1
- package/dist/screen/components/ScreenDocumentContext.js +1 -1
- package/dist/screen/components/ScreenMount.js +1 -1
- package/dist/screen/components/ScreenStoreProvider.js +1 -1
- package/dist/screen/components/SectionScreenShell.js +16 -16
- package/dist/screen/components/usePartBridge.js +1 -1
- package/dist/screen/index.js +1 -1
- package/dist/screen/lib/key-scope.js +1 -1
- package/dist/screen/lib/puck/use-section-ops.js +1 -1
- package/dist/screen/lib/screen-parts.js +1 -1
- package/dist/strings/catalogue.d.ts +1 -1
- package/dist/strings/catalogue.js +1 -1
- package/dist/strings/index.d.ts +1 -1
- package/dist/strings/index.js +1 -1
- package/dist/text-styles/index.d.ts +12 -4
- package/dist/text-styles/index.js +36 -35
- package/dist/text-styles/model.d.ts +9 -1
- package/dist/{words-CiuKuiy0.d.ts → words-notpwHR2.d.ts} +1 -1
- package/package.json +3 -3
- package/dist/chunk-5IUS6PM6.js +0 -13
- package/dist/chunk-A6PY6C3C.js +0 -1
- package/dist/chunk-DE35IQ4T.js +0 -57
- package/dist/chunk-JHYKRGRA.js +0 -5
- package/dist/chunk-JRRYFSCY.js +0 -5
- package/dist/chunk-KEWQZYUF.js +0 -7
- package/dist/chunk-NY7HHUGB.js +0 -7
package/dist/chunk-DE35IQ4T.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import{markedTreeNodeId as e,revealSelectedTreeRow as n,sameSelector as t}from"./chunk-FGNR22NY.js";import{cloneNodeWithFreshIds as o}from"./chunk-2GVCAIPX.js";import{dedupeSlotChildren as r}from"./chunk-26OOWIJJ.js";import{styleClipboardOf as i}from"./chunk-LZS7JZK5.js";import{rootRowName as l,slotChildRowName as s,slotChildRenameProp as d,sectionRenameProp as c}from"./chunk-TBF5CVPA.js";import{scrollPreviewToSection as a,gotoPreviewSlide as p,scrollPreviewToTop as u}from"./chunk-4ES5JGGX.js";import{useEaselKeyTarget as f,useEaselUndoKeys as h,useEaselSaveKey as m,editorRootFocus as g}from"./chunk-HRUMNRYI.js";import{usePartBridge as y}from"./chunk-H6IXH4A3.js";import{useSectionOps as S}from"./chunk-ATF2T5CI.js";import{SlotChildActionsProvider as k}from"./chunk-KCBEE2MC.js";import{screenStorageKeys as v,DEFAULT_PANEL_W as b,clampPanelWidth as w}from"./chunk-TZIIRGVY.js";import{MediaSidePanel as x}from"./chunk-URC5Y5G2.js";import{useNodeClipboard as z,useNodeContextMenu as C}from"./chunk-EC2I7SIY.js";import{PageEditGuardNotices as I}from"./chunk-6TJ2CIMY.js";import{useScreenDocument as B}from"./chunk-PS5BWS4I.js";import{requestMediaPick as N}from"./chunk-KG7RJWOK.js";import{ScreenSaveIcon as O,ScreenMainButton as P}from"./chunk-W4U4SHKW.js";import{useBrowserOffline as $}from"./chunk-RKTF5XLP.js";import{heldStyle as M,styleShortcut as T}from"./chunk-V7U33NF2.js";import{AddChildRow as j}from"./chunk-5545A3PC.js";import{AddSidePanel as A}from"./chunk-JHYKRGRA.js";import{SidePanelHead as R,PanelShowStrip as L}from"./chunk-62VPYC7F.js";import{useEaselSession as E}from"./chunk-O7Q4DDJT.js";import{useScreenSaveSwitch as V,useScreenNodeKeys as F,useScreenPinned as H,useScreenDocumentLabel as W,useScreenCanvasFrame as J,useScreenInspectorPanel as Y,useScreenDevices as D,useScreenPickFollowsSelection as U,useScreenLeftView as G,SELECTION_MODE as X,sameInspectorMode as K,useScreenBridges as q,useScreenBlockRules as Z,useScreenBlockLook as _,useScreenStorageNamespace as Q,useScreenNotify as ee,useScreenCanvasHead as ne,isSlotMode as te,useScreenStyleClipboard as oe,useScreenDocumentPass as re,useScreenCanvasDrag as ie,ScreenCanvasTargetProvider as le,isPinnedFirst as se,isPinnedLast as de,screenSlotsOf as ce}from"./chunk-JRRYFSCY.js";import{ROOT_ZONE as ae,blockNodeActions as pe,TREE_MAX_DEPTH as ue,childSlotsOf as fe,slotFieldsOf as he,slotChildrenIn as me,nestsInTree as ge,newNodeId as ye}from"./chunk-PLVEGYK6.js";import{useMediaPanel as Se,usePanelPick as ke,useCancelPanelPick as ve}from"./chunk-R6WTQWAC.js";import{useEaselHost as be,useHostEscape as we}from"./chunk-U3JP4VGF.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as xe}from"./chunk-6WY6ZXJG.js";import{DEFAULT_SCREEN_WORDS as ze}from"./chunk-VVPZMWJE.js";import{useEasel as Ce,useEaselApi as Ie,CanvasPassThroughContext as Be}from"./chunk-5IUS6PM6.js";import{TreeRow as Ne,Subtree as Oe,LayersTree as Pe,TreeGroupLabel as $e,TreeRowAction as Me,TreeSeam as Te}from"./chunk-4JSBIW5H.js";import{DEFAULT_TREE_WORDS as je}from"./chunk-K56YDHYQ.js";import{DEFAULT_NODE_MENU_WORDS as Ae}from"./chunk-WK3AFPXY.js";import{toItemSelector as Re,useNodeOps as Le,clickPick as Ee}from"./chunk-ECM5F6JJ.js";import{LayersIcon as Ve,MediaIcon as Fe}from"./chunk-4VJATVVR.js";import{EaselTopBar as He,TopBarRail as We,TopBarCluster as Je,EaselIconButton as Ye,TopBarDivider as De,DeviceSwitch as Ue,InspectorIconButton as Ge,PanelResizeHandle as Xe,MAX_PANEL_W as Ke,MIN_PANEL_W as qe,panelWidthVars as Ze}from"./chunk-IE55HNMA.js";import{DEFAULT_NOTICE_WORDS as _e,DEFAULT_CHROME_WORDS as Qe}from"./chunk-Z6PVRXVY.js";import{holderOf as en,nameOrSomeone as nn}from"./chunk-THWO5YVZ.js";import{DEFAULT_LOCK_WORDS as tn}from"./chunk-RE4LP46F.js";import{useWords as on}from"./chunk-MFIRYGHW.js";import{insertSeams as rn,CanvasDragLayer as ln,CanvasInsert as sn}from"./chunk-QFVRMARS.js";import{DEFAULT_DRAG_WORDS as dn}from"./chunk-AYWN5NRH.js";import{createDragSession as cn,useTreeDrag as an,gapToMoveIndex as pn}from"./chunk-67GNT6PF.js";import{useCanvasFrame as un,LIST_SELECTOR as fn,BLOCK_SELECTOR as hn,useCanvasEvent as mn,nodeIdAt as gn,frameRectToHost as yn,BLOCK_ATTRIBUTE as Sn,drawnBox as kn}from"./chunk-ILXP5VX5.js";import{ROOT_ID as vn,ROOT_SLOT as bn,zoneKey as wn,parseZoneKey as xn,find as zn,DataError as Cn}from"./chunk-KRXQM65X.js";import{useRef as In,useMemo as Bn,useState as Nn,useEffect as On,useCallback as Pn,useLayoutEffect as $n,Fragment as Mn}from"react";import{ColoredBadge as Tn,toast as jn,groupColors as An}from"efficient-shell/ui";import{UndoIcon as Rn,RedoIcon as Ln,RefreshIcon as En,AddIcon as Vn,TrashIcon as Fn,EyeOffIcon as Hn,EyeIcon as Wn,DuplicateIcon as Jn}from"efficient-shell/icons/efficient";import{jsx as Yn,jsxs as Dn,Fragment as Un}from"react/jsx-runtime";var Gn=/* @__PURE__ */new WeakSet;function Xn(e,n,t){const o=zn(e,n,t);if(!o)return null;const r=o.path.find(e=>"root"!==e.parentId);return r?r.parentId:t}function Kn({canvas:e,tabs:n,onSelect:t}){const o=In(null),[r,i]=Nn({}),l=n.map(e=>`${e.id}:${e.below?1:0}`).join("|");return $n(()=>{const t=e?.document,r=e?.window,l=e?.frame;if(!t||!r||!l||0===n.length)return void i({});let s=0;const d=()=>{s=0;const e=o.current;if(!e)return;const d=yn(l,{left:0,top:0,width:r.innerWidth,height:r.innerHeight},e),c={};for(const o of n){const n=t.querySelector(`[${Sn}="${r.CSS?.escape?r.CSS.escape(o.id):o.id}"]`),i=n?kn(n):null;if(!i||0===i.height){c[o.id]=null;continue}const s=yn(l,{left:i.left,top:i.top,width:i.width,height:i.height},e),a=s.top+s.height;if(a<d.top||s.top>d.top+d.height){c[o.id]=null;continue}const p=o.below?a+4:Math.max(s.top,d.top)+6;c[o.id]={left:Math.max(s.left,d.left)+6,top:p}}i(c)},c=()=>{s||(s=r.requestAnimationFrame(d))};d(),r.addEventListener("scroll",c,!0),r.addEventListener("resize",c);const a=new r.MutationObserver(c);return a.observe(t.body,{childList:!0,subtree:!0,attributes:!0}),()=>{s&&r.cancelAnimationFrame(s),r.removeEventListener("scroll",c,!0),r.removeEventListener("resize",c),a.disconnect()}},[e,l]),/* @__PURE__ */Yn("div",{ref:o,className:"es-band-tabs","aria-hidden":"true",children:n.map(e=>{const n=r[e.id];return n?/* @__PURE__ */Yn("span",{className:"es-band-tab","data-band-tab":e.id,style:{left:n.left,top:n.top},onClick:n=>{n.stopPropagation(),t(e.id)},children:/* @__PURE__ */Yn(Tn,{colorClass:An("info","solid"),size:"sm",children:e.label})},e.id):null})})}function qn({expand:e}){/* @__PURE__ */
|
|
2
|
-
return Yn("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round",children:/* @__PURE__ */Dn(Un,e?{children:[
|
|
3
|
-
/* @__PURE__ */Yn("path",{d:"M8 9l4-4 4 4"}),
|
|
4
|
-
/* @__PURE__ */Yn("path",{d:"M8 15l4 4 4-4"})]}:{children:[
|
|
5
|
-
/* @__PURE__ */Yn("path",{d:"M8 4l4 4 4-4"}),
|
|
6
|
-
/* @__PURE__ */Yn("path",{d:"M8 20l4-4 4 4"}),
|
|
7
|
-
/* @__PURE__ */Yn("path",{d:"M5 12h14"})]})})}var Zn=`${fn}, ${hn}`;function _n(e,n,t){const o=t-n;if(o<6)return null;if(o<24)return{top:Math.round((n+t)/2),height:Math.round(o)};return{top:Math.round(Math.min(Math.max(e,n+12),t-12))}}var Qn="__rungs";var et="screen:band",nt={duplicate:!0,delete:!0};function tt(){const fn=be(),{target:yn,docId:Sn,capabilities:kn,currentSlug:An,siteId:tt,onPublish:ot,saveState:rt,saveConflict:it,retrySave:lt,toggleAutoSave:st,flushSave:dt,access:ct,saveUnreachable:at=!1,readOnly:pt,readOnlyReason:ut=null}=B(),ft=V(),ht=F(),{mediaEditing:mt,hasEditGuard:gt,hasPinnedChrome:yt}=kn,{appState:St,dispatch:kt,history:vt,selectedItem:bt,getSelectorForId:wt,config:xt}=Ce(e=>e),zt=H(),{first:Ct,firstGroup:It,lastGroup:Bt,isSectionGroup:Nt,sectionGroupZone:Ot,panelOf:Pt}=zt,$t=Pt(Ct),Mt=e=>se(zt,e),Tt=e=>de(zt,e),jt="node"===zt.firstRow,At=zt.band??null,Rt=on("screen",ze),Lt=on("tree",je),Et=on("drag",dn),Vt=on("notice",_e),Ft=on("lock",tn),Ht=on("menu",Ae),Wt=on("styleClipboard",xe),Jt=on("chrome",Qe),Yt=W()??`/${An}`,Dt=J(),Ut=Y(),Gt=S({readOnly:pt}),Xt=S({readOnly:pt,foldIntoHistory:!0}),Kt=In(null),qt=Ie(),Zt=Bn(()=>({...Gt,select:e=>{Kt.current=e,Gt.select(e)},commitDocument:(e,n)=>{if(void 0!==n){const t=qt.config;Kt.current=Re(e,t,n)}Gt.commitDocument(e,n)}}),[Gt,qt]),_t=St.ui,Qt=_t.leftSideBarVisible,eo=_t.rightSideBarVisible,{options:no,widths:to,initial:oo,fluid:ro,fit:io}=D(),[lo,so]=Nn(oo),co=Se(),ao=mt&&null!==co,po=ke(),uo=ve();U(bt?.props.id);const{read:fo,write:ho,forSelection:mo}=G(),[go,yo]=Nn(fo);On(()=>{ho(go)},[go]);const[So,ko]=Nn(0),vo=In(null),bo=In(null),wo=un(bo,{readySelector:Zn}),xo=f(bo);h(bo,wo);const zo=$(),Co=en(ct),Io={state:rt,offline:zo||rt.failed&&at,readOnlyReason:ut,editing:Co?Vt.editing({name:nn(Co.name,Ft),noun:Rt.noun}):null,conflict:null!=it,notSaving:Rt.bar.notSaving},Bo=()=>{pt||(rt.failed?lt():dt())};m(bo,wo,Bo);const[No,Oo]=Nn(!1),Po=In(!1),$o=In(!1),[Mo,To]=Nn(null),[jo,Ao]=Nn([]),[Ro,Lo]=Nn(X),Eo="puck"===Ro.kind,Vo=e(Ro,bt?.props.id),[Fo,Ho]=Nn(null);On(()=>{Fo&&(n(),Ho(null))},[Fo]);const Wo=In(wt);Wo.current=wt;const Jo=Pn((e,{scroll:n})=>{yo(n=>mo(e,n)),n&&Ho(e);const t=[];let o=e;for(let e=0;e<4;e++){const e=Wo.current(o)?.zone;if(!e||!e.includes(":"))break;const n=e.split(":")[0];t.push(n),t.push(e),o=n}0!==t.length&&kr(e=>{if(t.every(n=>!e.has(n)))return e;const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},[]),Yo=In(null);On(()=>{const e=Yo.current;Yo.current=null;const n=null==bt?.props.id?null:String(bt.props.id);Lo(t=>e&&e.id===n?e.mode:"part"===t.kind&&"nodeId"in t&&t.nodeId===n?t:Pt(bt?.type)??X);const o=bt?.props.id,r=Kt.current;if(Kt.current=null,!o)return;const i=wt(o);Jo(String(o),{scroll:!t(r,i??null,ae)})},[bt?.props.id,Jo]);const Do=Pn(e=>{Lo(n=>K(n,e)?n:e),kt({type:"setUi",ui:{rightSideBarVisible:!0}})},[kt]),Uo=In(()=>{});Uo.current=(e,n)=>{const t=e?ui(e.zone??ae)[e.index]?.props.id:null,o=null==t?null:String(t),r=null==bt?.props.id?null:String(bt.props.id);Lo(e=>K(e,n)?e:n),o!==r&&(Yo.current={id:o,mode:n},Zt.select(e))};const Go=Pn((e,n)=>Uo.current(e,n),[]),Xo={kind:Ro.kind,mode:Ro,open:Do,show:e=>Lo(e),reveal:()=>{eo||kt({type:"setUi",ui:{rightSideBarVisible:!0}})},select:Go},Ko=q(Xo,{data:St.data,selected:bt??null,zoneOf:e=>wt(e)?.zone,readOnly:Boolean(pt),select:e=>{Lo(X),Zt.select({index:e})},replace:(e,n)=>Zt.replaceComponent(ae,e,n),scrollTo:e=>Li(e)},{device:lo,refreshes:So},{setView:yo,reveal:()=>{Qt||kt({type:"setUi",ui:{leftSideBarVisible:!0}})}}),qo=Ko.pinnedSource??!1,Zo=Ko.resolveLeftView?Ko.resolveLeftView(go,ao):"media"===go&&ao?go:"sections",_o=Z(),{isLockedBlock:Qo,duplicateBlocked:er,nestDepth:nr,newSectionNode:tr,canAddTo:or,blockIsOffered:rr}=_o,ir=_(),{labelAtLevel:lr,Icon:sr,useProducts:dr}=ir,cr=ir.rowName?(e,n,t)=>ir.rowName(e,n,t):void 0,ar=Pn(e=>{kt({type:"setUi",ui:{rightSideBarVisible:!0}}),a(e),Jo(e,{scroll:!0})},[kt,Jo]),{selectNode:pr,openPartId:ur}=y({mode:Ro,setMode:Lo,onOpenPart:ar}),[fr,hr]=Nn(null);we(null!==fr,()=>hr(null));const mr=v(Q()),gr=mr.collapsed,yr=mr.panelWidths,[Sr,kr]=Nn(()=>{if("undefined"==typeof window)/* @__PURE__ */return new Set;try{const e=window.localStorage.getItem(gr);return new Set(e?JSON.parse(e):[])}catch{/* @__PURE__ */
|
|
8
|
-
return new Set}});On(()=>{try{window.localStorage.setItem(gr,JSON.stringify([...Sr]))}catch{}},[Sr]);const[vr,br]=Nn(()=>{if("undefined"==typeof window)return{...b};try{const e=window.localStorage.getItem(yr);if(!e)return{...b};const n=JSON.parse(e);return{left:w(Number(n.left)||b.left),right:w(Number(n.right)||b.right)}}catch{return{...b}}});On(()=>{const e=setTimeout(()=>{try{window.localStorage.setItem(yr,JSON.stringify(vr))}catch{}},300);return()=>clearTimeout(e)},[vr]);const wr=Pn((e,n)=>br(t=>{const o="function"==typeof n?n(t[e]):n;return t[e]===o?t:{...t,[e]:o}}),[]),xr=Pn(e=>wr("left",e),[wr]),zr=Pn(e=>wr("right",e),[wr]),Cr=e=>Sr.has(e),Ir=e=>kr(n=>{const t=new Set(n);return t.has(e)?t.delete(e):t.add(e),t}),Br=In(!1),Nr=In(null);On(()=>{if(Br.current&&!No){const e=Nr.current,n=e&&e.isConnected&&!e.closest('[aria-hidden="true"]')?e:null;(n??bo.current?.querySelector(`button[aria-label="${CSS.escape(Rt.add.title)}"]`))?.focus(),Nr.current=null}Br.current=No},[No]),On(()=>{if(!No||!xo)return;const e=e=>{"Escape"===e.key&&Di()};return xo.addEventListener("keydown",e),()=>xo.removeEventListener("keydown",e)},[No,xo]),we(No,()=>Di()),On(()=>{!Qt&&No&&(Oo(!1),To(null),Po.current=!1)},[Qt]),On(()=>{if(!po)return $o.current&&kt({type:"setUi",ui:{leftSideBarVisible:!1}}),void($o.current=!1);No&&(Oo(!1),To(null),$o.current=Po.current,Po.current=!1),Qt||($o.current=!0,kt({type:"setUi",ui:{leftSideBarVisible:!0}}))},[po]),On(()=>{!Qt&&po&&($o.current=!1,uo())},[Qt]),On(()=>{if(!po||!xo)return;const e=e=>{"Escape"===e.key&&uo()};return xo.addEventListener("keydown",e),()=>xo.removeEventListener("keydown",e)},[po,xo]),we(null!==po,()=>uo());const Or=ee(),Pr=(e,n="success",t)=>{if(Or)return void(t?Or(e,"error"===n?"error":"info",t):Or(e,"error"===n?"error":"info"));const o={sound:!1,action:t?.action,onClose:t?.onClose};"error"===n?jn.error(e,{...o,duration:t?.duration??3200}):jn.success(e,{...o,duration:t?.duration??1900})},$r=In(null),[Mr,Tr]=Nn(0),[jr,Ar]=Nn(0),Rr=ne(),Lr=In(null),Er=e=>Math.max(0,e.clientHeight-(Lr.current?.offsetHeight??0));On(()=>{const e=$r.current;if(!e)return;const n=()=>{Tr(e.clientWidth),Ar(Er(e))};n();const t=new ResizeObserver(n);return t.observe(e),Lr.current&&t.observe(Lr.current),()=>t.disconnect()},[]),$n(()=>{$r.current&&(Tr($r.current.clientWidth),Ar(Er($r.current)))},[vr,Qt,eo]);const Vr=lo===ro?Mr>0?Mr:to[ro]:to[lo],Fr=Mr>0?Math.min(Mr/Vr,"shrink"===io?1:2):1,Hr=Vr*Fr,Wr=Mr>0&&Hr>Mr+1,Jr={width:Hr,height:jr||"100%",flex:"none",position:"relative"},Yr={width:Vr,height:jr?jr/Fr:"100%",maxHeight:"none",transform:1!==Fr?`scale(${Fr})`:void 0,transformOrigin:"top left"},Dr=()=>kt({type:"setUi",ui:{leftSideBarVisible:!Qt}}),Ur=()=>kt({type:"setUi",ui:{rightSideBarVisible:!eo}}),Gr=e=>{No&&(Oo(!1),To(null),Po.current=!1,Qt&&go===e)||po&&($o.current=!1,uo(),Qt&&go===e)||(Qt&&go===e?Dr():(yo(e),Qt||kt({type:"setUi",ui:{leftSideBarVisible:!0}})))},Xr=()=>{N(fn,{accept:"image/*",title:Jt.mediaLibrary})},Kr=()=>{Lo(X),Zt.select(null),u()},qr=()=>{Lo($t??X),eo||kt({type:"setUi",ui:{rightSideBarVisible:!0}})},Zr=St.data.content??[],_r=()=>{const e=Zr.findIndex(Mt),n=Zr.findIndex(Tt);return{floor:e>=0?e+1:0,cap:n>=0?n:Zr.length}},Qr=xt,ei=_o.stripCopy,ni=e=>o(e,ei),ti=z(),oi=Le({data:St.data,config:Qr,readOnly:Boolean(pt),clipboard:ti,strip:ei?e=>ei(e):void 0,afterRemove:"none",stepBounds:(e,n)=>{if(e.parentId!==vn||e.slot!==bn)return{min:0,max:n-1};const{floor:t,cap:o}=_r();return{min:t,max:o-1}},commit:(e,{select:n})=>{void 0!==n&&Lo(X);const t=void 0===n||"node"===n?.kind?n:null;Zt.commitDocument(e,t)}}),ri=e=>{const n=zn(St.data,xt,e);if(!n)return!1;const t=wn(n.place),o=n.node,r=t===ae?ci(o):xi(o);return!!oi.remove(e)&&(Pr(Rt.deleted({name:r}),"success",{duration:8e3,action:{label:Rt.bar.undo,onClick:()=>{oi.restore(n.node,n.place)}}}),!0)},ii={...oi,remove:ri},li=e=>lr(e,"block",xt.components[e]?.label??e),si=Pn(e=>xt.components[e]?.defaultProps??{},[xt]),di=e=>lr(e,"section",li(e)),ci=e=>l({type:e.type,props:e.props??{}},di(e.type),cr),{nodeAddresses:ai,zoneItems:pi}=Bn(()=>{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>=ue)return;const s=/* @__PURE__ */new Map;for(const{child:e,zone:t}of fe(xt,n))s.set(t,[...s.get(t)??[],e]);for(const[e,n]of s)t(n,e,i+1)})};return t(Zr,ae,0),{nodeAddresses:e,zoneItems:n}},[Zr,xt]),ui=Pn(e=>pi.get(e)??[],[pi]),fi=e=>{const n=ai.get(e);return n?ui(n.zone)[n.index]:void 0},hi=e=>ce(_o,xt,e),mi=e=>{if(!_o.slotsOf||e===ae)return null;const n=e.lastIndexOf(":");if(n<=0)return null;const t=fi(e.slice(0,n));if(!t)return null;const o=hi(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}},gi=(()=>{if(!te(Ro))return null;const e=`${Ro.nodeId}:${Ro.slot}`;return mi(e)?.slot.panel===Ro.kind?e:null})(),yi=In(null);On(()=>{const e=yi.current;if(yi.current=null,!gi||!te(Ro))return;const n=Ro.nodeId;Jo(n,{scroll:e!==gi}),kr(e=>{if(!e.has(n))return e;const t=new Set(e);return t.delete(n),t})},[Ro]);const Si=(e,n,t)=>{const o=String(e.props.id);if(!n.panel)return void(e=>{const n=ai.get(e);n&&(n.zone===ae?Ei(n.index):ul(n.zone,n.index,e,fi(n.zone.slice(0,n.zone.lastIndexOf(":")))?.type??""))})(o);const r={kind:n.panel,nodeId:o,slot:n.slot},i=`${o}:${n.slot}`;t&&gi!==i&&(yi.current=i),Go(null,r),eo||kt({type:"setUi",ui:{rightSideBarVisible:!0}}),Li(o)},ki=(e,n,t)=>{const o=`${e}:${n}`;if(kr(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;gi!==o&&(yi.current=o);Go(null,{kind:t,nodeId:e,slot:n})},vi=(e,n,t)=>{if(pt||!_o.moveSlot)return;const o=fi(e),r=o?hi(o).filter(e=>e.rung):[],i=r[n];if(!i)return;const l={parentId:e,slot:Qn,index:n},s=pn(l,{...l,index:Math.min(Math.max(t,0),r.length)});if(s===n)return;const d=_o.moveSlot(e,n,s);"string"==typeof d&&ki(e,d,i.panel)},bi=dr(),wi=Bn(()=>{const e=/* @__PURE__ */new Map;for(const n of bi??[])e.set(n.slug,n.name);return e},[bi]),xi=e=>s(e,li,ir.plainText,e=>wi.get(e),ir.rowName),zi=(e,n)=>{const t=xt.components[e.type]?.fields,o=n===ae||Tl(n)?"section":"block",r=n===ae&&(Mt(e)||Tt(e)||Nt(e.type)),i="block"===o?d(t):r?null:c(t);return ir.renamePropOf?ir.renamePropOf(e,o,i):i},Ci=(e,n,t,o)=>{if(!(!pt&&fr?.zone===e&&fr.index===n))return;const r=(t,o)=>{hr(null),o&&((e,n,t)=>{const o=ui(e)[n];if(!o)return;const r=zi(o,e);r&&Zt.replaceComponent(e,n,{...o,props:{...o.props,[r]:t.trim()}})})(e,n,t)};/* @__PURE__ */
|
|
9
|
-
return Yn("input",{className:"es-tree-rename",defaultValue:o,autoFocus:!0,"aria-label":Rt.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)},Ii=i(oe(),Wt),Bi=Ii.scope({target:yn,siteId:tt,docId:Sn}),Ni=xt,Oi=(e,n)=>n===ae?di(e):li(e),Pi=(e,n,t)=>{const o=Ii.plan(Bi,t,Oi(t.type,e),Ni);o&&(o.changed&&Zt.replaceComponent(e,n,{...t,props:{...o.props,id:t.props.id}}),Pr(o.message))},$i=C({nodesIn:ui,nodeAt:(e,n)=>ui(e)[n]??null,labelOf:(e,n)=>n===ae?di(e):li(e),renamePropOf:zi,beginRename:(e,n)=>hr({zone:e,index:n}),history:{hasPast:vt.hasPast,hasFuture:vt.hasFuture,back:()=>vt.back(),forward:()=>vt.forward()},openPageSettings:()=>{Zt.select(null),Lo(X)},pageSettingsLabel:Rt.pageSettings,words:{menu:Ht,styleClipboard:Wt,screen:Rt.menu},readOnly:Boolean(pt),collapseAll:()=>kr(new Set(ui(ae).map(e=>String(e.props.id)))),onPasteRefused:e=>Pr(e?Rt.pasteRefused({name:e.label}):Rt.menu.clipboardRefused,"error"),canPasteAt:(e,n)=>Rl(e,n),menuRows:Ko.menuRows,isLocked:e=>Qo(e.type),duplicateBlocked:e=>er(St.data,e),permits:e=>pe(xt,e.type),nodeOps:ii,isPinned:(e,n)=>n===ae&&(Mt(e)||Tt(e)),sectionBand:_r,locate:e=>ai.get(e)??null,rowNameOf:(e,n)=>n===ae?ci(e):xi(e),selectAt:(e,n,t,o)=>{e===ae?Ei(n):ul(e,n,t,o??"")},slotRung:e=>{const n=mi(e);return n?.slot.panel?{label:n.slot.label,select:()=>Si(n.node,n.slot,!1)}:null},style:{held:()=>M(Bi),canCopy:e=>Ii.rows(Ni,e).some(e=>!1!==e.counted),copy:(e,n)=>Ii.copy(Bi,e,Oi(e.type,n),Ni),paste:(e,n,t)=>Pi(e,n,t)},keys:ht?{target:xo,selected:()=>{const e=St.ui.itemSelector;return e?{zone:e.zone??ae,index:e.index}:null},held:()=>ti.get(),readOnly:Boolean(pt),onDone:({done:e,name:n})=>{"copied"===e&&Pr(Rt.copied({name:n}))}}:void 0},wo),Mi=In({copy:(e,n)=>{},paste:(e,n,t)=>{},at:()=>null,readOnly:!1});On(()=>{Mi.current={copy:(e,n)=>Ii.copy(Bi,e,Oi(e.type,n),Ni),paste:Pi,at:()=>{const e=St.ui.itemSelector;if(!e)return null;const n=e.zone??ae,t=ui(n)[e.index];return t?{zone:n,index:e.index,node:t}:null},readOnly:Boolean(pt)}});const Ti=Pn(e=>{const n=T(e);if(!n)return;const t=Mi.current,o=t.at();o&&(e.preventDefault(),"copy"===n?t.copy(o.node,o.zone):t.readOnly||t.paste(o.zone,o.index,o.node))},[]);On(()=>{if(!xo)return;const e=e=>Ti(e);return xo.addEventListener("keydown",e),()=>xo.removeEventListener("keydown",e)},[Ti,xo]),mn(wo,"keydown",Ti);const ji=Zr.map(e=>e.props.id).join("|");On(()=>{const e=wo?.document??null,n=wo?.window??null;let t=0;const o=[],r=()=>{if(!e)return void Ao(e=>e.length?[]:e);const n=Zr.findIndex(Tt),t=n>=0?n:Zr.length,o=n=>{const t=Zr[n]?.props?.id;return null==t?null:e.querySelector(`[data-puck-component="${CSS.escape(String(t))}"]`)},r=e=>e?[...e.querySelectorAll(hn)].map(e=>e.getBoundingClientRect()).filter(e=>e.width>0||e.height>0):[],i=[];for(let e=Zr.length>0&&!Mt(Zr[0])?0:1;e<=t;e++){const n=o(e),t=o(e-1),l=n?.getBoundingClientRect()??null,s=t?.getBoundingClientRect()??null;if(!l&&!s)continue;const d=_n(l&&s?(s.bottom+l.top)/2:l?0===e?l.top+12:l.top:s.bottom,Math.max(0===e?0:-1/0,...r(t).map(e=>e.bottom)),Math.min(1/0,...r(n).map(e=>e.top)));d&&i.push({...d,index:e})}Ao(e=>function(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t].top!==n[t].top||e[t].index!==n[t].index||e[t].height!==n[t].height)return!1;return!0}(e,i)?e:i)},i=()=>{cancelAnimationFrame(t),t=requestAnimationFrame(r)};if(!e||!n)return void r();n.addEventListener("scroll",i,{passive:!0});const l=new ResizeObserver(i);return l.observe(e.documentElement),r(),o.push(setTimeout(r,150),setTimeout(r,450)),()=>{cancelAnimationFrame(t),o.forEach(clearTimeout),n.removeEventListener("scroll",i),l.disconnect()}},[wo,ji,lo,Fr,Qt,eo,bt?.props.id]);const Ai=wo?.document??null,Ri=wo?.window??null;On(()=>{const e=vo.current;if(!e||!Ai||!Ri)return;const n=[],t=()=>{const n=Ai.querySelector(`[data-puck-component="${CSS.escape(e.id)}"]`);if(!n)return!1;const t=n.getBoundingClientRect().top-e.offset;return Math.abs(t)>1&&Ri.scrollTo({left:Ri.scrollX,top:Ri.scrollY+t,behavior:"instant"}),!0};return vo.current=null,t()&&n.push(setTimeout(t,150),setTimeout(t,450)),()=>n.forEach(clearTimeout)},[Ai,Ri]);const Li=e=>{Ko.holdCanvasOn?Ko.holdCanvasOn(e):a(e)},Ei=e=>{Lo(X),Zt.select({index:e}),Ko.sectionPressed?.(Zr[e]);const n=Zr[e]?.props?.id;n&&Li(n)},Vi=e=>{const{floor:n,cap:t}=_r(),o=e=>Math.min(Math.max(n,e),t);if("number"==typeof e)return o(e);const r=bt&&Ro.kind!==$t?.kind?Zr.findIndex(e=>e.props.id===bt.props.id):-1;return o(r>=0?r+1:t)},Fi=(e,n)=>{const{floor:t,cap:o}=_r(),r=Math.min(Math.max(n,t),o),i=e<r?r-1:r;return i===e?{moved:!1,dest:e}:(Zt.reorderComponent(ae,e,i),Zt.select({index:i}),{moved:!0,dest:i})},Hi=(e,n,t,o)=>{Lo(X),Zt.select(o?{index:o.index,zone:o.zone}:{index:e}),a(n),Pr(Rt.sectionAdded({name:t}))},Wi=(e,n)=>{const t=Vi(n),o=tr(e,{nodeDefaults:si,newNodeId:ye,sectionLabel:di,blockIsOffered:rr}),r=o?Zt.insertNode(ae,t,o):Zt.insertSection(e,t);return Hi(t,r,di(e),o?((e,n,t)=>{if(e.type===t)return null;const o={at:null},r=(e,n,i)=>{const l=i.filter(n=>n===e.type).length;for(const{child:s,zone:d,index:c}of fe(xt,e)){if(s.type===t&&(!o.at||n>o.at.depth)){const r=or(e.type,l,d.slice(d.lastIndexOf(":")+1)),i=r?.choices??(r?.spec?[{type:r.spec.childType,label:r.spec.childType}]:[]);null!==r&&"footer"!==r.source&&`${e.props.id}:${r.slot}`===d&&i.some(e=>e.type===t)&&(o.at={zone:d,index:c,depth:n})}r(s,n+1,[...i,e.type])}};return r({type:e.type,props:{...e.props,id:n}},1,[]),o.at?{zone:o.at.zone,index:o.at.index}:null})(o,r,e):null),t},Ji=e=>Yi(ae,e),Yi=(e,n)=>{Nr.current=document.activeElement??null,po&&(Po.current=$o.current,$o.current=!1,uo()),To(null===n?null:{zone:e,index:n}),Oo(!0),Qt||(Po.current=!0,kt({type:"setUi",ui:{leftSideBarVisible:!0}}))},Di=()=>{Oo(!1),To(null),Po.current&&kt({type:"setUi",ui:{leftSideBarVisible:!1}}),Po.current=!1},Ui=(e,n)=>ir.rowName?n?Mt(e)?ir.rowName(e,"section",Rt.header):Tt(e)?ir.rowName(e,"section",Rt.footer):Nt(e.type)?ir.rowName(e,"section",li(e.type)):ci(e):xi(e):n?di(e.type):li(e.type),Gi=e=>n=>{e()},Xi=()=>Ko.editPinnedSource?.(),Ki=(e,n,t)=>{if(pt)return null;const o=ui(e)[n];return o&&!pe(xt,o.type).delete?null:/* @__PURE__ */Yn(Me,{kind:"delete",label:Rt.deleteNamed({name:t}),onClick:()=>((e,n)=>{const t=ui(e)[n]?.props?.id;null!=t&&ri(String(t))})(e,n),children:/* @__PURE__ */Yn(Fn,{size:15})})},qi=e=>ir.rowPreview?.(e)||void 0,Zi=e=>ir.rowMarks?.(e)??void 0,_i=(e,n,t)=>ir.rowActions?.(e,n,t)??null,Qi=(e,n,t,o)=>{if(pt)return null;const r=Boolean(t.props._hidden);/* @__PURE__ */
|
|
10
|
-
return Yn(Me,{kind:"eye",label:r?Rt.showNamed({name:o}):Rt.hideNamed({name:o}),onClick:()=>nl(e,n,t),children:/* @__PURE__ */Yn(r?Hn:Wn,{size:14,strokeWidth:1.8,strokeLinecap:void 0,strokeLinejoin:void 0})})},el=e=>fs(ae,e),nl=(e,n,t)=>{Zt.replaceComponent(e,n,{...t,props:{...t.props,_hidden:!t.props._hidden}})},tl=e=>he(xt,e),ol=e=>fe(xt,e),rl=e=>_o.slotsOf?hi(e).map(n=>({slot:n.slot,rung:n.rung?n:null,kids:me(e,n.slot)})):[{slot:null,rung:null,kids:ol(e)}],il=e=>_o.slotsOf?rl(e).flatMap(e=>e.kids):ol(e),ll=e=>Boolean(_o.slotsOf)&&hi(e).some(e=>e.rung),sl=(e,n,t)=>null===t?void 0===n?or(e):or(e,n):or(e,n,t),dl=(e,n,t)=>{const o=ge(xt,e.type,n)&&(t||il(e).length>0||ll(e));return{collapsible:o,folded:o&&Cr(String(e.props.id))}},cl=(e,n,t)=>rl(e).flatMap(o=>{const r=o.rung?n+1:n,i=o.kids.flatMap(({child:e})=>dl(e,r,t(e.type)).collapsible?[String(e.props.id),...cl(e,r+1,t)]:[]);return o.rung?[`${e.props.id}:${o.rung.slot}`,...i]:i}),al=e=>il(e).length>0||ll(e)||Boolean(or(e.type)),pl=e=>Boolean(or(e)),ul=(e,n,t,o)=>{if(Lo(X),or(o)?.spec?.slider){const t=e.split(":")[0];p(t,n),Zt.select({index:n,zone:e}),a(t)}else Zt.select({index:n,zone:e}),Li(t)},fl=(e,n,t,o,r)=>{const i=`${e}:${n}`;Zt.insertComponent(i,t,o),or(r)?.spec?.slider?requestAnimationFrame(()=>{p(e,o),Zt.select({index:o,zone:i})}):Zt.select({index:o,zone:i})},hl=In(/* @__PURE__ */new Set);On(()=>{Zr.forEach(e=>{const n=or(e.type)?.spec;if(!n)return;const t=e.props.id;if(hl.current.has(t))return;hl.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(si)).forEach((e,t)=>Xt.seedChild(o,t,n.childType,e))})},[Zr,Xt,si]);const ml=In(/* @__PURE__ */new Set);On(()=>{Zr.forEach((e,n)=>{const t=e.props.id;if(ml.current.has(t))return;const o=r(e,tl(e.type));ml.current.add(t),o&&Xt.replaceComponent(ae,n,{...e,props:o})})},[Zr,Xt]),re(Xt,xt);const gl=Zr.findIndex(Tt),yl=gl>=0?Zr[gl]:null,Sl=jt?Zr.findIndex(Mt):-1,kl=Sl>=0?Zr[Sl]:null,vl=zt.groupTab,bl=Bn(()=>vl?e=>Nt(e.type):void 0,[vl]),wl=Boolean(zt.groupBadge),xl=zt.groupBadge?/* @__PURE__ */Yn("span",{className:"es-tree-group-badge",children:/* @__PURE__ */Yn(Tn,{tone:"info",size:"xs",children:zt.groupBadge})}):void 0,zl=Zr.find(e=>e.type===It)??null,Cl=Zr.find(e=>e.type===Bt)??null,Il=gl>=0?gl:Zr.length,Bl=[];Zr.forEach(e=>{Tt(e)||(al(e)&&Bl.push(String(e.props.id)),Bl.push(...cl(e,1,pl)))}),yl&&(Bl.push(String(yl.props.id)),Bl.push(...cl(yl,1,pl)));const Nl=Bl.length>0&&Bl.every(e=>Sr.has(e)),Ol=e=>{const n=ir.blockRowName(e,li);return ir.rowName?ir.rowName(e,"block",n):n},Pl=(e,n,t,o)=>{const r=ui(e)[t];if(!r)return;const i={...xn(e),index:t},l={...xn(n),index:Math.min(Math.max(o,0),ui(n).length)},s=pn(i,l);if(e!==n||s!==t)try{oi.move(String(r.props.id),{...l,index:s})}catch(e){if(!(e instanceof Cn))throw e}},$l=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 tl(e.type))n.add(`${e.props.id}:${t}`);return t(e),n},Ml=e=>{let n=e.slice(0,e.indexOf(":"));for(let e=0;e<64;e++){const e=ai.get(n);if(!e)return null;if(e.zone===ae)return n;n=e.zone.slice(0,e.zone.indexOf(":"))}return null},Tl=e=>{const n=e.slice(0,e.indexOf(":")),t=Zr.find(e=>Nt(e.type)&&String(e.props.id)===n);return t&&Ot(n)===e?t:null},jl=(e,n)=>{const t=Tl(e);return!t||(!zt.groupAccepts||zt.groupAccepts(t.type,n,ui(e).length))},Al=(e,n,t)=>{if(e.rung){const t=fi(e.rung.nodeId),o=t?hi(t).filter(e=>e.rung).length:0;return n.parentId===e.rung.nodeId&&n.slot===Qn&&n.index>=0&&n.index<=o}if(n.slot===Qn)return!1;if(e.add)return Vl(e.add,n);const o=wn(n);if(Nt(e.type))return!1;const r=Tl(o),i=Tl(e.zone);if(r||i)return!(!r||!i)&&(!(r!==i&&!jl(o,e.type))&&(n.index>=0&&n.index<=ui(o).length));if(e.zone===ae||o===ae){if(e.zone!==o)return!1;const{floor:t,cap:r}=_r();return n.index>=t&&n.index<=r}if(n.index<0||n.index>ui(o).length)return!1;if(e.zone===o)return!0;const l=yl&&!zt.lastIsOpen?String(yl.props.id):null;return(!l||Ml(e.zone)!==l&&Ml(o)!==l)&&((e,n,t,o)=>{if(e===n)return!0;const r=o??ui(e)[t];if(!r)return!1;const i=n.split(":")[0],l=ai.get(i),s=l?ui(l.zone)[l.index]:void 0;if(!s)return!1;if(!o&&$l(r).has(n))return!1;const d=or(s.type,nr(St?.data,s.type,i),n.slice(n.lastIndexOf(":")+1));return!!d&&(!!(d.choices?d.choices.some(e=>e.type===r.type):d.spec?.childType===r.type)&&!d.spec?.addBlocked?.(ui(n),r))})(e.zone,o,e.index,t)},Rl=(e,n)=>{const t=wn(e.from),o=e.node;return t===wn(n)?jl(t,o.type):Al({id:String(o.props?.id??""),zone:t,index:-1,type:o.type},n,o)},Ll=e=>{const n=e.slice(0,e.indexOf(":")),t=ai.get(n),o=t?ui(t.zone)[t.index]:void 0;if(!t||!o)return null;const r=or(o.type,nr(St?.data,o.type,n),e.slice(e.lastIndexOf(":")+1));if(!r||`${n}:${r.slot}`!==e)return null;if("footer"===r.source)return null;const i=r.choices??(r.spec?[{type:r.spec.childType,label:li(r.spec.childType)}]:[]),l=mi(e);return{parent:o,parentId:n,target:r,choices:i,parentName:l?l.slot.label:Ui(o,t.zone===ae)}},El=(e,n)=>{if("section"!==e.kind)return e;const t=wn(n);return t===ae||Tl(t)?e:Ll(t)?.choices.some(n=>n.type===e.type)?{kind:"block",type:e.type}:e},Vl=(e,n)=>{const t=El(e,n),o=wn(n);if("block"!==t.kind){if(Tl(o)){const e="section"===t.kind?t.type:t.template.node.type;return jl(o,e)&&n.index>=0&&n.index<=ui(o).length}if(o!==ae)return!1;const{floor:e,cap:r}=_r();return n.index>=e&&n.index<=r}if(o===ae)return!1;const r=Ll(o);return!(!r||!r.choices.some(e=>e.type===t.type))&&!r.target.spec?.addBlocked?.(ui(o))},Fl=(e,n)=>{const t=El(e,n);if("block"!==t.kind&&Tl(wn(n)))return void((e,n,t)=>{const o="section"===e.kind?e.type:"template"===e.kind?e.template.node.type:null;if(o&&jl(n,o)){if("section"===e.kind)Zt.insertComponent(n,e.type,t);else{if("template"!==e.kind)return;Zt.insertNode(n,t,ni(e.template.node))}Lo(X),Zt.select({index:t,zone:n})}})(t,wn(n),n.index);if("section"===t.kind)return void Wi(t.type,n.index);if("template"===t.kind)return void((e,n,t)=>{const o=Vi(t),r=Zt.insertNode(ae,o,n);Hi(o,r,e)})(t.template.name,ni(t.template.node),n.index);const o=wn(n),r=Ll(o);r&&(r.target.spec?fl(r.parentId,r.target.slot,t.type,n.index,r.parent.type):((e,n,t)=>{Zt.insertComponent(e,n,t),Lo(X),Zt.select({index:t,zone:e})})(o,t.type,n.index))},Hl=(e,n)=>{e.rung?vi(e.rung.nodeId,e.index,n.index):e.add?Fl(e.add,n):e.zone===ae?Fi(e.index,n.index):Pl(e.zone,wn(n),e.index,n.index)},[Wl]=Nn(()=>cn()),Jl=an({keyOf:e=>e.id,readOnly:Boolean(pt),session:Wl,canDrop:Al,onDrop:Hl,onStep:(e,n)=>{e.rung?vi(e.rung.nodeId,e.index,n<0?e.index-1:e.index+2):e.zone===ae?((e,n)=>{const t=di(Zr[e]?.type??""),o=Fi(e,n<0?e-1:e+2);if(!o.moved)return void Pr(n<0?Rt.sectionFirst({name:t}):Rt.sectionLast({name:t}));const{floor:r,cap:i}=_r();Pr(Rt.sectionMoved({name:t,n:o.dest-r+1,total:i-r}))})(e.index,n):Pl(e.zone,e.zone,e.index,n<0?e.index-1:e.index+2)}}),Yl=Pn(e=>{const{floor:n,cap:t}=_r(),o=[];for(const r of e.nodes){const e=wn(r.place),i=ui(e)[r.place.index];if(!i||String(i.props.id)!==r.id)continue;if(Mt(i)||Tt(i)||Qo(i.type))continue;if(Nt(i.type))continue;const l=Boolean(Tl(e)),s=e===ae||l;e===ae&&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?di(i.type):xi(i),from:r.place})}const r=e.zones.flatMap(e=>{const n=wn(e.list);if(n===ae&&0===e.children.length)return[{...e,addLabel:Rt.addSection,addAlways:!0}];const t=Ll(n),o=t?.target.spec?.addLabel;return e.children.length>0||Boolean(t?.choices.length)||Boolean(Tl(n))?[o?{...e,addLabel:o}:e]:[]}),i=r.flatMap(e=>{const n=wn(e.list),t=n===ae||Tl(n)?null:Ll(n);return t?.choices.length?rn(e,t.target.spec?.addLabel??Rt.addBlockHere):[]});return{sources:o,zones:r,seams:i}},[St.data]),Dl=null==bt?.props.id?null:String(bt.props.id),Ul=Pn(e=>{const n=xt,t=e=>!e.item.rung&&null!==zn(St.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(Dl);return i||(r(Ee(St.data,n,o.item.id,Dl,bl))??o)},[St.data,xt,Dl,bl]),[Gl,Xl]=Nn(null);mn(wo,"mouseover",e=>{if(!vl)return;const n=gn(e.target),t=n?Xn(St.data,xt,n):null;t!==Gl&&Xl(t)}),mn(wo,"mouseout",e=>{vl&&!e.relatedTarget&&Xl(null)});const Kl=e=>Mt(e)||Tt(e)||Nt(e.type),ql=[];if(vl){const e=Dl?Xn(St.data,xt,Dl):null;for(const n of/* @__PURE__ */new Set([e,Gl])){const e=n?Zr.find(e=>String(e.props.id)===n):void 0;if(!e||!Kl(e))continue;const t=vl(e);t&&ql.push({id:String(e.props.id),label:t,below:Mt(e)||e.type===It})}}const Zl=E(),_l=In(null);On(()=>{const e=zt.changeNotice;if(!e)return;const n=JSON.stringify(Zr.filter(Kl)),t=_l.current;if(_l.current={doc:Sn,bands:n,index:vt.index},!t||t.doc!==Sn||t.bands===n)return;vt.hasPast&&vt.index>=t.index&&!Gn.has(Zl)&&(Gn.add(Zl),Pr(e,"success",{action:{label:Rt.bar.undo,onClick:()=>vt.back()},duration:8e3}))},[Zr]);const Ql=e=>{Lo(X),Zt.select(e.zone===ae?{index:e.index}:{index:e.index,zone:e.zone})},es=ie(),ns=()=>({data:St.data,device:lo,ops:Zt,inspector:Xo}),ts=es?.model,os=Bn(()=>ts?e=>ts(e,Yl(e),ns()):Yl,[ts,Yl,lo]),rs=es?.measure,is=rs?(e,n)=>rs(e,n,ns()):void 0,ls=es?.canDrop,ss=ls?(e,n)=>ls(e,n,Al,ns()):Al,ds=es?.drop,cs=ds?(e,n)=>ds(e,n,Hl,ns()):Hl,as=es?.pick,ps=as?e=>as(e,Ql,ns()):Ql,us=e=>{const n=wn(e),t=mi(n);t&&Si(t.node,t.slot,!1),Yi(n,e.index)},fs=(e,n)=>/* @__PURE__ */Yn(Te,{...pt?{}:Jl.seam({place:{...xn(e),index:n}})},`seam:${e}:${n}`),hs={rowClick:Gi,isCollapsed:Cr,toggleCollapse:Ir},ms=e=>{const n=String(e.props.id),t=Zr.findIndex(e=>String(e.props.id)===n),o=Ot(n),r=ui(o),i=Cr(n),l=li(e.type),s=ir.rowName?ir.rowName(e,"section",l):l,d=e=>fs(o,e);/* @__PURE__ */
|
|
11
|
-
return Dn(Un,{children:[
|
|
12
|
-
/* @__PURE__ */Yn(Ne,{words:Lt,icon:/* @__PURE__ */Yn(sr,{type:e.type,size:13}),name:s,preview:qi(e),marks:Zi(e),onSelect:()=>Ei(t),nameSlot:Ci(ae,t,n,s),selected:Vo===n,badge:xl,actions:_i(e,ae,t)??void 0,rowProps:{"data-node-id":n,onClick:Gi(()=>Ei(t))},fold:{open:!i,label:"section",onToggle:()=>Ir(n)}}),!i&&/* @__PURE__ */Dn(Oe,{children:[r.map((n,t)=>{const r=String(n.props.id),i=ci(n),l=al(n),s=l&&Cr(r),c=()=>ul(o,t,r,e.type),{rowProps:a,...p}=Jl.row({item:{id:r,zone:o,index:t,type:n.type},place:{...xn(o),index:t}},{"data-node-id":r,onClick:Gi(c)});/* @__PURE__ */
|
|
13
|
-
return Dn(Mn,{children:[d(t),
|
|
14
|
-
/* @__PURE__ */Yn(Ne,{words:Lt,icon:/* @__PURE__ */Yn(sr,{type:n.type,size:13}),name:i,preview:qi(n),marks:Zi(n),onSelect:c,nameSlot:Ci(o,t,r,i),selected:Vo===r,hidden:Boolean(n.props._hidden),...p,fold:l?{open:!s,label:"section",onToggle:()=>Ir(r)}:void 0,actions:/* @__PURE__ */Dn(Un,{children:[Ki(o,t,i),_i(n,o,t),Qi(o,t,n,i)]}),rowProps:a}),l&&!s&&/* @__PURE__ */Yn(Oe,{children:Ss(n,2)})]},r)}),d(r.length)]})]})},gs=(e,n,t,o,r)=>{const i=String(e.props.id),l=`${i}:${n.slot}`,s=Jl.dragging,d=!Cr(l)&&s?.rung?.nodeId!==i,c={...xn(l),index:0},a=s&&!s.rung&&Al(s,c)?c:void 0,p=()=>Si(e,n,!0),{rowProps:u,...f}=Jl.row({item:{id:`rung:${l}`,zone:`${i}:${Qn}`,index:t,type:e.type,rung:{nodeId:i,slot:n.slot}},place:{parentId:i,slot:Qn,index:t},into:a,canDrag:Boolean(_o.moveSlot)&&!1!==n.movable&&o>1},{"data-slot-zone":l,onClick:Gi(p)}),h=pt?null:_o.slotActions?.(e,n.slot);/* @__PURE__ */
|
|
15
|
-
return Dn(Mn,{children:[n.heading,
|
|
16
|
-
/* @__PURE__ */Yn(Ne,{words:Lt,icon:n.glyph??null,name:n.label,badge:n.badge,onSelect:p,selected:gi===l,...f,dragHint:n.dragHint,fold:{open:d,label:n.label,onToggle:()=>Ir(l)},actions:h&&h.length>0?/* @__PURE__ */Yn(Un,{children:h.map((t,o)=>/* @__PURE__ */Yn(Me,{kind:"delete"===t.kind?"delete":"plain",label:t.label,disabled:t.disabled,onClick:()=>((e,n,t)=>{if(pt||t.disabled)return;const o=String(e.props.id),r=e=>{"string"==typeof e&&ki(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__ */Yn(Fn,{size:15}):/* @__PURE__ */Yn(Jn,{size:15})},`${o}:${t.kind}`))}):void 0,rowProps:u}),d&&/* @__PURE__ */Yn(Oe,{children:r})]},l)},ys=(e,n)=>{const t=rl(e),o=t.filter(e=>e.rung).length;let r=0;/* @__PURE__ */
|
|
17
|
-
return Yn(Un,{children:t.map(t=>{const i=t.kids,l=t.rung?n+1:n,s=sl(e.type,void 0,t.slot),d=s?`${e.props.id}:${s.slot}`:null,c=null===t.slot?null:`${e.props.id}:${t.slot}`,a=(e,n)=>fs(e,n),p=/* @__PURE__ */Dn(Un,{children:[i.map(({child:n,zone:t,index:o})=>{const r=Vo===String(n.props.id),{collapsible:i,folded:s}=dl(n,l,pl(n.type)),d=String(n.props.id),c=Ol(n),p=()=>ul(t,o,d,e.type),{rowProps:u,...f}=Jl.row({item:{id:d,zone:t,index:o,type:n.type},place:{...xn(t),index:o}},{"data-node-id":d,onClick:Gi(p)});/* @__PURE__ */
|
|
18
|
-
return Dn(Mn,{children:[0===o&&a(t,0),
|
|
19
|
-
/* @__PURE__ */Yn(Ne,{words:Lt,icon:/* @__PURE__ */Yn(sr,{type:n.type,size:13}),name:c,preview:qi(n),marks:Zi(n),onSelect:p,nameSlot:Ci(t,o,d,c),selected:r,hidden:Boolean(n.props._hidden),...f,fold:i?{open:!s,label:"group",onToggle:()=>Ir(d)}:void 0,actions:/* @__PURE__ */Dn(Un,{children:[Ki(t,o,c),_i(n,t,o),Qi(t,o,n,c)]}),rowProps:u}),i&&!s&&/* @__PURE__ */Yn(Oe,{children:ys(n,l+1)}),a(t,o+1)]},String(n.props.id??`${t}-${o}`))}),null===c?d&&!i.some(e=>e.zone===d)?a(d,0):null:0!==i.length||!t.rung&&d!==c?null:a(c,0)]});return t.rung?gs(e,t.rung,r++,o,p):/* @__PURE__ */Yn(Mn,{children:p},t.slot??"")})})},Ss=(e,n)=>{const t=nr(St?.data,e.type,String(e.props.id)),o=rl(e),r=o.filter(e=>e.rung).length;let i=0;/* @__PURE__ */
|
|
20
|
-
return Yn(Un,{children:o.map(o=>{const l=o.kids,s=o.rung?n+1:n,d=sl(e.type,t,o.slot),c=d?.spec??null,a=c&&Array.isArray(e.props[c.slot])?e.props[c.slot]:[],p=d&&d.choices?{slot:d.slot,choices:d.choices}:null,u=String(e.props.id),f=c&&!c.fixed?`${u}:${c.slot}`:null,h=p?`${u}:${p.slot}`:null,m=(e,n)=>fs(e,n),g=null===o.slot?null:`${u}:${o.slot}`,y=Boolean(c&&!c.fixed&&(null===g||g===f)),S=/* @__PURE__ */Dn(Un,{children:[l.map(({child:n,zone:t,index:o})=>{const r=Vo===String(n.props.id),i=xi(n),l=String(n.props.id),{collapsible:d,folded:c}=dl(n,s,pl(n.type)),a=tl(n.type),p=1===a.length?`${l}:${a[0]}`:null,u=p?{...xn(p),index:ui(p).length}:void 0,f=Jl.dragging,h=u&&f&&Al(f,u)?u:void 0,g=()=>ul(t,o,l,e.type),{rowProps:y,...S}=Jl.row({item:{id:l,zone:t,index:o,type:n.type},place:{...xn(t),index:o},into:h,canDrag:!Qo(n.type)},{"data-node-id":l,onClick:Gi(g)});/* @__PURE__ */
|
|
21
|
-
return Dn(Mn,{children:[0===o&&m(t,0),
|
|
22
|
-
/* @__PURE__ */Yn(Ne,{words:Lt,icon:/* @__PURE__ */Yn(sr,{type:n.type,size:13}),name:i,preview:qi(n),marks:Zi(n),onSelect:g,nameSlot:Ci(t,o,l,i),selected:r,hidden:Boolean(n.props._hidden),...S,fold:d?{open:!c,label:"group",onToggle:()=>Ir(l)}:void 0,actions:Qo(n.type)?_i(n,t,o)??void 0:/* @__PURE__ */Dn(Un,{children:[Ki(t,o,i),_i(n,t,o),Qi(t,o,n,i)]}),rowProps:y}),d&&!c&&/* @__PURE__ */Yn(Oe,{children:Ss(n,s+1)}),m(t,o+1)]},String(n.props.id??`${t}-${o}`))}),y&&c&&
|
|
23
|
-
/* @__PURE__ */Yn(j,{small:!0,label:c.addLabel,blocked:c.addBlocked?.(a)??null,onAdd:()=>fl(e.props.id,c.slot,c.childType,a.length,e.type)}),null===g?h&&!l.some(e=>e.zone===h)?m(h,0):null:0!==l.length||(o.rung?y:g!==h)?null:m(g,0)]});return o.rung?gs(e,o.rung,i++,r,S):/* @__PURE__ */Yn(Mn,{children:S},o.slot??"")})})},ks=No||null!==po,vs=e=>"panel"in e?{id:e.id,label:e.label,icon:e.icon,active:Qt&&!ks&&Zo===e.id,onSelect:()=>Gr(e.id)}:e,bs=[...(Ko.railLead??[]).map(vs),{id:"sections",label:Rt.layers,icon:/* @__PURE__ */Yn(Ve,{}),active:Qt&&!ks&&"sections"===Zo,onSelect:()=>Gr("sections")},...(Ko.railTrail??[]).map(vs)];ao?bs.push({id:"media",label:Rt.railMedia,icon:/* @__PURE__ */Yn(Fe,{}),active:Qt&&!No&&(null!==po||"media"===Zo),onSelect:()=>Gr("media")}):mt&&bs.push({id:"media",label:Rt.railMedia,icon:/* @__PURE__ */Yn(Fe,{}),onSelect:Xr});const ws=[...Ko.railLead??[],...Ko.railTrail??[]].find(e=>"panel"in e&&e.id===Zo),xs=Boolean(At?.foldable)&&!qo,zs=At?.label??(gt?Rt.pageSections:Rt.templateSections),Cs=xs&&Cr(et),Is=/* @__PURE__ */Dn(Un,{children:[Zr.map((e,n)=>{if(Mt(e)||Tt(e)||Nt(e.type))return null;const t=Vo===String(e.props.id),o=Boolean(e.props._hidden);ol(e);const r=String(e.props.id),i=Ko.hasOwnRows?.(e)??!1,l=al(e)||i,s=l&&Cr(r),d=tl(e.type),c=1===d.length?`${r}:${d[0]}`:null,a=c?{...xn(c),index:ui(c).length}:void 0,p=Jl.dragging,u=a&&p&&Al(p,a)?a:void 0,{rowProps:f,...h}=Jl.row({item:{id:r,zone:ae,index:n,type:e.type},place:{...xn(ae),index:n},into:u},{"data-node-id":r,onClick:Gi(()=>Ei(n))});/* @__PURE__ */
|
|
24
|
-
return Dn(Mn,{children:[n>0&&el(n),
|
|
25
|
-
/* @__PURE__ */Yn(Ne,{words:Lt,icon:/* @__PURE__ */Yn(sr,{type:e.type,size:13}),name:ci(e),preview:qi(e),marks:Zi(e),onSelect:()=>Ei(n),nameSlot:Ci(ae,n,r,ci(e)),selected:t,hidden:o,...h,fold:l?{open:!s,label:"section",onToggle:()=>Ir(r)}:void 0,actions:/* @__PURE__ */Dn(Un,{children:[Ki(ae,n,ci(e)),_i(e,ae,n),Qi(ae,n,e,ci(e))]}),rowProps:f}),al(e)&&!s&&/* @__PURE__ */Dn(Oe,{children:[Ss(e,1),Ko.partRows?.(e,hs)]}),i&&!s&&/* @__PURE__ */Yn(Oe,{children:Ko.ownRows?.(e,n,hs)})]},String(e.props.id??n))}),!qo&&Il>0&&el(Il)]}),Bs=(e,n,t)=>{const o=String(e.props.id),r=il(e).length>0||ll(e)||Boolean(or(e.type)),i=r&&Cr(o),l="header"===t?Rt.header:Rt.footer,s=ir.rowName?ir.rowName(e,"section",l):l;/* @__PURE__ */
|
|
26
|
-
return Dn(Un,{children:[
|
|
27
|
-
/* @__PURE__ */Yn(Ne,{words:Lt,icon:/* @__PURE__ */Yn(sr,{type:t,size:13}),name:s,preview:qi(e),marks:Zi(e),badge:xl,onSelect:()=>Ei(n),nameSlot:Ci(ae,n,o,s),selected:Vo===String(e.props.id),fold:r?{open:!i,label:"section",onToggle:()=>Ir(o)}:void 0,actions:_i(e,ae,n)??void 0,rowProps:{"data-node-id":o,onClick:Gi(()=>Ei(n))}}),r&&!i&&/* @__PURE__ */Yn(Oe,{children:ys(e,1)})]})};return(Ko.wrap??(e=>e))(
|
|
28
|
-
/* @__PURE__ */Yn(le,{target:wo,children:/* @__PURE__ */Dn("div",{ref:bo,className:"sf-editor es-editor",style:Ze(vr),onContextMenu:$i.onEditorContextMenu,...g(fn),children:[
|
|
29
|
-
/* @__PURE__ */Dn(He,{children:[
|
|
30
|
-
/* @__PURE__ */Yn(We,{items:bs,ariaLabel:Rt.bar.views}),
|
|
31
|
-
/* @__PURE__ */Dn(Je,{children:[
|
|
32
|
-
/* @__PURE__ */Yn(Ye,{label:Rt.bar.undo,disabled:Boolean(pt)||!vt.hasPast,onClick:()=>vt.back(),children:/* @__PURE__ */Yn(Rn,{})}),
|
|
33
|
-
/* @__PURE__ */Yn(Ye,{label:Rt.bar.redo,disabled:Boolean(pt)||!vt.hasFuture,onClick:()=>vt.forward(),children:/* @__PURE__ */Yn(Ln,{})}),
|
|
34
|
-
/* @__PURE__ */Yn(De,{}),
|
|
35
|
-
/* @__PURE__ */Yn(Ue,{devices:no,value:lo,onChange:so}),
|
|
36
|
-
/* @__PURE__ */Yn(Ye,{label:Rt.bar.refresh,tip:Rt.bar.refreshTip,onClick:()=>{vo.current=(()=>{const e=wo?.document;if(!e)return null;const n=Zr.findIndex(Tt),t=n>=0?n:Zr.length;let o=null;for(let n=0;n<t;n++){const t=Zr[n]?.props?.id;if(null==t)continue;const r=e.querySelector(`[data-puck-component="${CSS.escape(String(t))}"]`);if(!r)continue;const i=r.getBoundingClientRect().top;i<=4&&(null===o||i>o.offset)&&(o={id:String(t),offset:i})}if(!o){const e=bt?.props?.id??Zr[0]?.props?.id;null!=e&&(o={id:String(e),offset:0})}return o})(),ko(e=>e+1)},children:/* @__PURE__ */Yn(En,{})})]}),
|
|
37
|
-
/* @__PURE__ */Dn(Je,{kind:"right",style:{minWidth:300},children:[
|
|
38
|
-
/* @__PURE__ */Yn(O,{input:Io,words:Rt.saveStatus}),Ko.barLead?.(),Ko.barTrail?.(),Ko.mainAction||!Ko.barMain?/* @__PURE__ */Yn(P,{input:Io,action:Ko.mainAction??{label:Rt.done,onPress:()=>{ot(St.data)}},readOnly:Boolean(pt),saveSwitch:ft,onToggleAutoSave:st,onSaveNow:Bo,bar:Rt.bar,words:Rt.saveStatus}):Ko.barMain()]})]}),
|
|
39
|
-
/* @__PURE__ */Yn(I,{}),
|
|
40
|
-
/* @__PURE__ */Dn("div",{className:"sf-body",children:[Qt?/* @__PURE__ */Dn(Un,{children:[
|
|
41
|
-
/* @__PURE__ */Yn("aside",{className:"es-sidepanel es-sidepanel--left sf-panel sf-panel--left","aria-label":Rt.leftPanel,children:No?/* @__PURE__ */Yn(A,{at:Mo?{label:(e=>{const n=Tl(e.zone);if(n)return Rt.add.addingTo({name:ir.rowName?Ui(n,!0):li(n.type)});if(e.zone===ae){const n=Zr[e.index];return n&&!Tt(n)?Rt.add.addingBefore({name:Ui(n,!0)}):Rt.add.addingAtEnd}const t=Ll(e.zone);return t?Rt.add.addingTo({name:t.parentName}):Rt.add.addingHere})(Mo),onClear:()=>To(null)}:void 0,placeBlocks:Mo&&Mo.zone!==ae?Ll(Mo.zone)?.choices:void 0,canTake:Mo?e=>{if(!Mo)return null;const n={...xn(Mo.zone),index:Mo.index};if(Vl(e,n))return null;const t=Tl(Mo.zone);if(t)return Rt.add.notInside({name:Ui(t,!0)});if(Mo.zone===ae)return Rt.add.onlySections;const o=Ll(Mo.zone);return o?Rt.add.notInside({name:o.parentName}):Rt.add.onlySections}:void 0,onPick:Mo?e=>{if(!Mo)return;const n={...xn(Mo.zone),index:Mo.index};Vl(e,n)&&(Fl(e,n),Di())}:void 0,itemFor:e=>({id:`new:${e.kind}:${"template"===e.kind?e.template.id:e.type}`,zone:"",index:-1,type:"template"===e.kind?e.template.node.type:e.type,add:e}),session:Wl,siteWide:Ko.addPanelRow?.(Di),onClose:Di,onHide:Dr,readOnly:Boolean(pt)}):po&&co?
|
|
42
|
-
/* @__PURE__ */Yn(x,{panel:co,pick:po,onHide:Dr}):ws?ws.panel({onHide:Dr,notify:Pr}):"media"===Zo&&co?/* @__PURE__ */Yn(x,{panel:co,pick:null,onHide:Dr}):/* @__PURE__ */Dn(Un,{children:[
|
|
43
|
-
/* @__PURE__ */Yn(R,{icon:/* @__PURE__ */Yn(Ve,{}),title:Rt.layers,context:Yt,actions:/* @__PURE__ */Dn(Un,{children:[!pt&&/* @__PURE__ */Yn(Ge,{label:Rt.add.title,onClick:()=>Ji(null),children:/* @__PURE__ */Yn(Vn,{size:15})}),
|
|
44
|
-
/* @__PURE__ */Yn(Ge,{label:Nl?Rt.expandAll:Rt.collapseAll,title:0===Bl.length?Rt.nothingToFold:void 0,disabled:0===Bl.length,onClick:()=>kr(e=>{const n=new Set(Bl);return Nl?new Set([...e].filter(e=>!n.has(e))):/* @__PURE__ */new Set([...e,...Bl])}),children:/* @__PURE__ */Yn(qn,{expand:Nl})})]}),onHide:Dr}),
|
|
45
|
-
/* @__PURE__ */Dn(Pe,{className:"sf-tree sf-scroll",words:Lt,children:[
|
|
46
|
-
/* @__PURE__ */Yn(Ne,{words:Lt,icon:/* @__PURE__ */Yn(sr,{type:"page",size:13}),name:Rt.pageSettings,onSelect:Kr,selected:!bt&&Eo,rowProps:{onClick:Gi(Kr)}}),zl&&/* @__PURE__ */Dn(Un,{children:[!wl&&/* @__PURE__ */Yn($e,{children:Rt.header}),ms(zl)]}),!qo&&yt&&!(wl&&zl)&&/* @__PURE__ */Dn(Un,{children:[!wl&&/* @__PURE__ */Yn($e,{children:Rt.header}),!jt&&/* @__PURE__ */Yn(Ne,{words:Lt,icon:/* @__PURE__ */Yn(sr,{type:"header",size:13}),name:Rt.header,badge:xl,onSelect:qr,selected:Ro.kind===$t?.kind,rowProps:{onClick:Gi(qr)}})]}),!qo&&kl&&!(wl&&zl)&&Bs(kl,Sl,"header"),!qo&&!xs&&/* @__PURE__ */Yn($e,{children:zs}),xs?/* @__PURE__ */Dn(Un,{children:[
|
|
47
|
-
/* @__PURE__ */Yn(Ne,{words:Lt,icon:null,name:zs,fold:{open:!Cs,label:zs,onToggle:()=>Ir(et)}}),!Cs&&/* @__PURE__ */Yn(Oe,{children:Is})]}):Is,yt&&!wl&&/* @__PURE__ */Yn($e,{children:Rt.footer}),yl&&!(wl&&Cl)&&Bs(yl,gl,"footer"),!qo&&!yl&&yt&&!wl&&/* @__PURE__ */Yn(Ne,{words:Lt,icon:/* @__PURE__ */Yn(sr,{type:"footer",size:13}),name:Rt.footer,onSelect:Xi,rowProps:{onClick:Gi(Xi),title:Rt.editFooter}}),Cl&&ms(Cl),Ko.treeFoot?.()]})]})}),
|
|
48
|
-
/* @__PURE__ */Yn(Xe,{side:"left",width:vr.left,min:qe,max:Ke,defaultWidth:b.left,label:Rt.resizeLeftPanel,onResize:xr})]}):/* @__PURE__ */Yn(L,{side:"left",onShow:Dr}),
|
|
49
|
-
/* @__PURE__ */Dn("div",{ref:$r,className:"sf-center sf-scroll","data-sf-canvas-head":Rr?"":void 0,style:{overflowX:Wr?"auto":"hidden",overflowY:"hidden"},children:[Rr&&/* @__PURE__ */Yn("div",{ref:Lr,className:"sf-canvas-head",children:/* @__PURE__ */Yn(Rr,{device:lo})}),
|
|
50
|
-
/* @__PURE__ */Dn("div",{className:"sf-frame-scaler",style:Jr,children:[
|
|
51
|
-
/* @__PURE__ */Yn("div",{className:"sf-frame "+(lo===ro?"":`sf-frame--${lo}`),style:Yr,children:/* @__PURE__ */Dn("div",{className:"sf-preview-host",children:[
|
|
52
|
-
/* @__PURE__ */Yn(Be.Provider,{value:bl,children:/* @__PURE__ */Yn(Dt,{},So)}),
|
|
53
|
-
/* @__PURE__ */Yn(ln,{canvas:wo,session:Wl,model:os,measure:is,canDrop:ss,onDrop:cs,choose:Ul,onPick:ps,onZoneAdd:us,onSeamAdd:us,zoneAddLabel:Rt.canvasAddBlock,words:Et.canvas,readOnly:Boolean(pt),revision:St.data}),jo.length>0&&/* @__PURE__ */Yn("div",{className:"sf-preview-gaps",children:jo.map(e=>
|
|
54
|
-
/* @__PURE__ */Yn(sn,{index:e.index,label:Rt.addSectionHere,onInsert:()=>Ji(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))})]})}),vl?/* @__PURE__ */Yn(Kn,{canvas:wo,tabs:ql,onSelect:e=>{const n=Zr.findIndex(n=>String(n.props.id)===e);n>=0&&Ei(n)}}):null]})]}),eo?/* @__PURE__ */Dn(Un,{children:[
|
|
55
|
-
/* @__PURE__ */Yn(k,{value:{selectChild:ul,addChild:fl,childRowName:xi,blockRowName:Ol},children:/* @__PURE__ */Yn(Ut,{mode:Ro,onOpenWebsiteSettings:Ko.openSettings??(()=>{}),onOpenSiteStyles:Ko.openStyles,onSelectNode:pr,onNotify:Pr,onHidePanel:Ur,nodeActions:bt?pe(xt,bt.type):nt})}),
|
|
56
|
-
/* @__PURE__ */Yn(Xe,{side:"right",width:vr.right,min:qe,max:Ke,defaultWidth:b.right,label:Rt.resizeSettingsPanel,onResize:zr})]}):
|
|
57
|
-
/* @__PURE__ */Yn(L,{side:"right",onShow:Ur})]}),$i.menu]})}))}export{tt as ScreenChrome};
|
package/dist/chunk-JHYKRGRA.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{buildPaletteSections as e,pinnedSection as t,categoryLabel as o}from"./chunk-PA3PNTVV.js";import{blockTypesIn as n}from"./chunk-5ZBY24K7.js";import{sectionTemplatesOf as s}from"./chunk-BVN33R76.js";import{SidePanelHead as i,PanelModeExit as r}from"./chunk-62VPYC7F.js";import{useEaselSession as l}from"./chunk-O7Q4DDJT.js";import{blockRuns as c}from"./chunk-HQ4VVRIC.js";import{useScreenBlockLook as a,useScreenBlockRules as p}from"./chunk-JRRYFSCY.js";import{DEFAULT_SCREEN_WORDS as m}from"./chunk-VVPZMWJE.js";import{useEasel as d}from"./chunk-5IUS6PM6.js";import{useWords as f}from"./chunk-MFIRYGHW.js";import{AddPanel as y}from"./chunk-QFVRMARS.js";import{DEFAULT_DRAG_WORDS as h}from"./chunk-AYWN5NRH.js";import{useState as u,useEffect as k,useMemo as b}from"react";import{AddIcon as g}from"efficient-shell/icons/efficient";import{jsx as j,jsxs as v,Fragment as R}from"react/jsx-runtime";var V=e=>`section:${e}`,$=e=>`block:${e}`,w=e=>`template:${e}`;function A({at:A,placeBlocks:E,canTake:F,onPick:I,itemFor:N,session:O,siteWide:P,onClose:Y,onHide:x,readOnly:B}){const C=d(e=>e.config),H=a(),{labelAtLevel:M,categoryLabel:S,firstSection:T,Icon:W,Thumbnail:L}=H,{blockIsOffered:D,canAddTo:J}=p(),Q=f("screen",m).add,z=f("drag",h).add,Z=l(),[G,K]=u([]);k(()=>{let e=!1;const t=e=>D(e,Z);return s(Z).list().then(o=>{if(e)return;const s=C.components;K(o.filter(e=>e.node?.type&&s[e.node.type]&&n(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[C,Z]);const U=b(()=>e(C,H),[C]),q=e=>({type:V(e.type),label:e.name,cover:/* @__PURE__ */j(L,{type:e.type}),title:e.desc?`${e.name} — ${e.desc}`:Q.tile({name:e.name}),keywords:[e.alias??"",e.desc,e.type,e.catLabel].filter(Boolean)}),X=e=>{const t=e.indexOf(":"),o=e.slice(0,t),n=e.slice(t+1);if("section"===o)return{kind:"section",type:n};if("block"===o)return{kind:"block",type:n};if("template"===o){const e=G.find(e=>e.id===n);return e?{kind:"template",template:e}:null}return null},_=e=>/* @__PURE__ */j("span",{className:"es-add-glyph-cover",children:/* @__PURE__ */j(W,{type:e,size:26})}),ee=b(()=>{const e=t(U,T),n=/* @__PURE__ */new Map,s=e=>{!n.has(e.type)&&D(e.type,Z)&&n.set(e.type,e)};for(const t of e?[e]:U){const e=J(t.type)?.choices??[];e.forEach(s),e.forEach(e=>J(e.type,1)?.choices?.forEach(s))}E?.forEach(s);const i=new Set(U.map(e=>e.type)),r=[...n.values()].filter(e=>!i.has(e.type)),l=e=>({type:$(e.type),label:e.label,cover:_(e.type),title:Q.tile({name:e.label}),keywords:[e.group??"",e.type].filter(Boolean)}),a=e=>n.has(e.type)?{...q(e),cover:_(e.type)}:q(e),p=[];G.length>0&&p.push({key:"templates",title:Q.templates,tiles:G.map(e=>{return{type:w(e.id),label:e.name,cover:/* @__PURE__ */j(L,{type:e.node.type}),keywords:[(t=e.node.type,M(t,"section",C.components[t]?.label??t)),e.node.type]};var t})});const m=r.filter(e=>!e.group);let d=!1;for(const t of Object.keys(C.categories??{})){const n=U.filter(e=>e.cat===t);if(0===n.length)continue;const s=e&&n.some(t=>t.type===e.type)?e:null,i=(s?[s,...n.filter(e=>e.type!==s.type)]:n).map(a);s&&!d&&(i.splice(1,0,...m.map(l)),d=!0),p.push({key:`category:${t}`,title:o(C,t,S),tiles:i})}const f=p.find(e=>e.key?.startsWith("category:"));if(!d&&f&&m.length>0&&(f.tiles=[...f.tiles,...m.map(l)],d=!0),c(r.filter(e=>e.group||!d)).forEach((e,t)=>{p.push({key:`blocks:${t}`,title:e.group??"",tiles:e.items.map(l)})}),!F)return p;const y=p.map(e=>({...e,tiles:e.tiles.map(e=>{const t=X(e.type),o=t?F(t):null;return o?{...e,disabled:!0,disabledReason:o}:e})})),h=e=>e.tiles.some(e=>!e.disabled);return[...y.filter(h),...y.filter(e=>!h(e))]},[G,U,C,Q,F,E,Z]);/* @__PURE__ */
|
|
2
|
-
return v(R,{children:[
|
|
3
|
-
/* @__PURE__ */j(i,{icon:/* @__PURE__ */j(g,{size:15}),title:Q.title,context:Q.contextAll,actions:/* @__PURE__ */j(r,{label:Q.done,description:Q.doneDescription,onClick:Y}),onHide:x}),
|
|
4
|
-
/* @__PURE__ */v("div",{className:"sf-addside sf-scroll",children:[
|
|
5
|
-
/* @__PURE__ */j(y,{groups:ee,session:O,itemFor:e=>N(X(e)??{kind:"section",type:e}),onInsert:I?e=>{const t=X(e);t&&I(t)}:void 0,at:A,hint:Q.hint,searchLabel:Q.search,readOnly:B,words:z}),P??null]})]})}export{A as AddSidePanel,$ as blockKey,V as sectionKey,w as templateKey};
|
package/dist/chunk-JRRYFSCY.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{slotFieldsOf as n}from"./chunk-PLVEGYK6.js";import{usePickFollowsSelection as e}from"./chunk-R6WTQWAC.js";import{EaselCanvas as t,useSelectedFields as r}from"./chunk-5IUS6PM6.js";import{Inspector as i}from"./chunk-UBAYMWCX.js";import{createContext as o,useContext as u}from"react";import{DesktopIcon as l}from"efficient-shell/icons/efficient";import{jsx as s}from"react/jsx-runtime";var c={kind:"puck"};function f(n,e){const t=n,r=e,i=Object.keys(t);return i.length===Object.keys(r).length&&i.every(n=>Object.is(t[n],r[n]))}function a(n){const e=n;return"string"==typeof e.nodeId&&"string"==typeof e.slot}function d(e,t,r){const i=e.slotsOf?.(r);return i||n(t,r.type).map(n=>({slot:n,label:n,rung:!1}))}function p(n,e){return n.isFirst?n.isFirst(e):e.type===n.first}function m(n,e){return n.isLast?n.isLast(e):e.type===n.last}var k={},h=()=>k,v=()=>"",g=()=>null,y=()=>{},b={isLockedBlock:()=>!1,duplicateBlocked:()=>null,nestDepth:()=>0,newSectionNode:()=>null,canAddTo:()=>null,blockIsOffered:()=>!0},O={labelAtLevel:(n,e,t)=>t,descriptions:{},categoryLabel:()=>{},firstSection:null,blockRowName:(n,e)=>e(n.type),plainText:n=>n,Icon:()=>null,Thumbnail:()=>null,useProducts:()=>null},j={options:[{id:"desktop",label:"Desktop",icon:/* @__PURE__ */s(l,{})}],initial:"desktop",fluid:"desktop",widths:{desktop:2e3}},w={read:()=>"sections",write:()=>{},forSelection:(n,e)=>n?"sections":e},L={first:null,last:null,firstGroup:null,lastGroup:null,isSectionGroup:()=>!1,sectionGroupZone:()=>"",panelOf:()=>null};function S(){/* @__PURE__ */
|
|
2
|
-
return s(t,{height:"fill"})}function C(){const{id:n,fields:e,values:t,readOnly:o,onChange:u}=r();/* @__PURE__ */
|
|
3
|
-
return s("div",{className:"es-sidepanel es-sidepanel--right",children:/* @__PURE__ */s(i,{fields:e,values:t,onChange:u,readOnly:o,idPrefix:n})})}var P=o({});function B({parts:n,children:e}){/* @__PURE__ */
|
|
4
|
-
return s(P.Provider,{value:n,children:e})}function D(){return u(P)}function G(){return(D().useOwnerName??v)()}function I(){return(D().useDocumentLabel??g)()}function N(n,e,t,r){return(D().useBridges??h)(n,e,t,r)}function x(n){return(D().useStandaloneBridges??h)(n)}function A(n,e){(D().useDocumentPass??y)(n,e)}function T(){return D().blockRules??b}function F(){return D().blockLook??O}function R(){return D().devices??j}function W(){return D().leftView??w}function K(){return D().pinned??L}function M(){return D().saveSwitch??!0}function U(n){e(!0===D().pickFollowsSelection,n)}function V(){return D().storageNamespace||void 0}function Y(){return D().styleClipboard??null}function E(){return D().nodeKeys??!0}function H(){return D().notify??null}function Q(){return D().Canvas??S}function X(){return D().CanvasHead??null}function Z(){return D().canvasDrag??null}var q=o(null);function z({target:n,children:e}){/* @__PURE__ */
|
|
5
|
-
return s(q.Provider,{value:n,children:e})}function J(){return u(q)}function $(){return D().Inspector??C}export{c as SELECTION_MODE,z as ScreenCanvasTargetProvider,B as ScreenPartsProvider,p as isPinnedFirst,m as isPinnedLast,a as isSlotMode,f as sameInspectorMode,d as screenSlotsOf,F as useScreenBlockLook,T as useScreenBlockRules,N as useScreenBridges,Z as useScreenCanvasDrag,Q as useScreenCanvasFrame,X as useScreenCanvasHead,J as useScreenCanvasTarget,R as useScreenDevices,I as useScreenDocumentLabel,A as useScreenDocumentPass,$ as useScreenInspectorPanel,W as useScreenLeftView,E as useScreenNodeKeys,H as useScreenNotify,G as useScreenOwnerName,D as useScreenParts,U as useScreenPickFollowsSelection,K as useScreenPinned,M as useScreenSaveSwitch,V as useScreenStorageNamespace,Y as useScreenStyleClipboard,x as useStandaloneScreenBridges};
|
package/dist/chunk-KEWQZYUF.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenStoreProvider as n}from"./chunk-7BRKNQF7.js";import{ScreenChrome as e}from"./chunk-DE35IQ4T.js";import{ScreenDocumentProvider as i,useScreenDocument as a}from"./chunk-PS5BWS4I.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-VVPZMWJE.js";import{documentPermissions as s}from"./chunk-THWO5YVZ.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{useMemo as t,useState as d,useRef as l,useEffect as m,useCallback as g}from"react";import{Dialog as h,Button as f}from"efficient-shell/ui";import{jsx as u,jsxs as p,Fragment as v}from"react/jsx-runtime";var k=r(n),C=r(e);function N({onCancel:r,onDiscard:n,onSave:e}){const i=c("screen",o).leave,[a,s]=d(!1),t=l(!0);m(()=>(t.current=!0,()=>{t.current=!1}),[]);const k=g(async()=>{s(!0);try{await e()}finally{t.current&&s(!1)}},[e]);/* @__PURE__ */
|
|
2
|
-
return u(h,{open:!0,role:"alertdialog",size:"sm",title:i.title,onClose:r,footer:/* @__PURE__ */p(v,{children:[
|
|
3
|
-
/* @__PURE__ */u(f,{variant:"secondary",onClick:r,children:i.cancel}),
|
|
4
|
-
/* @__PURE__ */u(f,{variant:"ghost-danger",onClick:n,children:i.discard}),
|
|
5
|
-
/* @__PURE__ */u(f,{variant:"primary",loading:a,onClick:()=>{k()},children:i.save})]}),children:i.body})}function j({target:r,addressing:n,onHostMessage:e,children:a}){/* @__PURE__ */
|
|
6
|
-
return u(i,{target:r,addressing:n,onHostMessage:e,children:a})}var y=(r,n)=>/* @__PURE__ */p(v,{children:[r,n]});function H({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(),H=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(k,{config:r,data:i,onChange:h,permissions:H,parts:n,children:/* @__PURE__ */u(C,{})}),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{H as DocumentScreen,j as ScreenMount};
|
package/dist/chunk-NY7HHUGB.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{STANDARD_MARKUP as t,writeMarkedLines as e,sameMarks as n,markedLines as l,spanFor as r,marksIn as o,toggleMark as i,listIn as a,setList as s,colorOver as c,unlinkAt as u,linkOver as d,colorIn as h,findLink as f,isSafeLinkHref as p}from"efficient-shell/markup";import{Tooltip as m,ColorSwatch as g,ColorPickerPanel as b,Button as k}from"efficient-shell/ui";import{jsxs as v,jsx as y}from"react/jsx-runtime";var x=/* @__PURE__ */new Set(["script","style","head","title","meta","link","template","noscript","svg","math","object","iframe"]),w=/* @__PURE__ */new Set(["p","div","li","ul","ol","dl","dt","dd","h1","h2","h3","h4","h5","h6","blockquote","pre","table","thead","tbody","tfoot","tr","section","article","header","footer","aside","nav","figure","figcaption","address","hr"]);function D(r,o){const i=o.rules??t,a=r.html&&""!==r.html.trim()?function(t,r,o){const i=r.createElement("template");i.innerHTML=t;const a=[[]],s=()=>a[a.length-1],c=()=>{const t=s();for(;t.length>0&&" "===t[t.length-1].ch;)t.pop();t.length>0&&a.push([])},u=(t,e,n,l)=>{if(3===t.nodeType){for(const r of t.textContent??""){const t=/\s/.test(r)?" ":r,o=s();" "===t&&(0===o.length&&a.length>1||" "===o[o.length-1]?.ch)||o.push({ch:t,bold:e,italic:n,href:l})}return}if(1!==t.nodeType&&11!==t.nodeType)return;const r=t,o=1===t.nodeType?r.localName:"";if(x.has(o))return;if("br"===o)return void a.push([]);let i=e,d=n,h=l;if("b"!==o&&"strong"!==o||(i=!0),"i"!==o&&"em"!==o||(d=!0),"a"===o){const t=(r.getAttribute("href")??"").trim();h=p(t)?t:null}const f=1===t.nodeType?r.style:null;if(f){const t=f.fontWeight;"bold"===t||"bolder"===t||Number(t)>=600?i=!0:("normal"===t||"lighter"===t||""!==t&&Number(t)<600)&&(i=!1),"italic"===f.fontStyle||"oblique"===f.fontStyle?d=!0:"normal"===f.fontStyle&&(d=!1)}const m=w.has(o);m&&c();for(const e of[...t.childNodes])u(e,i,d,h);m&&c()};u(i.content,!1,!1,null);for(;a.length>1&&0===a[a.length-1].length;)a.pop();return a.map(t=>function(t,r){const o=e=>t.map((n,l)=>n[e]&&(" "!==n.ch||Boolean(t[l-1]?.[e])&&Boolean(t[l+1]?.[e]))),i=[{bold:!0,italic:!0,links:!0},{bold:!0,italic:!1,links:!0},{bold:!1,italic:!1,links:!0},{bold:!1,italic:!1,links:!1}];for(const a of i){const i=M(t,a.bold?o("bold"):null,a.italic?o("italic"):null,a.links),s=e([i]).text;if(n([i],l(s,r)))return s}return t.map(t=>t.ch).join("")}(t,o))}(r.html,o.doc,i):(r.text??"").replace(/\r\n?/g,"\n").split("\n");return o.multiline?a.join("\n"):1===a.length?a[0]:a.map(t=>t.trim()).filter(t=>""!==t).join(" ")}function M(t,e,n,l){let o=0,i=null,a=null,s=null;return{bullet:!1,chars:t.map((t,c)=>{const u=l?t.href:null;return i=null===u?null:i&&i.href===u?i:r(++o,"link",u),a=e?.[c]?a??r(++o,"bold"):null,s=n?.[c]?s??r(++o,"italic"):null,{ch:t.ch,at:-1,marks:[i,a,s].filter(t=>null!==t)}})}}var T="application/x-efficient-markup",N=/^([0-9]{1,3})\. $/;function C(t,e){const n=t.split("\n"),r=l(t,e);let o=0,i=0;const a=r.map((t,e)=>{const l=!t.bullet&&null==t.number&&"- "===n[e],r=null!=t.number||t.bullet?null:N.exec(n[e]),a=t.bullet||l,s=r?r[1]:t.number??null,c=l||r?[]:t.chars,u=c.map(t=>t.ch).join(""),d=null!=s?s.length+2:a?2:0,h={bullet:a,number:s,chars:c,start:o,src:o+d,vis:i,text:u};return o+=n[e].length+1,i+=u.length+1,h});return{lines:a,text:a.map(t=>t.text).join("\n")}}function E(t,e){const{lines:n}=t;for(let t=0;t<n.length;t+=1){const l=n[t];if(e<=l.vis+l.text.length||t===n.length-1)return[l,Math.max(0,Math.min(e-l.vis,l.text.length)),t]}return[n[0],0,0]}function S(t,e){const[n,l]=E(t,e);if(0===l)return n.src;let r=0;for(const t of n.chars){if(l<=r+t.ch.length)return t.at+(l-r);r+=t.ch.length}return n.src}function A(t,e){const[n,l]=E(t,e);let r=0;for(const t of n.chars){if(l===r)return t.at;r+=t.ch.length}return S(t,e)}function B(t,e){const{lines:n}=t;let l=n[0];for(const t of n)e>=t.start&&(l=t);let r=0;for(const t of l.chars){if(!(e>=t.at+t.ch.length)){e>t.at&&(r+=e-t.at);break}r+=t.ch.length}return l.vis+r}function L(t,e,n){return[B(t,e),B(t,n)]}function R(t,e,n){return e===n?[S(t,e),S(t,e)]:[A(t,e),S(t,n)]}function W(t,e){let n=0;for(let l=0;l<t.chars.length;l+=1){if(n>=e)return l;n+=t.chars[l].ch.length}return t.chars.length}function j(t,o,i,a,s){const c=C(t,o),[u,d,h]=E(c,Math.min(i,a)),[f,p,m]=E(c,Math.max(i,a)),g=W(u,d),b=W(f,p),k=u.chars.slice(0,g),v=f.chars.slice(b),y=i!==a&&u.chars[g]&&(h!==m||g<b)?u.chars[g].marks:function(t,e){const n=t.chars[e-1],l=t.chars[e],r=(t,e)=>{const n=t.findIndex(t=>"link"===t.kind);return-1===n||e?t:t.slice(0,n)};if(n){const t=n.marks.find(t=>"link"===t.kind),e=Boolean(t&&l?.marks.some(e=>e.id===t.id));return r(n.marks,e)}return l?r(l.marks,!1):[]}(u,g);let x=(w=c.lines,Math.max(0,...w.flatMap(t=>t.chars.flatMap(t=>t.marks.map(t=>t.id))))+1);var w;const D=t=>{let e;if(void 0!==s.markup){const t=x;e=l(s.markup,o).map(e=>({bullet:e.bullet,number:e.number??null,chars:e.chars.map(e=>({...e,at:-1,marks:e.marks.map(e=>({...e,id:e.id+t}))}))}))}else{let n=u.number??null;e=(s.text??"").split("\n").map((e,l)=>(l>0&&null!=n&&(n=function(t){return String(Number(t)+1).padStart(t.length,"0")}(n)),{bullet:u.bullet,number:n,chars:[...e].map(e=>({ch:e,at:-1,marks:t??[]}))}))}const n=e.map(t=>t.chars.map(t=>t.ch).join("")).join("\n"),r={bullet:u.bullet,number:u.number??null,chars:[...k,...e[0].chars]},i=e.slice(1);if(i.length>0){const t=i[i.length-1];i[i.length-1]={...t,chars:[...t.chars,...v]}}else r.chars.push(...v);return{lines:[...c.lines.slice(0,h).map(({bullet:t,number:e,chars:n})=>({bullet:t,number:e,chars:n})),r,...i,...c.lines.slice(m+1).map(({bullet:t,number:e,chars:n})=>({bullet:t,number:e,chars:n}))],shown:n}},M=void 0!==s.markup?[null]:[(t=>{let e=t.filter(t=>!s.drop?.some(e=>t.kind===e||"highlight"===e&&"accent"===t.kind));for(const t of s.add??[]){if(e.some(e=>e.kind===t))continue;const n=r(x++,t);n&&(e=[...e,n])}if(void 0!==s.color){e=e.filter(t=>"color"!==t.kind);const t=null===s.color?null:r(x++,"color",s.color);t&&(e=[...e,t])}return e})(y),y,[]];let T="",N="";for(const t of M){const l=D(t),r=e(l.lines).text;if(T=r,N=l.shown,n(l.lines,C(r,o).lines))break}return{text:T,caret:Math.min(i,a)+N.length}}function P(t,e,n,l){const r=C(t,e),[o,,i]=E(r,n);return n!==l||!o.bullet&&null==o.number||""!==o.text?j(t,e,n,l,{text:"\n"}):K(t,e,i,!1,n)}function K(t,n,l,r,o){const i=C(t,n).lines.map(({bullet:t,number:e,chars:n},o)=>o===l?{bullet:r,number:null,chars:n}:{bullet:t,number:e,chars:n});return{text:e(i).text,caret:o}}function V(t,n,l,r){const o=C(t,n),[i,a,s]=E(o,Math.min(l,r)),[c,u,d]=E(o,Math.max(l,r)),h=o.lines.slice(s,d+1).map(({bullet:t,number:e,chars:n},l)=>{const r=0===l?W(i,a):0,o=l===d-s?W(c,u):n.length;return{bullet:t,number:e,chars:n.slice(r,o)}});return e(h).text}function q(t,e,n){if(n<0){const n=t.charCodeAt(e-1);return e-(n>=56320&&n<=57343&&e>=2?2:1)}const l=t.charCodeAt(e);return e+(l>=55296&&l<=56319?2:1)}function F(t){const{value:e,rules:n,multiline:l,inputType:r,pending:o}=t;let[i,a]=t.sel;t.target&&t.target[0]!==t.target[1]&&r.startsWith("delete")&&([i,a]=t.target);const s=[i,a];if("historyUndo"===r||"historyRedo"===r)return{kind:"history",dir:"historyUndo"===r?"undo":"redo"};if("formatBold"===r||"formatItalic"===r||"formatStrikeThrough"===r)return{kind:"format",style:"formatBold"===r?"bold":"formatItalic"===r?"italic":"strike"};if("insertParagraph"===r||"insertLineBreak"===r)return l?{kind:"edit",edit:P(e,n,i,a),range:s}:null;if(r.startsWith("insert")){if("insertTranspose"===r)return null;let c=t.data??"";if("insertFromDrop"===r||"insertFromPaste"===r){const r=D({html:t.html??void 0,text:c},{doc:t.doc,multiline:l,rules:n});return{kind:"edit",edit:j(e,n,i,a,{markup:r}),range:s}}return l||(c=c.replace(/\s*\r?\n\s*/g," ")),{kind:"type",edit:j(e,n,i,a,{text:c,add:o?.add,drop:o?.drop,color:o?.color}),range:s}}if(r.startsWith("delete")){const t=C(e,n),l=t.text;if(i===a){const o=r.includes("Backward"),c=t.lines.findIndex(t=>i>=t.vis&&i<=t.vis+t.text.length),u=t.lines[c];if(o&&u&&i===u.vis&&(u.bullet||null!=u.number))return{kind:"edit",edit:K(e,n,c,!1,i),range:s};if(o?0===i:i===l.length)return null;o?i=q(l,i,-1):a=q(l,a,1)}return{kind:"type",edit:j(e,n,i,a,{text:""}),range:[i,a]}}return null}var I=1e3;function O(t=200){let e=[],n=[],l=null,r=0;return{record(o,i,a){const s="type"===i&&"type"===l&&a-r<1e3;l=i,r=a,n=[],s||(e.push(o),e.length>t&&e.shift())},undo(t){const r=e.pop();return r?(n.push(t),l=null,r):null},redo(t){const r=n.pop();return r?(e.push(t),l=null,r):null},reset(){e=[],n=[],l=null}}}var z=t=>t.preventDefault();function U(t,e){if(t)return t.startsWith("#")?t:e?.find(e=>e.name===t)?.value}function $({colors:t,current:e,words:n,onPick:l}){const r=null===e?null:e.startsWith("#")?e.toLowerCase():t.find(t=>t.name===e)?.value.toLowerCase()??null;/* @__PURE__ */
|
|
2
|
-
return v("div",{className:"es-copy-pop es-copy-colors",role:"dialog","aria-label":n.title,onMouseDown:t=>{"INPUT"!==t.target.tagName&&t.preventDefault()},children:[
|
|
3
|
-
/* @__PURE__ */y("span",{className:"es-copy-pop-label",children:n.theme}),
|
|
4
|
-
/* @__PURE__ */y("div",{className:"es-copy-theme",role:"group","aria-label":n.theme,children:t.map(t=>/* @__PURE__ */y(m,{content:`${t.label} · ${t.value.toUpperCase()}`,children:/* @__PURE__ */y(g,{color:t.value,size:"sm",className:"es-copy-theme-swatch","data-color":t.name,"aria-label":t.label,selected:e===t.name,onMouseDown:z,onClick:()=>l(t.name)})},t.name))}),
|
|
5
|
-
/* @__PURE__ */y("span",{className:"es-copy-pop-label",children:n.any}),
|
|
6
|
-
/* @__PURE__ */y(b,{className:"es-copy-any",value:r??"",onChange:t=>{t!==e&&l(t)},label:n.title,dragWrites:"end"}),
|
|
7
|
-
/* @__PURE__ */y("div",{className:"es-copy-pop-foot",children:/* @__PURE__ */y(k,{variant:"ghost-danger",size:"sm","data-window-action":"remove",onMouseDown:z,onClick:()=>l(null),children:n.remove})})]})}var H={sup:"sub",sub:"sup"};function X(t){const{value:e,rules:n,start:l,end:r,style:a,pending:s}=t,c=H[a];if(l===r){const t=o(e,l,r,n),i=s&&s.at===l?s:null,u=t.has(a),d=!!i?.add.includes(a)||!i?.drop.includes(a)&&u;let h=(i?.add??[]).filter(t=>t!==a),f=(i?.drop??[]).filter(t=>t!==a);return d&&u?f.push(a):d||u||h.push(a),!d&&c&&(h=h.filter(t=>t!==c),t.has(c)&&(f=[...f.filter(t=>t!==c),c])),{kind:"pending",pending:h.length||f.length||void 0!==i?.color?{add:h,drop:f,color:i?.color,at:l}:null}}let u=e,d=l,h=r;if(c&&!o(u,d,h,n).has(a)&&o(u,d,h,n).has(c)){const t=i(u,d,h,c,n);({text:u,selectionStart:d,selectionEnd:h}=t)}return{kind:"edit",result:i(u,d,h,a,n)}}var Y=/^(block|list-item|flex|grid|table|flow-root)$/;function Z(t){const e=t.ownerDocument.defaultView;return!!e&&Y.test(e.getComputedStyle(t).display)}function G(t,e){const n=[],l=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map;let o="",i=!1;const a=()=>{i&&(o+="\n",i=!1)},s=t=>{for(const c of Array.from(t.childNodes)){if(3===c.nodeType){c.data.length>0&&a(),l.set(c,o.length),n.push({node:c,start:o.length,length:c.data.length}),o+=c.data,r.set(c,o.length);continue}if(1!==c.nodeType)continue;const t=c;if(e&&t.matches(e)){l.set(t,o.length),r.set(t,o.length);continue}if("BR"===t.tagName){a(),l.set(t,o.length),o+="\n",r.set(t,o.length);continue}const u=Z(t);u&&((i||o.length>0&&!o.endsWith("\n"))&&(o+="\n"),i=!1),l.set(t,o.length);const d=o.length;s(t),u&&o.length===d&&!i&&n.push({node:t,start:d,length:0}),r.set(t,o.length),u&&(i=!0)}};l.set(t,0),s(t),r.set(t,o.length);return{text:o,at:(t,e)=>{if(3===t.nodeType)return(l.get(t)??0)+Math.min(e,t.data.length);const n=t.childNodes;return e<n.length?l.get(n[e])??r.get(t)??0:r.get(t)??o.length},dom:e=>{for(let t=0;t<n.length;t+=1){const l=n[t],r=l.start+l.length;if(e<l.start)return[l.node,0];if(e<r||e===r&&(t===n.length-1||n[t+1].start>e))return 3===l.node.nodeType?[l.node,e-l.start]:[l.node,0]}const l=n[n.length-1];return l?3===l.node.nodeType?[l.node,l.length]:[l.node,0]:[t,0]}}}function J(t){const e=t.element();if(!e)return null;let n=t.value;const l=t.rules;if(G(e,t.skip).text!==C(n,l).text)return null;const r=t.now??(()=>Date.now()),i=O();let p=e,m=!1,g=null,b=null,k=[t.caret[0],t.caret[1]],v=null,y=!1,x=!1;const w=()=>{x||t.onSelect?.()},M={contenteditable:e.getAttribute("contenteditable"),spellcheck:e.getAttribute("spellcheck")},N=()=>p.ownerDocument,E=()=>N().defaultView?.getSelection()??null,S=()=>{if(!b)return!0;nt();const e=G(p,t.skip);if(e.text!==C(n,l).text)return!1;const[r,o]=b,[i,a]=e.dom(r),[s,c]=e.dom(o);return y||N().activeElement===p||p.focus({preventScroll:!0}),E()?.setBaseAndExtent(i,a,s,c),k=b,A=b,b=null,w(),!0};let A=null;const B=()=>{if(!A)return!1;const t=E(),e=t?.anchorNode??null;return!(e&&e.isConnected&&p.contains(e))||e===p&&0===t.anchorOffset&&(0!==A[0]||0!==A[1])},W=()=>{b=A,S()},P=()=>{S(),N().activeElement===p&&B()&&W();const e=E();if(!(e&&e.anchorNode&&e.focusNode&&p.contains(e.anchorNode)&&p.contains(e.focusNode)))return k;const n=G(p,t.skip),l=n.at(e.anchorNode,e.anchorOffset),r=n.at(e.focusNode,e.focusOffset);return k=l<=r?[l,r]:[r,l],k},K=t=>{const e=N().defaultView;t<=0||!e?A=null:e.requestAnimationFrame(()=>{m||b||(nt(),N().activeElement===p?(B()&&(W(),w()),K(t-1)):A=null)})},q=(t,e)=>{b=[t,e];const n=t=>{if(m)return;if(S())return void K(3);const e=N().defaultView;t>0&&e&&e.requestAnimationFrame(()=>n(t-1))};n(30)},I=(e,l,o)=>{e.text!==n?(i.record({text:n,start:l[0],end:l[1]},o,r()),n=e.text,t.write(n),q(e.caret,e.caret),w()):q(e.caret,e.caret)},z=t=>R(C(n,l),t[0],t[1]),U=(e,o)=>{if(e.text===n)return;i.record({text:n,start:o[0],end:o[1]},"edit",r()),n=e.text,t.write(n);const[a,s]=L(C(n,l),e.selectionStart,e.selectionEnd);q(a,s),w()},$=t=>{if(m)return;const e=P(),[r,o]=z(e),i=X({value:n,rules:l,start:r,end:o,style:t,pending:v});if("pending"===i.kind)return v=i.pending,void w();U(i.result,e)},H=e=>{n=e.text,t.write(n),q(e.start,e.end)},Y=e=>{m||(m=!0,lt.removeEventListener("selectionchange",rt),et(p),t.end(e))},Z=(t,e)=>{const r=P();!m&&r[0]!==r[1]&&t.clipboardData&&(t.preventDefault(),t.clipboardData.setData("text/plain",C(n,l).text.slice(r[0],r[1])),t.clipboardData.setData(T,V(n,l,r[0],r[1])),e&&I(j(n,l,r[0],r[1],{text:""}),r,"edit"))},J=t=>t.preventDefault(),Q=()=>{t.remount?.()},_=[["keydown",e=>{if(m||e.isComposing)return;const l=e.metaKey||e.ctrlKey;if("Escape"!==e.key){if(l&&!e.altKey&&!e.shiftKey&&("k"===e.key||"K"===e.key)&&t.onLinkKey?.())return e.preventDefault(),void e.stopPropagation();if("Enter"===e.key&&(!e.shiftKey||l))return e.preventDefault(),e.stopPropagation(),void Y("enter");if(l&&("z"===e.key||"Z"===e.key||"y"===e.key)){e.preventDefault(),e.stopPropagation();const t=P(),l={text:n,start:t[0],end:t[1]},r="y"===e.key||e.shiftKey?i.redo(l):i.undo(l);r&&H(r)}}else{if(e.preventDefault(),e.stopPropagation(),t.onEscape?.())return;Y("escape")}}],["beforeinput",e=>{if(m)return;if("insertCompositionText"===e.inputType)return;e.preventDefault();const r=P(),o=G(p,t.skip),a="function"==typeof e.getTargetRanges?e.getTargetRanges()[0]:void 0,s=a&&!a.collapsed?[o.at(a.startContainer,a.startOffset),o.at(a.endContainer,a.endOffset)]:null,c=F({value:n,rules:l,multiline:t.multiline,inputType:e.inputType,data:e.data??e.dataTransfer?.getData("text/plain")??"",html:e.dataTransfer?.getData("text/html"),doc:N(),sel:r,target:s,pending:v&&v.at===z(r)[0]?v:null});if(c){if("type"!==c.kind&&"edit"!==c.kind||(v=null),"history"===c.kind){const t={text:n,start:r[0],end:r[1]},e="undo"===c.dir?i.undo(t):i.redo(t);return void(e&&H(e))}"format"!==c.kind?I(c.edit,c.range,c.kind):$(c.style)}}],["compositionstart",()=>{g=P()}],["compositionend",e=>{const o=g;if(g=null,!m&&o)if(e.data){const a=j(n,l,o[0],o[1],{text:e.data});i.record({text:n,start:o[0],end:o[1]},"type",r()),n=a.text,t.write(n),Q(),q(a.caret,a.caret)}else Q(),q(o[0],o[0])}],["paste",e=>{if(m)return;e.preventDefault();const r=P(),o=e.clipboardData,i=o?.getData(T)??"",a=i?t.multiline?i:i.replace(/\s*\r?\n\s*/g," "):D({html:o?.getData("text/html")??"",text:o?.getData("text/plain")??""},{doc:N(),multiline:t.multiline,rules:l});I(j(n,l,r[0],r[1],{markup:a}),r,"edit")}],["copy",t=>Z(t,!1)],["cut",t=>Z(t,!0)],["drop",J],["dragstart",J],["blur",e=>{if(m||null!==g||y)return;const n=e.target,l=n.ownerDocument.defaultView,r=()=>{m||(n.isConnected&&n===t.element()?y||n.ownerDocument.activeElement===n||Y("blur"):q(k[0],k[1]))};l?.requestAnimationFrame?l.requestAnimationFrame(r):setTimeout(r,0)}],["focus",()=>{y=!1}]];function tt(t){t.setAttribute("contenteditable","true"),t.setAttribute("spellcheck","false"),t.setAttribute("data-es-typing","");for(const[e,n]of _)t.addEventListener(e,n)}function et(t){for(const[e,n]of _)t.removeEventListener(e,n);null===M.contenteditable?t.removeAttribute("contenteditable"):t.setAttribute("contenteditable",M.contenteditable),null===M.spellcheck?t.removeAttribute("spellcheck"):t.setAttribute("spellcheck",M.spellcheck),t.removeAttribute("data-es-typing")}function nt(){const e=t.element();e&&e!==p&&(et(p),p=e,tt(p))}const lt=p.ownerDocument;function rt(){m||w()}return lt.addEventListener("selectionchange",rt),tt(p),p.focus({preventScroll:!0}),q(t.caret[0],t.caret[1]),{get value(){return n},update(t){if(t===n)return;const e=C(t,l).text.length,[r,o]=P();n=t,i.reset(),q(Math.min(r,e),Math.min(o,e))},stop(t="stop"){Y(t)},pressed(){let t;x=!0;try{t=P()}finally{x=!1}const[e,r]=z(t),i=o(n,e,r,l),s={};for(const t of["bold","italic","underline","strike","sup","sub","link"]){const n=i.has(t),l=v&&v.at===e?v:null;s[t]=!!l?.add.includes(t)||!l?.drop.includes(t)&&n}const c=v&&v.at===e&&void 0!==v.color?v:null;return{marks:s,list:a(n,e,r,l),selected:r>e,href:f(n,e,r)?.href??null,color:c?c.color??null:h(n,e,r,l)}},press:$,insert(t){if(m)return;y=!1;const e=P(),[l,r]=z(e),o=l+t.length;U({text:n.slice(0,l)+t+n.slice(r),selectionStart:o,selectionEnd:o},e),nt(),p.focus({preventScroll:!0})},hold(){m||(P(),y=!0)},release(){y=!1},resume(){m||(y=!1,nt(),p.focus({preventScroll:!0}),q(k[0],k[1]))},link(t){if(m)return;y=!1;const e=P(),[r,o]=z(e),i=null===t?u(n,r,o,l):d(n,r,o,t,l),a=i.text===n;U(i,e),nt(),p.focus({preventScroll:!0}),a&&q(e[0],e[1])},color(t){if(m)return;const e=P(),[r,o]=z(e);if(r===o){const e=v&&v.at===r?v:null;return v={add:e?.add??[],drop:e?.drop??[],color:t,at:r},void w()}U(c(n,r,o,t,l),e)},list(e){if(m||!t.multiline)return;const r=P(),[o,i]=z(r),c=a(n,o,i,l);U(s(n,o,i,c===e?null:e,l),r)}}}var Q=(t,e,n)=>Math.min(Math.max(t,e),Math.max(e,n));function _({anchor:t,size:e,within:n,clip:l,parent:r,gap:o=8}){const i=Math.max(n.left,l.left),a=Math.min(n.right,l.right)-e.width,s=Q(t.left,i,a),c=l.bottom-(t.bottom+o),u=t.top-o-l.top,d=e.height>c&&(e.height<=u||u>c),h=d?t.top-o-e.height:t.bottom+o,f=t.left+Math.min((t.right-t.left)/2,10),p=Q(f-5-s,10,e.width-10-10);return{top:h-r.top,left:s-r.left,above:d,point:p}}var tt=t=>({left:t.left,top:t.top,right:t.right,bottom:t.bottom});function et(t,e){const n=("function"==typeof t.getClientRects?[...t.getClientRects()]:[]).filter(t=>t.height>0);if(n.length>0){const e="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():n[0];return e.height>0?tt(e):tt(n[0])}if(!e)return null;const l=e.getBoundingClientRect();return{left:l.left,top:l.top,right:l.left,bottom:l.bottom}}function nt(t){const e=t.ownerDocument,n=e.documentElement,l={left:0,top:0,right:n.clientWidth,bottom:n.clientHeight},r=e.defaultView?.getComputedStyle.bind(e.defaultView);for(let o=t.parentElement;o&&o!==n&&o!==e.body;o=o.parentElement){const t=r?.(o);if(!t||"visible"===t.overflowX&&"visible"===t.overflowY)continue;const e=o.getBoundingClientRect();if(0===e.width&&0===e.height)continue;const n=e.left+o.clientLeft,i=e.top+o.clientTop;l.left=Math.max(l.left,n),l.top=Math.max(l.top,i),l.right=Math.min(l.right,n+(o.clientWidth||e.width)),l.bottom=Math.min(l.bottom,i+(o.clientHeight||e.height))}return l}function lt(t){const e=t.offsetParent??t.parentElement;if(!e)return{left:0,top:0};const n=e.getBoundingClientRect();return{left:n.left+e.clientLeft-e.scrollLeft,top:n.top+e.clientTop-e.scrollTop}}function rt(t,e,n){const l=t.ownerDocument,r=l.createTreeWalker(t,4),o=t=>{let e=t,n=null;for(let t=r.nextNode();t;t=r.nextNode()){if(e<=t.data.length)return[t,e];e-=t.data.length,n=t}return n?[n,n.data.length]:null},i=o(e);r.currentNode=t;const a=o(n);if(!i||!a)return null;const s=l.createRange();return s.setStart(i[0],i[1]),s.setEnd(a[0],a[1]),s}export{$ as ColorWindow,T as MARKUP_CLIPBOARD_TYPE,I as TYPING_BURST_MS,U as colorRunOf,O as createHistory,j as editVisible,X as markPress,V as markupOfRange,P as newLine,lt as offsetOrigin,D as pasteToMarkup,_ as placeWindow,F as richInput,C as richLayout,et as selectionBox,R as selectionToSource,L as selectionToVisible,K as setBullet,J as startCanvasTyping,G as textMap,rt as textRange,S as toSource,A as toSourceStart,B as toVisible,nt as visibleArea};
|