efficient-easel 20.0.0 → 20.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/{ScreenDocumentContext-RxVWWWHq.d.ts → ScreenDocumentContext-CFJeqqKk.d.ts} +27 -2
  2. package/dist/chrome/chrome.css +2 -1
  3. package/dist/chunk-276MBG5P.js +2 -0
  4. package/dist/chunk-2BOXPUGF.js +1 -0
  5. package/dist/{chunk-MS2U6MV5.js → chunk-2G6MAXPY.js} +1 -1
  6. package/dist/chunk-3R3PEVU7.js +65 -0
  7. package/dist/{chunk-EZG3TGQ7.js → chunk-77IWWW6X.js} +1 -1
  8. package/dist/{chunk-SK3P56FS.js → chunk-7LYKFL3Q.js} +13 -13
  9. package/dist/{chunk-ROPYFLNZ.js → chunk-EFHV56BO.js} +13 -13
  10. package/dist/chunk-FGJTX2DL.js +8 -0
  11. package/dist/{chunk-LNHT2KPX.js → chunk-FHCKFOCD.js} +2 -2
  12. package/dist/{chunk-LDEEFLE3.js → chunk-H2PRGXCW.js} +8 -8
  13. package/dist/{chunk-KC24D76S.js → chunk-I7BROL77.js} +1 -1
  14. package/dist/{chunk-BW5COX42.js → chunk-JQXD3TDE.js} +1 -1
  15. package/dist/{chunk-2A7HLAI5.js → chunk-L2Y3PF2R.js} +1 -1
  16. package/dist/chunk-MEHLY5Q4.js +1 -0
  17. package/dist/chunk-MQA7OFRA.js +2 -0
  18. package/dist/{chunk-RR4VIAHP.js → chunk-OTONLZR4.js} +4 -4
  19. package/dist/chunk-PAOZMXEI.js +5 -0
  20. package/dist/{chunk-2E2SXDYQ.js → chunk-TNGOL65V.js} +1 -1
  21. package/dist/{chunk-VPFNZ7TB.js → chunk-U66YKDAR.js} +1 -1
  22. package/dist/{chunk-5DPIGWUL.js → chunk-UJ46J7QW.js} +1 -1
  23. package/dist/{chunk-RYNBSKE7.js → chunk-UNVKPVZW.js} +1 -1
  24. package/dist/chunk-WEIE2FBC.js +1 -0
  25. package/dist/copy/index.js +12 -12
  26. package/dist/drag/index.js +1 -1
  27. package/dist/easel/index.js +1 -1
  28. package/dist/fields/index.js +1 -1
  29. package/dist/screen/components/AddBlockRow.js +1 -1
  30. package/dist/screen/components/AddSidePanel.js +1 -1
  31. package/dist/screen/components/MediaPopup.js +1 -1
  32. package/dist/screen/components/NodeContextMenu.d.ts +1 -1
  33. package/dist/screen/components/NodeContextMenu.js +1 -1
  34. package/dist/screen/components/PageEditGuardNotices.js +1 -1
  35. package/dist/screen/components/SaveControls.d.ts +1 -1
  36. package/dist/screen/components/ScreenChrome.js +1 -1
  37. package/dist/screen/components/ScreenDocumentContext.d.ts +1 -1
  38. package/dist/screen/components/ScreenDocumentContext.js +1 -1
  39. package/dist/screen/components/ScreenMount.d.ts +1 -1
  40. package/dist/screen/components/ScreenMount.js +1 -1
  41. package/dist/screen/components/ScreenStoreProvider.d.ts +1 -1
  42. package/dist/screen/components/ScreenStoreProvider.js +1 -1
  43. package/dist/screen/components/SectionScreenShell.js +16 -16
  44. package/dist/screen/components/usePartBridge.d.ts +1 -1
  45. package/dist/screen/components/usePartBridge.js +1 -1
  46. package/dist/screen/index.d.ts +1 -1
  47. package/dist/screen/index.js +1 -1
  48. package/dist/screen/lib/admin-bridge.js +1 -1
  49. package/dist/screen/lib/document-addressing.d.ts +1 -1
  50. package/dist/screen/lib/host-inbound.js +1 -1
  51. package/dist/screen/lib/host.d.ts +1 -1
  52. package/dist/screen/lib/host.js +1 -1
  53. package/dist/screen/lib/key-scope.js +1 -1
  54. package/dist/screen/lib/media-panel.d.ts +1 -1
  55. package/dist/screen/lib/media-panel.js +1 -1
  56. package/dist/screen/lib/media-picker.d.ts +1 -1
  57. package/dist/screen/lib/media-picker.js +1 -1
  58. package/dist/screen/lib/puck/preview-dom.js +1 -1
  59. package/dist/screen/lib/puck/style-clipboard.d.ts +1 -1
  60. package/dist/screen/lib/puck/style-clipboard.js +1 -1
  61. package/dist/screen/lib/puck/use-section-ops.js +1 -1
  62. package/dist/screen/lib/screen-parts.d.ts +6 -1
  63. package/dist/screen/lib/screen-parts.js +1 -1
  64. package/dist/screen/screen.css +37 -0
  65. package/dist/strings/index.js +1 -1
  66. package/dist/text-styles/index.js +27 -27
  67. package/package.json +1 -1
  68. package/dist/chunk-A42LPWNM.js +0 -1
  69. package/dist/chunk-BC5KJNHN.js +0 -63
  70. package/dist/chunk-CBICQ4J3.js +0 -5
  71. package/dist/chunk-EW6XAMDZ.js +0 -8
  72. package/dist/chunk-M62P4IQK.js +0 -2
  73. package/dist/chunk-NHY5L3SE.js +0 -1
  74. package/dist/chunk-QALW2ECZ.js +0 -1
  75. package/dist/chunk-U3JP4VGF.js +0 -2
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { ReactNode, RefObject } from 'react';
2
+ import { ComponentType, ReactNode, RefObject } from 'react';
3
3
  import { Data } from './blocks/index.js';
4
4
  import { EaselDocumentAdapter, EaselCapabilities } from './screen/lib/document-contract.js';
5
5
  import { SaveStatus } from './screen/lib/document-switch.js';
@@ -471,6 +471,28 @@ interface EaselHost {
471
471
  * own listeners close those things, as they always have.
472
472
  */
473
473
  claimEscape?(handler: (e: KeyboardEvent) => boolean): () => void;
474
+ /** What the host puts in the screen's own chrome (`EaselHostPanels`). */
475
+ readonly panels?: EaselHostPanels;
476
+ }
477
+ /**
478
+ * WHAT A HOST PUTS IN THE SCREEN (JARVIS in the Storefront editor, Victor Mau
479
+ * 2026-10-24). Fixed for the life of a host, like the rest of it: the host
480
+ * drives what they show from its own state, so turning a panel on or off
481
+ * never remounts the editor.
482
+ *
483
+ * - `Toolbar` is drawn first in the top bar's right cluster, before the save
484
+ * icon: the admin portal's JARVIS button.
485
+ * - `useRight` is called as a hook while the screen draws, every time. When
486
+ * it returns something, that stands in the inspector's place inside the
487
+ * right panel, at the panel's width and with its grip; selecting a block
488
+ * opens the panel onto it, not onto the inspector. The panel's own hide and
489
+ * show strip still work (a host that wants it open sends
490
+ * `storefront-editor:set-right-panel`). `null` gives the panel back to the
491
+ * inspector, exactly as it was.
492
+ */
493
+ interface EaselHostPanels {
494
+ Toolbar?: ComponentType;
495
+ useRight?: () => ReactNode | null;
474
496
  }
475
497
  /** The host of a surface nobody embeds: nothing sent, nothing heard, an address
476
498
  * that stays put. */
@@ -507,6 +529,9 @@ declare function createEaselHost(options: {
507
529
  /** How the screen takes Escape before the embedder's window does
508
530
  * (`EaselHost.claimEscape`, 0.105.0). Left out, it claims nothing. */
509
531
  claimEscape?: (handler: (e: KeyboardEvent) => boolean) => () => void;
532
+ /** What the host puts in the screen's chrome (`EaselHost.panels`). Left out,
533
+ * the screen draws only its own. */
534
+ panels?: EaselHostPanels;
510
535
  }): {
511
536
  host: EaselHost;
512
537
  deliver: (message: HostToEaselMessage) => void;
@@ -718,4 +743,4 @@ declare function ScreenDocumentProvider({ target, addressing: handed, onHostMess
718
743
  children: ReactNode;
719
744
  }): react.JSX.Element;
720
745
 
721
- export { type AnyDocumentAddressing as A, DETACHED_EASEL_HOST as D, type EaselBlockType as E, type HostPickedMedia as H, type InboundHostMessage as I, NO_DOCUMENT_ADDRESSING as N, type PageEditOp as P, type SectionScreenTarget as S, type DocumentAddressing as a, type EaselFieldDescription as b, type EaselHost as c, type EaselHostAddress as d, EaselHostContext as e, EaselHostProvider as f, type EaselMessageType as g, type EaselSelection as h, type EaselToHostMessage as i, type HostToEaselMessage as j, type PickedMediaSource as k, type SendToHost as l, createEaselHost as m, useHostEscape as n, type AnyScreenTarget as o, type DocumentTarget as p, ScreenDocumentContext as q, ScreenDocumentProvider as r, type ScreenDocumentValue as s, type ScreenTarget as t, useEaselHost as u, useScreenDocument as v };
746
+ export { type AnyDocumentAddressing as A, DETACHED_EASEL_HOST as D, type EaselBlockType as E, type HostPickedMedia as H, type InboundHostMessage as I, NO_DOCUMENT_ADDRESSING as N, type PageEditOp as P, type SectionScreenTarget as S, type DocumentAddressing as a, type EaselFieldDescription as b, type EaselHost as c, type EaselHostAddress as d, EaselHostContext as e, type EaselHostPanels as f, EaselHostProvider as g, type EaselMessageType as h, type EaselSelection as i, type EaselToHostMessage as j, type HostToEaselMessage as k, type PickedMediaSource as l, type SendToHost as m, createEaselHost as n, useHostEscape as o, type AnyScreenTarget as p, type DocumentTarget as q, ScreenDocumentContext as r, ScreenDocumentProvider as s, type ScreenDocumentValue as t, useEaselHost as u, type ScreenTarget as v, useScreenDocument as w };
@@ -61,7 +61,8 @@
61
61
  width: var(--es-left-w, 288px);
62
62
  box-sizing: border-box;
63
63
  height: 100%;
64
- border-right: 1px solid var(--es-line);
64
+ /* No hairline up through the bar since 2026-10-25 (owner): the bar draws no
65
+ vertical line; the panel below keeps its own edge. */
65
66
  }
66
67
  .es-cluster--rail {
67
68
  /* `flex: none` IS THE WIDTH. The bar is a flex row, so `width` alone is only a
@@ -0,0 +1,2 @@
1
+ import{routeSharedHostMessage as e}from"./chunk-77IWWW6X.js";import{describeLoadFailure as r,hostLoadRefusal as n}from"./chunk-ERR437B5.js";import{editLockOf as t}from"./chunk-GMCZXMOV.js";import{NO_DOCUMENT_ADDRESSING as o}from"./chunk-RLBXE4EU.js";import{saveStatusOf as u,resetForDocumentSwitch as a}from"./chunk-HNKB2ZYR.js";import{isExpiredSession as s,readEaselFailure as i}from"./chunk-CLOS6SSX.js";import{useAdminBridge as l}from"./chunk-U66YKDAR.js";import{STATUS_UNREACHABLE as c}from"./chunk-KCOBHPN6.js";import{useEaselSession as d}from"./chunk-O7Q4DDJT.js";import{backendOf as f,setSessionDocumentSite as m}from"./chunk-RSCMJIWS.js";import{useEaselHost as k}from"./chunk-MQA7OFRA.js";import{DEFAULT_SCREEN_WORDS as v}from"./chunk-23DYNW6S.js";import{useAutosave as g}from"./chunk-NDRZP6YR.js";import{canWriteDocument as p,newEaselClientId as h,reloadIfVersionMoved as y,openUnansweredClaim as w,FAIL_OPEN_RETRY_MS as S,CLAIM_FAIL_OPEN_MS as b,holderOf as I}from"./chunk-THWO5YVZ.js";import{useWords as P}from"./chunk-MFIRYGHW.js";import{createContext as j,useContext as R,useState as O,useMemo as B,useCallback as C,useEffect as E,useRef as H}from"react";import{jsx as A}from"react/jsx-runtime";var D={content:[],root:{},zones:{}};var M=j(null);function T(){const e=R(M);if(!e)throw new Error("useStorefrontDocument must be used within StorefrontDocumentProvider");return e}function N({target:j,addressing:R=o,onHostMessage:T,children:N}){const W=R,{homeSlug:F,entryMayBounce:L,entryBounce:Y,onSwitch:V,tellsHost:K,adapterFor:U,migrateRenamedProps:X,describeMissing:Z,onLoadFailed:x}=W,[G,J]=O(j),Q=k(),z=d(),_=B(()=>f(z),[z]),q=B(()=>t(z),[z]),$="template"===G.kind,ee="template"===G.kind?G.id:null,re="template"===G.kind?G.pageSlug??F??"":"document"===G.kind?G.slug??"":G.slug,ne="page"===G.kind?G.siteId??null:null,te=z.blocks,oe=B(()=>U(G,_,te),[U,_,te,G.kind,"template"===G.kind?G.id:"document"===G.kind?G.record:G.siteId]),ue=oe.capabilities,ae=C(e=>z.documentHooks?.stored?.(e)??e,[z]);E(()=>{m(z,ne)},[z,ne]);const se=H(G);E(()=>{se.current=G},[G]);const{token:ie,tokenRef:le,capabilities:ce}=l({onMessage:r=>{if(T?.(r)||e(r))return;const n=r;if("storefront-editor:navigate"===n?.type){const e=r;e?.target&&Or(e.target)}}}),de=!z.usesBridgedToken||null!==ie,fe=oe.lock,me=Boolean(_.lock),[ke,ve]=O(null),[ge,pe]=O(null),[he,ye]=O(null),[we,Se]=O(null),be=P("screen",v),Ie=we?function(e,r){if(null!==e.sentence)return e.sentence;if(!e.missing)return r.loadFailed({cause:e.cause});switch(e.target.kind){case"template":return r.missingTemplatePage;case"document":return r.missingDocument;default:return r.missingPage({slug:e.slug})}}(we,be):null,[Pe,je]=O(null),Re=H(null),Oe=H(null),[Be,Ce]=O(!1),Ee=H(null),[He,Ae]=O(null),De=H(null),[Me,Te]=O(null),[Ne,We]=O(!1),Fe=H(null);E(()=>{Fe.current=Me},[Me]);const[Le,Ye]=O(ue.hasEditLock?{kind:"checking"}:{kind:"editing"}),Ve=H(Le);E(()=>{Ve.current=Le},[Le]);const Ke=H(()=>Promise.resolve(!1)),Ue=C(e=>{Oe.current=e,Ce(!0)},[]),Xe=g({save:async({id:e,data:r})=>{if(p(Ve.current)){if(!await Ke.current(e,r)){if(!p(Ve.current))return void Ue({id:e,data:r});throw new Error("page save did not land")}}else Ue({id:e,data:r})},onFailure:(e,r)=>{0===r&&Q.send("storefront-editor:save-failed")}}),{state:Ze,push:xe,flush:Ge,pause:Je,resume:Qe,stop:ze,reset:_e,retryNow:qe,hasPending:$e}=Xe,er=H(Ze);E(()=>{er.current=Ze},[Ze]);const rr=u(Ze),nr=C(()=>{const e=Oe.current;e&&(Oe.current=null,Ce(!1),xe(e))},[xe]),tr=H("");tr.current||(tr.current=h());const[or,ur]=O(0),ar=H(!1),[sr,ir]=O(L(j)),lr=H(!1);E(()=>{if(lr.current)return;lr.current=!0;const e=Q.address.search(),r=Y(j,e);r?Q.address.load(r):L(j)&&ir(!1)},[j,Q]);const cr=Q.send;E(()=>{if(!de)return;let e=!1;const t=se.current,o=oe.resolve(re),u=z.documentHooks?.opening?.({slug:re,isTemplate:$,capabilities:ue});return o.then(async r=>{if(e)return;if(!r)return"page"===t.kind&&null!==F&&re!==F?void Q.address.load({kind:"page",slug:F,siteId:ne??void 0}):(Se({target:t,slug:re,missing:!0,sentence:Z?.(t)??null}),void x?.(t,null));const n=r.readOnlyReason?r.readOnlyReason:null;Re.current=n,je(n),ve(r.id),pe(r.kind??null),De.current=r.version??null;const o=r.layout,a=o&&Object.keys(o).length?o:D,s=X(a),i=u?await u(s):s;e||ye(i)}).catch(o=>{e||(console.error("[storefront-editor] document load failed",o),Se({target:t,slug:re,missing:!1,sentence:n(o,{slug:re},z),cause:r(o,z)}),x?.(t,o))}),()=>{e=!0}},[de,ie,$,oe,re]);const dr=C(e=>new Promise(r=>{const n=Date.now(),t=setInterval(()=>{const o=le.current;o&&o!==e?(clearInterval(t),r(o)):Date.now()-n>6e3&&(clearInterval(t),r(null))},200)}),[]),fr=C(async e=>{const r=le.current;if(!r&&z.usesBridgedToken)return{ok:!1,error:new Error("no editor token")};try{return{ok:!0,value:await e(r??"")}}catch(n){if(s(n,z)){cr("storefront-editor:auth-expired");const n=r?await dr(r):null;if(n)try{return{ok:!0,value:await e(n)}}catch(e){return{ok:!1,error:e}}}return{ok:!1,error:n}}},[cr,dr,z]),mr=C(async e=>{const r=le.current?await fr(e):{ok:!1};return r.ok||cr("storefront-editor:save-failed"),r.ok},[cr,fr]),kr=C(async(e,r,n=!1)=>{if(null!==Re.current)return!1;if(!p(Ve.current))return!1;if(Fe.current)return!1;const t=await fr(()=>oe.saveLayout(e,r,De.current,tr.current));if(t.ok)return De.current=t.value.version??De.current,We(!1),!0;const o=q.readLockTaken(t.error);if(o){const e={kind:"takenover",holder:o};return Ve.current=e,Ye(e),!1}const u=q.readSaveConflict(t.error);if(u){if(u.savedByYou&&!n&&oe.rereadVersion){const n=await fr(()=>oe.rereadVersion(e));if(n.ok&&n.value)return De.current=n.value,Ke.current(e,r,!0)}ze(),Fe.current=u,Te(u)}return We(i(t.error,z)?.status===c),!1},[oe,fr,ze,z]);E(()=>{Ke.current=kr},[kr]);const vr=C(e=>{if(null!==Re.current)return;if(cr("storefront-editor:dirty"),!ke)return;const r=ae(e);Ee.current=r,p(Ve.current)?xe({id:ke,data:r}):Ue({id:ke,data:r})},[ke,cr,Ue,xe,ae]),gr=C(async()=>{p(Ve.current)&&nr();return await Ge()&&null==Oe.current},[nr,Ge]),pr=H(gr);E(()=>{pr.current=gr},[gr]);const hr=H(fr);E(()=>{hr.current=fr},[fr]);const yr=C(()=>{Q.address.reload()},[Q]),wr=H(()=>Promise.resolve(!1));E(()=>{wr.current=()=>{const e=oe.rereadVersion;return ke&&e?y({ours:De.current,stored:async()=>{const r=await hr.current(()=>e(ke));return r.ok?r.value:null},hasPending:()=>null!=Oe.current||$e(),reload:yr}):Promise.resolve(!1)}},[oe,ke,$e,yr]);const Sr=null!==Pe;E(()=>{if(!fe||!ke||!de||Sr)return;let e=!1,r=null,n=null;const t=tr.current,o={claim:async e=>{const r=await hr.current(()=>fe.claim(ke,t,e));if(r.ok)return{heartbeat_seconds:r.value.heartbeatSeconds};throw r.error},cancelled:()=>e,currentAccess:()=>Ve.current,heldWrite:()=>({pending:null!=Oe.current||$e(),autoSaveEnabled:!er.current.paused,saveConflict:null!=Fe.current}),setAccess:e=>{Ve.current=e,Ye(e)},releaseHeldWrite:()=>{pr.current()},startHeartbeat:e=>{r&&clearInterval(r),r=setInterval(()=>{u(!1)},e)},stopHeartbeat:()=>{r&&(clearInterval(r),r=null)},reloadIfMoved:()=>{wr.current()}},u=q.makeClaimBeat(o),a=ar.current;return ar.current=!1,a||(Ye({kind:"checking"}),n=setTimeout(()=>{n=null,w(o)&&o.startHeartbeat(S)},b)),u(a).finally(()=>{n&&clearTimeout(n),n=null}),()=>{e=!0,n&&clearTimeout(n),r&&clearInterval(r),fe.release(ke,t).catch(()=>{})}},[ke,fe,de,ie,or,Sr]);const br=C(()=>{fe&&ke&&(ar.current=!0,ur(e=>e+1))},[ke,fe]),Ir=C(()=>{Ye(e=>{const r="blocked"===e.kind||"takenover"===e.kind?e.holder:null;return r?{kind:"readonly",holder:r}:e})},[]),Pr=C(()=>{er.current.paused?(p(Ve.current)&&nr(),Qe()):Je()},[nr,Je,Qe]),jr=C(()=>{qe()},[qe]),Rr=C(e=>{Ee.current=null,a("template"!==e.kind&&me,{resetAutosave:()=>{_e(),Oe.current=null,Ce(!1)},setVersion:e=>{De.current=e},setSaveConflict:Te,setAccess:Ye}),V(e),J(e),Re.current=null,je(null),ve(null),pe(null),ye(null),Se(null),Q.address.show(e),"document"!==e.kind&&K(e)&&Q.send("storefront-editor:navigated",{target:e})},[_e,Q,me,V,K]),Or=C(e=>{if(function(e,r,n){if(e.kind!==r.kind)return!1;if("template"===e.kind){const t=r;return e.id===t.id&&(e.pageSlug??n)===(t.pageSlug??n)}if("document"===e.kind){const n=r;return e.record===n.record&&(e.slug??"")===(n.slug??"")}const t=r;return e.slug===t.slug&&e.siteId===t.siteId}(e,se.current,F))return;const r=null!=Oe.current;if(!r&&!$e())return void Rr(e);const n=er.current;r||n.paused||n.failed||n.stopped?Ae(e):Ge().then(r=>{r?Rr(e):Ae(e)})},[Rr,$e,Ge,F]),Br=C(()=>Ae(null),[]),Cr=C(()=>{Ae(e=>(e&&Rr(e),null))},[Rr]),Er=C(async()=>{const e=He;if(!e)return;await gr()&&(Ae(null),Rr(e))},[He,gr,Rr]),Hr=C(async e=>{if(null!==Re.current)return;if(!ke)return;if(!p(Ve.current)||Fe.current)return;const r=ae(e);if(!await kr(ke,r))return void(Fe.current||cr("storefront-editor:save-failed"));const n=oe.publish;if(!ue.canPublish||!n)return void cr("storefront-editor:saved");const t=await fr(()=>n(ke,De.current??void 0));if(!t.ok){const{error:e}=t;return void cr("storefront-editor:publish-failed",{reason:e instanceof Error&&e.message?e.message:null})}De.current=t.value.version??De.current,cr("storefront-editor:published")},[ke,oe,ue.canPublish,cr,kr,fr,ae]);/* @__PURE__ */
2
+ return A(M.Provider,{value:{target:G,adapter:oe,capabilities:ue,templateId:ee,currentSlug:re,currentKind:ge,siteId:ne,ready:de,token:ie,tokenRef:le,notifyParent:cr,bridgeCapabilities:ce,runAuthed:mr,docId:ke,data:he,getLiveData:()=>Ee.current??he,error:Ie,redirecting:sr,saveStatus:rr,saveState:Ze,autoSaveEnabled:!Ze.paused,autoSaveStoppedByConflict:Ze.stopped,hasUnsavedEdits:Ze.pending||Be,toggleAutoSave:Pr,retrySave:jr,onChange:vr,flushSave:gr,onPublish:Hr,access:Le,readOnly:null!==I(Le)||null!==Pe||null!==Me,readOnlyReason:Pe,takeOverEditing:br,viewReadOnly:Ir,saveConflict:Me,saveUnreachable:Ne,reloadFromServer:yr,navigate:Or,pendingNav:He,cancelPendingNav:Br,discardAndNavigate:Cr,saveAndNavigate:Er},children:N})}export{M as ScreenDocumentContext,N as ScreenDocumentProvider,T as useScreenDocument};
@@ -0,0 +1 @@
1
+ import{useEaselSession as e}from"./chunk-O7Q4DDJT.js";import{useHostEscape as n}from"./chunk-MQA7OFRA.js";import{DEFAULT_SCREEN_WORDS as t}from"./chunk-23DYNW6S.js";import{styleMenuItems as o}from"./chunk-V7U33NF2.js";import{createNodeClipboard as l,nodeMenuItems as r}from"./chunk-P5VYGWYO.js";import{DEFAULT_NODE_MENU_WORDS as i}from"./chunk-WK3AFPXY.js";import{easelMenuEntries as c,menuLabel as s}from"./chunk-FIVU2COQ.js";import{zoneKey as u,ROOT_SLOT as a,ROOT_ID as d}from"./chunk-K7BTCBWD.js";import{isTypingTarget as p,useCanvasEvent as f,framePointToHost as m}from"./chunk-QIDRJH3S.js";import{ROOT_ZONE as h}from"./chunk-PLVEGYK6.js";import{useState as y,useCallback as k,useRef as b,useEffect as g}from"react";import{ContextMenu as v}from"efficient-shell/ui";import{UndoIcon as w,RedoIcon as x,PasteIcon as C,SettingsIcon as O,LayersIcon as z,CopyIcon as P}from"efficient-shell/icons/efficient";import{jsx as A}from"react/jsx-runtime";function D(e,n){const t=[],o=/* @__PURE__ */new Set;let l={zone:n.zone,index:n.index};for(;l;){const n=e.nodeAt(l.zone,l.index);if(!n||o.has(n.props.id))break;if(o.add(n.props.id),t.push({zone:l.zone,index:l.index,node:n,parentType:null}),l.zone===h)break;const r=l.zone.lastIndexOf(":");if(r<=0)break;l=e.locate(l.zone.slice(0,r))}for(let e=0;e<t.length-1;e+=1)t[e].parentType=t[e+1].node.type;return t}var K=l(),j=/* @__PURE__ */new WeakMap;function M(e){if(e.claimsPage)return K;const n=e.registry;if(!n)return e.cache("easel:node-clipboard",l);let t=j.get(n);return t||(t=l(),j.set(n,t)),t}function S(){return M(e())}function T(e,n,t){if(n===h){const{floor:n,cap:o}=e.sectionBand();return{parentId:d,slot:a,index:Math.min(Math.max(t,n),o)}}const o=n.lastIndexOf(":");return{parentId:n.slice(0,o),slot:n.slice(o+1),index:t}}function Y(e,n,t){const o=e.isPinned(n,t),l=!o&&!e.isLocked(n)&&!e.duplicateBlocked(n),r=e.permits?.(n)??{duplicate:!0,delete:!0};return{copy:!o&&r.duplicate,cut:l&&r.duplicate&&r.delete,delete:l&&r.delete}}function I(e,n,t){const o=e.canPasteAt;if(!o)return u(n.from)===t.zone?T(e,t.zone,t.index+1):null;for(const l of D(e,t)){const t=T(e,l.zone,l.index+1);if(o(n,t))return t}return null}function R(e){if(e.defaultPrevented||e.altKey||e.shiftKey)return null;if(p(e.target))return null;const n=e.target,t=n&&"ownerDocument"in n?n.ownerDocument??n:null,o=t?.getSelection?.();if(o&&!o.isCollapsed&&o.toString().trim())return null;if(!e.metaKey&&!e.ctrlKey)return"Delete"===e.key?"delete":null;const l=e.code||(1===e.key.length?`Key${e.key.toUpperCase()}`:"");return"KeyC"===l?"copy":"KeyX"===l?"cut":"KeyV"===l?"paste":null}function B(e,n,t,o){const l=e.nodeAt(t.zone,t.index);if(!l)return null;const r=l.props.id,i=e.labelOf(l.type,t.zone),c=Y(e,l,t.zone);if("copy"===n)return c.copy?(e.nodeOps.copy(r,i),{done:"copied",name:i}):null;if(o.readOnly)return null;if("cut"===n)return c.cut?(e.nodeOps.cut(r,i),{done:"cut",name:i}):null;if("delete"===n)return c.delete?(e.nodeOps.remove(r),{done:"deleted",name:i}):null;const s=o.held;if(!s)return null;const u=e.isPinned(l,t.zone)?null:I(e,s,t);return u?(e.nodeOps.paste(u),{done:"pasted",name:s.label}):(e.onPasteRefused(s),{done:"refused",name:s.label})}function E(e,n){const{zone:t,index:l}=n,i=e.nodeAt(t,l);if(!i)return[];const c=i.props.id,s=e.labelOf(i.type,t),u=Boolean(i.props._hidden),a=e.nodeOps,d=e.isPinned(i,t),p=e.isLocked(i),f=!d&&!p&&!e.duplicateBlocked(i),m=e.permits?.(i)??{duplicate:!0,delete:!0},y=Y(e,i,t),k=D(e,n),b=a.held,g=b&&!d?I(e,b,n):null,v=!e.readOnly,w=e.style?o({held:v?e.style.held():null,canCopy:e.style.canCopy(i,t),onCopy:()=>e.style?.copy(i,t),onPaste:()=>e.style?.paste(t,l,i),words:e.words?.styleClipboard}):[];return r({title:s,words:e.words?.menu,layer:{group:"pick",items:k.flatMap((n,t)=>{const o={label:e.rowNameOf(n.node,n.zone),checked:0===t,onClick:()=>e.selectAt(n.zone,n.index,n.node.props.id,n.parentType)},l=n.zone===h?null:e.slotRung?.(n.zone)??null;return l?[o,{label:l.label,checked:!1,onClick:l.select}]:[o]})},actions:{duplicate:v&&f&&m.duplicate?()=>a.duplicate(c):void 0,...L(v&&!d,e=>a.canStep(c,e),e=>a.step(c,e)),copy:y.copy?()=>a.copy(c,s):void 0,cut:v&&y.cut?()=>a.cut(c,s):void 0,paste:v&&b&&g?{label:b.label,run:()=>a.paste(g)}:void 0,rename:v&&e.renamePropOf(i,t)?()=>e.beginRename(t,l):void 0,hide:!v||p||d?void 0:{hidden:u,run:()=>a.setProps(c,{_hidden:!u})},delete:v&&f&&m.delete?()=>a.remove(c):void 0},style:w,extras:e.menuRows?.(i,t,l)??void 0,pinnedLine:d?V(e).pinned:void 0})}function L(e,n,t){return e?{moveUp:n(-1)?()=>t(-1):null,moveDown:n(1)?()=>t(1):null}:{}}var V=e=>e.words?.screen??t.menu;function X(e){const n=V(e),o=!e.readOnly,l=[];o&&e.history.hasPast&&l.push({label:n.undo,icon:/* @__PURE__ */A(w,{}),shortcut:"⌘Z",onClick:e.history.back}),o&&e.history.hasFuture&&l.push({label:n.redo,icon:/* @__PURE__ */A(x,{}),shortcut:"⇧⌘Z",onClick:e.history.forward});const r=[],c=e.nodeOps.held,s=T(e,h,e.sectionBand().cap);if(o&&c&&(e.canPasteAt?e.canPasteAt(c,s):u(c.from)===h)){const n=s,t=e.words?.menu??i;r.push({label:t.pasteNamed({paste:t.paste,label:c.label}),icon:/* @__PURE__ */A(C,{}),shortcut:"⌘V",onClick:()=>e.nodeOps.paste(n)})}const a=[l,r,[{label:e.pageSettingsLabel??t.pageSettings,icon:/* @__PURE__ */A(O,{}),onClick:e.openPageSettings},{label:n.collapseAll,icon:/* @__PURE__ */A(z,{}),onClick:e.collapseAll}]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return a.flatMap((e,n)=>n?[d,...e]:e)}function N(e,n){const t=n.selectionStart??0,o=n.selectionEnd??0,l=n.value.slice(t,o),r=e=>{n.focus(),n.setRangeText(e,t,o,"end"),n.dispatchEvent(new Event("input",{bubbles:!0}))},c=e.words?.menu??i,s=V(e),u=[];l&&(u.push({label:c.copy,icon:/* @__PURE__ */A(P,{}),shortcut:"⌘C",onClick:()=>navigator.clipboard?.writeText(l)}),u.push({label:c.cut,icon:/* @__PURE__ */A(P,{}),shortcut:"⌘X",onClick:()=>{navigator.clipboard?.writeText(l),r("")}})),u.push({label:c.paste,icon:/* @__PURE__ */A(C,{}),shortcut:"⌘V",onClick:()=>{navigator.clipboard?.readText().then(e=>{e&&r(e)}).catch(()=>e.onPasteRefused())}});const a=[u,n.value?[{label:s.selectAll,shortcut:"⌘A",onClick:()=>{n.focus(),n.select()}}]:[]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return a.flatMap((e,n)=>n?[d,...e]:e)}function F(e){return e.shiftKey}function U(e,t){const[o,l]=y(null),r=k(()=>l(null),[]);n(null!==o,r);const i=b(e);i.current=e;const c=k(e=>{const n=i.current,t=n.keys;if(!t)return;const o=R(e);if(!o)return;const l=t.selected();if(!l)return;const r=B(n,o,l,{readOnly:t.readOnly,held:t.held()});r&&(e.preventDefault(),t.onDone?.(r))},[]),s=e.keys?.target??null;g(()=>{if(!s)return;const e=e=>c(e);return s.addEventListener("keydown",e),()=>s.removeEventListener("keydown",e)},[s,c]),f(t,"keydown",c);const u=k(n=>{if(F(n))return;const t=n.target;if(t?.closest?.("[data-slot-zone]"))return n.preventDefault(),void l(null);const o=function(e){const n=e?.closest?.("input, textarea");return n&&("INPUT"!==n.tagName||["text","search","url","email","tel","number",""].includes(n.type))?n:null}(t);if(o)return n.preventDefault(),void l({kind:"input",x:n.clientX,y:n.clientY,el:o,owner:t});const r=t?.closest?.("[data-node-id]")?.getAttribute("data-node-id"),i=r?e.locate(r):null;n.preventDefault(),l(i?{kind:"node",x:n.clientX,y:n.clientY,...i,owner:t}:{kind:"empty",x:n.clientX,y:n.clientY,owner:t})},[e]);f(t,"contextmenu",n=>{if(F(n)||!t)return;const o=n.target?.closest?.("[data-puck-component]")??null,r=o?.getAttribute("data-puck-component"),i=r?e.locate(r):null;n.preventDefault();const c=m(t.frame,n.clientX,n.clientY),s=t.frame;l(i?{kind:"node",...c,...i,owner:s}:{kind:"empty",...c,owner:s})}),f(t,"mousedown",r),f(t,"scroll",r,{on:"window"});return{onEditorContextMenu:u,menu:o?/* @__PURE__ */A(W,{host:e,target:o,onClose:r}):null,closeMenu:r}}function W({host:e,target:n,onClose:t}){const o="node"===n.kind?E(e,n):"input"===n.kind?N(e,n.el):X(e);return 0===o.length?null:/* @__PURE__ */A(v,{at:{x:n.x,y:n.y},owner:n.owner??null,onClose:t,"aria-label":s(o),items:c(o)})}export{K as EASEL_NODE_CLIPBOARD,D as ancestorChain,M as nodeClipboardOf,Y as nodeClipboardRules,E as nodeMenuItems,R as nodeShortcut,X as pageMenuItems,I as pastePlace,B as runNodeShortcut,N as textMenuItems,S as useNodeClipboard,U as useNodeContextMenu};
@@ -1 +1 @@
1
- import{useMediaPanel as o,usePanelPick as r,useMediaBrowsing as n,useCloseMediaPopup as t,settlePanelPick as e}from"./chunk-LNHT2KPX.js";import{jsx as i}from"react/jsx-runtime";function c(){const c=o(),s=r(),u=n(),m=t();return c?/* @__PURE__ */i(c,{pick:s,browsing:u,onPick:o=>{s&&e(s.requestId,o)},onClose:m}):null}export{c as MediaPopup};
1
+ import{useMediaPanel as o,usePanelPick as r,useMediaBrowsing as n,useCloseMediaPopup as t,settlePanelPick as e}from"./chunk-FHCKFOCD.js";import{jsx as i}from"react/jsx-runtime";function c(){const c=o(),s=r(),u=n(),m=t();return c?/* @__PURE__ */i(c,{pick:s,browsing:u,onPick:o=>{s&&e(s.requestId,o)},onClose:m}):null}export{c as MediaPopup};
@@ -0,0 +1,65 @@
1
+ import{cloneNodeWithFreshIds as e}from"./chunk-2GVCAIPX.js";import{dedupeSlotChildren as n}from"./chunk-26OOWIJJ.js";import{styleClipboardOf as t}from"./chunk-JBOSEHIX.js";import{markedTreeNodeId as o,revealSelectedTreeRow as r,sameSelector as i}from"./chunk-FGNR22NY.js";import{scrollPreviewToSection as l,gotoPreviewSlide as s,scrollPreviewToTop as d}from"./chunk-TNGOL65V.js";import{useEaselKeyTarget as a,useEaselUndoKeys as c,useEaselSaveKey as p,editorRootFocus as u}from"./chunk-I7BROL77.js";import{SlotChildActionsProvider as h}from"./chunk-KCBEE2MC.js";import{screenStorageKeys as f,DEFAULT_PANEL_W as m,clampPanelWidth as g}from"./chunk-C56MPJBH.js";import{usePartBridge as y}from"./chunk-MEHLY5Q4.js";import{useSectionOps as v}from"./chunk-WEIE2FBC.js";import{ScreenSaveIcon as k,ScreenMainButton as b}from"./chunk-PY7OOQEZ.js";import{useBrowserOffline as S}from"./chunk-RKTF5XLP.js";import{AddChildRow as w}from"./chunk-5545A3PC.js";import{AddSidePanel as x}from"./chunk-FGJTX2DL.js";import{keepsSharedSections as z,sharedSectionsOf as C}from"./chunk-43AEUUNQ.js";import{PanelHideButton as O,SidePanelHead as I,PanelShowStrip as N}from"./chunk-SINAM2IT.js";import{offeredChoices as B}from"./chunk-M2Z775ZC.js";import{useScreenSaveSwitch as P,useScreenNodeKeys as $,useScreenPinned as M,useScreenDocumentLabel as j,useScreenCanvasFrame as A,useScreenInspectorPanel as L,useScreenDevices as T,useScreenPickFollowsSelection as E,useScreenLeftView as R,SELECTION_MODE as F,sameInspectorMode as D,useScreenBridges as H,useScreenBlockRules as V,useScreenBlockLook as W,useScreenStorageNamespace as U,useScreenNotify as J,useScreenCanvasHead as G,isSlotMode as Y,useScreenStyleClipboard as X,useScreenDocumentPass as K,useScreenCanvasDrag as Z,ScreenCanvasTargetProvider as Q,isPinnedFirst as _,isPinnedLast as q,screenSlotsOf as ee}from"./chunk-PAOZMXEI.js";import{MediaPopup as ne}from"./chunk-2G6MAXPY.js";import{useNodeClipboard as te,useNodeContextMenu as oe}from"./chunk-2BOXPUGF.js";import{PageEditGuardNotices as re}from"./chunk-UJ46J7QW.js";import{useScreenDocument as ie}from"./chunk-276MBG5P.js";import{requestMediaPick as le}from"./chunk-UNVKPVZW.js";import{useMediaPanel as se,usePanelPick as de,useMediaBrowsing as ae,useOpenMediaBrowse as ce,useMediaPlace as pe}from"./chunk-FHCKFOCD.js";import{useEaselSession as ue}from"./chunk-O7Q4DDJT.js";import{useEaselHost as he,useHostEscape as fe}from"./chunk-MQA7OFRA.js";import{LayersIcon as me,MediaIcon as ge}from"./chunk-XFYFKITX.js";import{DEFAULT_SCREEN_WORDS as ye}from"./chunk-23DYNW6S.js";import{heldStyle as ve,styleShortcut as ke}from"./chunk-V7U33NF2.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as be}from"./chunk-6WY6ZXJG.js";import{useEasel as Se,useEaselApi as we,CanvasPassThroughContext as xe,CanvasSharedContext as ze}from"./chunk-EFHV56BO.js";import{TreeRow as Ce,Subtree as Oe,LayersTree as Ie,TreeGroupLabel as Ne,TreeRowAction as Be,TreeSeam as Pe}from"./chunk-A6Z4SD3I.js";import{DEFAULT_TREE_WORDS as $e}from"./chunk-K56YDHYQ.js";import{DEFAULT_NODE_MENU_WORDS as Me}from"./chunk-WK3AFPXY.js";import{toItemSelector as je,useNodeOps as Ae,clickPick as Le}from"./chunk-BSHIQIZC.js";import{EaselTopBar as Te,EaselIconButton as Ee,TopBarCluster as Re,DeviceSwitch as Fe,InspectorIconButton as De,PanelResizeHandle as He,MAX_PANEL_W as Ve,MIN_PANEL_W_BY_SIDE as We,panelWidthVars as Ue}from"./chunk-ZG6PVMC3.js";import{DEFAULT_NOTICE_WORDS as Je,DEFAULT_CHROME_WORDS as Ge}from"./chunk-AJSDWWJW.js";import{holderOf as Ye,nameOrSomeone as Xe}from"./chunk-THWO5YVZ.js";import{DEFAULT_LOCK_WORDS as Ke}from"./chunk-RE4LP46F.js";import{useWords as Ze}from"./chunk-MFIRYGHW.js";import{insertSeams as Qe,CanvasDragLayer as _e,CanvasInsert as qe}from"./chunk-H2PRGXCW.js";import{DEFAULT_DRAG_WORDS as en}from"./chunk-KAML3KQH.js";import{createDragSession as nn,useTreeDrag as tn,gapToMoveIndex as on}from"./chunk-3S5N4HLJ.js";import{ROOT_ID as rn,ROOT_SLOT as ln,zoneKey as sn,parseZoneKey as dn,find as an,DataError as cn}from"./chunk-K7BTCBWD.js";import{useCanvasFrame as pn,LIST_SELECTOR as un,BLOCK_SELECTOR as hn,useCanvasTyping as fn,useCanvasEvent as mn,nodeIdAt as gn,frameRectToHost as yn,BLOCK_ATTRIBUTE as vn,drawnBox as kn}from"./chunk-QIDRJH3S.js";import{rootRowName as bn,slotChildRowName as Sn,slotChildRenameProp as wn,sectionRenameProp as xn}from"./chunk-BHRC3ASL.js";import{ROOT_ZONE as zn,blockNodeActions as Cn,TREE_MAX_DEPTH as On,childSlotsOf as In,slotFieldsOf as Nn,newNodeId as Bn,slotChildrenIn as Pn,nestsInTree as $n}from"./chunk-PLVEGYK6.js";import{queryMainCopy as Mn}from"./chunk-LF3FUSCQ.js";import{useRef as jn,useMemo as An,useState as Ln,useEffect as Tn,useCallback as En,useLayoutEffect as Rn,Fragment as Fn,useId as Dn}from"react";import{ColoredBadge as Hn,Button as Vn,Tabs as Wn,toast as Un,readMediaFileDrag as Jn,Tooltip as Gn,groupColors as Yn,Dialog as Xn,FormField as Kn,Input as Zn,MEDIA_FILE_DRAG_TYPE as Qn}from"efficient-shell/ui";import{UndoIcon as _n,RedoIcon as qn,RefreshIcon as et,AddIcon as nt,TrashIcon as tt,EyeOffIcon as ot,EyeIcon as rt,SharedIcon as it,DuplicateIcon as lt}from"efficient-shell/icons/efficient";import{jsx as st,jsxs as dt,Fragment as at}from"react/jsx-runtime";var ct="media-file";function pt({name:e,onMake:n,onCancel:t}){const o=Ze("screen",ye).shared,[r,i]=Ln(e),[l,s]=Ln(!1),d=Dn(),a=jn(null),c=async()=>{const e=r.trim();if(e&&!l){s(!0);try{await n(e)}finally{s(!1)}}};/* @__PURE__ */
2
+ return st(Xn,{open:!0,size:"sm",title:o.makeShared,description:o.makeSharedHint,onClose:t,initialFocus:a,footer:/* @__PURE__ */dt(at,{children:[
3
+ /* @__PURE__ */st(Vn,{variant:"secondary",onClick:t,children:o.cancel}),
4
+ /* @__PURE__ */st(Vn,{variant:"primary",loading:l,disabled:!r.trim(),onClick:()=>{c()},children:o.makeShared})]}),children:/* @__PURE__ */st("form",{onSubmit:e=>{e.preventDefault(),c()},children:/* @__PURE__ */st(Kn,{label:o.name,htmlFor:d,children:/* @__PURE__ */st(Zn,{id:d,ref:a,value:r,onChange:e=>i(e.target.value)})})})})}var ut=/* @__PURE__ */new WeakSet;function ht(e,n,t){const o=an(e,n,t);if(!o)return null;const r=o.path.find(e=>"root"!==e.parentId);return r?r.parentId:t}function ft({canvas:e,tabs:n,onSelect:t}){const o=jn(null),[r,i]=Ln({}),l=n.map(e=>`${e.id}:${e.below?1:0}`).join("|");return Rn(()=>{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),a={};for(const o of n){const n=Mn(t,`[${vn}="${r.CSS?.escape?r.CSS.escape(o.id):o.id}"]`),i=n?kn(n):null;if(!i||0===i.height){a[o.id]=null;continue}const s=yn(l,{left:i.left,top:i.top,width:i.width,height:i.height},e),c=s.top+s.height;if(c<d.top||s.top>d.top+d.height){a[o.id]=null;continue}const p=o.below?c+4:Math.max(s.top,d.top)+6;a[o.id]={left:Math.max(s.left,d.left)+6,top:p}}i(a)},a=()=>{s||(s=r.requestAnimationFrame(d))};d(),r.addEventListener("scroll",a,!0),r.addEventListener("resize",a);const c=new r.MutationObserver(a);return c.observe(t.body,{childList:!0,subtree:!0,attributes:!0}),()=>{s&&r.cancelAnimationFrame(s),r.removeEventListener("scroll",a,!0),r.removeEventListener("resize",a),c.disconnect()}},[e,l]),/* @__PURE__ */st("div",{ref:o,className:"es-band-tabs","aria-hidden":"true",children:n.map(e=>{const n=r[e.id];return n?/* @__PURE__ */st("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:e.reach?
5
+ /* @__PURE__ */st(Gn,{content:e.reach,children:/* @__PURE__ */dt(Hn,{colorClass:Yn("success","solid"),size:"sm",children:[
6
+ /* @__PURE__ */st("span",{className:"es-band-tab-mark",children:/* @__PURE__ */st(it,{size:12})}),e.label]})}):/* @__PURE__ */st(Hn,{colorClass:Yn("info","solid"),size:"sm",children:e.label})},e.id):null})})}function mt({expand:e}){/* @__PURE__ */
7
+ return st("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round",children:/* @__PURE__ */dt(at,e?{children:[
8
+ /* @__PURE__ */st("path",{d:"M8 9l4-4 4 4"}),
9
+ /* @__PURE__ */st("path",{d:"M8 15l4 4 4-4"})]}:{children:[
10
+ /* @__PURE__ */st("path",{d:"M8 4l4 4 4-4"}),
11
+ /* @__PURE__ */st("path",{d:"M8 20l4-4 4 4"}),
12
+ /* @__PURE__ */st("path",{d:"M5 12h14"})]})})}var gt=`${un}, ${hn}`;function yt(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 vt="__rungs";var kt="screen:band",bt={duplicate:!0,delete:!0},St=()=>null;function wt(){const un=he(),yn=un.panels?.Toolbar,vn=(un.panels?.useRight??St)(),{target:kn,docId:Dn,capabilities:Gn,currentSlug:Yn,siteId:Xn,onPublish:Kn,saveState:Zn,saveConflict:it,retrySave:wt,toggleAutoSave:xt,flushSave:zt,access:Ct,saveUnreachable:Ot=!1,readOnly:It,readOnlyReason:Nt=null}=ie(),Bt=P(),Pt=$(),{mediaEditing:$t,hasEditGuard:Mt,hasPinnedChrome:jt}=Gn,{appState:At,dispatch:Lt,history:Tt,selectedItem:Et,getSelectorForId:Rt,config:Ft}=Se(e=>e),Dt=M(),{first:Ht,firstGroup:Vt,lastGroup:Wt,isSectionGroup:Ut,sectionGroupZone:Jt,panelOf:Gt}=Dt,Yt=Gt(Ht),Xt=e=>_(Dt,e),Kt=e=>q(Dt,e),Zt="node"===Dt.firstRow,Qt=Dt.band??null,_t=Ze("screen",ye),qt=Ze("tree",$e),eo=Ze("drag",en),no=Ze("notice",Je),to=Ze("lock",Ke),oo=Ze("menu",Me),ro=Ze("styleClipboard",be),io=Ze("chrome",Ge),lo=j()??`/${Yn}`,so=A(),ao=L(),co=v({readOnly:It}),po=v({readOnly:It,foldIntoHistory:!0}),uo=jn(null),ho=we(),fo=An(()=>({...co,select:e=>{uo.current=e,co.select(e)},commitDocument:(e,n)=>{if(void 0!==n){const t=ho.config;uo.current=je(e,t,n)}co.commitDocument(e,n)}}),[co,ho]),mo=At.ui,go=mo.leftSideBarVisible,yo=mo.rightSideBarVisible,{options:vo,widths:ko,initial:bo,fluid:So,fit:wo}=T(),[xo,zo]=Ln(bo),Co=se(),Oo=$t&&null!==Co,Io=de(),No=ae(),Bo=null!==Io||No,Po=ce();E(Et?.props.id);const{read:$o,write:Mo,forSelection:jo}=R(),[Ao,Lo]=Ln($o);Tn(()=>{Mo(Ao)},[Ao]);const[To,Eo]=Ln(0),Ro=jn(null),Fo=jn(null),Do=pn(Fo,{readySelector:gt}),Ho=fn(Do),Vo=a(Fo);c(Fo,Do);const Wo=S(),Uo=Ye(Ct),Jo={state:Zn,offline:Wo||Zn.failed&&Ot,readOnlyReason:Nt,editing:Uo?no.editing({name:Xe(Uo.name,to),noun:_t.noun}):null,conflict:null!=it,notSaving:_t.bar.notSaving},Go=()=>{It||(Zn.failed?wt():zt())};p(Fo,Do,Go);const[Yo,Xo]=Ln(!1),Ko=jn(!1),[Zo,Qo]=Ln(null),[_o,qo]=Ln([]),[er,nr]=Ln(F),tr="puck"===er.kind,or=o(er,Et?.props.id),[rr,ir]=Ln(null);Tn(()=>{rr&&(r(),ir(null))},[rr]);const lr=jn(Rt);lr.current=Rt;const sr=En((e,{scroll:n})=>{Lo(n=>jo(e,n)),n&&ir(e);const t=[];let o=e;for(let e=0;e<4;e++){const e=lr.current(o)?.zone;if(!e||!e.includes(":"))break;const n=e.split(":")[0];t.push(n),t.push(e),o=n}0!==t.length&&Tr(e=>{if(t.every(n=>!e.has(n)))return e;const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},[]),dr=jn(null);Tn(()=>{const e=dr.current;dr.current=null;const n=null==Et?.props.id?null:String(Et.props.id);nr(t=>e&&e.id===n?e.mode:"part"===t.kind&&"nodeId"in t&&t.nodeId===n?t:Gt(Et?.type)??F);const t=Et?.props.id,o=uo.current;if(uo.current=null,!t)return;const r=Rt(t);sr(String(t),{scroll:!i(o,r??null,zn)})},[Et?.props.id,sr]);const ar=En(e=>{nr(n=>D(n,e)?n:e),Lt({type:"setUi",ui:{rightSideBarVisible:!0}})},[Lt]),cr=jn(()=>{});cr.current=(e,n)=>{const t=e?Mi(e.zone??zn)[e.index]?.props.id:null,o=null==t?null:String(t),r=null==Et?.props.id?null:String(Et.props.id);nr(e=>D(e,n)?e:n),o!==r&&(dr.current={id:o,mode:n},fo.select(e))};const pr=En((e,n)=>cr.current(e,n),[]),ur={kind:er.kind,mode:er,open:ar,show:e=>nr(e),reveal:()=>{yo||Lt({type:"setUi",ui:{rightSideBarVisible:!0}})},select:pr},hr=H(ur,{data:At.data,selected:Et??null,zoneOf:e=>Rt(e)?.zone,readOnly:Boolean(It),select:e=>{nr(F),fo.select({index:e})},replace:(e,n)=>fo.replaceComponent(zn,e,n),scrollTo:e=>l(e)},{device:xo,refreshes:To},{setView:Lo,reveal:()=>{go||Lt({type:"setUi",ui:{leftSideBarVisible:!0}})}}),fr=hr.resolveLeftView?hr.resolveLeftView(Ao):"sections",mr=V(),{isLockedBlock:gr,duplicateBlocked:yr,nestDepth:vr,newSectionNode:kr,canAddTo:br,blockIsOffered:Sr}=mr,wr=W(),{labelAtLevel:xr,Icon:zr,useProducts:Cr}=wr,Or=wr.rowName?(e,n,t)=>wr.rowName(e,n,t):void 0,Ir=En(e=>{Lt({type:"setUi",ui:{rightSideBarVisible:!0}}),l(e),sr(e,{scroll:!0})},[Lt,sr]),{selectNode:Nr,openPartId:Br}=y({mode:er,setMode:nr,onOpenPart:Ir}),[Pr,$r]=Ln(null);fe(null!==Pr,()=>$r(null));const Mr=f(U()),jr=Mr.collapsed,Ar=Mr.panelWidths,[Lr,Tr]=Ln(()=>{if("undefined"==typeof window)/* @__PURE__ */return new Set;try{const e=window.localStorage.getItem(jr);return new Set(e?JSON.parse(e):[])}catch{/* @__PURE__ */
13
+ return new Set}});Tn(()=>{try{window.localStorage.setItem(jr,JSON.stringify([...Lr]))}catch{}},[Lr]);const[Er,Rr]=Ln(()=>{if("undefined"==typeof window)return{...m};try{const e=window.localStorage.getItem(Ar);if(!e)return{...m};const n=JSON.parse(e);return{left:g(Number(n.left)||m.left,"left"),right:g(Number(n.right)||m.right,"right")}}catch{return{...m}}});Tn(()=>{const e=setTimeout(()=>{try{window.localStorage.setItem(Ar,JSON.stringify(Er))}catch{}},300);return()=>clearTimeout(e)},[Er]);const Fr=En((e,n)=>Rr(t=>{const o="function"==typeof n?n(t[e]):n;return t[e]===o?t:{...t,[e]:o}}),[]),Dr=En(e=>Fr("left",e),[Fr]),Hr=En(e=>Fr("right",e),[Fr]),Vr=e=>Lr.has(e),Wr=e=>Tr(n=>{const t=new Set(n);return t.has(e)?t.delete(e):t.add(e),t}),Ur=jn(!1),Jr=jn(null);Tn(()=>{if(Ur.current&&!Yo){const e=Jr.current,n=e&&e.isConnected&&!e.closest('[aria-hidden="true"]')?e:null;(n??Fo.current?.querySelector(`button[aria-label="${CSS.escape(_t.add.title)}"]`))?.focus(),Jr.current=null}Ur.current=Yo},[Yo]),Tn(()=>{if(!Yo||!Vo)return;const e=e=>{"Escape"===e.key&&cl()};return Vo.addEventListener("keydown",e),()=>Vo.removeEventListener("keydown",e)},[Yo,Vo]),fe(Yo,()=>cl()),Tn(()=>{!go&&Yo&&(Xo(!1),Qo(null),Ko.current=!1)},[go]);const Gr=J(),Yr=(e,n="success",t)=>{if(Gr)return void(t?Gr(e,"error"===n?"error":"info",t):Gr(e,"error"===n?"error":"info"));const o={sound:!1,action:t?.action,onClose:t?.onClose};"error"===n?Un.error(e,{...o,duration:t?.duration??3200}):Un.success(e,{...o,duration:t?.duration??1900})},Xr=jn(null),[Kr,Zr]=Ln(0),[Qr,_r]=Ln(0),qr=G(),ei=jn(null),ni=e=>Math.max(0,e.clientHeight-(ei.current?.offsetHeight??0));Tn(()=>{const e=Xr.current;if(!e)return;const n=()=>{Zr(e.clientWidth),_r(ni(e))};n();const t=new ResizeObserver(n);return t.observe(e),ei.current&&t.observe(ei.current),()=>t.disconnect()},[]),Rn(()=>{Xr.current&&(Zr(Xr.current.clientWidth),_r(ni(Xr.current)))},[Er,go,yo]);const ti=xo===So?Kr>0?Kr:ko[So]:ko[xo],oi=Kr>0?Math.min(Kr/ti,"shrink"===wo?1:2):1,ri=ti*oi,ii=Kr>0&&ri>Kr+1,li={width:ri,height:Qr||"100%",flex:"none",position:"relative"},si={width:ti,height:Qr?Qr/oi:"100%",maxHeight:"none",transform:1!==oi?`scale(${oi})`:void 0,transformOrigin:"top left"},di=()=>Lt({type:"setUi",ui:{leftSideBarVisible:!go}}),ai=()=>Lt({type:"setUi",ui:{rightSideBarVisible:!yo}}),ci=e=>{Yo&&(Xo(!1),Qo(null),Ko.current=!1,go&&Ao===e)||(Lo(e),go||Lt({type:"setUi",ui:{leftSideBarVisible:!0}}))},pi=()=>{nr(F),fo.select(null),d()},ui=()=>{nr(Yt??F),yo||Lt({type:"setUi",ui:{rightSideBarVisible:!0}})},hi=At.data.content??[],fi=()=>{const e=hi.findIndex(Xt),n=hi.findIndex(Kt);return{floor:e>=0?e+1:0,cap:n>=0?n:hi.length}},mi=Ft,gi=mr.stripCopy,yi=n=>e(n,gi),vi=te(),ki=Ae({data:At.data,config:mi,readOnly:Boolean(It),clipboard:vi,strip:gi?e=>gi(e):void 0,afterRemove:"none",stepBounds:(e,n)=>{if(e.parentId!==rn||e.slot!==ln)return{min:0,max:n-1};const{floor:t,cap:o}=fi();return{min:t,max:o-1}},commit:(e,{select:n})=>{void 0!==n&&nr(F);const t=void 0===n||"node"===n?.kind?n:null;fo.commitDocument(e,t)}}),bi=ue(),[Si,wi]=Ln(null),xi=e=>{const n=hi.find(n=>String(n.props.id)===e),t=Dt.shared;n&&t&&ki.swap(e,t.detach(n))},zi=e=>{const n=an(At.data,Ft,e);if(!n)return!1;const t=sn(n.place),o=n.node,r=t===zn?Bi(o):Wi(o),i=t===zn?Dt.shared?.usedOn(o):null;return!!ki.remove(e)&&(Yr(i?_t.shared.removed({count:Math.max(0,i.length-1)}):_t.deleted({name:r}),"success",{duration:8e3,action:{label:_t.bar.undo,onClick:()=>{ki.restore(n.node,n.place)}}}),!0)},Ci={...ki,remove:zi},Oi=e=>xr(e,"block",Ft.components[e]?.label??e),Ii=En(e=>Ft.components[e]?.defaultProps??{},[Ft]),Ni=e=>xr(e,"section",Oi(e)),Bi=e=>bn({type:e.type,props:e.props??{}},Ni(e.type),Or),{nodeAddresses:Pi,zoneItems:$i}=An(()=>{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>=On)return;const s=/* @__PURE__ */new Map;for(const{child:e,zone:t}of In(Ft,n))s.set(t,[...s.get(t)??[],e]);for(const[e,n]of s)t(n,e,i+1)})};return t(hi,zn,0),{nodeAddresses:e,zoneItems:n}},[hi,Ft]),Mi=En(e=>$i.get(e)??[],[$i]),ji=e=>{const n=Pi.get(e);return n?Mi(n.zone)[n.index]:void 0},Ai=e=>ee(mr,Ft,e),Li=e=>{if(!mr.slotsOf||e===zn)return null;const n=e.lastIndexOf(":");if(n<=0)return null;const t=ji(e.slice(0,n));if(!t)return null;const o=Ai(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}},Ti=(()=>{if(!Y(er))return null;const e=`${er.nodeId}:${er.slot}`;return Li(e)?.slot.panel===er.kind?e:null})(),Ei=jn(null);Tn(()=>{const e=Ei.current;if(Ei.current=null,!Ti||!Y(er))return;const n=er.nodeId;sr(n,{scroll:e!==Ti}),Tr(e=>{if(!e.has(n))return e;const t=new Set(e);return t.delete(n),t})},[er]);const Ri=(e,n,t)=>{const o=String(e.props.id);if(!n.panel)return void(e=>{const n=Pi.get(e);n&&(n.zone===zn?ol(n.index):Pl(n.zone,n.index,e,ji(n.zone.slice(0,n.zone.lastIndexOf(":")))?.type??""))})(o);const r={kind:n.panel,nodeId:o,slot:n.slot},i=`${o}:${n.slot}`;t&&Ti!==i&&(Ei.current=i),pr(null,r),yo||Lt({type:"setUi",ui:{rightSideBarVisible:!0}}),l(o)},Fi=(e,n,t)=>{const o=`${e}:${n}`;if(Tr(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;Ti!==o&&(Ei.current=o);pr(null,{kind:t,nodeId:e,slot:n})},Di=(e,n,t)=>{if(It||!mr.moveSlot)return;const o=ji(e),r=o?Ai(o).filter(e=>e.rung):[],i=r[n];if(!i)return;const l={parentId:e,slot:vt,index:n},s=on(l,{...l,index:Math.min(Math.max(t,0),r.length)});if(s===n)return;const d=mr.moveSlot(e,n,s);"string"==typeof d&&Fi(e,d,i.panel)},Hi=Cr(),Vi=An(()=>{const e=/* @__PURE__ */new Map;for(const n of Hi??[])e.set(n.slug,n.name);return e},[Hi]),Wi=e=>Sn(e,Oi,wr.plainText,e=>Vi.get(e),wr.rowName),Ui=(e,n)=>{const t=Ft.components[e.type]?.fields,o=n===zn||ts(n)?"section":"block",r=n===zn&&(Xt(e)||Kt(e)||Ut(e.type)),i="block"===o?wn(t):r?null:xn(t);return wr.renamePropOf?wr.renamePropOf(e,o,i):i},Ji=(e,n,t,o)=>{if(!(!It&&Pr?.zone===e&&Pr.index===n))return;const r=(t,o)=>{$r(null),o&&((e,n,t)=>{const o=Mi(e)[n];if(!o)return;const r=Ui(o,e);r&&fo.replaceComponent(e,n,{...o,props:{...o.props,[r]:t.trim()}})})(e,n,t)};/* @__PURE__ */
14
+ return st("input",{className:"es-tree-rename",defaultValue:o,autoFocus:!0,"aria-label":_t.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)},Gi=t(X(),ro),Yi=Gi.scope({target:kn,siteId:Xn,docId:Dn}),Xi=Ft,Ki=(e,n)=>n===zn?Ni(e):Oi(e),Zi=(e,n,t)=>{const o=Gi.plan(Yi,t,Ki(t.type,e),Xi);o&&(o.changed&&fo.replaceComponent(e,n,{...t,props:{...o.props,id:t.props.id}}),Yr(o.message))},Qi=oe({nodesIn:Mi,nodeAt:(e,n)=>Mi(e)[n]??null,labelOf:(e,n)=>n===zn?Ni(e):Oi(e),renamePropOf:Ui,beginRename:(e,n)=>$r({zone:e,index:n}),history:{hasPast:Tt.hasPast,hasFuture:Tt.hasFuture,back:()=>Tt.back(),forward:()=>Tt.forward()},openPageSettings:()=>{fo.select(null),nr(F)},pageSettingsLabel:_t.pageSettings,words:{menu:oo,styleClipboard:ro,screen:_t.menu},readOnly:Boolean(It),collapseAll:()=>Tr(new Set(Mi(zn).map(e=>String(e.props.id)))),onPasteRefused:e=>Yr(e?_t.pasteRefused({name:e.label}):_t.menu.clipboardRefused,"error"),canPasteAt:(e,n)=>is(e,n),menuRows:(e,n,t)=>{const o=hr.menuRows?.(e,n,t)??null,r=((e,n)=>{const t=Dt.shared;if(!t||n!==zn)return null;const o=t.usedOn(e);if(o){const n={pick:[{label:_t.shared.onPages({count:o.length}),onClick:()=>{},children:o.map(e=>({label:e.title,onClick:()=>t.openPage(e)}))}]};return It||gr(e.type,e)?n:{...n,change:[{label:_t.shared.detach,onClick:()=>xi(e.props.id)}],remove:[{label:_t.shared.removeFromPage,danger:!0,onClick:()=>{zi(e.props.id)}}]}}return It||Xt(e)||Kt(e)||Ut(e.type)?null:z(bi)?{change:[{label:_t.shared.makeShared,onClick:()=>wi({id:e.props.id,name:Bi(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=>gr(e.type,e),duplicateBlocked:e=>yr(At.data,e),permits:e=>{const n=Cn(Ft,e.type);return Dt.shared?.usedOn(e)?{...n,delete:!1}:n},nodeOps:Ci,isPinned:(e,n)=>n===zn&&(Xt(e)||Kt(e)),sectionBand:fi,locate:e=>Pi.get(e)??null,rowNameOf:(e,n)=>n===zn?Bi(e):Wi(e),selectAt:(e,n,t,o)=>{e===zn?ol(n):Pl(e,n,t,o??"")},slotRung:e=>{const n=Li(e);return n?.slot.panel?{label:n.slot.label,select:()=>Ri(n.node,n.slot,!1)}:null},style:{held:()=>ve(Yi),canCopy:e=>Gi.rows(Xi,e).some(e=>!1!==e.counted),copy:(e,n)=>Gi.copy(Yi,e,Ki(e.type,n),Xi),paste:(e,n,t)=>Zi(e,n,t)},keys:Pt?{target:Vo,selected:()=>{const e=At.ui.itemSelector;return e?{zone:e.zone??zn,index:e.index}:null},held:()=>vi.get(),readOnly:Boolean(It),onDone:({done:e,name:n})=>{"copied"===e&&Yr(_t.copied({name:n}))}}:void 0},Do),_i=jn({copy:(e,n)=>{},paste:(e,n,t)=>{},at:()=>null,readOnly:!1});Tn(()=>{_i.current={copy:(e,n)=>Gi.copy(Yi,e,Ki(e.type,n),Xi),paste:Zi,at:()=>{const e=At.ui.itemSelector;if(!e)return null;const n=e.zone??zn,t=Mi(n)[e.index];return t?{zone:n,index:e.index,node:t}:null},readOnly:Boolean(It)}});const qi=En(e=>{const n=ke(e);if(!n)return;const t=_i.current,o=t.at();o&&(e.preventDefault(),"copy"===n?t.copy(o.node,o.zone):t.readOnly||t.paste(o.zone,o.index,o.node))},[]);Tn(()=>{if(!Vo)return;const e=e=>qi(e);return Vo.addEventListener("keydown",e),()=>Vo.removeEventListener("keydown",e)},[qi,Vo]),mn(Do,"keydown",qi);const el=hi.map(e=>e.props.id).join("|");Tn(()=>{const e=Do?.document??null,n=Do?.window??null;let t=0;const o=[],r=()=>{if(!e)return void qo(e=>e.length?[]:e);const n=hi.findIndex(Kt),t=n>=0?n:hi.length,o=n=>{const t=hi[n]?.props?.id;return null==t?null:Mn(e,`[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=hi.length>0&&!Xt(hi[0])?0:1;e<=t;e++){const n=o(e),t=o(e-1),l=n?.getBoundingClientRect()??null,s=t?.getBoundingClientRect()??null;if(!l&&!s)continue;const d=yt(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})}qo(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()}},[Do,el,xo,oi,go,yo,Et?.props.id]);const nl=Do?.document??null,tl=Do?.window??null;Tn(()=>{const e=Ro.current;if(!e||!nl||!tl)return;const n=[],t=()=>{const n=Mn(nl,`[data-puck-component="${CSS.escape(e.id)}"]`);if(!n)return!1;const t=n.getBoundingClientRect().top-e.offset;return Math.abs(t)>1&&tl.scrollTo({left:tl.scrollX,top:tl.scrollY+t,behavior:"instant"}),!0};return Ro.current=null,t()&&n.push(setTimeout(t,150),setTimeout(t,450)),()=>n.forEach(clearTimeout)},[nl,tl]);const ol=e=>{nr(F),fo.select({index:e}),hr.sectionPressed?.(hi[e]);const n=hi[e]?.props?.id;n&&l(n)},rl=e=>{const{floor:n,cap:t}=fi(),o=e=>Math.min(Math.max(n,e),t);if("number"==typeof e)return o(e);const r=Et&&er.kind!==Yt?.kind?hi.findIndex(e=>e.props.id===Et.props.id):-1;return o(r>=0?r+1:t)},il=(e,n)=>{const{floor:t,cap:o}=fi(),r=Math.min(Math.max(n,t),o),i=e<r?r-1:r;return i===e?{moved:!1,dest:e}:(fo.reorderComponent(zn,e,i),fo.select({index:i}),{moved:!0,dest:i})},ll=(e,n,t,o)=>{nr(F),fo.select(o?{index:o.index,zone:o.zone}:{index:e}),l(n),Yr(_t.sectionAdded({name:t}))},sl=(e,n)=>{const t=rl(n),o=kr(e,{nodeDefaults:Ii,newNodeId:Bn,sectionLabel:Ni,blockIsOffered:Sr}),r=o?fo.insertNode(zn,t,o):fo.insertSection(e,t);return ll(t,r,Ni(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 In(Ft,e)){if(s.type===t&&(!o.at||n>o.at.depth)){const r=br(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: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},dl=e=>al(zn,e),al=(e,n)=>{Jr.current=document.activeElement??null,Qo(null===n?null:{zone:e,index:n}),Xo(!0),go||(Ko.current=!0,Lt({type:"setUi",ui:{leftSideBarVisible:!0}}))},cl=()=>{Xo(!1),Qo(null),Ko.current&&Lt({type:"setUi",ui:{leftSideBarVisible:!1}}),Ko.current=!1},pl=(e,n)=>wr.rowName?n?Xt(e)?wr.rowName(e,"section",_t.header):Kt(e)?wr.rowName(e,"section",_t.footer):Ut(e.type)?wr.rowName(e,"section",Oi(e.type)):Bi(e):Wi(e):n?Ni(e.type):Oi(e.type),ul=e=>n=>{e()},hl=(e,n,t)=>{if(It)return null;const o=Mi(e)[n];return o&&!Cn(Ft,o.type).delete||o&&gr(o.type,o)?null:/* @__PURE__ */st(Be,{kind:"delete",label:e===zn&&o&&Dt.shared?.usedOn(o)?_t.shared.removeFromPage:_t.deleteNamed({name:t}),onClick:()=>((e,n)=>{const t=Mi(e)[n]?.props?.id;null!=t&&zi(String(t))})(e,n),children:/* @__PURE__ */st(tt,{size:15})})},fl=e=>wr.rowPreview?.(e)||void 0,ml=e=>wr.rowMarks?.(e)??void 0,gl=(e,n,t)=>wr.rowActions?.(e,n,t)??null,yl=(e,n,t,o)=>{if(It)return null;if(gr(t.type,t))return null;const r=Boolean(t.props._hidden);/* @__PURE__ */
15
+ return st(Be,{kind:"eye",label:r?_t.showNamed({name:o}):_t.hideNamed({name:o}),onClick:()=>kl(e,n,t),children:/* @__PURE__ */st(r?ot:rt,{size:14,strokeWidth:1.8,strokeLinecap:void 0,strokeLinejoin:void 0})})},vl=e=>Js(zn,e),kl=(e,n,t)=>{fo.replaceComponent(e,n,{...t,props:{...t.props,_hidden:!t.props._hidden}})},bl=e=>Nn(Ft,e),Sl=e=>In(Ft,e),wl=e=>mr.slotsOf?Ai(e).map(n=>({slot:n.slot,rung:n.rung?n:null,kids:Pn(e,n.slot)})):[{slot:null,rung:null,kids:Sl(e)}],xl=e=>mr.slotsOf?wl(e).flatMap(e=>e.kids):Sl(e),zl=e=>Boolean(mr.slotsOf)&&Ai(e).some(e=>e.rung),Cl=(e,n,t)=>null===t?void 0===n?br(e):br(e,n):br(e,n,t),Ol=(e,n,t)=>{const o=$n(Ft,e.type,n)&&(t||xl(e).length>0||zl(e));return{collapsible:o,folded:o&&Vr(String(e.props.id))}},Il=(e,n,t)=>wl(e).flatMap(o=>{const r=o.rung?n+1:n,i=o.kids.flatMap(({child:e})=>Ol(e,r,t(e.type)).collapsible?[String(e.props.id),...Il(e,r+1,t)]:[]);return o.rung?[`${e.props.id}:${o.rung.slot}`,...i]:i}),Nl=e=>xl(e).length>0||zl(e)||Boolean(br(e.type)),Bl=e=>Boolean(br(e)),Pl=(e,n,t,o)=>{if(nr(F),br(o)?.spec?.slider){const t=e.split(":")[0];s(t,n),fo.select({index:n,zone:e}),l(t)}else fo.select({index:n,zone:e}),l(t)},$l=(e,n,t,o,r)=>{const i=`${e}:${n}`;fo.insertComponent(i,t,o),br(r)?.spec?.slider?requestAnimationFrame(()=>{s(e,o),fo.select({index:o,zone:i})}):fo.select({index:o,zone:i})},Ml=jn(/* @__PURE__ */new Set);Tn(()=>{hi.forEach(e=>{const n=br(e.type)?.spec;if(!n)return;const t=e.props.id;if(Ml.current.has(t))return;Ml.current.add(t);if((Array.isArray(e.props[n.slot])?e.props[n.slot]:[]).length>0)return;if(n.skipSeed?.(e.props))return;const o=`${t}:${n.slot}`,r=n.legacy?.(e.props)??[];(r.length?r:n.seeds(Ii)).forEach((e,t)=>po.seedChild(o,t,n.childType,e))})},[hi,po,Ii]);const jl=jn(/* @__PURE__ */new Set);Tn(()=>{hi.forEach((e,t)=>{const o=e.props.id;if(jl.current.has(o))return;const r=n(e,bl(e.type));jl.current.add(o),r&&po.replaceComponent(zn,t,{...e,props:r})})},[hi,po]),K(po,Ft);const Al=hi.findIndex(Kt),Ll=Al>=0?hi[Al]:null,Tl=Zt?hi.findIndex(Xt):-1,El=Tl>=0?hi[Tl]:null,Rl=Dt.groupTab,Fl=An(()=>Rl?e=>Ut(e.type):void 0,[Rl]),Dl=Boolean(Dt.groupBadge),Hl=Dt.sharedReach,Vl=e=>Hl?.(e)??void 0,Wl=An(()=>Hl?new Set(hi.filter(e=>Vl(e)).map(e=>String(e.props.id))):null,[hi,Hl]),Ul=An(()=>Wl?e=>Wl.has(e):void 0,[Wl]),Jl=Dt.first?Hl?.({type:Dt.first,props:{id:""}})??void 0:void 0,Gl=Dt.groupBadge?/* @__PURE__ */st("span",{className:"es-tree-group-badge",children:/* @__PURE__ */st(Hn,{tone:"info",size:"xs",children:Dt.groupBadge})}):void 0,Yl=hi.find(e=>e.type===Vt)??null,Xl=hi.find(e=>e.type===Wt)??null,Kl=Al>=0?Al:hi.length,Zl=[];hi.forEach(e=>{Kt(e)||(Nl(e)&&Zl.push(String(e.props.id)),Zl.push(...Il(e,1,Bl)))}),Ll&&(Zl.push(String(Ll.props.id)),Zl.push(...Il(Ll,1,Bl)));const Ql=Zl.length>0&&Zl.every(e=>Lr.has(e)),_l=e=>{const n=wr.blockRowName(e,Oi);return wr.rowName?wr.rowName(e,"block",n):n},ql=(e,n,t,o)=>{const r=Mi(e)[t];if(!r)return;const i={...dn(e),index:t},l={...dn(n),index:Math.min(Math.max(o,0),Mi(n).length)},s=on(i,l);if(e!==n||s!==t)try{ki.move(String(r.props.id),{...l,index:s})}catch(e){if(!(e instanceof cn))throw e}},es=e=>{const n=/* @__PURE__ */new Set,t=e=>{for(const{child:o,zone:r}of Sl(e))n.add(r),t(o)};for(const t of bl(e.type))n.add(`${e.props.id}:${t}`);return t(e),n},ns=e=>{let n=e.slice(0,e.indexOf(":"));for(let e=0;e<64;e++){const e=Pi.get(n);if(!e)return null;if(e.zone===zn)return n;n=e.zone.slice(0,e.zone.indexOf(":"))}return null},ts=e=>{const n=e.slice(0,e.indexOf(":")),t=hi.find(e=>Ut(e.type)&&String(e.props.id)===n);return t&&Jt(n)===e?t:null},os=(e,n)=>{const t=ts(e);return!t||(!Dt.groupAccepts||Dt.groupAccepts(t.type,n,Mi(e).length))},rs=(e,n,t)=>{if(e.rung){const t=ji(e.rung.nodeId),o=t?Ai(t).filter(e=>e.rung).length:0;return n.parentId===e.rung.nodeId&&n.slot===vt&&n.index>=0&&n.index<=o}if(n.slot===vt)return!1;if(e.add)return ds(e.add,n);const o=sn(n);if(Ut(e.type))return!1;const r=ts(o),i=ts(e.zone);if(r||i)return!(!r||!i)&&(!(r!==i&&!os(o,e.type))&&(n.index>=0&&n.index<=Mi(o).length));if(e.zone===zn||o===zn){if(e.zone!==o)return!1;const{floor:t,cap:r}=fi();return n.index>=t&&n.index<=r}if(n.index<0||n.index>Mi(o).length)return!1;if(e.zone===o)return!0;const l=Ll&&!Dt.lastIsOpen?String(Ll.props.id):null;return(!l||ns(e.zone)!==l&&ns(o)!==l)&&((e,n,t,o)=>{if(e===n)return!0;const r=o??Mi(e)[t];if(!r)return!1;const i=n.split(":")[0],l=Pi.get(i),s=l?Mi(l.zone)[l.index]:void 0;if(!s)return!1;if(!o&&es(r).has(n))return!1;const d=br(s.type,vr(At?.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?.(Mi(n),r))})(e.zone,o,e.index,t)},is=(e,n)=>{const t=sn(e.from),o=e.node;return t===sn(n)?os(t,o.type):rs({id:String(o.props?.id??""),zone:t,index:-1,type:o.type},n,o)},ls=e=>{const n=e.slice(0,e.indexOf(":")),t=Pi.get(n),o=t?Mi(t.zone)[t.index]:void 0;if(!t||!o)return null;const r=br(o.type,vr(At?.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=B(r.choices??(r.spec?[{type:r.spec.childType,label:Oi(r.spec.childType)}]:[])),l=Li(e);return{parent:o,parentId:n,target:r,choices:i,parentName:l?l.slot.label:pl(o,t.zone===zn)}},ss=(e,n)=>{if("section"!==e.kind)return e;const t=sn(n);return t===zn||ts(t)?e:ls(t)?.choices.some(n=>n.type===e.type)?{kind:"block",type:e.type}:e},ds=(e,n)=>{const t=ss(e,n),o=sn(n);if("shared"===t.kind){if(o!==zn||!Dt.shared?.nodeOf(t.section))return!1;const{floor:e,cap:r}=fi();return n.index>=e&&n.index<=r}if("block"!==t.kind){if(ts(o)){const e="section"===t.kind?t.type:t.template.node.type;return os(o,e)&&n.index>=0&&n.index<=Mi(o).length}if(o!==zn)return!1;const{floor:e,cap:r}=fi();return n.index>=e&&n.index<=r}if(o===zn)return!1;const r=ls(o);return!(!r||!r.choices.some(e=>e.type===t.type))&&!r.target.spec?.addBlocked?.(Mi(o))},as=(e,n)=>{const t=ss(e,n);if("block"!==t.kind&&ts(sn(n)))return void((e,n,t)=>{const o="section"===e.kind?e.type:"template"===e.kind?e.template.node.type:null;if(o&&os(n,o)){if("section"===e.kind)fo.insertComponent(n,e.type,t);else{if("template"!==e.kind)return;fo.insertNode(n,t,yi(e.template.node))}nr(F),fo.select({index:t,zone:n})}})(t,sn(n),n.index);if("section"===t.kind)return void sl(t.type,n.index);if("template"===t.kind)return void((e,n,t)=>{const o=rl(t),r=fo.insertNode(zn,o,n);ll(o,r,e)})(t.template.name,yi(t.template.node),n.index);if("shared"===t.kind){const e=Dt.shared?.nodeOf(t.section);if(!e)return;const o=rl(n.index);return void(ki.restore(e,{parentId:rn,slot:ln,index:o})&&ll(o,e.props.id,t.section.title))}const o=sn(n),r=ls(o);r&&(r.target.spec?$l(r.parentId,r.target.slot,t.type,n.index,r.parent.type):((e,n,t)=>{fo.insertComponent(e,n,t),nr(F),fo.select({index:t,zone:e})})(o,t.type,n.index))},cs=(e,n)=>{e.media?function(e){const n=Ds();if(!n||!Es)return;Vs(n).then(n=>{n&&function(e,n){if(!Es)return;const t=Es.create(e,{nodeDefaults:Ii,newNodeId:Bn,sectionLabel:Ni,blockIsOffered:Sr}),o=sn(n);if(o===zn){const e=rl(n.index),o=fo.insertNode(zn,e,t);return void ll(e,o,Ni(t.type))}fo.insertNode(o,n.index,t),nr(F),fo.select({index:n.index,zone:o})}(n,e)})}(n):e.rung?Di(e.rung.nodeId,e.index,n.index):e.add?as(e.add,n):e.zone===zn?il(e.index,n.index):ql(e.zone,sn(n),e.index,n.index)},[ps]=Ln(()=>nn()),us=tn({keyOf:e=>e.id,readOnly:Boolean(It),session:ps,canDrop:rs,onDrop:cs,onStep:(e,n)=>{e.rung?Di(e.rung.nodeId,e.index,n<0?e.index-1:e.index+2):e.zone===zn?((e,n)=>{const t=Ni(hi[e]?.type??""),o=il(e,n<0?e-1:e+2);if(!o.moved)return void Yr(n<0?_t.sectionFirst({name:t}):_t.sectionLast({name:t}));const{floor:r,cap:i}=fi();Yr(_t.sectionMoved({name:t,n:o.dest-r+1,total:i-r}))})(e.index,n):ql(e.zone,e.zone,e.index,n<0?e.index-1:e.index+2)}}),hs=En(e=>{const{floor:n,cap:t}=fi(),o=[];for(const r of e.nodes){const e=sn(r.place),i=Mi(e)[r.place.index];if(!i||String(i.props.id)!==r.id)continue;if(Xt(i)||Kt(i)||gr(i.type,i))continue;if(Ut(i.type))continue;const l=Boolean(ts(e)),s=e===zn||l;e===zn&&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?Ni(i.type):Wi(i),from:r.place})}const r=e.zones.flatMap(e=>{const n=sn(e.list);if(n===zn&&0===e.children.length)return[{...e,addLabel:_t.addSection,addAlways:!0}];const t=ls(n),o=t?.target.spec?.addLabel;return e.children.length>0||Boolean(t?.choices.length)||Boolean(ts(n))?[o?{...e,addLabel:o}:e]:[]}),i=r.flatMap(e=>{const n=sn(e.list),t=n===zn||ts(n)?null:ls(n);return t?.choices.length?Qe(e,t.target.spec?.addLabel??_t.addBlockHere):[]});return{sources:o,zones:r,seams:i}},[At.data]),fs=null==Et?.props.id?null:String(Et.props.id),ms=En(e=>{const n=Ft,t=e=>!e.item.rung&&null!==an(At.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(fs);return i||(r(Le(At.data,n,o.item.id,fs,Fl))??o)},[At.data,Ft,fs,Fl]),[gs,ys]=Ln(null),vs=Boolean(Rl||Hl);mn(Do,"mouseover",e=>{if(!vs)return;const n=gn(e.target),t=n?ht(At.data,Ft,n):null;t!==gs&&ys(t)}),mn(Do,"mouseout",e=>{vs&&!e.relatedTarget&&ys(null)});const ks=e=>Xt(e)||Kt(e)||Ut(e.type),bs=e=>{const n=Ut(e.type)?Oi(e.type):Xt(e)?_t.header:Kt(e)?_t.footer:null;return null===n?Bi(e):wr.rowName?wr.rowName(e,"section",n):n},Ss=[];if(vs){const e=fs?ht(At.data,Ft,fs):null;for(const n of/* @__PURE__ */new Set([e,gs])){const e=n?hi.find(e=>String(e.props.id)===n):void 0;if(!e)continue;const t=Xt(e)||e.type===Vt,o=Vl(e);if(o){Ss.push({id:String(e.props.id),label:bs(e),below:t,reach:o});continue}if(!Rl||!ks(e))continue;const r=Rl(e);r&&Ss.push({id:String(e.props.id),label:r,below:t})}}const ws=ue(),xs=jn(null);Tn(()=>{const e=Dt.changeNotice;if(!e)return;const n=JSON.stringify(hi.filter(ks)),t=xs.current;if(xs.current={doc:Dn,bands:n,index:Tt.index},!t||t.doc!==Dn||t.bands===n)return;Tt.hasPast&&Tt.index>=t.index&&!ut.has(ws)&&(ut.add(ws),Yr(e,"success",{action:{label:_t.bar.undo,onClick:()=>Tt.back()},duration:8e3}))},[hi]);const zs=e=>{nr(F),fo.select(e.zone===zn?{index:e.index}:{index:e.index,zone:e.zone})},Cs=Z(),Os=()=>({data:At.data,device:xo,ops:fo,inspector:ur}),Is=Cs?.model,Ns=An(()=>Is?e=>Is(e,hs(e),Os()):hs,[Is,hs,xo]),Bs=Cs?.measure,Ps=Bs?(e,n)=>Bs(e,n,Os()):void 0,$s=Cs?.canDrop,Ms=$s?(e,n)=>$s(e,n,rs,Os()):rs,js=Cs?.drop,As=js?(e,n)=>js(e,n,cs,Os()):cs,Ls=Cs?.pick,Ts=Ls?e=>Ls(e,zs,Os()):zs,Es=Cs?.media??null,Rs=jn(null),Fs=An(()=>Es?{id:ct,zone:"",index:-1,type:Es.adds.type,add:{kind:Es.adds.kind,type:Es.adds.type},media:!0}:null,[Es]);Tn(()=>{if(!Fs||It||"undefined"==typeof document)return;const e=e=>{(e=>Array.from(e.dataTransfer?.types??[]).includes(Qn))(e)&&(Rs.current=null,ps.start({key:ct,item:Fs}))},n=e=>{ps.get()?.item.media&&(Rs.current=Jn(e.dataTransfer))},t=()=>{ps.get()?.item.media&&ps.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)}},[Fs,It,ps]);const Ds=()=>{const e=Rs.current;return Rs.current=null,e},Hs=pe(),Vs=async e=>{if(!Hs)return e;const n=await Hs(e);return n?{...e,id:n.id,url:n.url}:null};const Ws=(e,n)=>{if(!Es)return;const t=an(ho.getState().appState.data,mi,n);if(!t)return;const o=t.node;fo.replaceComponent(sn(t.place),t.place.index,{...o,props:{...Es.replace(o,e),id:o.props.id}})},Us=e=>{const n=sn(e),t=Li(n);t&&Ri(t.node,t.slot,!1),al(n,e.index)},Js=(e,n)=>/* @__PURE__ */st(Pe,{...It?{}:us.seam({place:{...dn(e),index:n}})},`seam:${e}:${n}`),Gs={rowClick:ul,isCollapsed:Vr,toggleCollapse:Wr},Ys=e=>{const n=String(e.props.id),t=hi.findIndex(e=>String(e.props.id)===n),o=Jt(n),r=Mi(o),i=Vr(n),l=Oi(e.type),s=wr.rowName?wr.rowName(e,"section",l):l,d=e=>Js(o,e);/* @__PURE__ */
16
+ return dt(at,{children:[
17
+ /* @__PURE__ */st(Ce,{words:qt,icon:/* @__PURE__ */st(zr,{type:e.type,size:13}),name:s,preview:fl(e),marks:ml(e),onSelect:()=>ol(t),nameSlot:Ji(zn,t,n,s),selected:or===n,badge:Vl(e)?void 0:Gl,shared:Vl(e),actions:gl(e,zn,t)??void 0,rowProps:{"data-node-id":n,onClick:ul(()=>ol(t))},fold:{open:!i,label:"section",onToggle:()=>Wr(n)}}),!i&&/* @__PURE__ */dt(Oe,{children:[r.map((n,t)=>{const r=String(n.props.id),i=Bi(n),l=Nl(n),s=l&&Vr(r),a=()=>Pl(o,t,r,e.type),{rowProps:c,...p}=us.row({item:{id:r,zone:o,index:t,type:n.type},place:{...dn(o),index:t}},{"data-node-id":r,onClick:ul(a)});/* @__PURE__ */
18
+ return dt(Fn,{children:[d(t),
19
+ /* @__PURE__ */st(Ce,{words:qt,icon:/* @__PURE__ */st(zr,{type:n.type,size:13}),name:i,preview:fl(n),marks:ml(n),onSelect:a,nameSlot:Ji(o,t,r,i),selected:or===r,hidden:Boolean(n.props._hidden),...p,fold:l?{open:!s,label:"section",onToggle:()=>Wr(r)}:void 0,actions:/* @__PURE__ */dt(at,{children:[hl(o,t,i),gl(n,o,t),yl(o,t,n,i)]}),rowProps:c}),l&&!s&&/* @__PURE__ */st(Oe,{children:Zs(n,2)})]},r)}),d(r.length)]})]})},Xs=(e,n,t,o,r)=>{const i=String(e.props.id),l=`${i}:${n.slot}`,s=us.dragging,d=!Vr(l)&&s?.rung?.nodeId!==i,a={...dn(l),index:0},c=s&&!s.rung&&rs(s,a)?a:void 0,p=()=>Ri(e,n,!0),{rowProps:u,...h}=us.row({item:{id:`rung:${l}`,zone:`${i}:${vt}`,index:t,type:e.type,rung:{nodeId:i,slot:n.slot}},place:{parentId:i,slot:vt,index:t},into:c,canDrag:Boolean(mr.moveSlot)&&!1!==n.movable&&o>1},{"data-slot-zone":l,onClick:ul(p)}),f=It?null:mr.slotActions?.(e,n.slot);/* @__PURE__ */
20
+ return dt(Fn,{children:[n.heading,
21
+ /* @__PURE__ */st(Ce,{words:qt,icon:n.glyph??null,name:n.label,badge:n.badge,onSelect:p,selected:Ti===l,...h,dragHint:n.dragHint,fold:{open:d,label:n.label,onToggle:()=>Wr(l)},actions:f&&f.length>0?/* @__PURE__ */st(at,{children:f.map((t,o)=>/* @__PURE__ */st(Be,{kind:"delete"===t.kind?"delete":"plain",label:t.label,disabled:t.disabled,onClick:()=>((e,n,t)=>{if(It||t.disabled)return;const o=String(e.props.id),r=e=>{"string"==typeof e&&Fi(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__ */st(tt,{size:15}):/* @__PURE__ */st(lt,{size:15})},`${o}:${t.kind}`))}):void 0,rowProps:u}),d&&/* @__PURE__ */st(Oe,{children:r})]},l)},Ks=(e,n)=>{const t=wl(e),o=t.filter(e=>e.rung).length;let r=0;/* @__PURE__ */
22
+ return st(at,{children:t.map(t=>{const i=t.kids,l=t.rung?n+1:n,s=Cl(e.type,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)=>Js(e,n),p=/* @__PURE__ */dt(at,{children:[i.map(({child:n,zone:t,index:o})=>{const r=or===String(n.props.id),{collapsible:i,folded:s}=Ol(n,l,Bl(n.type)),d=String(n.props.id),a=_l(n),p=()=>Pl(t,o,d,e.type),{rowProps:u,...h}=us.row({item:{id:d,zone:t,index:o,type:n.type},place:{...dn(t),index:o}},{"data-node-id":d,onClick:ul(p)});/* @__PURE__ */
23
+ return dt(Fn,{children:[0===o&&c(t,0),
24
+ /* @__PURE__ */st(Ce,{words:qt,icon:/* @__PURE__ */st(zr,{type:n.type,size:13}),name:a,preview:fl(n),marks:ml(n),onSelect:p,nameSlot:Ji(t,o,d,a),selected:r,hidden:Boolean(n.props._hidden),...h,fold:i?{open:!s,label:"group",onToggle:()=>Wr(d)}:void 0,actions:/* @__PURE__ */dt(at,{children:[hl(t,o,a),gl(n,t,o),yl(t,o,n,a)]}),rowProps:u}),i&&!s&&/* @__PURE__ */st(Oe,{children:Ks(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?Xs(e,t.rung,r++,o,p):/* @__PURE__ */st(Fn,{children:p},t.slot??"")})})},Zs=(e,n)=>{const t=vr(At?.data,e.type,String(e.props.id)),o=wl(e),r=o.filter(e=>e.rung).length;let i=0;/* @__PURE__ */
25
+ return st(at,{children:o.map(o=>{const l=o.kids,s=o.rung?n+1:n,d=Cl(e.type,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),h=a&&!a.fixed?`${u}:${a.slot}`:null,f=p?`${u}:${p.slot}`:null,m=(e,n)=>Js(e,n),g=null===o.slot?null:`${u}:${o.slot}`,y=Boolean(a&&!a.fixed&&(null===g||g===h)),v=/* @__PURE__ */dt(at,{children:[l.map(({child:n,zone:t,index:o})=>{const r=or===String(n.props.id),i=Wi(n),l=String(n.props.id),{collapsible:d,folded:a}=Ol(n,s,Bl(n.type)),c=bl(n.type),p=1===c.length?`${l}:${c[0]}`:null,u=p?{...dn(p),index:Mi(p).length}:void 0,h=us.dragging,f=u&&h&&rs(h,u)?u:void 0,g=()=>Pl(t,o,l,e.type),{rowProps:y,...v}=us.row({item:{id:l,zone:t,index:o,type:n.type},place:{...dn(t),index:o},into:f,canDrag:!gr(n.type,n)},{"data-node-id":l,onClick:ul(g)});/* @__PURE__ */
26
+ return dt(Fn,{children:[0===o&&m(t,0),
27
+ /* @__PURE__ */st(Ce,{words:qt,icon:/* @__PURE__ */st(zr,{type:n.type,size:13}),name:i,preview:fl(n),marks:ml(n),onSelect:g,nameSlot:Ji(t,o,l,i),selected:r,hidden:Boolean(n.props._hidden),...v,fold:d?{open:!a,label:"group",onToggle:()=>Wr(l)}:void 0,actions:gr(n.type,n)?gl(n,t,o)??void 0:/* @__PURE__ */dt(at,{children:[hl(t,o,i),gl(n,t,o),yl(t,o,n,i)]}),rowProps:y}),d&&!a&&/* @__PURE__ */st(Oe,{children:Zs(n,s+1)}),m(t,o+1)]},String(n.props.id??`${t}-${o}`))}),y&&a&&
28
+ /* @__PURE__ */st(w,{small:!0,label:a.addLabel,blocked:a.addBlocked?.(c)??null,onAdd:()=>$l(e.props.id,a.slot,a.childType,c.length,e.type)}),null===g?f&&!l.some(e=>e.zone===f)?m(f,0):null:0!==l.length||(o.rung?y:g!==f)?null:m(g,0)]});return o.rung?Xs(e,o.rung,i++,r,v):/* @__PURE__ */st(Fn,{children:v},o.slot??"")})})},Qs=Yo,_s=e=>"panel"in e?{id:e.id,label:e.label,icon:e.icon,active:go&&!Qs&&fr===e.id,onSelect:()=>ci(e.id)}:e,qs=[...(hr.railLead??[]).map(_s),{id:"sections",label:_t.layers,icon:/* @__PURE__ */st(me,{}),active:go&&!Qs&&"sections"===fr,onSelect:()=>ci("sections")},...(hr.railTrail??[]).map(_s)],ed=Oo?{pressed:Bo,onPress:Po}:$t?{pressed:!1,onPress:()=>{le(un,{accept:"image/*",title:io.mediaLibrary})}}:null,nd={value:qs.find(e=>!0===e.active)?.id??"",press:e=>{const n=qs.find(n=>n.id===e);n&&!n.disabled&&!0!==n.active&&n.onSelect?.()},items:qs.map(e=>({id:e.id,icon:e.icon,label:/* @__PURE__ */st("span",{className:"sr-only",children:e.label}),tooltip:e.label,disabled:e.disabled}))},td=[...hr.railLead??[],...hr.railTrail??[]].find(e=>"panel"in e&&e.id===fr),od=Boolean(Qt?.foldable),rd=Qt?.label??(Mt?_t.pageSections:_t.templateSections),id=od&&Vr(kt),ld=/* @__PURE__ */dt(at,{children:[hi.map((e,n)=>{if(Xt(e)||Kt(e)||Ut(e.type))return null;const t=or===String(e.props.id),o=Boolean(e.props._hidden);Sl(e);const r=String(e.props.id),i=hr.hasOwnRows?.(e)??!1,l=Nl(e)||i,s=l&&Vr(r),d=bl(e.type),a=1===d.length?`${r}:${d[0]}`:null,c=a?{...dn(a),index:Mi(a).length}:void 0,p=us.dragging,u=c&&p&&rs(p,c)?c:void 0,{rowProps:h,...f}=us.row({item:{id:r,zone:zn,index:n,type:e.type},place:{...dn(zn),index:n},into:u,canDrag:!gr(e.type,e)},{"data-node-id":r,onClick:ul(()=>ol(n))});/* @__PURE__ */
29
+ return dt(Fn,{children:[n>0&&vl(n),
30
+ /* @__PURE__ */st(Ce,{words:qt,icon:/* @__PURE__ */st(zr,{type:e.type,size:13}),name:Bi(e),preview:fl(e),marks:ml(e),shared:Vl(e),onSelect:()=>ol(n),nameSlot:Ji(zn,n,r,Bi(e)),selected:t,hidden:o,...f,fold:l?{open:!s,label:"section",onToggle:()=>Wr(r)}:void 0,actions:/* @__PURE__ */dt(at,{children:[hl(zn,n,Bi(e)),gl(e,zn,n),yl(zn,n,e,Bi(e))]}),rowProps:h}),Nl(e)&&!s&&/* @__PURE__ */dt(Oe,{children:[Zs(e,1),hr.partRows?.(e,Gs)]}),i&&!s&&/* @__PURE__ */st(Oe,{children:hr.ownRows?.(e,n,Gs)})]},String(e.props.id??n))}),Kl>0&&vl(Kl)]}),sd=(e,n,t)=>{const o=String(e.props.id),r=xl(e).length>0||zl(e)||Boolean(br(e.type)),i=r&&Vr(o),l="header"===t?_t.header:_t.footer,s=wr.rowName?wr.rowName(e,"section",l):l;/* @__PURE__ */
31
+ return dt(at,{children:[
32
+ /* @__PURE__ */st(Ce,{words:qt,icon:/* @__PURE__ */st(zr,{type:t,size:13}),name:s,preview:fl(e),marks:ml(e),badge:Vl(e)?void 0:Gl,shared:Vl(e),onSelect:()=>ol(n),nameSlot:Ji(zn,n,o,s),selected:or===String(e.props.id),fold:r?{open:!i,label:"section",onToggle:()=>Wr(o)}:void 0,actions:gl(e,zn,n)??void 0,rowProps:{"data-node-id":o,onClick:ul(()=>ol(n))}}),r&&!i&&/* @__PURE__ */st(Oe,{children:Ks(e,1)})]})};return(hr.wrap??(e=>e))(
33
+ /* @__PURE__ */st(Q,{target:Do,children:/* @__PURE__ */dt("div",{ref:Fo,className:"sf-editor es-editor",style:Ue(Er),onContextMenu:Qi.onEditorContextMenu,...u(un),children:[
34
+ /* @__PURE__ */dt(Te,{children:[
35
+ /* @__PURE__ */dt("div",{className:"es-cluster es-cluster--left",children:[ed?/* @__PURE__ */st(Vn,{variant:ed.pressed?"primary":"secondary",className:"es-barbtn","aria-pressed":ed.pressed,leftIcon:/* @__PURE__ */st(ge,{}),onClick:ed.onPress,children:_t.railMedia}):null,
36
+ /* @__PURE__ */st(Ee,{label:_t.bar.undo,disabled:Boolean(It)||!Tt.hasPast,onClick:()=>Tt.back(),children:/* @__PURE__ */st(_n,{})}),
37
+ /* @__PURE__ */st(Ee,{label:_t.bar.redo,disabled:Boolean(It)||!Tt.hasFuture,onClick:()=>Tt.forward(),children:/* @__PURE__ */st(qn,{})})]}),
38
+ /* @__PURE__ */dt(Re,{children:[
39
+ /* @__PURE__ */st(Fe,{devices:vo,value:xo,onChange:zo}),
40
+ /* @__PURE__ */st(Ee,{label:_t.bar.refresh,tip:_t.bar.refreshTip,onClick:()=>{Ro.current=(()=>{const e=Do?.document;if(!e)return null;const n=hi.findIndex(Kt),t=n>=0?n:hi.length;let o=null;for(let n=0;n<t;n++){const t=hi[n]?.props?.id;if(null==t)continue;const r=Mn(e,`[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=Et?.props?.id??hi[0]?.props?.id;null!=e&&(o={id:String(e),offset:0})}return o})(),Eo(e=>e+1)},children:/* @__PURE__ */st(et,{})}),hr.barView?.()]}),
41
+ /* @__PURE__ */dt(Re,{kind:"right",style:{minWidth:300},children:[
42
+ /* @__PURE__ */st(k,{input:Jo,words:_t.saveStatus}),yn?/* @__PURE__ */st(yn,{}):null,hr.barLead?.(),hr.barTrail?.(),hr.mainAction||!hr.barMain?/* @__PURE__ */st(b,{input:Jo,action:hr.mainAction??{label:_t.done,onPress:()=>{Kn(At.data)}},readOnly:Boolean(It),saveSwitch:Bt,onToggleAutoSave:xt,onSaveNow:Go,bar:_t.bar,words:_t.saveStatus}):hr.barMain()]})]}),
43
+ /* @__PURE__ */st(re,{}),
44
+ /* @__PURE__ */dt("div",{className:"sf-body",children:[go?/* @__PURE__ */dt(at,{children:[
45
+ /* @__PURE__ */dt("aside",{className:"es-sidepanel es-sidepanel--left sf-panel sf-panel--left","aria-label":_t.leftPanel,children:[
46
+ /* @__PURE__ */dt("div",{className:"es-paneltabs es-paneltabs--with-hide",children:[
47
+ /* @__PURE__ */st(O,{side:"left",onHide:di}),
48
+ /* @__PURE__ */st("span",{className:"es-paneltabs-divider","aria-hidden":"true"}),
49
+ /* @__PURE__ */st(Wn,{variant:"underline",block:!0,"aria-label":_t.bar.views,value:nd.value,onChange:nd.press,items:nd.items})]}),Yo?/* @__PURE__ */st(x,{at:Zo?{label:(e=>{const n=ts(e.zone);if(n)return _t.add.addingTo({name:wr.rowName?pl(n,!0):Oi(n.type)});if(e.zone===zn){const n=hi[e.index];return n&&!Kt(n)?_t.add.addingBefore({name:pl(n,!0)}):_t.add.addingAtEnd}const t=ls(e.zone);return t?_t.add.addingTo({name:t.parentName}):_t.add.addingHere})(Zo),onClear:()=>Qo(null)}:void 0,placeBlocks:Zo&&Zo.zone!==zn?ls(Zo.zone)?.choices:void 0,canTake:Zo?e=>{if(!Zo)return null;const n={...dn(Zo.zone),index:Zo.index};if(ds(e,n))return null;if("shared"===e.kind&&Zo.zone===zn&&!Dt.shared?.nodeOf(e.section))return _t.shared.alreadyHere;const t=ts(Zo.zone);if(t)return _t.add.notInside({name:pl(t,!0)});if(Zo.zone===zn)return _t.add.onlySections;const o=ls(Zo.zone);return o?_t.add.notInside({name:o.parentName}):_t.add.onlySections}:void 0,onPick:Zo?e=>{if(!Zo)return;const n={...dn(Zo.zone),index:Zo.index};ds(e,n)&&(as(e,n),cl())}:void 0,itemFor:e=>({id:`new:${e.kind}:${"template"===e.kind?e.template.id:"shared"===e.kind?e.section.id:e.type}`,zone:"",index:-1,type:"template"===e.kind?e.template.node.type:"shared"===e.kind?e.section.node.type:e.type,add:e}),session:ps,siteWide:hr.addPanelRow?.(cl),onClose:cl,readOnly:Boolean(It)}):td?td.panel({onHide:di,notify:Yr}):/* @__PURE__ */dt(at,{children:[
50
+ /* @__PURE__ */st(I,{icon:/* @__PURE__ */st(me,{}),title:_t.layers,context:lo,actions:/* @__PURE__ */dt(at,{children:[!It&&/* @__PURE__ */st(De,{label:_t.add.title,onClick:()=>dl(null),children:/* @__PURE__ */st(nt,{size:15})}),
51
+ /* @__PURE__ */st(De,{label:Ql?_t.expandAll:_t.collapseAll,title:0===Zl.length?_t.nothingToFold:void 0,disabled:0===Zl.length,onClick:()=>Tr(e=>{const n=new Set(Zl);return Ql?new Set([...e].filter(e=>!n.has(e))):/* @__PURE__ */new Set([...e,...Zl])}),children:/* @__PURE__ */st(mt,{expand:Ql})})]})}),
52
+ /* @__PURE__ */dt(Ie,{className:"sf-tree sf-scroll",words:qt,children:[
53
+ /* @__PURE__ */st(Ce,{words:qt,icon:/* @__PURE__ */st(zr,{type:"page",size:13}),name:_t.pageSettings,onSelect:pi,selected:!Et&&tr,rowProps:{onClick:ul(pi)}}),Yl&&/* @__PURE__ */dt(at,{children:[!Dl&&/* @__PURE__ */st(Ne,{children:_t.header}),Ys(Yl)]}),jt&&!(Dl&&Yl)&&/* @__PURE__ */dt(at,{children:[!Dl&&/* @__PURE__ */st(Ne,{children:_t.header}),!Zt&&/* @__PURE__ */st(Ce,{words:qt,icon:/* @__PURE__ */st(zr,{type:"header",size:13}),name:_t.header,badge:Jl?void 0:Gl,shared:Jl,onSelect:ui,selected:er.kind===Yt?.kind,rowProps:{onClick:ul(ui)}})]}),El&&!(Dl&&Yl)&&sd(El,Tl,"header"),!od&&/* @__PURE__ */st(Ne,{children:rd}),od?/* @__PURE__ */dt(at,{children:[
54
+ /* @__PURE__ */st(Ce,{words:qt,icon:null,name:rd,fold:{open:!id,label:rd,onToggle:()=>Wr(kt)}}),!id&&/* @__PURE__ */st(Oe,{children:ld})]}):ld,jt&&!Dl&&/* @__PURE__ */st(Ne,{children:_t.footer}),Ll&&!(Dl&&Xl)&&sd(Ll,Al,"footer"),Xl&&Ys(Xl),hr.treeFoot?.()]})]})]}),
55
+ /* @__PURE__ */st(He,{side:"left",width:Er.left,min:We.left,max:Ve,defaultWidth:m.left,label:_t.resizeLeftPanel,onResize:Dr})]}):/* @__PURE__ */st(N,{side:"left",onShow:di}),
56
+ /* @__PURE__ */dt("div",{ref:Xr,className:"sf-center sf-scroll","data-sf-canvas-head":qr?"":void 0,style:{overflowX:ii?"auto":"hidden",overflowY:"hidden"},children:[qr&&/* @__PURE__ */st("div",{ref:ei,className:"sf-canvas-head",children:/* @__PURE__ */st(qr,{device:xo})}),
57
+ /* @__PURE__ */dt("div",{className:"sf-frame-scaler",style:li,children:[
58
+ /* @__PURE__ */st("div",{className:"sf-frame "+(xo===So?"":`sf-frame--${xo}`),style:si,children:/* @__PURE__ */dt("div",{className:"sf-preview-host",children:[
59
+ /* @__PURE__ */st(xe.Provider,{value:Fl,children:/* @__PURE__ */st(ze.Provider,{value:Ul,children:/* @__PURE__ */st(so,{},To)})}),
60
+ /* @__PURE__ */st(_e,{canvas:Do,session:ps,model:Ns,measure:Ps,canDrop:Ms,onDrop:As,choose:ms,onPick:Ts,dropOn:Es?{accepts:(e,n)=>{if(!e.media||!Es||n.item.rung)return!1;const t=an(At.data,mi,n.item.id);return null!==t&&Es.takes(t.node)},onDrop:(e,n)=>(e=>{const n=Ds();n&&Es&&Vs(n).then(n=>{n&&Ws(n,e.item.id)})})(n),label:()=>_t.canvasReplaceImage}:void 0,onZoneAdd:Us,onSeamAdd:Us,zoneAddLabel:_t.canvasAddBlock,words:eo.canvas,readOnly:Boolean(It),revision:At.data}),_o.length>0&&!Ho&&/* @__PURE__ */st("div",{className:"sf-preview-gaps",children:_o.map(e=>
61
+ /* @__PURE__ */st(qe,{index:e.index,label:_t.addSectionHere,onInsert:()=>dl(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))})]})}),vs?/* @__PURE__ */st(ft,{canvas:Do,tabs:Ss,onSelect:e=>{const n=hi.findIndex(n=>String(n.props.id)===e);n>=0&&ol(n)}}):null]})]}),yo?/* @__PURE__ */dt(at,{children:[vn?
62
+ /* @__PURE__ */st("div",{className:"es-sidepanel es-sidepanel--right","data-es-host-panel":"",children:vn}):/* @__PURE__ */st(at,{children:/* @__PURE__ */st(h,{value:{selectChild:Pl,addChild:$l,childRowName:Wi,blockRowName:_l},children:/* @__PURE__ */st(ao,{mode:er,onOpenWebsiteSettings:hr.openSettings??(()=>{}),onOpenSiteStyles:hr.openStyles,onSelectNode:Nr,onNotify:Yr,onHidePanel:ai,nodeActions:Et?Cn(Ft,Et.type):bt})})}),
63
+ /* @__PURE__ */st(He,{side:"right",width:Er.right,min:We.right,max:Ve,defaultWidth:m.right,label:_t.resizeSettingsPanel,onResize:Hr})]}):
64
+ /* @__PURE__ */st(N,{side:"right",onShow:ai})]}),Qi.menu,
65
+ /* @__PURE__ */st(ne,{}),Si?/* @__PURE__ */st(pt,{name:Si.name,onMake:e=>(async(e,n)=>{const t=hi.find(n=>String(n.props.id)===e),o=Dt.shared;if(!t||!o)return;let r;try{r=await C(bi).create(n,t)}catch{return void Yr(_t.shared.makeFailed,"error")}o.adopt(t,r),wi(null)})(Si.id,e),onCancel:()=>wi(null)}):null]})}))}export{wt as ScreenChrome};
@@ -1 +1 @@
1
- import{resolveMediaPick as e}from"./chunk-RYNBSKE7.js";function t(t){const r=t;switch(r?.type){case"storefront-editor:media-picked":{const r=t;return r.requestId&&e(r.requestId,r.media??null),!0}case"storefront-editor:media-pick-cancelled":{const r=t;return r.requestId&&e(r.requestId,null),!0}default:return!1}}export{t as routeSharedHostMessage};
1
+ import{resolveMediaPick as e}from"./chunk-UNVKPVZW.js";function t(t){const r=t;switch(r?.type){case"storefront-editor:media-picked":{const r=t;return r.requestId&&e(r.requestId,r.media??null),!0}case"storefront-editor:media-pick-cancelled":{const r=t;return r.requestId&&e(r.requestId,null),!0}default:return!1}}export{t as routeSharedHostMessage};
@@ -1,21 +1,21 @@
1
- import{fieldIsShown as e,shownFields as n}from"./chunk-BPXEFVSQ.js";import{TreeSeam as t}from"./chunk-A6Z4SD3I.js";import{SETTINGS_BUCKETS as l,SettingsGroup as a}from"./chunk-RC25EGHD.js";import{DEFAULT_TREE_WORDS as r}from"./chunk-K56YDHYQ.js";import{DEFAULT_PANEL_WORDS as o}from"./chunk-KFV7N2DJ.js";import{easelMenuEntries as i}from"./chunk-FIVU2COQ.js";import{FieldNumber as s}from"./chunk-ZOBSIXRD.js";import{SettingsField as c,SettingsSegmented as d}from"./chunk-VANKQVOW.js";import{FieldSelect as u}from"./chunk-QAJAEWCZ.js";import{DEFAULT_FIELDS_WORDS as m}from"./chunk-WRFD4EXD.js";import{useWords as h}from"./chunk-MFIRYGHW.js";import{useTreeDrag as p,gapToMoveIndex as f}from"./chunk-3S5N4HLJ.js";import{withTip as b}from"./chunk-P2VEMZH5.js";import{Textarea as g,Input as v,SortableList as y,ListRow as k,ContextMenu as x,tabPanelId as w,Tabs as C,tabButtonId as N}from"efficient-shell/ui";export{LinkPicker}from"efficient-shell/ui";import{useRef as O,useState as j,useLayoutEffect as D,useId as S}from"react";import{jsx as $,jsxs as I}from"react/jsx-runtime";import{ChevronIcon as L,LockIcon as P,MoveUpIcon as F,MoveDownIcon as E,DuplicateIcon as R,TrashIcon as A}from"efficient-shell/icons/efficient";function M({id:e,value:n,onChange:t,placeholder:l,multiline:a=!1,rows:r=3,readOnly:o=!1,ariaLabel:i,ariaLabelledBy:s}){const c=n??"";return a?/* @__PURE__ */$(g,{id:e,size:"sm",className:"es-fin",value:c,rows:r,placeholder:l,readOnly:o,"aria-label":i,"aria-labelledby":s,onChange:e=>t(e.target.value)}):/* @__PURE__ */$(v,{id:e,size:"md",className:"es-fin",type:"text",value:c,placeholder:l,readOnly:o,"aria-label":i,"aria-labelledby":s,onChange:e=>t(e.target.value)})}function W(e,n,t){const l=e.slice();return l.splice(Math.max(0,Math.min(n,l.length)),0,t),l}function z(e,n,t){const l=e.slice(),[a]=l.splice(n,1);return l.splice(Math.max(0,Math.min(t,l.length)),0,a),l}function T(e,n){return e.filter((e,t)=>t!==n)}function H(e){return null===e||"object"!=typeof e?e:JSON.parse(JSON.stringify(e))}var V='input, textarea, select, button, [contenteditable]:not([contenteditable="false"]), [tabindex]',B={parentId:"list",slot:"items"};function K({label:e,icon:n,noun:l,items:a,onChange:o,newItem:s,summary:c,itemName:d,thumb:u,min:g=0,max:v,readOnly:w=!1,open:C,onOpen:N,renderItem:S,renderRow:M,canRemove:K,lockedReason:J,fixed:Q=!1,removeOnRow:Z=!0,canDuplicate:X,above:Y,head:q=!0}){const G=h("fields",m).list,U=h("tree",r),_=l??G.item,ee=!w&&!Q&&("number"!=typeof v||a.length<v),ne=a.length<=g,te=e=>!!K&&!K(a[e],e),le=e=>!w&&!Q&&Z&&!ne&&!te(e),ae=e=>ee&&(!X||X(a[e],e)),re=(e,n)=>d?d(e,n):G.itemName({noun:_,n:n+1}),oe=O([]),ie=O(null),[se,ce]=j(null),de=O(null),[ue,me]=j(null),[he,pe]=j("");D(()=>{const e=ie.current;if(!e)return;ie.current=null;const n=oe.current[e.index]?.querySelectorAll(V)[e.nth]??oe.current[e.index];if(n?.focus(),n&&null!==e.start&&"setSelectionRange"in n)try{n.setSelectionRange(e.start,e.end)}catch{}});const fe=(e,n)=>{if(n<0||n>=a.length||n===e)return;const t=oe.current[e],l=t?.ownerDocument.activeElement;if(t&&l&&t.contains(l)){const e=[...t.querySelectorAll(V)].indexOf(l),a=l;ie.current={index:n,nth:e,start:"number"==typeof a.selectionStart?a.selectionStart:null,end:"number"==typeof a.selectionEnd?a.selectionEnd:null}}o(z(a,e,n));const r=function(e,n,t){return null===e?null:e===n?t:n<e&&t>=e?e-1:n>e&&t<=e?e+1:e}(C,e,n);r!==C&&N(r),pe(G.moved({n:n+1,total:a.length}))},be=e=>{ee&&(o(W(a,e,s())),M?(ie.current={index:e,nth:0,start:null,end:null},null!==C&&C>=e&&N(C+1)):N(e))},ge=e=>{le(e)&&(o(T(a,e)),C===e?N(null):null!==C&&C>e&&N(C-1))},ve=p({keyOf:e=>String(e),canDrop:(e,n)=>n.parentId===B.parentId&&n.slot===B.slot,onDrop:(e,n)=>{const t=f({...B,index:e},n);t!==e&&fe(e,t)},onStep:(e,n)=>fe(e,e+n),canStep:(e,n)=>e+n>=0&&e+n<a.length,readOnly:w}),ye=e=>{const n=[];return e>0&&n.push({label:G.moveUp,icon:/* @__PURE__ */$(F,{size:14}),shortcut:"⌥↑",onClick:()=>fe(e,e-1)}),e<a.length-1&&n.push({label:G.moveDown,icon:/* @__PURE__ */$(E,{size:14}),shortcut:"⌥↓",onClick:()=>fe(e,e+1)}),ae(e)&&n.push({label:G.duplicate,icon:/* @__PURE__ */$(R,{size:14}),onClick:()=>(e=>{ae(e)&&(o(W(a,e+1,H(a[e]))),null!==C&&C>e&&N(C+1))})(e)}),le(e)&&n.push({label:G.delete,icon:/* @__PURE__ */$(A,{size:14}),danger:!0,onClick:()=>ge(e)}),n},ke=(e,n,t,l)=>{w||0===ye(e).length||me({index:e,x:n,y:t,owner:l})},xe=e=>n=>{const t=a.slice();t[e]=n,o(t)};/* @__PURE__ */
1
+ import{fieldIsShown as e,shownFields as n}from"./chunk-BPXEFVSQ.js";import{TreeSeam as t}from"./chunk-A6Z4SD3I.js";import{DEFAULT_TREE_WORDS as l}from"./chunk-K56YDHYQ.js";import{easelMenuEntries as a}from"./chunk-FIVU2COQ.js";import{SETTINGS_BUCKETS as r,SettingsGroup as o}from"./chunk-RC25EGHD.js";import{DEFAULT_PANEL_WORDS as i}from"./chunk-KFV7N2DJ.js";import{FieldNumber as s}from"./chunk-ZOBSIXRD.js";import{FieldSelect as c}from"./chunk-QAJAEWCZ.js";import{DEFAULT_FIELDS_WORDS as d}from"./chunk-WRFD4EXD.js";import{SettingsField as u,SettingsSegmented as m}from"./chunk-VANKQVOW.js";import{useWords as h}from"./chunk-MFIRYGHW.js";import{useTreeDrag as p,gapToMoveIndex as f}from"./chunk-3S5N4HLJ.js";import{withTip as b}from"./chunk-P2VEMZH5.js";import{Textarea as g,Input as v,SortableList as y,ListRow as k,ContextMenu as x,tabPanelId as w,Tabs as C,tabButtonId as N}from"efficient-shell/ui";export{LinkPicker}from"efficient-shell/ui";import{useRef as O,useState as j,useLayoutEffect as D,useId as S}from"react";import{jsx as $,jsxs as I}from"react/jsx-runtime";import{ChevronIcon as L,LockIcon as P,MoveUpIcon as F,MoveDownIcon as E,DuplicateIcon as R,TrashIcon as A}from"efficient-shell/icons/efficient";function M({id:e,value:n,onChange:t,placeholder:l,multiline:a=!1,rows:r=3,readOnly:o=!1,ariaLabel:i,ariaLabelledBy:s}){const c=n??"";return a?/* @__PURE__ */$(g,{id:e,size:"sm",className:"es-fin",value:c,rows:r,placeholder:l,readOnly:o,"aria-label":i,"aria-labelledby":s,onChange:e=>t(e.target.value)}):/* @__PURE__ */$(v,{id:e,size:"md",className:"es-fin",type:"text",value:c,placeholder:l,readOnly:o,"aria-label":i,"aria-labelledby":s,onChange:e=>t(e.target.value)})}function W(e,n,t){const l=e.slice();return l.splice(Math.max(0,Math.min(n,l.length)),0,t),l}function z(e,n,t){const l=e.slice(),[a]=l.splice(n,1);return l.splice(Math.max(0,Math.min(t,l.length)),0,a),l}function T(e,n){return e.filter((e,t)=>t!==n)}function H(e){return null===e||"object"!=typeof e?e:JSON.parse(JSON.stringify(e))}var V='input, textarea, select, button, [contenteditable]:not([contenteditable="false"]), [tabindex]',B={parentId:"list",slot:"items"};function K({label:e,icon:n,noun:r,items:o,onChange:i,newItem:s,summary:c,itemName:u,thumb:m,min:g=0,max:v,readOnly:w=!1,open:C,onOpen:N,renderItem:S,renderRow:M,canRemove:K,lockedReason:J,fixed:Q=!1,removeOnRow:Z=!0,canDuplicate:X,above:Y,head:q=!0}){const G=h("fields",d).list,U=h("tree",l),_=r??G.item,ee=!w&&!Q&&("number"!=typeof v||o.length<v),ne=o.length<=g,te=e=>!!K&&!K(o[e],e),le=e=>!w&&!Q&&Z&&!ne&&!te(e),ae=e=>ee&&(!X||X(o[e],e)),re=(e,n)=>u?u(e,n):G.itemName({noun:_,n:n+1}),oe=O([]),ie=O(null),[se,ce]=j(null),de=O(null),[ue,me]=j(null),[he,pe]=j("");D(()=>{const e=ie.current;if(!e)return;ie.current=null;const n=oe.current[e.index]?.querySelectorAll(V)[e.nth]??oe.current[e.index];if(n?.focus(),n&&null!==e.start&&"setSelectionRange"in n)try{n.setSelectionRange(e.start,e.end)}catch{}});const fe=(e,n)=>{if(n<0||n>=o.length||n===e)return;const t=oe.current[e],l=t?.ownerDocument.activeElement;if(t&&l&&t.contains(l)){const e=[...t.querySelectorAll(V)].indexOf(l),a=l;ie.current={index:n,nth:e,start:"number"==typeof a.selectionStart?a.selectionStart:null,end:"number"==typeof a.selectionEnd?a.selectionEnd:null}}i(z(o,e,n));const a=function(e,n,t){return null===e?null:e===n?t:n<e&&t>=e?e-1:n>e&&t<=e?e+1:e}(C,e,n);a!==C&&N(a),pe(G.moved({n:n+1,total:o.length}))},be=e=>{ee&&(i(W(o,e,s())),M?(ie.current={index:e,nth:0,start:null,end:null},null!==C&&C>=e&&N(C+1)):N(e))},ge=e=>{le(e)&&(i(T(o,e)),C===e?N(null):null!==C&&C>e&&N(C-1))},ve=p({keyOf:e=>String(e),canDrop:(e,n)=>n.parentId===B.parentId&&n.slot===B.slot,onDrop:(e,n)=>{const t=f({...B,index:e},n);t!==e&&fe(e,t)},onStep:(e,n)=>fe(e,e+n),canStep:(e,n)=>e+n>=0&&e+n<o.length,readOnly:w}),ye=e=>{const n=[];return e>0&&n.push({label:G.moveUp,icon:/* @__PURE__ */$(F,{size:14}),shortcut:"⌥↑",onClick:()=>fe(e,e-1)}),e<o.length-1&&n.push({label:G.moveDown,icon:/* @__PURE__ */$(E,{size:14}),shortcut:"⌥↓",onClick:()=>fe(e,e+1)}),ae(e)&&n.push({label:G.duplicate,icon:/* @__PURE__ */$(R,{size:14}),onClick:()=>(e=>{ae(e)&&(i(W(o,e+1,H(o[e]))),null!==C&&C>e&&N(C+1))})(e)}),le(e)&&n.push({label:G.delete,icon:/* @__PURE__ */$(A,{size:14}),danger:!0,onClick:()=>ge(e)}),n},ke=(e,n,t,l)=>{w||0===ye(e).length||me({index:e,x:n,y:t,owner:l})},xe=e=>n=>{const t=o.slice();t[e]=n,i(t)};/* @__PURE__ */
2
2
  return I("div",{className:"es-list",children:[q?/* @__PURE__ */I("div",{className:"es-list-head",children:[
3
3
  /* @__PURE__ */I("span",{className:"es-list-label",children:[n?/* @__PURE__ */$("span",{className:"es-field-icon","aria-hidden":"true",children:n}):null,e]}),
4
- /* @__PURE__ */$("span",{className:"es-list-count",children:a.length})]}):null,Y?/* @__PURE__ */$("div",{className:"es-list-above",children:Y}):null,a.length?/* @__PURE__ */I(y,{"aria-label":e,spacing:"comfortable",className:"es-list-rows",rootProps:ve.rootProps(),children:[a.map((e,n)=>{const l=ve.row({item:n,place:{...B,index:n}}),a=l.draggable&&se!==n,r=!M&&C===n,o=!w&&!Q&&Z&&te(n),i=["es-list-row",M?"is-inline":"is-item",r?"is-open":"",a?"is-draggable":"",l.dragging?"is-dragging":"",l.drop?`is-drop-${l.drop}`:""].filter(Boolean).join(" ");return[n>0?/* @__PURE__ */$(t,{...ve.seam({place:{...B,index:n}}),onAdd:ee?()=>be(n):void 0,label:G.addHere({noun:_})},`seam-${n}`):null,
5
- /* @__PURE__ */$(k,{className:i,flat:!!M,active:r,draggable:l.draggable,dragHint:U.dragHint,dragging:l.dragging,drop:"before"===l.drop||"after"===l.drop?l.drop:void 0,onMove:l.draggable?e=>fe(n,"up"===e?n-1:n+1):void 0,rowRef:e=>{oe.current[n]=e},rowProps:{...l.rowProps,draggable:a||void 0,onPointerDown:e=>{const t=e.target.closest?.('input, textarea, select, [contenteditable]:not([contenteditable="false"])'),a=!!t&&t===t.ownerDocument.activeElement;e.currentTarget.draggable=l.draggable&&!a,de.current=t&&!a?t:null,ce(a?n:null)},onDragStart:e=>{const n=de.current;de.current=null,n&&n.ownerDocument.activeElement===n&&n.blur(),l.rowProps.onDragStart?.(e)},onContextMenu:e=>{w||(e.preventDefault(),e.stopPropagation(),ke(n,e.clientX,e.clientY,e.currentTarget))},onKeyDown:e=>{if("ContextMenu"===e.key||e.shiftKey&&"F10"===e.key){e.preventDefault();const t=e.currentTarget.ownerDocument,l=e=>e.preventDefault();t.addEventListener("contextmenu",l,{capture:!0,once:!0}),t.defaultView?.setTimeout(()=>t.removeEventListener("contextmenu",l,{capture:!0}),500);const a=e.currentTarget.getBoundingClientRect();return void ke(n,a.left+24,a.bottom,e.currentTarget)}l.rowProps.onKeyDown?.(e)}},actions:w||Q||!Z?void 0:o?b(J?J(e,n):G.locked,/* @__PURE__ */$("span",{className:"es-list-lock",role:"img","aria-label":J?J(e,n):G.locked,children:/* @__PURE__ */$(P,{size:13})})):b(G.deleteItem({noun:_}),/* @__PURE__ */$("button",{type:"button",className:"es-list-x","aria-label":G.deleteItem({noun:_}),disabled:!le(n),onClick:()=>ge(n),children:"×"})),below:r?/* @__PURE__ */$("div",{className:"es-list-item",children:S(e,n,xe(n))}):void 0,children:M?/* @__PURE__ */$("div",{className:"es-list-row-main",children:M(e,n,xe(n))}):/* @__PURE__ */I("button",{type:"button",className:"es-list-open","aria-expanded":r,onClick:()=>N(r?null:n),children:[u?/* @__PURE__ */$("span",{className:"es-list-thumb","aria-hidden":"true",children:u(e,n)}):null,
4
+ /* @__PURE__ */$("span",{className:"es-list-count",children:o.length})]}):null,Y?/* @__PURE__ */$("div",{className:"es-list-above",children:Y}):null,o.length?/* @__PURE__ */I(y,{"aria-label":e,spacing:"comfortable",className:"es-list-rows",rootProps:ve.rootProps(),children:[o.map((e,n)=>{const l=ve.row({item:n,place:{...B,index:n}}),a=l.draggable&&se!==n,r=!M&&C===n,o=!w&&!Q&&Z&&te(n),i=["es-list-row",M?"is-inline":"is-item",r?"is-open":"",a?"is-draggable":"",l.dragging?"is-dragging":"",l.drop?`is-drop-${l.drop}`:""].filter(Boolean).join(" ");return[n>0?/* @__PURE__ */$(t,{...ve.seam({place:{...B,index:n}}),onAdd:ee?()=>be(n):void 0,label:G.addHere({noun:_})},`seam-${n}`):null,
5
+ /* @__PURE__ */$(k,{className:i,flat:!!M,active:r,draggable:l.draggable,dragHint:U.dragHint,dragging:l.dragging,drop:"before"===l.drop||"after"===l.drop?l.drop:void 0,onMove:l.draggable?e=>fe(n,"up"===e?n-1:n+1):void 0,rowRef:e=>{oe.current[n]=e},rowProps:{...l.rowProps,draggable:a||void 0,onPointerDown:e=>{const t=e.target.closest?.('input, textarea, select, [contenteditable]:not([contenteditable="false"])'),a=!!t&&t===t.ownerDocument.activeElement;e.currentTarget.draggable=l.draggable&&!a,de.current=t&&!a?t:null,ce(a?n:null)},onDragStart:e=>{const n=de.current;de.current=null,n&&n.ownerDocument.activeElement===n&&n.blur(),l.rowProps.onDragStart?.(e)},onContextMenu:e=>{w||(e.preventDefault(),e.stopPropagation(),ke(n,e.clientX,e.clientY,e.currentTarget))},onKeyDown:e=>{if("ContextMenu"===e.key||e.shiftKey&&"F10"===e.key){e.preventDefault();const t=e.currentTarget.ownerDocument,l=e=>e.preventDefault();t.addEventListener("contextmenu",l,{capture:!0,once:!0}),t.defaultView?.setTimeout(()=>t.removeEventListener("contextmenu",l,{capture:!0}),500);const a=e.currentTarget.getBoundingClientRect();return void ke(n,a.left+24,a.bottom,e.currentTarget)}l.rowProps.onKeyDown?.(e)}},actions:w||Q||!Z?void 0:o?b(J?J(e,n):G.locked,/* @__PURE__ */$("span",{className:"es-list-lock",role:"img","aria-label":J?J(e,n):G.locked,children:/* @__PURE__ */$(P,{size:13})})):b(G.deleteItem({noun:_}),/* @__PURE__ */$("button",{type:"button",className:"es-list-x","aria-label":G.deleteItem({noun:_}),disabled:!le(n),onClick:()=>ge(n),children:"×"})),below:r?/* @__PURE__ */$("div",{className:"es-list-item",children:S(e,n,xe(n))}):void 0,children:M?/* @__PURE__ */$("div",{className:"es-list-row-main",children:M(e,n,xe(n))}):/* @__PURE__ */I("button",{type:"button",className:"es-list-open","aria-expanded":r,onClick:()=>N(r?null:n),children:[m?/* @__PURE__ */$("span",{className:"es-list-thumb","aria-hidden":"true",children:m(e,n)}):null,
6
6
  /* @__PURE__ */$("span",{className:"es-list-row-name",children:re(e,n)}),/* @__PURE__ */$("span",c?{className:"es-list-row-summary",children:c(e,n)}:{className:"es-list-row-summary"}),
7
7
  /* @__PURE__ */$(L,{size:14,className:"es-list-chev","aria-hidden":"true"})]})},n)]}),
8
- /* @__PURE__ */$(t,{...ve.seam({place:{...B,index:a.length}})})]}):null,w||Q?null:/* @__PURE__ */$("button",{type:"button",className:"es-list-add",disabled:!ee,onClick:()=>be(a.length),children:G.add({noun:_})}),
9
- /* @__PURE__ */$("span",{className:"es-list-said","aria-live":"polite",children:he}),ue&&ue.index<a.length?
10
- /* @__PURE__ */$(x,{at:{x:ue.x,y:ue.y},owner:ue.owner,onClose:()=>me(null),items:i(ye(ue.index))}):null]})}var J=e=>e<6?e+1:6,Q=(e,n)=>"string"==typeof e.label&&e.label?e.label:n;function Z({field:e,name:t,id:l,value:r,onChange:o,readOnly:i,context:s,showWhenContext:c,renderers:d,headingLevel:u=3}){const[m,h]=j(!0),p=r&&"object"==typeof r?r:{};/* @__PURE__ */
11
- return $(a,{id:`${l}-group`,title:Q(e,t),open:m,onToggle:h,level:u,children:Object.entries(n(e.objectFields,{values:p,context:c})).map(([e,n])=>/* @__PURE__ */$(Y,{field:n,name:`${t}.${e}`,id:`${l}-${e}`,value:p[e],onChange:n=>o({...p,[e]:n}),readOnly:i,context:s,showWhenContext:c,renderers:d,headingLevel:J(u)},e))})}function X({field:e,name:t,id:l,value:a,onChange:r,readOnly:o,context:i,showWhenContext:s,renderers:c,openItem:d,onOpenItem:u,headingLevel:m}){const[h,p]=j(null),f=u?d??null:h,b=u??p,g=Array.isArray(a)?a:[],v=e.getItemSummary;/* @__PURE__ */
12
- return $(K,{label:Q(e,t),icon:e.icon,noun:"string"==typeof e.noun?e.noun:void 0,items:g,onChange:r,newItem:()=>H({...e.defaultItemProps??{}}),summary:v?(e,n)=>v(e,n):void 0,min:e.min,max:e.max,readOnly:o,open:f,onOpen:b,renderItem:(a,r,d)=>Object.entries(n(e.arrayFields,{values:a,context:s})).map(([e,n])=>/* @__PURE__ */$(Y,{field:n,name:`${t}[${r}].${e}`,id:`${l}-${r}-${e}`,value:a?.[e],onChange:n=>d({...a,[e]:n}),readOnly:o,context:i,showWhenContext:s,renderers:c,headingLevel:m},e))})}function Y(e){const{field:n,name:t,id:l,value:a,onChange:r,readOnly:o,context:i,renderers:m}=e;if(!n||n.marker||!1===n.visible)return null;const h=m?.[n.type];if(h)return h({field:n,name:t,id:l,value:a,onChange:r,readOnly:o});switch(n.type){case"custom":{const e={...i,field:n,name:t,id:l,value:a,onChange:r,readOnly:o};return n.render(e)}case"text":case"textarea":/* @__PURE__ */
13
- return $(c,{label:Q(n,t),htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */$(M,{id:l,value:"string"==typeof a?a:null==a?"":String(a),onChange:r,placeholder:n.placeholder,multiline:"textarea"===n.type,readOnly:o})});case"number":/* @__PURE__ */
14
- return $(c,{label:Q(n,t),htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */$(s,{id:l,value:"number"==typeof a?a:void 0,onChange:r,min:n.min,max:n.max,step:n.step,placeholder:n.placeholder,readOnly:o})});case"select":{const e=`${l}-label`;/* @__PURE__ */
15
- return $(c,{label:Q(n,t),labelId:e,htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */$(u,{id:l,value:a,options:n.options,onChange:r,readOnly:o,ariaLabelledBy:e})})}case"radio":/* @__PURE__ */
16
- return $(c,{label:Q(n,t),icon:n.icon,hint:n.hint,children:/* @__PURE__ */$(d,{ariaLabel:Q(n,t),value:a,options:n.options.map(e=>({id:e.value,label:e.label,icon:e.icon,disabled:e.disabled||o})),onChange:e=>{o||r(e)}})});case"object":/* @__PURE__ */
8
+ /* @__PURE__ */$(t,{...ve.seam({place:{...B,index:o.length}})})]}):null,w||Q?null:/* @__PURE__ */$("button",{type:"button",className:"es-list-add",disabled:!ee,onClick:()=>be(o.length),children:G.add({noun:_})}),
9
+ /* @__PURE__ */$("span",{className:"es-list-said","aria-live":"polite",children:he}),ue&&ue.index<o.length?
10
+ /* @__PURE__ */$(x,{at:{x:ue.x,y:ue.y},owner:ue.owner,onClose:()=>me(null),items:a(ye(ue.index))}):null]})}var J=e=>e<6?e+1:6,Q=(e,n)=>"string"==typeof e.label&&e.label?e.label:n;function Z({field:e,name:t,id:l,value:a,onChange:r,readOnly:i,context:s,showWhenContext:c,renderers:d,headingLevel:u=3}){const[m,h]=j(!0),p=a&&"object"==typeof a?a:{};/* @__PURE__ */
11
+ return $(o,{id:`${l}-group`,title:Q(e,t),open:m,onToggle:h,level:u,children:Object.entries(n(e.objectFields,{values:p,context:c})).map(([e,n])=>/* @__PURE__ */$(Y,{field:n,name:`${t}.${e}`,id:`${l}-${e}`,value:p[e],onChange:n=>r({...p,[e]:n}),readOnly:i,context:s,showWhenContext:c,renderers:d,headingLevel:J(u)},e))})}function X({field:e,name:t,id:l,value:a,onChange:r,readOnly:o,context:i,showWhenContext:s,renderers:c,openItem:d,onOpenItem:u,headingLevel:m}){const[h,p]=j(null),f=u?d??null:h,b=u??p,g=Array.isArray(a)?a:[],v=e.getItemSummary;/* @__PURE__ */
12
+ return $(K,{label:Q(e,t),icon:e.icon,noun:"string"==typeof e.noun?e.noun:void 0,items:g,onChange:r,newItem:()=>H({...e.defaultItemProps??{}}),summary:v?(e,n)=>v(e,n):void 0,min:e.min,max:e.max,readOnly:o,open:f,onOpen:b,renderItem:(a,r,d)=>Object.entries(n(e.arrayFields,{values:a,context:s})).map(([e,n])=>/* @__PURE__ */$(Y,{field:n,name:`${t}[${r}].${e}`,id:`${l}-${r}-${e}`,value:a?.[e],onChange:n=>d({...a,[e]:n}),readOnly:o,context:i,showWhenContext:s,renderers:c,headingLevel:m},e))})}function Y(e){const{field:n,name:t,id:l,value:a,onChange:r,readOnly:o,context:i,renderers:d}=e;if(!n||n.marker||!1===n.visible)return null;const h=d?.[n.type];if(h)return h({field:n,name:t,id:l,value:a,onChange:r,readOnly:o});switch(n.type){case"custom":{const e={...i,field:n,name:t,id:l,value:a,onChange:r,readOnly:o};return n.render(e)}case"text":case"textarea":/* @__PURE__ */
13
+ return $(u,{label:Q(n,t),htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */$(M,{id:l,value:"string"==typeof a?a:null==a?"":String(a),onChange:r,placeholder:n.placeholder,multiline:"textarea"===n.type,readOnly:o})});case"number":/* @__PURE__ */
14
+ return $(u,{label:Q(n,t),htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */$(s,{id:l,value:"number"==typeof a?a:void 0,onChange:r,min:n.min,max:n.max,step:n.step,placeholder:n.placeholder,readOnly:o})});case"select":{const e=`${l}-label`;/* @__PURE__ */
15
+ return $(u,{label:Q(n,t),labelId:e,htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */$(c,{id:l,value:a,options:n.options,onChange:r,readOnly:o,ariaLabelledBy:e})})}case"radio":/* @__PURE__ */
16
+ return $(u,{label:Q(n,t),icon:n.icon,hint:n.hint,children:/* @__PURE__ */$(m,{ariaLabel:Q(n,t),value:a,options:n.options.map(e=>({id:e.value,label:e.label,icon:e.icon,disabled:e.disabled||o})),onChange:e=>{o||r(e)}})});case"object":/* @__PURE__ */
17
17
  return $(Z,{...e,field:n});case"array":/* @__PURE__ */
18
- return $(X,{...e,field:n});case"slot":return null}}var q=e=>l.includes(e);function G(n,t){let a,r=l[0];const o=[],i=/* @__PURE__ */new Set;for(const[l,s]of Object.entries(n))s&&(q(s.bucket)&&((s.marker||s.bucket!==r)&&(a=void 0),r=s.bucket),s.marker&&"string"==typeof s.fold?a={key:l,title:s.fold}:s.marker&&!1===s.fold&&(a=void 0),s.marker||!1===s.visible||t&&!e(s,t)||(o.push(a?{name:l,field:s,bucket:r,fold:a}:{name:l,field:s,bucket:r}),"slot"!==s.type&&i.add(r)));return{rows:o,buckets:l.filter(e=>i.has(e))}}function U(e){return new Map(G(e).rows.map(e=>[e.name,e.bucket]))}function _(e){const n=[];for(const t of e){const e=n[n.length-1];e&&e.fold?.key===t.fold?.key?e.rows.push(t):n.push({fold:t.fold,rows:[t]})}return n}function ee({fields:e,values:n,onChange:t,readOnly:l=!1,context:r,showWhenContext:i,tab:s,onTab:c,tabs:d=!0,tabIcons:u,renderers:m,idPrefix:p,ariaLabel:f,lead:b,children:g,leadFold:v,closedFolds:y,onFold:k,headingLevel:x=3}){const O=h("panel",o),D=S(),L=p??`es-insp${D.replace(/:/g,"")}`,P=G(e,{values:n,context:i}),[F,E]=j(void 0),R=s??F,A=R&&P.buckets.includes(R)?R:P.buckets[0],[M,W]=j(null),z=M&&M.panel===L&&P.rows.some(e=>e.name===M.name)?M:null,T=d&&P.buckets.length>1,H=T&&A?w(L,A):`${L}-rows`,[V,B]=j(()=>/* @__PURE__ */new Set),K=y??V,Q=(e,n)=>{/* @__PURE__ */return $(a,{title:e.title,open:!K.has(e.key),onToggle:n=>((e,n)=>{void 0===y&&B(t=>{const l=new Set(t);return n?l.delete(e):l.add(e),l}),k?.(e,n)})(e.key,n),id:`${L}-fold-${t=e.key,[...t].map(e=>/[A-Za-z0-9_-]/.test(e)?e:`-u${e.codePointAt(0).toString(16)}-`).join("")}`,level:x,children:n});var t},Z=e=>T&&e!==A,X=({name:e,field:a,bucket:o,fold:s})=>/* @__PURE__ */$("div",{className:"es-insp-row","data-field":e,"data-bucket":o,hidden:!!Z(o)||void 0,children:/* @__PURE__ */$(Y,{field:a,name:e,id:`${L}-${e}`,value:n[e],onChange:n=>t(e,n),readOnly:l,context:r,showWhenContext:i,renderers:m,openItem:z&&z.name===e?z.index:null,onOpenItem:n=>W(null===n?null:{panel:L,name:e,index:n}),headingLevel:s?J(x):x})},e);/* @__PURE__ */
18
+ return $(X,{...e,field:n});case"slot":return null}}var q=e=>r.includes(e);function G(n,t){let l,a=r[0];const o=[],i=/* @__PURE__ */new Set;for(const[r,s]of Object.entries(n))s&&(q(s.bucket)&&((s.marker||s.bucket!==a)&&(l=void 0),a=s.bucket),s.marker&&"string"==typeof s.fold?l={key:r,title:s.fold}:s.marker&&!1===s.fold&&(l=void 0),s.marker||!1===s.visible||t&&!e(s,t)||(o.push(l?{name:r,field:s,bucket:a,fold:l}:{name:r,field:s,bucket:a}),"slot"!==s.type&&i.add(a)));return{rows:o,buckets:r.filter(e=>i.has(e))}}function U(e){return new Map(G(e).rows.map(e=>[e.name,e.bucket]))}function _(e){const n=[];for(const t of e){const e=n[n.length-1];e&&e.fold?.key===t.fold?.key?e.rows.push(t):n.push({fold:t.fold,rows:[t]})}return n}function ee({fields:e,values:n,onChange:t,readOnly:l=!1,context:a,showWhenContext:r,tab:s,onTab:c,tabs:d=!0,tabIcons:u,renderers:m,idPrefix:p,ariaLabel:f,lead:b,children:g,leadFold:v,closedFolds:y,onFold:k,headingLevel:x=3}){const O=h("panel",i),D=S(),L=p??`es-insp${D.replace(/:/g,"")}`,P=G(e,{values:n,context:r}),[F,E]=j(void 0),R=s??F,A=R&&P.buckets.includes(R)?R:P.buckets[0],[M,W]=j(null),z=M&&M.panel===L&&P.rows.some(e=>e.name===M.name)?M:null,T=d&&P.buckets.length>1,H=T&&A?w(L,A):`${L}-rows`,[V,B]=j(()=>/* @__PURE__ */new Set),K=y??V,Q=(e,n)=>{/* @__PURE__ */return $(o,{title:e.title,open:!K.has(e.key),onToggle:n=>((e,n)=>{void 0===y&&B(t=>{const l=new Set(t);return n?l.delete(e):l.add(e),l}),k?.(e,n)})(e.key,n),id:`${L}-fold-${t=e.key,[...t].map(e=>/[A-Za-z0-9_-]/.test(e)?e:`-u${e.codePointAt(0).toString(16)}-`).join("")}`,level:x,children:n});var t},Z=e=>T&&e!==A,X=({name:e,field:o,bucket:i,fold:s})=>/* @__PURE__ */$("div",{className:"es-insp-row","data-field":e,"data-bucket":i,hidden:!!Z(i)||void 0,children:/* @__PURE__ */$(Y,{field:o,name:e,id:`${L}-${e}`,value:n[e],onChange:n=>t(e,n),readOnly:l,context:a,showWhenContext:r,renderers:m,openItem:z&&z.name===e?z.index:null,onOpenItem:n=>W(null===n?null:{panel:L,name:e,index:n}),headingLevel:s?J(x):x})},e);/* @__PURE__ */
19
19
  return I("div",{className:"es-insp",children:[T?/* @__PURE__ */$("div",{className:"es-insp-tabs",children:/* @__PURE__ */$(C,{variant:"underline",block:!0,"aria-label":f??O.settings,idPrefix:L,value:A,onChange:e=>{const n=e;void 0===s&&E(n),c?.(n)},items:P.buckets.map(e=>{const n=O.buckets[e],t=u?.[e];return t?{id:e,icon:t,label:/* @__PURE__ */$("span",{className:"sr-only",children:n}),tooltip:n}:{id:e,label:n}})})}):null,
20
20
  /* @__PURE__ */I("div",{className:"es-insp-rows",id:H,role:T?"tabpanel":void 0,"aria-labelledby":T&&A?N(L,A):void 0,children:[b?v?/* @__PURE__ */$("div",{className:"es-insp-band","data-fold":v.key,children:Q(v,b)}):b:null,_(P.rows).map((e,n)=>{if(!e.fold)return e.rows.map(X);const t=e.rows[0].bucket,l=e.rows.every(e=>"slot"===e.field.type);/* @__PURE__ */
21
21
  return $("div",{className:"es-insp-band","data-fold":e.fold.key,"data-bucket":t,hidden:!(!Z(t)&&!l)||void 0,children:Q(e.fold,e.rows.map(X))},`fold-${e.fold.key}-${n}`)}),g]})]})}export{M as FieldText,ee as Inspector,Y as InspectorField,K as ListField,U as bucketsOf,H as copyItem,W as insertAt,Q as labelOf,z as moveTo,G as planFields,T as removeAt};