efficient-easel 2.2.0 → 3.2.1

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 (119) hide show
  1. package/README.md +20 -5
  2. package/dist/blocks/index.d.ts +2 -2
  3. package/dist/chrome/index.d.ts +2 -2
  4. package/dist/chrome/index.js +1 -1
  5. package/dist/{chunk-ZNNATBDC.js → chunk-2T3ED73A.js} +1 -1
  6. package/dist/chunk-2WVZ3CK3.js +5 -0
  7. package/dist/{chunk-2JIWFFXA.js → chunk-42TMLDSQ.js} +1 -1
  8. package/dist/chunk-4WEGYBTV.js +7 -0
  9. package/dist/chunk-55IKQFBW.js +5 -0
  10. package/dist/chunk-5SOSVTVI.js +5 -0
  11. package/dist/{chunk-7SQF6LZL.js → chunk-66LWADFP.js} +1 -1
  12. package/dist/{chunk-AAT3O7PK.js → chunk-6QSPOILR.js} +1 -1
  13. package/dist/chunk-7VP5RXNO.js +64 -0
  14. package/dist/{chunk-ZV6OYSZ7.js → chunk-AVYFZZAP.js} +1 -1
  15. package/dist/chunk-BF3PIXZD.js +1 -0
  16. package/dist/chunk-CRPJGCSO.js +20 -0
  17. package/dist/chunk-FFYXVAAL.js +1 -0
  18. package/dist/{chunk-UAVNI3BU.js → chunk-FRGCTHDB.js} +1 -1
  19. package/dist/{chunk-OXYGFK2B.js → chunk-GTDLBUOC.js} +6 -6
  20. package/dist/chunk-IMRJHRQ2.js +1 -0
  21. package/dist/{chunk-PT6V53OO.js → chunk-J2JBETVO.js} +1 -1
  22. package/dist/chunk-JZDEIRH4.js +1 -0
  23. package/dist/{chunk-35Q5HMJZ.js → chunk-KNUFI3WV.js} +1 -1
  24. package/dist/chunk-LMHGVI5R.js +4 -0
  25. package/dist/{chunk-VB5LRSGJ.js → chunk-OFNXIZEP.js} +1 -1
  26. package/dist/{chunk-FOBGSFFS.js → chunk-OZ72A6MY.js} +7 -7
  27. package/dist/chunk-PDZXAFNX.js +9 -0
  28. package/dist/{chunk-ONRYLR2D.js → chunk-PRSTFWUY.js} +2 -2
  29. package/dist/chunk-QASZFO4S.js +1 -0
  30. package/dist/chunk-U2DVXW2H.js +2 -0
  31. package/dist/chunk-Y2G7CU6A.js +1 -0
  32. package/dist/{chunk-6OY2THZH.js → chunk-ZN752E2O.js} +1 -1
  33. package/dist/copy/copy.css +79 -82
  34. package/dist/copy/index.d.ts +9 -7
  35. package/dist/copy/index.js +21 -31
  36. package/dist/easel/index.d.ts +5 -5
  37. package/dist/easel/index.js +1 -1
  38. package/dist/fields/fields.css +0 -28
  39. package/dist/fields/index.d.ts +2 -2
  40. package/dist/fields/index.js +1 -1
  41. package/dist/node-ops/index.d.ts +2 -2
  42. package/dist/node-ops/index.js +1 -1
  43. package/dist/panel/index.d.ts +4 -222
  44. package/dist/panel/index.js +12 -15
  45. package/dist/panel/panel.css +0 -165
  46. package/dist/{plan-DChbUXdS.d.ts → plan-BdQ9mLIf.d.ts} +20 -1
  47. package/dist/screen/components/AddBlockRow.js +1 -1
  48. package/dist/screen/components/AddSidePanel.js +1 -1
  49. package/dist/screen/components/MediaSidePanel.d.ts +3 -3
  50. package/dist/screen/components/MediaSidePanel.js +1 -1
  51. package/dist/screen/components/NodeContextMenu.d.ts +19 -17
  52. package/dist/screen/components/NodeContextMenu.js +1 -1
  53. package/dist/screen/components/PageEditGuardNotices.js +1 -1
  54. package/dist/screen/components/ScreenChrome.js +1 -1
  55. package/dist/screen/components/ScreenDocumentContext.d.ts +3 -3
  56. package/dist/screen/components/ScreenDocumentContext.js +1 -1
  57. package/dist/screen/components/ScreenMount.d.ts +3 -3
  58. package/dist/screen/components/ScreenMount.js +1 -1
  59. package/dist/screen/components/ScreenStoreProvider.d.ts +3 -3
  60. package/dist/screen/components/ScreenStoreProvider.js +1 -1
  61. package/dist/screen/components/SectionScreenShell.js +16 -16
  62. package/dist/screen/components/SidePanelHead.js +1 -1
  63. package/dist/screen/components/UiIcon.js +1 -1
  64. package/dist/screen/components/panel-widths.js +1 -1
  65. package/dist/screen/components/usePartBridge.d.ts +3 -3
  66. package/dist/screen/components/usePartBridge.js +1 -1
  67. package/dist/screen/index.d.ts +3 -3
  68. package/dist/screen/index.js +1 -1
  69. package/dist/screen/lib/admin-bridge.d.ts +3 -3
  70. package/dist/screen/lib/document-addressing.d.ts +3 -3
  71. package/dist/screen/lib/document-hooks.d.ts +2 -2
  72. package/dist/screen/lib/host-chrome.d.ts +1 -1
  73. package/dist/screen/lib/host.d.ts +3 -3
  74. package/dist/screen/lib/key-scope.js +1 -1
  75. package/dist/screen/lib/links/link-filters.d.ts +1 -2
  76. package/dist/screen/lib/media-panel.d.ts +3 -3
  77. package/dist/screen/lib/media-picker.d.ts +3 -3
  78. package/dist/screen/lib/page-lock.d.ts +3 -3
  79. package/dist/screen/lib/puck/device-fields.js +1 -1
  80. package/dist/screen/lib/puck/palette-sections.d.ts +2 -2
  81. package/dist/screen/lib/puck/section-doc.d.ts +2 -2
  82. package/dist/screen/lib/puck/style-clipboard.d.ts +10 -6
  83. package/dist/screen/lib/puck/style-clipboard.js +1 -1
  84. package/dist/screen/lib/puck/use-section-ops.d.ts +2 -2
  85. package/dist/screen/lib/puck/use-section-ops.js +1 -1
  86. package/dist/screen/lib/screen-parts.d.ts +5 -5
  87. package/dist/screen/lib/screen-parts.js +1 -1
  88. package/dist/screen/lib/section-templates.d.ts +3 -3
  89. package/dist/screen/lib/session-context.d.ts +3 -3
  90. package/dist/screen/lib/session.d.ts +3 -3
  91. package/dist/screen/words.d.ts +123 -1
  92. package/dist/screen/words.js +1 -1
  93. package/dist/strings/catalogue.d.ts +3 -3
  94. package/dist/strings/catalogue.js +1 -1
  95. package/dist/strings/index.d.ts +3 -3
  96. package/dist/strings/index.js +1 -1
  97. package/dist/text-styles/index.js +11 -11
  98. package/dist/{types-E3HrTPg2.d.ts → types-CGFykP7c.d.ts} +1 -1
  99. package/dist/{useNodeOps-BF0fQsif.d.ts → useNodeOps-B3e4b8a2.d.ts} +1 -1
  100. package/dist/{words-AHHfiaRY.d.ts → words-C1U_dLBh.d.ts} +7 -0
  101. package/dist/{words-XH0TvZPg.d.ts → words-lpvYzf5U.d.ts} +4 -19
  102. package/dist/{words-D8kf071T.d.ts → words-vhnV8sM7.d.ts} +4 -26
  103. package/package.json +3 -3
  104. package/dist/LinkPicker-hPEr1MJx.d.ts +0 -113
  105. package/dist/chunk-4TMMEBAG.js +0 -4
  106. package/dist/chunk-5TRBCPRB.js +0 -5
  107. package/dist/chunk-BSSKAEFF.js +0 -5
  108. package/dist/chunk-D2BCHTQR.js +0 -1
  109. package/dist/chunk-E2O2MRZR.js +0 -1
  110. package/dist/chunk-FPOKPNO4.js +0 -1
  111. package/dist/chunk-HGTPLCTQ.js +0 -1
  112. package/dist/chunk-PWZOS45R.js +0 -2
  113. package/dist/chunk-PYCLHOSA.js +0 -9
  114. package/dist/chunk-RC6DD4XP.js +0 -7
  115. package/dist/chunk-TSQUEJZB.js +0 -5
  116. package/dist/chunk-UEM66O42.js +0 -64
  117. package/dist/chunk-UH7IGZKF.js +0 -1
  118. package/dist/chunk-VETFIYQR.js +0 -23
  119. package/dist/chunk-ZJEBF4NB.js +0 -1
@@ -1,9 +1,9 @@
1
- import{DEFAULT_FIELDS_WORDS as e}from"./chunk-FPOKPNO4.js";import{useWords as l}from"./chunk-MFIRYGHW.js";import{SearchableSelect as a,Select as i,Slider as n}from"efficient-shell/ui";import{jsx as r,jsxs as s}from"react/jsx-runtime";import{useId as o,useRef as t}from"react";function u(e,l){return e.find(e=>Object.is(e.value,l))}var d=e=>String(e);function c(n){const{id:o,options:t,placeholder:u,readOnly:c=!1,ariaLabel:v,ariaLabelledBy:m,searchable:p=!1,searchPlaceholder:h,groupCount:b=!1,renderOption:f}=n,g=l("fields",e),N=m?{"aria-labelledby":m}:v?{"aria-label":v}:{},x=t.some(e=>void 0!==e.thumb),y=x||void 0!==f||t.some(e=>void 0!==e.meta),O=e=>""===e?void 0:t[Number(e)],C=(e,l)=>{const a=O(e.value);return a?/* @__PURE__ */s("span",{className:"es-fsel-row",children:[x?/* @__PURE__ */r("span",{className:"es-fsel-thumb","aria-hidden":"true",children:a.thumb?/* @__PURE__ */r("img",{src:a.thumb,alt:"",loading:"lazy"}):null}):null,
2
- /* @__PURE__ */r("span",{className:"es-fsel-label",children:f?f(a,{active:l.active??!1,chosen:l.selected}):a.label}),void 0===a.meta||p?null:/* @__PURE__ */r("span",{className:"es-fsel-meta","aria-hidden":"true",children:a.meta})]}):e.label},j=[];let V=null;if(t.forEach((e,l)=>{const a={value:d(l),label:e.label,...e.disabled?{disabled:!0}:{},...p&&e.meta?{sublabel:e.meta}:{}};void 0===e.group?(V=null,j.push(a)):V&&V.label===e.group?V.options.push(a):(V={label:e.group,options:[a]},j.push(V))}),b)for(const e of j)"options"in e&&(e.label=`${e.label} ${e.options.length}`);const I=e=>e.flatMap(e=>{const l=O(e.value);return l?[l]:[]});if(p){const l={id:o,options:j,placeholder:h??u??g.search??e.search,disabled:c,renderOption:y?C:void 0,...N};if(!0===n.multiple){const e=Array.isArray(n.value)?n.value:[],i=n.onChange;/* @__PURE__ */
1
+ import{DEFAULT_FIELDS_WORDS as e}from"./chunk-FFYXVAAL.js";import{useWords as l}from"./chunk-MFIRYGHW.js";import{SearchableSelect as a,Select as i,Slider as n}from"efficient-shell/ui";import{jsx as r,jsxs as s}from"react/jsx-runtime";import{useId as o,useRef as t}from"react";function u(e,l){return e.find(e=>Object.is(e.value,l))}var d=e=>String(e);function c(n){const{id:o,options:t,placeholder:u,readOnly:c=!1,ariaLabel:v,ariaLabelledBy:m,searchable:p=!1,searchPlaceholder:h,groupCount:b=!1,renderOption:f}=n,g=l("fields",e),N=m?{"aria-labelledby":m}:v?{"aria-label":v}:{},x=t.some(e=>void 0!==e.thumb),y=x||void 0!==f||t.some(e=>void 0!==e.meta),C=e=>""===e?void 0:t[Number(e)],O=(e,l)=>{const a=C(e.value);return a?/* @__PURE__ */s("span",{className:"es-fsel-row",children:[x?/* @__PURE__ */r("span",{className:"es-fsel-thumb","aria-hidden":"true",children:a.thumb?/* @__PURE__ */r("img",{src:a.thumb,alt:"",loading:"lazy"}):null}):null,
2
+ /* @__PURE__ */r("span",{className:"es-fsel-label",children:f?f(a,{active:l.active??!1,chosen:l.selected}):a.label}),void 0===a.meta||p?null:/* @__PURE__ */r("span",{className:"es-fsel-meta","aria-hidden":"true",children:a.meta})]}):e.label},j=[];let V=null;if(t.forEach((e,l)=>{const a={value:d(l),label:e.label,...e.disabled?{disabled:!0}:{},...p&&e.meta?{sublabel:e.meta}:{}};void 0===e.group?(V=null,j.push(a)):V&&V.label===e.group?V.options.push(a):(V={label:e.group,options:[a]},j.push(V))}),b)for(const e of j)"options"in e&&(e.label=`${e.label} ${e.options.length}`);const F=e=>e.flatMap(e=>{const l=C(e.value);return l?[l]:[]});if(p){const l={id:o,options:j,placeholder:h??u??g.search??e.search,disabled:c,renderOption:y?O:void 0,...N};if(!0===n.multiple){const e=Array.isArray(n.value)?n.value:[],i=n.onChange;/* @__PURE__ */
3
3
  return r("div",{className:"es-fsel",children:/* @__PURE__ */r(a,{...l,multiple:!0,value:t.flatMap((l,a)=>e.some(e=>Object.is(e,l.value))?[d(a)]:[]),onChange:e=>i(t.filter((l,a)=>e.includes(d(a))).map(e=>e.value))})})}const i=t.findIndex(e=>Object.is(e.value,n.value)),s=n.onChange;/* @__PURE__ */
4
- return r("div",{className:"es-fsel",children:/* @__PURE__ */r(a,{...l,value:i>=0?d(i):"",clearable:!1,onChange:e=>{const l=O(e);l&&!Object.is(l.value,n.value)&&s(l.value)}})})}const M={id:o,size:"sm",className:"es-fsel-button",options:j,placeholder:u??g.choose,readOnly:c,renderOption:y?C:void 0,...N};if(!0===n.multiple){const e=Array.isArray(n.value)?n.value:[],l=l=>e.some(e=>Object.is(e,l.value)),a=t.flatMap((e,a)=>l(e)?[d(a)]:[]),s=n.onChange;/* @__PURE__ */
5
- return r("div",{className:"es-fsel",children:/* @__PURE__ */r(i,{...M,multiple:!0,value:a,renderValue:n.renderValue?e=>n.renderValue(I(e)):void 0,valueText:n.valueText?e=>n.valueText(I(e)):void 0,onChange:e=>s(t.filter((l,a)=>e.includes(d(a))).map(e=>e.value))})})}const T=t.findIndex(e=>Object.is(e.value,n.value)),F=n.onChange;/* @__PURE__ */
6
- return r("div",{className:"es-fsel",children:/* @__PURE__ */r(i,{...M,value:T>=0?d(T):"",renderValue:n.renderValue?e=>n.renderValue(I(e)[0]):void 0,valueText:n.valueText?e=>n.valueText(I(e)[0]):void 0,onChange:e=>{const l=O(e);l&&!Object.is(l.value,n.value)&&F(l.value)}})})}function v({id:e,label:l,value:a,onChange:i,min:u,max:d,step:c=1,shiftStep:v,styleValue:m,unit:p,sliderMin:h,sliderMax:b,auto:f,readOnly:g=!1}){const N=o(),x=e??N,y="number"==typeof a&&Number.isFinite(a)?a:void 0,O=void 0!==f&&void 0===y,C=!O&&void 0===y&&void 0!==m,j=Number((h-c).toFixed(6)),V=t(!1),I=e=>{V.current="range"===e.target.type},M=e=>{g||e===y||i(e)};/* @__PURE__ */
7
- return s("div",{className:"es-fslider"+(C||O?" is-style":""),onChangeCapture:I,onKeyDownCapture:I,onPointerDownCapture:I,children:[
4
+ return r("div",{className:"es-fsel",children:/* @__PURE__ */r(a,{...l,value:i>=0?d(i):"",clearable:!1,onChange:e=>{const l=C(e);l&&!Object.is(l.value,n.value)&&s(l.value)}})})}const I={id:o,size:"sm",className:"es-fsel-button",options:j,placeholder:u??g.choose,readOnly:c,renderOption:y?O:void 0,...N};if(!0===n.multiple){const e=Array.isArray(n.value)?n.value:[],l=l=>e.some(e=>Object.is(e,l.value)),a=t.flatMap((e,a)=>l(e)?[d(a)]:[]),s=n.onChange;/* @__PURE__ */
5
+ return r("div",{className:"es-fsel",children:/* @__PURE__ */r(i,{...I,multiple:!0,value:a,renderValue:n.renderValue?e=>n.renderValue(F(e)):void 0,valueText:n.valueText?e=>n.valueText(F(e)):void 0,onChange:e=>s(t.filter((l,a)=>e.includes(d(a))).map(e=>e.value))})})}const M=t.findIndex(e=>Object.is(e.value,n.value)),T=n.onChange;/* @__PURE__ */
6
+ return r("div",{className:"es-fsel",children:/* @__PURE__ */r(i,{...I,value:M>=0?d(M):"",renderValue:n.renderValue?e=>n.renderValue(F(e)[0]):void 0,valueText:n.valueText?e=>n.valueText(F(e)[0]):void 0,onChange:e=>{const l=C(e);l&&!Object.is(l.value,n.value)&&T(l.value)}})})}function v({id:e,label:l,value:a,onChange:i,min:u,max:d,step:c=1,shiftStep:v,styleValue:m,unit:p,sliderMin:h,sliderMax:b,auto:f,readOnly:g=!1}){const N=o(),x=e??N,y="number"==typeof a&&Number.isFinite(a)?a:void 0,C=void 0!==f&&void 0===y,O=!C&&void 0===y&&void 0!==m,j=Number((h-c).toFixed(6)),V=t(!1),F=e=>{V.current="range"===e.target.type},I=e=>{g||e===y||i(e)};/* @__PURE__ */
7
+ return s("div",{className:"es-fslider"+(O||C?" is-style":""),onChangeCapture:F,onKeyDownCapture:F,onPointerDownCapture:F,children:[
8
8
  /* @__PURE__ */r("label",{className:"es-fslider-name",htmlFor:x,children:l}),
9
- /* @__PURE__ */r(n,{id:x,label:l,value:y??null,onChange:e=>{if(null===e)return M(void 0);M(void 0!==f&&V.current&&e<h?void 0:e)},min:void 0!==f?j:h,max:b,inputMin:u??-1e9,inputMax:d??Number.POSITIVE_INFINITY,step:c,shiftStep:v,suffix:p&&!O?p:void 0,emptyLabel:f??(void 0===m?"":void 0),placeholderValue:void 0===f?m:void 0,stepFrom:void 0!==f?j:void 0,disabled:g,size:"sm"})]})}export{c as FieldSelect,v as FieldSlider,u as optionFor};
9
+ /* @__PURE__ */r(n,{id:x,label:l,value:y??null,onChange:e=>{if(null===e)return I(void 0);I(void 0!==f&&V.current&&e<h?void 0:e)},min:void 0!==f?j:h,max:b,inputMin:u??-1e9,inputMax:d??Number.POSITIVE_INFINITY,step:c,shiftStep:v,suffix:p&&!C?p:void 0,emptyLabel:f??(void 0===m?"":void 0),placeholderValue:void 0===f?m:void 0,stepFrom:void 0!==f?j:void 0,disabled:g,size:"sm"})]})}export{c as FieldSelect,v as FieldSlider,u as optionFor};
@@ -0,0 +1,9 @@
1
+ import{DEFAULT_CANVAS_WORDS as e}from"./chunk-AELNNAFM.js";import{useResolvedFields as t}from"./chunk-YRLPFZW3.js";import{toItemSelector as n,fromItemSelector as o,useNodeOps as r,parentStep as i,nextInChain as a,nodeChain as s}from"./chunk-QASZFO4S.js";import{useWords as d}from"./chunk-MFIRYGHW.js";import{setCanvasNonce as l,isTypingTarget as c}from"./chunk-ZNCEOSXO.js";import{find as u,ROOT_ID as p,getList as f,remove as h,parseZoneKey as m,move as v,duplicate as g,replaceNode as y,createNode as k,insert as S,normalizeData as w,createResolveCache as b,resolveNodeData as I,ROOT_SLOT as C,slotsOf as E}from"./chunk-KRXQM65X.js";import{topLevelSlotKeys as O,fieldsFrom as x,defaultsFrom as A}from"./chunk-NKB3KVAB.js";import{createContext as D,useEffect as z,useContext as M,useRef as Z,useSyncExternalStore as N,useState as j,useMemo as P,useCallback as $,useLayoutEffect as L}from"react";import{jsx as R,jsxs as B}from"react/jsx-runtime";import{createPortal as F}from"react-dom";function K(e){return!["setData","setUi","set"].includes(e.type)}var V=(e,t,n,o)=>{const r=f(e,t,m(n));return r?.[o]??null},H=(e,t,n,o,r)=>{const i=V(e,t,n,o);if(!i)throw new Error(`${r}: nothing at ${n}[${o}]`);return i};function T(e,t){const{selection:o}=e;return{...e.ui,itemSelector:n(e.data,t,o),selectedSlot:o&&"slot"===o.kind?{parentId:o.parentId,slot:o.slot}:null}}function q(e,t,n){return n?"node"===n.kind?u(e,t,n.id)?n:null:n.parentId===p?f(e,t,n)?n:null:u(e,t,n.parentId)&&f(e,t,n)?n:null:null}function Y(e,t,n,r=!1){const{itemSelector:i,selectedSlot:a,...s}=n;let d=e.selection;var l;return"itemSelector"in n&&(d=o(e.data,t,i??null)),"selectedSlot"in n&&(a?d=(l=a)?{kind:"slot",parentId:l.parentId,slot:l.slot}:null:"slot"===d?.kind&&(d=null)),{...e,selection:d,ui:r?s:{...e.ui,...s}}}function U(e,t,n){const o=W(e,t,n);if(o===e)return e;const r=q(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function W(e,t,n){const{data:o}=e;switch(t.type){case"setData":{const n="function"==typeof t.data?t.data(o):t.data;return{...e,data:{...o,...n}}}case"setUi":return Y(e,n,"function"==typeof t.ui?t.ui(T(e,n)):t.ui);case"set":{const r={data:o,ui:T(e,n)},i="function"==typeof t.state?t.state(r):t.state;let a=i.data?{...e,data:i.data}:e;return i.ui&&(a=Y(a,n,i.ui,!0)),a}case"insert":{const r={...m(t.destinationZone),index:t.destinationIndex},i=k(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:S(o,n,r,i)}}case"replace":{const r=H(o,n,t.destinationZone,t.destinationIndex,"replace");if(r.props.id!==t.data.props.id)throw new Error("Can't change the id during a replace action. Use remove and insert for a new node.");return{...e,data:y(o,n,r.props.id,t.data)}}case"replaceRoot":{const n={...o.root,props:{...o.root.props,...t.root.props},readOnly:t.root.readOnly};return{...e,data:{...o,root:n}}}case"duplicate":{const r=H(o,n,t.sourceZone,t.sourceIndex,"duplicate"),i=g(o,n,r.props.id),a=V(i,n,t.sourceZone,t.sourceIndex+1);return{...e,data:i,selection:a?{kind:"node",id:a.props.id}:e.selection}}case"reorder":return W(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=V(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const i={...m(t.destinationZone),index:t.destinationIndex};return{...e,data:v(o,n,r.props.id,i)}}case"remove":{const r=H(o,n,t.zone,t.index,"remove");return{...e,data:h(o,n,r.props.id)}}default:return e}}var X={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},Q={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},G=0,J=()=>`history-${G+=1}`;function _(e){let t=e.config;const r=e.now??(()=>Date.now()),i=e.historyCoalesceMs??250;let a=e.permissions??{};const s=w(e.data,t);let d={data:s,selection:null,ui:{...Q}};if(e.ui){const{itemSelector:n,selectedSlot:r,...i}=e.ui;d={data:s,selection:r?{kind:"slot",...r}:o(s,t,n??null),ui:{...Q,...i}}}let l=[{core:d,at:-1/0,sealed:!0,id:J()}],c=0;const p=e=>{const t=l[c],n=r();!e&&c===l.length-1&&c>0&&!t.sealed&&n-t.at<i?l=[...l.slice(0,c),{...t,core:d,at:n}]:(l=[...l.slice(0,c+1),{core:d,at:n,sealed:e,id:J()}],c=l.length-1)},h=/* @__PURE__ */new Set;let m=null,v=null,g=0,k=null,S=!1;const C=()=>{for(const e of[...h])e()},E=()=>{l=[...l.slice(0,c),{...l[c],core:d},...l.slice(c+1)]},O=(t,n)=>{g>0?S=S||n:(n?p(!1):d!==t&&E(),d.data!==t.data&&e.onChange?.(d.data),d!==t&&C())},x=e=>{const n=d;if(d=U(d,e,t),d===n)return;const o=e.recordHistory??K(e);O(n,o&&d.data!==n.data)},A=t=>{0===g&&(k=d,S=!1),g+=1;try{t()}catch(e){throw g-=1,0===g&&k&&(d=k,k=null),e}if(g-=1,g>0||!k)return;const n=k;k=null,S&&d.data!==n.data?p(!0):d!==n&&E(),d.data!==n.data&&e.onChange?.(d.data),d!==n&&C()},D=e=>{const n=d,o=q(d.data,t,e);var r,i;(r=o,i=d.selection,r===i||r&&i&&r.kind===i.kind&&("node"===r.kind&&"node"===i.kind?r.id===i.id:"slot"===r.kind&&"slot"===i.kind&&r.parentId===i.parentId&&r.slot===i.slot))||(d={...d,selection:o},O(n,!1))},z=t=>{const n=d;c=t,d=l[c].core,d.data!==n.data&&e.onChange?.(d.data),d!==n&&C()},M=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...X,...a,...n}};let Z=M();const N=b(),j={resolveCache:N,async resolveAll({trigger:e="load",metadata:n}={}){const o=d.data,r={type:"root",props:{...o.root.props??{}}},i=[...o.content,...Object.values(o.zones??{}).flat()],[a,...s]=await Promise.all([I(r,t,{cache:N,trigger:e,metadata:n}),...i.map(o=>I(o,t,{cache:N,trigger:e,metadata:n}))]);A(()=>{const e=d;let n=d.data;s.forEach((e,r)=>{if(!e.didChange)return;const a=i[r].props.id,s=u(n,t,a)?.node;s&&s===u(o,t,a)?.node&&(n=y(n,t,a,e.node))}),a.didChange&&n.root===o.root&&(n={...n,root:{...n.root,props:a.node.props,readOnly:a.node.readOnly??n.root.readOnly}}),n!==d.data&&(d={...d,data:n,selection:q(n,t,d.selection)},O(e,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=u(d.data,t,e)?.node;if(!r)return!1;const i=await I(r,t,{cache:N,trigger:n,metadata:o});if(!i.didChange)return!1;let a=!1;return A(()=>{const n=d;if(u(d.data,t,e)?.node!==r)return;const o=y(d.data,t,e,i.node);o!==d.data&&(d={...d,data:o,selection:q(o,t,d.selection)},O(n,!1),a=!0)}),a},get config(){return t},getState(){if(m&&v===d)return m;const e=d,o={data:e.data,ui:T(e,t)},r="node"===e.selection?.kind?u(e.data,t,e.selection.id)?.node??null:null;return m={appState:o,selection:e.selection,selectedItem:r,config:t,dispatch:x,history:{back:()=>j.undo(),forward:()=>j.redo(),hasPast:c>0,hasFuture:c<l.length-1,histories:l.map(e=>({id:e.id,state:{data:e.core.data,ui:T(e.core,t)}})),index:c,setHistoryIndex:e=>{e>=0&&e<l.length&&e!==c&&z(e)}},getPermissions:Z,getItemById:n=>u(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return f(e,t,{parentId:o,slot:r})?.[n.index]}(e.data,t,n),getSelectorForId:o=>{const r=n(e.data,t,{kind:"node",id:o});return r?{index:r.index,zone:r.zone??"root:default-zone"}:void 0}},v=e,m},subscribe:e=>(h.add(e),()=>{h.delete(e)}),dispatch:x,batch:A,select:e=>D(e?{kind:"node",id:e}:null),selectSlot:e=>D(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){A(()=>{const n=d,o=void 0===e.select?d.selection:e.select;d={...d,data:e.data,selection:q(e.data,t,o)},O(n,e.data!==n.data)})},load(e,n={}){const o=d,r=w(e,t);d={...d,data:r,selection:q(r,t,n.selection??d.selection)},n.keepHistory||(l=[{core:d,at:-1/0,sealed:!0,id:J()}],c=0),d!==o&&C()},undo(){c>0&&z(c-1)},redo(){c<l.length-1&&z(c+1)},setPermissions(e){(function(e,t){if(e===t)return!0;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])})(e,a)||(a=e,Z=M(),m=null,C())},setConfig(e){e!==t&&(t=e,Z=M(),m=null,C())}};return j}function ee(e,t,n={}){const o=e=>{if(e.altKey)return;if(!(e.metaKey!==e.ctrlKey))return;const o="KeyZ"===e.code,r="KeyY"===e.code&&!e.shiftKey;(o||r)&&(n.leaveTyping&&c(e.target)||!1!==t.getState?.().getPermissions().edit&&(e.preventDefault(),r||e.shiftKey?t.redo():t.undo()))};return e.addEventListener("keydown",o),()=>e.removeEventListener("keydown",o)}var te=D(null),ne=D(!0);function oe({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return z(()=>{n&&e.resolveAll()},[e,n]),z(()=>{if(t&&"undefined"!=typeof document)return ee(document,e)},[e,t]),/* @__PURE__ */R(te.Provider,{value:e,children:/* @__PURE__ */R(ne.Provider,{value:t,children:o})})}function re(){const e=M(te);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function ie(e){const t=re(),n=Z({view:null,selector:null,value:void 0,has:!1}),o=()=>{const o=t.getState(),r=n.current;if(r.has&&r.view===o&&r.selector===e)return r.value;const i=e(o);return r.has&&Object.is(r.value,i)?(n.current={view:o,selector:e,value:r.value,has:!0},r.value):(n.current={view:o,selector:e,value:i,has:!0},i)};return N(t.subscribe,o,o)}function ae(){return function(e){return ie(e)}}var se="data-puck-component",de="data-puck-dropzone",le={},ce="data-es-mirror",ue="undefined"==typeof window?z:L;function pe(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${ce}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(ce,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function fe({children:t,id:n="preview-frame",title:o,className:r,style:i,mirrorStyles:a=!0,onDocument:s,height:c="auto",nonce:u}){const p=d("canvas",e),f=Z(null),[h,m]=j(null);return ue(()=>{const e=f.current,t=h?.ownerDocument.defaultView;if("auto"!==c||!e||!h||!t)return;const n=()=>{e.style.height=`${Math.ceil(h.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(h),()=>r?.disconnect()},[h,c]),ue(()=>{let e=f.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=f.current?.contentDocument??e),e.body||e.documentElement.appendChild(e.createElement("body")),e.body.style.margin="0";const t=e.createElement("div");t.setAttribute("data-puck-entry",""),t.id="frame-root","fill"===c&&t.classList.add("es-frame-fill"),e.body.appendChild(t),l(e,u),m(t),s?.(e);let n=null;const o=f.current?.ownerDocument;if(a&&o){pe(o,e,u);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>pe(o,e,u)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}return()=>{n?.disconnect(),t.remove(),m(null),s?.(null)}},[]),/* @__PURE__ */R("iframe",{ref:f,id:n,title:o??p.frame,className:["es-canvas-frame","fill"===c?"is-fill":"",r??""].filter(Boolean).join(" "),style:i,children:h?F(t,h):null})}var he=D(null),me=D(le),ve=[];function ge({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128}){const i=re(),a=ie(n=>f(n.appState.data,i.config,{parentId:e,slot:t})??ve),s=ie(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==p),d=ie(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),l=M(he),c=["es-zone"];return a.length&&c.push("has-children"),e===p&&c.push("is-root"),(s||d)&&c.push("is-area-selected"),null!==l&&l===e&&e!==p&&c.push("is-hovering-area"),n&&c.push(n),/* @__PURE__ */R("div",{className:c.join(" "),[de]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`},children:a.map(e=>/* @__PURE__ */R(Se,{node:e},e.props.id))})}function ye(e,t,n,o){const r="root"===t?e.root:e.components[t],i={...o};for(const e of O(x(r)))i[e]=function(t={}){/* @__PURE__ */
2
+ return R(ge,{parentId:n,slot:e,...t})};return i}function ke(e){return function({zone:t,...n}){/* @__PURE__ */
3
+ return R(ge,{parentId:e,slot:t,...n})}}function Se({node:e}){const t=re().config,n=t.components[e.type],o=e.props.id,r=function(e){const t=Z(null);return P(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(se),o.removeAttribute("data-puck-dnd")),t.current=n,n&&(n.setAttribute(se,e),n.setAttribute("data-puck-dnd",e),n.style.position="relative")},[e])}(o),i=M(me);if(!n?.render)return null;const a=n.render,s=ye(t,e.type,o,{...A(n),...e.props}),d={renderDropZone:ke(o),isEditing:!0,dragRef:n.inline?r:null,metadata:{...i,...n.metadata}};return n.inline?/* @__PURE__ */R(a,{...s,puck:d,editMode:!0}):/* @__PURE__ */R("div",{[se]:o,"data-puck-dnd":o,style:{position:"relative"},children:/* @__PURE__ */R(a,{...s,puck:d,editMode:!0})})}function we({metadata:e}){const t=ie(e=>e.config),n=ie(e=>e.appState.data.root).props??{},o=t.root?.render,r=/* @__PURE__ */R(ge,{parentId:p,slot:C}),i=o?/* @__PURE__ */R(o,{id:"puck-root",...ye(t,"root",p,n),puck:{renderDropZone:ke(p),isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:r}):r;/* @__PURE__ */
4
+ return R(me.Provider,{value:e??le,children:i})}function be({id:e,kind:t,overlay:n}){const o=Z(null),[r,i]=j(null);ue(()=>{const t=o.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!e)return void i(null);let r=0;const a=()=>{r=0;const a=function(e,t){if(!e||!t)return null;const n=e.getBoundingClientRect(),o=t.getBoundingClientRect();return{top:n.top-o.top,left:n.left-o.left,width:n.width,height:n.height}}(t.querySelector(`[${se}="${n.CSS?.escape?n.CSS.escape(e):e}"]`),o.current?.parentElement??null);i(e=>{return(t=e)===(n=a)||t&&n&&t.top===n.top&&t.left===n.left&&t.width===n.width&&t.height===n.height?e:a;var t,n})},s=()=>{r||(r=(n.requestAnimationFrame??(e=>n.setTimeout(e,16)))(a))};a();const d="MutationObserver"in n?new n.MutationObserver(s):null;d?.observe(t.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0});const l="ResizeObserver"in n?new n.ResizeObserver(s):null;return l?.observe(t.documentElement),n.addEventListener("resize",s),()=>{d?.disconnect(),l?.disconnect(),n.removeEventListener("resize",s),r&&(n.cancelAnimationFrame??n.clearTimeout)(r)}},[e]);const a=/* @__PURE__ */R("div",{ref:o,"aria-hidden":"true",className:`es-canvas-outline is-${t}`,style:r?{position:"absolute",top:r.top,left:r.left,width:r.width,height:r.height}:{display:"none"}});return n&&e?/* @__PURE__ */R(n,{componentId:e,kind:t,children:a}):a}function Ie({frame:e=!0,className:t,style:n,metadata:o,mirrorStyles:r,onDocument:d,height:l,title:c,nonce:p,hotkeys:f,frameWrapper:h,overlay:m,children:v}){const g=re(),y=M(ne),k=f??y,[S,w]=j(void 0),b=ie(e=>"node"===e.selection?.kind?e.selection.id:null),[I,C]=j(null),O=e=>{const t=e.closest?.(`[${se}]`)?.getAttribute(se);if(!t)return;const n=g.getState(),o=n.appState.data,r=u(o,g.config,t);if(!r||0===E(r.node,g.config).length)return t;const i="node"===n.selection?.kind?n.selection.id:null;return a(s(o,g.config,t),i)??t},x=/* @__PURE__ */B("div",{className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;t.closest?.("a[href]")&&e.preventDefault();const n=O(t);void 0===n?t.hasAttribute?.(de)||g.select(null):g.select(n)},onMouseOver:e=>{const t=O(e.target)??null;t!==I&&C(t)},onMouseLeave:()=>C(null),children:[
5
+ /* @__PURE__ */R(he.Provider,{value:I,children:/* @__PURE__ */R(we,{metadata:o})}),
6
+ /* @__PURE__ */B("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
7
+ /* @__PURE__ */R(be,{id:I&&I!==b?I:null,kind:"hover",overlay:m}),
8
+ /* @__PURE__ */R(be,{id:b,kind:"selected",overlay:m})]}),v]}),A=h?/* @__PURE__ */R(h,{document:S,children:x}):x;z(()=>{if(S&&k)return ee(S,g)},[S,k,g]),z(()=>{if(!S)return;const e=e=>{if("Escape"!==e.key||e.defaultPrevented)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select"))return;const n=g.getState();if("node"!==n.selection?.kind)return;const o=i(n.appState.data,g.config,n.selection);"node"===o?.kind&&g.select(o.id)};return S.addEventListener("keydown",e),()=>S.removeEventListener("keydown",e)},[S,g]);/* @__PURE__ */
9
+ return R("div",{className:"es-canvas"+(t?` ${t}`:""),style:n,"data-puck-preview":"",children:e?/* @__PURE__ */R(fe,{mirrorStyles:r,onDocument:e=>{w(e??void 0),d?.(e)},height:l,title:c,nonce:p,children:A}):/* @__PURE__ */R("div",{id:"preview-frame","data-puck-entry":"",children:A})})}function Ce(e={}){const t=re(),n=ie(e=>e.appState.data);return r({...e,data:n,config:t.config,commit:(e,{select:n})=>t.run({data:e,select:n})})}function Ee(){const e=re(),n=ie(e=>e.config),o=e.resolveCache,r=ie(e=>e.selectedItem),i=ie(e=>e.appState.data.root),a=r?r.props.id:"root",s=i.props??{},d=P(()=>r||{type:"root",props:s},[r,s]),l=r?n.components[r.type]:n.root,c=e.getState(),p=r?u(c.appState.data,n,a):null,f=p&&"root"!==p.place.parentId?p.place.parentId:null,h=f?c.getItemById(f)??null:null,{fields:m}=t({id:a,node:d,block:l,parent:h,appState:c.appState}),v=ie(e=>!1===e.getPermissions(r?{item:r}:{root:!0}).edit),g=$((t,r)=>{(async()=>{const i=e.getState();if("root"!==a){const s=i.getItemById(a),d=i.getSelectorForId(a);if(!s||!d)return;const l={...s,props:{...s.props,[t]:r}},{node:c}=await I(l,n,{cache:o,trigger:"replace"}),u=e.getState().getSelectorForId(a);if(!u)return;return void e.dispatch({type:"replace",destinationZone:u.zone??"root:default-zone",destinationIndex:u.index,data:c})}const s=i.appState.data.root.props??{},{node:d}=await I({type:"root",props:{...s,[t]:r}},n,{cache:o,trigger:"replace"});e.dispatch({type:"replaceRoot",root:{props:d.props,readOnly:d.readOnly},recordHistory:!0})})()},[e,n,o,a]);return{id:a,node:d,fields:m,values:d.props,readOnly:v,onChange:g}}export{fe as CanvasFrame,Q as DEFAULT_UI,Ie as EaselCanvas,oe as EaselProvider,we as EditDocument,ee as bindUndoKeys,_ as createEasel,ae as createUseEasel,K as recordsByDefault,U as reduce,T as uiView,ie as useEasel,re as useEaselApi,Ce as useEaselNodeOps,Ee as useSelectedFields,q as validSelection};
@@ -1,2 +1,2 @@
1
- import{routeSharedHostMessage as e}from"./chunk-S4AWJX4Q.js";import{describeLoadFailure as r,hostLoadRefusal as n}from"./chunk-ERR437B5.js";import{editLockOf as t}from"./chunk-GMCZXMOV.js";import{NO_DOCUMENT_ADDRESSING as o}from"./chunk-RLBXE4EU.js";import{saveStatusOf as u,resetForDocumentSwitch as a}from"./chunk-HNKB2ZYR.js";import{isExpiredSession as s}from"./chunk-CLOS6SSX.js";import{useAdminBridge as i}from"./chunk-VPFNZ7TB.js";import{useEaselSession as l}from"./chunk-O7Q4DDJT.js";import{backendOf as c,setSessionDocumentSite as d}from"./chunk-RSCMJIWS.js";import{useEaselHost as f}from"./chunk-U3JP4VGF.js";import{DEFAULT_SCREEN_WORDS as m}from"./chunk-E2O2MRZR.js";import{useAutosave as g}from"./chunk-BDTITTMW.js";import{canWriteDocument as k,newEaselClientId as v,reloadIfVersionMoved as p,openUnansweredClaim as h,FAIL_OPEN_RETRY_MS as y,CLAIM_FAIL_OPEN_MS as w,holderOf as S}from"./chunk-THWO5YVZ.js";import{useWords as b}from"./chunk-MFIRYGHW.js";import{createContext as I,useContext as P,useState as j,useMemo as R,useCallback as T,useEffect as B,useRef as O}from"react";import{jsx as E}from"react/jsx-runtime";var C={content:[],root:{},zones:{}};var H=I(null);function M(){const e=P(H);if(!e)throw new Error("useStorefrontDocument must be used within StorefrontDocumentProvider");return e}function A({target:I,addressing:P=o,onHostMessage:M,children:A}){const D=P,{homeSlug:F,entryMayBounce:V,entryBounce:L,onSwitch:N,tellsHost:W,adapterFor:Z,migrateRenamedProps:J,describeMissing:X,onLoadFailed:Y}=D,[x,G]=j(I),U=f(),K=l(),Q=R(()=>c(K),[K]),z=R(()=>t(K),[K]),_="template"===x.kind,q="template"===x.kind?x.id:null,$="template"===x.kind?x.pageSlug??F??"":"document"===x.kind?x.slug??"":x.slug,ee="page"===x.kind?x.siteId??null:null,re=K.blocks,ne=R(()=>Z(x,Q,re),[Z,Q,re,x.kind,"template"===x.kind?x.id:"document"===x.kind?x.record:x.siteId]),te=ne.capabilities,oe=T(e=>K.documentHooks?.stored?.(e)??e,[K]),ue="page"===x.kind?x.originSlug??null:null;B(()=>{d(K,ee)},[K,ee]);const ae=O(x);B(()=>{ae.current=x},[x]);const{token:se,tokenRef:ie,capabilities:le}=i({onMessage:r=>{if(M?.(r)||e(r))return;const n=r;if("storefront-editor:navigate"===n?.type){const e=r;e?.target&&Pr(e.target)}}}),ce=!K.usesBridgedToken||null!==se,de=ne.lock,fe=Boolean(Q.lock),[me,ge]=j(null),[ke,ve]=j(null),[pe,he]=j(null),[ye,we]=j(null),Se=b("screen",m),be=ye?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})}}(ye,Se):null,[Ie,Pe]=j(null),je=O(null),Re=O(null),[Te,Be]=j(!1),Oe=O(null),[Ee,Ce]=j(null),He=O(null),[Me,Ae]=j(null),De=O(null);B(()=>{De.current=Me},[Me]);const[Fe,Ve]=j(te.hasEditLock?{kind:"checking"}:{kind:"editing"}),Le=O(Fe);B(()=>{Le.current=Fe},[Fe]);const Ne=O(()=>Promise.resolve(!1)),We=T(e=>{Re.current=e,Be(!0)},[]),Ze=g({save:async({id:e,data:r})=>{if(k(Le.current)){if(!await Ne.current(e,r)){if(!k(Le.current))return void We({id:e,data:r});throw new Error("page save did not land")}}else We({id:e,data:r})},onFailure:(e,r)=>{0===r&&U.send("storefront-editor:save-failed")}}),{state:Je,push:Xe,flush:Ye,pause:xe,resume:Ge,stop:Ue,reset:Ke,retryNow:Qe,hasPending:ze}=Ze,_e=O(Je);B(()=>{_e.current=Je},[Je]);const qe=u(Je),$e=T(()=>{const e=Re.current;e&&(Re.current=null,Be(!1),Xe(e))},[Xe]),er=O("");er.current||(er.current=v());const[rr,nr]=j(0),tr=O(!1),[or,ur]=j(V(I)),ar=O(!1);B(()=>{if(ar.current)return;ar.current=!0;const e=U.address.search(),r=L(I,e);r?U.address.load(r):V(I)&&ur(!1)},[I,U]);const sr=U.send;B(()=>{if(!ce)return;let e=!1;const t=ae.current,o=ne.resolve($),u=K.documentHooks?.opening?.({slug:$,isTemplate:_,capabilities:te});return o.then(async r=>{if(e)return;if(!r)return"page"===t.kind&&null!==F&&$!==F?void U.address.load({kind:"page",slug:F,siteId:ee??void 0}):(we({target:t,slug:$,missing:!0,sentence:X?.(t)??null}),void Y?.(t,null));const n=r.readOnlyReason?r.readOnlyReason:null;je.current=n,Pe(n),ge(r.id),ve(r.kind??null),He.current=r.version??null;const o=r.layout,a=o&&Object.keys(o).length?o:C,s=J(a),i=u?await u(s):s;e||he(i)}).catch(o=>{e||(console.error("[storefront-editor] document load failed",o),we({target:t,slug:$,missing:!1,sentence:n(o,{slug:$},K),cause:r(o,K)}),Y?.(t,o))}),()=>{e=!0}},[ce,se,_,ne,$]);const ir=T(e=>new Promise(r=>{const n=Date.now(),t=setInterval(()=>{const o=ie.current;o&&o!==e?(clearInterval(t),r(o)):Date.now()-n>6e3&&(clearInterval(t),r(null))},200)}),[]),lr=T(async e=>{const r=ie.current;if(!r&&K.usesBridgedToken)return{ok:!1,error:new Error("no editor token")};try{return{ok:!0,value:await e(r??"")}}catch(n){if(s(n,K)){sr("storefront-editor:auth-expired");const n=r?await ir(r):null;if(n)try{return{ok:!0,value:await e(n)}}catch(e){return{ok:!1,error:e}}}return{ok:!1,error:n}}},[sr,ir,K]),cr=T(async e=>{const r=ie.current?await lr(e):{ok:!1};return r.ok||sr("storefront-editor:save-failed"),r.ok},[sr,lr]),dr=T(async(e,r,n=!1)=>{if(null!==je.current)return!1;if(!k(Le.current))return!1;if(De.current)return!1;const t=await lr(()=>ne.saveLayout(e,r,He.current,er.current));if(t.ok)return He.current=t.value.version??He.current,!0;const o=z.readLockTaken(t.error);if(o){const e={kind:"takenover",holder:o};return Le.current=e,Ve(e),!1}const u=z.readSaveConflict(t.error);if(u){if(u.savedByYou&&!n&&ne.rereadVersion){const n=await lr(()=>ne.rereadVersion(e));if(n.ok&&n.value)return He.current=n.value,Ne.current(e,r,!0)}Ue(),De.current=u,Ae(u)}return!1},[ne,lr,Ue]);B(()=>{Ne.current=dr},[dr]);const fr=T(e=>{if(null!==je.current)return;if(sr("storefront-editor:dirty"),!me)return;const r=oe(e);Oe.current=r,k(Le.current)?Xe({id:me,data:r}):We({id:me,data:r})},[me,sr,We,Xe,oe]),mr=T(async()=>{k(Le.current)&&$e();return await Ye()&&null==Re.current},[$e,Ye]),gr=O(mr);B(()=>{gr.current=mr},[mr]);const kr=O(lr);B(()=>{kr.current=lr},[lr]);const vr=T(()=>{U.address.reload()},[U]),pr=O(()=>Promise.resolve(!1));B(()=>{pr.current=()=>{const e=ne.rereadVersion;return me&&e?p({ours:He.current,stored:async()=>{const r=await kr.current(()=>e(me));return r.ok?r.value:null},hasPending:()=>null!=Re.current||ze(),reload:vr}):Promise.resolve(!1)}},[ne,me,ze,vr]);const hr=null!==Ie;B(()=>{if(!de||!me||!ce||hr)return;let e=!1,r=null,n=null;const t=er.current,o={claim:async e=>{const r=await kr.current(()=>de.claim(me,t,e));if(r.ok)return{heartbeat_seconds:r.value.heartbeatSeconds};throw r.error},cancelled:()=>e,currentAccess:()=>Le.current,heldWrite:()=>({pending:null!=Re.current||ze(),autoSaveEnabled:!_e.current.paused,saveConflict:null!=De.current}),setAccess:e=>{Le.current=e,Ve(e)},releaseHeldWrite:()=>{gr.current()},startHeartbeat:e=>{r&&clearInterval(r),r=setInterval(()=>{u(!1)},e)},stopHeartbeat:()=>{r&&(clearInterval(r),r=null)},reloadIfMoved:()=>{pr.current()}},u=z.makeClaimBeat(o),a=tr.current;return tr.current=!1,a||(Ve({kind:"checking"}),n=setTimeout(()=>{n=null,h(o)&&o.startHeartbeat(y)},w)),u(a).finally(()=>{n&&clearTimeout(n),n=null}),()=>{e=!0,n&&clearTimeout(n),r&&clearInterval(r),de.release(me,t).catch(()=>{})}},[me,de,ce,se,rr,hr]);const yr=T(()=>{de&&me&&(tr.current=!0,nr(e=>e+1))},[me,de]),wr=T(()=>{Ve(e=>{const r="blocked"===e.kind||"takenover"===e.kind?e.holder:null;return r?{kind:"readonly",holder:r}:e})},[]),Sr=T(()=>{_e.current.paused?(k(Le.current)&&$e(),Ge()):xe()},[$e,xe,Ge]),br=T(()=>{Qe()},[Qe]),Ir=T(e=>{Oe.current=null,a("template"!==e.kind&&fe,{resetAutosave:()=>{Ke(),Re.current=null,Be(!1)},setVersion:e=>{He.current=e},setSaveConflict:Ae,setAccess:Ve}),N(e),G(e),je.current=null,Pe(null),ge(null),ve(null),he(null),we(null),U.address.show(e),"document"!==e.kind&&W(e)&&U.send("storefront-editor:navigated",{target:e})},[Ke,U,fe,N,W]),Pr=T(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,ae.current,F))return;const r=null!=Re.current;if(!r&&!ze())return void Ir(e);const n=_e.current;r||n.paused||n.failed||n.stopped?Ce(e):Ye().then(r=>{r?Ir(e):Ce(e)})},[Ir,ze,Ye,F]),jr=T(()=>Ce(null),[]),Rr=T(()=>{Ce(e=>(e&&Ir(e),null))},[Ir]),Tr=T(async()=>{const e=Ee;if(!e)return;await mr()&&(Ce(null),Ir(e))},[Ee,mr,Ir]),Br=T(async e=>{if(null!==je.current)return;if(!me)return;if(!k(Le.current)||De.current)return;const r=oe(e);if(!await dr(me,r))return void(De.current||sr("storefront-editor:save-failed"));const n=ne.publish;if(!te.canPublish||!n)return void sr("storefront-editor:saved");const t=await lr(()=>n(me,He.current??void 0));t.ok?(He.current=t.value.version??He.current,sr("storefront-editor:published")):sr("storefront-editor:save-failed")},[me,ne,te.canPublish,sr,dr,lr,oe]);/* @__PURE__ */
2
- return E(H.Provider,{value:{target:x,adapter:ne,capabilities:te,templateId:q,currentSlug:$,currentKind:ke,siteId:ee,ready:ce,token:se,tokenRef:ie,notifyParent:sr,bridgeCapabilities:le,runAuthed:cr,docId:me,data:pe,getLiveData:()=>Oe.current??pe,footerOriginSlug:ue,error:be,redirecting:or,saveStatus:qe,saveState:Je,autoSaveEnabled:!Je.paused,autoSaveStoppedByConflict:Je.stopped,hasUnsavedEdits:Je.pending||Te,toggleAutoSave:Sr,retrySave:br,onChange:fr,flushSave:mr,onPublish:Br,access:Fe,readOnly:null!==S(Fe)||null!==Ie||null!==Me,readOnlyReason:Ie,takeOverEditing:yr,viewReadOnly:wr,saveConflict:Me,reloadFromServer:vr,navigate:Pr,pendingNav:Ee,cancelPendingNav:jr,discardAndNavigate:Rr,saveAndNavigate:Tr},children:A})}export{H as ScreenDocumentContext,A as ScreenDocumentProvider,M as useScreenDocument};
1
+ import{routeSharedHostMessage as e}from"./chunk-S4AWJX4Q.js";import{describeLoadFailure as r,hostLoadRefusal as n}from"./chunk-ERR437B5.js";import{editLockOf as t}from"./chunk-GMCZXMOV.js";import{NO_DOCUMENT_ADDRESSING as o}from"./chunk-RLBXE4EU.js";import{saveStatusOf as u,resetForDocumentSwitch as a}from"./chunk-HNKB2ZYR.js";import{isExpiredSession as s}from"./chunk-CLOS6SSX.js";import{useAdminBridge as i}from"./chunk-VPFNZ7TB.js";import{useEaselSession as l}from"./chunk-O7Q4DDJT.js";import{backendOf as c,setSessionDocumentSite as d}from"./chunk-RSCMJIWS.js";import{useEaselHost as f}from"./chunk-U3JP4VGF.js";import{DEFAULT_SCREEN_WORDS as m}from"./chunk-BF3PIXZD.js";import{useAutosave as g}from"./chunk-BDTITTMW.js";import{canWriteDocument as k,newEaselClientId as v,reloadIfVersionMoved as p,openUnansweredClaim as h,FAIL_OPEN_RETRY_MS as y,CLAIM_FAIL_OPEN_MS as w,holderOf as S}from"./chunk-THWO5YVZ.js";import{useWords as b}from"./chunk-MFIRYGHW.js";import{createContext as I,useContext as P,useState as j,useMemo as B,useCallback as T,useEffect as R,useRef as O}from"react";import{jsx as C}from"react/jsx-runtime";var E={content:[],root:{},zones:{}};var H=I(null);function D(){const e=P(H);if(!e)throw new Error("useStorefrontDocument must be used within StorefrontDocumentProvider");return e}function M({target:I,addressing:P=o,onHostMessage:D,children:M}){const A=P,{homeSlug:F,entryMayBounce:V,entryBounce:L,onSwitch:N,tellsHost:W,adapterFor:X,migrateRenamedProps:Z,describeMissing:J,onLoadFailed:Y}=A,[x,G]=j(I),U=f(),K=l(),Q=B(()=>c(K),[K]),z=B(()=>t(K),[K]),_="template"===x.kind,q="template"===x.kind?x.id:null,$="template"===x.kind?x.pageSlug??F??"":"document"===x.kind?x.slug??"":x.slug,ee="page"===x.kind?x.siteId??null:null,re=K.blocks,ne=B(()=>X(x,Q,re),[X,Q,re,x.kind,"template"===x.kind?x.id:"document"===x.kind?x.record:x.siteId]),te=ne.capabilities,oe=T(e=>K.documentHooks?.stored?.(e)??e,[K]),ue="page"===x.kind?x.originSlug??null:null;R(()=>{d(K,ee)},[K,ee]);const ae=O(x);R(()=>{ae.current=x},[x]);const{token:se,tokenRef:ie,capabilities:le}=i({onMessage:r=>{if(D?.(r)||e(r))return;const n=r;if("storefront-editor:navigate"===n?.type){const e=r;e?.target&&Pr(e.target)}}}),ce=!K.usesBridgedToken||null!==se,de=ne.lock,fe=Boolean(Q.lock),[me,ge]=j(null),[ke,ve]=j(null),[pe,he]=j(null),[ye,we]=j(null),Se=b("screen",m),be=ye?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})}}(ye,Se):null,[Ie,Pe]=j(null),je=O(null),Be=O(null),[Te,Re]=j(!1),Oe=O(null),[Ce,Ee]=j(null),He=O(null),[De,Me]=j(null),Ae=O(null);R(()=>{Ae.current=De},[De]);const[Fe,Ve]=j(te.hasEditLock?{kind:"checking"}:{kind:"editing"}),Le=O(Fe);R(()=>{Le.current=Fe},[Fe]);const Ne=O(()=>Promise.resolve(!1)),We=T(e=>{Be.current=e,Re(!0)},[]),Xe=g({save:async({id:e,data:r})=>{if(k(Le.current)){if(!await Ne.current(e,r)){if(!k(Le.current))return void We({id:e,data:r});throw new Error("page save did not land")}}else We({id:e,data:r})},onFailure:(e,r)=>{0===r&&U.send("storefront-editor:save-failed")}}),{state:Ze,push:Je,flush:Ye,pause:xe,resume:Ge,stop:Ue,reset:Ke,retryNow:Qe,hasPending:ze}=Xe,_e=O(Ze);R(()=>{_e.current=Ze},[Ze]);const qe=u(Ze),$e=T(()=>{const e=Be.current;e&&(Be.current=null,Re(!1),Je(e))},[Je]),er=O("");er.current||(er.current=v());const[rr,nr]=j(0),tr=O(!1),[or,ur]=j(V(I)),ar=O(!1);R(()=>{if(ar.current)return;ar.current=!0;const e=U.address.search(),r=L(I,e);r?U.address.load(r):V(I)&&ur(!1)},[I,U]);const sr=U.send;R(()=>{if(!ce)return;let e=!1;const t=ae.current,o=ne.resolve($),u=K.documentHooks?.opening?.({slug:$,isTemplate:_,capabilities:te});return o.then(async r=>{if(e)return;if(!r)return"page"===t.kind&&null!==F&&$!==F?void U.address.load({kind:"page",slug:F,siteId:ee??void 0}):(we({target:t,slug:$,missing:!0,sentence:J?.(t)??null}),void Y?.(t,null));const n=r.readOnlyReason?r.readOnlyReason:null;je.current=n,Pe(n),ge(r.id),ve(r.kind??null),He.current=r.version??null;const o=r.layout,a=o&&Object.keys(o).length?o:E,s=Z(a),i=u?await u(s):s;e||he(i)}).catch(o=>{e||(console.error("[storefront-editor] document load failed",o),we({target:t,slug:$,missing:!1,sentence:n(o,{slug:$},K),cause:r(o,K)}),Y?.(t,o))}),()=>{e=!0}},[ce,se,_,ne,$]);const ir=T(e=>new Promise(r=>{const n=Date.now(),t=setInterval(()=>{const o=ie.current;o&&o!==e?(clearInterval(t),r(o)):Date.now()-n>6e3&&(clearInterval(t),r(null))},200)}),[]),lr=T(async e=>{const r=ie.current;if(!r&&K.usesBridgedToken)return{ok:!1,error:new Error("no editor token")};try{return{ok:!0,value:await e(r??"")}}catch(n){if(s(n,K)){sr("storefront-editor:auth-expired");const n=r?await ir(r):null;if(n)try{return{ok:!0,value:await e(n)}}catch(e){return{ok:!1,error:e}}}return{ok:!1,error:n}}},[sr,ir,K]),cr=T(async e=>{const r=ie.current?await lr(e):{ok:!1};return r.ok||sr("storefront-editor:save-failed"),r.ok},[sr,lr]),dr=T(async(e,r,n=!1)=>{if(null!==je.current)return!1;if(!k(Le.current))return!1;if(Ae.current)return!1;const t=await lr(()=>ne.saveLayout(e,r,He.current,er.current));if(t.ok)return He.current=t.value.version??He.current,!0;const o=z.readLockTaken(t.error);if(o){const e={kind:"takenover",holder:o};return Le.current=e,Ve(e),!1}const u=z.readSaveConflict(t.error);if(u){if(u.savedByYou&&!n&&ne.rereadVersion){const n=await lr(()=>ne.rereadVersion(e));if(n.ok&&n.value)return He.current=n.value,Ne.current(e,r,!0)}Ue(),Ae.current=u,Me(u)}return!1},[ne,lr,Ue]);R(()=>{Ne.current=dr},[dr]);const fr=T(e=>{if(null!==je.current)return;if(sr("storefront-editor:dirty"),!me)return;const r=oe(e);Oe.current=r,k(Le.current)?Je({id:me,data:r}):We({id:me,data:r})},[me,sr,We,Je,oe]),mr=T(async()=>{k(Le.current)&&$e();return await Ye()&&null==Be.current},[$e,Ye]),gr=O(mr);R(()=>{gr.current=mr},[mr]);const kr=O(lr);R(()=>{kr.current=lr},[lr]);const vr=T(()=>{U.address.reload()},[U]),pr=O(()=>Promise.resolve(!1));R(()=>{pr.current=()=>{const e=ne.rereadVersion;return me&&e?p({ours:He.current,stored:async()=>{const r=await kr.current(()=>e(me));return r.ok?r.value:null},hasPending:()=>null!=Be.current||ze(),reload:vr}):Promise.resolve(!1)}},[ne,me,ze,vr]);const hr=null!==Ie;R(()=>{if(!de||!me||!ce||hr)return;let e=!1,r=null,n=null;const t=er.current,o={claim:async e=>{const r=await kr.current(()=>de.claim(me,t,e));if(r.ok)return{heartbeat_seconds:r.value.heartbeatSeconds};throw r.error},cancelled:()=>e,currentAccess:()=>Le.current,heldWrite:()=>({pending:null!=Be.current||ze(),autoSaveEnabled:!_e.current.paused,saveConflict:null!=Ae.current}),setAccess:e=>{Le.current=e,Ve(e)},releaseHeldWrite:()=>{gr.current()},startHeartbeat:e=>{r&&clearInterval(r),r=setInterval(()=>{u(!1)},e)},stopHeartbeat:()=>{r&&(clearInterval(r),r=null)},reloadIfMoved:()=>{pr.current()}},u=z.makeClaimBeat(o),a=tr.current;return tr.current=!1,a||(Ve({kind:"checking"}),n=setTimeout(()=>{n=null,h(o)&&o.startHeartbeat(y)},w)),u(a).finally(()=>{n&&clearTimeout(n),n=null}),()=>{e=!0,n&&clearTimeout(n),r&&clearInterval(r),de.release(me,t).catch(()=>{})}},[me,de,ce,se,rr,hr]);const yr=T(()=>{de&&me&&(tr.current=!0,nr(e=>e+1))},[me,de]),wr=T(()=>{Ve(e=>{const r="blocked"===e.kind||"takenover"===e.kind?e.holder:null;return r?{kind:"readonly",holder:r}:e})},[]),Sr=T(()=>{_e.current.paused?(k(Le.current)&&$e(),Ge()):xe()},[$e,xe,Ge]),br=T(()=>{Qe()},[Qe]),Ir=T(e=>{Oe.current=null,a("template"!==e.kind&&fe,{resetAutosave:()=>{Ke(),Be.current=null,Re(!1)},setVersion:e=>{He.current=e},setSaveConflict:Me,setAccess:Ve}),N(e),G(e),je.current=null,Pe(null),ge(null),ve(null),he(null),we(null),U.address.show(e),"document"!==e.kind&&W(e)&&U.send("storefront-editor:navigated",{target:e})},[Ke,U,fe,N,W]),Pr=T(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,ae.current,F))return;const r=null!=Be.current;if(!r&&!ze())return void Ir(e);const n=_e.current;r||n.paused||n.failed||n.stopped?Ee(e):Ye().then(r=>{r?Ir(e):Ee(e)})},[Ir,ze,Ye,F]),jr=T(()=>Ee(null),[]),Br=T(()=>{Ee(e=>(e&&Ir(e),null))},[Ir]),Tr=T(async()=>{const e=Ce;if(!e)return;await mr()&&(Ee(null),Ir(e))},[Ce,mr,Ir]),Rr=T(async e=>{if(null!==je.current)return;if(!me)return;if(!k(Le.current)||Ae.current)return;const r=oe(e);if(!await dr(me,r))return void(Ae.current||sr("storefront-editor:save-failed"));const n=ne.publish;if(!te.canPublish||!n)return void sr("storefront-editor:saved");const t=await lr(()=>n(me,He.current??void 0));t.ok?(He.current=t.value.version??He.current,sr("storefront-editor:published")):sr("storefront-editor:save-failed")},[me,ne,te.canPublish,sr,dr,lr,oe]);/* @__PURE__ */
2
+ return C(H.Provider,{value:{target:x,adapter:ne,capabilities:te,templateId:q,currentSlug:$,currentKind:ke,siteId:ee,ready:ce,token:se,tokenRef:ie,notifyParent:sr,bridgeCapabilities:le,runAuthed:cr,docId:me,data:pe,getLiveData:()=>Oe.current??pe,footerOriginSlug:ue,error:be,redirecting:or,saveStatus:qe,saveState:Ze,autoSaveEnabled:!Ze.paused,autoSaveStoppedByConflict:Ze.stopped,hasUnsavedEdits:Ze.pending||Te,toggleAutoSave:Sr,retrySave:br,onChange:fr,flushSave:mr,onPublish:Rr,access:Fe,readOnly:null!==S(Fe)||null!==Ie||null!==De,readOnlyReason:Ie,takeOverEditing:yr,viewReadOnly:wr,saveConflict:De,reloadFromServer:vr,navigate:Pr,pendingNav:Ce,cancelPendingNav:jr,discardAndNavigate:Br,saveAndNavigate:Tr},children:M})}export{H as ScreenDocumentContext,M as ScreenDocumentProvider,D as useScreenDocument};
@@ -0,0 +1 @@
1
+ import{find as t,remove as n,getList as e,newId as r,duplicate as o,move as a,copyNode as l,insert as c,setProps as d}from"./chunk-KRXQM65X.js";import{useRef as i,useSyncExternalStore as s,useCallback as p,useMemo as u}from"react";var f=t=>({kind:"node",id:t});function m(r,o,a,l="none"){const c=t(r,o,a),d=n(r,o,a);if("none"===l||!c)return{data:d,select:null};const i=e(r,o,c.place)??[],s=i[c.place.index+1]??i[c.place.index-1];return s?.props?.id?{data:d,select:f(s.props.id)}:"root"!==c.place.parentId?{data:d,select:f(c.place.parentId)}:{data:d,select:null}}function x(n,e,a,l={}){const c=t(n,e,a)?.node,d=l.id??r(c?.type??"Node");return{data:o(n,e,a,{strip:l.strip,id:d}),select:f(d)}}function I(t,n,e,r){return{data:a(t,n,e,r),select:f(e)}}var g=(t,n)=>({min:0,max:n-1});function v(n,r,o,a,l=g){const c=t(n,r,o);if(!c)return!1;const d=e(n,r,c.place)?.length??0,{min:i,max:s}=l(c.place,d),p=c.place.index+a;return c.place.index>=i&&c.place.index<=s&&p>=i&&p<=s}function b(n,e,r,o,a=g){if(!v(n,e,r,o,a))return null;const l=t(n,e,r);return I(n,e,r,{...l.place,index:l.place.index+o})}function h(t,n,e,r,o={}){const a=l(e,n,{strip:o.strip});return{data:c(t,n,r,a),select:f(a.props.id)}}function k(t,n,e,r){return{data:d(t,n,e,r),select:void 0}}function y(n,e,r,o=()=>!1){if(!r)return null;if("slot"===r.kind)return t(n,e,r.parentId)?f(r.parentId):null;const a=t(n,e,r.id);if(!a||"root"===a.place.parentId)return null;const l=t(n,e,a.place.parentId);return l?o(l.node,a.place.slot)?{kind:"slot",parentId:l.node.props.id,slot:a.place.slot}:f(l.node.props.id):null}function O(n,e,r){const o=t(n,e,r);return o?[...o.path.filter(t=>"root"!==t.parentId).map(t=>t.parentId),r]:[]}function z(t,n){if(0===t.length)return null;const e=null===n?-1:t.indexOf(n);return-1===e?t[0]:t[Math.min(e+1,t.length-1)]}function R(n,e,r){if(!r||"node"!==r.kind)return null;const o=t(n,e,r.id);return o?{zone:`${o.place.parentId}:${o.place.slot}`,index:o.place.index}:null}function B(t,n,r){if(!r)return null;const[o,a]=(r.zone??"root:default-zone").split(/:(.*)/s),l={parentId:o,slot:a},c=e(t,n,l)?.[r.index];return c?.props?.id?f(c.props.id):null}var M={get:()=>null,set:()=>{},subscribe:()=>()=>{}};function X(n){const e=i(n);e.current=n;const r=n.clipboard??M,o=s(r.subscribe,r.get,r.get),a=p(t=>{const n=e.current;if(n.readOnly)return!1;const r=t(n.data,n.config);return!!r&&((r.data!==n.data||void 0!==r.select)&&(n.commit(r.data,{select:r.select}),e.current={...n,data:r.data},!0))},[]);return u(()=>{const n=()=>e.current,r=(e,r)=>{const o=t(n().data,n().config,e);return o?{node:o.node,label:r,from:{parentId:o.place.parentId,slot:o.place.slot}}:null};return{held:o,remove:t=>a((e,r)=>m(e,r,t,n().afterRemove)),duplicate:t=>a((e,r)=>x(e,r,t,{strip:n().strip})),move:(t,n)=>a((e,r)=>I(e,r,t,n)),step:(t,e)=>a((r,o)=>b(r,o,t,e,n().stepBounds)),canStep:(t,e)=>v(n().data,n().config,t,e,n().stepBounds),setProps:(t,n)=>a((e,r)=>k(e,r,t,n)),copy:(t,e)=>{const o=r(t,e);return o&&(n().clipboard??M).set(o),!!o},cut:(t,e)=>{if(n().readOnly)return!1;const o=r(t,e);return!!o&&((n().clipboard??M).set(o),a((e,r)=>m(e,r,t,n().afterRemove)))},paste:t=>{const e=(n().clipboard??M).get();return!!e&&a((r,o)=>h(r,o,e.node,t,{strip:n().strip}))},parentOf:t=>y(n().data,n().config,t,n().slotIsLevel)}},[o,a])}export{v as canStep,B as fromItemSelector,z as nextInChain,O as nodeChain,y as parentStep,x as planDuplicate,I as planMove,h as planPaste,m as planRemove,k as planSetProps,b as planStep,R as toItemSelector,X as useNodeOps};
@@ -0,0 +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-BF3PIXZD.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};
@@ -0,0 +1 @@
1
+ var e={reload:"Reload the saved version",takeOver:"Take over editing",takeBack:"Take it back",viewReadOnly:"View read-only",savedByYou:({noun:e,when:n})=>`You saved this ${e} in another tab or window ${n}.`,savedByOther:({name:e,noun:n,when:i})=>`${e} saved this ${n} ${i}.`,conflictBody:"Your last change was not saved. It is still on screen here, but this copy is out of date — copy anything you need, then reload to carry on from the saved version.",takeOverWhileDeciding:"Nobody else can save while you decide. Nothing on your screen is lost.",tookOver:({name:e,noun:n,when:i})=>`${e} took over this ${n} ${i}.`,tookOverBody:"Your changes since then are still on screen but are no longer being saved.",viewingOnly:"Viewing only.",viewingOnlyBody:({name:e,noun:n,seen:i})=>`${e} is editing this ${n} (last seen ${i}). Nothing you change here is saved.`,editing:({name:e,noun:n})=>`${e} is editing this ${n}`,editingBody:({seen:e})=>`(last seen ${e}). Nothing you change here will be saved while they are in it.`,takeOverTold:"They are told straight away and stop being able to save."},n={device:"Preview device",upLevel:"Go up one level",upLevelTo:({label:e,name:n})=>`${e} to ${n}`,resize:"Drag to resize · double-click to reset",mediaLibrary:"Media library",mediaChoose:({kind:e})=>`Choose ${e}`,mediaFor:({field:e})=>`For ${e}`,mediaKinds:{image:"image",video:"video",svg:"SVG logo"},mediaCancel:"Cancel",mediaKeep:({kind:e})=>`Keep the current ${e}`,hidePanel:"Hide panel",hidePanelLabel:({side:e})=>`Hide the ${e} panel`,showPanel:"Show panel",showPanelLabel:({side:e})=>`Show the ${e} panel`};export{n as DEFAULT_CHROME_WORDS,e as DEFAULT_NOTICE_WORDS};
@@ -1,4 +1,4 @@
1
- import{useScreenOwnerName as e}from"./chunk-5TRBCPRB.js";import{settlePanelPick as n}from"./chunk-R6WTQWAC.js";import{MediaPanelHead as i,mediaPickKind as c}from"./chunk-OXYGFK2B.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-55IKQFBW.js";import{settlePanelPick as n}from"./chunk-R6WTQWAC.js";import{MediaPanelHead as i,mediaPickKind as c}from"./chunk-GTDLBUOC.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};
@@ -177,45 +177,15 @@
177
177
  /* — the link button's window (blueprint 4.9) — */
178
178
 
179
179
  /*
180
- * Under the box, in its flow: a settings panel scrolls, and a floating window
181
- * is clipped by the edge it scrolls under (the colour window's rule). Drawn on
182
- * the panel's own raised surface, so it reads as part of this field.
180
+ * The window is efficient-shell's `LinkPicker` (window mode): its frame, its
181
+ * boxes, its refusal and its buttons are the kit's, never redrawn here. This
182
+ * only places it: under the classic bar it sits in the box's flow (a settings
183
+ * panel scrolls, and a floating window is clipped by the edge it scrolls
184
+ * under — the colour window's rule); under the final toolbar it floats
185
+ * (`.es-copy-pop`, below).
183
186
  */
184
187
  .es-copy-link {
185
- display: flex;
186
- flex-direction: column;
187
- gap: 8px;
188
188
  margin-top: var(--es-copy-gap);
189
- padding: 12px;
190
- border: 1px solid var(--es-copy-rule);
191
- border-radius: var(--es-row-radius, var(--radius-lg));
192
- background: var(--es-raised, var(--es-copy-field-bg));
193
- box-shadow: var(--es-raised-shadow, var(--rosh-glass-solid-shadow));
194
- }
195
-
196
- /* The window's parts are the shell's Label, Input and Buttons (UI-24): their
197
- look is the kit's, never redrawn here. */
198
-
199
- .es-copy-link-why {
200
- margin: 0;
201
- font-size: 11px;
202
- line-height: 1.45;
203
- color: var(--es-danger, var(--status-danger-soft-ink));
204
- }
205
-
206
- .es-copy-link-actions {
207
- display: flex;
208
- align-items: center;
209
- justify-content: space-between;
210
- gap: 8px;
211
- }
212
-
213
- /* Cancel and Apply sit together at the end; Remove, when there is a link to
214
- take off, at the start (the design's footer). */
215
- .es-copy-link-end {
216
- display: flex;
217
- gap: var(--es-space-4, 4px);
218
- margin-left: auto;
219
189
  }
220
190
 
221
191
  /* — the rich view (0.95.0, rulings B + C) — */
@@ -378,25 +348,17 @@
378
348
 
379
349
  /*
380
350
  * CLEAR STYLE (owner ruling 2026-10-07, mockup
381
- * https://claude.ai/artifact/GiyeV3xazepzArKGVkFM8T): a quiet text button at
382
- * the right end of the line under the box — beside Show marks, or alone under
383
- * a one-line box (GG, 2026-10-07) — with the clear-marks glyph. Grey and
384
- * not pressable until words are selected in the box.
351
+ * https://claude.ai/artifact/GiyeV3xazepzArKGVkFM8T): a text button at the
352
+ * right end of the line under the box — beside Show marks, or alone under a
353
+ * one-line box (GG, 2026-10-07) — with the clear-marks glyph. Off until words
354
+ * are selected in the box.
355
+ *
356
+ * It is the shell's secondary Button, small (Lewis 2026-10-13: ghost is for
357
+ * toolbars and rows of icons; a lone text button is secondary; UI-24). The
358
+ * shell owns its look; this sheet only places it on the line.
385
359
  */
386
360
  .es-copy-clear {
387
361
  margin-left: auto;
388
- display: inline-flex;
389
- align-items: center;
390
- gap: var(--es-space-4, 4px);
391
- padding: var(--es-space-4, 4px) var(--es-space-8, 8px);
392
- border: 0;
393
- border-radius: var(--radius-md);
394
- background: transparent;
395
- font: inherit;
396
- font-size: 13px;
397
- white-space: nowrap;
398
- color: var(--es-text-secondary, var(--ink));
399
- cursor: pointer;
400
362
  }
401
363
 
402
364
  /* Off, it explains itself in the shell's Tooltip, whose wrapper is then the
@@ -405,33 +367,18 @@
405
367
  margin-left: auto;
406
368
  }
407
369
 
408
- .es-copy-clear svg {
409
- flex: none;
410
- width: 16px;
411
- height: 16px;
412
- }
413
-
414
- .es-copy-clear:hover:not(:disabled) {
415
- background: var(--es-hover, var(--surface-raised));
416
- }
417
-
418
- .es-copy-clear:focus-visible {
419
- outline: none;
420
- box-shadow: var(--es-copy-focus-ring);
421
- }
422
-
423
- .es-copy-clear:disabled {
424
- color: var(--es-disabled, var(--ink-faintest));
425
- cursor: default;
426
- }
427
-
428
370
  /* — the final toolbar (E5b, design final 2026-10-06) — */
429
371
 
430
372
  /*
431
- * TWO ROWS ON ONE 9-COLUMN GRID, flush to the box at both ends: every button
432
- * sits under the one above it. The size is react-os-shell's IconButton md
433
- * (`--es-copy-mark-size`, 32px), the size the design draws in a 320px panel.
434
- * A cell the host does not offer is drawn EMPTY, so the columns still line up.
373
+ * TWO ROWS ON ONE 9-COLUMN GRID, flush to the box at both ends: in two full
374
+ * rows every button sits under the one above it. The size is react-os-shell's
375
+ * IconButton md (`--es-copy-mark-size`, 32px), the size the design draws in a
376
+ * 320px panel.
377
+ *
378
+ * NO BLANK CELLS (Lewis 2026-10-13): a tool the host does not offer is not
379
+ * drawn. The row keeps its explicit tracks, so the tools it has fill the first
380
+ * tracks: packed from the row's start, at a full row's size and gap, never
381
+ * stretched to the far end. A row with no tool is not drawn (TextToolbar).
435
382
  */
436
383
  .es-tb-wrap {
437
384
  /*
@@ -471,6 +418,51 @@
471
418
  --es-tb-steps: 7;
472
419
  }
473
420
 
421
+ /*
422
+ * ONE ROW (Lewis 2026-10-13, on the phone paragraph: "can't they go up?").
423
+ * When the word tools, one gap cell and the paragraph tools fit the nine
424
+ * cells (TextToolbar's `toolbarRows`), both groups share ONE row: the words,
425
+ * then the group gap, then the paragraph tools. The gap is the toolbar gap
426
+ * token (8px, the 2026-10-12 spacing roles), owned by the row (UI-23). Inside
427
+ * each group the buttons keep the nine-cell grid's size and pitch, packed
428
+ * from the start, never stretched to the far end. The windows' points use
429
+ * that pitch: eight steps across nine cells.
430
+ */
431
+ .es-tb-row.is-one-row {
432
+ display: flex;
433
+ justify-content: flex-start;
434
+ column-gap: var(--es-space-8, 8px);
435
+ }
436
+
437
+ .es-tb-words,
438
+ .es-tb-para {
439
+ display: flex;
440
+ column-gap: calc((100cqw - 9 * var(--es-tb-size)) / 8);
441
+ }
442
+
443
+ .es-tb-wrap.is-one-row {
444
+ --es-tb-steps: 8;
445
+ }
446
+
447
+ /*
448
+ * FLOW-FILL (Lewis 2026-10-13: "If there is a second row, the first row must
449
+ * not leave blank space"; "The second row does not need to be filled. Just
450
+ * let it run in natural order."). When the tools do not fit one row, the
451
+ * toolbar is ONE grid of nine cells a line: the word tools, one cell for the
452
+ * group gap (`.es-tb-flowgap`), then the paragraph tools. Line 1 is always
453
+ * nine cells, flush to the box at both ends; the rest run on in line 2 from
454
+ * its start, in the same nine tracks, so at the normal pitch and never
455
+ * spread. The lines are the toolbar's 4px apart. The windows' points use the
456
+ * nine-cell pitch.
457
+ */
458
+ .es-tb-row.is-flow {
459
+ row-gap: var(--es-space-4, 4px);
460
+ }
461
+
462
+ .es-tb-wrap.is-flow {
463
+ --es-tb-steps: 8;
464
+ }
465
+
474
466
  /* The alignment and case groups are radiogroups for a screen reader and
475
467
  nothing for the grid: their buttons are cells of the row. */
476
468
  .es-tb-group {
@@ -492,9 +484,11 @@
492
484
  height: 16px;
493
485
  }
494
486
 
495
- /* The bar under the A is the colour the selected words wear. */
496
- .es-tb-color svg rect {
497
- fill: var(--es-tb-run, currentColor);
487
+ /* The letter A is filled with the colour the selected words wear: the
488
+ glyph's `data-part="swatch"` (efficient-shell 7.4.0, #414). No fallback:
489
+ with no colour the A stays hollow, so "no colour" is not black. */
490
+ .es-tb-color [data-part="swatch"] {
491
+ fill: var(--es-tb-run);
498
492
  }
499
493
 
500
494
  /*
@@ -544,7 +538,10 @@
544
538
  }
545
539
 
546
540
  /* The point, aimed at its button: column k of row 1 across the box (100cqw),
547
- whose cells are `--es-tb-steps` + 1 (nine, or eight with no host control). */
541
+ whose cells are `--es-tb-steps` + 1 (nine, or eight with no host control).
542
+ Row 1 draws only what the host offers, so k is the button's column as
543
+ drawn: CopyBox writes `--es-tb-color-col` and `--es-tb-link-col` on the
544
+ wrapper (TextToolbar's `windowColumns`), never a fixed 4 or 5. */
548
545
  .es-copy-pop::before {
549
546
  content: '';
550
547
  position: absolute;
@@ -559,11 +556,11 @@
559
556
 
560
557
  /* Aimed at the words (measured), or — unmeasured — at its button, as above. */
561
558
  .es-copy-colors::before {
562
- left: var(--es-pop-point, calc(4 * (100cqw - var(--es-tb-size)) / var(--es-tb-steps) + var(--es-tb-size) / 2 - 6px));
559
+ left: var(--es-pop-point, calc(var(--es-tb-color-col) * (100cqw - var(--es-tb-size)) / var(--es-tb-steps) + var(--es-tb-size) / 2 - 6px));
563
560
  }
564
561
 
565
562
  .es-copy-link.es-copy-pop::before {
566
- left: var(--es-pop-point, calc(5 * (100cqw - var(--es-tb-size)) / var(--es-tb-steps) + var(--es-tb-size) / 2 - 6px));
563
+ left: var(--es-pop-point, calc(var(--es-tb-link-col) * (100cqw - var(--es-tb-size)) / var(--es-tb-steps) + var(--es-tb-size) / 2 - 6px));
567
564
  }
568
565
 
569
566
  /* Opened above the words: the point is on the bottom edge, aimed down. */
@@ -1,8 +1,8 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
3
  import { MarkStyle, MarkupTool, WrapResult, InlineRule, MarkedLine } from '../markup/index.js';
4
- import { C as CopyWords, a as CopyAlign } from '../words-XH0TvZPg.js';
5
- export { b as COPY_ALIGNS, c as COPY_ALIGN_FIT, d as COPY_ALIGN_GLYPHS, e as COPY_ALIGN_LABELS, f as copyAlignOptions } from '../words-XH0TvZPg.js';
4
+ import { C as CopyWords, a as CopyAlign } from '../words-lpvYzf5U.js';
5
+ export { b as COPY_ALIGNS, c as COPY_ALIGN_FIT, d as COPY_ALIGN_GLYPHS, e as COPY_ALIGN_LABELS, f as copyAlignOptions } from '../words-lpvYzf5U.js';
6
6
 
7
7
  type CellWords = NonNullable<CopyWords['cells']>;
8
8
  interface CopyCell {
@@ -74,7 +74,7 @@ interface TextToolbarProps {
74
74
  /** The marks the selection wears (or a pending press set). */
75
75
  pressed: Partial<Record<string, boolean>>;
76
76
  onMark: (style: ToolbarMark) => void;
77
- /** The colour button, when the host hands colours. `run` paints the bar under the A. */
77
+ /** The colour button, when the host hands colours. `run` fills the A (the glyph's `data-part="swatch"`). */
78
78
  color?: {
79
79
  run?: string;
80
80
  open: boolean;
@@ -103,7 +103,7 @@ interface TextToolbarProps {
103
103
  disabled?: boolean;
104
104
  ariaLabel?: string;
105
105
  }
106
- declare function TextToolbar({ words, align: alignWords, alignmentLabel, offered, pressed, onMark, color, linkOpen, last, alignment, list, letterCase, disabled, ariaLabel, }: TextToolbarProps): react.JSX.Element;
106
+ declare function TextToolbar({ words, align: alignWords, alignmentLabel, offered, pressed, onMark, color, linkOpen, last, alignment, list, letterCase, disabled, ariaLabel, }: TextToolbarProps): react.JSX.Element | null;
107
107
 
108
108
  /** `'b'` → `Meta+B`, `'shift+x'` → `Meta+Shift+X` — the ARIA spelling of a
109
109
  * shortcut. Meta is what the tooltips promise (⌘); Ctrl works too. */
@@ -403,7 +403,7 @@ interface CopyBoxProps {
403
403
  * saved in `[words]{color=name}`, what it is called, and its value. The box
404
404
  * paints a coloured word with the value (`--es-color-<name>`). The window
405
405
  * also offers Any color, saved as a hex (`[words]{color=#rrggbb}`). No colours:
406
- * no colour button — its cell stays, empty.
406
+ * no colour button, and no blank where it was (Lewis 2026-10-13).
407
407
  */
408
408
  colors?: readonly CopyThemeColor[];
409
409
  /** The number cells between the toolbar and the box (final toolbar), each
@@ -412,7 +412,8 @@ interface CopyBoxProps {
412
412
  /**
413
413
  * The host's letter-case field, set by Aa · AA · aa (final toolbar). The
414
414
  * lit one pressed again writes `''`: no case of its own, the style decides.
415
- * Left out: the three cells stay, empty.
415
+ * Left out: no case buttons, and no blanks where they were (Lewis
416
+ * 2026-10-13). A row with no tool at all is not drawn.
416
417
  */
417
418
  letterCase?: {
418
419
  value: CopyCase | '';
@@ -422,7 +423,8 @@ interface CopyBoxProps {
422
423
  /**
423
424
  * Row 1's 9th cell of the final toolbar, drawn by the host (owner ruling
424
425
  * 2026-10-07: Undo left that cell). Return one control; it is placed in the
425
- * cell as given. Left out, row 1 is eight buttons spread over the row. See
426
+ * cell as given; one that draws nothing (`null`) leaves no blank. Left
427
+ * out, row 1 is eight buttons spread over the row. See
426
428
  * {@link CopyBoxLastTool}.
427
429
  */
428
430
  lastTool?: (slot: CopyBoxLastTool) => ReactNode;