efficient-easel 12.0.0 → 13.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +24 -0
  2. package/dist/{canvas-typing-CZ11Y5tb.d.ts → canvas-typing-CC0wA-ys.d.ts} +1 -1
  3. package/dist/{chunk-4ES5JGGX.js → chunk-3Z2MVLCD.js} +1 -1
  4. package/dist/{chunk-5NM5TPAX.js → chunk-4EI6UGGH.js} +1 -1
  5. package/dist/{chunk-WY5U4XFO.js → chunk-52LIZZG4.js} +4 -4
  6. package/dist/chunk-6RLEHTMK.js +1 -0
  7. package/dist/{chunk-2SOOKBHH.js → chunk-BPZQ7S2Z.js} +16 -16
  8. package/dist/chunk-DWIOHQG7.js +1 -0
  9. package/dist/{chunk-47JTYRQC.js → chunk-FBS75I6E.js} +2 -2
  10. package/dist/chunk-FUMIBYUU.js +57 -0
  11. package/dist/chunk-FZ3Y3QTQ.js +5 -0
  12. package/dist/chunk-H5QI34FV.js +1 -0
  13. package/dist/{chunk-WUO2GBPO.js → chunk-IWFVVCRN.js} +1 -1
  14. package/dist/{chunk-5QP7ZE35.js → chunk-J2JDC3EZ.js} +1 -1
  15. package/dist/{chunk-CZYR5V77.js → chunk-J54OXLQF.js} +1 -1
  16. package/dist/chunk-M4CNCPHA.js +1 -0
  17. package/dist/{chunk-FHLYUIJJ.js → chunk-NBDMTIU2.js} +2 -2
  18. package/dist/{chunk-EC2I7SIY.js → chunk-NW4LJ4G4.js} +1 -1
  19. package/dist/chunk-NY7HHUGB.js +7 -0
  20. package/dist/chunk-OG2SKSSK.js +2 -0
  21. package/dist/chunk-PIND6KE7.js +1 -0
  22. package/dist/chunk-PVAIOBBE.js +13 -0
  23. package/dist/{chunk-X4VIDPKV.js → chunk-S2MMPHKD.js} +1 -1
  24. package/dist/{chunk-XY5ZHRMR.js → chunk-TLDRFVD2.js} +1 -1
  25. package/dist/chunk-YWUHPY5W.js +5 -0
  26. package/dist/copy/index.d.ts +4 -4
  27. package/dist/copy/index.js +18 -18
  28. package/dist/draw/client.d.ts +6 -0
  29. package/dist/draw/client.js +1 -0
  30. package/dist/draw/index.d.ts +8 -0
  31. package/dist/draw/index.js +1 -0
  32. package/dist/easel/index.d.ts +2 -2
  33. package/dist/easel/index.js +1 -1
  34. package/dist/fields/index.js +1 -1
  35. package/dist/icons/index.d.ts +3 -2
  36. package/dist/icons/index.js +1 -1
  37. package/dist/icons/meanings.d.ts +1 -0
  38. package/dist/icons/meanings.js +1 -0
  39. package/dist/index.js +1 -1
  40. package/dist/panel/index.js +1 -1
  41. package/dist/screen/components/AddBlockRow.js +1 -1
  42. package/dist/screen/components/AddSidePanel.js +1 -1
  43. package/dist/screen/components/MediaSidePanel.js +1 -1
  44. package/dist/screen/components/NodeContextMenu.d.ts +2 -2
  45. package/dist/screen/components/NodeContextMenu.js +1 -1
  46. package/dist/screen/components/PageEditGuardNotices.js +1 -1
  47. package/dist/screen/components/SaveControls.d.ts +2 -2
  48. package/dist/screen/components/ScreenChrome.js +1 -1
  49. package/dist/screen/components/ScreenDocumentContext.js +1 -1
  50. package/dist/screen/components/ScreenMount.d.ts +1 -1
  51. package/dist/screen/components/ScreenMount.js +1 -1
  52. package/dist/screen/components/ScreenStoreProvider.d.ts +2 -2
  53. package/dist/screen/components/ScreenStoreProvider.js +1 -1
  54. package/dist/screen/components/SectionScreenShell.js +15 -15
  55. package/dist/screen/components/UiIcon.d.ts +3 -1
  56. package/dist/screen/components/UiIcon.js +1 -2
  57. package/dist/screen/components/usePartBridge.d.ts +2 -2
  58. package/dist/screen/components/usePartBridge.js +1 -1
  59. package/dist/screen/index.d.ts +2 -2
  60. package/dist/screen/index.js +1 -1
  61. package/dist/screen/lib/content/view-tiers.js +1 -1
  62. package/dist/screen/lib/key-scope.js +1 -1
  63. package/dist/screen/lib/puck/device-fields.js +1 -1
  64. package/dist/screen/lib/puck/preview-dom.js +1 -1
  65. package/dist/screen/lib/puck/style-clipboard.d.ts +2 -2
  66. package/dist/screen/lib/puck/style-clipboard.js +1 -1
  67. package/dist/screen/lib/puck/text-control-kinds.js +1 -1
  68. package/dist/screen/lib/puck/use-section-ops.js +1 -1
  69. package/dist/screen/lib/screen-parts.d.ts +2 -2
  70. package/dist/screen/lib/screen-parts.js +1 -1
  71. package/dist/strings/catalogue.d.ts +1 -1
  72. package/dist/strings/catalogue.js +1 -1
  73. package/dist/strings/index.d.ts +1 -1
  74. package/dist/strings/index.js +1 -1
  75. package/dist/text-styles/index.js +26 -26
  76. package/dist/tree/index.d.ts +3 -2
  77. package/dist/{types-BLRK6_JO.d.ts → types-D8P9q-BG.d.ts} +7 -2
  78. package/dist/{words-notpwHR2.d.ts → words-CiuKuiy0.d.ts} +1 -1
  79. package/package.json +18 -3
  80. package/dist/chunk-5R7FE4VT.js +0 -57
  81. package/dist/chunk-KE2CXEIK.js +0 -13
  82. package/dist/chunk-KR4OCYRP.js +0 -1
  83. package/dist/chunk-LZS7JZK5.js +0 -1
  84. package/dist/chunk-O3RLI7XE.js +0 -1
  85. package/dist/chunk-UX7UJPC5.js +0 -5
  86. package/dist/chunk-WDQY6JMM.js +0 -7
  87. package/dist/chunk-WP7AZDCV.js +0 -5
package/README.md CHANGED
@@ -657,6 +657,30 @@ each level. A type the config does not know draws nothing.
657
657
  whose stylesheet has to reach it: `<Render … className="page" />`. Left out,
658
658
  the wrapper is bare and the markup is Puck's.
659
659
 
660
+ ## What a block draws with — `efficient-easel/draw`, `efficient-easel/draw/client`
661
+
662
+ A published page must not download the editor (card [PLAN] Keep Editor Code
663
+ Off Shopper Pages, 2026-10-19). Blocks used to reach a few small helpers
664
+ through `efficient-easel/screen/…`, the folder the whole editor screen lives
665
+ in, so a host could not forbid the editor on its published pages without a
666
+ list of exceptions. These two entries are that list, and the hosts' guards
667
+ allow a published page to take easel through `render`, `draw` and
668
+ `draw/client` only.
669
+
670
+ - `efficient-easel/draw` — pure functions and constants: `hidableText`,
671
+ `readHidable`, the part ids (`encodePartId`, `decodePartId`), the field
672
+ markers (`TEXT_FIELD_MARKER`, `textFieldIdentifier`, …), the text control
673
+ kinds, the slot-child names, the content-tree walkers (`childSlotsOf`,
674
+ `locateNode`, `pinnedDuplicateIndices`, …), the view tiers and the preview
675
+ event names. No React and no import: a server component may use it.
676
+ - `efficient-easel/draw/client` — the React pieces: `PreviewDeviceContext` /
677
+ `usePreviewDevice`, `PreviewPartsProvider` / `usePreviewParts`,
678
+ `createPreviewSelectionContext`, and `UiIcon`.
679
+
680
+ Nothing moved: each name is re-exported from the module that defines it, and
681
+ the `screen/…` paths still work. `tests/draw-leaf-safety.test.ts` holds each
682
+ graph to an exact list of files and imports.
683
+
660
684
  ## The canvas — `efficient-easel/canvas`
661
685
 
662
686
  `efficient-easel/canvas` (added in 0.70.0, blueprint step 2.1) is the one way
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
3
  import { MarkStyle, WrapResult, InlineRule, MarkupTool } from 'efficient-shell/markup';
4
- import { C as CopyWords, a as CopyAlign } from './words-notpwHR2.js';
4
+ import { C as CopyWords, a as CopyAlign } from './words-CiuKuiy0.js';
5
5
  import { TextToolbarCase, TextToolbarMark } from 'efficient-shell/ui';
6
6
 
7
7
  type CellWords = NonNullable<CopyWords['cells']>;
@@ -1 +1 @@
1
- import{HERO_SLIDER_GOTO_EVENT as t}from"./chunk-IQ5TA7AM.js";import{isPreviewClick as e}from"./chunk-R5L2E7JX.js";var n=()=>document.querySelector(".sf-editor #preview-frame");function o(t){e()||requestAnimationFrame(()=>{n()?.contentDocument?.querySelector(`[data-puck-component="${CSS.escape(t)}"]`)?.scrollIntoView({behavior:"smooth",block:"start"})})}function r(e,o){const r=n()?.contentWindow;if(!r)return;const c={id:e,index:o};r.dispatchEvent(new CustomEvent(t,{detail:c}))}function c(){requestAnimationFrame(()=>{n()?.contentWindow?.scrollTo({top:0,behavior:"smooth"})})}function u(t,{passes:e=[150,400],onPinned:o}={}){let r=0,c=!1;const u=[],i=()=>{const r=n(),s=r?.contentWindow,l=r?.contentDocument;if(!s||!l)return!1;const a=t(s,l);if(null==a)return!1;if(s.scrollTo({left:s.scrollX,top:a,behavior:"instant"}),!c){c=!0,o?.();for(const t of e)u.push(setTimeout(i,t))}return!0},s=()=>{!i()&&r++<150&&u.push(setTimeout(s,32))};return s(),()=>u.forEach(clearTimeout)}function i(t){return u((e,n)=>{const o=n.querySelector(`[data-puck-component="${CSS.escape(t)}"]`);return o?e.scrollY+o.getBoundingClientRect().top:null})}function s(t){return u((t,e)=>{if(!e.querySelector("[data-puck-component]"))return null;const n=Math.max(e.documentElement.scrollHeight,e.body?.scrollHeight??0);return n<=e.documentElement.clientHeight?null:n},{passes:[150,400,800,1300,2e3],onPinned:t})}export{r as gotoPreviewSlide,s as pinPreviewToBottom,i as pinPreviewToSection,n as previewFrame,o as scrollPreviewToSection,c as scrollPreviewToTop};
1
+ import{isPreviewClick as t}from"./chunk-R5L2E7JX.js";import{HERO_SLIDER_GOTO_EVENT as e}from"./chunk-IQ5TA7AM.js";var n=()=>document.querySelector(".sf-editor #preview-frame");function o(e){t()||requestAnimationFrame(()=>{n()?.contentDocument?.querySelector(`[data-puck-component="${CSS.escape(e)}"]`)?.scrollIntoView({behavior:"smooth",block:"start"})})}function r(t,o){const r=n()?.contentWindow;if(!r)return;const c={id:t,index:o};r.dispatchEvent(new CustomEvent(e,{detail:c}))}function c(){requestAnimationFrame(()=>{n()?.contentWindow?.scrollTo({top:0,behavior:"smooth"})})}function u(t,{passes:e=[150,400],onPinned:o}={}){let r=0,c=!1;const u=[],i=()=>{const r=n(),s=r?.contentWindow,l=r?.contentDocument;if(!s||!l)return!1;const a=t(s,l);if(null==a)return!1;if(s.scrollTo({left:s.scrollX,top:a,behavior:"instant"}),!c){c=!0,o?.();for(const t of e)u.push(setTimeout(i,t))}return!0},s=()=>{!i()&&r++<150&&u.push(setTimeout(s,32))};return s(),()=>u.forEach(clearTimeout)}function i(t){return u((e,n)=>{const o=n.querySelector(`[data-puck-component="${CSS.escape(t)}"]`);return o?e.scrollY+o.getBoundingClientRect().top:null})}function s(t){return u((t,e)=>{if(!e.querySelector("[data-puck-component]"))return null;const n=Math.max(e.documentElement.scrollHeight,e.body?.scrollHeight??0);return n<=e.documentElement.clientHeight?null:n},{passes:[150,400,800,1300,2e3],onPinned:t})}export{r as gotoPreviewSlide,s as pinPreviewToBottom,i as pinPreviewToSection,n as previewFrame,o as scrollPreviewToSection,c as scrollPreviewToTop};
@@ -1 +1 @@
1
- import{useEaselHost as n}from"./chunk-U3JP4VGF.js";import{useEaselApi as e,bindUndoKeys as t}from"./chunk-KE2CXEIK.js";import{useState as r,useEffect as o,useRef as u}from"react";function c(e){const t=n(),[u,c]=r(null);return o(()=>c(e.current),[e]),t.ownsDocument?"undefined"==typeof document?null:document:u}function i(r,u){const i=n(),s=e(),f=c(r);o(()=>{if(!i.ownsDocument&&f)return t(f,s,{leaveTyping:!0})},[i,s,f]);const m=u?.document??null;o(()=>{if(!i.ownsDocument&&m)return t(m,s,{leaveTyping:!0})},[i,s,m])}function s(n){return n.ownsDocument?{}:{tabIndex:-1}}function f(n){return!n.altKey&&!n.shiftKey&&(!(!n.metaKey&&!n.ctrlKey)&&("s"===n.key||"S"===n.key||"KeyS"===n.code))}function m(n,e,t){const r=c(n),i=u(t);o(()=>{i.current=t}),o(()=>{if(!r)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return r.addEventListener("keydown",n),()=>r.removeEventListener("keydown",n)},[r]);const s=e?.document??null;o(()=>{if(!s)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return s.addEventListener("keydown",n),()=>s.removeEventListener("keydown",n)},[s])}export{s as editorRootFocus,f as isSaveShortcut,c as useEaselKeyTarget,m as useEaselSaveKey,i as useEaselUndoKeys};
1
+ import{useEaselHost as n}from"./chunk-U3JP4VGF.js";import{useEaselApi as e,bindUndoKeys as t}from"./chunk-PVAIOBBE.js";import{useState as r,useEffect as o,useRef as u}from"react";function c(e){const t=n(),[u,c]=r(null);return o(()=>c(e.current),[e]),t.ownsDocument?"undefined"==typeof document?null:document:u}function i(r,u){const i=n(),s=e(),f=c(r);o(()=>{if(!i.ownsDocument&&f)return t(f,s,{leaveTyping:!0})},[i,s,f]);const m=u?.document??null;o(()=>{if(!i.ownsDocument&&m)return t(m,s,{leaveTyping:!0})},[i,s,m])}function s(n){return n.ownsDocument?{}:{tabIndex:-1}}function f(n){return!n.altKey&&!n.shiftKey&&(!(!n.metaKey&&!n.ctrlKey)&&("s"===n.key||"S"===n.key||"KeyS"===n.code))}function m(n,e,t){const r=c(n),i=u(t);o(()=>{i.current=t}),o(()=>{if(!r)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return r.addEventListener("keydown",n),()=>r.removeEventListener("keydown",n)},[r]);const s=e?.document??null;o(()=>{if(!s)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return s.addEventListener("keydown",n),()=>s.removeEventListener("keydown",n)},[s])}export{s as editorRootFocus,f as isSaveShortcut,c as useEaselKeyTarget,m as useEaselSaveKey,i as useEaselUndoKeys};
@@ -1,7 +1,7 @@
1
- import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenStoreProvider as n}from"./chunk-CZYR5V77.js";import{ScreenChrome as e}from"./chunk-5R7FE4VT.js";import{ScreenDocumentProvider as i,useScreenDocument as a}from"./chunk-47JTYRQC.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-VVPZMWJE.js";import{documentPermissions as s}from"./chunk-THWO5YVZ.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{useMemo as t,useState as d,useRef as l,useEffect as m,useCallback as g}from"react";import{Dialog as h,Button as f}from"efficient-shell/ui";import{jsx as u,jsxs as p,Fragment as v}from"react/jsx-runtime";var C=r(n),k=r(e);function j({onCancel:r,onDiscard:n,onSave:e}){const i=c("screen",o).leave,[a,s]=d(!1),t=l(!0);m(()=>(t.current=!0,()=>{t.current=!1}),[]);const C=g(async()=>{s(!0);try{await e()}finally{t.current&&s(!1)}},[e]);/* @__PURE__ */
1
+ import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenChrome as n}from"./chunk-FUMIBYUU.js";import{ScreenStoreProvider as e}from"./chunk-J54OXLQF.js";import{ScreenDocumentProvider as i,useScreenDocument as a}from"./chunk-FBS75I6E.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-VVPZMWJE.js";import{documentPermissions as s}from"./chunk-THWO5YVZ.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{useMemo as t,useState as d,useRef as l,useEffect as m,useCallback as g}from"react";import{Dialog as h,Button as f}from"efficient-shell/ui";import{jsx as u,jsxs as p,Fragment as v}from"react/jsx-runtime";var k=r(e),C=r(n);function j({onCancel:r,onDiscard:n,onSave:e}){const i=c("screen",o).leave,[a,s]=d(!1),t=l(!0);m(()=>(t.current=!0,()=>{t.current=!1}),[]);const k=g(async()=>{s(!0);try{await e()}finally{t.current&&s(!1)}},[e]);/* @__PURE__ */
2
2
  return u(h,{open:!0,role:"alertdialog",size:"sm",title:i.title,onClose:r,footer:/* @__PURE__ */p(v,{children:[
3
3
  /* @__PURE__ */u(f,{variant:"secondary",onClick:r,children:i.cancel}),
4
4
  /* @__PURE__ */u(f,{variant:"ghost-danger",onClick:n,children:i.discard}),
5
- /* @__PURE__ */u(f,{variant:"primary",loading:a,onClick:()=>{C()},children:i.save})]}),children:i.body})}function y({target:r,addressing:n,onHostMessage:e,children:a}){/* @__PURE__ */
6
- return u(i,{target:r,addressing:n,onHostMessage:e,children:a})}var N=(r,n)=>/* @__PURE__ */p(v,{children:[r,n]});function V({config:r,parts:n,wrap:e=N}){const{data:i,error:d,redirecting:l,ready:m,readOnly:g,onChange:h,pendingNav:f,cancelPendingNav:p,discardAndNavigate:v,saveAndNavigate:y}=a(),V=t(()=>s(!g),[g]),H=c("screen",o);return l?/* @__PURE__ */u("div",{className:"sf-msg",children:H.loading}):d?/* @__PURE__ */u("div",{className:"sf-msg sf-msg--error",children:d}):m?i?e(
7
- /* @__PURE__ */u(C,{config:r,data:i,onChange:h,permissions:V,parts:n,children:/* @__PURE__ */u(k,{})}),f&&/* @__PURE__ */u(j,{onCancel:p,onDiscard:v,onSave:y})):/* @__PURE__ */u("div",{className:"sf-msg",children:H.loading}):/* @__PURE__ */u("div",{className:"sf-msg",children:H.waitingForAuthorization})}export{V as DocumentScreen,y as ScreenMount};
5
+ /* @__PURE__ */u(f,{variant:"primary",loading:a,onClick:()=>{k()},children:i.save})]}),children:i.body})}function y({target:r,addressing:n,onHostMessage:e,children:a}){/* @__PURE__ */
6
+ return u(i,{target:r,addressing:n,onHostMessage:e,children:a})}var N=(r,n)=>/* @__PURE__ */p(v,{children:[r,n]});function F({config:r,parts:n,wrap:e=N}){const{data:i,error:d,redirecting:l,ready:m,readOnly:g,onChange:h,pendingNav:f,cancelPendingNav:p,discardAndNavigate:v,saveAndNavigate:y}=a(),F=t(()=>s(!g),[g]),M=c("screen",o);return l?/* @__PURE__ */u("div",{className:"sf-msg",children:M.loading}):d?/* @__PURE__ */u("div",{className:"sf-msg sf-msg--error",children:d}):m?i?e(
7
+ /* @__PURE__ */u(k,{config:r,data:i,onChange:h,permissions:F,parts:n,children:/* @__PURE__ */u(C,{})}),f&&/* @__PURE__ */u(j,{onCancel:p,onDiscard:v,onSave:y})):/* @__PURE__ */u("div",{className:"sf-msg",children:M.loading}):/* @__PURE__ */u("div",{className:"sf-msg",children:M.waitingForAuthorization})}export{F as DocumentScreen,y as ScreenMount};
@@ -0,0 +1 @@
1
+ import{DEFAULT_TEXT_STYLES_WORDS as o}from"./chunk-OGH6CC3E.js";import{DEFAULT_PICK_WORDS as r}from"./chunk-643PVCEG.js";import{DEFAULT_SCREEN_WORDS as t}from"./chunk-VVPZMWJE.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as m}from"./chunk-6WY6ZXJG.js";import{DEFAULT_NODE_MENU_WORDS as n}from"./chunk-WK3AFPXY.js";import{DEFAULT_CANVAS_WORDS as c}from"./chunk-TBY3DFKS.js";import{DEFAULT_TREE_WORDS as s}from"./chunk-K56YDHYQ.js";import{DEFAULT_PANEL_WORDS as f}from"./chunk-KFV7N2DJ.js";import{DEFAULT_SAVE_WORDS as p}from"./chunk-H6DDIBQ4.js";import{DEFAULT_COPY_WORDS as e}from"./chunk-33C6ALT5.js";import{DEFAULT_FIELDS_WORDS as i}from"./chunk-WRFD4EXD.js";import{DEFAULT_CHROME_WORDS as u,DEFAULT_NOTICE_WORDS as k}from"./chunk-Z6PVRXVY.js";import{DEFAULT_LOCK_WORDS as j}from"./chunk-RE4LP46F.js";import{DEFAULT_RAIL_WORDS as h}from"./chunk-2OAZYSWJ.js";import{DEFAULT_DRAG_WORDS as l}from"./chunk-AYWN5NRH.js";var a={notice:k,lock:j,save:p,chrome:u,rail:h,tree:s,panel:f,fields:i,pick:r,drag:l,menu:n,styleClipboard:m,copy:e,canvas:c,textStyles:o,screen:t},Y=o=>"object"==typeof o&&null!==o;function y(o,r){const t={};for(const m of Object.keys(o)){const n=o[m],c=r[m];null==c?t[m]=n:Y(n)?t[m]=Y(c)?y(n,c):n:t[m]=typeof c==typeof n?c:n}return t}function D(o,r){return r?y(o,r):o}export{a as DEFAULT_EASEL_STRINGS,D as mergeEaselStrings};
@@ -1,21 +1,21 @@
1
- import{TreeSeam as e}from"./chunk-4JSBIW5H.js";import{SETTINGS_BUCKETS as n,SettingsGroup as l}from"./chunk-RC25EGHD.js";import{DEFAULT_TREE_WORDS as t}from"./chunk-K56YDHYQ.js";import{DEFAULT_PANEL_WORDS as a}from"./chunk-KFV7N2DJ.js";import{EaselMenuItems as r}from"./chunk-EA2HTX37.js";import{useTreeDrag as o,gapToMoveIndex as i}from"./chunk-67GNT6PF.js";import{withTip as s}from"./chunk-P2VEMZH5.js";import{FieldNumber as c}from"./chunk-2XMHLXMA.js";import{FieldSelect as d}from"./chunk-G3GWAP5R.js";import{SettingsField as u,SettingsSegmented as m}from"./chunk-36LVP5WD.js";import{DEFAULT_FIELDS_WORDS as p}from"./chunk-WRFD4EXD.js";import{useWords as h}from"./chunk-MFIRYGHW.js";import{Textarea as f,Input as b,SortableList as g,ListRow as v,ContextMenu as y,tabPanelId as k,Tabs as x,tabButtonId as w}from"efficient-shell/ui";export{LinkPicker}from"efficient-shell/ui";import{useRef as N,useState as C,useLayoutEffect as O,useId as $}from"react";import{jsx as j,jsxs as D}from"react/jsx-runtime";import{ChevronIcon as S,LockIcon as I,MoveUpIcon as P,MoveDownIcon as L,DuplicateIcon as F,TrashIcon as M}from"efficient-shell/icons/efficient";function R({id:e,value:n,onChange:l,placeholder:t,multiline:a=!1,rows:r=3,readOnly:o=!1,ariaLabel:i,ariaLabelledBy:s}){const c=n??"";return a?/* @__PURE__ */j(f,{id:e,size:"sm",className:"es-fin",value:c,rows:r,placeholder:t,readOnly:o,"aria-label":i,"aria-labelledby":s,onChange:e=>l(e.target.value)}):/* @__PURE__ */j(b,{id:e,size:"sm",className:"es-fin",type:"text",value:c,placeholder:t,readOnly:o,"aria-label":i,"aria-labelledby":s,onChange:e=>l(e.target.value)})}function E(e,n,l){const t=e.slice();return t.splice(Math.max(0,Math.min(n,t.length)),0,l),t}function T(e,n,l){const t=e.slice(),[a]=t.splice(n,1);return t.splice(Math.max(0,Math.min(l,t.length)),0,a),t}function A(e,n){return e.filter((e,l)=>l!==n)}function H(e){return null===e||"object"!=typeof e?e:JSON.parse(JSON.stringify(e))}var z='input, textarea, select, button, [contenteditable]:not([contenteditable="false"]), [tabindex]',B={parentId:"list",slot:"items"};function G({label:n,icon:l,noun:a,items:c,onChange:d,newItem:u,summary:m,itemName:f,thumb:b,min:k=0,max:x,readOnly:w=!1,open:$,onOpen:R,renderItem:G,renderRow:K,canRemove:W,lockedReason:X,fixed:J=!1,removeOnRow:V=!0,canDuplicate:Y,above:q,head:Z=!0}){const Q=h("fields",p).list,U=h("tree",t),_=a??Q.item,ee=!w&&!J&&("number"!=typeof x||c.length<x),ne=c.length<=k,le=e=>!!W&&!W(c[e],e),te=e=>!w&&!J&&V&&!ne&&!le(e),ae=e=>ee&&(!Y||Y(c[e],e)),re=(e,n)=>f?f(e,n):Q.itemName({noun:_,n:n+1}),oe=N([]),ie=N(null),[se,ce]=C(null),de=N(null),[ue,me]=C(null),[pe,he]=C("");O(()=>{const e=ie.current;if(!e)return;ie.current=null;const n=oe.current[e.index]?.querySelectorAll(z)[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>=c.length||n===e)return;const l=oe.current[e],t=l?.ownerDocument.activeElement;if(l&&t&&l.contains(t)){const e=[...l.querySelectorAll(z)].indexOf(t),a=t;ie.current={index:n,nth:e,start:"number"==typeof a.selectionStart?a.selectionStart:null,end:"number"==typeof a.selectionEnd?a.selectionEnd:null}}d(T(c,e,n));const a=function(e,n,l){return null===e?null:e===n?l:n<e&&l>=e?e-1:n>e&&l<=e?e+1:e}($,e,n);a!==$&&R(a),he(Q.moved({n:n+1,total:c.length}))},be=e=>{ee&&(d(E(c,e,u())),K?(ie.current={index:e,nth:0,start:null,end:null},null!==$&&$>=e&&R($+1)):R(e))},ge=e=>{te(e)&&(d(A(c,e)),$===e?R(null):null!==$&&$>e&&R($-1))},ve=o({keyOf:e=>String(e),canDrop:(e,n)=>n.parentId===B.parentId&&n.slot===B.slot,onDrop:(e,n)=>{const l=i({...B,index:e},n);l!==e&&fe(e,l)},onStep:(e,n)=>fe(e,e+n),canStep:(e,n)=>e+n>=0&&e+n<c.length,readOnly:w}),ye=e=>{const n=[];return e>0&&n.push({label:Q.moveUp,icon:/* @__PURE__ */j(P,{size:14}),shortcut:"⌥↑",onClick:()=>fe(e,e-1)}),e<c.length-1&&n.push({label:Q.moveDown,icon:/* @__PURE__ */j(L,{size:14}),shortcut:"⌥↓",onClick:()=>fe(e,e+1)}),ae(e)&&n.push({label:Q.duplicate,icon:/* @__PURE__ */j(F,{size:14}),onClick:()=>(e=>{ae(e)&&(d(E(c,e+1,H(c[e]))),null!==$&&$>e&&R($+1))})(e)}),te(e)&&n.push({label:Q.delete,icon:/* @__PURE__ */j(M,{size:14}),danger:!0,onClick:()=>ge(e)}),n},ke=(e,n,l,t)=>{w||0===ye(e).length||me({index:e,x:n,y:l,owner:t})},xe=e=>n=>{const l=c.slice();l[e]=n,d(l)};/* @__PURE__ */
1
+ import{TreeSeam as e}from"./chunk-4JSBIW5H.js";import{DEFAULT_TREE_WORDS as n}from"./chunk-K56YDHYQ.js";import{EaselMenuItems as l}from"./chunk-EA2HTX37.js";import{SETTINGS_BUCKETS as t,SettingsGroup as a}from"./chunk-RC25EGHD.js";import{DEFAULT_PANEL_WORDS as r}from"./chunk-KFV7N2DJ.js";import{FieldNumber as o}from"./chunk-2XMHLXMA.js";import{FieldSelect as i}from"./chunk-G3GWAP5R.js";import{DEFAULT_FIELDS_WORDS as s}from"./chunk-WRFD4EXD.js";import{SettingsField as c,SettingsSegmented as d}from"./chunk-36LVP5WD.js";import{useWords as u}from"./chunk-MFIRYGHW.js";import{useTreeDrag as m,gapToMoveIndex as p}from"./chunk-67GNT6PF.js";import{withTip as h}from"./chunk-P2VEMZH5.js";import{Textarea as f,Input as b,SortableList as g,ListRow as v,ContextMenu as y,tabPanelId as k,Tabs as x,tabButtonId as w}from"efficient-shell/ui";export{LinkPicker}from"efficient-shell/ui";import{useRef as N,useState as C,useLayoutEffect as O,useId as $}from"react";import{jsx as j,jsxs as D}from"react/jsx-runtime";import{ChevronIcon as S,LockIcon as I,MoveUpIcon as P,MoveDownIcon as L,DuplicateIcon as F,TrashIcon as M}from"efficient-shell/icons/efficient";function R({id:e,value:n,onChange:l,placeholder:t,multiline:a=!1,rows:r=3,readOnly:o=!1,ariaLabel:i,ariaLabelledBy:s}){const c=n??"";return a?/* @__PURE__ */j(f,{id:e,size:"sm",className:"es-fin",value:c,rows:r,placeholder:t,readOnly:o,"aria-label":i,"aria-labelledby":s,onChange:e=>l(e.target.value)}):/* @__PURE__ */j(b,{id:e,size:"sm",className:"es-fin",type:"text",value:c,placeholder:t,readOnly:o,"aria-label":i,"aria-labelledby":s,onChange:e=>l(e.target.value)})}function E(e,n,l){const t=e.slice();return t.splice(Math.max(0,Math.min(n,t.length)),0,l),t}function T(e,n,l){const t=e.slice(),[a]=t.splice(n,1);return t.splice(Math.max(0,Math.min(l,t.length)),0,a),t}function A(e,n){return e.filter((e,l)=>l!==n)}function H(e){return null===e||"object"!=typeof e?e:JSON.parse(JSON.stringify(e))}var z='input, textarea, select, button, [contenteditable]:not([contenteditable="false"]), [tabindex]',B={parentId:"list",slot:"items"};function G({label:t,icon:a,noun:r,items:o,onChange:i,newItem:c,summary:d,itemName:f,thumb:b,min:k=0,max:x,readOnly:w=!1,open:$,onOpen:R,renderItem:G,renderRow:K,canRemove:W,lockedReason:X,fixed:J=!1,removeOnRow:V=!0,canDuplicate:Y,above:q,head:Z=!0}){const Q=u("fields",s).list,U=u("tree",n),_=r??Q.item,ee=!w&&!J&&("number"!=typeof x||o.length<x),ne=o.length<=k,le=e=>!!W&&!W(o[e],e),te=e=>!w&&!J&&V&&!ne&&!le(e),ae=e=>ee&&(!Y||Y(o[e],e)),re=(e,n)=>f?f(e,n):Q.itemName({noun:_,n:n+1}),oe=N([]),ie=N(null),[se,ce]=C(null),de=N(null),[ue,me]=C(null),[pe,he]=C("");O(()=>{const e=ie.current;if(!e)return;ie.current=null;const n=oe.current[e.index]?.querySelectorAll(z)[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 l=oe.current[e],t=l?.ownerDocument.activeElement;if(l&&t&&l.contains(t)){const e=[...l.querySelectorAll(z)].indexOf(t),a=t;ie.current={index:n,nth:e,start:"number"==typeof a.selectionStart?a.selectionStart:null,end:"number"==typeof a.selectionEnd?a.selectionEnd:null}}i(T(o,e,n));const a=function(e,n,l){return null===e?null:e===n?l:n<e&&l>=e?e-1:n>e&&l<=e?e+1:e}($,e,n);a!==$&&R(a),he(Q.moved({n:n+1,total:o.length}))},be=e=>{ee&&(i(E(o,e,c())),K?(ie.current={index:e,nth:0,start:null,end:null},null!==$&&$>=e&&R($+1)):R(e))},ge=e=>{te(e)&&(i(A(o,e)),$===e?R(null):null!==$&&$>e&&R($-1))},ve=m({keyOf:e=>String(e),canDrop:(e,n)=>n.parentId===B.parentId&&n.slot===B.slot,onDrop:(e,n)=>{const l=p({...B,index:e},n);l!==e&&fe(e,l)},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:Q.moveUp,icon:/* @__PURE__ */j(P,{size:14}),shortcut:"⌥↑",onClick:()=>fe(e,e-1)}),e<o.length-1&&n.push({label:Q.moveDown,icon:/* @__PURE__ */j(L,{size:14}),shortcut:"⌥↓",onClick:()=>fe(e,e+1)}),ae(e)&&n.push({label:Q.duplicate,icon:/* @__PURE__ */j(F,{size:14}),onClick:()=>(e=>{ae(e)&&(i(E(o,e+1,H(o[e]))),null!==$&&$>e&&R($+1))})(e)}),te(e)&&n.push({label:Q.delete,icon:/* @__PURE__ */j(M,{size:14}),danger:!0,onClick:()=>ge(e)}),n},ke=(e,n,l,t)=>{w||0===ye(e).length||me({index:e,x:n,y:l,owner:t})},xe=e=>n=>{const l=o.slice();l[e]=n,i(l)};/* @__PURE__ */
2
2
  return D("div",{className:"es-list",children:[Z?/* @__PURE__ */D("div",{className:"es-list-head",children:[
3
- /* @__PURE__ */D("span",{className:"es-list-label",children:[l?/* @__PURE__ */j("span",{className:"es-field-icon","aria-hidden":"true",children:l}):null,n]}),
4
- /* @__PURE__ */j("span",{className:"es-list-count",children:c.length})]}):null,q?/* @__PURE__ */j("div",{className:"es-list-above",children:q}):null,c.length?/* @__PURE__ */D(g,{"aria-label":n,spacing:"comfortable",className:"es-list-rows",rootProps:ve.rootProps(),children:[c.map((n,l)=>{const t=ve.row({item:l,place:{...B,index:l}}),a=t.draggable&&se!==l,r=!K&&$===l,o=!w&&!J&&V&&le(l),i=["es-list-row",K?"is-inline":"is-item",r?"is-open":"",a?"is-draggable":"",t.dragging?"is-dragging":"",t.drop?`is-drop-${t.drop}`:""].filter(Boolean).join(" ");return[l>0?/* @__PURE__ */j(e,{...ve.seam({place:{...B,index:l}}),onAdd:ee?()=>be(l):void 0,label:Q.addHere({noun:_})},`seam-${l}`):null,
5
- /* @__PURE__ */j(v,{className:i,flat:!!K,active:r,draggable:t.draggable,dragHint:U.dragHint,dragging:t.dragging,drop:"before"===t.drop||"after"===t.drop?t.drop:void 0,onMove:t.draggable?e=>fe(l,"up"===e?l-1:l+1):void 0,rowRef:e=>{oe.current[l]=e},rowProps:{...t.rowProps,draggable:a||void 0,onPointerDown:e=>{const n=e.target.closest?.('input, textarea, select, [contenteditable]:not([contenteditable="false"])'),a=!!n&&n===n.ownerDocument.activeElement;e.currentTarget.draggable=t.draggable&&!a,de.current=n&&!a?n:null,ce(a?l:null)},onDragStart:e=>{const n=de.current;de.current=null,n&&n.ownerDocument.activeElement===n&&n.blur(),t.rowProps.onDragStart?.(e)},onContextMenu:e=>{w||(e.preventDefault(),e.stopPropagation(),ke(l,e.clientX,e.clientY,e.currentTarget))},onKeyDown:e=>{if("ContextMenu"===e.key||e.shiftKey&&"F10"===e.key){e.preventDefault();const n=e.currentTarget.ownerDocument,t=e=>e.preventDefault();n.addEventListener("contextmenu",t,{capture:!0,once:!0}),n.defaultView?.setTimeout(()=>n.removeEventListener("contextmenu",t,{capture:!0}),500);const a=e.currentTarget.getBoundingClientRect();return void ke(l,a.left+24,a.bottom,e.currentTarget)}t.rowProps.onKeyDown?.(e)}},actions:w||J||!V?void 0:o?s(X?X(n,l):Q.locked,/* @__PURE__ */j("span",{className:"es-list-lock",role:"img","aria-label":X?X(n,l):Q.locked,children:/* @__PURE__ */j(I,{size:13})})):s(Q.deleteItem({noun:_}),/* @__PURE__ */j("button",{type:"button",className:"es-list-x","aria-label":Q.deleteItem({noun:_}),disabled:!te(l),onClick:()=>ge(l),children:"×"})),below:r?/* @__PURE__ */j("div",{className:"es-list-item",children:G(n,l,xe(l))}):void 0,children:K?/* @__PURE__ */j("div",{className:"es-list-row-main",children:K(n,l,xe(l))}):/* @__PURE__ */D("button",{type:"button",className:"es-list-open","aria-expanded":r,onClick:()=>R(r?null:l),children:[b?/* @__PURE__ */j("span",{className:"es-list-thumb","aria-hidden":"true",children:b(n,l)}):null,
6
- /* @__PURE__ */j("span",{className:"es-list-row-name",children:re(n,l)}),/* @__PURE__ */j("span",m?{className:"es-list-row-summary",children:m(n,l)}:{className:"es-list-row-summary"}),
3
+ /* @__PURE__ */D("span",{className:"es-list-label",children:[a?/* @__PURE__ */j("span",{className:"es-field-icon","aria-hidden":"true",children:a}):null,t]}),
4
+ /* @__PURE__ */j("span",{className:"es-list-count",children:o.length})]}):null,q?/* @__PURE__ */j("div",{className:"es-list-above",children:q}):null,o.length?/* @__PURE__ */D(g,{"aria-label":t,spacing:"comfortable",className:"es-list-rows",rootProps:ve.rootProps(),children:[o.map((n,l)=>{const t=ve.row({item:l,place:{...B,index:l}}),a=t.draggable&&se!==l,r=!K&&$===l,o=!w&&!J&&V&&le(l),i=["es-list-row",K?"is-inline":"is-item",r?"is-open":"",a?"is-draggable":"",t.dragging?"is-dragging":"",t.drop?`is-drop-${t.drop}`:""].filter(Boolean).join(" ");return[l>0?/* @__PURE__ */j(e,{...ve.seam({place:{...B,index:l}}),onAdd:ee?()=>be(l):void 0,label:Q.addHere({noun:_})},`seam-${l}`):null,
5
+ /* @__PURE__ */j(v,{className:i,flat:!!K,active:r,draggable:t.draggable,dragHint:U.dragHint,dragging:t.dragging,drop:"before"===t.drop||"after"===t.drop?t.drop:void 0,onMove:t.draggable?e=>fe(l,"up"===e?l-1:l+1):void 0,rowRef:e=>{oe.current[l]=e},rowProps:{...t.rowProps,draggable:a||void 0,onPointerDown:e=>{const n=e.target.closest?.('input, textarea, select, [contenteditable]:not([contenteditable="false"])'),a=!!n&&n===n.ownerDocument.activeElement;e.currentTarget.draggable=t.draggable&&!a,de.current=n&&!a?n:null,ce(a?l:null)},onDragStart:e=>{const n=de.current;de.current=null,n&&n.ownerDocument.activeElement===n&&n.blur(),t.rowProps.onDragStart?.(e)},onContextMenu:e=>{w||(e.preventDefault(),e.stopPropagation(),ke(l,e.clientX,e.clientY,e.currentTarget))},onKeyDown:e=>{if("ContextMenu"===e.key||e.shiftKey&&"F10"===e.key){e.preventDefault();const n=e.currentTarget.ownerDocument,t=e=>e.preventDefault();n.addEventListener("contextmenu",t,{capture:!0,once:!0}),n.defaultView?.setTimeout(()=>n.removeEventListener("contextmenu",t,{capture:!0}),500);const a=e.currentTarget.getBoundingClientRect();return void ke(l,a.left+24,a.bottom,e.currentTarget)}t.rowProps.onKeyDown?.(e)}},actions:w||J||!V?void 0:o?h(X?X(n,l):Q.locked,/* @__PURE__ */j("span",{className:"es-list-lock",role:"img","aria-label":X?X(n,l):Q.locked,children:/* @__PURE__ */j(I,{size:13})})):h(Q.deleteItem({noun:_}),/* @__PURE__ */j("button",{type:"button",className:"es-list-x","aria-label":Q.deleteItem({noun:_}),disabled:!te(l),onClick:()=>ge(l),children:"×"})),below:r?/* @__PURE__ */j("div",{className:"es-list-item",children:G(n,l,xe(l))}):void 0,children:K?/* @__PURE__ */j("div",{className:"es-list-row-main",children:K(n,l,xe(l))}):/* @__PURE__ */D("button",{type:"button",className:"es-list-open","aria-expanded":r,onClick:()=>R(r?null:l),children:[b?/* @__PURE__ */j("span",{className:"es-list-thumb","aria-hidden":"true",children:b(n,l)}):null,
6
+ /* @__PURE__ */j("span",{className:"es-list-row-name",children:re(n,l)}),/* @__PURE__ */j("span",d?{className:"es-list-row-summary",children:d(n,l)}:{className:"es-list-row-summary"}),
7
7
  /* @__PURE__ */j(S,{size:14,className:"es-list-chev","aria-hidden":"true"})]})},l)]}),
8
- /* @__PURE__ */j(e,{...ve.seam({place:{...B,index:c.length}})})]}):null,w||J?null:/* @__PURE__ */j("button",{type:"button",className:"es-list-add",disabled:!ee,onClick:()=>be(c.length),children:Q.add({noun:_})}),
9
- /* @__PURE__ */j("span",{className:"es-list-said","aria-live":"polite",children:pe}),ue&&ue.index<c.length?
10
- /* @__PURE__ */j(y,{at:{x:ue.x,y:ue.y},owner:ue.owner,onClose:()=>me(null),children:/* @__PURE__ */j(r,{items:ye(ue.index),onClose:()=>me(null)})}):null]})}var K=e=>e<6?e+1:6,W=(e,n)=>"string"==typeof e.label&&e.label?e.label:n;function X({field:e,name:n,id:t,value:a,onChange:r,readOnly:o,context:i,renderers:s,headingLevel:c=3}){const[d,u]=C(!0),m=a&&"object"==typeof a?a:{};/* @__PURE__ */
11
- return j(l,{id:`${t}-group`,title:W(e,n),open:d,onToggle:u,level:c,children:Object.entries(e.objectFields).map(([e,l])=>/* @__PURE__ */j(V,{field:l,name:`${n}.${e}`,id:`${t}-${e}`,value:m[e],onChange:n=>r({...m,[e]:n}),readOnly:o,context:i,renderers:s,headingLevel:K(c)},e))})}function J({field:e,name:n,id:l,value:t,onChange:a,readOnly:r,context:o,renderers:i,openItem:s,onOpenItem:c,headingLevel:d}){const[u,m]=C(null),p=c?s??null:u,h=c??m,f=Array.isArray(t)?t:[],b=e.getItemSummary;/* @__PURE__ */
12
- return j(G,{label:W(e,n),icon:e.icon,noun:"string"==typeof e.noun?e.noun:void 0,items:f,onChange:a,newItem:()=>H({...e.defaultItemProps??{}}),summary:b?(e,n)=>b(e,n):void 0,min:e.min,max:e.max,readOnly:r,open:p,onOpen:h,renderItem:(t,a,s)=>Object.entries(e.arrayFields).map(([e,c])=>/* @__PURE__ */j(V,{field:c,name:`${n}[${a}].${e}`,id:`${l}-${a}-${e}`,value:t?.[e],onChange:n=>s({...t,[e]:n}),readOnly:r,context:o,renderers:i,headingLevel:d},e))})}function V(e){const{field:n,name:l,id:t,value:a,onChange:r,readOnly:o,context:i,renderers:s}=e;if(!n||n.marker||!1===n.visible)return null;const p=s?.[n.type];if(p)return p({field:n,name:l,id:t,value:a,onChange:r,readOnly:o});switch(n.type){case"custom":{const e={...i,field:n,name:l,id:t,value:a,onChange:r,readOnly:o};return n.render(e)}case"text":case"textarea":/* @__PURE__ */
13
- return j(u,{label:W(n,l),htmlFor:t,icon:n.icon,hint:n.hint,children:/* @__PURE__ */j(R,{id:t,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 j(u,{label:W(n,l),htmlFor:t,icon:n.icon,hint:n.hint,children:/* @__PURE__ */j(c,{id:t,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=`${t}-label`;/* @__PURE__ */
15
- return j(u,{label:W(n,l),labelId:e,htmlFor:t,icon:n.icon,hint:n.hint,children:/* @__PURE__ */j(d,{id:t,value:a,options:n.options,onChange:r,readOnly:o,ariaLabelledBy:e})})}case"radio":/* @__PURE__ */
16
- return j(u,{label:W(n,l),icon:n.icon,hint:n.hint,children:/* @__PURE__ */j(m,{ariaLabel:W(n,l),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__ */j(e,{...ve.seam({place:{...B,index:o.length}})})]}):null,w||J?null:/* @__PURE__ */j("button",{type:"button",className:"es-list-add",disabled:!ee,onClick:()=>be(o.length),children:Q.add({noun:_})}),
9
+ /* @__PURE__ */j("span",{className:"es-list-said","aria-live":"polite",children:pe}),ue&&ue.index<o.length?
10
+ /* @__PURE__ */j(y,{at:{x:ue.x,y:ue.y},owner:ue.owner,onClose:()=>me(null),children:/* @__PURE__ */j(l,{items:ye(ue.index),onClose:()=>me(null)})}):null]})}var K=e=>e<6?e+1:6,W=(e,n)=>"string"==typeof e.label&&e.label?e.label:n;function X({field:e,name:n,id:l,value:t,onChange:r,readOnly:o,context:i,renderers:s,headingLevel:c=3}){const[d,u]=C(!0),m=t&&"object"==typeof t?t:{};/* @__PURE__ */
11
+ return j(a,{id:`${l}-group`,title:W(e,n),open:d,onToggle:u,level:c,children:Object.entries(e.objectFields).map(([e,t])=>/* @__PURE__ */j(V,{field:t,name:`${n}.${e}`,id:`${l}-${e}`,value:m[e],onChange:n=>r({...m,[e]:n}),readOnly:o,context:i,renderers:s,headingLevel:K(c)},e))})}function J({field:e,name:n,id:l,value:t,onChange:a,readOnly:r,context:o,renderers:i,openItem:s,onOpenItem:c,headingLevel:d}){const[u,m]=C(null),p=c?s??null:u,h=c??m,f=Array.isArray(t)?t:[],b=e.getItemSummary;/* @__PURE__ */
12
+ return j(G,{label:W(e,n),icon:e.icon,noun:"string"==typeof e.noun?e.noun:void 0,items:f,onChange:a,newItem:()=>H({...e.defaultItemProps??{}}),summary:b?(e,n)=>b(e,n):void 0,min:e.min,max:e.max,readOnly:r,open:p,onOpen:h,renderItem:(t,a,s)=>Object.entries(e.arrayFields).map(([e,c])=>/* @__PURE__ */j(V,{field:c,name:`${n}[${a}].${e}`,id:`${l}-${a}-${e}`,value:t?.[e],onChange:n=>s({...t,[e]:n}),readOnly:r,context:o,renderers:i,headingLevel:d},e))})}function V(e){const{field:n,name:l,id:t,value:a,onChange:r,readOnly:s,context:u,renderers:m}=e;if(!n||n.marker||!1===n.visible)return null;const p=m?.[n.type];if(p)return p({field:n,name:l,id:t,value:a,onChange:r,readOnly:s});switch(n.type){case"custom":{const e={...u,field:n,name:l,id:t,value:a,onChange:r,readOnly:s};return n.render(e)}case"text":case"textarea":/* @__PURE__ */
13
+ return j(c,{label:W(n,l),htmlFor:t,icon:n.icon,hint:n.hint,children:/* @__PURE__ */j(R,{id:t,value:"string"==typeof a?a:null==a?"":String(a),onChange:r,placeholder:n.placeholder,multiline:"textarea"===n.type,readOnly:s})});case"number":/* @__PURE__ */
14
+ return j(c,{label:W(n,l),htmlFor:t,icon:n.icon,hint:n.hint,children:/* @__PURE__ */j(o,{id:t,value:"number"==typeof a?a:void 0,onChange:r,min:n.min,max:n.max,step:n.step,placeholder:n.placeholder,readOnly:s})});case"select":{const e=`${t}-label`;/* @__PURE__ */
15
+ return j(c,{label:W(n,l),labelId:e,htmlFor:t,icon:n.icon,hint:n.hint,children:/* @__PURE__ */j(i,{id:t,value:a,options:n.options,onChange:r,readOnly:s,ariaLabelledBy:e})})}case"radio":/* @__PURE__ */
16
+ return j(c,{label:W(n,l),icon:n.icon,hint:n.hint,children:/* @__PURE__ */j(d,{ariaLabel:W(n,l),value:a,options:n.options.map(e=>({id:e.value,label:e.label,icon:e.icon,disabled:e.disabled||s})),onChange:e=>{s||r(e)}})});case"object":/* @__PURE__ */
17
17
  return j(X,{...e,field:n});case"array":/* @__PURE__ */
18
- return j(J,{...e,field:n});case"slot":return null}}var Y=e=>n.includes(e);function q(e){let l,t=n[0];const a=[],r=/* @__PURE__ */new Set;for(const[n,o]of Object.entries(e))o&&(Y(o.bucket)&&((o.marker||o.bucket!==t)&&(l=void 0),t=o.bucket),o.marker&&"string"==typeof o.fold?l={key:n,title:o.fold}:o.marker&&!1===o.fold&&(l=void 0),o.marker||!1===o.visible||(a.push(l?{name:n,field:o,bucket:t,fold:l}:{name:n,field:o,bucket:t}),"slot"!==o.type&&r.add(t)));return{rows:a,buckets:n.filter(e=>r.has(e))}}function Z(e){return new Map(q(e).rows.map(e=>[e.name,e.bucket]))}function Q(e){const n=[];for(const l of e){const e=n[n.length-1];e&&e.fold?.key===l.fold?.key?e.rows.push(l):n.push({fold:l.fold,rows:[l]})}return n}function U({fields:e,values:n,onChange:t,readOnly:r=!1,context:o,tab:i,onTab:s,tabs:c=!0,tabIcons:d,renderers:u,idPrefix:m,ariaLabel:p,lead:f,children:b,leadFold:g,closedFolds:v,onFold:y,headingLevel:N=3}){const O=h("panel",a),S=$(),I=m??`es-insp${S.replace(/:/g,"")}`,P=q(e),[L,F]=C(void 0),M=i??L,R=M&&P.buckets.includes(M)?M:P.buckets[0],[E,T]=C(null),A=E&&E.panel===I&&P.rows.some(e=>e.name===E.name)?E:null,H=c&&P.buckets.length>1,z=H&&R?k(I,R):`${I}-rows`,[B,G]=C(()=>/* @__PURE__ */new Set),W=v??B,X=(e,n)=>{/* @__PURE__ */return j(l,{title:e.title,open:!W.has(e.key),onToggle:n=>((e,n)=>{void 0===v&&G(l=>{const t=new Set(l);return n?t.delete(e):t.add(e),t}),y?.(e,n)})(e.key,n),id:`${I}-fold-${t=e.key,[...t].map(e=>/[A-Za-z0-9_-]/.test(e)?e:`-u${e.codePointAt(0).toString(16)}-`).join("")}`,level:N,children:n});var t},J=e=>H&&e!==R,Y=({name:e,field:l,bucket:a,fold:i})=>/* @__PURE__ */j("div",{className:"es-insp-row","data-field":e,"data-bucket":a,hidden:!!J(a)||void 0,children:/* @__PURE__ */j(V,{field:l,name:e,id:`${I}-${e}`,value:n[e],onChange:n=>t(e,n),readOnly:r,context:o,renderers:u,openItem:A&&A.name===e?A.index:null,onOpenItem:n=>T(null===n?null:{panel:I,name:e,index:n}),headingLevel:i?K(N):N})},e);/* @__PURE__ */
19
- return D("div",{className:"es-insp",children:[H?/* @__PURE__ */j("div",{className:"es-insp-tabs",children:/* @__PURE__ */j(x,{variant:"underline",block:!0,"aria-label":p??O.settings,idPrefix:I,value:R,onChange:e=>{const n=e;void 0===i&&F(n),s?.(n)},items:P.buckets.map(e=>{const n=O.buckets[e],l=d?.[e];return l?{id:e,icon:l,label:/* @__PURE__ */j("span",{className:"sr-only",children:n}),tooltip:n}:{id:e,label:n}})})}):null,
18
+ return j(J,{...e,field:n});case"slot":return null}}var Y=e=>t.includes(e);function q(e){let n,l=t[0];const a=[],r=/* @__PURE__ */new Set;for(const[t,o]of Object.entries(e))o&&(Y(o.bucket)&&((o.marker||o.bucket!==l)&&(n=void 0),l=o.bucket),o.marker&&"string"==typeof o.fold?n={key:t,title:o.fold}:o.marker&&!1===o.fold&&(n=void 0),o.marker||!1===o.visible||(a.push(n?{name:t,field:o,bucket:l,fold:n}:{name:t,field:o,bucket:l}),"slot"!==o.type&&r.add(l)));return{rows:a,buckets:t.filter(e=>r.has(e))}}function Z(e){return new Map(q(e).rows.map(e=>[e.name,e.bucket]))}function Q(e){const n=[];for(const l of e){const e=n[n.length-1];e&&e.fold?.key===l.fold?.key?e.rows.push(l):n.push({fold:l.fold,rows:[l]})}return n}function U({fields:e,values:n,onChange:l,readOnly:t=!1,context:o,tab:i,onTab:s,tabs:c=!0,tabIcons:d,renderers:m,idPrefix:p,ariaLabel:h,lead:f,children:b,leadFold:g,closedFolds:v,onFold:y,headingLevel:N=3}){const O=u("panel",r),S=$(),I=p??`es-insp${S.replace(/:/g,"")}`,P=q(e),[L,F]=C(void 0),M=i??L,R=M&&P.buckets.includes(M)?M:P.buckets[0],[E,T]=C(null),A=E&&E.panel===I&&P.rows.some(e=>e.name===E.name)?E:null,H=c&&P.buckets.length>1,z=H&&R?k(I,R):`${I}-rows`,[B,G]=C(()=>/* @__PURE__ */new Set),W=v??B,X=(e,n)=>{/* @__PURE__ */return j(a,{title:e.title,open:!W.has(e.key),onToggle:n=>((e,n)=>{void 0===v&&G(l=>{const t=new Set(l);return n?t.delete(e):t.add(e),t}),y?.(e,n)})(e.key,n),id:`${I}-fold-${l=e.key,[...l].map(e=>/[A-Za-z0-9_-]/.test(e)?e:`-u${e.codePointAt(0).toString(16)}-`).join("")}`,level:N,children:n});var l},J=e=>H&&e!==R,Y=({name:e,field:a,bucket:r,fold:i})=>/* @__PURE__ */j("div",{className:"es-insp-row","data-field":e,"data-bucket":r,hidden:!!J(r)||void 0,children:/* @__PURE__ */j(V,{field:a,name:e,id:`${I}-${e}`,value:n[e],onChange:n=>l(e,n),readOnly:t,context:o,renderers:m,openItem:A&&A.name===e?A.index:null,onOpenItem:n=>T(null===n?null:{panel:I,name:e,index:n}),headingLevel:i?K(N):N})},e);/* @__PURE__ */
19
+ return D("div",{className:"es-insp",children:[H?/* @__PURE__ */j("div",{className:"es-insp-tabs",children:/* @__PURE__ */j(x,{variant:"underline",block:!0,"aria-label":h??O.settings,idPrefix:I,value:R,onChange:e=>{const n=e;void 0===i&&F(n),s?.(n)},items:P.buckets.map(e=>{const n=O.buckets[e],l=d?.[e];return l?{id:e,icon:l,label:/* @__PURE__ */j("span",{className:"sr-only",children:n}),tooltip:n}:{id:e,label:n}})})}):null,
20
20
  /* @__PURE__ */D("div",{className:"es-insp-rows",id:z,role:H?"tabpanel":void 0,"aria-labelledby":H&&R?w(I,R):void 0,children:[f?g?/* @__PURE__ */j("div",{className:"es-insp-band","data-fold":g.key,children:X(g,f)}):f:null,Q(P.rows).map((e,n)=>{if(!e.fold)return e.rows.map(Y);const l=e.rows[0].bucket,t=e.rows.every(e=>"slot"===e.field.type);/* @__PURE__ */
21
21
  return j("div",{className:"es-insp-band","data-fold":e.fold.key,"data-bucket":l,hidden:!(!J(l)&&!t)||void 0,children:X(e.fold,e.rows.map(Y))},`fold-${e.fold.key}-${n}`)}),b]})]})}export{R as FieldText,U as Inspector,V as InspectorField,G as ListField,Z as bucketsOf,H as copyItem,E as insertAt,W as labelOf,T as moveTo,q as planFields,A as removeAt};
@@ -0,0 +1 @@
1
+ var e=["desktop","tablet","mobile"],t={desktop:"Desktop",tablet:"Tablet",mobile:"Mobile"},o=720,b=1100;function l(e){return e>=1100?"desktop":e>=720?"tablet":"mobile"}export{b as VIEW_DESKTOP_MIN,o as VIEW_TABLET_MIN,e as VIEW_TIERS,t as VIEW_TIER_LABEL,l as viewTierForWidth};
@@ -1,2 +1,2 @@
1
- import{editLockOf as e}from"./chunk-GMCZXMOV.js";import{saveStatusOf as r,resetForDocumentSwitch as n}from"./chunk-HNKB2ZYR.js";import{isExpiredSession as t,readEaselFailure as o}from"./chunk-CLOS6SSX.js";import{routeSharedHostMessage as u}from"./chunk-S4AWJX4Q.js";import{describeLoadFailure as a,hostLoadRefusal as s}from"./chunk-ERR437B5.js";import{useAdminBridge as i}from"./chunk-VPFNZ7TB.js";import{NO_DOCUMENT_ADDRESSING as l}from"./chunk-RLBXE4EU.js";import{STATUS_UNREACHABLE as c}from"./chunk-KCOBHPN6.js";import{useEaselSession as d}from"./chunk-O7Q4DDJT.js";import{backendOf as f,setSessionDocumentSite as m}from"./chunk-RSCMJIWS.js";import{useEaselHost as k}from"./chunk-U3JP4VGF.js";import{DEFAULT_SCREEN_WORDS as g}from"./chunk-VVPZMWJE.js";import{canWriteDocument as v,newEaselClientId as p,reloadIfVersionMoved as h,openUnansweredClaim as y,FAIL_OPEN_RETRY_MS as w,CLAIM_FAIL_OPEN_MS as S,holderOf as b}from"./chunk-THWO5YVZ.js";import{useAutosave as P}from"./chunk-NDRZP6YR.js";import{useWords as I}from"./chunk-MFIRYGHW.js";import{createContext as j,useContext as R,useState as B,useMemo as O,useCallback as C,useEffect as E,useRef as H}from"react";import{jsx as T}from"react/jsx-runtime";var M={content:[],root:{},zones:{}};var V=j(null);function A(){const e=R(V);if(!e)throw new Error("useStorefrontDocument must be used within StorefrontDocumentProvider");return e}function D({target:j,addressing:R=l,onHostMessage:A,children:D}){const N=R,{homeSlug:F,entryMayBounce:L,entryBounce:W,onSwitch:Z,tellsHost:J,adapterFor:Y,migrateRenamedProps:U,describeMissing:X,onLoadFailed:x}=N,[G,K]=B(j),Q=k(),z=d(),_=O(()=>f(z),[z]),q=O(()=>e(z),[z]),$="template"===G.kind,ee="template"===G.kind?G.id:null,re="template"===G.kind?G.pageSlug??F??"":"document"===G.kind?G.slug??"":G.slug,ne="page"===G.kind?G.siteId??null:null,te=z.blocks,oe=O(()=>Y(G,_,te),[Y,_,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]),se="page"===G.kind?G.originSlug??null:null;E(()=>{m(z,ne)},[z,ne]);const ie=H(G);E(()=>{ie.current=G},[G]);const{token:le,tokenRef:ce,capabilities:de}=i({onMessage:e=>{if(A?.(e)||u(e))return;const r=e;if("storefront-editor:navigate"===r?.type){const r=e;r?.target&&Or(r.target)}}}),fe=!z.usesBridgedToken||null!==le,me=oe.lock,ke=Boolean(_.lock),[ge,ve]=B(null),[pe,he]=B(null),[ye,we]=B(null),[Se,be]=B(null),Pe=I("screen",g),Ie=Se?function(e,r){if(null!==e.sentence)return e.sentence;if(!e.missing)return r.loadFailed({cause:e.cause});switch(e.target.kind){case"template":return r.missingTemplatePage;case"document":return r.missingDocument;default:return r.missingPage({slug:e.slug})}}(Se,Pe):null,[je,Re]=B(null),Be=H(null),Oe=H(null),[Ce,Ee]=B(!1),He=H(null),[Te,Me]=B(null),Ve=H(null),[Ae,De]=B(null),[Ne,Fe]=B(!1),Le=H(null);E(()=>{Le.current=Ae},[Ae]);const[We,Ze]=B(ue.hasEditLock?{kind:"checking"}:{kind:"editing"}),Je=H(We);E(()=>{Je.current=We},[We]);const Ye=H(()=>Promise.resolve(!1)),Ue=C(e=>{Oe.current=e,Ee(!0)},[]),Xe=P({save:async({id:e,data:r})=>{if(v(Je.current)){if(!await Ye.current(e,r)){if(!v(Je.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:xe,push:Ge,flush:Ke,pause:Qe,resume:ze,stop:_e,reset:qe,retryNow:$e,hasPending:er}=Xe,rr=H(xe);E(()=>{rr.current=xe},[xe]);const nr=r(xe),tr=C(()=>{const e=Oe.current;e&&(Oe.current=null,Ee(!1),Ge(e))},[Ge]),or=H("");or.current||(or.current=p());const[ur,ar]=B(0),sr=H(!1),[ir,lr]=B(L(j)),cr=H(!1);E(()=>{if(cr.current)return;cr.current=!0;const e=Q.address.search(),r=W(j,e);r?Q.address.load(r):L(j)&&lr(!1)},[j,Q]);const dr=Q.send;E(()=>{if(!fe)return;let e=!1;const r=ie.current,n=oe.resolve(re),t=z.documentHooks?.opening?.({slug:re,isTemplate:$,capabilities:ue});return n.then(async n=>{if(e)return;if(!n)return"page"===r.kind&&null!==F&&re!==F?void Q.address.load({kind:"page",slug:F,siteId:ne??void 0}):(be({target:r,slug:re,missing:!0,sentence:X?.(r)??null}),void x?.(r,null));const o=n.readOnlyReason?n.readOnlyReason:null;Be.current=o,Re(o),ve(n.id),he(n.kind??null),Ve.current=n.version??null;const u=n.layout,a=u&&Object.keys(u).length?u:M,s=U(a),i=t?await t(s):s;e||we(i)}).catch(n=>{e||(console.error("[storefront-editor] document load failed",n),be({target:r,slug:re,missing:!1,sentence:s(n,{slug:re},z),cause:a(n,z)}),x?.(r,n))}),()=>{e=!0}},[fe,le,$,oe,re]);const fr=C(e=>new Promise(r=>{const n=Date.now(),t=setInterval(()=>{const o=ce.current;o&&o!==e?(clearInterval(t),r(o)):Date.now()-n>6e3&&(clearInterval(t),r(null))},200)}),[]),mr=C(async e=>{const r=ce.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(t(n,z)){dr("storefront-editor:auth-expired");const n=r?await fr(r):null;if(n)try{return{ok:!0,value:await e(n)}}catch(e){return{ok:!1,error:e}}}return{ok:!1,error:n}}},[dr,fr,z]),kr=C(async e=>{const r=ce.current?await mr(e):{ok:!1};return r.ok||dr("storefront-editor:save-failed"),r.ok},[dr,mr]),gr=C(async(e,r,n=!1)=>{if(null!==Be.current)return!1;if(!v(Je.current))return!1;if(Le.current)return!1;const t=await mr(()=>oe.saveLayout(e,r,Ve.current,or.current));if(t.ok)return Ve.current=t.value.version??Ve.current,Fe(!1),!0;const u=q.readLockTaken(t.error);if(u){const e={kind:"takenover",holder:u};return Je.current=e,Ze(e),!1}const a=q.readSaveConflict(t.error);if(a){if(a.savedByYou&&!n&&oe.rereadVersion){const n=await mr(()=>oe.rereadVersion(e));if(n.ok&&n.value)return Ve.current=n.value,Ye.current(e,r,!0)}_e(),Le.current=a,De(a)}return Fe(o(t.error,z)?.status===c),!1},[oe,mr,_e,z]);E(()=>{Ye.current=gr},[gr]);const vr=C(e=>{if(null!==Be.current)return;if(dr("storefront-editor:dirty"),!ge)return;const r=ae(e);He.current=r,v(Je.current)?Ge({id:ge,data:r}):Ue({id:ge,data:r})},[ge,dr,Ue,Ge,ae]),pr=C(async()=>{v(Je.current)&&tr();return await Ke()&&null==Oe.current},[tr,Ke]),hr=H(pr);E(()=>{hr.current=pr},[pr]);const yr=H(mr);E(()=>{yr.current=mr},[mr]);const wr=C(()=>{Q.address.reload()},[Q]),Sr=H(()=>Promise.resolve(!1));E(()=>{Sr.current=()=>{const e=oe.rereadVersion;return ge&&e?h({ours:Ve.current,stored:async()=>{const r=await yr.current(()=>e(ge));return r.ok?r.value:null},hasPending:()=>null!=Oe.current||er(),reload:wr}):Promise.resolve(!1)}},[oe,ge,er,wr]);const br=null!==je;E(()=>{if(!me||!ge||!fe||br)return;let e=!1,r=null,n=null;const t=or.current,o={claim:async e=>{const r=await yr.current(()=>me.claim(ge,t,e));if(r.ok)return{heartbeat_seconds:r.value.heartbeatSeconds};throw r.error},cancelled:()=>e,currentAccess:()=>Je.current,heldWrite:()=>({pending:null!=Oe.current||er(),autoSaveEnabled:!rr.current.paused,saveConflict:null!=Le.current}),setAccess:e=>{Je.current=e,Ze(e)},releaseHeldWrite:()=>{hr.current()},startHeartbeat:e=>{r&&clearInterval(r),r=setInterval(()=>{u(!1)},e)},stopHeartbeat:()=>{r&&(clearInterval(r),r=null)},reloadIfMoved:()=>{Sr.current()}},u=q.makeClaimBeat(o),a=sr.current;return sr.current=!1,a||(Ze({kind:"checking"}),n=setTimeout(()=>{n=null,y(o)&&o.startHeartbeat(w)},S)),u(a).finally(()=>{n&&clearTimeout(n),n=null}),()=>{e=!0,n&&clearTimeout(n),r&&clearInterval(r),me.release(ge,t).catch(()=>{})}},[ge,me,fe,le,ur,br]);const Pr=C(()=>{me&&ge&&(sr.current=!0,ar(e=>e+1))},[ge,me]),Ir=C(()=>{Ze(e=>{const r="blocked"===e.kind||"takenover"===e.kind?e.holder:null;return r?{kind:"readonly",holder:r}:e})},[]),jr=C(()=>{rr.current.paused?(v(Je.current)&&tr(),ze()):Qe()},[tr,Qe,ze]),Rr=C(()=>{$e()},[$e]),Br=C(e=>{He.current=null,n("template"!==e.kind&&ke,{resetAutosave:()=>{qe(),Oe.current=null,Ee(!1)},setVersion:e=>{Ve.current=e},setSaveConflict:De,setAccess:Ze}),Z(e),K(e),Be.current=null,Re(null),ve(null),he(null),we(null),be(null),Q.address.show(e),"document"!==e.kind&&J(e)&&Q.send("storefront-editor:navigated",{target:e})},[qe,Q,ke,Z,J]),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,ie.current,F))return;const r=null!=Oe.current;if(!r&&!er())return void Br(e);const n=rr.current;r||n.paused||n.failed||n.stopped?Me(e):Ke().then(r=>{r?Br(e):Me(e)})},[Br,er,Ke,F]),Cr=C(()=>Me(null),[]),Er=C(()=>{Me(e=>(e&&Br(e),null))},[Br]),Hr=C(async()=>{const e=Te;if(!e)return;await pr()&&(Me(null),Br(e))},[Te,pr,Br]),Tr=C(async e=>{if(null!==Be.current)return;if(!ge)return;if(!v(Je.current)||Le.current)return;const r=ae(e);if(!await gr(ge,r))return void(Le.current||dr("storefront-editor:save-failed"));const n=oe.publish;if(!ue.canPublish||!n)return void dr("storefront-editor:saved");const t=await mr(()=>n(ge,Ve.current??void 0));t.ok?(Ve.current=t.value.version??Ve.current,dr("storefront-editor:published")):dr("storefront-editor:save-failed")},[ge,oe,ue.canPublish,dr,gr,mr,ae]);/* @__PURE__ */
2
- return T(V.Provider,{value:{target:G,adapter:oe,capabilities:ue,templateId:ee,currentSlug:re,currentKind:pe,siteId:ne,ready:fe,token:le,tokenRef:ce,notifyParent:dr,bridgeCapabilities:de,runAuthed:kr,docId:ge,data:ye,getLiveData:()=>He.current??ye,footerOriginSlug:se,error:Ie,redirecting:ir,saveStatus:nr,saveState:xe,autoSaveEnabled:!xe.paused,autoSaveStoppedByConflict:xe.stopped,hasUnsavedEdits:xe.pending||Ce,toggleAutoSave:jr,retrySave:Rr,onChange:vr,flushSave:pr,onPublish:Tr,access:We,readOnly:null!==b(We)||null!==je||null!==Ae,readOnlyReason:je,takeOverEditing:Pr,viewReadOnly:Ir,saveConflict:Ae,saveUnreachable:Ne,reloadFromServer:wr,navigate:Or,pendingNav:Te,cancelPendingNav:Cr,discardAndNavigate:Er,saveAndNavigate:Hr},children:D})}export{V as ScreenDocumentContext,D as ScreenDocumentProvider,A as useScreenDocument};
1
+ import{describeLoadFailure as e,hostLoadRefusal as r}from"./chunk-ERR437B5.js";import{editLockOf as n}from"./chunk-GMCZXMOV.js";import{NO_DOCUMENT_ADDRESSING as t}from"./chunk-RLBXE4EU.js";import{saveStatusOf as o,resetForDocumentSwitch as u}from"./chunk-HNKB2ZYR.js";import{isExpiredSession as a,readEaselFailure as s}from"./chunk-CLOS6SSX.js";import{routeSharedHostMessage as i}from"./chunk-S4AWJX4Q.js";import{useAdminBridge as l}from"./chunk-VPFNZ7TB.js";import{STATUS_UNREACHABLE as c}from"./chunk-KCOBHPN6.js";import{useEaselSession as d}from"./chunk-O7Q4DDJT.js";import{backendOf as f,setSessionDocumentSite as m}from"./chunk-RSCMJIWS.js";import{useEaselHost as k}from"./chunk-U3JP4VGF.js";import{DEFAULT_SCREEN_WORDS as g}from"./chunk-VVPZMWJE.js";import{useAutosave as v}from"./chunk-NDRZP6YR.js";import{canWriteDocument as p,newEaselClientId as h,reloadIfVersionMoved as y,openUnansweredClaim as w,FAIL_OPEN_RETRY_MS as S,CLAIM_FAIL_OPEN_MS as b,holderOf as P}from"./chunk-THWO5YVZ.js";import{useWords as I}from"./chunk-MFIRYGHW.js";import{createContext as j,useContext as R,useState as B,useMemo as O,useCallback as C,useEffect as E,useRef as H}from"react";import{jsx as T}from"react/jsx-runtime";var M={content:[],root:{},zones:{}};var V=j(null);function A(){const e=R(V);if(!e)throw new Error("useStorefrontDocument must be used within StorefrontDocumentProvider");return e}function D({target:j,addressing:R=t,onHostMessage:A,children:D}){const N=R,{homeSlug:F,entryMayBounce:L,entryBounce:W,onSwitch:Z,tellsHost:J,adapterFor:Y,migrateRenamedProps:U,describeMissing:X,onLoadFailed:x}=N,[G,K]=B(j),Q=k(),z=d(),_=O(()=>f(z),[z]),q=O(()=>n(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=O(()=>Y(G,_,te),[Y,_,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]),se="page"===G.kind?G.originSlug??null:null;E(()=>{m(z,ne)},[z,ne]);const ie=H(G);E(()=>{ie.current=G},[G]);const{token:le,tokenRef:ce,capabilities:de}=l({onMessage:e=>{if(A?.(e)||i(e))return;const r=e;if("storefront-editor:navigate"===r?.type){const r=e;r?.target&&Or(r.target)}}}),fe=!z.usesBridgedToken||null!==le,me=oe.lock,ke=Boolean(_.lock),[ge,ve]=B(null),[pe,he]=B(null),[ye,we]=B(null),[Se,be]=B(null),Pe=I("screen",g),Ie=Se?function(e,r){if(null!==e.sentence)return e.sentence;if(!e.missing)return r.loadFailed({cause:e.cause});switch(e.target.kind){case"template":return r.missingTemplatePage;case"document":return r.missingDocument;default:return r.missingPage({slug:e.slug})}}(Se,Pe):null,[je,Re]=B(null),Be=H(null),Oe=H(null),[Ce,Ee]=B(!1),He=H(null),[Te,Me]=B(null),Ve=H(null),[Ae,De]=B(null),[Ne,Fe]=B(!1),Le=H(null);E(()=>{Le.current=Ae},[Ae]);const[We,Ze]=B(ue.hasEditLock?{kind:"checking"}:{kind:"editing"}),Je=H(We);E(()=>{Je.current=We},[We]);const Ye=H(()=>Promise.resolve(!1)),Ue=C(e=>{Oe.current=e,Ee(!0)},[]),Xe=v({save:async({id:e,data:r})=>{if(p(Je.current)){if(!await Ye.current(e,r)){if(!p(Je.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:xe,push:Ge,flush:Ke,pause:Qe,resume:ze,stop:_e,reset:qe,retryNow:$e,hasPending:er}=Xe,rr=H(xe);E(()=>{rr.current=xe},[xe]);const nr=o(xe),tr=C(()=>{const e=Oe.current;e&&(Oe.current=null,Ee(!1),Ge(e))},[Ge]),or=H("");or.current||(or.current=h());const[ur,ar]=B(0),sr=H(!1),[ir,lr]=B(L(j)),cr=H(!1);E(()=>{if(cr.current)return;cr.current=!0;const e=Q.address.search(),r=W(j,e);r?Q.address.load(r):L(j)&&lr(!1)},[j,Q]);const dr=Q.send;E(()=>{if(!fe)return;let n=!1;const t=ie.current,o=oe.resolve(re),u=z.documentHooks?.opening?.({slug:re,isTemplate:$,capabilities:ue});return o.then(async e=>{if(n)return;if(!e)return"page"===t.kind&&null!==F&&re!==F?void Q.address.load({kind:"page",slug:F,siteId:ne??void 0}):(be({target:t,slug:re,missing:!0,sentence:X?.(t)??null}),void x?.(t,null));const r=e.readOnlyReason?e.readOnlyReason:null;Be.current=r,Re(r),ve(e.id),he(e.kind??null),Ve.current=e.version??null;const o=e.layout,a=o&&Object.keys(o).length?o:M,s=U(a),i=u?await u(s):s;n||we(i)}).catch(o=>{n||(console.error("[storefront-editor] document load failed",o),be({target:t,slug:re,missing:!1,sentence:r(o,{slug:re},z),cause:e(o,z)}),x?.(t,o))}),()=>{n=!0}},[fe,le,$,oe,re]);const fr=C(e=>new Promise(r=>{const n=Date.now(),t=setInterval(()=>{const o=ce.current;o&&o!==e?(clearInterval(t),r(o)):Date.now()-n>6e3&&(clearInterval(t),r(null))},200)}),[]),mr=C(async e=>{const r=ce.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(a(n,z)){dr("storefront-editor:auth-expired");const n=r?await fr(r):null;if(n)try{return{ok:!0,value:await e(n)}}catch(e){return{ok:!1,error:e}}}return{ok:!1,error:n}}},[dr,fr,z]),kr=C(async e=>{const r=ce.current?await mr(e):{ok:!1};return r.ok||dr("storefront-editor:save-failed"),r.ok},[dr,mr]),gr=C(async(e,r,n=!1)=>{if(null!==Be.current)return!1;if(!p(Je.current))return!1;if(Le.current)return!1;const t=await mr(()=>oe.saveLayout(e,r,Ve.current,or.current));if(t.ok)return Ve.current=t.value.version??Ve.current,Fe(!1),!0;const o=q.readLockTaken(t.error);if(o){const e={kind:"takenover",holder:o};return Je.current=e,Ze(e),!1}const u=q.readSaveConflict(t.error);if(u){if(u.savedByYou&&!n&&oe.rereadVersion){const n=await mr(()=>oe.rereadVersion(e));if(n.ok&&n.value)return Ve.current=n.value,Ye.current(e,r,!0)}_e(),Le.current=u,De(u)}return Fe(s(t.error,z)?.status===c),!1},[oe,mr,_e,z]);E(()=>{Ye.current=gr},[gr]);const vr=C(e=>{if(null!==Be.current)return;if(dr("storefront-editor:dirty"),!ge)return;const r=ae(e);He.current=r,p(Je.current)?Ge({id:ge,data:r}):Ue({id:ge,data:r})},[ge,dr,Ue,Ge,ae]),pr=C(async()=>{p(Je.current)&&tr();return await Ke()&&null==Oe.current},[tr,Ke]),hr=H(pr);E(()=>{hr.current=pr},[pr]);const yr=H(mr);E(()=>{yr.current=mr},[mr]);const wr=C(()=>{Q.address.reload()},[Q]),Sr=H(()=>Promise.resolve(!1));E(()=>{Sr.current=()=>{const e=oe.rereadVersion;return ge&&e?y({ours:Ve.current,stored:async()=>{const r=await yr.current(()=>e(ge));return r.ok?r.value:null},hasPending:()=>null!=Oe.current||er(),reload:wr}):Promise.resolve(!1)}},[oe,ge,er,wr]);const br=null!==je;E(()=>{if(!me||!ge||!fe||br)return;let e=!1,r=null,n=null;const t=or.current,o={claim:async e=>{const r=await yr.current(()=>me.claim(ge,t,e));if(r.ok)return{heartbeat_seconds:r.value.heartbeatSeconds};throw r.error},cancelled:()=>e,currentAccess:()=>Je.current,heldWrite:()=>({pending:null!=Oe.current||er(),autoSaveEnabled:!rr.current.paused,saveConflict:null!=Le.current}),setAccess:e=>{Je.current=e,Ze(e)},releaseHeldWrite:()=>{hr.current()},startHeartbeat:e=>{r&&clearInterval(r),r=setInterval(()=>{u(!1)},e)},stopHeartbeat:()=>{r&&(clearInterval(r),r=null)},reloadIfMoved:()=>{Sr.current()}},u=q.makeClaimBeat(o),a=sr.current;return sr.current=!1,a||(Ze({kind:"checking"}),n=setTimeout(()=>{n=null,w(o)&&o.startHeartbeat(S)},b)),u(a).finally(()=>{n&&clearTimeout(n),n=null}),()=>{e=!0,n&&clearTimeout(n),r&&clearInterval(r),me.release(ge,t).catch(()=>{})}},[ge,me,fe,le,ur,br]);const Pr=C(()=>{me&&ge&&(sr.current=!0,ar(e=>e+1))},[ge,me]),Ir=C(()=>{Ze(e=>{const r="blocked"===e.kind||"takenover"===e.kind?e.holder:null;return r?{kind:"readonly",holder:r}:e})},[]),jr=C(()=>{rr.current.paused?(p(Je.current)&&tr(),ze()):Qe()},[tr,Qe,ze]),Rr=C(()=>{$e()},[$e]),Br=C(e=>{He.current=null,u("template"!==e.kind&&ke,{resetAutosave:()=>{qe(),Oe.current=null,Ee(!1)},setVersion:e=>{Ve.current=e},setSaveConflict:De,setAccess:Ze}),Z(e),K(e),Be.current=null,Re(null),ve(null),he(null),we(null),be(null),Q.address.show(e),"document"!==e.kind&&J(e)&&Q.send("storefront-editor:navigated",{target:e})},[qe,Q,ke,Z,J]),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,ie.current,F))return;const r=null!=Oe.current;if(!r&&!er())return void Br(e);const n=rr.current;r||n.paused||n.failed||n.stopped?Me(e):Ke().then(r=>{r?Br(e):Me(e)})},[Br,er,Ke,F]),Cr=C(()=>Me(null),[]),Er=C(()=>{Me(e=>(e&&Br(e),null))},[Br]),Hr=C(async()=>{const e=Te;if(!e)return;await pr()&&(Me(null),Br(e))},[Te,pr,Br]),Tr=C(async e=>{if(null!==Be.current)return;if(!ge)return;if(!p(Je.current)||Le.current)return;const r=ae(e);if(!await gr(ge,r))return void(Le.current||dr("storefront-editor:save-failed"));const n=oe.publish;if(!ue.canPublish||!n)return void dr("storefront-editor:saved");const t=await mr(()=>n(ge,Ve.current??void 0));t.ok?(Ve.current=t.value.version??Ve.current,dr("storefront-editor:published")):dr("storefront-editor:save-failed")},[ge,oe,ue.canPublish,dr,gr,mr,ae]);/* @__PURE__ */
2
+ return T(V.Provider,{value:{target:G,adapter:oe,capabilities:ue,templateId:ee,currentSlug:re,currentKind:pe,siteId:ne,ready:fe,token:le,tokenRef:ce,notifyParent:dr,bridgeCapabilities:de,runAuthed:kr,docId:ge,data:ye,getLiveData:()=>He.current??ye,footerOriginSlug:se,error:Ie,redirecting:ir,saveStatus:nr,saveState:xe,autoSaveEnabled:!xe.paused,autoSaveStoppedByConflict:xe.stopped,hasUnsavedEdits:xe.pending||Ce,toggleAutoSave:jr,retrySave:Rr,onChange:vr,flushSave:pr,onPublish:Tr,access:We,readOnly:null!==P(We)||null!==je||null!==Ae,readOnlyReason:je,takeOverEditing:Pr,viewReadOnly:Ir,saveConflict:Ae,saveUnreachable:Ne,reloadFromServer:wr,navigate:Or,pendingNav:Te,cancelPendingNav:Cr,discardAndNavigate:Er,saveAndNavigate:Hr},children:D})}export{V as ScreenDocumentContext,D as ScreenDocumentProvider,A as useScreenDocument};
@@ -0,0 +1,57 @@
1
+ import{styleClipboardOf as e}from"./chunk-M4CNCPHA.js";import{markedTreeNodeId as n,revealSelectedTreeRow as t,sameSelector as o}from"./chunk-FGNR22NY.js";import{cloneNodeWithFreshIds as r}from"./chunk-2GVCAIPX.js";import{dedupeSlotChildren as i}from"./chunk-26OOWIJJ.js";import{ScreenSaveIcon as l,ScreenMainButton as s}from"./chunk-W4U4SHKW.js";import{useBrowserOffline as d}from"./chunk-RKTF5XLP.js";import{scrollPreviewToSection as c,gotoPreviewSlide as a,scrollPreviewToTop as p}from"./chunk-3Z2MVLCD.js";import{useEaselKeyTarget as u,useEaselUndoKeys as f,useEaselSaveKey as h,editorRootFocus as m}from"./chunk-4EI6UGGH.js";import{SlotChildActionsProvider as g}from"./chunk-KCBEE2MC.js";import{screenStorageKeys as y,DEFAULT_PANEL_W as k,clampPanelWidth as S}from"./chunk-TZIIRGVY.js";import{usePartBridge as v}from"./chunk-H5QI34FV.js";import{useSectionOps as b}from"./chunk-S2MMPHKD.js";import{AddChildRow as w}from"./chunk-5545A3PC.js";import{AddSidePanel as x}from"./chunk-YWUHPY5W.js";import{SidePanelHead as z,PanelShowStrip as C}from"./chunk-62VPYC7F.js";import{MediaSidePanel as I}from"./chunk-J2JDC3EZ.js";import{useScreenSaveSwitch as B,useScreenNodeKeys as N,useScreenPinned as P,useScreenDocumentLabel as O,useScreenCanvasFrame as $,useScreenInspectorPanel as M,useScreenDevices as j,useScreenPickFollowsSelection as A,useScreenLeftView as T,SELECTION_MODE as L,sameInspectorMode as E,useScreenBridges as R,useScreenBlockRules as V,useScreenBlockLook as F,useScreenStorageNamespace as W,useScreenNotify as H,useScreenCanvasHead as D,isSlotMode as J,useScreenStyleClipboard as U,useScreenDocumentPass as G,useScreenCanvasDrag as Y,ScreenCanvasTargetProvider as K,isPinnedFirst as X,isPinnedLast as Z,screenSlotsOf as q}from"./chunk-FZ3Y3QTQ.js";import{useNodeClipboard as _,useNodeContextMenu as Q}from"./chunk-NW4LJ4G4.js";import{PageEditGuardNotices as ee}from"./chunk-IWFVVCRN.js";import{useScreenDocument as ne}from"./chunk-FBS75I6E.js";import{requestMediaPick as te}from"./chunk-KG7RJWOK.js";import{useMediaPanel as oe,usePanelPick as re,useCancelPanelPick as ie}from"./chunk-R6WTQWAC.js";import{useEaselSession as le}from"./chunk-O7Q4DDJT.js";import{useEaselHost as se,useHostEscape as de}from"./chunk-U3JP4VGF.js";import{DEFAULT_SCREEN_WORDS as ce}from"./chunk-VVPZMWJE.js";import{heldStyle as ae,styleShortcut as pe}from"./chunk-V7U33NF2.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as ue}from"./chunk-6WY6ZXJG.js";import{DEFAULT_NODE_MENU_WORDS as fe}from"./chunk-WK3AFPXY.js";import{rootRowName as he,slotChildRowName as me,slotChildRenameProp as ge,sectionRenameProp as ye}from"./chunk-TBF5CVPA.js";import{ROOT_ZONE as ke,blockNodeActions as Se,TREE_MAX_DEPTH as ve,childSlotsOf as be,slotFieldsOf as we,slotChildrenIn as xe,nestsInTree as ze,newNodeId as Ce}from"./chunk-PLVEGYK6.js";import{useEasel as Ie,useEaselApi as Be,CanvasPassThroughContext as Ne}from"./chunk-PVAIOBBE.js";import{toItemSelector as Pe,useNodeOps as Oe,clickPick as $e}from"./chunk-ECM5F6JJ.js";import{TreeRow as Me,Subtree as je,LayersTree as Ae,TreeGroupLabel as Te,TreeRowAction as Le,TreeSeam as Ee}from"./chunk-4JSBIW5H.js";import{DEFAULT_TREE_WORDS as Re}from"./chunk-K56YDHYQ.js";import{LayersIcon as Ve,MediaIcon as Fe}from"./chunk-4VJATVVR.js";import{EaselTopBar as We,TopBarRail as He,TopBarCluster as De,EaselIconButton as Je,TopBarDivider as Ue,DeviceSwitch as Ge,InspectorIconButton as Ye,PanelResizeHandle as Ke,MAX_PANEL_W as Xe,MIN_PANEL_W as Ze,panelWidthVars as qe}from"./chunk-IE55HNMA.js";import{DEFAULT_NOTICE_WORDS as _e,DEFAULT_CHROME_WORDS as Qe}from"./chunk-Z6PVRXVY.js";import{holderOf as en,nameOrSomeone as nn}from"./chunk-THWO5YVZ.js";import{DEFAULT_LOCK_WORDS as tn}from"./chunk-RE4LP46F.js";import{useWords as on}from"./chunk-MFIRYGHW.js";import{insertSeams as rn,CanvasDragLayer as ln,CanvasInsert as sn}from"./chunk-QFVRMARS.js";import{DEFAULT_DRAG_WORDS as dn}from"./chunk-AYWN5NRH.js";import{createDragSession as cn,useTreeDrag as an,gapToMoveIndex as pn}from"./chunk-67GNT6PF.js";import{useCanvasFrame as un,LIST_SELECTOR as fn,BLOCK_SELECTOR as hn,useCanvasEvent as mn,nodeIdAt as gn,frameRectToHost as yn,BLOCK_ATTRIBUTE as kn,drawnBox as Sn}from"./chunk-ILXP5VX5.js";import{ROOT_ID as vn,ROOT_SLOT as bn,zoneKey as wn,parseZoneKey as xn,find as zn,DataError as Cn}from"./chunk-KRXQM65X.js";import{useRef as In,useMemo as Bn,useState as Nn,useEffect as Pn,useCallback as On,useLayoutEffect as $n,Fragment as Mn}from"react";import{ColoredBadge as jn,toast as An,groupColors as Tn}from"efficient-shell/ui";import{UndoIcon as Ln,RedoIcon as En,RefreshIcon as Rn,AddIcon as Vn,TrashIcon as Fn,EyeOffIcon as Wn,EyeIcon as Hn,DuplicateIcon as Dn}from"efficient-shell/icons/efficient";import{jsx as Jn,jsxs as Un,Fragment as Gn}from"react/jsx-runtime";var Yn=/* @__PURE__ */new WeakSet;function Kn(e,n,t){const o=zn(e,n,t);if(!o)return null;const r=o.path.find(e=>"root"!==e.parentId);return r?r.parentId:t}function Xn({canvas:e,tabs:n,onSelect:t}){const o=In(null),[r,i]=Nn({}),l=n.map(e=>`${e.id}:${e.below?1:0}`).join("|");return $n(()=>{const t=e?.document,r=e?.window,l=e?.frame;if(!t||!r||!l||0===n.length)return void i({});let s=0;const d=()=>{s=0;const e=o.current;if(!e)return;const d=yn(l,{left:0,top:0,width:r.innerWidth,height:r.innerHeight},e),c={};for(const o of n){const n=t.querySelector(`[${kn}="${r.CSS?.escape?r.CSS.escape(o.id):o.id}"]`),i=n?Sn(n):null;if(!i||0===i.height){c[o.id]=null;continue}const s=yn(l,{left:i.left,top:i.top,width:i.width,height:i.height},e),a=s.top+s.height;if(a<d.top||s.top>d.top+d.height){c[o.id]=null;continue}const p=o.below?a+4:Math.max(s.top,d.top)+6;c[o.id]={left:Math.max(s.left,d.left)+6,top:p}}i(c)},c=()=>{s||(s=r.requestAnimationFrame(d))};d(),r.addEventListener("scroll",c,!0),r.addEventListener("resize",c);const a=new r.MutationObserver(c);return a.observe(t.body,{childList:!0,subtree:!0,attributes:!0}),()=>{s&&r.cancelAnimationFrame(s),r.removeEventListener("scroll",c,!0),r.removeEventListener("resize",c),a.disconnect()}},[e,l]),/* @__PURE__ */Jn("div",{ref:o,className:"es-band-tabs","aria-hidden":"true",children:n.map(e=>{const n=r[e.id];return n?/* @__PURE__ */Jn("span",{className:"es-band-tab","data-band-tab":e.id,style:{left:n.left,top:n.top},onClick:n=>{n.stopPropagation(),t(e.id)},children:/* @__PURE__ */Jn(jn,{colorClass:Tn("info","solid"),size:"sm",children:e.label})},e.id):null})})}function Zn({expand:e}){/* @__PURE__ */
2
+ return Jn("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round",children:/* @__PURE__ */Un(Gn,e?{children:[
3
+ /* @__PURE__ */Jn("path",{d:"M8 9l4-4 4 4"}),
4
+ /* @__PURE__ */Jn("path",{d:"M8 15l4 4 4-4"})]}:{children:[
5
+ /* @__PURE__ */Jn("path",{d:"M8 4l4 4 4-4"}),
6
+ /* @__PURE__ */Jn("path",{d:"M8 20l4-4 4 4"}),
7
+ /* @__PURE__ */Jn("path",{d:"M5 12h14"})]})})}var qn=`${fn}, ${hn}`;function _n(e,n,t){const o=t-n;if(o<6)return null;if(o<24)return{top:Math.round((n+t)/2),height:Math.round(o)};return{top:Math.round(Math.min(Math.max(e,n+12),t-12))}}var Qn="__rungs";var et="screen:band",nt={duplicate:!0,delete:!0};function tt(){const fn=se(),{target:yn,docId:kn,capabilities:Sn,currentSlug:Tn,siteId:tt,onPublish:ot,saveState:rt,saveConflict:it,retrySave:lt,toggleAutoSave:st,flushSave:dt,access:ct,saveUnreachable:at=!1,readOnly:pt,readOnlyReason:ut=null}=ne(),ft=B(),ht=N(),{mediaEditing:mt,hasEditGuard:gt,hasPinnedChrome:yt}=Sn,{appState:kt,dispatch:St,history:vt,selectedItem:bt,getSelectorForId:wt,config:xt}=Ie(e=>e),zt=P(),{first:Ct,firstGroup:It,lastGroup:Bt,isSectionGroup:Nt,sectionGroupZone:Pt,panelOf:Ot}=zt,$t=Ot(Ct),Mt=e=>X(zt,e),jt=e=>Z(zt,e),At="node"===zt.firstRow,Tt=zt.band??null,Lt=on("screen",ce),Et=on("tree",Re),Rt=on("drag",dn),Vt=on("notice",_e),Ft=on("lock",tn),Wt=on("menu",fe),Ht=on("styleClipboard",ue),Dt=on("chrome",Qe),Jt=O()??`/${Tn}`,Ut=$(),Gt=M(),Yt=b({readOnly:pt}),Kt=b({readOnly:pt,foldIntoHistory:!0}),Xt=In(null),Zt=Be(),qt=Bn(()=>({...Yt,select:e=>{Xt.current=e,Yt.select(e)},commitDocument:(e,n)=>{if(void 0!==n){const t=Zt.config;Xt.current=Pe(e,t,n)}Yt.commitDocument(e,n)}}),[Yt,Zt]),_t=kt.ui,Qt=_t.leftSideBarVisible,eo=_t.rightSideBarVisible,{options:no,widths:to,initial:oo,fluid:ro,fit:io}=j(),[lo,so]=Nn(oo),co=oe(),ao=mt&&null!==co,po=re(),uo=ie();A(bt?.props.id);const{read:fo,write:ho,forSelection:mo}=T(),[go,yo]=Nn(fo);Pn(()=>{ho(go)},[go]);const[ko,So]=Nn(0),vo=In(null),bo=In(null),wo=un(bo,{readySelector:qn}),xo=u(bo);f(bo,wo);const zo=d(),Co=en(ct),Io={state:rt,offline:zo||rt.failed&&at,readOnlyReason:ut,editing:Co?Vt.editing({name:nn(Co.name,Ft),noun:Lt.noun}):null,conflict:null!=it,notSaving:Lt.bar.notSaving},Bo=()=>{pt||(rt.failed?lt():dt())};h(bo,wo,Bo);const[No,Po]=Nn(!1),Oo=In(!1),$o=In(!1),[Mo,jo]=Nn(null),[Ao,To]=Nn([]),[Lo,Eo]=Nn(L),Ro="puck"===Lo.kind,Vo=n(Lo,bt?.props.id),[Fo,Wo]=Nn(null);Pn(()=>{Fo&&(t(),Wo(null))},[Fo]);const Ho=In(wt);Ho.current=wt;const Do=On((e,{scroll:n})=>{yo(n=>mo(e,n)),n&&Wo(e);const t=[];let o=e;for(let e=0;e<4;e++){const e=Ho.current(o)?.zone;if(!e||!e.includes(":"))break;const n=e.split(":")[0];t.push(n),t.push(e),o=n}0!==t.length&&Sr(e=>{if(t.every(n=>!e.has(n)))return e;const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},[]),Jo=In(null);Pn(()=>{const e=Jo.current;Jo.current=null;const n=null==bt?.props.id?null:String(bt.props.id);Eo(t=>e&&e.id===n?e.mode:"part"===t.kind&&"nodeId"in t&&t.nodeId===n?t:Ot(bt?.type)??L);const t=bt?.props.id,r=Xt.current;if(Xt.current=null,!t)return;const i=wt(t);Do(String(t),{scroll:!o(r,i??null,ke)})},[bt?.props.id,Do]);const Uo=On(e=>{Eo(n=>E(n,e)?n:e),St({type:"setUi",ui:{rightSideBarVisible:!0}})},[St]),Go=In(()=>{});Go.current=(e,n)=>{const t=e?ui(e.zone??ke)[e.index]?.props.id:null,o=null==t?null:String(t),r=null==bt?.props.id?null:String(bt.props.id);Eo(e=>E(e,n)?e:n),o!==r&&(Jo.current={id:o,mode:n},qt.select(e))};const Yo=On((e,n)=>Go.current(e,n),[]),Ko={kind:Lo.kind,mode:Lo,open:Uo,show:e=>Eo(e),reveal:()=>{eo||St({type:"setUi",ui:{rightSideBarVisible:!0}})},select:Yo},Xo=R(Ko,{data:kt.data,selected:bt??null,zoneOf:e=>wt(e)?.zone,readOnly:Boolean(pt),select:e=>{Eo(L),qt.select({index:e})},replace:(e,n)=>qt.replaceComponent(ke,e,n),scrollTo:e=>Ei(e)},{device:lo,refreshes:ko},{setView:yo,reveal:()=>{Qt||St({type:"setUi",ui:{leftSideBarVisible:!0}})}}),Zo=Xo.pinnedSource??!1,qo=Xo.resolveLeftView?Xo.resolveLeftView(go,ao):"media"===go&&ao?go:"sections",_o=V(),{isLockedBlock:Qo,duplicateBlocked:er,nestDepth:nr,newSectionNode:tr,canAddTo:or,blockIsOffered:rr}=_o,ir=F(),{labelAtLevel:lr,Icon:sr,useProducts:dr}=ir,cr=ir.rowName?(e,n,t)=>ir.rowName(e,n,t):void 0,ar=On(e=>{St({type:"setUi",ui:{rightSideBarVisible:!0}}),c(e),Do(e,{scroll:!0})},[St,Do]),{selectNode:pr,openPartId:ur}=v({mode:Lo,setMode:Eo,onOpenPart:ar}),[fr,hr]=Nn(null);de(null!==fr,()=>hr(null));const mr=y(W()),gr=mr.collapsed,yr=mr.panelWidths,[kr,Sr]=Nn(()=>{if("undefined"==typeof window)/* @__PURE__ */return new Set;try{const e=window.localStorage.getItem(gr);return new Set(e?JSON.parse(e):[])}catch{/* @__PURE__ */
8
+ return new Set}});Pn(()=>{try{window.localStorage.setItem(gr,JSON.stringify([...kr]))}catch{}},[kr]);const[vr,br]=Nn(()=>{if("undefined"==typeof window)return{...k};try{const e=window.localStorage.getItem(yr);if(!e)return{...k};const n=JSON.parse(e);return{left:S(Number(n.left)||k.left),right:S(Number(n.right)||k.right)}}catch{return{...k}}});Pn(()=>{const e=setTimeout(()=>{try{window.localStorage.setItem(yr,JSON.stringify(vr))}catch{}},300);return()=>clearTimeout(e)},[vr]);const wr=On((e,n)=>br(t=>{const o="function"==typeof n?n(t[e]):n;return t[e]===o?t:{...t,[e]:o}}),[]),xr=On(e=>wr("left",e),[wr]),zr=On(e=>wr("right",e),[wr]),Cr=e=>kr.has(e),Ir=e=>Sr(n=>{const t=new Set(n);return t.has(e)?t.delete(e):t.add(e),t}),Br=In(!1),Nr=In(null);Pn(()=>{if(Br.current&&!No){const e=Nr.current,n=e&&e.isConnected&&!e.closest('[aria-hidden="true"]')?e:null;(n??bo.current?.querySelector(`button[aria-label="${CSS.escape(Lt.add.title)}"]`))?.focus(),Nr.current=null}Br.current=No},[No]),Pn(()=>{if(!No||!xo)return;const e=e=>{"Escape"===e.key&&Ui()};return xo.addEventListener("keydown",e),()=>xo.removeEventListener("keydown",e)},[No,xo]),de(No,()=>Ui()),Pn(()=>{!Qt&&No&&(Po(!1),jo(null),Oo.current=!1)},[Qt]),Pn(()=>{if(!po)return $o.current&&St({type:"setUi",ui:{leftSideBarVisible:!1}}),void($o.current=!1);No&&(Po(!1),jo(null),$o.current=Oo.current,Oo.current=!1),Qt||($o.current=!0,St({type:"setUi",ui:{leftSideBarVisible:!0}}))},[po]),Pn(()=>{!Qt&&po&&($o.current=!1,uo())},[Qt]),Pn(()=>{if(!po||!xo)return;const e=e=>{"Escape"===e.key&&uo()};return xo.addEventListener("keydown",e),()=>xo.removeEventListener("keydown",e)},[po,xo]),de(null!==po,()=>uo());const Pr=H(),Or=(e,n="success",t)=>{if(Pr)return void(t?Pr(e,"error"===n?"error":"info",t):Pr(e,"error"===n?"error":"info"));const o={sound:!1,action:t?.action,onClose:t?.onClose};"error"===n?An.error(e,{...o,duration:t?.duration??3200}):An.success(e,{...o,duration:t?.duration??1900})},$r=In(null),[Mr,jr]=Nn(0),[Ar,Tr]=Nn(0),Lr=D(),Er=In(null),Rr=e=>Math.max(0,e.clientHeight-(Er.current?.offsetHeight??0));Pn(()=>{const e=$r.current;if(!e)return;const n=()=>{jr(e.clientWidth),Tr(Rr(e))};n();const t=new ResizeObserver(n);return t.observe(e),Er.current&&t.observe(Er.current),()=>t.disconnect()},[]),$n(()=>{$r.current&&(jr($r.current.clientWidth),Tr(Rr($r.current)))},[vr,Qt,eo]);const Vr=lo===ro?Mr>0?Mr:to[ro]:to[lo],Fr=Mr>0?Math.min(Mr/Vr,"shrink"===io?1:2):1,Wr=Vr*Fr,Hr=Mr>0&&Wr>Mr+1,Dr={width:Wr,height:Ar||"100%",flex:"none",position:"relative"},Jr={width:Vr,height:Ar?Ar/Fr:"100%",maxHeight:"none",transform:1!==Fr?`scale(${Fr})`:void 0,transformOrigin:"top left"},Ur=()=>St({type:"setUi",ui:{leftSideBarVisible:!Qt}}),Gr=()=>St({type:"setUi",ui:{rightSideBarVisible:!eo}}),Yr=e=>{No&&(Po(!1),jo(null),Oo.current=!1,Qt&&go===e)||po&&($o.current=!1,uo(),Qt&&go===e)||(Qt&&go===e?Ur():(yo(e),Qt||St({type:"setUi",ui:{leftSideBarVisible:!0}})))},Kr=()=>{te(fn,{accept:"image/*",title:Dt.mediaLibrary})},Xr=()=>{Eo(L),qt.select(null),p()},Zr=()=>{Eo($t??L),eo||St({type:"setUi",ui:{rightSideBarVisible:!0}})},qr=kt.data.content??[],_r=()=>{const e=qr.findIndex(Mt),n=qr.findIndex(jt);return{floor:e>=0?e+1:0,cap:n>=0?n:qr.length}},Qr=xt,ei=_o.stripCopy,ni=e=>r(e,ei),ti=_(),oi=Oe({data:kt.data,config:Qr,readOnly:Boolean(pt),clipboard:ti,strip:ei?e=>ei(e):void 0,afterRemove:"none",stepBounds:(e,n)=>{if(e.parentId!==vn||e.slot!==bn)return{min:0,max:n-1};const{floor:t,cap:o}=_r();return{min:t,max:o-1}},commit:(e,{select:n})=>{void 0!==n&&Eo(L);const t=void 0===n||"node"===n?.kind?n:null;qt.commitDocument(e,t)}}),ri=e=>{const n=zn(kt.data,xt,e);if(!n)return!1;const t=wn(n.place),o=n.node,r=t===ke?ci(o):xi(o);return!!oi.remove(e)&&(Or(Lt.deleted({name:r}),"success",{duration:8e3,action:{label:Lt.bar.undo,onClick:()=>{oi.restore(n.node,n.place)}}}),!0)},ii={...oi,remove:ri},li=e=>lr(e,"block",xt.components[e]?.label??e),si=On(e=>xt.components[e]?.defaultProps??{},[xt]),di=e=>lr(e,"section",li(e)),ci=e=>he({type:e.type,props:e.props??{}},di(e.type),cr),{nodeAddresses:ai,zoneItems:pi}=Bn(()=>{const e=/* @__PURE__ */new Map,n=/* @__PURE__ */new Map,t=(o,r,i)=>{n.set(r,o),o.forEach((n,o)=>{const l=String(n.props?.id??"");if(l&&e.set(l,{zone:r,index:o}),i>=ve)return;const s=/* @__PURE__ */new Map;for(const{child:e,zone:t}of be(xt,n))s.set(t,[...s.get(t)??[],e]);for(const[e,n]of s)t(n,e,i+1)})};return t(qr,ke,0),{nodeAddresses:e,zoneItems:n}},[qr,xt]),ui=On(e=>pi.get(e)??[],[pi]),fi=e=>{const n=ai.get(e);return n?ui(n.zone)[n.index]:void 0},hi=e=>q(_o,xt,e),mi=e=>{if(!_o.slotsOf||e===ke)return null;const n=e.lastIndexOf(":");if(n<=0)return null;const t=fi(e.slice(0,n));if(!t)return null;const o=hi(t).filter(e=>e.rung),r=o.findIndex(t=>t.slot===e.slice(n+1));return r<0?null:{node:t,slot:o[r],position:r}},gi=(()=>{if(!J(Lo))return null;const e=`${Lo.nodeId}:${Lo.slot}`;return mi(e)?.slot.panel===Lo.kind?e:null})(),yi=In(null);Pn(()=>{const e=yi.current;if(yi.current=null,!gi||!J(Lo))return;const n=Lo.nodeId;Do(n,{scroll:e!==gi}),Sr(e=>{if(!e.has(n))return e;const t=new Set(e);return t.delete(n),t})},[Lo]);const ki=(e,n,t)=>{const o=String(e.props.id);if(!n.panel)return void(e=>{const n=ai.get(e);n&&(n.zone===ke?Ri(n.index):ul(n.zone,n.index,e,fi(n.zone.slice(0,n.zone.lastIndexOf(":")))?.type??""))})(o);const r={kind:n.panel,nodeId:o,slot:n.slot},i=`${o}:${n.slot}`;t&&gi!==i&&(yi.current=i),Yo(null,r),eo||St({type:"setUi",ui:{rightSideBarVisible:!0}}),Ei(o)},Si=(e,n,t)=>{const o=`${e}:${n}`;if(Sr(n=>{if(!n.has(o)&&!n.has(e))return n;const t=new Set(n);return t.delete(o),t.delete(e),t}),!t)return;gi!==o&&(yi.current=o);Yo(null,{kind:t,nodeId:e,slot:n})},vi=(e,n,t)=>{if(pt||!_o.moveSlot)return;const o=fi(e),r=o?hi(o).filter(e=>e.rung):[],i=r[n];if(!i)return;const l={parentId:e,slot:Qn,index:n},s=pn(l,{...l,index:Math.min(Math.max(t,0),r.length)});if(s===n)return;const d=_o.moveSlot(e,n,s);"string"==typeof d&&Si(e,d,i.panel)},bi=dr(),wi=Bn(()=>{const e=/* @__PURE__ */new Map;for(const n of bi??[])e.set(n.slug,n.name);return e},[bi]),xi=e=>me(e,li,ir.plainText,e=>wi.get(e),ir.rowName),zi=(e,n)=>{const t=xt.components[e.type]?.fields,o=n===ke||jl(n)?"section":"block",r=n===ke&&(Mt(e)||jt(e)||Nt(e.type)),i="block"===o?ge(t):r?null:ye(t);return ir.renamePropOf?ir.renamePropOf(e,o,i):i},Ci=(e,n,t,o)=>{if(!(!pt&&fr?.zone===e&&fr.index===n))return;const r=(t,o)=>{hr(null),o&&((e,n,t)=>{const o=ui(e)[n];if(!o)return;const r=zi(o,e);r&&qt.replaceComponent(e,n,{...o,props:{...o.props,[r]:t.trim()}})})(e,n,t)};/* @__PURE__ */
9
+ return Jn("input",{className:"es-tree-rename",defaultValue:o,autoFocus:!0,"aria-label":Lt.rename,onClick:e=>e.stopPropagation(),onBlur:e=>r(e.currentTarget.value,!0),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),r(e.currentTarget.value,!0)):"Escape"===e.key&&(e.preventDefault(),r("",!1))}},t)},Ii=e(U(),Ht),Bi=Ii.scope({target:yn,siteId:tt,docId:kn}),Ni=xt,Pi=(e,n)=>n===ke?di(e):li(e),Oi=(e,n,t)=>{const o=Ii.plan(Bi,t,Pi(t.type,e),Ni);o&&(o.changed&&qt.replaceComponent(e,n,{...t,props:{...o.props,id:t.props.id}}),Or(o.message))},$i=Q({nodesIn:ui,nodeAt:(e,n)=>ui(e)[n]??null,labelOf:(e,n)=>n===ke?di(e):li(e),renamePropOf:zi,beginRename:(e,n)=>hr({zone:e,index:n}),history:{hasPast:vt.hasPast,hasFuture:vt.hasFuture,back:()=>vt.back(),forward:()=>vt.forward()},openPageSettings:()=>{qt.select(null),Eo(L)},pageSettingsLabel:Lt.pageSettings,words:{menu:Wt,styleClipboard:Ht,screen:Lt.menu},readOnly:Boolean(pt),collapseAll:()=>Sr(new Set(ui(ke).map(e=>String(e.props.id)))),onPasteRefused:e=>Or(e?Lt.pasteRefused({name:e.label}):Lt.menu.clipboardRefused,"error"),canPasteAt:(e,n)=>Ll(e,n),menuRows:Xo.menuRows,isLocked:e=>Qo(e.type),duplicateBlocked:e=>er(kt.data,e),permits:e=>Se(xt,e.type),nodeOps:ii,isPinned:(e,n)=>n===ke&&(Mt(e)||jt(e)),sectionBand:_r,locate:e=>ai.get(e)??null,rowNameOf:(e,n)=>n===ke?ci(e):xi(e),selectAt:(e,n,t,o)=>{e===ke?Ri(n):ul(e,n,t,o??"")},slotRung:e=>{const n=mi(e);return n?.slot.panel?{label:n.slot.label,select:()=>ki(n.node,n.slot,!1)}:null},style:{held:()=>ae(Bi),canCopy:e=>Ii.rows(Ni,e).some(e=>!1!==e.counted),copy:(e,n)=>Ii.copy(Bi,e,Pi(e.type,n),Ni),paste:(e,n,t)=>Oi(e,n,t)},keys:ht?{target:xo,selected:()=>{const e=kt.ui.itemSelector;return e?{zone:e.zone??ke,index:e.index}:null},held:()=>ti.get(),readOnly:Boolean(pt),onDone:({done:e,name:n})=>{"copied"===e&&Or(Lt.copied({name:n}))}}:void 0},wo),Mi=In({copy:(e,n)=>{},paste:(e,n,t)=>{},at:()=>null,readOnly:!1});Pn(()=>{Mi.current={copy:(e,n)=>Ii.copy(Bi,e,Pi(e.type,n),Ni),paste:Oi,at:()=>{const e=kt.ui.itemSelector;if(!e)return null;const n=e.zone??ke,t=ui(n)[e.index];return t?{zone:n,index:e.index,node:t}:null},readOnly:Boolean(pt)}});const ji=On(e=>{const n=pe(e);if(!n)return;const t=Mi.current,o=t.at();o&&(e.preventDefault(),"copy"===n?t.copy(o.node,o.zone):t.readOnly||t.paste(o.zone,o.index,o.node))},[]);Pn(()=>{if(!xo)return;const e=e=>ji(e);return xo.addEventListener("keydown",e),()=>xo.removeEventListener("keydown",e)},[ji,xo]),mn(wo,"keydown",ji);const Ai=qr.map(e=>e.props.id).join("|");Pn(()=>{const e=wo?.document??null,n=wo?.window??null;let t=0;const o=[],r=()=>{if(!e)return void To(e=>e.length?[]:e);const n=qr.findIndex(jt),t=n>=0?n:qr.length,o=n=>{const t=qr[n]?.props?.id;return null==t?null:e.querySelector(`[data-puck-component="${CSS.escape(String(t))}"]`)},r=e=>e?[...e.querySelectorAll(hn)].map(e=>e.getBoundingClientRect()).filter(e=>e.width>0||e.height>0):[],i=[];for(let e=qr.length>0&&!Mt(qr[0])?0:1;e<=t;e++){const n=o(e),t=o(e-1),l=n?.getBoundingClientRect()??null,s=t?.getBoundingClientRect()??null;if(!l&&!s)continue;const d=_n(l&&s?(s.bottom+l.top)/2:l?0===e?l.top+12:l.top:s.bottom,Math.max(0===e?0:-1/0,...r(t).map(e=>e.bottom)),Math.min(1/0,...r(n).map(e=>e.top)));d&&i.push({...d,index:e})}To(e=>function(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t].top!==n[t].top||e[t].index!==n[t].index||e[t].height!==n[t].height)return!1;return!0}(e,i)?e:i)},i=()=>{cancelAnimationFrame(t),t=requestAnimationFrame(r)};if(!e||!n)return void r();n.addEventListener("scroll",i,{passive:!0});const l=new ResizeObserver(i);return l.observe(e.documentElement),r(),o.push(setTimeout(r,150),setTimeout(r,450)),()=>{cancelAnimationFrame(t),o.forEach(clearTimeout),n.removeEventListener("scroll",i),l.disconnect()}},[wo,Ai,lo,Fr,Qt,eo,bt?.props.id]);const Ti=wo?.document??null,Li=wo?.window??null;Pn(()=>{const e=vo.current;if(!e||!Ti||!Li)return;const n=[],t=()=>{const n=Ti.querySelector(`[data-puck-component="${CSS.escape(e.id)}"]`);if(!n)return!1;const t=n.getBoundingClientRect().top-e.offset;return Math.abs(t)>1&&Li.scrollTo({left:Li.scrollX,top:Li.scrollY+t,behavior:"instant"}),!0};return vo.current=null,t()&&n.push(setTimeout(t,150),setTimeout(t,450)),()=>n.forEach(clearTimeout)},[Ti,Li]);const Ei=e=>{Xo.holdCanvasOn?Xo.holdCanvasOn(e):c(e)},Ri=e=>{Eo(L),qt.select({index:e}),Xo.sectionPressed?.(qr[e]);const n=qr[e]?.props?.id;n&&Ei(n)},Vi=e=>{const{floor:n,cap:t}=_r(),o=e=>Math.min(Math.max(n,e),t);if("number"==typeof e)return o(e);const r=bt&&Lo.kind!==$t?.kind?qr.findIndex(e=>e.props.id===bt.props.id):-1;return o(r>=0?r+1:t)},Fi=(e,n)=>{const{floor:t,cap:o}=_r(),r=Math.min(Math.max(n,t),o),i=e<r?r-1:r;return i===e?{moved:!1,dest:e}:(qt.reorderComponent(ke,e,i),qt.select({index:i}),{moved:!0,dest:i})},Wi=(e,n,t,o)=>{Eo(L),qt.select(o?{index:o.index,zone:o.zone}:{index:e}),c(n),Or(Lt.sectionAdded({name:t}))},Hi=(e,n)=>{const t=Vi(n),o=tr(e,{nodeDefaults:si,newNodeId:Ce,sectionLabel:di,blockIsOffered:rr}),r=o?qt.insertNode(ke,t,o):qt.insertSection(e,t);return Wi(t,r,di(e),o?((e,n,t)=>{if(e.type===t)return null;const o={at:null},r=(e,n,i)=>{const l=i.filter(n=>n===e.type).length;for(const{child:s,zone:d,index:c}of be(xt,e)){if(s.type===t&&(!o.at||n>o.at.depth)){const r=or(e.type,l,d.slice(d.lastIndexOf(":")+1)),i=r?.choices??(r?.spec?[{type:r.spec.childType,label:r.spec.childType}]:[]);null!==r&&"footer"!==r.source&&`${e.props.id}:${r.slot}`===d&&i.some(e=>e.type===t)&&(o.at={zone:d,index:c,depth:n})}r(s,n+1,[...i,e.type])}};return r({type:e.type,props:{...e.props,id:n}},1,[]),o.at?{zone:o.at.zone,index:o.at.index}:null})(o,r,e):null),t},Di=e=>Ji(ke,e),Ji=(e,n)=>{Nr.current=document.activeElement??null,po&&(Oo.current=$o.current,$o.current=!1,uo()),jo(null===n?null:{zone:e,index:n}),Po(!0),Qt||(Oo.current=!0,St({type:"setUi",ui:{leftSideBarVisible:!0}}))},Ui=()=>{Po(!1),jo(null),Oo.current&&St({type:"setUi",ui:{leftSideBarVisible:!1}}),Oo.current=!1},Gi=(e,n)=>ir.rowName?n?Mt(e)?ir.rowName(e,"section",Lt.header):jt(e)?ir.rowName(e,"section",Lt.footer):Nt(e.type)?ir.rowName(e,"section",li(e.type)):ci(e):xi(e):n?di(e.type):li(e.type),Yi=e=>n=>{e()},Ki=()=>Xo.editPinnedSource?.(),Xi=(e,n,t)=>{if(pt)return null;const o=ui(e)[n];return o&&!Se(xt,o.type).delete?null:/* @__PURE__ */Jn(Le,{kind:"delete",label:Lt.deleteNamed({name:t}),onClick:()=>((e,n)=>{const t=ui(e)[n]?.props?.id;null!=t&&ri(String(t))})(e,n),children:/* @__PURE__ */Jn(Fn,{size:15})})},Zi=e=>ir.rowPreview?.(e)||void 0,qi=e=>ir.rowMarks?.(e)??void 0,_i=(e,n,t)=>ir.rowActions?.(e,n,t)??null,Qi=(e,n,t,o)=>{if(pt)return null;const r=Boolean(t.props._hidden);/* @__PURE__ */
10
+ return Jn(Le,{kind:"eye",label:r?Lt.showNamed({name:o}):Lt.hideNamed({name:o}),onClick:()=>nl(e,n,t),children:/* @__PURE__ */Jn(r?Wn:Hn,{size:14,strokeWidth:1.8,strokeLinecap:void 0,strokeLinejoin:void 0})})},el=e=>fs(ke,e),nl=(e,n,t)=>{qt.replaceComponent(e,n,{...t,props:{...t.props,_hidden:!t.props._hidden}})},tl=e=>we(xt,e),ol=e=>be(xt,e),rl=e=>_o.slotsOf?hi(e).map(n=>({slot:n.slot,rung:n.rung?n:null,kids:xe(e,n.slot)})):[{slot:null,rung:null,kids:ol(e)}],il=e=>_o.slotsOf?rl(e).flatMap(e=>e.kids):ol(e),ll=e=>Boolean(_o.slotsOf)&&hi(e).some(e=>e.rung),sl=(e,n,t)=>null===t?void 0===n?or(e):or(e,n):or(e,n,t),dl=(e,n,t)=>{const o=ze(xt,e.type,n)&&(t||il(e).length>0||ll(e));return{collapsible:o,folded:o&&Cr(String(e.props.id))}},cl=(e,n,t)=>rl(e).flatMap(o=>{const r=o.rung?n+1:n,i=o.kids.flatMap(({child:e})=>dl(e,r,t(e.type)).collapsible?[String(e.props.id),...cl(e,r+1,t)]:[]);return o.rung?[`${e.props.id}:${o.rung.slot}`,...i]:i}),al=e=>il(e).length>0||ll(e)||Boolean(or(e.type)),pl=e=>Boolean(or(e)),ul=(e,n,t,o)=>{if(Eo(L),or(o)?.spec?.slider){const t=e.split(":")[0];a(t,n),qt.select({index:n,zone:e}),c(t)}else qt.select({index:n,zone:e}),Ei(t)},fl=(e,n,t,o,r)=>{const i=`${e}:${n}`;qt.insertComponent(i,t,o),or(r)?.spec?.slider?requestAnimationFrame(()=>{a(e,o),qt.select({index:o,zone:i})}):qt.select({index:o,zone:i})},hl=In(/* @__PURE__ */new Set);Pn(()=>{qr.forEach(e=>{const n=or(e.type)?.spec;if(!n)return;const t=e.props.id;if(hl.current.has(t))return;hl.current.add(t);if((Array.isArray(e.props[n.slot])?e.props[n.slot]:[]).length>0)return;if(n.skipSeed?.(e.props))return;const o=`${t}:${n.slot}`,r=n.legacy?.(e.props)??[];(r.length?r:n.seeds(si)).forEach((e,t)=>Kt.seedChild(o,t,n.childType,e))})},[qr,Kt,si]);const ml=In(/* @__PURE__ */new Set);Pn(()=>{qr.forEach((e,n)=>{const t=e.props.id;if(ml.current.has(t))return;const o=i(e,tl(e.type));ml.current.add(t),o&&Kt.replaceComponent(ke,n,{...e,props:o})})},[qr,Kt]),G(Kt,xt);const gl=qr.findIndex(jt),yl=gl>=0?qr[gl]:null,kl=At?qr.findIndex(Mt):-1,Sl=kl>=0?qr[kl]:null,vl=zt.groupTab,bl=Bn(()=>vl?e=>Nt(e.type):void 0,[vl]),wl=Boolean(zt.groupBadge),xl=zt.groupBadge?/* @__PURE__ */Jn("span",{className:"es-tree-group-badge",children:/* @__PURE__ */Jn(jn,{tone:"info",size:"xs",children:zt.groupBadge})}):void 0,zl=qr.find(e=>e.type===It)??null,Cl=qr.find(e=>e.type===Bt)??null,Il=gl>=0?gl:qr.length,Bl=[];qr.forEach(e=>{jt(e)||(al(e)&&Bl.push(String(e.props.id)),Bl.push(...cl(e,1,pl)))}),yl&&(Bl.push(String(yl.props.id)),Bl.push(...cl(yl,1,pl)));const Nl=Bl.length>0&&Bl.every(e=>kr.has(e)),Pl=e=>{const n=ir.blockRowName(e,li);return ir.rowName?ir.rowName(e,"block",n):n},Ol=(e,n,t,o)=>{const r=ui(e)[t];if(!r)return;const i={...xn(e),index:t},l={...xn(n),index:Math.min(Math.max(o,0),ui(n).length)},s=pn(i,l);if(e!==n||s!==t)try{oi.move(String(r.props.id),{...l,index:s})}catch(e){if(!(e instanceof Cn))throw e}},$l=e=>{const n=/* @__PURE__ */new Set,t=e=>{for(const{child:o,zone:r}of ol(e))n.add(r),t(o)};for(const t of tl(e.type))n.add(`${e.props.id}:${t}`);return t(e),n},Ml=e=>{let n=e.slice(0,e.indexOf(":"));for(let e=0;e<64;e++){const e=ai.get(n);if(!e)return null;if(e.zone===ke)return n;n=e.zone.slice(0,e.zone.indexOf(":"))}return null},jl=e=>{const n=e.slice(0,e.indexOf(":")),t=qr.find(e=>Nt(e.type)&&String(e.props.id)===n);return t&&Pt(n)===e?t:null},Al=(e,n)=>{const t=jl(e);return!t||(!zt.groupAccepts||zt.groupAccepts(t.type,n,ui(e).length))},Tl=(e,n,t)=>{if(e.rung){const t=fi(e.rung.nodeId),o=t?hi(t).filter(e=>e.rung).length:0;return n.parentId===e.rung.nodeId&&n.slot===Qn&&n.index>=0&&n.index<=o}if(n.slot===Qn)return!1;if(e.add)return Vl(e.add,n);const o=wn(n);if(Nt(e.type))return!1;const r=jl(o),i=jl(e.zone);if(r||i)return!(!r||!i)&&(!(r!==i&&!Al(o,e.type))&&(n.index>=0&&n.index<=ui(o).length));if(e.zone===ke||o===ke){if(e.zone!==o)return!1;const{floor:t,cap:r}=_r();return n.index>=t&&n.index<=r}if(n.index<0||n.index>ui(o).length)return!1;if(e.zone===o)return!0;const l=yl&&!zt.lastIsOpen?String(yl.props.id):null;return(!l||Ml(e.zone)!==l&&Ml(o)!==l)&&((e,n,t,o)=>{if(e===n)return!0;const r=o??ui(e)[t];if(!r)return!1;const i=n.split(":")[0],l=ai.get(i),s=l?ui(l.zone)[l.index]:void 0;if(!s)return!1;if(!o&&$l(r).has(n))return!1;const d=or(s.type,nr(kt?.data,s.type,i),n.slice(n.lastIndexOf(":")+1));return!!d&&(!!(d.choices?d.choices.some(e=>e.type===r.type):d.spec?.childType===r.type)&&!d.spec?.addBlocked?.(ui(n),r))})(e.zone,o,e.index,t)},Ll=(e,n)=>{const t=wn(e.from),o=e.node;return t===wn(n)?Al(t,o.type):Tl({id:String(o.props?.id??""),zone:t,index:-1,type:o.type},n,o)},El=e=>{const n=e.slice(0,e.indexOf(":")),t=ai.get(n),o=t?ui(t.zone)[t.index]:void 0;if(!t||!o)return null;const r=or(o.type,nr(kt?.data,o.type,n),e.slice(e.lastIndexOf(":")+1));if(!r||`${n}:${r.slot}`!==e)return null;if("footer"===r.source)return null;const i=r.choices??(r.spec?[{type:r.spec.childType,label:li(r.spec.childType)}]:[]),l=mi(e);return{parent:o,parentId:n,target:r,choices:i,parentName:l?l.slot.label:Gi(o,t.zone===ke)}},Rl=(e,n)=>{if("section"!==e.kind)return e;const t=wn(n);return t===ke||jl(t)?e:El(t)?.choices.some(n=>n.type===e.type)?{kind:"block",type:e.type}:e},Vl=(e,n)=>{const t=Rl(e,n),o=wn(n);if("block"!==t.kind){if(jl(o)){const e="section"===t.kind?t.type:t.template.node.type;return Al(o,e)&&n.index>=0&&n.index<=ui(o).length}if(o!==ke)return!1;const{floor:e,cap:r}=_r();return n.index>=e&&n.index<=r}if(o===ke)return!1;const r=El(o);return!(!r||!r.choices.some(e=>e.type===t.type))&&!r.target.spec?.addBlocked?.(ui(o))},Fl=(e,n)=>{const t=Rl(e,n);if("block"!==t.kind&&jl(wn(n)))return void((e,n,t)=>{const o="section"===e.kind?e.type:"template"===e.kind?e.template.node.type:null;if(o&&Al(n,o)){if("section"===e.kind)qt.insertComponent(n,e.type,t);else{if("template"!==e.kind)return;qt.insertNode(n,t,ni(e.template.node))}Eo(L),qt.select({index:t,zone:n})}})(t,wn(n),n.index);if("section"===t.kind)return void Hi(t.type,n.index);if("template"===t.kind)return void((e,n,t)=>{const o=Vi(t),r=qt.insertNode(ke,o,n);Wi(o,r,e)})(t.template.name,ni(t.template.node),n.index);const o=wn(n),r=El(o);r&&(r.target.spec?fl(r.parentId,r.target.slot,t.type,n.index,r.parent.type):((e,n,t)=>{qt.insertComponent(e,n,t),Eo(L),qt.select({index:t,zone:e})})(o,t.type,n.index))},Wl=(e,n)=>{e.rung?vi(e.rung.nodeId,e.index,n.index):e.add?Fl(e.add,n):e.zone===ke?Fi(e.index,n.index):Ol(e.zone,wn(n),e.index,n.index)},[Hl]=Nn(()=>cn()),Dl=an({keyOf:e=>e.id,readOnly:Boolean(pt),session:Hl,canDrop:Tl,onDrop:Wl,onStep:(e,n)=>{e.rung?vi(e.rung.nodeId,e.index,n<0?e.index-1:e.index+2):e.zone===ke?((e,n)=>{const t=di(qr[e]?.type??""),o=Fi(e,n<0?e-1:e+2);if(!o.moved)return void Or(n<0?Lt.sectionFirst({name:t}):Lt.sectionLast({name:t}));const{floor:r,cap:i}=_r();Or(Lt.sectionMoved({name:t,n:o.dest-r+1,total:i-r}))})(e.index,n):Ol(e.zone,e.zone,e.index,n<0?e.index-1:e.index+2)}}),Jl=On(e=>{const{floor:n,cap:t}=_r(),o=[];for(const r of e.nodes){const e=wn(r.place),i=ui(e)[r.place.index];if(!i||String(i.props.id)!==r.id)continue;if(Mt(i)||jt(i)||Qo(i.type))continue;if(Nt(i.type))continue;const l=Boolean(jl(e)),s=e===ke||l;e===ke&&t-n<2||o.push({key:r.id,item:{id:r.id,zone:e,index:r.place.index,type:i.type},box:r.box,label:s?di(i.type):xi(i),from:r.place})}const r=e.zones.flatMap(e=>{const n=wn(e.list);if(n===ke&&0===e.children.length)return[{...e,addLabel:Lt.addSection,addAlways:!0}];const t=El(n),o=t?.target.spec?.addLabel;return e.children.length>0||Boolean(t?.choices.length)||Boolean(jl(n))?[o?{...e,addLabel:o}:e]:[]}),i=r.flatMap(e=>{const n=wn(e.list),t=n===ke||jl(n)?null:El(n);return t?.choices.length?rn(e,t.target.spec?.addLabel??Lt.addBlockHere):[]});return{sources:o,zones:r,seams:i}},[kt.data]),Ul=null==bt?.props.id?null:String(bt.props.id),Gl=On(e=>{const n=xt,t=e=>!e.item.rung&&null!==zn(kt.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(Ul);return i||(r($e(kt.data,n,o.item.id,Ul,bl))??o)},[kt.data,xt,Ul,bl]),[Yl,Kl]=Nn(null);mn(wo,"mouseover",e=>{if(!vl)return;const n=gn(e.target),t=n?Kn(kt.data,xt,n):null;t!==Yl&&Kl(t)}),mn(wo,"mouseout",e=>{vl&&!e.relatedTarget&&Kl(null)});const Xl=e=>Mt(e)||jt(e)||Nt(e.type),Zl=[];if(vl){const e=Ul?Kn(kt.data,xt,Ul):null;for(const n of/* @__PURE__ */new Set([e,Yl])){const e=n?qr.find(e=>String(e.props.id)===n):void 0;if(!e||!Xl(e))continue;const t=vl(e);t&&Zl.push({id:String(e.props.id),label:t,below:Mt(e)||e.type===It})}}const ql=le(),_l=In(null);Pn(()=>{const e=zt.changeNotice;if(!e)return;const n=JSON.stringify(qr.filter(Xl)),t=_l.current;if(_l.current={doc:kn,bands:n,index:vt.index},!t||t.doc!==kn||t.bands===n)return;vt.hasPast&&vt.index>=t.index&&!Yn.has(ql)&&(Yn.add(ql),Or(e,"success",{action:{label:Lt.bar.undo,onClick:()=>vt.back()},duration:8e3}))},[qr]);const Ql=e=>{Eo(L),qt.select(e.zone===ke?{index:e.index}:{index:e.index,zone:e.zone})},es=Y(),ns=()=>({data:kt.data,device:lo,ops:qt,inspector:Ko}),ts=es?.model,os=Bn(()=>ts?e=>ts(e,Jl(e),ns()):Jl,[ts,Jl,lo]),rs=es?.measure,is=rs?(e,n)=>rs(e,n,ns()):void 0,ls=es?.canDrop,ss=ls?(e,n)=>ls(e,n,Tl,ns()):Tl,ds=es?.drop,cs=ds?(e,n)=>ds(e,n,Wl,ns()):Wl,as=es?.pick,ps=as?e=>as(e,Ql,ns()):Ql,us=e=>{const n=wn(e),t=mi(n);t&&ki(t.node,t.slot,!1),Ji(n,e.index)},fs=(e,n)=>/* @__PURE__ */Jn(Ee,{...pt?{}:Dl.seam({place:{...xn(e),index:n}})},`seam:${e}:${n}`),hs={rowClick:Yi,isCollapsed:Cr,toggleCollapse:Ir},ms=e=>{const n=String(e.props.id),t=qr.findIndex(e=>String(e.props.id)===n),o=Pt(n),r=ui(o),i=Cr(n),l=li(e.type),s=ir.rowName?ir.rowName(e,"section",l):l,d=e=>fs(o,e);/* @__PURE__ */
11
+ return Un(Gn,{children:[
12
+ /* @__PURE__ */Jn(Me,{words:Et,icon:/* @__PURE__ */Jn(sr,{type:e.type,size:13}),name:s,preview:Zi(e),marks:qi(e),onSelect:()=>Ri(t),nameSlot:Ci(ke,t,n,s),selected:Vo===n,badge:xl,actions:_i(e,ke,t)??void 0,rowProps:{"data-node-id":n,onClick:Yi(()=>Ri(t))},fold:{open:!i,label:"section",onToggle:()=>Ir(n)}}),!i&&/* @__PURE__ */Un(je,{children:[r.map((n,t)=>{const r=String(n.props.id),i=ci(n),l=al(n),s=l&&Cr(r),c=()=>ul(o,t,r,e.type),{rowProps:a,...p}=Dl.row({item:{id:r,zone:o,index:t,type:n.type},place:{...xn(o),index:t}},{"data-node-id":r,onClick:Yi(c)});/* @__PURE__ */
13
+ return Un(Mn,{children:[d(t),
14
+ /* @__PURE__ */Jn(Me,{words:Et,icon:/* @__PURE__ */Jn(sr,{type:n.type,size:13}),name:i,preview:Zi(n),marks:qi(n),onSelect:c,nameSlot:Ci(o,t,r,i),selected:Vo===r,hidden:Boolean(n.props._hidden),...p,fold:l?{open:!s,label:"section",onToggle:()=>Ir(r)}:void 0,actions:/* @__PURE__ */Un(Gn,{children:[Xi(o,t,i),_i(n,o,t),Qi(o,t,n,i)]}),rowProps:a}),l&&!s&&/* @__PURE__ */Jn(je,{children:ks(n,2)})]},r)}),d(r.length)]})]})},gs=(e,n,t,o,r)=>{const i=String(e.props.id),l=`${i}:${n.slot}`,s=Dl.dragging,d=!Cr(l)&&s?.rung?.nodeId!==i,c={...xn(l),index:0},a=s&&!s.rung&&Tl(s,c)?c:void 0,p=()=>ki(e,n,!0),{rowProps:u,...f}=Dl.row({item:{id:`rung:${l}`,zone:`${i}:${Qn}`,index:t,type:e.type,rung:{nodeId:i,slot:n.slot}},place:{parentId:i,slot:Qn,index:t},into:a,canDrag:Boolean(_o.moveSlot)&&!1!==n.movable&&o>1},{"data-slot-zone":l,onClick:Yi(p)}),h=pt?null:_o.slotActions?.(e,n.slot);/* @__PURE__ */
15
+ return Un(Mn,{children:[n.heading,
16
+ /* @__PURE__ */Jn(Me,{words:Et,icon:n.glyph??null,name:n.label,badge:n.badge,onSelect:p,selected:gi===l,...f,dragHint:n.dragHint,fold:{open:d,label:n.label,onToggle:()=>Ir(l)},actions:h&&h.length>0?/* @__PURE__ */Jn(Gn,{children:h.map((t,o)=>/* @__PURE__ */Jn(Le,{kind:"delete"===t.kind?"delete":"plain",label:t.label,disabled:t.disabled,onClick:()=>((e,n,t)=>{if(pt||t.disabled)return;const o=String(e.props.id),r=e=>{"string"==typeof e&&Si(o,e,n.panel)},i=t.run();i&&"function"==typeof i.then?i.then(r):r(i)})(e,n,t),children:"delete"===t.kind?/* @__PURE__ */Jn(Fn,{size:15}):/* @__PURE__ */Jn(Dn,{size:15})},`${o}:${t.kind}`))}):void 0,rowProps:u}),d&&/* @__PURE__ */Jn(je,{children:r})]},l)},ys=(e,n)=>{const t=rl(e),o=t.filter(e=>e.rung).length;let r=0;/* @__PURE__ */
17
+ return Jn(Gn,{children:t.map(t=>{const i=t.kids,l=t.rung?n+1:n,s=sl(e.type,void 0,t.slot),d=s?`${e.props.id}:${s.slot}`:null,c=null===t.slot?null:`${e.props.id}:${t.slot}`,a=(e,n)=>fs(e,n),p=/* @__PURE__ */Un(Gn,{children:[i.map(({child:n,zone:t,index:o})=>{const r=Vo===String(n.props.id),{collapsible:i,folded:s}=dl(n,l,pl(n.type)),d=String(n.props.id),c=Pl(n),p=()=>ul(t,o,d,e.type),{rowProps:u,...f}=Dl.row({item:{id:d,zone:t,index:o,type:n.type},place:{...xn(t),index:o}},{"data-node-id":d,onClick:Yi(p)});/* @__PURE__ */
18
+ return Un(Mn,{children:[0===o&&a(t,0),
19
+ /* @__PURE__ */Jn(Me,{words:Et,icon:/* @__PURE__ */Jn(sr,{type:n.type,size:13}),name:c,preview:Zi(n),marks:qi(n),onSelect:p,nameSlot:Ci(t,o,d,c),selected:r,hidden:Boolean(n.props._hidden),...f,fold:i?{open:!s,label:"group",onToggle:()=>Ir(d)}:void 0,actions:/* @__PURE__ */Un(Gn,{children:[Xi(t,o,c),_i(n,t,o),Qi(t,o,n,c)]}),rowProps:u}),i&&!s&&/* @__PURE__ */Jn(je,{children:ys(n,l+1)}),a(t,o+1)]},String(n.props.id??`${t}-${o}`))}),null===c?d&&!i.some(e=>e.zone===d)?a(d,0):null:0!==i.length||!t.rung&&d!==c?null:a(c,0)]});return t.rung?gs(e,t.rung,r++,o,p):/* @__PURE__ */Jn(Mn,{children:p},t.slot??"")})})},ks=(e,n)=>{const t=nr(kt?.data,e.type,String(e.props.id)),o=rl(e),r=o.filter(e=>e.rung).length;let i=0;/* @__PURE__ */
20
+ return Jn(Gn,{children:o.map(o=>{const l=o.kids,s=o.rung?n+1:n,d=sl(e.type,t,o.slot),c=d?.spec??null,a=c&&Array.isArray(e.props[c.slot])?e.props[c.slot]:[],p=d&&d.choices?{slot:d.slot,choices:d.choices}:null,u=String(e.props.id),f=c&&!c.fixed?`${u}:${c.slot}`:null,h=p?`${u}:${p.slot}`:null,m=(e,n)=>fs(e,n),g=null===o.slot?null:`${u}:${o.slot}`,y=Boolean(c&&!c.fixed&&(null===g||g===f)),k=/* @__PURE__ */Un(Gn,{children:[l.map(({child:n,zone:t,index:o})=>{const r=Vo===String(n.props.id),i=xi(n),l=String(n.props.id),{collapsible:d,folded:c}=dl(n,s,pl(n.type)),a=tl(n.type),p=1===a.length?`${l}:${a[0]}`:null,u=p?{...xn(p),index:ui(p).length}:void 0,f=Dl.dragging,h=u&&f&&Tl(f,u)?u:void 0,g=()=>ul(t,o,l,e.type),{rowProps:y,...k}=Dl.row({item:{id:l,zone:t,index:o,type:n.type},place:{...xn(t),index:o},into:h,canDrag:!Qo(n.type)},{"data-node-id":l,onClick:Yi(g)});/* @__PURE__ */
21
+ return Un(Mn,{children:[0===o&&m(t,0),
22
+ /* @__PURE__ */Jn(Me,{words:Et,icon:/* @__PURE__ */Jn(sr,{type:n.type,size:13}),name:i,preview:Zi(n),marks:qi(n),onSelect:g,nameSlot:Ci(t,o,l,i),selected:r,hidden:Boolean(n.props._hidden),...k,fold:d?{open:!c,label:"group",onToggle:()=>Ir(l)}:void 0,actions:Qo(n.type)?_i(n,t,o)??void 0:/* @__PURE__ */Un(Gn,{children:[Xi(t,o,i),_i(n,t,o),Qi(t,o,n,i)]}),rowProps:y}),d&&!c&&/* @__PURE__ */Jn(je,{children:ks(n,s+1)}),m(t,o+1)]},String(n.props.id??`${t}-${o}`))}),y&&c&&
23
+ /* @__PURE__ */Jn(w,{small:!0,label:c.addLabel,blocked:c.addBlocked?.(a)??null,onAdd:()=>fl(e.props.id,c.slot,c.childType,a.length,e.type)}),null===g?h&&!l.some(e=>e.zone===h)?m(h,0):null:0!==l.length||(o.rung?y:g!==h)?null:m(g,0)]});return o.rung?gs(e,o.rung,i++,r,k):/* @__PURE__ */Jn(Mn,{children:k},o.slot??"")})})},Ss=No||null!==po,vs=e=>"panel"in e?{id:e.id,label:e.label,icon:e.icon,active:Qt&&!Ss&&qo===e.id,onSelect:()=>Yr(e.id)}:e,bs=[...(Xo.railLead??[]).map(vs),{id:"sections",label:Lt.layers,icon:/* @__PURE__ */Jn(Ve,{}),active:Qt&&!Ss&&"sections"===qo,onSelect:()=>Yr("sections")},...(Xo.railTrail??[]).map(vs)];ao?bs.push({id:"media",label:Lt.railMedia,icon:/* @__PURE__ */Jn(Fe,{}),active:Qt&&!No&&(null!==po||"media"===qo),onSelect:()=>Yr("media")}):mt&&bs.push({id:"media",label:Lt.railMedia,icon:/* @__PURE__ */Jn(Fe,{}),onSelect:Kr});const ws=[...Xo.railLead??[],...Xo.railTrail??[]].find(e=>"panel"in e&&e.id===qo),xs=Boolean(Tt?.foldable)&&!Zo,zs=Tt?.label??(gt?Lt.pageSections:Lt.templateSections),Cs=xs&&Cr(et),Is=/* @__PURE__ */Un(Gn,{children:[qr.map((e,n)=>{if(Mt(e)||jt(e)||Nt(e.type))return null;const t=Vo===String(e.props.id),o=Boolean(e.props._hidden);ol(e);const r=String(e.props.id),i=Xo.hasOwnRows?.(e)??!1,l=al(e)||i,s=l&&Cr(r),d=tl(e.type),c=1===d.length?`${r}:${d[0]}`:null,a=c?{...xn(c),index:ui(c).length}:void 0,p=Dl.dragging,u=a&&p&&Tl(p,a)?a:void 0,{rowProps:f,...h}=Dl.row({item:{id:r,zone:ke,index:n,type:e.type},place:{...xn(ke),index:n},into:u},{"data-node-id":r,onClick:Yi(()=>Ri(n))});/* @__PURE__ */
24
+ return Un(Mn,{children:[n>0&&el(n),
25
+ /* @__PURE__ */Jn(Me,{words:Et,icon:/* @__PURE__ */Jn(sr,{type:e.type,size:13}),name:ci(e),preview:Zi(e),marks:qi(e),onSelect:()=>Ri(n),nameSlot:Ci(ke,n,r,ci(e)),selected:t,hidden:o,...h,fold:l?{open:!s,label:"section",onToggle:()=>Ir(r)}:void 0,actions:/* @__PURE__ */Un(Gn,{children:[Xi(ke,n,ci(e)),_i(e,ke,n),Qi(ke,n,e,ci(e))]}),rowProps:f}),al(e)&&!s&&/* @__PURE__ */Un(je,{children:[ks(e,1),Xo.partRows?.(e,hs)]}),i&&!s&&/* @__PURE__ */Jn(je,{children:Xo.ownRows?.(e,n,hs)})]},String(e.props.id??n))}),!Zo&&Il>0&&el(Il)]}),Bs=(e,n,t)=>{const o=String(e.props.id),r=il(e).length>0||ll(e)||Boolean(or(e.type)),i=r&&Cr(o),l="header"===t?Lt.header:Lt.footer,s=ir.rowName?ir.rowName(e,"section",l):l;/* @__PURE__ */
26
+ return Un(Gn,{children:[
27
+ /* @__PURE__ */Jn(Me,{words:Et,icon:/* @__PURE__ */Jn(sr,{type:t,size:13}),name:s,preview:Zi(e),marks:qi(e),badge:xl,onSelect:()=>Ri(n),nameSlot:Ci(ke,n,o,s),selected:Vo===String(e.props.id),fold:r?{open:!i,label:"section",onToggle:()=>Ir(o)}:void 0,actions:_i(e,ke,n)??void 0,rowProps:{"data-node-id":o,onClick:Yi(()=>Ri(n))}}),r&&!i&&/* @__PURE__ */Jn(je,{children:ys(e,1)})]})};return(Xo.wrap??(e=>e))(
28
+ /* @__PURE__ */Jn(K,{target:wo,children:/* @__PURE__ */Un("div",{ref:bo,className:"sf-editor es-editor",style:qe(vr),onContextMenu:$i.onEditorContextMenu,...m(fn),children:[
29
+ /* @__PURE__ */Un(We,{children:[
30
+ /* @__PURE__ */Jn(He,{items:bs,ariaLabel:Lt.bar.views}),
31
+ /* @__PURE__ */Un(De,{children:[
32
+ /* @__PURE__ */Jn(Je,{label:Lt.bar.undo,disabled:Boolean(pt)||!vt.hasPast,onClick:()=>vt.back(),children:/* @__PURE__ */Jn(Ln,{})}),
33
+ /* @__PURE__ */Jn(Je,{label:Lt.bar.redo,disabled:Boolean(pt)||!vt.hasFuture,onClick:()=>vt.forward(),children:/* @__PURE__ */Jn(En,{})}),
34
+ /* @__PURE__ */Jn(Ue,{}),
35
+ /* @__PURE__ */Jn(Ge,{devices:no,value:lo,onChange:so}),
36
+ /* @__PURE__ */Jn(Je,{label:Lt.bar.refresh,tip:Lt.bar.refreshTip,onClick:()=>{vo.current=(()=>{const e=wo?.document;if(!e)return null;const n=qr.findIndex(jt),t=n>=0?n:qr.length;let o=null;for(let n=0;n<t;n++){const t=qr[n]?.props?.id;if(null==t)continue;const r=e.querySelector(`[data-puck-component="${CSS.escape(String(t))}"]`);if(!r)continue;const i=r.getBoundingClientRect().top;i<=4&&(null===o||i>o.offset)&&(o={id:String(t),offset:i})}if(!o){const e=bt?.props?.id??qr[0]?.props?.id;null!=e&&(o={id:String(e),offset:0})}return o})(),So(e=>e+1)},children:/* @__PURE__ */Jn(Rn,{})})]}),
37
+ /* @__PURE__ */Un(De,{kind:"right",style:{minWidth:300},children:[
38
+ /* @__PURE__ */Jn(l,{input:Io,words:Lt.saveStatus}),Xo.barLead?.(),Xo.barTrail?.(),Xo.mainAction||!Xo.barMain?/* @__PURE__ */Jn(s,{input:Io,action:Xo.mainAction??{label:Lt.done,onPress:()=>{ot(kt.data)}},readOnly:Boolean(pt),saveSwitch:ft,onToggleAutoSave:st,onSaveNow:Bo,bar:Lt.bar,words:Lt.saveStatus}):Xo.barMain()]})]}),
39
+ /* @__PURE__ */Jn(ee,{}),
40
+ /* @__PURE__ */Un("div",{className:"sf-body",children:[Qt?/* @__PURE__ */Un(Gn,{children:[
41
+ /* @__PURE__ */Jn("aside",{className:"es-sidepanel es-sidepanel--left sf-panel sf-panel--left","aria-label":Lt.leftPanel,children:No?/* @__PURE__ */Jn(x,{at:Mo?{label:(e=>{const n=jl(e.zone);if(n)return Lt.add.addingTo({name:ir.rowName?Gi(n,!0):li(n.type)});if(e.zone===ke){const n=qr[e.index];return n&&!jt(n)?Lt.add.addingBefore({name:Gi(n,!0)}):Lt.add.addingAtEnd}const t=El(e.zone);return t?Lt.add.addingTo({name:t.parentName}):Lt.add.addingHere})(Mo),onClear:()=>jo(null)}:void 0,placeBlocks:Mo&&Mo.zone!==ke?El(Mo.zone)?.choices:void 0,canTake:Mo?e=>{if(!Mo)return null;const n={...xn(Mo.zone),index:Mo.index};if(Vl(e,n))return null;const t=jl(Mo.zone);if(t)return Lt.add.notInside({name:Gi(t,!0)});if(Mo.zone===ke)return Lt.add.onlySections;const o=El(Mo.zone);return o?Lt.add.notInside({name:o.parentName}):Lt.add.onlySections}:void 0,onPick:Mo?e=>{if(!Mo)return;const n={...xn(Mo.zone),index:Mo.index};Vl(e,n)&&(Fl(e,n),Ui())}:void 0,itemFor:e=>({id:`new:${e.kind}:${"template"===e.kind?e.template.id:e.type}`,zone:"",index:-1,type:"template"===e.kind?e.template.node.type:e.type,add:e}),session:Hl,siteWide:Xo.addPanelRow?.(Ui),onClose:Ui,onHide:Ur,readOnly:Boolean(pt)}):po&&co?
42
+ /* @__PURE__ */Jn(I,{panel:co,pick:po,onHide:Ur}):ws?ws.panel({onHide:Ur,notify:Or}):"media"===qo&&co?/* @__PURE__ */Jn(I,{panel:co,pick:null,onHide:Ur}):/* @__PURE__ */Un(Gn,{children:[
43
+ /* @__PURE__ */Jn(z,{icon:/* @__PURE__ */Jn(Ve,{}),title:Lt.layers,context:Jt,actions:/* @__PURE__ */Un(Gn,{children:[!pt&&/* @__PURE__ */Jn(Ye,{label:Lt.add.title,onClick:()=>Di(null),children:/* @__PURE__ */Jn(Vn,{size:15})}),
44
+ /* @__PURE__ */Jn(Ye,{label:Nl?Lt.expandAll:Lt.collapseAll,title:0===Bl.length?Lt.nothingToFold:void 0,disabled:0===Bl.length,onClick:()=>Sr(e=>{const n=new Set(Bl);return Nl?new Set([...e].filter(e=>!n.has(e))):/* @__PURE__ */new Set([...e,...Bl])}),children:/* @__PURE__ */Jn(Zn,{expand:Nl})})]}),onHide:Ur}),
45
+ /* @__PURE__ */Un(Ae,{className:"sf-tree sf-scroll",words:Et,children:[
46
+ /* @__PURE__ */Jn(Me,{words:Et,icon:/* @__PURE__ */Jn(sr,{type:"page",size:13}),name:Lt.pageSettings,onSelect:Xr,selected:!bt&&Ro,rowProps:{onClick:Yi(Xr)}}),zl&&/* @__PURE__ */Un(Gn,{children:[!wl&&/* @__PURE__ */Jn(Te,{children:Lt.header}),ms(zl)]}),!Zo&&yt&&!(wl&&zl)&&/* @__PURE__ */Un(Gn,{children:[!wl&&/* @__PURE__ */Jn(Te,{children:Lt.header}),!At&&/* @__PURE__ */Jn(Me,{words:Et,icon:/* @__PURE__ */Jn(sr,{type:"header",size:13}),name:Lt.header,badge:xl,onSelect:Zr,selected:Lo.kind===$t?.kind,rowProps:{onClick:Yi(Zr)}})]}),!Zo&&Sl&&!(wl&&zl)&&Bs(Sl,kl,"header"),!Zo&&!xs&&/* @__PURE__ */Jn(Te,{children:zs}),xs?/* @__PURE__ */Un(Gn,{children:[
47
+ /* @__PURE__ */Jn(Me,{words:Et,icon:null,name:zs,fold:{open:!Cs,label:zs,onToggle:()=>Ir(et)}}),!Cs&&/* @__PURE__ */Jn(je,{children:Is})]}):Is,yt&&!wl&&/* @__PURE__ */Jn(Te,{children:Lt.footer}),yl&&!(wl&&Cl)&&Bs(yl,gl,"footer"),!Zo&&!yl&&yt&&!wl&&/* @__PURE__ */Jn(Me,{words:Et,icon:/* @__PURE__ */Jn(sr,{type:"footer",size:13}),name:Lt.footer,onSelect:Ki,rowProps:{onClick:Yi(Ki),title:Lt.editFooter}}),Cl&&ms(Cl),Xo.treeFoot?.()]})]})}),
48
+ /* @__PURE__ */Jn(Ke,{side:"left",width:vr.left,min:Ze,max:Xe,defaultWidth:k.left,label:Lt.resizeLeftPanel,onResize:xr})]}):/* @__PURE__ */Jn(C,{side:"left",onShow:Ur}),
49
+ /* @__PURE__ */Un("div",{ref:$r,className:"sf-center sf-scroll","data-sf-canvas-head":Lr?"":void 0,style:{overflowX:Hr?"auto":"hidden",overflowY:"hidden"},children:[Lr&&/* @__PURE__ */Jn("div",{ref:Er,className:"sf-canvas-head",children:/* @__PURE__ */Jn(Lr,{device:lo})}),
50
+ /* @__PURE__ */Un("div",{className:"sf-frame-scaler",style:Dr,children:[
51
+ /* @__PURE__ */Jn("div",{className:"sf-frame "+(lo===ro?"":`sf-frame--${lo}`),style:Jr,children:/* @__PURE__ */Un("div",{className:"sf-preview-host",children:[
52
+ /* @__PURE__ */Jn(Ne.Provider,{value:bl,children:/* @__PURE__ */Jn(Ut,{},ko)}),
53
+ /* @__PURE__ */Jn(ln,{canvas:wo,session:Hl,model:os,measure:is,canDrop:ss,onDrop:cs,choose:Gl,onPick:ps,onZoneAdd:us,onSeamAdd:us,zoneAddLabel:Lt.canvasAddBlock,words:Rt.canvas,readOnly:Boolean(pt),revision:kt.data}),Ao.length>0&&/* @__PURE__ */Jn("div",{className:"sf-preview-gaps",children:Ao.map(e=>
54
+ /* @__PURE__ */Jn(sn,{index:e.index,label:Lt.addSectionHere,onInsert:()=>Di(e.index),className:void 0===e.height?"sf-preview-gap":"sf-preview-gap sf-preview-gap--tight",style:void 0===e.height?{top:e.top}:{top:e.top,height:e.height}},e.index))})]})}),vl?/* @__PURE__ */Jn(Xn,{canvas:wo,tabs:Zl,onSelect:e=>{const n=qr.findIndex(n=>String(n.props.id)===e);n>=0&&Ri(n)}}):null]})]}),eo?/* @__PURE__ */Un(Gn,{children:[
55
+ /* @__PURE__ */Jn(g,{value:{selectChild:ul,addChild:fl,childRowName:xi,blockRowName:Pl},children:/* @__PURE__ */Jn(Gt,{mode:Lo,onOpenWebsiteSettings:Xo.openSettings??(()=>{}),onOpenSiteStyles:Xo.openStyles,onSelectNode:pr,onNotify:Or,onHidePanel:Gr,nodeActions:bt?Se(xt,bt.type):nt})}),
56
+ /* @__PURE__ */Jn(Ke,{side:"right",width:vr.right,min:Ze,max:Xe,defaultWidth:k.right,label:Lt.resizeSettingsPanel,onResize:zr})]}):
57
+ /* @__PURE__ */Jn(C,{side:"right",onShow:Gr})]}),$i.menu]})}))}export{tt as ScreenChrome};
@@ -0,0 +1,5 @@
1
+ import{usePickFollowsSelection as n}from"./chunk-R6WTQWAC.js";import{slotFieldsOf as e}from"./chunk-PLVEGYK6.js";import{EaselCanvas as t,useSelectedFields as r}from"./chunk-PVAIOBBE.js";import{Inspector as i}from"./chunk-BPZQ7S2Z.js";import{createContext as o,useContext as u}from"react";import{DesktopIcon as l}from"efficient-shell/icons/efficient";import{jsx as s}from"react/jsx-runtime";var c={kind:"puck"};function f(n,e){const t=n,r=e,i=Object.keys(t);return i.length===Object.keys(r).length&&i.every(n=>Object.is(t[n],r[n]))}function a(n){const e=n;return"string"==typeof e.nodeId&&"string"==typeof e.slot}function d(n,t,r){const i=n.slotsOf?.(r);return i||e(t,r.type).map(n=>({slot:n,label:n,rung:!1}))}function p(n,e){return n.isFirst?n.isFirst(e):e.type===n.first}function m(n,e){return n.isLast?n.isLast(e):e.type===n.last}var k={},h=()=>k,v=()=>"",g=()=>null,y=()=>{},b={isLockedBlock:()=>!1,duplicateBlocked:()=>null,nestDepth:()=>0,newSectionNode:()=>null,canAddTo:()=>null,blockIsOffered:()=>!0},O={labelAtLevel:(n,e,t)=>t,descriptions:{},categoryLabel:()=>{},firstSection:null,blockRowName:(n,e)=>e(n.type),plainText:n=>n,Icon:()=>null,Thumbnail:()=>null,useProducts:()=>null},j={options:[{id:"desktop",label:"Desktop",icon:/* @__PURE__ */s(l,{})}],initial:"desktop",fluid:"desktop",widths:{desktop:2e3}},w={read:()=>"sections",write:()=>{},forSelection:(n,e)=>n?"sections":e},L={first:null,last:null,firstGroup:null,lastGroup:null,isSectionGroup:()=>!1,sectionGroupZone:()=>"",panelOf:()=>null};function P(){/* @__PURE__ */
2
+ return s(t,{height:"fill"})}function S(){const{id:n,fields:e,values:t,readOnly:o,onChange:u}=r();/* @__PURE__ */
3
+ return s("div",{className:"es-sidepanel es-sidepanel--right",children:/* @__PURE__ */s(i,{fields:e,values:t,onChange:u,readOnly:o,idPrefix:n})})}var B=o({});function C({parts:n,children:e}){/* @__PURE__ */
4
+ return s(B.Provider,{value:n,children:e})}function D(){return u(B)}function G(){return(D().useOwnerName??v)()}function I(){return(D().useDocumentLabel??g)()}function N(n,e,t,r){return(D().useBridges??h)(n,e,t,r)}function x(n){return(D().useStandaloneBridges??h)(n)}function A(n,e){(D().useDocumentPass??y)(n,e)}function T(){return D().blockRules??b}function F(){return D().blockLook??O}function R(){return D().devices??j}function V(){return D().leftView??w}function Z(){return D().pinned??L}function E(){return D().saveSwitch??!0}function K(e){n(!0===D().pickFollowsSelection,e)}function Q(){return D().storageNamespace||void 0}function W(){return D().styleClipboard??null}function H(){return D().nodeKeys??!0}function Y(){return D().notify??null}function q(){return D().Canvas??P}function z(){return D().CanvasHead??null}function J(){return D().canvasDrag??null}var M=o(null);function U({target:n,children:e}){/* @__PURE__ */
5
+ return s(M.Provider,{value:n,children:e})}function X(){return u(M)}function $(){return D().Inspector??S}export{c as SELECTION_MODE,U as ScreenCanvasTargetProvider,C as ScreenPartsProvider,p as isPinnedFirst,m as isPinnedLast,a as isSlotMode,f as sameInspectorMode,d as screenSlotsOf,F as useScreenBlockLook,T as useScreenBlockRules,N as useScreenBridges,J as useScreenCanvasDrag,q as useScreenCanvasFrame,z as useScreenCanvasHead,X as useScreenCanvasTarget,R as useScreenDevices,I as useScreenDocumentLabel,A as useScreenDocumentPass,$ as useScreenInspectorPanel,V as useScreenLeftView,H as useScreenNodeKeys,Y as useScreenNotify,G as useScreenOwnerName,D as useScreenParts,K as useScreenPickFollowsSelection,Z as useScreenPinned,E as useScreenSaveSwitch,Q as useScreenStorageNamespace,W as useScreenStyleClipboard,x as useStandaloneScreenBridges};
@@ -0,0 +1 @@
1
+ import{useSectionOps as o}from"./chunk-S2MMPHKD.js";import{SELECTION_MODE as e}from"./chunk-FZ3Y3QTQ.js";import{usePreviewParts as r}from"./chunk-I54UCYOU.js";import{decodePartId as t,encodePartId as n}from"./chunk-IYT6NN2J.js";import{useEasel as p}from"./chunk-PVAIOBBE.js";import{useCallback as d,useEffect as c}from"react";var s=o=>"part"===o.kind;function m({mode:m,setMode:i,onOpenPart:I}){const{getSelectorForId:a}=p(o=>o),u=o(),{setSelectedPartId:f,setSelectHandler:k}=r(),l=d(o=>{const r=t(o);if(!r)return;const{nodeId:n,propKey:p}=r;p?(i(o=>s(o)&&o.nodeId===n&&o.propKey===p?o:{kind:"part",nodeId:n,propKey:p}),I?.(n)):i(o=>"part"===o.kind?e:o)},[i,I]);c(()=>{k(l)},[k,l]);const h=s(m)?n(m.nodeId,m.propKey):null;c(()=>{f(h)},[h,f]);return{selectNode:d(o=>{i(()=>e);const r=a(o);r&&u.select(r)},[i,a,u]),openPartId:h}}export{m as usePartBridge};
@@ -1 +1 @@
1
- import{useScreenDocument as n}from"./chunk-47JTYRQC.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-VVPZMWJE.js";import{EditNotice as r}from"./chunk-IE55HNMA.js";import{useWords as e}from"./chunk-MFIRYGHW.js";import{jsx as i}from"react/jsx-runtime";function t(){const{capabilities:t,access:c,takeOverEditing:a,viewReadOnly:s,saveConflict:m,reloadFromServer:u}=n(),{noun:l}=e("screen",o);return t.hasEditGuard?/* @__PURE__ */i(r,{access:c,conflict:m,noun:l,onTakeOver:a,onViewReadOnly:s,onReload:u}):null}export{t as PageEditGuardNotices};
1
+ import{useScreenDocument as n}from"./chunk-FBS75I6E.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-VVPZMWJE.js";import{EditNotice as r}from"./chunk-IE55HNMA.js";import{useWords as e}from"./chunk-MFIRYGHW.js";import{jsx as i}from"react/jsx-runtime";function t(){const{capabilities:t,access:c,takeOverEditing:a,viewReadOnly:s,saveConflict:m,reloadFromServer:u}=n(),{noun:l}=e("screen",o);return t.hasEditGuard?/* @__PURE__ */i(r,{access:c,conflict:m,noun:l,onTakeOver:a,onViewReadOnly:s,onReload:u}):null}export{t as PageEditGuardNotices};
@@ -1,4 +1,4 @@
1
- import{useScreenOwnerName as e}from"./chunk-WP7AZDCV.js";import{settlePanelPick as n}from"./chunk-R6WTQWAC.js";import{MediaPanelHead as i,mediaPickKind as c}from"./chunk-IE55HNMA.js";import{jsxs as o,Fragment as r,jsx as t}from"react/jsx-runtime";function l({panel:l,pick:d,onHide:m}){const p=e();/* @__PURE__ */
1
+ import{useScreenOwnerName as e}from"./chunk-FZ3Y3QTQ.js";import{settlePanelPick as n}from"./chunk-R6WTQWAC.js";import{MediaPanelHead as i,mediaPickKind as c}from"./chunk-IE55HNMA.js";import{jsxs as o,Fragment as r,jsx as t}from"react/jsx-runtime";function l({panel:l,pick:d,onHide:m}){const p=e();/* @__PURE__ */
2
2
  return o(r,{children:[
3
3
  /* @__PURE__ */t(i,{context:p,pick:d?{kind:c(d.accept),field:d.title||void 0}:null,onCancel:()=>d&&n(d.requestId,null),onHide:m}),
4
4
  /* @__PURE__ */t("div",{className:"sf-media-panel",children:/* @__PURE__ */t(l,{pick:d,onPick:e=>d&&n(d.requestId,e)})})]})}export{l as MediaSidePanel};
@@ -1,2 +1,2 @@
1
- import{ScreenPartsProvider as t}from"./chunk-WP7AZDCV.js";import{useEaselHost as r}from"./chunk-U3JP4VGF.js";import{createEasel as e,EaselProvider as n}from"./chunk-KE2CXEIK.js";import{useState as o,useEffect as s}from"react";import{jsx as i}from"react/jsx-runtime";function a({config:a,data:c,onChange:m,permissions:p,parts:f,children:u}){const[h]=o(()=>e({config:a,data:c,permissions:p}));s(()=>{h.setConfig(a)},[h,a]),s(()=>{if(!m)return;let t=h.getState().appState.data;return h.subscribe(()=>{const r=h.getState().appState.data;r!==t&&(t=r,m(r))})},[h,m]),s(()=>{p&&h.setPermissions(p)},[h,p]);const d=r();/* @__PURE__ */
1
+ import{ScreenPartsProvider as t}from"./chunk-FZ3Y3QTQ.js";import{useEaselHost as r}from"./chunk-U3JP4VGF.js";import{createEasel as e,EaselProvider as n}from"./chunk-PVAIOBBE.js";import{useState as o,useEffect as s}from"react";import{jsx as i}from"react/jsx-runtime";function a({config:a,data:c,onChange:m,permissions:p,parts:f,children:u}){const[h]=o(()=>e({config:a,data:c,permissions:p}));s(()=>{h.setConfig(a)},[h,a]),s(()=>{if(!m)return;let t=h.getState().appState.data;return h.subscribe(()=>{const r=h.getState().appState.data;r!==t&&(t=r,m(r))})},[h,m]),s(()=>{p&&h.setPermissions(p)},[h,p]);const d=r();/* @__PURE__ */
2
2
  return i(n,{easel:h,hotkeys:d.ownsDocument,children:/* @__PURE__ */i(t,{parts:f,children:u})})}export{a as ScreenStoreProvider};
@@ -0,0 +1 @@
1
+ import{withoutDeviceGate as t,deviceMetaOf as o}from"./chunk-NBDMTIU2.js";import{DESIGN_GROUP_KEY as n,BUCKET_KEY as e}from"./chunk-MQNBD6AB.js";import{panelFieldsOf as r}from"./chunk-ZE7I3PLX.js";import{STYLE_KIND as s,fieldKind as c,copyStyle as i,heldStyle as p,planPaste as u,pasteMessage as a}from"./chunk-V7U33NF2.js";import{ANCHOR_FIELD_KEYS as f,foldMetaOf as l,MEDIA_FIELD_MARKER as m,TEXT_FIELD_MARKER as h,LINK_FIELD_MARKER as y}from"./chunk-DUVRZ456.js";var j=/* @__PURE__ */new Set([n.Size,n.Design,n.Layout,n.Position]),w=new Set(Object.values(n)),b=new Set(Object.values(e)),S=new Set(f),g=/* @__PURE__ */new Set(["focal","imageFocal"]),k=[m,h,y];function v(t){return`site:${t??""}`}function D(o){if(!o||"object"!=typeof o)return null;const n=o,e=t(o)??o,r=n[s]??e[s];if("string"==typeof r)return r;const i=n.options??e.options;if(Array.isArray(i)){return`choice:${i.map(t=>String(t?.value)).sort().join("|")}`}return c(e)}function d(o){const n=o,e=t(o);return k.some(t=>t in n||e&&t in e)}function A(t,n){const s=r(t,n)??{},c=[];let i=!0,p=!1;for(const[t,n]of Object.entries(s))b.has(t)?(i=t===e.Design,p=!1):w.has(t)?i&&(p=j.has(t)):p&&n&&"object"==typeof n&&!t.startsWith("_")&&(l(n)||S.has(t)||g.has(t)||d(n)||"slot"!==n.type&&c.push({path:[t],kind:D(n),counted:"mobile"!==o(n)?.tier}));return c}function B(t,o,n,e,r){i({scope:n,type:e.type,label:r,rows:t(o,e),props:e.props})}function I(t,o,n,e,r,s){const c=p(n);if(!c)return null;const i=u(c,{type:e.type,rows:t(o,e),props:e.props});return{...i,message:a(i,c.sourceLabel,r,s)}}function L(t,o,n,e){B(A,t,o,n,e)}function N(t,o,n,e,r){return I(A,t,o,n,e,r)}var O={scope:t=>v(t.siteId),rows:(t,o)=>A(t,o),copy:(t,o,n,e)=>L(e,t,o,n),plan:(t,o,n,e)=>N(e,t,o,n)};function U(t,o){if(!t&&!o)return O;const n=t?.rows,e=n?(t,o)=>n(t,o):A;return{scope:t?.scope??O.scope,rows:(t,o)=>e(t,o),copy:t?.copy??((t,o,n,r)=>B(e,r,t,o,n)),plan:t?.plan??((t,n,r,s)=>I(e,s,t,n,r,o))}}export{L as copyNodeStyle,A as nodeStyleRows,N as planNodePaste,D as shopFieldKind,v as siteStyleScope,U as styleClipboardOf};
@@ -1,2 +1,2 @@
1
- import{noControlField as e}from"./chunk-7F52SZOI.js";import{usePreviewDevice as n}from"./chunk-BSPCSC45.js";import{DEFAULT_SCREEN_WORDS as r}from"./chunk-VVPZMWJE.js";import{useWords as t}from"./chunk-MFIRYGHW.js";import{jsx as o}from"react/jsx-runtime";function i(e){return"mobile"===e?"mobile":"desktop"}var c={desktop:null,tablet:r.deviceNote.tablet,mobile:r.deviceNote.mobile},u="data-sf-device-hidden";function d(){/* @__PURE__ */
2
- return o("span",{hidden:!0,[u]:""})}function s({tier:e,render:r,...t}){return i(n())===e?/* @__PURE__ */o(r,{...t}):/* @__PURE__ */o(d,{})}var m="__device";function f(e){const n=e?.[m];return n??null}function l(e){return f(e)?.inner??e}function a(e,n){const r=n.render;return{...n,[m]:{tier:e,inner:n},render:n=>/* @__PURE__ */o(s,{tier:e,render:r,...n})}}function p(){const e=t("screen",r).deviceNote,i=n(),c="desktop"===i?null:e[i];return c?/* @__PURE__ */o("div",{className:"sf-device-scope",children:c}):/* @__PURE__ */o(d,{})}function v(){return e({type:"custom",render:()=>/* @__PURE__ */o(p,{})},"always")}export{m as DEVICE_FIELD_MARKER,u as DEVICE_HIDDEN_ATTR,c as DEVICE_NOTE,a as deviceField,f as deviceMetaOf,v as deviceNote,i as shownTier,l as withoutDeviceGate};
1
+ import{noControlField as e}from"./chunk-7F52SZOI.js";import{DEFAULT_SCREEN_WORDS as n}from"./chunk-VVPZMWJE.js";import{usePreviewDevice as r}from"./chunk-BSPCSC45.js";import{useWords as t}from"./chunk-MFIRYGHW.js";import{jsx as o}from"react/jsx-runtime";function i(e){return"mobile"===e?"mobile":"desktop"}var c={desktop:null,tablet:n.deviceNote.tablet,mobile:n.deviceNote.mobile},u="data-sf-device-hidden";function d(){/* @__PURE__ */
2
+ return o("span",{hidden:!0,[u]:""})}function s({tier:e,render:n,...t}){return i(r())===e?/* @__PURE__ */o(n,{...t}):/* @__PURE__ */o(d,{})}var m="__device";function f(e){const n=e?.[m];return n??null}function l(e){return f(e)?.inner??e}function a(e,n){const r=n.render;return{...n,[m]:{tier:e,inner:n},render:n=>/* @__PURE__ */o(s,{tier:e,render:r,...n})}}function p(){const e=t("screen",n).deviceNote,i=r(),c="desktop"===i?null:e[i];return c?/* @__PURE__ */o("div",{className:"sf-device-scope",children:c}):/* @__PURE__ */o(d,{})}function v(){return e({type:"custom",render:()=>/* @__PURE__ */o(p,{})},"always")}export{m as DEVICE_FIELD_MARKER,u as DEVICE_HIDDEN_ATTR,c as DEVICE_NOTE,a as deviceField,f as deviceMetaOf,v as deviceNote,i as shownTier,l as withoutDeviceGate};
@@ -1 +1 @@
1
- import{styleMenuItems as e}from"./chunk-V7U33NF2.js";import{useEaselSession as n}from"./chunk-O7Q4DDJT.js";import{ROOT_ZONE as t}from"./chunk-PLVEGYK6.js";import{useHostEscape as o}from"./chunk-U3JP4VGF.js";import{DEFAULT_SCREEN_WORDS as l}from"./chunk-VVPZMWJE.js";import{EaselMenuItems as r,menuLabel as i}from"./chunk-EA2HTX37.js";import{createNodeClipboard as c,nodeMenuItems as s}from"./chunk-OSPUG6S6.js";import{DEFAULT_NODE_MENU_WORDS as a}from"./chunk-WK3AFPXY.js";import{isTypingTarget as u,useCanvasEvent as d,framePointToHost as p}from"./chunk-ILXP5VX5.js";import{zoneKey as f,ROOT_SLOT as m,ROOT_ID as h}from"./chunk-KRXQM65X.js";import{useState as y,useCallback as k,useRef as b,useEffect as v}from"react";import{ContextMenu as g}from"efficient-shell/ui";import{UndoIcon as w,RedoIcon as x,PasteIcon as C,SettingsIcon as P,LayersIcon as z,CopyIcon as O}from"efficient-shell/icons/efficient";import{jsx as A}from"react/jsx-runtime";function D(e,n){const o=[],l=/* @__PURE__ */new Set;let r={zone:n.zone,index:n.index};for(;r;){const n=e.nodeAt(r.zone,r.index);if(!n||l.has(n.props.id))break;if(l.add(n.props.id),o.push({zone:r.zone,index:r.index,node:n,parentType:null}),r.zone===t)break;const i=r.zone.lastIndexOf(":");if(i<=0)break;r=e.locate(r.zone.slice(0,i))}for(let e=0;e<o.length-1;e+=1)o[e].parentType=o[e+1].node.type;return o}var K=c(),X=/* @__PURE__ */new WeakMap;function j(e){if(e.claimsPage)return K;const n=e.registry;if(!n)return e.cache("easel:node-clipboard",c);let t=X.get(n);return t||(t=c(),X.set(n,t)),t}function M(){return j(n())}function S(e,n,o){if(n===t){const{floor:n,cap:t}=e.sectionBand();return{parentId:h,slot:m,index:Math.min(Math.max(o,n),t)}}const l=n.lastIndexOf(":");return{parentId:n.slice(0,l),slot:n.slice(l+1),index:o}}function T(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 E(e,n,t){const o=e.canPasteAt;if(!o)return f(n.from)===t.zone?S(e,t.zone,t.index+1):null;for(const l of D(e,t)){const t=S(e,l.zone,l.index+1);if(o(n,t))return t}return null}function V(e){if(e.defaultPrevented||e.altKey||e.shiftKey)return null;if(u(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||"Backspace"===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 L(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=T(e,l,t.zone);if("copy"===n)return c.copy?(e.nodeOps.copy(r,i),{done:"copied",name:i}):null;if(o.readOnly)return null;if("cut"===n)return c.cut?(e.nodeOps.cut(r,i),{done:"cut",name:i}):null;if("delete"===n)return c.delete?(e.nodeOps.remove(r),{done:"deleted",name:i}):null;const s=o.held;if(!s)return null;const a=e.isPinned(l,t.zone)?null:E(e,s,t);return a?(e.nodeOps.paste(a),{done:"pasted",name:s.label}):(e.onPasteRefused(s),{done:"refused",name:s.label})}function I(n,o){const{zone:l,index:r}=o,i=n.nodeAt(l,r);if(!i)return[];const c=i.props.id,a=n.labelOf(i.type,l),u=Boolean(i.props._hidden),d=n.nodeOps,p=n.isPinned(i,l),f=n.isLocked(i),m=!p&&!f&&!n.duplicateBlocked(i),h=n.permits?.(i)??{duplicate:!0,delete:!0},y=T(n,i,l),k=D(n,o),b=d.held,v=b&&!p?E(n,b,o):null,g=!n.readOnly,w=n.style?e({held:g?n.style.held():null,canCopy:n.style.canCopy(i,l),onCopy:()=>n.style?.copy(i,l),onPaste:()=>n.style?.paste(l,r,i),words:n.words?.styleClipboard}):[];return s({title:a,words:n.words?.menu,layer:{group:"pick",items:k.flatMap((e,o)=>{const l={label:n.rowNameOf(e.node,e.zone),checked:0===o,onClick:()=>n.selectAt(e.zone,e.index,e.node.props.id,e.parentType)},r=e.zone===t?null:n.slotRung?.(e.zone)??null;return r?[l,{label:r.label,checked:!1,onClick:r.select}]:[l]})},actions:{duplicate:g&&m&&h.duplicate?()=>d.duplicate(c):void 0,moveUp:g&&d.canStep(c,-1)?()=>d.step(c,-1):void 0,moveDown:g&&d.canStep(c,1)?()=>d.step(c,1):void 0,copy:y.copy?()=>d.copy(c,a):void 0,cut:g&&y.cut?()=>d.cut(c,a):void 0,paste:g&&b&&v?{label:b.label,run:()=>d.paste(v)}:void 0,rename:g&&n.renamePropOf(i,l)?()=>n.beginRename(l,r):void 0,hide:!g||f||p?void 0:{hidden:u,run:()=>d.setProps(c,{_hidden:!u})},delete:g&&m&&h.delete?()=>d.remove(c):void 0},style:w,extras:n.menuRows?.(i,l,r)??void 0,pinnedLine:p?R(n).pinned:void 0})}var R=e=>e.words?.screen??l.menu;function B(e){const n=R(e),o=!e.readOnly,r=[];o&&e.history.hasPast&&r.push({label:n.undo,icon:/* @__PURE__ */A(w,{}),shortcut:"⌘Z",onClick:e.history.back}),o&&e.history.hasFuture&&r.push({label:n.redo,icon:/* @__PURE__ */A(x,{}),shortcut:"⇧⌘Z",onClick:e.history.forward});const i=[],c=e.nodeOps.held,s=S(e,t,e.sectionBand().cap);if(o&&c&&(e.canPasteAt?e.canPasteAt(c,s):f(c.from)===t)){const n=s,t=e.words?.menu??a;i.push({label:t.pasteNamed({paste:t.paste,label:c.label}),icon:/* @__PURE__ */A(C,{}),shortcut:"⌘V",onClick:()=>e.nodeOps.paste(n)})}const u=[r,i,[{label:e.pageSettingsLabel??l.pageSettings,icon:/* @__PURE__ */A(P,{}),onClick:e.openPageSettings},{label:n.collapseAll,icon:/* @__PURE__ */A(z,{}),onClick:e.collapseAll}]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return u.flatMap((e,n)=>n?[d,...e]:e)}function U(e,n){const t=n.selectionStart??0,o=n.selectionEnd??0,l=n.value.slice(t,o),r=e=>{n.focus(),n.setRangeText(e,t,o,"end"),n.dispatchEvent(new Event("input",{bubbles:!0}))},i=e.words?.menu??a,c=R(e),s=[];l&&(s.push({label:i.copy,icon:/* @__PURE__ */A(O,{}),shortcut:"⌘C",onClick:()=>navigator.clipboard?.writeText(l)}),s.push({label:i.cut,icon:/* @__PURE__ */A(O,{}),shortcut:"⌘X",onClick:()=>{navigator.clipboard?.writeText(l),r("")}})),s.push({label:i.paste,icon:/* @__PURE__ */A(C,{}),shortcut:"⌘V",onClick:()=>{navigator.clipboard?.readText().then(e=>{e&&r(e)}).catch(()=>e.onPasteRefused())}});const u=[s,n.value?[{label:c.selectAll,shortcut:"⌘A",onClick:()=>{n.focus(),n.select()}}]:[]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return u.flatMap((e,n)=>n?[d,...e]:e)}function Y(e){return e.shiftKey}function N(e,n){const[t,l]=y(null),r=k(()=>l(null),[]);o(null!==t,r);const i=b(e);i.current=e;const c=k(e=>{const n=i.current,t=n.keys;if(!t)return;const o=V(e);if(!o)return;const l=t.selected();if(!l)return;const r=L(n,o,l,{readOnly:t.readOnly,held:t.held()});r&&(e.preventDefault(),t.onDone?.(r))},[]),s=e.keys?.target??null;v(()=>{if(!s)return;const e=e=>c(e);return s.addEventListener("keydown",e),()=>s.removeEventListener("keydown",e)},[s,c]),d(n,"keydown",c);const a=k(n=>{if(Y(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]);d(n,"contextmenu",t=>{if(Y(t)||!n)return;const o=t.target?.closest?.("[data-puck-component]")??null,r=o?.getAttribute("data-puck-component"),i=r?e.locate(r):null;t.preventDefault();const c=p(n.frame,t.clientX,t.clientY),s=n.frame;l(i?{kind:"node",...c,...i,owner:s}:{kind:"empty",...c,owner:s})}),d(n,"mousedown",r),d(n,"scroll",r,{on:"window"});return{onEditorContextMenu:a,menu:t?/* @__PURE__ */A(F,{host:e,target:t,onClose:r}):null,closeMenu:r}}function F({host:e,target:n,onClose:t}){const o="node"===n.kind?I(e,n):"input"===n.kind?U(e,n.el):B(e);return 0===o.length?null:/* @__PURE__ */A(g,{at:{x:n.x,y:n.y},owner:n.owner??null,onClose:t,"aria-label":i(o),children:/* @__PURE__ */A(r,{items:o,onClose:t})})}export{K as EASEL_NODE_CLIPBOARD,D as ancestorChain,j as nodeClipboardOf,T as nodeClipboardRules,I as nodeMenuItems,V as nodeShortcut,B as pageMenuItems,E as pastePlace,L as runNodeShortcut,U as textMenuItems,M as useNodeClipboard,N as useNodeContextMenu};
1
+ import{useEaselSession as e}from"./chunk-O7Q4DDJT.js";import{useHostEscape as n}from"./chunk-U3JP4VGF.js";import{DEFAULT_SCREEN_WORDS as t}from"./chunk-VVPZMWJE.js";import{styleMenuItems as o}from"./chunk-V7U33NF2.js";import{createNodeClipboard as l,nodeMenuItems as r}from"./chunk-OSPUG6S6.js";import{DEFAULT_NODE_MENU_WORDS as i}from"./chunk-WK3AFPXY.js";import{ROOT_ZONE as c}from"./chunk-PLVEGYK6.js";import{EaselMenuItems as s,menuLabel as a}from"./chunk-EA2HTX37.js";import{isTypingTarget as u,useCanvasEvent as d,framePointToHost as p}from"./chunk-ILXP5VX5.js";import{zoneKey as f,ROOT_SLOT as m,ROOT_ID as h}from"./chunk-KRXQM65X.js";import{useState as y,useCallback as k,useRef as b,useEffect as v}from"react";import{ContextMenu as g}from"efficient-shell/ui";import{UndoIcon as w,RedoIcon as x,PasteIcon as C,SettingsIcon as P,LayersIcon as z,CopyIcon as O}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===c)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(),X=/* @__PURE__ */new WeakMap;function j(e){if(e.claimsPage)return K;const n=e.registry;if(!n)return e.cache("easel:node-clipboard",l);let t=X.get(n);return t||(t=l(),X.set(n,t)),t}function M(){return j(e())}function S(e,n,t){if(n===c){const{floor:n,cap:o}=e.sectionBand();return{parentId:h,slot:m,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 T(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 E(e,n,t){const o=e.canPasteAt;if(!o)return f(n.from)===t.zone?S(e,t.zone,t.index+1):null;for(const l of D(e,t)){const t=S(e,l.zone,l.index+1);if(o(n,t))return t}return null}function V(e){if(e.defaultPrevented||e.altKey||e.shiftKey)return null;if(u(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||"Backspace"===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 L(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=T(e,l,t.zone);if("copy"===n)return c.copy?(e.nodeOps.copy(r,i),{done:"copied",name:i}):null;if(o.readOnly)return null;if("cut"===n)return c.cut?(e.nodeOps.cut(r,i),{done:"cut",name:i}):null;if("delete"===n)return c.delete?(e.nodeOps.remove(r),{done:"deleted",name:i}):null;const s=o.held;if(!s)return null;const a=e.isPinned(l,t.zone)?null:E(e,s,t);return a?(e.nodeOps.paste(a),{done:"pasted",name:s.label}):(e.onPasteRefused(s),{done:"refused",name:s.label})}function I(e,n){const{zone:t,index:l}=n,i=e.nodeAt(t,l);if(!i)return[];const s=i.props.id,a=e.labelOf(i.type,t),u=Boolean(i.props._hidden),d=e.nodeOps,p=e.isPinned(i,t),f=e.isLocked(i),m=!p&&!f&&!e.duplicateBlocked(i),h=e.permits?.(i)??{duplicate:!0,delete:!0},y=T(e,i,t),k=D(e,n),b=d.held,v=b&&!p?E(e,b,n):null,g=!e.readOnly,w=e.style?o({held:g?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:a,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===c?null:e.slotRung?.(n.zone)??null;return l?[o,{label:l.label,checked:!1,onClick:l.select}]:[o]})},actions:{duplicate:g&&m&&h.duplicate?()=>d.duplicate(s):void 0,moveUp:g&&d.canStep(s,-1)?()=>d.step(s,-1):void 0,moveDown:g&&d.canStep(s,1)?()=>d.step(s,1):void 0,copy:y.copy?()=>d.copy(s,a):void 0,cut:g&&y.cut?()=>d.cut(s,a):void 0,paste:g&&b&&v?{label:b.label,run:()=>d.paste(v)}:void 0,rename:g&&e.renamePropOf(i,t)?()=>e.beginRename(t,l):void 0,hide:!g||f||p?void 0:{hidden:u,run:()=>d.setProps(s,{_hidden:!u})},delete:g&&m&&h.delete?()=>d.remove(s):void 0},style:w,extras:e.menuRows?.(i,t,l)??void 0,pinnedLine:p?R(e).pinned:void 0})}var R=e=>e.words?.screen??t.menu;function B(e){const n=R(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=[],s=e.nodeOps.held,a=S(e,c,e.sectionBand().cap);if(o&&s&&(e.canPasteAt?e.canPasteAt(s,a):f(s.from)===c)){const n=a,t=e.words?.menu??i;r.push({label:t.pasteNamed({paste:t.paste,label:s.label}),icon:/* @__PURE__ */A(C,{}),shortcut:"⌘V",onClick:()=>e.nodeOps.paste(n)})}const u=[l,r,[{label:e.pageSettingsLabel??t.pageSettings,icon:/* @__PURE__ */A(P,{}),onClick:e.openPageSettings},{label:n.collapseAll,icon:/* @__PURE__ */A(z,{}),onClick:e.collapseAll}]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return u.flatMap((e,n)=>n?[d,...e]:e)}function U(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=R(e),a=[];l&&(a.push({label:c.copy,icon:/* @__PURE__ */A(O,{}),shortcut:"⌘C",onClick:()=>navigator.clipboard?.writeText(l)}),a.push({label:c.cut,icon:/* @__PURE__ */A(O,{}),shortcut:"⌘X",onClick:()=>{navigator.clipboard?.writeText(l),r("")}})),a.push({label:c.paste,icon:/* @__PURE__ */A(C,{}),shortcut:"⌘V",onClick:()=>{navigator.clipboard?.readText().then(e=>{e&&r(e)}).catch(()=>e.onPasteRefused())}});const u=[a,n.value?[{label:s.selectAll,shortcut:"⌘A",onClick:()=>{n.focus(),n.select()}}]:[]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return u.flatMap((e,n)=>n?[d,...e]:e)}function Y(e){return e.shiftKey}function N(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=V(e);if(!o)return;const l=t.selected();if(!l)return;const r=L(n,o,l,{readOnly:t.readOnly,held:t.held()});r&&(e.preventDefault(),t.onDone?.(r))},[]),s=e.keys?.target??null;v(()=>{if(!s)return;const e=e=>c(e);return s.addEventListener("keydown",e),()=>s.removeEventListener("keydown",e)},[s,c]),d(t,"keydown",c);const a=k(n=>{if(Y(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]);d(t,"contextmenu",n=>{if(Y(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=p(t.frame,n.clientX,n.clientY),s=t.frame;l(i?{kind:"node",...c,...i,owner:s}:{kind:"empty",...c,owner:s})}),d(t,"mousedown",r),d(t,"scroll",r,{on:"window"});return{onEditorContextMenu:a,menu:o?/* @__PURE__ */A(F,{host:e,target:o,onClose:r}):null,closeMenu:r}}function F({host:e,target:n,onClose:t}){const o="node"===n.kind?I(e,n):"input"===n.kind?U(e,n.el):B(e);return 0===o.length?null:/* @__PURE__ */A(g,{at:{x:n.x,y:n.y},owner:n.owner??null,onClose:t,"aria-label":a(o),children:/* @__PURE__ */A(s,{items:o,onClose:t})})}export{K as EASEL_NODE_CLIPBOARD,D as ancestorChain,j as nodeClipboardOf,T as nodeClipboardRules,I as nodeMenuItems,V as nodeShortcut,B as pageMenuItems,E as pastePlace,L as runNodeShortcut,U as textMenuItems,M as useNodeClipboard,N as useNodeContextMenu};