efficient-easel 14.1.0 → 15.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 (85) hide show
  1. package/README.md +0 -1
  2. package/dist/{CanvasDragLayer-CLb7j-CZ.d.ts → CanvasDragLayer-dZCPbQCP.d.ts} +1 -1
  3. package/dist/canvas/index.d.ts +21 -1
  4. package/dist/canvas/index.js +1 -1
  5. package/dist/{chunk-NY7HHUGB.js → chunk-23VM4PMV.js} +2 -2
  6. package/dist/{chunk-IWFVVCRN.js → chunk-2H3W5OLQ.js} +1 -1
  7. package/dist/chunk-5EPK5WB3.js +1 -0
  8. package/dist/{chunk-CSGTPJTY.js → chunk-EHBWUEEE.js} +4 -4
  9. package/dist/chunk-FRXE6EQN.js +5 -0
  10. package/dist/{chunk-F3A7SXSV.js → chunk-GOABCALQ.js} +1 -1
  11. package/dist/{chunk-44QA42OJ.js → chunk-GS44HQ45.js} +1 -1
  12. package/dist/{chunk-CY52PUMZ.js → chunk-HM7S7H5H.js} +1 -1
  13. package/dist/chunk-JASNL4KG.js +7 -0
  14. package/dist/{chunk-AYWN5NRH.js → chunk-KAML3KQH.js} +1 -1
  15. package/dist/chunk-OFBZOI6W.js +1 -0
  16. package/dist/{chunk-TR4APEJZ.js → chunk-OJ6QWOLG.js} +1 -1
  17. package/dist/chunk-POSLNRTO.js +18 -0
  18. package/dist/chunk-QKZPPI5O.js +57 -0
  19. package/dist/chunk-SMM3ST7A.js +13 -0
  20. package/dist/chunk-U6LJ5UKD.js +6 -0
  21. package/dist/chunk-VJZDNOQ7.js +1 -0
  22. package/dist/chunk-X4T6JT3M.js +1 -0
  23. package/dist/{chunk-YKJ3RIMT.js → chunk-YQVR54RE.js} +1 -1
  24. package/dist/{chunk-CMXK3JT3.js → chunk-Z62Z75UI.js} +1 -1
  25. package/dist/{chunk-FBS75I6E.js → chunk-ZZ64CEC2.js} +2 -2
  26. package/dist/copy/copy.css +9 -9
  27. package/dist/copy/index.d.ts +2 -29
  28. package/dist/copy/index.js +12 -13
  29. package/dist/drag/drag.css +22 -0
  30. package/dist/drag/index.d.ts +2 -2
  31. package/dist/drag/index.js +1 -1
  32. package/dist/easel/easel.css +26 -0
  33. package/dist/easel/index.js +1 -1
  34. package/dist/{host-GOlVK3LX.d.ts → host-DGmdCaNL.d.ts} +10 -1
  35. package/dist/pick/index.d.ts +5 -70
  36. package/dist/pick/index.js +1 -3
  37. package/dist/pick/pick.css +1 -21
  38. package/dist/screen/components/AddBlockRow.js +1 -1
  39. package/dist/screen/components/AddSidePanel.js +1 -1
  40. package/dist/screen/components/MediaSidePanel.d.ts +1 -1
  41. package/dist/screen/components/MediaSidePanel.js +1 -1
  42. package/dist/screen/components/NodeContextMenu.d.ts +4 -4
  43. package/dist/screen/components/NodeContextMenu.js +1 -1
  44. package/dist/screen/components/PageEditGuardNotices.js +1 -1
  45. package/dist/screen/components/SaveControls.d.ts +3 -3
  46. package/dist/screen/components/ScreenChrome.js +1 -1
  47. package/dist/screen/components/ScreenDocumentContext.d.ts +1 -1
  48. package/dist/screen/components/ScreenDocumentContext.js +1 -1
  49. package/dist/screen/components/ScreenMount.d.ts +3 -3
  50. package/dist/screen/components/ScreenMount.js +1 -1
  51. package/dist/screen/components/ScreenStoreProvider.d.ts +3 -3
  52. package/dist/screen/components/ScreenStoreProvider.js +1 -1
  53. package/dist/screen/components/SectionScreenShell.js +16 -16
  54. package/dist/screen/components/usePartBridge.d.ts +3 -3
  55. package/dist/screen/components/usePartBridge.js +1 -1
  56. package/dist/screen/index.d.ts +3 -3
  57. package/dist/screen/index.js +1 -1
  58. package/dist/screen/lib/document-addressing.d.ts +1 -1
  59. package/dist/screen/lib/host.d.ts +1 -1
  60. package/dist/screen/lib/key-scope.js +1 -1
  61. package/dist/screen/lib/media-panel.d.ts +1 -1
  62. package/dist/screen/lib/media-picker.d.ts +1 -1
  63. package/dist/screen/lib/puck/style-clipboard.d.ts +3 -3
  64. package/dist/screen/lib/puck/style-clipboard.js +1 -1
  65. package/dist/screen/lib/puck/use-section-ops.js +1 -1
  66. package/dist/screen/lib/screen-parts.d.ts +3 -3
  67. package/dist/screen/lib/screen-parts.js +1 -1
  68. package/dist/strings/catalogue.d.ts +2 -2
  69. package/dist/strings/catalogue.js +1 -1
  70. package/dist/strings/index.d.ts +2 -2
  71. package/dist/strings/index.js +1 -1
  72. package/dist/text-styles/index.js +36 -36
  73. package/dist/{words-BDignMl_.d.ts → words-CvwYvkJm.d.ts} +2 -0
  74. package/dist/{words-is_Vy6hn.d.ts → words-DWvCJXwR.d.ts} +2 -37
  75. package/package.json +3 -3
  76. package/dist/chunk-3DCI44F3.js +0 -7
  77. package/dist/chunk-5XUMLKQF.js +0 -6
  78. package/dist/chunk-643PVCEG.js +0 -1
  79. package/dist/chunk-D46OYLJR.js +0 -5
  80. package/dist/chunk-F6NO7B57.js +0 -57
  81. package/dist/chunk-ILXP5VX5.js +0 -1
  82. package/dist/chunk-LPM2SCM4.js +0 -13
  83. package/dist/chunk-NW4LJ4G4.js +0 -1
  84. package/dist/chunk-QFVRMARS.js +0 -18
  85. package/dist/chunk-XGW6NWLC.js +0 -1
@@ -0,0 +1,13 @@
1
+ import{DEFAULT_CANVAS_WORDS as e}from"./chunk-TBY3DFKS.js";import{toItemSelector as t,fromItemSelector as n,useNodeOps as o,parentStep as r,clickPick as i}from"./chunk-ECM5F6JJ.js";import{useResolvedFields as l}from"./chunk-YRLPFZW3.js";import{selectionBox as s,placeWindow as a,offsetOrigin as c,colorRunOf as d,ColorWindow as u,startCanvasTyping as p,textMap as f}from"./chunk-23VM4PMV.js";import{DEFAULT_COPY_WORDS as h}from"./chunk-B4JN227A.js";import{useWords as m}from"./chunk-MFIRYGHW.js";import{setCanvasNonce as g,CANVAS_TYPABLE_EVENT as v,isTypingTarget as y,frameRectToHost as w,CANVAS_TYPING_EVENT as b,drawnBox as k}from"./chunk-X4T6JT3M.js";import{find as S,ROOT_ID as C,getList as I,remove as E,parseZoneKey as D,move as x,duplicate as M,replaceNode as A,createNode as O,insert as z,normalizeData as R,createResolveCache as P,resolveNodeData as V,ROOT_SLOT as B}from"./chunk-KRXQM65X.js";import{topLevelSlotKeys as N,fieldsFrom as $,defaultsFrom as L}from"./chunk-NKB3KVAB.js";import{createContext as K,useEffect as j,useContext as Z,useRef as F,useSyncExternalStore as T,useState as H,useMemo as W,useCallback as q,useLayoutEffect as Y}from"react";import{jsx as J,jsxs as X,Fragment as U}from"react/jsx-runtime";import{createPortal as G}from"react-dom";import{registerModalEscapeInterceptor as Q,FloatingBar as _,TextToolbar as ee,LinkPicker as te}from"efficient-shell/ui";function ne(e){return!["setData","setUi","set"].includes(e.type)}var oe=(e,t,n,o)=>{const r=I(e,t,D(n));return r?.[o]??null},re=(e,t,n,o,r)=>{const i=oe(e,t,n,o);if(!i)throw new Error(`${r}: nothing at ${n}[${o}]`);return i};function ie(e,n){const{selection:o}=e;return{...e.ui,itemSelector:t(e.data,n,o),selectedSlot:o&&"slot"===o.kind?{parentId:o.parentId,slot:o.slot}:null}}function le(e,t,n){return n?"node"===n.kind?S(e,t,n.id)?n:null:n.parentId===C?I(e,t,n)?n:null:S(e,t,n.parentId)&&I(e,t,n)?n:null:null}function se(e,t,o,r=!1){const{itemSelector:i,selectedSlot:l,...s}=o;let a=e.selection;var c;return"itemSelector"in o&&(a=n(e.data,t,i??null)),"selectedSlot"in o&&(l?a=(c=l)?{kind:"slot",parentId:c.parentId,slot:c.slot}:null:"slot"===a?.kind&&(a=null)),{...e,selection:a,ui:r?s:{...e.ui,...s}}}function ae(e,t,n){const o=ce(e,t,n);if(o===e)return e;const r=le(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function ce(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 se(e,n,"function"==typeof t.ui?t.ui(ie(e,n)):t.ui);case"set":{const r={data:o,ui:ie(e,n)},i="function"==typeof t.state?t.state(r):t.state;let l=i.data?{...e,data:i.data}:e;return i.ui&&(l=se(l,n,i.ui,!0)),l}case"insert":{const r={...D(t.destinationZone),index:t.destinationIndex},i=O(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:z(o,n,r,i)}}case"replace":{const r=re(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:A(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=re(o,n,t.sourceZone,t.sourceIndex,"duplicate"),i=M(o,n,r.props.id),l=oe(i,n,t.sourceZone,t.sourceIndex+1);return{...e,data:i,selection:l?{kind:"node",id:l.props.id}:e.selection}}case"reorder":return ce(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=oe(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const i={...D(t.destinationZone),index:t.destinationIndex};return{...e,data:x(o,n,r.props.id,i)}}case"remove":{const r=re(o,n,t.zone,t.index,"remove");return{...e,data:E(o,n,r.props.id)}}default:return e}}var de={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},ue={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},pe=0,fe=()=>`history-${pe+=1}`;function he(e){let o=e.config;const r=e.now??(()=>Date.now()),i=e.historyCoalesceMs??250;let l=e.permissions??{};const s=R(e.data,o);let a={data:s,selection:null,ui:{...ue}};if(e.ui){const{itemSelector:t,selectedSlot:r,...i}=e.ui;a={data:s,selection:r?{kind:"slot",...r}:n(s,o,t??null),ui:{...ue,...i}}}let c=[{core:a,at:-1/0,sealed:!0,id:fe()}],d=0;const u=e=>{const t=c[d],n=r();!e&&d===c.length-1&&d>0&&!t.sealed&&n-t.at<i?c=[...c.slice(0,d),{...t,core:a,at:n}]:(c=[...c.slice(0,d+1),{core:a,at:n,sealed:e,id:fe()}],d=c.length-1)},p=/* @__PURE__ */new Set;let f=null,h=null,m=0,g=null,v=!1;const y=()=>{for(const e of[...p])e()},w=()=>{c=[...c.slice(0,d),{...c[d],core:a},...c.slice(d+1)]},b=(t,n)=>{m>0?v=v||n:(n?u(!1):a!==t&&w(),a.data!==t.data&&e.onChange?.(a.data),a!==t&&y())},k=e=>{const t=a;if(a=ae(a,e,o),a===t)return;const n=e.recordHistory??ne(e);b(t,n&&a.data!==t.data)},C=t=>{0===m&&(g=a,v=!1),m+=1;try{t()}catch(e){throw m-=1,0===m&&g&&(a=g,g=null),e}if(m-=1,m>0||!g)return;const n=g;g=null,v&&a.data!==n.data?u(!0):a!==n&&w(),a.data!==n.data&&e.onChange?.(a.data),a!==n&&y()},E=e=>{const t=a,n=le(a.data,o,e);var r,i;(r=n,i=a.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))||(a={...a,selection:n},b(t,!1))},D=t=>{const n=a;d=t,a=c[d].core,a.data!==n.data&&e.onChange?.(a.data),a!==n&&y()},x=()=>(e={})=>{const t=e.root?o.root?.permissions:o.components[e.item?.type??e.type??""]?.permissions;return{...de,...l,...t}};let M=x();const O=P(),z={resolveCache:O,async resolveAll({trigger:e="load",metadata:t}={}){const n=a.data,r={type:"root",props:{...n.root.props??{}}},i=[...n.content,...Object.values(n.zones??{}).flat()],[l,...s]=await Promise.all([V(r,o,{cache:O,trigger:e,metadata:t}),...i.map(n=>V(n,o,{cache:O,trigger:e,metadata:t}))]);C(()=>{const e=a;let t=a.data;s.forEach((e,r)=>{if(!e.didChange)return;const l=i[r].props.id,s=S(t,o,l)?.node;s&&s===S(n,o,l)?.node&&(t=A(t,o,l,e.node))}),l.didChange&&t.root===n.root&&(t={...t,root:{...t.root,props:l.node.props,readOnly:l.node.readOnly??t.root.readOnly}}),t!==a.data&&(a={...a,data:t,selection:le(t,o,a.selection)},b(e,!1))})},async resolveNode(e,{trigger:t="replace",metadata:n}={}){const r=S(a.data,o,e)?.node;if(!r)return!1;const i=await V(r,o,{cache:O,trigger:t,metadata:n});if(!i.didChange)return!1;let l=!1;return C(()=>{const t=a;if(S(a.data,o,e)?.node!==r)return;const n=A(a.data,o,e,i.node);n!==a.data&&(a={...a,data:n,selection:le(n,o,a.selection)},b(t,!1),l=!0)}),l},get config(){return o},getState(){if(f&&h===a)return f;const e=a,n={data:e.data,ui:ie(e,o)},r="node"===e.selection?.kind?S(e.data,o,e.selection.id)?.node??null:null;return f={appState:n,selection:e.selection,selectedItem:r,config:o,dispatch:k,history:{back:()=>z.undo(),forward:()=>z.redo(),hasPast:d>0,hasFuture:d<c.length-1,histories:c.map(e=>({id:e.id,state:{data:e.core.data,ui:ie(e.core,o)}})),index:d,setHistoryIndex:e=>{e>=0&&e<c.length&&e!==d&&D(e)}},getPermissions:M,getItemById:t=>S(e.data,o,t)?.node,getItemBySelector:t=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return I(e,t,{parentId:o,slot:r})?.[n.index]}(e.data,o,t),getSelectorForId:n=>{const r=t(e.data,o,{kind:"node",id:n});return r?{index:r.index,zone:r.zone??"root:default-zone"}:void 0}},h=e,f},subscribe:e=>(p.add(e),()=>{p.delete(e)}),dispatch:k,batch:C,group:()=>{const e=d,t=c[e].id;let n=!0;return{close:()=>{if(!n)return;if(n=!1,c[e]?.id!==t)return;if(d<=e+1)return void(d===e+1&&(c=[...c.slice(0,d),{...c[d],sealed:!0},...c.slice(d+1)]));const o=c[d];c=[...c.slice(0,e+1),{...o,sealed:!0},...c.slice(d+1)],d=e+1}}},select:e=>E(e?{kind:"node",id:e}:null),selectSlot:e=>E(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){C(()=>{const t=a,n=void 0===e.select?a.selection:e.select;a={...a,data:e.data,selection:le(e.data,o,n)},b(t,e.data!==t.data)})},load(e,t={}){const n=a,r=R(e,o);a={...a,data:r,selection:le(r,o,t.selection??a.selection)},t.keepHistory||(c=[{core:a,at:-1/0,sealed:!0,id:fe()}],d=0),a!==n&&y()},undo(){d>0&&D(d-1)},redo(){d<c.length-1&&D(d+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,l)||(l=e,M=x(),f=null,y())},setConfig(e){e!==o&&(o=e,M=x(),f=null,y())}};return z}function me(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&&y(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 ge=K(null),ve=K(!0);function ye({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return j(()=>{n&&e.resolveAll()},[e,n]),j(()=>{if(t&&"undefined"!=typeof document)return me(document,e)},[e,t]),/* @__PURE__ */J(ge.Provider,{value:e,children:/* @__PURE__ */J(ve.Provider,{value:t,children:o})})}function we(){const e=Z(ge);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function be(e){const t=we(),n=F({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 T(t.subscribe,o,o)}function ke(){return function(e){return be(e)}}var Se="data-puck-component",Ce="data-puck-dropzone",Ie={},Ee="data-es-mirror",De="undefined"==typeof window?j:Y;function xe(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${Ee}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(Ee,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function Me({children:t,id:n="preview-frame",title:o,className:r,style:i,mirrorStyles:l=!0,onDocument:s,height:a="auto",nonce:c}){const d=m("canvas",e),u=F(null),[p,f]=H(null);return De(()=>{const e=u.current,t=p?.ownerDocument.defaultView;if("auto"!==a||!e||!p||!t)return;const n=()=>{e.style.height=`${Math.ceil(p.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(p),()=>r?.disconnect()},[p,a]),De(()=>{let e=u.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=u.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"===a&&t.classList.add("es-frame-fill"),e.body.appendChild(t),g(e,c),f(t),s?.(e);let n=null;const o=u.current?.ownerDocument;if(l&&o){xe(o,e,c);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>xe(o,e,c)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}return()=>{n?.disconnect(),t.remove(),f(null),s?.(null)}},[]),/* @__PURE__ */J("iframe",{ref:u,id:n,title:o??d.frame,className:["es-canvas-frame","fill"===a?"is-fill":"",r??""].filter(Boolean).join(" "),style:i,children:p?G(t,p):null})}var Ae=K(null),Oe=K(Ie),ze=[];function Re({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:i=120}){const l=we(),s=be(n=>I(n.appState.data,l.config,{parentId:e,slot:t})??ze),a=be(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==C),c=be(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),d=Z(Ae),u=["es-zone"];return s.length&&u.push("has-children"),e===C&&u.push("is-root"),(a||c)&&u.push("is-area-selected"),null!==d&&d===e&&e!==C&&u.push("is-hovering-area"),n&&u.push(n),/* @__PURE__ */J("div",{className:u.join(" "),[Ce]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${i}px`},children:s.map(e=>/* @__PURE__ */J(je,{node:e},e.props.id))})}function Pe(e,t){return W(()=>{const n={};for(const o of N($(e)))n[o]=function(e={}){/* @__PURE__ */
2
+ return J(Re,{parentId:t,slot:o,...e})};return n},[e,t])}function Ve(e){return W(()=>function({zone:t,...n}){/* @__PURE__ */
3
+ return J(Re,{parentId:e,slot:t,...n})},[e])}var Be=["top","bottom","zIndex"];function Ne(e,t,n){e.style[t]!==n&&(e.style[t]=n)}function $e(e){const t=function(e){const t=e?.ownerDocument.defaultView?.getComputedStyle(e);if(!t||"sticky"!==t.position)return null;const n=e=>"auto"===e?"":e;return{top:n(t.top),bottom:n(t.bottom),zIndex:n(t.zIndex)}}(function(e){const t=e.ownerDocument.defaultView;let n=null;for(const o of Array.from(e.children))if("none"!==t?.getComputedStyle(o).display){if(n)return null;n=o}return n}(e));Ne(e,"position",t?"sticky":"relative");for(const n of Be)Ne(e,n,t?.[n]??"");return!!t}var Le="data-es-canvas-relative";function Ke(e){e.hasAttribute(Le)&&("relative"===e.style.position&&(e.style.position=""),e.removeAttribute(Le));const t=e.ownerDocument.defaultView?.getComputedStyle(e).position;return t&&"static"!==t?"sticky"===t:(e.style.position||(e.style.position="relative",e.setAttribute(Le,"")),!1)}function je({node:e}){const t=we().config.components[e.type],n=e.props.id,o=F(null),r=function(e,t){return W(()=>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),Ke(n))},[e,t])}(n,o),i=F(null),l=!!t?.inline;!function(e,t){const n=F(!1),o=F(()=>{});o.current=()=>{const o=e(),i=n.current;n.current=!!o&&t(o),i!==n.current&&r.current()};const r=F(()=>{});De(()=>o.current()),De(()=>{const t=e(),i=t?.ownerDocument.defaultView;if(!t||!i)return;const l=()=>o.current();i.addEventListener("resize",l);const s=i.ResizeObserver,a=s?new s(l):null;a?.observe(t);let c=null;return r.current=()=>{c?.disconnect(),c=null;const e=t.ownerDocument.documentElement;n.current&&e&&i.MutationObserver&&(c=new i.MutationObserver(l),c.observe(e,{attributes:!0}))},r.current(),()=>{i.removeEventListener("resize",l),a?.disconnect(),c?.disconnect(),r.current=()=>{}}},[])}(()=>l?o.current:i.current,e=>l?Ke(e):$e(e));const s=Z(Oe),a=Pe(t,n),c=Ve(n);if(!t?.render)return null;const d=t.render,u={...L(t),...e.props,...a},p={renderDropZone:c,isEditing:!0,dragRef:t.inline?r:null,metadata:{...s,...t.metadata}};return t.inline?/* @__PURE__ */J(d,{...u,puck:p,editMode:!0}):
4
+ /* @__PURE__ */J("div",{ref:i,[Se]:n,"data-puck-dnd":n,style:{position:"relative"},children:/* @__PURE__ */J(d,{...u,puck:p,editMode:!0})})}function Ze({metadata:e}){const t=be(e=>e.config),n=be(e=>e.appState.data.root).props??{},o=t.root?.render,r=Pe(t.root,C),i=Ve(C),l=/* @__PURE__ */J(Re,{parentId:C,slot:B}),s=o?/* @__PURE__ */J(o,{id:"puck-root",...n,...r,puck:{renderDropZone:i,isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:l}):l;/* @__PURE__ */
5
+ return J(Oe.Provider,{value:e??Ie,children:s})}var Fe=K(void 0);function Te(e,t,n){const[o,r]=H(null),i=F(t);return i.current=t,De(()=>{const t=e.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!i.current)return void r(null);let o=0;const l=()=>{o=0;const n=function(e,t){if(!e||!t)return null;const n=k(e),o=t.getBoundingClientRect();return{top:n.top-o.top,left:n.left-o.left,width:n.width,height:n.height}}(i.current?i.current(t):null,e.current?.parentElement??null);r(e=>{return(t=e)===(o=n)||t&&o&&t.top===o.top&&t.left===o.left&&t.width===o.width&&t.height===o.height?e:n;var t,o})},s=()=>{o||(o=(n.requestAnimationFrame??(e=>n.setTimeout(e,16)))(l))};l();const a="MutationObserver"in n?new n.MutationObserver(s):null;a?.observe(t.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0});const c="ResizeObserver"in n?new n.ResizeObserver(s):null;return c?.observe(t.documentElement),n.addEventListener("resize",s),()=>{a?.disconnect(),c?.disconnect(),n.removeEventListener("resize",s),o&&(n.cancelAnimationFrame??n.clearTimeout)(o)}},[n]),o}function He({id:e,kind:t,overlay:n}){const o=F(null),r=Te(o,e?t=>t.querySelector(`[${Se}="${t.defaultView?.CSS?.escape?t.defaultView.CSS.escape(e):e}"]`):null,e),i=/* @__PURE__ */J("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__ */J(n,{componentId:e,kind:t,children:i}):i}function We(e,t,n){const o=f(e,n),r=o.text.length,i=e.ownerDocument;if(!t)return[r,r];let l=null;const s=i.caretPositionFromPoint?.(t.x,t.y);if(s&&e.contains(s.offsetNode))l=o.at(s.offsetNode,s.offset);else{const n=i.caretRangeFromPoint?.(t.x,t.y);n&&e.contains(n.startContainer)&&(l=o.at(n.startContainer,n.startOffset))}if(null===l)return[r,r];const a=o.text;let c=l,d=l;for(;c>0&&!/\s/.test(a[c-1]);)c-=1;for(;d<a.length&&!/\s/.test(a[d]);)d+=1;return[c,d]}function qe({s:e,element:t,toolbar:n,label:o,keys:r}){const i=m("copy",h),l=e.pressed(),p=new Set(n.offered),f=n.colors&&n.colors.length>0?n.colors:null,g=F(null),[v,y]=H(!1),[b,k]=H(null),S=v||null!==b,C=()=>{e.hold(),y(!1),k({href:e.pressed().href})},I=()=>{y(!1),k(null),e.resume()};Y(()=>{r.current={escape:()=>!!S&&(I(),!0),link:()=>!!p.has("link")&&(C(),!0)}}),Y(()=>()=>{r.current=null},[r]);const E=F(I);E.current=I,j(()=>{if(v)return Q(e=>{const t=g.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(E.current(),!0)},()=>g.current?.querySelector(".es-copy-colors"))},[v]),j(()=>{const n=g.current;if(!S||!n)return;const o=/* @__PURE__ */new Set([n.ownerDocument]),r=t();r&&o.add(r.ownerDocument);const i=o=>{const r=o.target;if(r&&n.contains(r))return;y(!1),k(null);const i=t();r&&i&&i.contains(r)?e.release():e.stop("outside")};for(const e of o)e.addEventListener("pointerdown",i,!0);return()=>{for(const e of o)e.removeEventListener("pointerdown",i,!0)}},[S,e,t]),Y(()=>{const e=g.current,n=e?.querySelector(".rosh-tb-wrap > .es-copy-pop"),o=t();if(!(S&&e&&n&&o))return;const r=o.ownerDocument.defaultView?.getSelection()??null,i=r&&r.rangeCount>0&&o.contains(r.getRangeAt(0).startContainer)?r.getRangeAt(0):null,l=(i?s(i,o):null)??(()=>{const e=o.getBoundingClientRect();return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}})(),d=o.ownerDocument.defaultView?.frameElement,u=d?w(d,{left:l.left,top:l.top,width:l.right-l.left,height:l.bottom-l.top}):{left:l.left,top:l.top,width:l.right-l.left,height:l.bottom-l.top},p=o.getBoundingClientRect(),f=d?w(d,{left:p.left,top:p.top,width:p.width,height:p.height}):{left:p.left,top:p.top,width:p.width,height:p.height},h=(e.closest("[data-floating-bar]")??e).getBoundingClientRect(),m={left:u.left,right:u.left+u.width,top:Math.min(u.top,f.top-6,h.top),bottom:Math.max(u.top+u.height,f.top+f.height+6,h.bottom)},v=e.ownerDocument.documentElement,y=(d??o.closest(".es-canvas")??o).getBoundingClientRect(),b={left:Math.max(0,y.left),top:Math.max(0,y.top),right:Math.min(v.clientWidth||y.right,y.right),bottom:Math.min(v.clientHeight||y.bottom,y.bottom)};if(b.right<=b.left||b.bottom<=b.top||0===n.offsetWidth)return;const k=a({anchor:m,size:{width:n.offsetWidth,height:n.offsetHeight},within:{left:y.left,top:y.top,right:y.right,bottom:y.bottom},clip:b,parent:c(n)});n.style.top=`${k.top}px`,n.style.left=`${k.left}px`,n.style.setProperty("--es-pop-point",`${k.point}px`),n.dataset.side=k.above?"above":"below"});const D=f?{run:d(l.color,f),open:v,onToggle:()=>{k(null),v?I():(e.hold(),y(!0))}}:void 0;/* @__PURE__ */
6
+ return J(_,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?w(o,{left:n.left,top:n.top,width:n.width,height:n.height}):{left:n.left,top:n.top,width:n.width,height:n.height};return{left:r.left-6,top:r.top-6,right:r.left+r.width+6,bottom:r.top+r.height+6}},bounds:()=>{const e=t(),n=e?.ownerDocument.defaultView?.frameElement,o=(n??e?.closest(".es-canvas")??e)?.getBoundingClientRect();return o?{left:o.left,top:o.top,right:o.right,bottom:o.bottom}:{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight}},"aria-label":o,children:/* @__PURE__ */J("div",{ref:g,children:/* @__PURE__ */J(ee,{layout:"row",offered:p,pressed:l.marks,onMark:t=>{"link"===t?C():e.press(t)},color:D,linkOpen:null!==b,list:{pressed:l.list,onList:t=>e.list(t)},alignment:n.alignment,letterCase:n.letterCase,last:n.lastTool?.({className:"rosh-tb-btn",disabled:!1,selected:l.selected,keepCaret:t=>{t.preventDefault(),e.hold()},insert:t=>e.insert(t)}),windows:/* @__PURE__ */X(U,{children:[v&&f?/* @__PURE__ */J(u,{colors:f,current:l.color,words:i.colors??h.colors,onPick:t=>e.color(t)}):null,b?
7
+ /* @__PURE__ */J(te,{className:"es-copy-link es-copy-pop",value:b.href??"",onApply:t=>{k(null),e.link(t)},onRemove:null!==b.href?()=>{k(null),e.link(null)}:void 0,onCancel:I}):null]})})})})}function Ye({element:e}){const t=F(null),n=Te(t,()=>e(),e);/* @__PURE__ */
8
+ return J("div",{ref:t,"aria-hidden":"true",className:"es-canvas-outline is-typing",style:n?{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height}:{display:"none"}})}function Je({frame:t=!0,className:n,style:o,metadata:l,mirrorStyles:s,onDocument:a,height:c,title:d,nonce:u,hotkeys:f,frameWrapper:h,overlay:g,children:y,typing:w,passThrough:k}){const S=we(),C=Z(Fe),I=k??C,E=Z(ve),D=m("canvas",e),x=f??E,[M,A]=H(void 0),O=be(e=>"node"===e.selection?.kind?e.selection.id:null),[z,R]=H(null),[P,V]=H(null),B=F(null),[,N]=H(0),$=F(w);$.current=w;const L=F(null),K=F(null),T=be(e=>e.appState.data);j(()=>{const e=K.current?.ownerDocument,t=e?.defaultView?.CustomEvent;if(!e||!t)return;const n=O&&!P&&$.current?.atSelection?.()?O:null;e.dispatchEvent(new t(v,{detail:{id:n}}))},[O,P,T]);const W=e=>{const t=K.current?.ownerDocument,n=t?.defaultView?.CustomEvent;t&&n&&t.dispatchEvent(new n(b,{detail:{typing:e}}))},q=(e,t)=>{B.current?.s.stop("stop");const n=e.element();if(!n)return!1;const o=S.group(),r=e.element,i=p({element:r,value:e.value,rules:e.rules,multiline:e.multiline,skip:e.skip,caret:We(n,t,e.skip),write:e.write,remount:e.remount,onSelect:()=>N(e=>e+1),onEscape:()=>L.current?.escape()??!1,onLinkKey:()=>L.current?.link()??!1,end:e=>{o.close(),B.current?.element===r&&(B.current=null),V(null),W(!1),$.current?.onChange?.({typing:!1,why:e})}});if(!i)return o.close(),!1;const l=n.closest?.(`[${Se}]`)?.getAttribute(Se);return l&&S.select(l),B.current={s:i,element:r,target:e},V(()=>r),R(null),W(!0),$.current?.onChange?.({typing:!0,element:n}),!0};j(()=>()=>B.current?.s.stop("stop"),[]);const Y=e=>{const t=B.current?.element();return Boolean(t&&t.contains(e))},U=e=>{const t=e.closest?.(`[${Se}]`)?.getAttribute(Se);if(!t)return;const n=S.getState(),o="node"===n.selection?.kind?n.selection.id:null;return i(n.appState.data,S.config,t,o,I)??t},G=e=>{if("Enter"!==e.key||e.defaultPrevented||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;if(B.current)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select, button"))return;const n=$.current?.atSelection?.();n&&q(n,null)&&e.preventDefault()},Q=/* @__PURE__ */X("div",{ref:K,className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;if(t.closest?.("a[href]")&&e.preventDefault(),B.current){if(Y(t))return;B.current.s.stop("outside")}const n=t.ownerDocument?.getSelection?.();n&&n.rangeCount>0&&n.isCollapsed&&n.removeAllRanges();const o=U(t);void 0===o?t.hasAttribute?.(Ce)||S.select(null):S.select(o)},onDoubleClick:e=>{const t=$.current;if(!t||Y(e.target))return;const n=t.at(e.target);n&&q(n,{x:e.clientX,y:e.clientY})&&e.preventDefault()},onKeyDown:e=>G(e),onMouseOver:e=>{if(B.current)return;const t=U(e.target)??null;t!==z&&R(t)},onMouseLeave:()=>R(null),children:[
9
+ /* @__PURE__ */J(Ae.Provider,{value:z,children:/* @__PURE__ */J(Ze,{metadata:l})}),
10
+ /* @__PURE__ */X("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
11
+ /* @__PURE__ */J(He,{id:!P&&z&&z!==O?z:null,kind:"hover",overlay:g}),
12
+ /* @__PURE__ */J(He,{id:P?null:O,kind:"selected",overlay:g}),P?/* @__PURE__ */J(Ye,{element:P}):null]}),y]}),_=h?/* @__PURE__ */J(h,{document:M,children:Q}):Q;j(()=>{if(M&&x)return me(M,S)},[M,x,S]),j(()=>{if(!M)return;const e=e=>{if("Enter"===e.key)return void G(e);if("Escape"!==e.key||e.defaultPrevented)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select"))return;const n=S.getState();if("node"!==n.selection?.kind)return;const o=r(n.appState.data,S.config,n.selection);"node"===o?.kind&&S.select(o.id)};return M.addEventListener("keydown",e),()=>M.removeEventListener("keydown",e)},[M,S]);/* @__PURE__ */
13
+ return X("div",{className:"es-canvas"+(n?` ${n}`:""),style:o,"data-puck-preview":"","data-es-typing":P?"":void 0,children:[P&&B.current?.target.toolbar?/* @__PURE__ */J(qe,{s:B.current.s,element:B.current.element,toolbar:B.current.target.toolbar,label:D.textTools,keys:L}):null,t?/* @__PURE__ */J(Me,{mirrorStyles:s,onDocument:e=>{A(e??void 0),a?.(e)},height:c,title:d,nonce:u,children:_}):/* @__PURE__ */J("div",{id:"preview-frame","data-puck-entry":"",children:_})]})}function Xe(e={}){const t=we(),n=be(e=>e.appState.data);return o({...e,data:n,config:t.config,commit:(e,{select:n})=>t.run({data:e,select:n})})}function Ue(){const e=we(),t=be(e=>e.config),n=e.resolveCache,o=be(e=>e.selectedItem),r=be(e=>e.appState.data.root),i=o?o.props.id:"root",s=r.props??{},a=W(()=>o||{type:"root",props:s},[o,s]),c=o?t.components[o.type]:t.root,d=e.getState(),u=o?S(d.appState.data,t,i):null,p=u&&"root"!==u.place.parentId?u.place.parentId:null,f=p?d.getItemById(p)??null:null,{fields:h}=l({id:i,node:a,block:c,parent:f,appState:d.appState}),m=be(e=>!1===e.getPermissions(o?{item:o}:{root:!0}).edit),g=q(o=>{(async()=>{const r=e.getState();if("root"!==i){const l=r.getItemById(i),s=r.getSelectorForId(i);if(!l||!s)return;const a={...l,props:{...l.props,...o}},{node:c}=await V(a,t,{cache:n,trigger:"replace"}),d=e.getState().getSelectorForId(i);if(!d)return;return void e.dispatch({type:"replace",destinationZone:d.zone??"root:default-zone",destinationIndex:d.index,data:c})}const l=r.appState.data.root.props??{},{node:s}=await V({type:"root",props:{...l,...o}},t,{cache:n,trigger:"replace"});e.dispatch({type:"replaceRoot",root:{props:s.props,readOnly:s.readOnly},recordHistory:!0})})()},[e,t,n,i]),v=q((e,t)=>g({[e]:t}),[g]);return{id:i,node:a,fields:h,values:a.props,readOnly:m,onChange:v,onChangeMany:g}}export{Me as CanvasFrame,Fe as CanvasPassThroughContext,ue as DEFAULT_UI,Je as EaselCanvas,ye as EaselProvider,Ze as EditDocument,me as bindUndoKeys,he as createEasel,ke as createUseEasel,ne as recordsByDefault,ae as reduce,ie as uiView,be as useEasel,we as useEaselApi,Xe as useEaselNodeOps,Ue as useSelectedFields,le as validSelection};
@@ -0,0 +1,6 @@
1
+ import{DEFAULT_PICK_WORDS as e}from"./chunk-OFBZOI6W.js";import{parseHexColor as t,Popover as n,colorSwatchClasses as r,colorFill as l,ColorPickerPanel as i}from"efficient-shell/ui";export{hexToHsv,hsvToHex}from"efficient-shell/ui";import{useRef as a,useState as s,useLayoutEffect as o,useEffect as c}from"react";import{jsx as u,jsxs as p}from"react/jsx-runtime";var d=t,h=7,m=e=>e.toUpperCase(),g=(e,t,n)=>Math.min(n,Math.max(t,e));function f(e,t,n){return{s:n.width>0?g((e-n.left)/n.width,0,1):0,v:n.height>0?1-g((t-n.top)/n.height,0,1):0}}function v(e,t){return t.width>0?360*g((e-t.left)/t.width,0,1):0}function w({value:t,onChange:i,label:h,theme:g,caption:f,inherited:v,after:w,id:x,readOnly:C,words:y=e.colour}){const E=a(null),L=a(null),N=()=>{const e=E.current?.parentElement;return e?.classList.contains("es-field-head")?e.querySelector(":scope > .es-field-name .es-field-label"):e?.classList.contains("es-pick-line")?e.querySelector(":scope > .es-pick-line-label"):null},O=()=>L.current?.querySelector(".es-pick-hexwrap > *")??null,B=e=>e.scrollWidth>e.clientWidth+1,R=e=>{e&&(B(e)?e.dataset.clipped="true":delete e.dataset.clipped)},D=a(()=>{});D.current=()=>{R(N()),W||R(O())};const[T,S]=s(null),[W,M]=s(null);o(()=>D.current()),c(()=>{const e=E.current?.parentElement,t=e?.ownerDocument.defaultView;if(!e||!t?.ResizeObserver)return;const n=new t.ResizeObserver(()=>D.current());return n.observe(e),()=>n.disconnect()},[]),c(()=>{const e=E.current?.parentElement;if(!e)return;const t=e=>{const t=e;if(!t)return null;const n=N(),r=O();return n&&(t===n||n.contains(t))?n:r&&t===r?r:null},n=e=>{const n=t(e.target),r=P();if(!n||!r||n.ownerDocument.activeElement===n||!B(n))return;const l=n.getBoundingClientRect(),i=r.getBoundingClientRect(),a="INPUT"===n.tagName?n.value:n.textContent??"";S({text:a,left:l.left-i.left,top:l.top-i.top})},r=e=>{t(e.target)&&S(null)};return e.addEventListener("pointerover",n),e.addEventListener("pointerout",r),()=>{e.removeEventListener("pointerover",n),e.removeEventListener("pointerout",r)}},[]);const P=()=>{const e=E.current?.parentElement;return e&&(e.classList.contains("es-field-head")||e.classList.contains("es-pick-line"))?e:L.current},q=t?null:d(v??""),F=void 0===f||t&&d(f)===d(t)?null:f,U=F??(t?m(t):q?m(q):y.notSet);/* @__PURE__ */
2
+ return u("div",{ref:E,className:"es-pick-colour",children:/* @__PURE__ */p("div",{ref:L,className:"es-pick-colour-row","data-editing":W??void 0,onFocus:e=>{const t=e.target,n=P();if(!n||!t.classList.contains("es-pick-hex"))return;S(null),t.style.setProperty("--es-pick-edit-room",n.getBoundingClientRect().right-t.getBoundingClientRect().left+"px");const r=t.parentElement?.nextElementSibling,l=!!r&&t.getBoundingClientRect().right>r.getBoundingClientRect().left-2;M(l?"over":"room")},onBlur:e=>{const t=e.target;t.classList.contains("es-pick-hex")&&(t.style.removeProperty("--es-pick-edit-room"),M(null))},children:[
3
+ /* @__PURE__ */u(n,{id:x,className:"es-pick-swatch-wrap",trigger:/* @__PURE__ */u("span",{"aria-hidden":"true",style:{position:"absolute",inset:0,...l(t||q)}}),triggerLabel:y.swatch({label:h,shown:U}),triggerClassName:r({className:t?"es-pick-swatch":q?"es-pick-swatch is-inherited":"es-pick-swatch is-unset"}),"aria-label":y.dialog({label:h}),disabled:C,children:/* @__PURE__ */u(k,{value:t,onChange:i,label:h,theme:g,inherited:v,readOnly:C})}),
4
+ /* @__PURE__ */u("span",{className:"es-pick-hexwrap",children:null===F?/* @__PURE__ */u(b,{value:t,follows:q?m(q):void 0,onChange:e=>{C||e===t||i(e)},name:y.hex({label:h}),readOnly:C}):/* @__PURE__ */u("span",{className:"es-pick-caption",children:F})}),w,T?/* @__PURE__ */u("span",{className:"es-pick-tag","aria-hidden":"true",style:{left:T.left,top:T.top},children:T.text}):null]})})}function k({value:e,onChange:t,label:n,theme:r,onClose:l,id:a,inherited:s,readOnly:o,words:c,swatch:p,dragWrites:d="live"}){/* @__PURE__ */
5
+ return u(i,{id:a,className:"es-pick-window",value:e,onChange:t,label:n,presets:r?.map(e=>({value:e.value,label:e.name})),fallback:s,dragWrites:d,disabled:o,onClose:l})}function b({value:e,follows:t,onChange:n,name:r,readOnly:l}){const[i,o]=s(null),c=a(!1);/* @__PURE__ */
6
+ return u("input",{type:"text",className:!e&&t?"es-pick-hex is-inherited":"es-pick-hex",value:i??(e?m(e):t??""),"aria-label":r,maxLength:7,spellCheck:!1,autoComplete:"off",readOnly:l,onChange:t=>{o(t.target.value);const r=d(t.target.value);null!==r&&r!==e&&n(r)},onFocus:e=>e.currentTarget.select(),onMouseDown:e=>{c.current=e.currentTarget.ownerDocument.activeElement!==e.currentTarget},onMouseUp:e=>{c.current&&e.preventDefault(),c.current=!1},onKeyDown:e=>{"Enter"!==e.key&&"Escape"!==e.key||(e.preventDefault(),e.stopPropagation(),o(null),e.currentTarget.blur())},onBlur:()=>o(null)})}export{w as ColourPicker,k as ColourWindow,h as HEX_MAX_LENGTH,m as hexReadout,v as hueFromPoint,f as svFromPoint,d as typedHex};
@@ -0,0 +1 @@
1
+ import{useEaselSession as e}from"./chunk-O7Q4DDJT.js";import{useHostEscape as n}from"./chunk-U3JP4VGF.js";import{styleMenuItems as t}from"./chunk-V7U33NF2.js";import{createNodeClipboard as o,nodeMenuItems as l}from"./chunk-OSPUG6S6.js";import{DEFAULT_NODE_MENU_WORDS as r}from"./chunk-WK3AFPXY.js";import{DEFAULT_SCREEN_WORDS as i}from"./chunk-VVPZMWJE.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-X4T6JT3M.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 z,LayersIcon as P,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=o(),M=/* @__PURE__ */new WeakMap;function T(e){if(e.claimsPage)return K;const n=e.registry;if(!n)return e.cache("easel:node-clipboard",o);let t=M.get(n);return t||(t=o(),M.set(n,t)),t}function j(){return T(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 X(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?"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=X(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 R(e,n){const{zone:o,index:r}=n,i=e.nodeAt(o,r);if(!i)return[];const s=i.props.id,a=e.labelOf(i.type,o),u=Boolean(i.props._hidden),d=e.nodeOps,p=e.isPinned(i,o),f=e.isLocked(i),m=!p&&!f&&!e.duplicateBlocked(i),h=e.permits?.(i)??{duplicate:!0,delete:!0},y=X(e,i,o),k=D(e,n),b=d.held,v=b&&!p?E(e,b,n):null,g=!e.readOnly,w=e.style?t({held:g?e.style.held():null,canCopy:e.style.canCopy(i,o),onCopy:()=>e.style?.copy(i,o),onPaste:()=>e.style?.paste(o,r,i),words:e.words?.styleClipboard}):[];return l({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,o)?()=>e.beginRename(o,r):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,o,r)??void 0,pinnedLine:p?I(e).pinned:void 0})}var I=e=>e.words?.screen??i.menu;function U(e){const n=I(e),t=!e.readOnly,o=[];t&&e.history.hasPast&&o.push({label:n.undo,icon:/* @__PURE__ */A(w,{}),shortcut:"⌘Z",onClick:e.history.back}),t&&e.history.hasFuture&&o.push({label:n.redo,icon:/* @__PURE__ */A(x,{}),shortcut:"⇧⌘Z",onClick:e.history.forward});const l=[],s=e.nodeOps.held,a=S(e,c,e.sectionBand().cap);if(t&&s&&(e.canPasteAt?e.canPasteAt(s,a):f(s.from)===c)){const n=a,t=e.words?.menu??r;l.push({label:t.pasteNamed({paste:t.paste,label:s.label}),icon:/* @__PURE__ */A(C,{}),shortcut:"⌘V",onClick:()=>e.nodeOps.paste(n)})}const u=[o,l,[{label:e.pageSettingsLabel??i.pageSettings,icon:/* @__PURE__ */A(z,{}),onClick:e.openPageSettings},{label:n.collapseAll,icon:/* @__PURE__ */A(P,{}),onClick:e.collapseAll}]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return u.flatMap((e,n)=>n?[d,...e]:e)}function Y(e,n){const t=n.selectionStart??0,o=n.selectionEnd??0,l=n.value.slice(t,o),i=e=>{n.focus(),n.setRangeText(e,t,o,"end"),n.dispatchEvent(new Event("input",{bubbles:!0}))},c=e.words?.menu??r,s=I(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),i("")}})),a.push({label:c.paste,icon:/* @__PURE__ */A(C,{}),shortcut:"⌘V",onClick:()=>{navigator.clipboard?.readText().then(e=>{e&&i(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 B(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(B(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(B(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?R(e,n):"input"===n.kind?Y(e,n.el):U(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,T as nodeClipboardOf,X as nodeClipboardRules,R as nodeMenuItems,V as nodeShortcut,U as pageMenuItems,E as pastePlace,L as runNodeShortcut,Y as textMenuItems,j as useNodeClipboard,N as useNodeContextMenu};
@@ -0,0 +1 @@
1
+ import{useState as t,useEffect as e,useRef as n}from"react";var o=/* @__PURE__ */new Set(["button","checkbox","color","file","hidden","image","radio","range","reset","submit"]);function r(t){const e=t;if(!e||"string"!=typeof e.tagName)return!1;const n=e.tagName.toUpperCase();if("TEXTAREA"===n||"SELECT"===n)return!0;if("INPUT"===n)return!o.has(String(e.type??"text").toLowerCase());if(e.isContentEditable)return!0;const r=e.closest?.("[contenteditable]");return!(!r||"false"===r.getAttribute("contenteditable"))||null!=e.closest?.('[role="textbox"]')}var i="data-puck-component";function c(t,e=i){const n=t;return n&&"function"==typeof n.closest?n.closest(`[${e}]`)?.getAttribute(e)??null:null}function u(t){const e=t.getBoundingClientRect();if(e.width>0&&e.height>0)return{left:e.left,top:e.top,width:e.width,height:e.height};let n=1/0,o=1/0,r=-1/0,i=-1/0;for(const e of Array.from(t.children)){const t=e.getBoundingClientRect();t.width<=0||t.height<=0||(n=Math.min(n,t.left),o=Math.min(o,t.top),r=Math.max(r,t.right??t.left+t.width),i=Math.max(i,t.bottom??t.top+t.height))}return n===1/0?{left:e.left,top:e.top,width:e.width,height:e.height}:{left:n,top:o,width:r-n,height:i-o}}function l(t){const e=t.offsetWidth;if(!e)return 1;const n=t.getBoundingClientRect().width;return n>0?n/e:1}function s(t,e,n){const o=t.getBoundingClientRect(),r=n?.getBoundingClientRect()??{left:0,top:0},i=l(t);return{left:o.left-r.left+e.left*i,top:o.top-r.top+e.top*i,width:e.width*i,height:e.height*i}}function a(t){const e=t.offsetWidth;if(!e)return 1;const n=t.getBoundingClientRect().width;return n>0?n/e:1}function d(t,e,n){const o=s(t,e,n),r=a(n);return{left:o.left/r,top:o.top/r,width:o.width/r,height:o.height/r}}function f(t,e,n){const o=t.getBoundingClientRect(),r=a(t);return{x:(e-o.left)/r,y:(n-o.top)/r}}function h(t,e,n,o){const{left:r,top:i}=s(t,{left:e,top:n,width:0,height:0},o);return{x:r,y:i}}function m({available:t,width:e,maxScale:n=1}){const o=Math.max(0,t);if(!e||e<=0)return{width:o,scale:1,shownWidth:o};const r=o>0?Math.min(o/e,n):1;return{width:e,scale:r,shownWidth:e*r}}var w="data-es-canvas-style",g=/* @__PURE__ */new WeakMap;function p(t,e){e?g.set(t,e):g.delete(t)}function b(t,e,n){const o=t.head??t.documentElement;let r=y(t,e);if(!r){r=t.createElement("style"),r.setAttribute(w,e);const n=g.get(t);n&&r.setAttribute("nonce",n),o.appendChild(r)}return r.textContent!==n&&(r.textContent=n),r}function v(t,e){y(t,e)?.remove()}function y(t,e){for(const n of Array.from(t.querySelectorAll(`style[${w}]`)))if(n.getAttribute(w)===e)return n;return null}var E="[data-puck-component]",A="[data-puck-dropzone]",C="iframe#preview-frame";function L(t){const e=t.contentDocument;if(!e||!t.contentWindow||"loading"===e.readyState||!e.body)return!1;if(t.hasAttribute("srcdoc"))return"about:srcdoc"===e.URL;const n=t.getAttribute("src");return!n||"about:blank"===n||"about:blank"!==e.URL}function x(t,e,{selector:n=C,readySelector:o}={}){let r=null,i=null,c=!1,u=!1,l=null;const s=()=>{l?.observer.disconnect(),l=null},a=()=>{if(u)return;let t=null;if(r&&L(r)){const e=r.contentDocument;(t=>{if(!o||t.querySelector(o))return s(),!0;if(l?.doc!==t){s();const e=t.defaultView?.MutationObserver;if(e){const n=new e(()=>a());n.observe(t,{childList:!0,subtree:!0}),l={doc:t,observer:n}}}return!1})(e)&&(t={frame:r,document:e,window:r.contentWindow})}else s();(t===i||!!t&&!!i&&t.frame===i.frame&&t.document===i.document)&&c||(c=!0,i=t,e(i))},d=()=>a(),f=()=>{const e=t.querySelector?.(n);e!==r?(r?.removeEventListener("load",d),r=e,r?.addEventListener("load",d),a()):a()},h=t.ownerDocument?.defaultView??t.defaultView,m=h?.MutationObserver,w=m?new m(t=>(t=>null!==r&&!r.isConnected||t.some(t=>[...t.addedNodes,...t.removedNodes].some(t=>"IFRAME"===t.nodeName||!!t.querySelector?.("iframe"))))(t)&&f()):null;return w?.observe(t,{childList:!0,subtree:!0}),f(),()=>{u=!0,w?.disconnect(),s(),r?.removeEventListener("load",d),r=null}}function M(n,{selector:o,readySelector:r}={}){const[i,c]=t(null);return e(()=>{const t=n.current;if(!t)return;const e=x(t,c,{selector:o,readySelector:r});return()=>{e(),c(null)}},[n,o,r]),i}var R="easel:canvas-typing",S="easel:canvas-typable";function B(t,o,r,{on:i="document",capture:c=!1}={}){const u=n(r);u.current=r;const l=t?.document??null,s=t?.window??null;e(()=>{const t="window"===i?s:l;if(!t)return;const e=t=>u.current(t);return t.addEventListener(o,e,c),()=>t.removeEventListener(o,e,c)},[l,s,o,i,c])}function k(e){const[n,o]=t(!1);return B(e,R,t=>o(Boolean(t.detail?.typing))),n}function W(t,n,o){const r=t?.document??null;e(()=>{if(!r)return;if(!o)return void v(r,n);const t=b(r,n,o),e=r.defaultView?.MutationObserver,i=e?new e(()=>{t.isConnected||b(r,n,o)}):null;return i?.observe(r.head??r.documentElement,{childList:!0}),()=>{i?.disconnect(),v(r,n)}},[r,n,o])}function q(n,{settle:o=[150,450]}={}){const[r,i]=t(0),c=n?.frame??null,u=n?.document??null,l=n?.window??null,s=o.join(",");return e(()=>{if(!c||!u||!l)return;const t=c.ownerDocument.defaultView;let e=!1,n=0;const r=()=>{if(e)return;e=!0;const o=()=>{e=!1,i(t=>t+1)};t?.requestAnimationFrame?n=t.requestAnimationFrame(o):o()},s=[],a=(t,e)=>{t.addEventListener(e,r,!0),s.push(()=>t.removeEventListener(e,r,!0))};a(u,"scroll"),a(l,"resize"),t&&(a(t,"scroll"),a(t,"resize"));const d=t?.ResizeObserver;if(d){const t=new d(r);t.observe(c),u.documentElement&&t.observe(u.documentElement),s.push(()=>t.disconnect())}const f=u.defaultView?.MutationObserver,h=u.body??u.documentElement;if(f&&h){const t=new f(r);t.observe(u===c.ownerDocument?c:h,{childList:!0,subtree:!0}),s.push(()=>t.disconnect())}const m=u.fonts;m&&a(m,"loadingdone");const w=o.map(t=>setTimeout(r,t));return r(),()=>{for(const t of s)t();for(const t of w)clearTimeout(t);n&&t?.cancelAnimationFrame&&t.cancelAnimationFrame(n)}},[c,u,l,s]),r}export{i as BLOCK_ATTRIBUTE,E as BLOCK_SELECTOR,C as CANVAS_SELECTOR,S as CANVAS_TYPABLE_EVENT,R as CANVAS_TYPING_EVENT,A as LIST_SELECTOR,f as clientPointToLayer,u as drawnBox,a as elementScale,m as fitCanvas,h as framePointToHost,s as frameRectToHost,d as frameRectToLayer,l as frameScale,L as isFrameReady,r as isTypingTarget,c as nodeIdAt,v as removeCanvasStyle,p as setCanvasNonce,b as upsertCanvasStyle,B as useCanvasEvent,M as useCanvasFrame,q as useCanvasLayout,W as useCanvasStyle,k as useCanvasTyping,x as watchCanvasFrame};
@@ -1,2 +1,2 @@
1
- import{ScreenPartsProvider as t}from"./chunk-CSGTPJTY.js";import{useEaselHost as r}from"./chunk-U3JP4VGF.js";import{createEasel as e,EaselProvider as n}from"./chunk-LPM2SCM4.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-EHBWUEEE.js";import{useEaselHost as r}from"./chunk-U3JP4VGF.js";import{createEasel as e,EaselProvider as n}from"./chunk-SMM3ST7A.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};
@@ -1 +1 @@
1
- import{useSectionOps as o}from"./chunk-TR4APEJZ.js";import{SELECTION_MODE as e}from"./chunk-CSGTPJTY.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-LPM2SCM4.js";import{useCallback as d,useEffect as c}from"react";var s=o=>"part"===o.kind;function m({mode:m,setMode:i,onOpenPart:a}){const{getSelectorForId:u}=p(o=>o),I=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}),a?.(n)):i(o=>"part"===o.kind?e:o)},[i,a]);c(()=>{k(l)},[k,l]);const P=s(m)?n(m.nodeId,m.propKey):null;c(()=>{f(P)},[P,f]);return{selectNode:d(o=>{i(()=>e);const r=u(o);r&&I.select(r)},[i,u,I]),openPartId:P}}export{m as usePartBridge};
1
+ import{useSectionOps as o}from"./chunk-OJ6QWOLG.js";import{SELECTION_MODE as e}from"./chunk-EHBWUEEE.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-SMM3ST7A.js";import{useCallback as d,useEffect as c}from"react";var s=o=>"part"===o.kind;function m({mode:m,setMode:i,onOpenPart:a}){const{getSelectorForId:u}=p(o=>o),I=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}),a?.(n)):i(o=>"part"===o.kind?e:o)},[i,a]);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=u(o);r&&I.select(r)},[i,u,I]),openPartId:h}}export{m as usePartBridge};
@@ -1,2 +1,2 @@
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};
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 g}from"./chunk-U3JP4VGF.js";import{DEFAULT_SCREEN_WORDS as k}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 E,useCallback as O,useEffect as C,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=g(),z=d(),_=E(()=>f(z),[z]),q=E(()=>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=E(()=>Y(G,_,te),[Y,_,te,G.kind,"template"===G.kind?G.id:"document"===G.kind?G.record:G.siteId]),ue=oe.capabilities,ae=O(e=>z.documentHooks?.stored?.(e)??e,[z]),se="page"===G.kind?G.originSlug??null:null;C(()=>{m(z,ne)},[z,ne]);const ie=H(G);C(()=>{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&&Er(r.target)}}}),fe=!z.usesBridgedToken||null!==le,me=oe.lock,ge=Boolean(_.lock),[ke,ve]=B(null),[pe,he]=B(null),[ye,we]=B(null),[Se,be]=B(null),Pe=I("screen",k),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),Ee=H(null),[Oe,Ce]=B(!1),He=H(null),[Te,Me]=B(null),Ve=H(null),[Ae,De]=B(null),[Ne,Fe]=B(!1),Le=H(null);C(()=>{Le.current=Ae},[Ae]);const[We,Ze]=B(ue.hasEditLock?{kind:"checking"}:{kind:"editing"}),Je=H(We);C(()=>{Je.current=We},[We]);const Ye=H(()=>Promise.resolve(!1)),Ue=O(e=>{Ee.current=e,Ce(!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);C(()=>{rr.current=xe},[xe]);const nr=o(xe),tr=O(()=>{const e=Ee.current;e&&(Ee.current=null,Ce(!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);C(()=>{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;C(()=>{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=O(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=O(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]),gr=O(async e=>{const r=ce.current?await mr(e):{ok:!1};return r.ok||dr("storefront-editor:save-failed"),r.ok},[dr,mr]),kr=O(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]);C(()=>{Ye.current=kr},[kr]);const vr=O(e=>{if(null!==Be.current)return;if(dr("storefront-editor:dirty"),!ke)return;const r=ae(e);He.current=r,p(Je.current)?Ge({id:ke,data:r}):Ue({id:ke,data:r})},[ke,dr,Ue,Ge,ae]),pr=O(async()=>{p(Je.current)&&tr();return await Ke()&&null==Ee.current},[tr,Ke]),hr=H(pr);C(()=>{hr.current=pr},[pr]);const yr=H(mr);C(()=>{yr.current=mr},[mr]);const wr=O(()=>{Q.address.reload()},[Q]),Sr=H(()=>Promise.resolve(!1));C(()=>{Sr.current=()=>{const e=oe.rereadVersion;return ke&&e?y({ours:Ve.current,stored:async()=>{const r=await yr.current(()=>e(ke));return r.ok?r.value:null},hasPending:()=>null!=Ee.current||er(),reload:wr}):Promise.resolve(!1)}},[oe,ke,er,wr]);const br=null!==je;C(()=>{if(!me||!ke||!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(ke,t,e));if(r.ok)return{heartbeat_seconds:r.value.heartbeatSeconds};throw r.error},cancelled:()=>e,currentAccess:()=>Je.current,heldWrite:()=>({pending:null!=Ee.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(ke,t).catch(()=>{})}},[ke,me,fe,le,ur,br]);const Pr=O(()=>{me&&ke&&(sr.current=!0,ar(e=>e+1))},[ke,me]),Ir=O(()=>{Ze(e=>{const r="blocked"===e.kind||"takenover"===e.kind?e.holder:null;return r?{kind:"readonly",holder:r}:e})},[]),jr=O(()=>{rr.current.paused?(p(Je.current)&&tr(),ze()):Qe()},[tr,Qe,ze]),Rr=O(()=>{$e()},[$e]),Br=O(e=>{He.current=null,u("template"!==e.kind&&ge,{resetAutosave:()=>{qe(),Ee.current=null,Ce(!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,ge,Z,J]),Er=O(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!=Ee.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]),Or=O(()=>Me(null),[]),Cr=O(()=>{Me(e=>(e&&Br(e),null))},[Br]),Hr=O(async()=>{const e=Te;if(!e)return;await pr()&&(Me(null),Br(e))},[Te,pr,Br]),Tr=O(async e=>{if(null!==Be.current)return;if(!ke)return;if(!p(Je.current)||Le.current)return;const r=ae(e);if(!await kr(ke,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(ke,Ve.current??void 0));if(!t.ok){const{error:e}=t;return void dr("storefront-editor:publish-failed",{reason:e instanceof Error&&e.message?e.message:null})}Ve.current=t.value.version??Ve.current,dr("storefront-editor:published")},[ke,oe,ue.canPublish,dr,kr,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:gr,docId:ke,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||Oe,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:Er,pendingNav:Te,cancelPendingNav:Or,discardAndNavigate:Cr,saveAndNavigate:Hr},children:D})}export{V as ScreenDocumentContext,D as ScreenDocumentProvider,A as useScreenDocument};
@@ -273,8 +273,8 @@
273
273
  * The toolbar is efficient-shell's `TextToolbar` (S4/E2, harness UI-24): its
274
274
  * grid, its sizes, its narrow step and its colour fill are the shell's sheet
275
275
  * (`.rosh-tb-*` in ui.css), held by the shell's own specs. Its wrapper is the
276
- * size container; its direct children carry `--rosh-tb-size`,
277
- * `--rosh-tb-steps`, `--rosh-tb-color-col` and `--rosh-tb-link-col`, and the
276
+ * size container; its direct children carry `--rosh-tb-size` and the two
277
+ * window buttons' centres, `--rosh-tb-color-x` and `--rosh-tb-link-x`, and the
278
278
  * two windows below are drawn among them, so they read those. What stays here
279
279
  * is the toolbar's place in the box: the gap under it.
280
280
  */
@@ -311,11 +311,11 @@
311
311
  box-shadow: var(--rosh-glass-solid-shadow);
312
312
  }
313
313
 
314
- /* The point, aimed at its button: column k of row 1 across the box (100cqw),
315
- whose cells are `--rosh-tb-steps` + 1 (nine, or eight with no host control).
316
- Row 1 draws only what the host offers, so k is the button's column as
317
- drawn: the shell's toolbar writes `--rosh-tb-color-col` and `--rosh-tb-link-col` on
318
- its wrapper (`textToolbarWindowColumns`), never a fixed 4 or 5. */
314
+ /* The point, aimed at its button's centre, which the shell's toolbar says
315
+ for both of its layouts — the panel's nine-cell grid and the canvas's one
316
+ row (`--rosh-tb-color-x`, `--rosh-tb-link-x`, efficient-shell #566) — from
317
+ the button's column as drawn (`textToolbarWindowColumns`), never a fixed 4
318
+ or 5. Easel never re-derives the grid. */
319
319
  .es-copy-pop::before {
320
320
  content: '';
321
321
  position: absolute;
@@ -330,11 +330,11 @@
330
330
 
331
331
  /* Aimed at the words (measured), or — unmeasured — at its button, as above. */
332
332
  .es-copy-colors::before {
333
- left: var(--es-pop-point, calc(var(--rosh-tb-color-col) * (100cqw - var(--rosh-tb-size)) / var(--rosh-tb-steps) + var(--rosh-tb-size) / 2 - 6px));
333
+ left: var(--es-pop-point, calc(var(--rosh-tb-color-x) - 6px));
334
334
  }
335
335
 
336
336
  .es-copy-link.es-copy-pop::before {
337
- left: var(--es-pop-point, calc(var(--rosh-tb-link-col) * (100cqw - var(--rosh-tb-size)) / var(--rosh-tb-steps) + var(--rosh-tb-size) / 2 - 6px));
337
+ left: var(--es-pop-point, calc(var(--rosh-tb-link-x) - 6px));
338
338
  }
339
339
 
340
340
  /* Opened above the words: the point is on the bottom edge, aimed down. */
@@ -1,44 +1,17 @@
1
1
  import * as react from 'react';
2
- import { ReactNode } from 'react';
3
2
  import { c as CopyBoxProps, d as CopyCell, T as TextBoxHandle } from '../canvas-typing-BsNigaCa.js';
4
3
  export { e as COPY_CELLS, b as CanvasTypingEnd, f as CanvasTypingOptions, g as CanvasTypingSession, h as ColorWindow, i as CopyBoxAlign, j as CopyBoxFooter, C as CopyBoxLastTool, k as CopyCase, l as CopyCellPreset, m as CopyCells, a as CopyThemeColor, M as MarkWriter, S as SelectionSource, n as TextAreaHandle, o as TextMap, p as ToolbarMark, q as colorRunOf, r as insertSelection, s as markSelection, t as startCanvasTyping, u as textMap } from '../canvas-typing-BsNigaCa.js';
5
- import { MarkStyle, MarkupTool, InlineRule, MarkedLine, WrapResult } from 'efficient-shell/markup';
6
4
  export { TextToolbar, TextToolbarProps } from 'efficient-shell/ui';
7
5
  import { F as FieldOption } from '../types-CDX6vd6A.js';
8
6
  import { a as CopyAlign } from '../words-D-yhjdOg.js';
9
7
  export { b as COPY_ALIGNS, c as COPY_ALIGN_FIT, d as COPY_ALIGN_GLYPHS, e as COPY_ALIGN_LABELS, C as CopyWords, f as copyAlignOptions } from '../words-D-yhjdOg.js';
10
8
  import { TextStyleCase } from '../text-styles/model.js';
9
+ import { InlineRule, MarkStyle, MarkedLine, WrapResult } from 'efficient-shell/markup';
11
10
  import '../buckets-Tj-nkBpg.js';
12
11
  import '../words-gIDCeRv3.js';
13
12
 
14
13
  declare function CopyBox({ value, onChange, onCommit, onCancel, multiline, placeholder, ariaLabel, className, readOnly, rules, tools, writeMark, align, actions, toolbar, barLabel, renderFooter, inputRef, barShows, richText, defaultShowMarks, colors, cells, letterCase, lastTool, }: CopyBoxProps): react.JSX.Element;
15
14
 
16
- /** `'b'` → `Meta+B`, `'shift+x'` → `Meta+Shift+X` — the ARIA spelling of a
17
- * shortcut.
18
- * @deprecated The toolbar spells its own shortcuts. Removed in 12.0.0. */
19
- declare function ariaShortcut(shortcut: string | undefined): string | undefined;
20
- /** @deprecated Draw `TextToolbar` (`efficient-shell/ui`). Removed in 12.0.0. */
21
- interface MarkBarProps {
22
- /** The marks to offer: styles, or a host's descriptors (only `style` is read). */
23
- tools: readonly MarkStyle[] | readonly MarkupTool[];
24
- onApply: (style: MarkStyle) => void;
25
- disabled?: boolean;
26
- /** One control of the host's, drawn in row 1's last cell. */
27
- actions?: ReactNode;
28
- /** Not drawn: the toolbar's alignment is a value. */
29
- align?: ReactNode;
30
- /** Not drawn: the drawings are the shell set's. */
31
- glyphs?: Partial<Record<MarkStyle, ReactNode>>;
32
- /** The toolbar's accessible name; "Formatting" (`EaselStrings.copy.formatting`) by default. */
33
- ariaLabel?: string;
34
- /** The marks the selection already wears. */
35
- pressed?: Partial<Record<MarkStyle, boolean>>;
36
- /** The style whose own window is open (`'link'` lights the link button). */
37
- open?: MarkStyle | null;
38
- }
39
- /** @deprecated Draw `TextToolbar` (`efficient-shell/ui`). Removed in 12.0.0. */
40
- declare function MarkBar({ tools, onApply, disabled, actions, ariaLabel, pressed, open }: MarkBarProps): react.JSX.Element;
41
-
42
15
  /** Whether the lines are a list, and which kind. */
43
16
  type TextList = 'none' | 'bullet' | 'number';
44
17
  /** How the letters are drawn: as typed, all capitals, each word capitalized,
@@ -350,4 +323,4 @@ interface CaretEdit {
350
323
  */
351
324
  declare function useCaretEdit({ target, onChange }: CaretEdit): (edit: (el: HTMLInputElement | HTMLTextAreaElement | null) => WrapResult) => void;
352
325
 
353
- export { type CaretEdit, CopyAlign, CopyBox, CopyBoxProps, CopyCell, type History, MARKUP_CLIPBOARD_TYPE, MarkBar, type MarkBarProps, type PasteData, type PasteOptions, RichBox, type RichBoxProps, type RichEdit, type RichHandle, type RichInputEvent, type RichInputResult, type RichInsert, type RichLayout, type RichLine, type RichPending, type Snapshot, TYPING_BURST_MS, TextBoxHandle, type TextCase, type TextList, TextPartPanel, type TextPartPanelProps, type TextPartStrip, ariaShortcut, createHistory, editVisible, markupOfRange, newLine, pasteToMarkup, richInput, richLayout, selectionToSource, selectionToVisible, setBullet, toSource, toSourceStart, toVisible, useCaretEdit };
326
+ export { type CaretEdit, CopyAlign, CopyBox, CopyBoxProps, CopyCell, type History, MARKUP_CLIPBOARD_TYPE, type PasteData, type PasteOptions, RichBox, type RichBoxProps, type RichEdit, type RichHandle, type RichInputEvent, type RichInputResult, type RichInsert, type RichLayout, type RichLine, type RichPending, type Snapshot, TYPING_BURST_MS, TextBoxHandle, type TextCase, type TextList, TextPartPanel, type TextPartPanelProps, type TextPartStrip, createHistory, editVisible, markupOfRange, newLine, pasteToMarkup, richInput, richLayout, selectionToSource, selectionToVisible, setBullet, toSource, toSourceStart, toVisible, useCaretEdit };
@@ -1,18 +1,17 @@
1
- import{TEXT_STYLE_CASES as e}from"../chunk-YHZSBL2N.js";import{selectionToVisible as t,selectionToSource as n,richLayout as r,createHistory as l,colorRunOf as o,textRange as a,selectionBox as s,placeWindow as i,offsetOrigin as c,visibleArea as u,ColorWindow as d,markPress as p,pasteToMarkup as m,richInput as h,editVisible as f,MARKUP_CLIPBOARD_TYPE as g,markupOfRange as y}from"../chunk-NY7HHUGB.js";export{ColorWindow,MARKUP_CLIPBOARD_TYPE,TYPING_BURST_MS,colorRunOf,createHistory,editVisible,markupOfRange,newLine,pasteToMarkup,richInput,richLayout,selectionToSource,selectionToVisible,setBullet,startCanvasTyping,textMap,toSource,toSourceStart,toVisible}from"../chunk-NY7HHUGB.js";import{DEFAULT_COPY_WORDS as v}from"../chunk-B4JN227A.js";import{FieldNumber as b}from"../chunk-2XMHLXMA.js";import{FieldSelect as S}from"../chunk-G3GWAP5R.js";import"../chunk-WRFD4EXD.js";import{SettingsSwitch as k,SettingsField as x,SettingsSegmented as w}from"../chunk-36LVP5WD.js";import{GoldTextInput as E}from"../chunk-H4UMY7QF.js";import{useWords as C}from"../chunk-MFIRYGHW.js";import{TextToolbar as D,registerModalEscapeInterceptor as N,textToolbarRows as L,LinkPicker as O,Tooltip as T,IconButton as R}from"efficient-shell/ui";export{TextToolbar}from"efficient-shell/ui";import{useRef as H,useState as K,useLayoutEffect as M,useEffect as P,useId as j}from"react";import{RETIRED_MARKS as B,applyMark as F,marksIn as $,STANDARD_MARKUP as V,listIn as z,colorIn as U,spanFor as W,findLink as A,colorOver as Y,setList as I,unlinkAt as G,removeLink as q,linkOver as _,writeLink as X}from"efficient-shell/markup";import{jsxs as Z,jsx as J,Fragment as Q}from"react/jsx-runtime";import{ParagraphSpacingIcon as ee,LetterSpacingIcon as te,LineSpacingIcon as ne,TextSizeIcon as re,AlignJustifyIcon as le,AlignRightIcon as oe,AlignCenterIcon as ae,AlignLeftIcon as se,StylesIcon as ie,TypeIcon as ce,AlignmentIcon as ue,ListFormatIcon as de,CaseIcon as pe,ItalicIcon as me,NumberedListIcon as he,ListIcon as fe,ListNoneIcon as ge,CaseLowerIcon as ye,CaseCapitalizedIcon as ve,CaseUpperIcon as be,CaseNormalIcon as Se}from"efficient-shell/icons/efficient";function ke(e,t){const n=t?.selectionStart??e.length;return{start:n,end:t?.selectionEnd??n}}function xe(e,t,n,r=F){const{start:l,end:o}=ke(e,n);return r(e,l,o,t)}function we(e,t,n){const{start:r,end:l}=ke(e,n),o=r+t.length;return{text:e.slice(0,r)+t+e.slice(l),selectionStart:o,selectionEnd:o}}function Ee(e,t,n,r){switch(t){case"bold":return e.createElement("strong");case"italic":return e.createElement("em");case"strike":return e.createElement("s");case"underline":return e.createElement("u");case"sup":return e.createElement("sup");case"sub":return e.createElement("sub");case"color":{const t=e.createElement("span");return t.className="es-rich-color",r&&(t.dataset.color=r,t.title=r.startsWith("#")?r.toUpperCase():r,t.style.color=r.startsWith("#")?r:`var(--es-color-${r}, inherit)`),t}case"link":{const t=e.createElement("a");return t.className="es-rich-link",n&&(t.title=n),t}default:{const n=e.createElement("span");return n.className="highlight"===t||"accent"===t?"es-rich-emphasis":`es-rich-${t}`,n}}}function Ce(e,t,n,r){const l=e.layout.lines;if(n===t)return r>=e.lines.length?e.layout.text.length:l[r].vis;const o=e.lines.findIndex(e=>e===n||e.contains(n));if(-1===o)return 0;const a=t.ownerDocument.createRange();a.setStart(e.lines[o],0);try{a.setEnd(n,r)}catch{return l[o].vis}return l[o].vis+Math.min(a.toString().length,l[o].text.length)}function De(e,t){const n=e.layout.lines;let r=n.length-1;for(let e=0;e<n.length;e+=1)if(t<=n[e].vis+n[e].text.length){r=e;break}let l=Math.max(0,t-n[r].vis);const o=e.lines[r].ownerDocument.createTreeWalker(e.lines[r],4);let a=o.nextNode(),s=null;for(;a;){if(l<=a.data.length)return[a,l];l-=a.data.length,s=a,a=o.nextNode()}return s?[s,s.data.length]:[e.lines[r],0]}function Ne({value:e,rules:l,multiline:o,readOnly:a=!1,placeholder:s,ariaLabel:i,handle:c,onEdit:u,onSelect:d,onHistory:p,onFormat:v,pending:b,onCommit:S,onCancel:k}){const x=H(null),w=H(null),E=H(null),C=H(null),D=H(null),N=H(e),[L,O]=K(0),T=H({value:e,rules:l,multiline:o,readOnly:a,pending:b,onEdit:u,onHistory:p,onFormat:v});T.current={value:e,rules:l,multiline:o,readOnly:a,pending:b,onEdit:u,onHistory:p,onFormat:v};const R=()=>{const e=x.current,t=w.current,n=e?.ownerDocument.getSelection();if(!(e&&t&&n&&0!==n.rangeCount&&n.anchorNode&&e.contains(n.anchorNode)))return null;const r=Ce(t,e,n.anchorNode,n.anchorOffset),l=n.focusNode&&e.contains(n.focusNode)?Ce(t,e,n.focusNode,n.focusOffset):r;return r<=l?[r,l]:[l,r]},j=(e,t)=>{const n=x.current,r=w.current;if(!n||!r)return;const[l,o]=De(r,e),[a,s]=De(r,t);n.ownerDocument.getSelection()?.setBaseAndExtent(l,o,a,s)};c.current={getSource(){const e=R(),t=w.current;if(!e||!t)return null;const[r,l]=n(t.layout,e[0],e[1]);return{start:r,end:l}},setSource(e,t,n){C.current={text:n,src:[e,t]},O(e=>e+1)},focus(){x.current?.focus()},rangeOf(e,n){const r=x.current,l=w.current;if(!r||!l)return null;const[o,a]=t(l.layout,e,n),[s,i]=De(l,o),[c,u]=De(l,a),d=r.ownerDocument.createRange();return d.setStart(s,i),d.setEnd(c,u),d}},M(()=>{const n=x.current;if(!n||D.current)return;const o=C.current?null:R();w.current=function(e,t){const n=e.ownerDocument;e.replaceChildren();const r=t.lines.map(t=>{const r=n.createElement("div");r.className=null!=t.number?"es-rich-line is-numbered":t.bullet?"es-rich-line is-bullet":"es-rich-line",null!=t.number&&(r.dataset.number=t.number);const l=[],o=()=>l.length?l[l.length-1].el:r;let a=null;for(const e of t.chars){let t=0;for(;t<l.length&&t<e.marks.length&&l[t].id===e.marks[t].id;)t+=1;(l.length>t||e.marks.length>t)&&(a=null),l.length=t;for(let r=t;r<e.marks.length;r+=1){const t=Ee(n,e.marks[r].kind,e.marks[r].href,e.marks[r].color);o().appendChild(t),l.push({id:e.marks[r].id,el:t})}a||(a=n.createTextNode(""),o().appendChild(a)),a.data+=e.ch}return 0===t.chars.length&&r.appendChild(n.createElement("br")),e.appendChild(r),r});return{layout:t,lines:r}}(n,r(e,l)),E.current=e;const a=C.current;if(!a||a.text!==e)return void(o&&n.ownerDocument.activeElement===n&&j(o[0],Math.min(o[1],w.current.layout.text.length)));C.current=null;const s=w.current.layout,[i,c]=a.vis??t(s,a.src[0],a.src[1]);n.ownerDocument.activeElement!==n&&n.focus(),j(i,c)},[e,l,L]);const B=(e,t,r)=>{const l=w.current,[o,a]=n(l.layout,t[0],t[1]);C.current={text:e.text,vis:[e.caret,e.caret]},e.text!==T.current.value?T.current.onEdit(e.text,{start:o,end:a},r):O(e=>e+1)};P(()=>{const e=x.current;if(!e)return;const t=t=>{const{value:n,rules:r,multiline:l,readOnly:o,pending:a}=T.current;if("insertCompositionText"===t.inputType)return;if(t.preventDefault(),o)return;const s=w.current,i=R();if(!s||!i)return;const c="function"==typeof t.getTargetRanges?t.getTargetRanges()[0]:void 0,u=c&&!c.collapsed?[Ce(s,e,c.startContainer,c.startOffset),Ce(s,e,c.endContainer,c.endOffset)]:null,d=h({value:n,rules:r,multiline:l,inputType:t.inputType,data:t.data??t.dataTransfer?.getData("text/plain")??"",html:t.dataTransfer?.getData("text/html"),doc:e.ownerDocument,sel:i,target:u,pending:a});d&&("history"!==d.kind?"format"!==d.kind?B(d.edit,d.range,d.kind):T.current.onFormat(d.style):T.current.onHistory(d.dir))},n=()=>{D.current||O(e=>e+1)};return e.addEventListener("beforeinput",t),e.addEventListener("input",n),()=>{e.removeEventListener("beforeinput",t),e.removeEventListener("input",n)}},[]),P(()=>{const e=x.current;if(!e)return;const t=e.ownerDocument,n=()=>{const e=c.current?.getSource();e&&d(e)};return t.addEventListener("selectionchange",n),()=>t.removeEventListener("selectionchange",n)});const F=(t,n=!1)=>{const r=R();if(!r||r[0]===r[1])return;t.preventDefault();const o=w.current;t.clipboardData.setData("text/plain",o.layout.text.slice(r[0],r[1])),t.clipboardData.setData(g,y(e,l,r[0],r[1])),n&&!a&&B(f(e,l,r[0],r[1],{text:""}),r,"edit")};/* @__PURE__ */
1
+ import{TEXT_STYLE_CASES as e}from"../chunk-YHZSBL2N.js";import{selectionToVisible as t,selectionToSource as n,richLayout as r,createHistory as l,colorRunOf as o,textRange as a,selectionBox as s,placeWindow as c,offsetOrigin as i,visibleArea as u,ColorWindow as d,markPress as p,pasteToMarkup as m,richInput as h,editVisible as f,MARKUP_CLIPBOARD_TYPE as g,markupOfRange as y}from"../chunk-23VM4PMV.js";export{ColorWindow,MARKUP_CLIPBOARD_TYPE,TYPING_BURST_MS,colorRunOf,createHistory,editVisible,markupOfRange,newLine,pasteToMarkup,richInput,richLayout,selectionToSource,selectionToVisible,setBullet,startCanvasTyping,textMap,toSource,toSourceStart,toVisible}from"../chunk-23VM4PMV.js";import{DEFAULT_COPY_WORDS as v}from"../chunk-B4JN227A.js";import{FieldNumber as b}from"../chunk-2XMHLXMA.js";import{FieldSelect as S}from"../chunk-G3GWAP5R.js";import"../chunk-WRFD4EXD.js";import{SettingsSwitch as k,SettingsField as x,SettingsSegmented as w}from"../chunk-36LVP5WD.js";import{GoldTextInput as E}from"../chunk-H4UMY7QF.js";import{useWords as C}from"../chunk-MFIRYGHW.js";import{registerModalEscapeInterceptor as D,textToolbarRows as N,TextToolbar as L,LinkPicker as O,Tooltip as T,IconButton as R}from"efficient-shell/ui";export{TextToolbar}from"efficient-shell/ui";import{useRef as M,useState as P,useLayoutEffect as K,useEffect as V,useId as F}from"react";import{RETIRED_MARKS as H,applyMark as j,marksIn as B,STANDARD_MARKUP as $,listIn as z,colorIn as W,spanFor as A,findLink as I,colorOver as U,setList as Y,unlinkAt as q,removeLink as G,linkOver as _,writeLink as X}from"efficient-shell/markup";import{jsxs as Z,jsx as J,Fragment as Q}from"react/jsx-runtime";import{ParagraphSpacingIcon as ee,LetterSpacingIcon as te,LineSpacingIcon as ne,TextSizeIcon as re,AlignJustifyIcon as le,AlignRightIcon as oe,AlignCenterIcon as ae,AlignLeftIcon as se,StylesIcon as ce,TypeIcon as ie,AlignmentIcon as ue,ListFormatIcon as de,CaseIcon as pe,ItalicIcon as me,NumberedListIcon as he,ListIcon as fe,ListNoneIcon as ge,CaseLowerIcon as ye,CaseCapitalizedIcon as ve,CaseUpperIcon as be,CaseNormalIcon as Se}from"efficient-shell/icons/efficient";function ke(e,t){const n=t?.selectionStart??e.length;return{start:n,end:t?.selectionEnd??n}}function xe(e,t,n,r=j){const{start:l,end:o}=ke(e,n);return r(e,l,o,t)}function we(e,t,n){const{start:r,end:l}=ke(e,n),o=r+t.length;return{text:e.slice(0,r)+t+e.slice(l),selectionStart:o,selectionEnd:o}}function Ee(e,t,n,r){switch(t){case"bold":return e.createElement("strong");case"italic":return e.createElement("em");case"strike":return e.createElement("s");case"underline":return e.createElement("u");case"sup":return e.createElement("sup");case"sub":return e.createElement("sub");case"color":{const t=e.createElement("span");return t.className="es-rich-color",r&&(t.dataset.color=r,t.title=r.startsWith("#")?r.toUpperCase():r,t.style.color=r.startsWith("#")?r:`var(--es-color-${r}, inherit)`),t}case"link":{const t=e.createElement("a");return t.className="es-rich-link",n&&(t.title=n),t}default:{const n=e.createElement("span");return n.className="highlight"===t||"accent"===t?"es-rich-emphasis":`es-rich-${t}`,n}}}function Ce(e,t,n,r){const l=e.layout.lines;if(n===t)return r>=e.lines.length?e.layout.text.length:l[r].vis;const o=e.lines.findIndex(e=>e===n||e.contains(n));if(-1===o)return 0;const a=t.ownerDocument.createRange();a.setStart(e.lines[o],0);try{a.setEnd(n,r)}catch{return l[o].vis}return l[o].vis+Math.min(a.toString().length,l[o].text.length)}function De(e,t){const n=e.layout.lines;let r=n.length-1;for(let e=0;e<n.length;e+=1)if(t<=n[e].vis+n[e].text.length){r=e;break}let l=Math.max(0,t-n[r].vis);const o=e.lines[r].ownerDocument.createTreeWalker(e.lines[r],4);let a=o.nextNode(),s=null;for(;a;){if(l<=a.data.length)return[a,l];l-=a.data.length,s=a,a=o.nextNode()}return s?[s,s.data.length]:[e.lines[r],0]}function Ne({value:e,rules:l,multiline:o,readOnly:a=!1,placeholder:s,ariaLabel:c,handle:i,onEdit:u,onSelect:d,onHistory:p,onFormat:v,pending:b,onCommit:S,onCancel:k}){const x=M(null),w=M(null),E=M(null),C=M(null),D=M(null),N=M(e),[L,O]=P(0),T=M({value:e,rules:l,multiline:o,readOnly:a,pending:b,onEdit:u,onHistory:p,onFormat:v});T.current={value:e,rules:l,multiline:o,readOnly:a,pending:b,onEdit:u,onHistory:p,onFormat:v};const R=()=>{const e=x.current,t=w.current,n=e?.ownerDocument.getSelection();if(!(e&&t&&n&&0!==n.rangeCount&&n.anchorNode&&e.contains(n.anchorNode)))return null;const r=Ce(t,e,n.anchorNode,n.anchorOffset),l=n.focusNode&&e.contains(n.focusNode)?Ce(t,e,n.focusNode,n.focusOffset):r;return r<=l?[r,l]:[l,r]},F=(e,t)=>{const n=x.current,r=w.current;if(!n||!r)return;const[l,o]=De(r,e),[a,s]=De(r,t);n.ownerDocument.getSelection()?.setBaseAndExtent(l,o,a,s)};i.current={getSource(){const e=R(),t=w.current;if(!e||!t)return null;const[r,l]=n(t.layout,e[0],e[1]);return{start:r,end:l}},setSource(e,t,n){C.current={text:n,src:[e,t]},O(e=>e+1)},focus(){x.current?.focus()},rangeOf(e,n){const r=x.current,l=w.current;if(!r||!l)return null;const[o,a]=t(l.layout,e,n),[s,c]=De(l,o),[i,u]=De(l,a),d=r.ownerDocument.createRange();return d.setStart(s,c),d.setEnd(i,u),d}},K(()=>{const n=x.current;if(!n||D.current)return;const o=C.current?null:R();w.current=function(e,t){const n=e.ownerDocument;e.replaceChildren();const r=t.lines.map(t=>{const r=n.createElement("div");r.className=null!=t.number?"es-rich-line is-numbered":t.bullet?"es-rich-line is-bullet":"es-rich-line",null!=t.number&&(r.dataset.number=t.number);const l=[],o=()=>l.length?l[l.length-1].el:r;let a=null;for(const e of t.chars){let t=0;for(;t<l.length&&t<e.marks.length&&l[t].id===e.marks[t].id;)t+=1;(l.length>t||e.marks.length>t)&&(a=null),l.length=t;for(let r=t;r<e.marks.length;r+=1){const t=Ee(n,e.marks[r].kind,e.marks[r].href,e.marks[r].color);o().appendChild(t),l.push({id:e.marks[r].id,el:t})}a||(a=n.createTextNode(""),o().appendChild(a)),a.data+=e.ch}return 0===t.chars.length&&r.appendChild(n.createElement("br")),e.appendChild(r),r});return{layout:t,lines:r}}(n,r(e,l)),E.current=e;const a=C.current;if(!a||a.text!==e)return void(o&&n.ownerDocument.activeElement===n&&F(o[0],Math.min(o[1],w.current.layout.text.length)));C.current=null;const s=w.current.layout,[c,i]=a.vis??t(s,a.src[0],a.src[1]);n.ownerDocument.activeElement!==n&&n.focus(),F(c,i)},[e,l,L]);const H=(e,t,r)=>{const l=w.current,[o,a]=n(l.layout,t[0],t[1]);C.current={text:e.text,vis:[e.caret,e.caret]},e.text!==T.current.value?T.current.onEdit(e.text,{start:o,end:a},r):O(e=>e+1)};V(()=>{const e=x.current;if(!e)return;const t=t=>{const{value:n,rules:r,multiline:l,readOnly:o,pending:a}=T.current;if("insertCompositionText"===t.inputType)return;if(t.preventDefault(),o)return;const s=w.current,c=R();if(!s||!c)return;const i="function"==typeof t.getTargetRanges?t.getTargetRanges()[0]:void 0,u=i&&!i.collapsed?[Ce(s,e,i.startContainer,i.startOffset),Ce(s,e,i.endContainer,i.endOffset)]:null,d=h({value:n,rules:r,multiline:l,inputType:t.inputType,data:t.data??t.dataTransfer?.getData("text/plain")??"",html:t.dataTransfer?.getData("text/html"),doc:e.ownerDocument,sel:c,target:u,pending:a});d&&("history"!==d.kind?"format"!==d.kind?H(d.edit,d.range,d.kind):T.current.onFormat(d.style):T.current.onHistory(d.dir))},n=()=>{D.current||O(e=>e+1)};return e.addEventListener("beforeinput",t),e.addEventListener("input",n),()=>{e.removeEventListener("beforeinput",t),e.removeEventListener("input",n)}},[]),V(()=>{const e=x.current;if(!e)return;const t=e.ownerDocument,n=()=>{const e=i.current?.getSource();e&&d(e)};return t.addEventListener("selectionchange",n),()=>t.removeEventListener("selectionchange",n)});const j=(t,n=!1)=>{const r=R();if(!r||r[0]===r[1])return;t.preventDefault();const o=w.current;t.clipboardData.setData("text/plain",o.layout.text.slice(r[0],r[1])),t.clipboardData.setData(g,y(e,l,r[0],r[1])),n&&!a&&H(f(e,l,r[0],r[1],{text:""}),r,"edit")};/* @__PURE__ */
2
2
  return Z("div",{className:"es-rich-wrap",children:[s&&""===e?/* @__PURE__ */J("div",{className:"es-rich-placeholder","aria-hidden":"true",children:s}):null,
3
- /* @__PURE__ */J("div",{ref:x,className:`es-rich${o?" is-multiline":" is-single"}${a?" is-off":""}`,contentEditable:!a,suppressContentEditableWarning:!0,role:"textbox","aria-multiline":o,"aria-label":i,"aria-readonly":a||void 0,"aria-placeholder":s,tabIndex:a?-1:0,spellCheck:!0,onFocus:()=>{N.current=e},onBlur:()=>{e!==N.current&&S?.(e),N.current=e},onKeyDown:t=>{if("Escape"===t.key)return t.preventDefault(),k?.(N.current),void(N.current=e);"Enter"!==t.key||o||(t.preventDefault(),e!==N.current&&S?.(e),N.current=e)},onCompositionStart:()=>{const e=R()??[0,0];D.current={from:e[0],to:e[1]}},onCompositionEnd:e=>{const t=D.current;if(D.current=null,!t)return;const{value:n,rules:r,pending:l}=T.current;e.data?B(f(n,r,t.from,t.to,{text:e.data,add:l?.add,drop:l?.drop,color:l?.color}),[t.from,t.to],"type"):O(e=>e+1)},onCopy:e=>F(e),onCut:e=>F(e,!0),onPaste:t=>{if(t.preventDefault(),a)return;const n=R();if(!n)return;const r=t.clipboardData.getData(g),s=r?o?r:r.replace(/\s*\r?\n\s*/g," "):m({html:t.clipboardData.getData("text/html"),text:t.clipboardData.getData("text/plain")},{doc:t.currentTarget.ownerDocument,multiline:o,rules:l});B(f(e,l,n[0],n[1],{markup:s}),n,"edit")}})]})}var Le={fontSize:{key:"fontSize",nameKey:"fontSize",icon:/* @__PURE__ */J(re,{}),unit:"px",step:1,shiftStep:10,min:5},lineHeight:{key:"lineHeight",nameKey:"lineHeight",icon:/* @__PURE__ */J(ne,{}),unit:"%",step:1,shiftStep:10,min:50,max:250,scale:100},letterSpacing:{key:"letterSpacing",nameKey:"letterSpacing",icon:/* @__PURE__ */J(te,{}),unit:"px",step:.1,shiftStep:1,min:-10},paragraphSpacing:{key:"paragraphSpacing",nameKey:"paragraphSpacing",icon:/* @__PURE__ */J(ee,{}),unit:"px",step:1,shiftStep:10,min:0}};function Oe(e,t){return void 0===e?void 0:Number((e*t).toFixed(6))}function Te({cells:e,words:t,readOnly:n=!1}){const r=t??v.cells,l=j();/* @__PURE__ */
4
- return J("div",{className:"es-copy-cells-fit",children:/* @__PURE__ */J("div",{className:"es-copy-cells",children:e.map(e=>{const t=e.scale??1,o=e.name??(e.nameKey?r[e.nameKey]:e.key),a=e.unit??"",s=e.step??1,i=`${l}-${e.key}`;/* @__PURE__ */
3
+ /* @__PURE__ */J("div",{ref:x,className:`es-rich${o?" is-multiline":" is-single"}${a?" is-off":""}`,contentEditable:!a,suppressContentEditableWarning:!0,role:"textbox","aria-multiline":o,"aria-label":c,"aria-readonly":a||void 0,"aria-placeholder":s,tabIndex:a?-1:0,spellCheck:!0,onFocus:()=>{N.current=e},onBlur:()=>{e!==N.current&&S?.(e),N.current=e},onKeyDown:t=>{if("Escape"===t.key)return t.preventDefault(),k?.(N.current),void(N.current=e);"Enter"!==t.key||o||(t.preventDefault(),e!==N.current&&S?.(e),N.current=e)},onCompositionStart:()=>{const e=R()??[0,0];D.current={from:e[0],to:e[1]}},onCompositionEnd:e=>{const t=D.current;if(D.current=null,!t)return;const{value:n,rules:r,pending:l}=T.current;e.data?H(f(n,r,t.from,t.to,{text:e.data,add:l?.add,drop:l?.drop,color:l?.color}),[t.from,t.to],"type"):O(e=>e+1)},onCopy:e=>j(e),onCut:e=>j(e,!0),onPaste:t=>{if(t.preventDefault(),a)return;const n=R();if(!n)return;const r=t.clipboardData.getData(g),s=r?o?r:r.replace(/\s*\r?\n\s*/g," "):m({html:t.clipboardData.getData("text/html"),text:t.clipboardData.getData("text/plain")},{doc:t.currentTarget.ownerDocument,multiline:o,rules:l});H(f(e,l,n[0],n[1],{markup:s}),n,"edit")}})]})}var Le={fontSize:{key:"fontSize",nameKey:"fontSize",icon:/* @__PURE__ */J(re,{}),unit:"px",step:1,shiftStep:10,min:5},lineHeight:{key:"lineHeight",nameKey:"lineHeight",icon:/* @__PURE__ */J(ne,{}),unit:"%",step:1,shiftStep:10,min:50,max:250,scale:100},letterSpacing:{key:"letterSpacing",nameKey:"letterSpacing",icon:/* @__PURE__ */J(te,{}),unit:"px",step:.1,shiftStep:1,min:-10},paragraphSpacing:{key:"paragraphSpacing",nameKey:"paragraphSpacing",icon:/* @__PURE__ */J(ee,{}),unit:"px",step:1,shiftStep:10,min:0}};function Oe(e,t){return void 0===e?void 0:Number((e*t).toFixed(6))}function Te({cells:e,words:t,readOnly:n=!1}){const r=t??v.cells,l=F();/* @__PURE__ */
4
+ return J("div",{className:"es-copy-cells-fit",children:/* @__PURE__ */J("div",{className:"es-copy-cells",children:e.map(e=>{const t=e.scale??1,o=e.name??(e.nameKey?r[e.nameKey]:e.key),a=e.unit??"",s=e.step??1,c=`${l}-${e.key}`;/* @__PURE__ */
5
5
  return Z("div",{className:"es-copy-cell",children:[
6
- /* @__PURE__ */J("label",{className:"es-field-label es-copy-cell-name",htmlFor:i,children:o}),
7
- /* @__PURE__ */J(b,{id:i,value:Oe(e.value,t),styleValue:Oe(e.styleValue,t),onChange:n=>e.onChange(void 0===n?void 0:Number((n/t).toFixed(6))),min:e.min,max:e.max,step:s,shiftStep:e.shiftStep,icon:e.icon,unit:a||void 0,steppers:"compact",readOnly:n,ariaLabel:o,title:r.tip({name:o,step:s,unit:a})})]},e.key)})})})}function Re({target:e,onChange:t}){const n=H(null);return M(()=>{const t=n.current,r=e.current;t&&r&&r.value===t.text&&(n.current=null,r.focus(),r.setSelectionRange(t.start,t.end))}),r=>{const l=r(e.current);t(l.text),n.current={start:l.selectionStart,end:l.selectionEnd,text:l.text}}}var He=/* @__PURE__ */new Set([...B,"clear"]);function Ke(e){if(!e)return;const t=e.split("+"),n=t.pop().toUpperCase();return["Meta",...t.map(e=>e[0].toUpperCase()+e.slice(1)),n].join("+")}function Me({tools:e,onApply:t,disabled:n=!1,actions:r,ariaLabel:l,pressed:o,open:a=null}){const s=C("copy",v),i=("string"==typeof e[0]?e:e.map(e=>e.style)).filter(e=>!He.has(e));/* @__PURE__ */
8
- return J(D,{"aria-label":l??s.formatting,offered:new Set(i),pressed:o??{},onMark:e=>t(e),linkOpen:"link"===a,list:i.includes("bullet")||i.includes("number")?{pressed:null,onList:e=>t(e)}:void 0,last:r,disabled:n})}function Pe({value:e,onChange:t,onCommit:n,onCancel:r,multiline:h=!1,placeholder:f,ariaLabel:g,className:y,readOnly:b=!1,rules:S,tools:x=[],writeMark:w,align:T,actions:R,toolbar:B,barLabel:ee,renderFooter:te,inputRef:ne,barShows:re="always",richText:le=!0,defaultShowMarks:oe=!1,colors:ae,cells:se,letterCase:ie,lastTool:ce}){const ue=C("copy",v),de=H(null),pe=ne??de,[me,he]=K(!1),[fe,ge]=K(null),ye=H(l()).current,ve=H(null);P(()=>{const t=ve.current;t&&e===t.to?ve.current=null:t&&e===t.from||(ve.current=null,ye.reset())},[e,ye]);const be=n=>{ve.current={from:ve.current?.from??e,to:n},t(n)},Se=t=>({text:e,start:t?.selectionStart??fe?.start??e.length,end:t?.selectionEnd??fe?.end??e.length}),[ke,Ee]=K(oe),Ce=le&&!(h&&ke),De=H(null),Le=j(),[Oe,Ke]=K(null),[Me,Pe]=K(!1),je=()=>{if(!Ce)return pe.current;const e=De.current?.getSource()??fe;return e?{selectionStart:e.start,selectionEnd:e.end}:null},Be=Re({target:pe,onChange:be}),Fe=e=>(ge({start:e.selectionStart,end:e.selectionEnd}),e),$e=(t,n)=>{if(!Ce)return void Be(e=>(n&&ye.record(Se(e),"edit",Date.now()),Fe(t(e))));const r=je(),l=Fe(t(r));n&&ye.record(Se(r),"edit",Date.now()),Ke(null),l.text!==e&&be(l.text),De.current?.setSource(l.selectionStart,l.selectionEnd,l.text)},Ve=e=>$e(e,!0),ze=e=>$e(t=>{const n=Se(t),r=ye[e](n);return r?{text:r.text,selectionStart:r.start,selectionEnd:r.end}:{text:n.text,selectionStart:n.start,selectionEnd:n.end}},!1),Ue=H(null);M(()=>{const t=Ue.current;t&&(Ue.current=null,Ce?De.current?.setSource(t.start,t.end,e):(pe.current?.focus(),pe.current?.setSelectionRange(t.start,t.end),ge(t)))},[Ce]);const[We,Ae]=K(null),Ye=S??V,Ie=("string"==typeof x[0]?x:x.map(e=>e.style)).filter(e=>!He.has(e)),Ge={};if(fe){const t=$(e,fe.start,fe.end,Ye);for(const e of Ie){const n=t.has(e)||"highlight"===e&&t.has("accent");Ge[e]=!!Oe?.add.includes(e)||!Oe?.drop.includes(e)&&n}Ge.link=t.has("link")}const qe=()=>{const t=je(),n=t?.selectionStart??e.length;return{start:n,end:t?.selectionEnd??n}},_e=t=>{if("link"!==t&&W(0,t)){const{start:n,end:r}=qe();if(n===r&&!Ce)return void Ve(n=>xe(e,t,n,(e,t,n,r)=>F(e,t,n,r,Ye,ue.placeholders)));const l=p({value:e,rules:Ye,start:n,end:r,style:t,pending:Oe});return void("pending"===l.kind?Ke(l.pending):Ve(()=>l.result))}if("link"!==t){const n=w??((e,t,n,r)=>F(e,t,n,r,V,ue.placeholders));return void Ve(r=>xe(e,t,r,n))}const n=je(),r=n?.selectionStart??e.length,l=n?.selectionEnd??r;Pe(!1),Ae({start:r,end:l,link:A(e,r,l)})},Xe=Boolean(fe&&fe.start!==fe.end),Ze=fe?z(e,fe.start,fe.end,Ye):null,Je=fe?Oe&&void 0!==Oe.color&&Oe.at===fe.start?Oe.color:U(e,fe.start,fe.end,Ye):null,Qe=o(Je,ae),et=t=>{Ce?t?De.current?.setSource(t.start,t.end,e):De.current?.focus():(pe.current?.focus(),t&&pe.current?.setSelectionRange(t.start,t.end))},tt=()=>{const e=We;Ae(null),et(e?{start:e.start,end:e.end}:fe)},nt=()=>{const e=lt.current,t=Boolean(e&&e.querySelector(".es-copy-colors")?.contains(e.ownerDocument.activeElement));Pe(!1),t&&et(fe)},rt=H(nt);rt.current=nt,P(()=>{if(Me)return N(e=>{const t=lt.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(rt.current(),!0)},()=>lt.current?.querySelector(".es-copy-colors"))},[Me]);const lt=H(null),ot=Me||null!==We;P(()=>{const e=lt.current;if(!ot||!e)return;const t=e.ownerDocument,n=()=>{Pe(!1),Ae(null)},r=t=>{e.contains(t.target)||n()};let l;const o=r=>{const o=r.relatedTarget;o?e.contains(o)||n():(clearTimeout(l),l=setTimeout(()=>{const r=t.activeElement;t.hasFocus()&&r&&r!==t.body&&!e.contains(r)&&n()},0))};return t.addEventListener("pointerdown",r,!0),e.addEventListener("focusout",o),()=>{clearTimeout(l),t.removeEventListener("pointerdown",r,!0),e.removeEventListener("focusout",o)}},[ot]);const at=We??(Me?fe??{start:e.length,end:e.length}:null),st=H(()=>{});st.current=()=>{const e=lt.current,t=e?.querySelector(".rosh-tb-wrap > .es-copy-pop");if(!e||!t||!at)return;const n=Ce?null:e.querySelector(".es-gold-layer"),r=Ce?De.current?.rangeOf(at.start,at.end)??null:n?a(n,at.start,at.end):null,l=r?.endContainer,o=l?1===l.nodeType?l:l.parentElement:null,d=r?s(r,o?.closest(".es-rich-line, .es-gold-layer")??null):null;if(!d)return;const p=i({anchor:d,size:{width:t.offsetWidth,height:t.offsetHeight},within:e.getBoundingClientRect(),clip:u(e),parent:c(t)});t.style.top=`${p.top}px`,t.style.left=`${p.left}px`,t.style.setProperty("--es-pop-point",`${p.point}px`),t.dataset.side=p.above?"above":"below"},M(()=>{const e=lt.current;if(!ot||!e)return;const t=()=>st.current();t();const n=e.ownerDocument.defaultView;n?.addEventListener("resize",t);const r=e.querySelector(".rosh-tb-wrap > .es-copy-pop"),l=n?.ResizeObserver,o=l&&r?new l(t):null;return o&&r&&o.observe(r),()=>{n?.removeEventListener("resize",t),o?.disconnect()}},[ot,Me,We,at?.start,at?.end,Ce]);const it="always"===re||me||null!==We||Me,ct=ae&&ae.length>0?{run:Qe,open:Me,onToggle:()=>{Ae(null),Me?nt():Pe(!0)}}:void 0,ut=it?ce?ce({className:"rosh-tb-btn",disabled:b,selected:Xe,keepCaret:e=>e.preventDefault(),insert:t=>Ve(n=>we(e,t,n))}):"classic"===B?R:void 0:void 0,dt=new Set(Ie),pt=T?{value:T.value,allow:T.allow,onChange:T.onChange,disabled:T.disabled}:void 0,mt={pressed:Ze,onList:t=>{const{start:n,end:r}=qe(),l=z(e,n,r,Ye);Ve(()=>I(e,n,r,l===t?null:t,Ye))}},ht=L({offered:dt,color:ct,last:ut,alignment:pt,list:mt,letterCase:ie});/* @__PURE__ */
9
- return Z("div",{ref:lt,className:"es-copy"+(y?` ${y}`:""),onFocus:()=>he(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||he(!1)},onKeyDown:e=>{const t=e.target===pe.current||Boolean(e.target.closest?.(".es-rich"));if(b||!t)return;if(e.altKey||e.metaKey===e.ctrlKey)return;const n=e.key.toLowerCase(),r="KeyZ"===e.code||"z"===n,l=("KeyY"===e.code||"y"===n)&&!e.shiftKey;if(r||l)return e.preventDefault(),e.stopPropagation(),void ze(l||e.shiftKey?"redo":"undo");const o={b:"bold",i:"italic",u:"underline",k:"link"}[`${e.shiftKey?"shift+":""}${n}`];o&&Ie.includes(o)&&(e.preventDefault(),e.stopPropagation(),_e(o))},onPaste:t=>{const n=pe.current;if(b||!n||t.target!==n)return;t.preventDefault();const r=m({html:t.clipboardData.getData("text/html"),text:t.clipboardData.getData("text/plain")},{doc:n.ownerDocument,multiline:h,rules:Ye});Ve(t=>we(e,r,t))},style:ae&&ae.length>0?Object.fromEntries(ae.map(e=>[`--es-color-${e.name}`,e.value])):void 0,onSelect:()=>{const t=pe.current;t&&t.ownerDocument.activeElement===t&&ge({start:t.selectionStart??e.length,end:t.selectionEnd??e.length})},children:[it&&(ht.words||ht.paragraph)?
10
- /* @__PURE__ */J(D,{className:"es-copy-toolbar","aria-label":ee??ue.formatting,offered:dt,pressed:Ge,onMark:e=>_e(e),color:ct,linkOpen:null!==We,last:ut,alignment:pt,list:mt,letterCase:ie,disabled:b,windows:/* @__PURE__ */Z(Q,{children:[Me&&ae&&ae.length>0?/* @__PURE__ */J(d,{colors:ae,current:Je,words:ue.colors??v.colors,onPick:t=>{const{start:n,end:r}=qe();if(n!==r)Ve(()=>Y(e,n,r,t,Ye));else{if(!Ce)return;Ke({add:Oe?.add??[],drop:Oe?.drop??[],color:t,at:n})}}}):null,We?We&&/* @__PURE__ */J(O,{className:"es-copy-link es-copy-pop",value:We.link?.href??"",onApply:t=>{const n=We;Ae(null),Ve(()=>Ce?_(e,n.start,n.end,t,Ye):X(e,n.start,n.end,t))},onRemove:We.link?()=>{const t=We.link,n=We;Ae(null),t&&Ve(()=>Ce?G(e,n.start,n.end,Ye):q(e,t))}:void 0,onCancel:tt}):null]})}):null,se&&se.length>0?/* @__PURE__ */J(Te,{cells:se,words:ue.cells??v.cells,readOnly:b}):null,Ce?/* @__PURE__ */J(Ne,{value:e,rules:Ye,multiline:h,readOnly:b,placeholder:f,ariaLabel:g,handle:De,pending:Oe??void 0,onEdit:(t,n,r)=>{ye.record({text:e,start:n.start,end:n.end},r,Date.now()),Ke(null),be(t)},onSelect:e=>{ge(t=>t&&t.start===e.start&&t.end===e.end?t:e),!Oe||e.start===Oe.at&&e.end===Oe.at||Ke(null)},onHistory:ze,onFormat:e=>{Ie.includes(e)&&_e(e)},onCommit:n,onCancel:r}):/* @__PURE__ */J(E,{value:e,onInput:e=>{ye.record(Se(null),"type",Date.now()),be(e)},onCommit:n,onCancel:r,multiline:h,placeholder:f,ariaLabel:g,rules:S,disabled:b,inputRef:pe,className:"es-copy-box"}),te?te({focused:me,insert:t=>Ve(n=>we(e,t,n))}):null,le&&h?
6
+ /* @__PURE__ */J("label",{className:"es-field-label es-copy-cell-name",htmlFor:c,children:o}),
7
+ /* @__PURE__ */J(b,{id:c,value:Oe(e.value,t),styleValue:Oe(e.styleValue,t),onChange:n=>e.onChange(void 0===n?void 0:Number((n/t).toFixed(6))),min:e.min,max:e.max,step:s,shiftStep:e.shiftStep,icon:e.icon,unit:a||void 0,steppers:"compact",readOnly:n,ariaLabel:o,title:r.tip({name:o,step:s,unit:a})})]},e.key)})})})}function Re({target:e,onChange:t}){const n=M(null);return K(()=>{const t=n.current,r=e.current;t&&r&&r.value===t.text&&(n.current=null,r.focus(),r.setSelectionRange(t.start,t.end))}),r=>{const l=r(e.current);t(l.text),n.current={start:l.selectionStart,end:l.selectionEnd,text:l.text}}}var Me=/* @__PURE__ */new Set([...H,"clear"]);function Pe({value:e,onChange:t,onCommit:n,onCancel:r,multiline:h=!1,placeholder:f,ariaLabel:g,className:y,readOnly:b=!1,rules:S,tools:x=[],writeMark:w,align:T,actions:R,toolbar:H,barLabel:ee,renderFooter:te,inputRef:ne,barShows:re="always",richText:le=!0,defaultShowMarks:oe=!1,colors:ae,cells:se,letterCase:ce,lastTool:ie}){const ue=C("copy",v),de=M(null),pe=ne??de,[me,he]=P(!1),[fe,ge]=P(null),ye=M(l()).current,ve=M(null);V(()=>{const t=ve.current;t&&e===t.to?ve.current=null:t&&e===t.from||(ve.current=null,ye.reset())},[e,ye]);const be=n=>{ve.current={from:ve.current?.from??e,to:n},t(n)},Se=t=>({text:e,start:t?.selectionStart??fe?.start??e.length,end:t?.selectionEnd??fe?.end??e.length}),[ke,Ee]=P(oe),Ce=le&&!(h&&ke),De=M(null),Le=F(),[Oe,Pe]=P(null),[Ke,Ve]=P(!1),Fe=()=>{if(!Ce)return pe.current;const e=De.current?.getSource()??fe;return e?{selectionStart:e.start,selectionEnd:e.end}:null},He=Re({target:pe,onChange:be}),je=e=>(ge({start:e.selectionStart,end:e.selectionEnd}),e),Be=(t,n)=>{if(!Ce)return void He(e=>(n&&ye.record(Se(e),"edit",Date.now()),je(t(e))));const r=Fe(),l=je(t(r));n&&ye.record(Se(r),"edit",Date.now()),Pe(null),l.text!==e&&be(l.text),De.current?.setSource(l.selectionStart,l.selectionEnd,l.text)},$e=e=>Be(e,!0),ze=e=>Be(t=>{const n=Se(t),r=ye[e](n);return r?{text:r.text,selectionStart:r.start,selectionEnd:r.end}:{text:n.text,selectionStart:n.start,selectionEnd:n.end}},!1),We=M(null);K(()=>{const t=We.current;t&&(We.current=null,Ce?De.current?.setSource(t.start,t.end,e):(pe.current?.focus(),pe.current?.setSelectionRange(t.start,t.end),ge(t)))},[Ce]);const[Ae,Ie]=P(null),Ue=S??$,Ye=("string"==typeof x[0]?x:x.map(e=>e.style)).filter(e=>!Me.has(e)),qe={};if(fe){const t=B(e,fe.start,fe.end,Ue);for(const e of Ye){const n=t.has(e)||"highlight"===e&&t.has("accent");qe[e]=!!Oe?.add.includes(e)||!Oe?.drop.includes(e)&&n}qe.link=t.has("link")}const Ge=()=>{const t=Fe(),n=t?.selectionStart??e.length;return{start:n,end:t?.selectionEnd??n}},_e=t=>{if("link"!==t&&A(0,t)){const{start:n,end:r}=Ge();if(n===r&&!Ce)return void $e(n=>xe(e,t,n,(e,t,n,r)=>j(e,t,n,r,Ue,ue.placeholders)));const l=p({value:e,rules:Ue,start:n,end:r,style:t,pending:Oe});return void("pending"===l.kind?Pe(l.pending):$e(()=>l.result))}if("link"!==t){const n=w??((e,t,n,r)=>j(e,t,n,r,$,ue.placeholders));return void $e(r=>xe(e,t,r,n))}const n=Fe(),r=n?.selectionStart??e.length,l=n?.selectionEnd??r;Ve(!1),Ie({start:r,end:l,link:I(e,r,l)})},Xe=Boolean(fe&&fe.start!==fe.end),Ze=fe?z(e,fe.start,fe.end,Ue):null,Je=fe?Oe&&void 0!==Oe.color&&Oe.at===fe.start?Oe.color:W(e,fe.start,fe.end,Ue):null,Qe=o(Je,ae),et=t=>{Ce?t?De.current?.setSource(t.start,t.end,e):De.current?.focus():(pe.current?.focus(),t&&pe.current?.setSelectionRange(t.start,t.end))},tt=()=>{const e=Ae;Ie(null),et(e?{start:e.start,end:e.end}:fe)},nt=()=>{const e=lt.current,t=Boolean(e&&e.querySelector(".es-copy-colors")?.contains(e.ownerDocument.activeElement));Ve(!1),t&&et(fe)},rt=M(nt);rt.current=nt,V(()=>{if(Ke)return D(e=>{const t=lt.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(rt.current(),!0)},()=>lt.current?.querySelector(".es-copy-colors"))},[Ke]);const lt=M(null),ot=Ke||null!==Ae;V(()=>{const e=lt.current;if(!ot||!e)return;const t=e.ownerDocument,n=()=>{Ve(!1),Ie(null)},r=t=>{e.contains(t.target)||n()};let l;const o=r=>{const o=r.relatedTarget;o?e.contains(o)||n():(clearTimeout(l),l=setTimeout(()=>{const r=t.activeElement;t.hasFocus()&&r&&r!==t.body&&!e.contains(r)&&n()},0))};return t.addEventListener("pointerdown",r,!0),e.addEventListener("focusout",o),()=>{clearTimeout(l),t.removeEventListener("pointerdown",r,!0),e.removeEventListener("focusout",o)}},[ot]);const at=Ae??(Ke?fe??{start:e.length,end:e.length}:null),st=M(()=>{});st.current=()=>{const e=lt.current,t=e?.querySelector(".rosh-tb-wrap > .es-copy-pop");if(!e||!t||!at)return;const n=Ce?null:e.querySelector(".es-gold-layer"),r=Ce?De.current?.rangeOf(at.start,at.end)??null:n?a(n,at.start,at.end):null,l=r?.endContainer,o=l?1===l.nodeType?l:l.parentElement:null,d=r?s(r,o?.closest(".es-rich-line, .es-gold-layer")??null):null;if(!d)return;const p=c({anchor:d,size:{width:t.offsetWidth,height:t.offsetHeight},within:e.getBoundingClientRect(),clip:u(e),parent:i(t)});t.style.top=`${p.top}px`,t.style.left=`${p.left}px`,t.style.setProperty("--es-pop-point",`${p.point}px`),t.dataset.side=p.above?"above":"below"},K(()=>{const e=lt.current;if(!ot||!e)return;const t=()=>st.current();t();const n=e.ownerDocument.defaultView;n?.addEventListener("resize",t);const r=e.querySelector(".rosh-tb-wrap > .es-copy-pop"),l=n?.ResizeObserver,o=l&&r?new l(t):null;return o&&r&&o.observe(r),()=>{n?.removeEventListener("resize",t),o?.disconnect()}},[ot,Ke,Ae,at?.start,at?.end,Ce]);const ct="always"===re||me||null!==Ae||Ke,it=ae&&ae.length>0?{run:Qe,open:Ke,onToggle:()=>{Ie(null),Ke?nt():Ve(!0)}}:void 0,ut=ct?ie?ie({className:"rosh-tb-btn",disabled:b,selected:Xe,keepCaret:e=>e.preventDefault(),insert:t=>$e(n=>we(e,t,n))}):"classic"===H?R:void 0:void 0,dt=new Set(Ye),pt=T?{value:T.value,allow:T.allow,onChange:T.onChange,disabled:T.disabled}:void 0,mt={pressed:Ze,onList:t=>{const{start:n,end:r}=Ge(),l=z(e,n,r,Ue);$e(()=>Y(e,n,r,l===t?null:t,Ue))}},ht=N({offered:dt,color:it,last:ut,alignment:pt,list:mt,letterCase:ce});/* @__PURE__ */
8
+ return Z("div",{ref:lt,className:"es-copy"+(y?` ${y}`:""),onFocus:()=>he(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||he(!1)},onKeyDown:e=>{const t=e.target===pe.current||Boolean(e.target.closest?.(".es-rich"));if(b||!t)return;if(e.altKey||e.metaKey===e.ctrlKey)return;const n=e.key.toLowerCase(),r="KeyZ"===e.code||"z"===n,l=("KeyY"===e.code||"y"===n)&&!e.shiftKey;if(r||l)return e.preventDefault(),e.stopPropagation(),void ze(l||e.shiftKey?"redo":"undo");const o={b:"bold",i:"italic",u:"underline",k:"link"}[`${e.shiftKey?"shift+":""}${n}`];o&&Ye.includes(o)&&(e.preventDefault(),e.stopPropagation(),_e(o))},onPaste:t=>{const n=pe.current;if(b||!n||t.target!==n)return;t.preventDefault();const r=m({html:t.clipboardData.getData("text/html"),text:t.clipboardData.getData("text/plain")},{doc:n.ownerDocument,multiline:h,rules:Ue});$e(t=>we(e,r,t))},style:ae&&ae.length>0?Object.fromEntries(ae.map(e=>[`--es-color-${e.name}`,e.value])):void 0,onSelect:()=>{const t=pe.current;t&&t.ownerDocument.activeElement===t&&ge({start:t.selectionStart??e.length,end:t.selectionEnd??e.length})},children:[ct&&(ht.words||ht.paragraph)?
9
+ /* @__PURE__ */J(L,{className:"es-copy-toolbar","aria-label":ee??ue.formatting,offered:dt,pressed:qe,onMark:e=>_e(e),color:it,linkOpen:null!==Ae,last:ut,alignment:pt,list:mt,letterCase:ce,disabled:b,windows:/* @__PURE__ */Z(Q,{children:[Ke&&ae&&ae.length>0?/* @__PURE__ */J(d,{colors:ae,current:Je,words:ue.colors??v.colors,onPick:t=>{const{start:n,end:r}=Ge();if(n!==r)$e(()=>U(e,n,r,t,Ue));else{if(!Ce)return;Pe({add:Oe?.add??[],drop:Oe?.drop??[],color:t,at:n})}}}):null,Ae?Ae&&/* @__PURE__ */J(O,{className:"es-copy-link es-copy-pop",value:Ae.link?.href??"",onApply:t=>{const n=Ae;Ie(null),$e(()=>Ce?_(e,n.start,n.end,t,Ue):X(e,n.start,n.end,t))},onRemove:Ae.link?()=>{const t=Ae.link,n=Ae;Ie(null),t&&$e(()=>Ce?q(e,n.start,n.end,Ue):G(e,t))}:void 0,onCancel:tt}):null]})}):null,se&&se.length>0?/* @__PURE__ */J(Te,{cells:se,words:ue.cells??v.cells,readOnly:b}):null,Ce?/* @__PURE__ */J(Ne,{value:e,rules:Ue,multiline:h,readOnly:b,placeholder:f,ariaLabel:g,handle:De,pending:Oe??void 0,onEdit:(t,n,r)=>{ye.record({text:e,start:n.start,end:n.end},r,Date.now()),Pe(null),be(t)},onSelect:e=>{ge(t=>t&&t.start===e.start&&t.end===e.end?t:e),!Oe||e.start===Oe.at&&e.end===Oe.at||Pe(null)},onHistory:ze,onFormat:e=>{Ye.includes(e)&&_e(e)},onCommit:n,onCancel:r}):/* @__PURE__ */J(E,{value:e,onInput:e=>{ye.record(Se(null),"type",Date.now()),be(e)},onCommit:n,onCancel:r,multiline:h,placeholder:f,ariaLabel:g,rules:S,disabled:b,inputRef:pe,className:"es-copy-box"}),te?te({focused:me,insert:t=>$e(n=>we(e,t,n))}):null,le&&h?
11
10
  /* @__PURE__ */Z("div",{className:"es-copy-marks",children:[
12
- /* @__PURE__ */J(k,{checked:ke,onChange:()=>{const e=je();Ue.current=e&&null!==e.selectionStart&&null!==e.selectionEnd?{start:e.selectionStart,end:e.selectionEnd}:fe,Ke(null),Ee(e=>!e)},ariaLabelledBy:Le,disabled:b}),
13
- /* @__PURE__ */J("span",{id:Le,className:"es-copy-marks-label",children:ue.showMarks??"Show marks"})]}):null]})}var je=["left","center","right","justify"],Be=v.align,Fe={left:/* @__PURE__ */J(se,{}),center:/* @__PURE__ */J(ae,{}),right:/* @__PURE__ */J(oe,{}),justify:/* @__PURE__ */J(le,{})},$e={three:{labelsPx:94.5,widestLabelPx:39.94},four:{labelsPx:140,widestLabelPx:44}};function Ve(e,t=Be){return je.filter(t=>e.includes(t)).map(e=>({id:e,label:t[e],icon:Fe[e],title:t[e]}))}var ze=["none","bullet","number"],Ue=e,We={none:/* @__PURE__ */J(ge,{}),bullet:/* @__PURE__ */J(fe,{}),number:/* @__PURE__ */J(he,{})},Ae={none:/* @__PURE__ */J(Se,{}),upper:/* @__PURE__ */J(be,{}),capitalize:/* @__PURE__ */J(ve,{}),lower:/* @__PURE__ */J(ye,{})};function Ye({label:e,icon:t,answers:n,names:r,glyphs:l,row:o,readOnly:a}){const s=o.value||o.styleValue||"";/* @__PURE__ */
14
- return J(x,{label:e,icon:t,children:/* @__PURE__ */J(w,{ariaLabel:e,value:s,disabled:a,onChange:e=>{a||o.onChange(function(e,t){return t===e.value||""===e.value&&t===e.styleValue?"":t}(o,e))},options:n.map(e=>({id:e,label:l[e],title:r[e]}))})})}function Ie({kept:e,keptHint:t,readOnly:n=!1,style:r,font:l,italic:o,cells:a,align:s,list:i,letterCase:c}){const u=C("copy",v),d={...v.panel,...u.panel},p=r&&!n?[r.onEditStyles&&{label:d.editStyles,onSelect:r.onEditStyles},r.onUpdateStyle&&{label:d.updateStyle,onSelect:r.onUpdateStyle}].filter(e=>!!e):[],m=!!o&&(o.value??o.styleValue??!1),h=o?/* @__PURE__ */J(T,{content:d.italic,children:/* @__PURE__ */J(R,{size:"sm",variant:"ghost","aria-label":d.italic,"aria-pressed":m,disabled:n,onClick:()=>{if(n)return;const e=!m;o.onChange(e===(o.styleValue??!1)?void 0:e)},children:/* @__PURE__ */J(me,{})})}):null;/* @__PURE__ */
11
+ /* @__PURE__ */J(k,{checked:ke,onChange:()=>{const e=Fe();We.current=e&&null!==e.selectionStart&&null!==e.selectionEnd?{start:e.selectionStart,end:e.selectionEnd}:fe,Pe(null),Ee(e=>!e)},ariaLabelledBy:Le,disabled:b}),
12
+ /* @__PURE__ */J("span",{id:Le,className:"es-copy-marks-label",children:ue.showMarks??"Show marks"})]}):null]})}var Ke=["left","center","right","justify"],Ve=v.align,Fe={left:/* @__PURE__ */J(se,{}),center:/* @__PURE__ */J(ae,{}),right:/* @__PURE__ */J(oe,{}),justify:/* @__PURE__ */J(le,{})},He={three:{labelsPx:94.5,widestLabelPx:39.94},four:{labelsPx:140,widestLabelPx:44}};function je(e,t=Ve){return Ke.filter(t=>e.includes(t)).map(e=>({id:e,label:t[e],icon:Fe[e],title:t[e]}))}var Be=["none","bullet","number"],$e=e,ze={none:/* @__PURE__ */J(ge,{}),bullet:/* @__PURE__ */J(fe,{}),number:/* @__PURE__ */J(he,{})},We={none:/* @__PURE__ */J(Se,{}),upper:/* @__PURE__ */J(be,{}),capitalize:/* @__PURE__ */J(ve,{}),lower:/* @__PURE__ */J(ye,{})};function Ae({label:e,icon:t,answers:n,names:r,glyphs:l,row:o,readOnly:a}){const s=o.value||o.styleValue||"";/* @__PURE__ */
13
+ return J(x,{label:e,icon:t,children:/* @__PURE__ */J(w,{ariaLabel:e,value:s,disabled:a,onChange:e=>{a||o.onChange(function(e,t){return t===e.value||""===e.value&&t===e.styleValue?"":t}(o,e))},options:n.map(e=>({id:e,label:l[e],title:r[e]}))})})}function Ie({kept:e,keptHint:t,readOnly:n=!1,style:r,font:l,italic:o,cells:a,align:s,list:c,letterCase:i}){const u=C("copy",v),d={...v.panel,...u.panel},p=r&&!n?[r.onEditStyles&&{label:d.editStyles,onSelect:r.onEditStyles},r.onUpdateStyle&&{label:d.updateStyle,onSelect:r.onUpdateStyle}].filter(e=>!!e):[],m=!!o&&(o.value??o.styleValue??!1),h=o?/* @__PURE__ */J(T,{content:d.italic,children:/* @__PURE__ */J(R,{size:"sm",variant:"ghost","aria-label":d.italic,"aria-pressed":m,disabled:n,onClick:()=>{if(n)return;const e=!m;o.onChange(e===(o.styleValue??!1)?void 0:e)},children:/* @__PURE__ */J(me,{})})}):null;/* @__PURE__ */
15
14
  return Z("div",{className:"es-tpp",children:[e?/* @__PURE__ */Z("div",{className:"es-tpp-kept",children:[
16
- /* @__PURE__ */J(Pe,{...e,readOnly:n||e.readOnly}),t?/* @__PURE__ */J("p",{className:"es-field-hint",children:t}):null]}):null,r?/* @__PURE__ */J(x,{label:d.style,icon:/* @__PURE__ */J(ie,{}),children:/* @__PURE__ */J(S,{ariaLabel:d.style,value:r.value,options:r.options,onChange:r.onChange,changed:r.changed,footer:p,readOnly:n})}):null,l?/* @__PURE__ */J(x,{label:d.font,icon:/* @__PURE__ */J(ce,{}),children:/* @__PURE__ */Z("div",{className:"es-tpp-font",children:[
15
+ /* @__PURE__ */J(Pe,{...e,readOnly:n||e.readOnly}),t?/* @__PURE__ */J("p",{className:"es-field-hint",children:t}):null]}):null,r?/* @__PURE__ */J(x,{label:d.style,icon:/* @__PURE__ */J(ce,{}),children:/* @__PURE__ */J(S,{ariaLabel:d.style,value:r.value,options:r.options,onChange:r.onChange,changed:r.changed,footer:p,readOnly:n})}):null,l?/* @__PURE__ */J(x,{label:d.font,icon:/* @__PURE__ */J(ie,{}),children:/* @__PURE__ */Z("div",{className:"es-tpp-font",children:[
17
16
  /* @__PURE__ */J("div",{className:"es-tpp-font-select",children:/* @__PURE__ */J(S,{ariaLabel:d.font,value:l.value||void 0,placeholder:l.styleValue,options:l.options,onChange:l.onChange,searchable:l.searchable,readOnly:n})}),h]})}):h?
18
- /* @__PURE__ */J(x,{label:d.italic,icon:/* @__PURE__ */J(ce,{}),children:/* @__PURE__ */J("div",{className:"es-tpp-font",children:h})}):null,a?.length?/* @__PURE__ */J(Te,{cells:a,words:u.cells,readOnly:n}):null,s?/* @__PURE__ */J(Ye,{label:u.alignment,icon:/* @__PURE__ */J(ue,{}),answers:je.filter(e=>!s.allow||s.allow.includes(e)),names:u.align,glyphs:Fe,row:s,readOnly:n}):null,i?/* @__PURE__ */J(Ye,{label:d.list,icon:/* @__PURE__ */J(de,{}),answers:ze,names:d.lists,glyphs:We,row:i,readOnly:n}):null,c?/* @__PURE__ */J(Ye,{label:d.capitalization,icon:/* @__PURE__ */J(pe,{}),answers:Ue,names:d.cases,glyphs:Ae,row:c,readOnly:n}):null]})}export{je as COPY_ALIGNS,$e as COPY_ALIGN_FIT,Fe as COPY_ALIGN_GLYPHS,Be as COPY_ALIGN_LABELS,Le as COPY_CELLS,Pe as CopyBox,Te as CopyCells,Me as MarkBar,Ne as RichBox,Ie as TextPartPanel,Ke as ariaShortcut,Ve as copyAlignOptions,we as insertSelection,xe as markSelection,Re as useCaretEdit};
17
+ /* @__PURE__ */J(x,{label:d.italic,icon:/* @__PURE__ */J(ie,{}),children:/* @__PURE__ */J("div",{className:"es-tpp-font",children:h})}):null,a?.length?/* @__PURE__ */J(Te,{cells:a,words:u.cells,readOnly:n}):null,s?/* @__PURE__ */J(Ae,{label:u.alignment,icon:/* @__PURE__ */J(ue,{}),answers:Ke.filter(e=>!s.allow||s.allow.includes(e)),names:u.align,glyphs:Fe,row:s,readOnly:n}):null,c?/* @__PURE__ */J(Ae,{label:d.list,icon:/* @__PURE__ */J(de,{}),answers:Be,names:d.lists,glyphs:ze,row:c,readOnly:n}):null,i?/* @__PURE__ */J(Ae,{label:d.capitalization,icon:/* @__PURE__ */J(pe,{}),answers:$e,names:d.cases,glyphs:We,row:i,readOnly:n}):null]})}export{Ke as COPY_ALIGNS,He as COPY_ALIGN_FIT,Fe as COPY_ALIGN_GLYPHS,Ve as COPY_ALIGN_LABELS,Le as COPY_CELLS,Pe as CopyBox,Te as CopyCells,Ne as RichBox,Ie as TextPartPanel,je as copyAlignOptions,we as insertSelection,xe as markSelection,Re as useCaretEdit};
@@ -84,6 +84,28 @@
84
84
  pointer-events: none;
85
85
  }
86
86
 
87
+ /* "DOUBLE-CLICK TO EDIT" (Lewis 2026-10-20, mockup v4 decision a): on the
88
+ selection's top-right corner, across its line (the layer hands it the
89
+ corner; it hangs left of it and is centred on the line); `.is-below` hangs
90
+ it under the bottom-right corner instead. Its surface is the shell's
91
+ (`solidSurfaceStyle`, inline); the size and words are the tooltip
92
+ bubble's. It takes no pointer: a click there is the block's. */
93
+ .es-canvas-hint {
94
+ position: absolute;
95
+ transform: translate(calc(-100% - var(--es-space-8, 8px)), -50%);
96
+ box-sizing: border-box;
97
+ padding: var(--es-space-4, 4px) var(--es-space-8, 8px);
98
+ border-radius: var(--radius-md);
99
+ font: 400 var(--text-xs, 12px) / 1.4 var(--es-font);
100
+ color: var(--es-text);
101
+ white-space: nowrap;
102
+ pointer-events: none;
103
+ z-index: 1;
104
+ }
105
+ .es-canvas-hint.is-below {
106
+ transform: translate(calc(-100% - var(--es-space-8, 8px)), var(--es-space-4, 4px));
107
+ }
108
+
87
109
  /* A ➕ INSERT POINT (./CanvasInsert, owner 2026-10-14): one look wherever the
88
110
  canvas offers to add — between sections and between, before and after the
89
111
  blocks of a box. The band only positions the chip and lets every other
@@ -3,8 +3,8 @@ import { HTMLAttributes, CSSProperties, ReactNode } from 'react';
3
3
  import { P as Place } from '../types-41704JE4.js';
4
4
  import { D as DragSession } from '../session-DSQFmIvx.js';
5
5
  export { a as DragHeld, c as createDragSession } from '../session-DSQFmIvx.js';
6
- export { B as Box, a as CanvasDragLayer, b as CanvasDragLayerProps, C as CanvasDragModel, c as CanvasDropTarget, d as CanvasSeam, e as CanvasSource, f as CanvasZone, E as EMPTY_MEASURE, H as HANDLE_GRACE_MS, M as MeasuredCanvas, g as MeasuredNode, h as canvasTarget, i as contains, j as gapInZone, k as gapLine, l as insertSeams, m as measureCanvas, p as pickSource, s as seamsBetween, n as sourcesAt } from '../CanvasDragLayer-CLb7j-CZ.js';
7
- import { D as DragWords } from '../words-BDignMl_.js';
6
+ export { B as Box, a as CanvasDragLayer, b as CanvasDragLayerProps, C as CanvasDragModel, c as CanvasDropTarget, d as CanvasSeam, e as CanvasSource, f as CanvasZone, E as EMPTY_MEASURE, H as HANDLE_GRACE_MS, M as MeasuredCanvas, g as MeasuredNode, h as canvasTarget, i as contains, j as gapInZone, k as gapLine, l as insertSeams, m as measureCanvas, p as pickSource, s as seamsBetween, n as sourcesAt } from '../CanvasDragLayer-dZCPbQCP.js';
7
+ import { D as DragWords } from '../words-CvwYvkJm.js';
8
8
  import '../watch-BTYOJpQU.js';
9
9
 
10
10
  /**
@@ -1 +1 @@
1
- export{AddPanel,CanvasDragLayer,CanvasInsert,EMPTY_MEASURE,HANDLE_GRACE_MS,canvasTarget,contains,gapInZone,gapLine,insertSeams,measureCanvas,pickSource,seamsBetween,sourcesAt}from"../chunk-QFVRMARS.js";import"../chunk-AYWN5NRH.js";export{AUTO_SCROLL_EDGE,AUTO_SCROLL_MAX_SPEED,autoScrollDelta,autoScrollSpeed,createDragSession,dropEffectFor,dropOnRow,frameScrollBox,gapToMoveIndex,isNoOpDrop,scrollBoxOf,scrollParent,startAutoScroll,stepGap,useTreeDrag}from"../chunk-67GNT6PF.js";import"../chunk-P2VEMZH5.js";import"../chunk-ILXP5VX5.js";import"../chunk-KRXQM65X.js";import"../chunk-NKB3KVAB.js";
1
+ export{AddPanel,CanvasDragLayer,CanvasInsert,EMPTY_MEASURE,HANDLE_GRACE_MS,canvasTarget,contains,gapInZone,gapLine,insertSeams,measureCanvas,pickSource,seamsBetween,sourcesAt}from"../chunk-POSLNRTO.js";import"../chunk-KAML3KQH.js";export{AUTO_SCROLL_EDGE,AUTO_SCROLL_MAX_SPEED,autoScrollDelta,autoScrollSpeed,createDragSession,dropEffectFor,dropOnRow,frameScrollBox,gapToMoveIndex,isNoOpDrop,scrollBoxOf,scrollParent,startAutoScroll,stepGap,useTreeDrag}from"../chunk-67GNT6PF.js";import"../chunk-P2VEMZH5.js";import"../chunk-X4T6JT3M.js";import"../chunk-KRXQM65X.js";import"../chunk-NKB3KVAB.js";
@@ -122,6 +122,32 @@
122
122
  outline: 2px solid var(--es-canvas-outline-colour);
123
123
  outline-offset: 4px;
124
124
  }
125
+ /* THE POINTER (Lewis 2026-10-20, mockup v4 decision c): on the canvas it is
126
+ the arrow — over words, and over the links and buttons the page drew, which
127
+ the canvas never follows — and the I-beam only inside the words being
128
+ typed. The grab hand is the handle's, in the layer over the canvas.
129
+ `!important`: the canvas holds the PAGE's own sheet, and its
130
+ `a { cursor: pointer }` and button rules would otherwise win. */
131
+ .es-canvas-content,
132
+ .es-canvas-content * {
133
+ cursor: default !important;
134
+ }
135
+ .es-canvas-content [data-es-typing],
136
+ .es-canvas-content [data-es-typing] * {
137
+ cursor: text !important;
138
+ }
139
+
140
+ /* A PLACEHOLDER FOR EMPTY WORDS (Lewis 2026-10-20, decision h): words the
141
+ page draws empty and marks `data-es-placeholder` (an Eyebrow switched on
142
+ before it has words) show that word, greyed, on the canvas only — drawn by
143
+ the canvas beside the words, never into them, so nothing is typed over it.
144
+ It goes with the first typed letter (`:empty`). */
145
+ .es-canvas-content [data-es-placeholder]:empty::before {
146
+ content: attr(data-es-placeholder);
147
+ opacity: 0.45;
148
+ pointer-events: none;
149
+ }
150
+
125
151
  /* …and the words themselves draw no focus ring: a contenteditable gets the
126
152
  browser's (`outline: auto`), which drew a second line inside the box on a
127
153
  page whose own sheet does not remove it (an email). */
@@ -1 +1 @@
1
- export{CanvasFrame,CanvasPassThroughContext,DEFAULT_UI,EaselCanvas,EaselProvider,EditDocument,bindUndoKeys,createEasel,createUseEasel,recordsByDefault,reduce,uiView,useEasel,useEaselApi,useEaselNodeOps,useSelectedFields,validSelection}from"../chunk-LPM2SCM4.js";import"../chunk-TBY3DFKS.js";import"../chunk-ECM5F6JJ.js";import"../chunk-YRLPFZW3.js";import"../chunk-NY7HHUGB.js";import"../chunk-B4JN227A.js";import"../chunk-MFIRYGHW.js";import"../chunk-ILXP5VX5.js";import"../chunk-KRXQM65X.js";import"../chunk-NKB3KVAB.js";
1
+ export{CanvasFrame,CanvasPassThroughContext,DEFAULT_UI,EaselCanvas,EaselProvider,EditDocument,bindUndoKeys,createEasel,createUseEasel,recordsByDefault,reduce,uiView,useEasel,useEaselApi,useEaselNodeOps,useSelectedFields,validSelection}from"../chunk-SMM3ST7A.js";import"../chunk-TBY3DFKS.js";import"../chunk-ECM5F6JJ.js";import"../chunk-YRLPFZW3.js";import"../chunk-23VM4PMV.js";import"../chunk-B4JN227A.js";import"../chunk-MFIRYGHW.js";import"../chunk-X4T6JT3M.js";import"../chunk-KRXQM65X.js";import"../chunk-NKB3KVAB.js";
@@ -402,10 +402,19 @@ type EaselToHostMessage =
402
402
  | {
403
403
  type: "storefront-editor:published";
404
404
  }
405
- /** A save failed (first failure of a retry run only). */
405
+ /** A save failed (first failure of a retry run only). The save icon says
406
+ * so too, so a host may stay quiet on it. */
406
407
  | {
407
408
  type: "storefront-editor:save-failed";
408
409
  }
410
+ /** Publish failed after its save landed: nothing went live, and the edits
411
+ * are kept as they were saved. `reason` is the failure's own words (the
412
+ * backend's, e.g. which part cannot go live), or null when it has none. The
413
+ * save icon is calm here, so the host says it. */
414
+ | {
415
+ type: "storefront-editor:publish-failed";
416
+ reason: string | null;
417
+ }
409
418
  /** The editor moved in place to another page (page targets only). */
410
419
  | {
411
420
  type: "storefront-editor:navigated";