efficient-easel 19.3.0 → 20.1.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 (112) hide show
  1. package/README.md +40 -3
  2. package/dist/{ScreenDocumentContext-D55vIrG3.d.ts → ScreenDocumentContext-CFJeqqKk.d.ts} +130 -2
  3. package/dist/blocks/index.d.ts +13 -2
  4. package/dist/canvas/index.d.ts +2 -0
  5. package/dist/canvas/index.js +1 -1
  6. package/dist/chunk-276MBG5P.js +2 -0
  7. package/dist/chunk-2E2SXDYQ.js +1 -0
  8. package/dist/{chunk-MS2U6MV5.js → chunk-2G6MAXPY.js} +1 -1
  9. package/dist/{chunk-67GNT6PF.js → chunk-3S5N4HLJ.js} +1 -1
  10. package/dist/chunk-47CD7ULN.js +1 -0
  11. package/dist/chunk-47PYYMFM.js +8 -0
  12. package/dist/{chunk-FMZGR7EG.js → chunk-5THLKXTH.js} +1 -1
  13. package/dist/{chunk-EZG3TGQ7.js → chunk-77IWWW6X.js} +1 -1
  14. package/dist/{chunk-VULUDKA3.js → chunk-7LYKFL3Q.js} +21 -21
  15. package/dist/{chunk-X3TYRF5V.js → chunk-BSHIQIZC.js} +1 -1
  16. package/dist/{chunk-LNHT2KPX.js → chunk-FHCKFOCD.js} +2 -2
  17. package/dist/{chunk-KWE5U6CE.js → chunk-H4JCMK36.js} +1 -1
  18. package/dist/{chunk-A6CY3TQ5.js → chunk-HBBXDGDD.js} +1 -1
  19. package/dist/chunk-HK6I3NVO.js +1 -0
  20. package/dist/{chunk-YRLPFZW3.js → chunk-IWCKVZHS.js} +1 -1
  21. package/dist/{chunk-KRXQM65X.js → chunk-K7BTCBWD.js} +1 -1
  22. package/dist/chunk-L55YIXDC.js +1 -0
  23. package/dist/chunk-LDEEFLE3.js +18 -0
  24. package/dist/chunk-LEZFSSQN.js +5 -0
  25. package/dist/chunk-LF3FUSCQ.js +1 -0
  26. package/dist/chunk-MQA7OFRA.js +2 -0
  27. package/dist/chunk-OECWLNKJ.js +2 -0
  28. package/dist/{chunk-YOXKBOZX.js → chunk-PEDR7G3K.js} +1 -1
  29. package/dist/{chunk-7OKL7HDV.js → chunk-PI6RFJR4.js} +1 -1
  30. package/dist/chunk-ROPYFLNZ.js +15 -0
  31. package/dist/chunk-RVZJ52EP.js +63 -0
  32. package/dist/{chunk-VPFNZ7TB.js → chunk-U66YKDAR.js} +1 -1
  33. package/dist/{chunk-5DPIGWUL.js → chunk-UJ46J7QW.js} +1 -1
  34. package/dist/{chunk-RYNBSKE7.js → chunk-UNVKPVZW.js} +1 -1
  35. package/dist/chunk-VANKQVOW.js +8 -0
  36. package/dist/{chunk-ME4V6PML.js → chunk-WBFLSCTI.js} +4 -4
  37. package/dist/chunk-XFYFKITX.js +1 -0
  38. package/dist/{chunk-XWFH2NHZ.js → chunk-ZEH6QLBH.js} +2 -2
  39. package/dist/copy/copy.css +1 -1
  40. package/dist/copy/index.js +12 -12
  41. package/dist/data/index.js +1 -1
  42. package/dist/drag/index.js +1 -1
  43. package/dist/draw/index.d.ts +2 -1
  44. package/dist/draw/index.js +1 -1
  45. package/dist/easel/index.js +1 -1
  46. package/dist/fields/index.js +1 -1
  47. package/dist/gold/gold.css +4 -1
  48. package/dist/node-ops/index.js +1 -1
  49. package/dist/panel/index.d.ts +7 -8
  50. package/dist/panel/index.js +9 -9
  51. package/dist/rail/index.d.ts +2 -2
  52. package/dist/rail/index.js +1 -1
  53. package/dist/rail/rail.css +1 -1
  54. package/dist/render/index.d.ts +12 -3
  55. package/dist/render/index.js +5 -5
  56. package/dist/repeat-Czi-6zPX.d.ts +49 -0
  57. package/dist/screen/components/AddBlockRow.js +1 -1
  58. package/dist/screen/components/AddSidePanel.js +1 -1
  59. package/dist/screen/components/MediaPopup.js +1 -1
  60. package/dist/screen/components/NodeContextMenu.d.ts +1 -1
  61. package/dist/screen/components/NodeContextMenu.js +1 -1
  62. package/dist/screen/components/PageEditGuardNotices.js +1 -1
  63. package/dist/screen/components/SaveControls.d.ts +1 -1
  64. package/dist/screen/components/ScreenChrome.js +1 -1
  65. package/dist/screen/components/ScreenDocumentContext.d.ts +1 -1
  66. package/dist/screen/components/ScreenDocumentContext.js +1 -1
  67. package/dist/screen/components/ScreenMount.d.ts +1 -1
  68. package/dist/screen/components/ScreenMount.js +1 -1
  69. package/dist/screen/components/ScreenStoreProvider.d.ts +1 -1
  70. package/dist/screen/components/ScreenStoreProvider.js +1 -1
  71. package/dist/screen/components/SectionScreenShell.js +16 -16
  72. package/dist/screen/components/usePartBridge.d.ts +1 -1
  73. package/dist/screen/components/usePartBridge.js +1 -1
  74. package/dist/screen/index.d.ts +1 -1
  75. package/dist/screen/index.js +1 -1
  76. package/dist/screen/lib/admin-bridge.js +1 -1
  77. package/dist/screen/lib/content/view-tiers.d.ts +81 -1
  78. package/dist/screen/lib/content/view-tiers.js +1 -1
  79. package/dist/screen/lib/document-addressing.d.ts +1 -1
  80. package/dist/screen/lib/document-contract.d.ts +12 -5
  81. package/dist/screen/lib/host-inbound.js +1 -1
  82. package/dist/screen/lib/host.d.ts +1 -1
  83. package/dist/screen/lib/host.js +1 -1
  84. package/dist/screen/lib/key-scope.js +1 -1
  85. package/dist/screen/lib/media-panel.d.ts +1 -1
  86. package/dist/screen/lib/media-panel.js +1 -1
  87. package/dist/screen/lib/media-picker.d.ts +1 -1
  88. package/dist/screen/lib/media-picker.js +1 -1
  89. package/dist/screen/lib/puck/preview-dom.js +1 -1
  90. package/dist/screen/lib/puck/style-clipboard.d.ts +1 -1
  91. package/dist/screen/lib/puck/use-section-ops.js +1 -1
  92. package/dist/screen/lib/screen-parts.d.ts +1 -1
  93. package/dist/screen/lib/screen-parts.js +1 -1
  94. package/dist/shell/shell.css +4 -2
  95. package/dist/strings/index.js +1 -1
  96. package/dist/text-styles/index.js +36 -36
  97. package/dist/text-styles/model.d.ts +8 -0
  98. package/package.json +3 -3
  99. package/dist/chunk-36LVP5WD.js +0 -9
  100. package/dist/chunk-4ES5JGGX.js +0 -1
  101. package/dist/chunk-4VJATVVR.js +0 -1
  102. package/dist/chunk-CNKVVHDA.js +0 -63
  103. package/dist/chunk-DWIOHQG7.js +0 -1
  104. package/dist/chunk-H5YLVKGA.js +0 -1
  105. package/dist/chunk-KOVJODTY.js +0 -14
  106. package/dist/chunk-M62P4IQK.js +0 -2
  107. package/dist/chunk-NKB3KVAB.js +0 -1
  108. package/dist/chunk-OGBYHQE6.js +0 -5
  109. package/dist/chunk-U3JP4VGF.js +0 -2
  110. package/dist/chunk-U6LF5YVK.js +0 -8
  111. package/dist/chunk-ZO3UUK45.js +0 -18
  112. /package/dist/{chunk-X4T6JT3M.js → chunk-QIDRJH3S.js} +0 -0
package/README.md CHANGED
@@ -614,6 +614,23 @@ block's `render` gets its props, `puck`, and each slot as a component —
614
614
  plain `<div>`, and `puck` carries exactly what Puck's client `<Render>` gives at
615
615
  each level. A type the config does not know draws nothing.
616
616
 
617
+ **A slot says how many blocks it holds** (Unreleased). Each slot component
618
+ has a read-only `blockCount`: the blocks it draws. A block of a type the
619
+ config does not know draws nothing, so it is not counted. The editor's canvas
620
+ (`efficient-easel/easel`) puts the same number on its slots, for the same
621
+ document, and writes it again when the slot's list changes (the slot stays
622
+ the same component). So a block can choose what to draw without calling the
623
+ slot or reading the editor's store:
624
+
625
+ ```tsx
626
+ render: ({ template: Template }) =>
627
+ Template.blockCount ? <Template /> : <PlainList />,
628
+ ```
629
+
630
+ The `SlotComponent` type in `efficient-easel/blocks` has it as optional, so a
631
+ slot written by hand in a test still types; `render`'s own `SlotComponent`
632
+ always has it.
633
+
617
634
  `className` (0.95.0) is an opt-in class for that top-level wrapper, for a host
618
635
  whose stylesheet has to reach it: `<Render … className="page" />`. Left out,
619
636
  the wrapper is bare and the markup is Puck's.
@@ -632,15 +649,34 @@ allow a published page to take easel through `render`, `draw` and
632
649
  `readHidable`, the part ids (`encodePartId`, `decodePartId`), the field
633
650
  markers (`TEXT_FIELD_MARKER`, `textFieldIdentifier`, …), the text control
634
651
  kinds, the slot-child names, the content-tree walkers (`childSlotsOf`,
635
- `locateNode`, `pinnedDuplicateIndices`, …), the view tiers, the preview
652
+ `locateNode`, `pinnedDuplicateIndices`, …), the view tiers and the
653
+ per-view value engine (below), the preview
636
654
  event names, and the one letter-case code (`TEXT_STYLE_CASES`,
637
655
  `TEXT_STYLE_CASE_CSS`, `isTextStyleCase`, `textStyleCaseCss`,
638
- `textStyleCaseOfCss`, the same functions as `text-styles/model`). No React
639
- and no import: a server component may use it.
656
+ `textStyleCaseOfCss`, the same functions as `text-styles/model`), and the
657
+ names of the wrapper round each drawn copy of a template
658
+ (`REPEAT_ATTRIBUTE` = `data-sf-repeat`, `REPEAT_INDEX_ATTRIBUTE` =
659
+ `data-sf-repeat-index`; see `canvas` below). No React and no import: a
660
+ server component may use it.
640
661
  - `efficient-easel/draw/client` — the React pieces: `PreviewDeviceContext` /
641
662
  `usePreviewDevice`, `PreviewPartsProvider` / `usePreviewParts`,
642
663
  `createPreviewSelectionContext`, and `UiIcon`.
643
664
 
665
+ **Each view owns its values** (three views, the plan approved 2026-10-23).
666
+ A setting keeps its desktop value. Tablet and Phone MAY store their own, under
667
+ `tabletKey(key)` (`<key>Tablet`) and `phoneKey(key)` (`<key>Phone`, the key
668
+ web-builder already stores). A view with nothing stored is auto (`isAuto`):
669
+ `resolveViewValue(kind, desktop, tablet?, phone?)` gives what each view draws,
670
+ by `AUTO_RULES[kind]`; Phone's parent is Tablet, Tablet's is Desktop. The kinds:
671
+ `spacing` (Tablet x0.75, Phone x0.5 of Desktop, on the 4px scale: 80 → 60 →
672
+ 40), `columns` (at most 2, then 1), `stack` (Phone stacked), `textSize`
673
+ (x0.85 and x0.7, to 1px), `heightMode` (Phone: px → fit, Screen % stays),
674
+ `heightPx` (x0.75) and `same`. The breakpoints are `VIEW_TABLET_MIN` 720 and
675
+ `VIEW_DESKTOP_MIN` 1100. A text style's `sizeTablet` (absent = auto) sits
676
+ beside `sizePhone`. Nothing draws with the engine yet: the rendering and the
677
+ panel come in later releases. Never store what `resolveViewValue` returns for
678
+ an auto view.
679
+
644
680
  Nothing moved: each name is re-exported from the module that defines it, and
645
681
  the `screen/…` paths still work. `tests/draw-leaf-safety.test.ts` holds each
646
682
  graph to an exact list of files and imports.
@@ -672,6 +708,7 @@ const tick = useCanvasLayout(canvas); // re-m
672
708
  | `fitCanvas({ available, width, maxScale })` | The canvas width and the scale that fits it into the pane. |
673
709
  | `isTypingTarget(target)` | Is this key pressed somewhere a person types (text inputs, textarea, select, editable regions)? A shortcut must stay out. |
674
710
  | `nodeIdAt(target, attribute?)` | The block a pointer event landed on. |
711
+ | `REPEAT_ATTRIBUTE`, `REPEAT_INDEX_ATTRIBUTE`, `isRepeatCopy`, `mainCopyOf`, `queryMainCopy`, `queryAllCopies` | A template drawn once per data row: each copy is in `<div data-sf-repeat="<ownerId>:template" data-sf-repeat-index={i}>`, index 0 the main copy. The outline goes on every copy (`queryAllCopies`), a lookup by id reads the main one (`queryMainCopy`), and only the main copy's lists take drops. With no `data-sf-repeat` each answers what `querySelector` answers. |
675
712
  | `watchCanvasFrame(root, onChange, options)` | The watcher the hook wraps, for code outside React. |
676
713
  | `setCanvasNonce(document, nonce)` | The CSP nonce every `<style>` created in that canvas document carries (0.95.0). `CanvasFrame`'s `nonce` prop sets it; a host that builds its own frame calls it. |
677
714
 
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { ReactNode, RefObject } from 'react';
2
+ import { ComponentType, ReactNode, RefObject } from 'react';
3
3
  import { Data } from './blocks/index.js';
4
4
  import { EaselDocumentAdapter, EaselCapabilities } from './screen/lib/document-contract.js';
5
5
  import { SaveStatus } from './screen/lib/document-switch.js';
@@ -272,6 +272,85 @@ type EaselToHostMessage =
272
272
  type: "storefront-editor:save-as-template";
273
273
  siteId: string;
274
274
  slug: string;
275
+ }
276
+ /** The selection changed: what is selected, as the host may name it to a
277
+ * person or an assistant, or null when nothing is. Sent on every change. */
278
+ | {
279
+ type: "storefront-editor:selection";
280
+ selection: EaselSelection | null;
281
+ }
282
+ /** The answer to `request-document`, with its id: the open document as the
283
+ * editor has it now (unsaved edits included) and the block types it knows. */
284
+ | {
285
+ type: "storefront-editor:document";
286
+ requestId: string;
287
+ document: unknown;
288
+ blocks: Record<string, EaselBlockType>;
289
+ }
290
+ /** The answer to `apply-page-edits` or `undo-page-edits`, with its id. */
291
+ | {
292
+ type: "storefront-editor:page-edits-result";
293
+ requestId: string;
294
+ applied: boolean;
295
+ reason: string | null;
296
+ };
297
+ /**
298
+ * What is selected, as the editor names it. `label` is for a person
299
+ * ("Hero slider · slide 1"); `blockId` is the block's own id, and `path`,
300
+ * when a part of the block is open (one slide), says where in its props
301
+ * ("slides[0]"), else "".
302
+ */
303
+ interface EaselSelection {
304
+ blockId: string;
305
+ type: string;
306
+ label: string;
307
+ path: string;
308
+ }
309
+ /**
310
+ * A block type as the editor describes it to a host: its label and its fields,
311
+ * the plain part of each (no render, no custom field's component), so the
312
+ * description is JSON.
313
+ */
314
+ interface EaselBlockType {
315
+ label: string;
316
+ fields: Record<string, EaselFieldDescription>;
317
+ }
318
+ interface EaselFieldDescription {
319
+ type: string;
320
+ label?: string;
321
+ options?: {
322
+ value: unknown;
323
+ label?: string;
324
+ }[];
325
+ arrayFields?: Record<string, EaselFieldDescription>;
326
+ objectFields?: Record<string, EaselFieldDescription>;
327
+ }
328
+ /**
329
+ * One change a host asks the editor to make to the open document. Every
330
+ * change is recorded, so the editor's undo takes it back. `set_props` writes
331
+ * fields of a block, at `path` inside it when given ("slides[0]");
332
+ * `insert_block`, `remove_block` and `move_block` work among the document's
333
+ * top-level blocks, `after` or `before` naming the block it goes next to.
334
+ */
335
+ type PageEditOp = {
336
+ op: "set_props";
337
+ block_id: string;
338
+ path: string;
339
+ props: Record<string, unknown>;
340
+ } | {
341
+ op: "insert_block";
342
+ type: string;
343
+ props: Record<string, unknown>;
344
+ after: string;
345
+ before: string;
346
+ } | {
347
+ op: "remove_block";
348
+ block_id: string;
349
+ } | {
350
+ op: "move_block";
351
+ block_id: string;
352
+ after: string;
353
+ before: string;
275
354
  };
276
355
  /** Every message a host sends the editor, by name. */
277
356
  type HostToEaselMessage = {
@@ -308,6 +387,30 @@ type HostToEaselMessage = {
308
387
  } | {
309
388
  type: "storefront-editor:media-pick-cancelled";
310
389
  requestId: string;
390
+ }
391
+ /** Ask for the open document; answered by `document` with the same id. */
392
+ | {
393
+ type: "storefront-editor:request-document";
394
+ requestId: string;
395
+ }
396
+ /** Apply these changes to the open document, as one step of its history, or
397
+ * none of them; answered by `page-edits-result` with the same id. */
398
+ | {
399
+ type: "storefront-editor:apply-page-edits";
400
+ requestId: string;
401
+ ops: PageEditOp[];
402
+ }
403
+ /** Take back the step `apply-page-edits` with this id made, when it is still
404
+ * the last one; answered by `page-edits-result` with the same id. */
405
+ | {
406
+ type: "storefront-editor:undo-page-edits";
407
+ requestId: string;
408
+ }
409
+ /** Show or hide the editor's right-hand panel (the host puts something of
410
+ * its own there, an assistant). */
411
+ | {
412
+ type: "storefront-editor:set-right-panel";
413
+ shown: boolean;
311
414
  };
312
415
  type EaselMessageType = EaselToHostMessage["type"];
313
416
  type PayloadOf<T extends EaselMessageType> = Omit<Extract<EaselToHostMessage, {
@@ -368,6 +471,28 @@ interface EaselHost {
368
471
  * own listeners close those things, as they always have.
369
472
  */
370
473
  claimEscape?(handler: (e: KeyboardEvent) => boolean): () => void;
474
+ /** What the host puts in the screen's own chrome (`EaselHostPanels`). */
475
+ readonly panels?: EaselHostPanels;
476
+ }
477
+ /**
478
+ * WHAT A HOST PUTS IN THE SCREEN (JARVIS in the Storefront editor, Victor Mau
479
+ * 2026-10-24). Fixed for the life of a host, like the rest of it: the host
480
+ * drives what they show from its own state, so turning a panel on or off
481
+ * never remounts the editor.
482
+ *
483
+ * - `Toolbar` is drawn first in the top bar's right cluster, before the save
484
+ * icon: the admin portal's JARVIS button.
485
+ * - `useRight` is called as a hook while the screen draws, every time. When
486
+ * it returns something, that stands in the inspector's place inside the
487
+ * right panel, at the panel's width and with its grip; selecting a block
488
+ * opens the panel onto it, not onto the inspector. The panel's own hide and
489
+ * show strip still work (a host that wants it open sends
490
+ * `storefront-editor:set-right-panel`). `null` gives the panel back to the
491
+ * inspector, exactly as it was.
492
+ */
493
+ interface EaselHostPanels {
494
+ Toolbar?: ComponentType;
495
+ useRight?: () => ReactNode | null;
371
496
  }
372
497
  /** The host of a surface nobody embeds: nothing sent, nothing heard, an address
373
498
  * that stays put. */
@@ -404,6 +529,9 @@ declare function createEaselHost(options: {
404
529
  /** How the screen takes Escape before the embedder's window does
405
530
  * (`EaselHost.claimEscape`, 0.105.0). Left out, it claims nothing. */
406
531
  claimEscape?: (handler: (e: KeyboardEvent) => boolean) => () => void;
532
+ /** What the host puts in the screen's chrome (`EaselHost.panels`). Left out,
533
+ * the screen draws only its own. */
534
+ panels?: EaselHostPanels;
407
535
  }): {
408
536
  host: EaselHost;
409
537
  deliver: (message: HostToEaselMessage) => void;
@@ -615,4 +743,4 @@ declare function ScreenDocumentProvider({ target, addressing: handed, onHostMess
615
743
  children: ReactNode;
616
744
  }): react.JSX.Element;
617
745
 
618
- export { type AnyDocumentAddressing as A, DETACHED_EASEL_HOST as D, type EaselHost as E, type HostPickedMedia as H, type InboundHostMessage as I, NO_DOCUMENT_ADDRESSING as N, type PickedMediaSource as P, type SectionScreenTarget as S, type DocumentAddressing as a, type EaselHostAddress as b, EaselHostContext as c, EaselHostProvider as d, type EaselMessageType as e, type EaselToHostMessage as f, type HostToEaselMessage as g, type SendToHost as h, createEaselHost as i, useHostEscape as j, type AnyScreenTarget as k, type DocumentTarget as l, ScreenDocumentContext as m, ScreenDocumentProvider as n, type ScreenDocumentValue as o, type ScreenTarget as p, useScreenDocument as q, useEaselHost as u };
746
+ export { type AnyDocumentAddressing as A, DETACHED_EASEL_HOST as D, type EaselBlockType as E, type HostPickedMedia as H, type InboundHostMessage as I, NO_DOCUMENT_ADDRESSING as N, type PageEditOp as P, type SectionScreenTarget as S, type DocumentAddressing as a, type EaselFieldDescription as b, type EaselHost as c, type EaselHostAddress as d, EaselHostContext as e, type EaselHostPanels as f, EaselHostProvider as g, type EaselMessageType as h, type EaselSelection as i, type EaselToHostMessage as j, type HostToEaselMessage as k, type PickedMediaSource as l, type SendToHost as m, createEaselHost as n, useHostEscape as o, type AnyScreenTarget as p, type DocumentTarget as q, ScreenDocumentContext as r, ScreenDocumentProvider as s, type ScreenDocumentValue as t, useEaselHost as u, type ScreenTarget as v, useScreenDocument as w };
@@ -227,8 +227,19 @@ type DropZoneProps = {
227
227
  className?: string;
228
228
  collisionAxis?: DragAxis;
229
229
  };
230
- /** A slot, as a block's `render` receives it: draw it with `<Content />`. */
231
- type SlotComponent = (props?: Omit<DropZoneProps, 'zone'>) => ReactNode;
230
+ /**
231
+ * A slot, as a block's `render` receives it: draw it with `<Content />`.
232
+ *
233
+ * `blockCount` is how many blocks the slot draws — a block of a type nobody
234
+ * registered is not counted. It is the same number on the published page
235
+ * (`efficient-easel/render`) and in the editor's canvas, so a block can choose
236
+ * what to draw (`Content.blockCount ? <Content /> : fallback`) without
237
+ * calling the slot or reading the editor's store. Both always set it; it is
238
+ * optional here only so a slot written by hand (a test, a story) still types.
239
+ */
240
+ type SlotComponent = ((props?: Omit<DropZoneProps, 'zone'>) => ReactNode) & {
241
+ readonly blockCount?: number;
242
+ };
232
243
  /** The `puck` prop every block's `render` receives. */
233
244
  type BlockContext = {
234
245
  renderDropZone: FC<DropZoneProps>;
@@ -1,6 +1,7 @@
1
1
  import { RefObject } from 'react';
2
2
  import { C as CanvasTarget, W as WatchOptions } from '../watch-BTYOJpQU.js';
3
3
  export { B as BLOCK_SELECTOR, a as CANVAS_SELECTOR, L as LIST_SELECTOR, i as isFrameReady, w as watchCanvasFrame } from '../watch-BTYOJpQU.js';
4
+ export { R as REPEAT_ATTRIBUTE, a as REPEAT_INDEX_ATTRIBUTE, i as isRepeatCopy, m as mainCopyOf, q as queryAllCopies, b as queryMainCopy } from '../repeat-Czi-6zPX.js';
4
5
 
5
6
  /**
6
7
  * The small facts every canvas surface needs, written once — pure DOM, no
@@ -26,6 +27,7 @@ export { B as BLOCK_SELECTOR, a as CANVAS_SELECTOR, L as LIST_SELECTOR, i as isF
26
27
  declare function isTypingTarget(target: EventTarget | null): boolean;
27
28
  /** The attribute on every block the canvas draws (Puck 0.20's name, kept). */
28
29
  declare const BLOCK_ATTRIBUTE = "data-puck-component";
30
+
29
31
  /**
30
32
  * The id of the block a pointer event landed on: the NEAREST ancestor (or the
31
33
  * target itself) carrying `attribute`. `null` on bare canvas.
@@ -1 +1 @@
1
- export{BLOCK_ATTRIBUTE,BLOCK_SELECTOR,CANVAS_SELECTOR,CANVAS_TYPABLE_EVENT,CANVAS_TYPING_EVENT,LIST_SELECTOR,clientPointToLayer,drawnBox,elementScale,fitCanvas,framePointToHost,frameRectToHost,frameRectToLayer,frameScale,isFrameReady,isTypingTarget,nodeIdAt,removeCanvasStyle,setCanvasNonce,upsertCanvasStyle,useCanvasEvent,useCanvasFrame,useCanvasLayout,useCanvasStyle,useCanvasTyping,watchCanvasFrame}from"../chunk-X4T6JT3M.js";
1
+ export{BLOCK_ATTRIBUTE,BLOCK_SELECTOR,CANVAS_SELECTOR,CANVAS_TYPABLE_EVENT,CANVAS_TYPING_EVENT,LIST_SELECTOR,clientPointToLayer,drawnBox,elementScale,fitCanvas,framePointToHost,frameRectToHost,frameRectToLayer,frameScale,isFrameReady,isTypingTarget,nodeIdAt,removeCanvasStyle,setCanvasNonce,upsertCanvasStyle,useCanvasEvent,useCanvasFrame,useCanvasLayout,useCanvasStyle,useCanvasTyping,watchCanvasFrame}from"../chunk-QIDRJH3S.js";export{REPEAT_ATTRIBUTE,REPEAT_INDEX_ATTRIBUTE,isRepeatCopy,mainCopyOf,queryAllCopies,queryMainCopy}from"../chunk-LF3FUSCQ.js";
@@ -0,0 +1,2 @@
1
+ import{routeSharedHostMessage as e}from"./chunk-77IWWW6X.js";import{describeLoadFailure as r,hostLoadRefusal as n}from"./chunk-ERR437B5.js";import{editLockOf as t}from"./chunk-GMCZXMOV.js";import{NO_DOCUMENT_ADDRESSING as o}from"./chunk-RLBXE4EU.js";import{saveStatusOf as u,resetForDocumentSwitch as a}from"./chunk-HNKB2ZYR.js";import{isExpiredSession as s,readEaselFailure as i}from"./chunk-CLOS6SSX.js";import{useAdminBridge as l}from"./chunk-U66YKDAR.js";import{STATUS_UNREACHABLE as c}from"./chunk-KCOBHPN6.js";import{useEaselSession as d}from"./chunk-O7Q4DDJT.js";import{backendOf as f,setSessionDocumentSite as m}from"./chunk-RSCMJIWS.js";import{useEaselHost as k}from"./chunk-MQA7OFRA.js";import{DEFAULT_SCREEN_WORDS as v}from"./chunk-23DYNW6S.js";import{useAutosave as g}from"./chunk-NDRZP6YR.js";import{canWriteDocument as p,newEaselClientId as h,reloadIfVersionMoved as y,openUnansweredClaim as w,FAIL_OPEN_RETRY_MS as S,CLAIM_FAIL_OPEN_MS as b,holderOf as I}from"./chunk-THWO5YVZ.js";import{useWords as P}from"./chunk-MFIRYGHW.js";import{createContext as j,useContext as R,useState as O,useMemo as B,useCallback as C,useEffect as E,useRef as H}from"react";import{jsx as A}from"react/jsx-runtime";var D={content:[],root:{},zones:{}};var M=j(null);function T(){const e=R(M);if(!e)throw new Error("useStorefrontDocument must be used within StorefrontDocumentProvider");return e}function N({target:j,addressing:R=o,onHostMessage:T,children:N}){const W=R,{homeSlug:F,entryMayBounce:L,entryBounce:Y,onSwitch:V,tellsHost:K,adapterFor:U,migrateRenamedProps:X,describeMissing:Z,onLoadFailed:x}=W,[G,J]=O(j),Q=k(),z=d(),_=B(()=>f(z),[z]),q=B(()=>t(z),[z]),$="template"===G.kind,ee="template"===G.kind?G.id:null,re="template"===G.kind?G.pageSlug??F??"":"document"===G.kind?G.slug??"":G.slug,ne="page"===G.kind?G.siteId??null:null,te=z.blocks,oe=B(()=>U(G,_,te),[U,_,te,G.kind,"template"===G.kind?G.id:"document"===G.kind?G.record:G.siteId]),ue=oe.capabilities,ae=C(e=>z.documentHooks?.stored?.(e)??e,[z]);E(()=>{m(z,ne)},[z,ne]);const se=H(G);E(()=>{se.current=G},[G]);const{token:ie,tokenRef:le,capabilities:ce}=l({onMessage:r=>{if(T?.(r)||e(r))return;const n=r;if("storefront-editor:navigate"===n?.type){const e=r;e?.target&&Or(e.target)}}}),de=!z.usesBridgedToken||null!==ie,fe=oe.lock,me=Boolean(_.lock),[ke,ve]=O(null),[ge,pe]=O(null),[he,ye]=O(null),[we,Se]=O(null),be=P("screen",v),Ie=we?function(e,r){if(null!==e.sentence)return e.sentence;if(!e.missing)return r.loadFailed({cause:e.cause});switch(e.target.kind){case"template":return r.missingTemplatePage;case"document":return r.missingDocument;default:return r.missingPage({slug:e.slug})}}(we,be):null,[Pe,je]=O(null),Re=H(null),Oe=H(null),[Be,Ce]=O(!1),Ee=H(null),[He,Ae]=O(null),De=H(null),[Me,Te]=O(null),[Ne,We]=O(!1),Fe=H(null);E(()=>{Fe.current=Me},[Me]);const[Le,Ye]=O(ue.hasEditLock?{kind:"checking"}:{kind:"editing"}),Ve=H(Le);E(()=>{Ve.current=Le},[Le]);const Ke=H(()=>Promise.resolve(!1)),Ue=C(e=>{Oe.current=e,Ce(!0)},[]),Xe=g({save:async({id:e,data:r})=>{if(p(Ve.current)){if(!await Ke.current(e,r)){if(!p(Ve.current))return void Ue({id:e,data:r});throw new Error("page save did not land")}}else Ue({id:e,data:r})},onFailure:(e,r)=>{0===r&&Q.send("storefront-editor:save-failed")}}),{state:Ze,push:xe,flush:Ge,pause:Je,resume:Qe,stop:ze,reset:_e,retryNow:qe,hasPending:$e}=Xe,er=H(Ze);E(()=>{er.current=Ze},[Ze]);const rr=u(Ze),nr=C(()=>{const e=Oe.current;e&&(Oe.current=null,Ce(!1),xe(e))},[xe]),tr=H("");tr.current||(tr.current=h());const[or,ur]=O(0),ar=H(!1),[sr,ir]=O(L(j)),lr=H(!1);E(()=>{if(lr.current)return;lr.current=!0;const e=Q.address.search(),r=Y(j,e);r?Q.address.load(r):L(j)&&ir(!1)},[j,Q]);const cr=Q.send;E(()=>{if(!de)return;let e=!1;const t=se.current,o=oe.resolve(re),u=z.documentHooks?.opening?.({slug:re,isTemplate:$,capabilities:ue});return o.then(async r=>{if(e)return;if(!r)return"page"===t.kind&&null!==F&&re!==F?void Q.address.load({kind:"page",slug:F,siteId:ne??void 0}):(Se({target:t,slug:re,missing:!0,sentence:Z?.(t)??null}),void x?.(t,null));const n=r.readOnlyReason?r.readOnlyReason:null;Re.current=n,je(n),ve(r.id),pe(r.kind??null),De.current=r.version??null;const o=r.layout,a=o&&Object.keys(o).length?o:D,s=X(a),i=u?await u(s):s;e||ye(i)}).catch(o=>{e||(console.error("[storefront-editor] document load failed",o),Se({target:t,slug:re,missing:!1,sentence:n(o,{slug:re},z),cause:r(o,z)}),x?.(t,o))}),()=>{e=!0}},[de,ie,$,oe,re]);const dr=C(e=>new Promise(r=>{const n=Date.now(),t=setInterval(()=>{const o=le.current;o&&o!==e?(clearInterval(t),r(o)):Date.now()-n>6e3&&(clearInterval(t),r(null))},200)}),[]),fr=C(async e=>{const r=le.current;if(!r&&z.usesBridgedToken)return{ok:!1,error:new Error("no editor token")};try{return{ok:!0,value:await e(r??"")}}catch(n){if(s(n,z)){cr("storefront-editor:auth-expired");const n=r?await dr(r):null;if(n)try{return{ok:!0,value:await e(n)}}catch(e){return{ok:!1,error:e}}}return{ok:!1,error:n}}},[cr,dr,z]),mr=C(async e=>{const r=le.current?await fr(e):{ok:!1};return r.ok||cr("storefront-editor:save-failed"),r.ok},[cr,fr]),kr=C(async(e,r,n=!1)=>{if(null!==Re.current)return!1;if(!p(Ve.current))return!1;if(Fe.current)return!1;const t=await fr(()=>oe.saveLayout(e,r,De.current,tr.current));if(t.ok)return De.current=t.value.version??De.current,We(!1),!0;const o=q.readLockTaken(t.error);if(o){const e={kind:"takenover",holder:o};return Ve.current=e,Ye(e),!1}const u=q.readSaveConflict(t.error);if(u){if(u.savedByYou&&!n&&oe.rereadVersion){const n=await fr(()=>oe.rereadVersion(e));if(n.ok&&n.value)return De.current=n.value,Ke.current(e,r,!0)}ze(),Fe.current=u,Te(u)}return We(i(t.error,z)?.status===c),!1},[oe,fr,ze,z]);E(()=>{Ke.current=kr},[kr]);const vr=C(e=>{if(null!==Re.current)return;if(cr("storefront-editor:dirty"),!ke)return;const r=ae(e);Ee.current=r,p(Ve.current)?xe({id:ke,data:r}):Ue({id:ke,data:r})},[ke,cr,Ue,xe,ae]),gr=C(async()=>{p(Ve.current)&&nr();return await Ge()&&null==Oe.current},[nr,Ge]),pr=H(gr);E(()=>{pr.current=gr},[gr]);const hr=H(fr);E(()=>{hr.current=fr},[fr]);const yr=C(()=>{Q.address.reload()},[Q]),wr=H(()=>Promise.resolve(!1));E(()=>{wr.current=()=>{const e=oe.rereadVersion;return ke&&e?y({ours:De.current,stored:async()=>{const r=await hr.current(()=>e(ke));return r.ok?r.value:null},hasPending:()=>null!=Oe.current||$e(),reload:yr}):Promise.resolve(!1)}},[oe,ke,$e,yr]);const Sr=null!==Pe;E(()=>{if(!fe||!ke||!de||Sr)return;let e=!1,r=null,n=null;const t=tr.current,o={claim:async e=>{const r=await hr.current(()=>fe.claim(ke,t,e));if(r.ok)return{heartbeat_seconds:r.value.heartbeatSeconds};throw r.error},cancelled:()=>e,currentAccess:()=>Ve.current,heldWrite:()=>({pending:null!=Oe.current||$e(),autoSaveEnabled:!er.current.paused,saveConflict:null!=Fe.current}),setAccess:e=>{Ve.current=e,Ye(e)},releaseHeldWrite:()=>{pr.current()},startHeartbeat:e=>{r&&clearInterval(r),r=setInterval(()=>{u(!1)},e)},stopHeartbeat:()=>{r&&(clearInterval(r),r=null)},reloadIfMoved:()=>{wr.current()}},u=q.makeClaimBeat(o),a=ar.current;return ar.current=!1,a||(Ye({kind:"checking"}),n=setTimeout(()=>{n=null,w(o)&&o.startHeartbeat(S)},b)),u(a).finally(()=>{n&&clearTimeout(n),n=null}),()=>{e=!0,n&&clearTimeout(n),r&&clearInterval(r),fe.release(ke,t).catch(()=>{})}},[ke,fe,de,ie,or,Sr]);const br=C(()=>{fe&&ke&&(ar.current=!0,ur(e=>e+1))},[ke,fe]),Ir=C(()=>{Ye(e=>{const r="blocked"===e.kind||"takenover"===e.kind?e.holder:null;return r?{kind:"readonly",holder:r}:e})},[]),Pr=C(()=>{er.current.paused?(p(Ve.current)&&nr(),Qe()):Je()},[nr,Je,Qe]),jr=C(()=>{qe()},[qe]),Rr=C(e=>{Ee.current=null,a("template"!==e.kind&&me,{resetAutosave:()=>{_e(),Oe.current=null,Ce(!1)},setVersion:e=>{De.current=e},setSaveConflict:Te,setAccess:Ye}),V(e),J(e),Re.current=null,je(null),ve(null),pe(null),ye(null),Se(null),Q.address.show(e),"document"!==e.kind&&K(e)&&Q.send("storefront-editor:navigated",{target:e})},[_e,Q,me,V,K]),Or=C(e=>{if(function(e,r,n){if(e.kind!==r.kind)return!1;if("template"===e.kind){const t=r;return e.id===t.id&&(e.pageSlug??n)===(t.pageSlug??n)}if("document"===e.kind){const n=r;return e.record===n.record&&(e.slug??"")===(n.slug??"")}const t=r;return e.slug===t.slug&&e.siteId===t.siteId}(e,se.current,F))return;const r=null!=Oe.current;if(!r&&!$e())return void Rr(e);const n=er.current;r||n.paused||n.failed||n.stopped?Ae(e):Ge().then(r=>{r?Rr(e):Ae(e)})},[Rr,$e,Ge,F]),Br=C(()=>Ae(null),[]),Cr=C(()=>{Ae(e=>(e&&Rr(e),null))},[Rr]),Er=C(async()=>{const e=He;if(!e)return;await gr()&&(Ae(null),Rr(e))},[He,gr,Rr]),Hr=C(async e=>{if(null!==Re.current)return;if(!ke)return;if(!p(Ve.current)||Fe.current)return;const r=ae(e);if(!await kr(ke,r))return void(Fe.current||cr("storefront-editor:save-failed"));const n=oe.publish;if(!ue.canPublish||!n)return void cr("storefront-editor:saved");const t=await fr(()=>n(ke,De.current??void 0));if(!t.ok){const{error:e}=t;return void cr("storefront-editor:publish-failed",{reason:e instanceof Error&&e.message?e.message:null})}De.current=t.value.version??De.current,cr("storefront-editor:published")},[ke,oe,ue.canPublish,cr,kr,fr,ae]);/* @__PURE__ */
2
+ return A(M.Provider,{value:{target:G,adapter:oe,capabilities:ue,templateId:ee,currentSlug:re,currentKind:ge,siteId:ne,ready:de,token:ie,tokenRef:le,notifyParent:cr,bridgeCapabilities:ce,runAuthed:mr,docId:ke,data:he,getLiveData:()=>Ee.current??he,error:Ie,redirecting:sr,saveStatus:rr,saveState:Ze,autoSaveEnabled:!Ze.paused,autoSaveStoppedByConflict:Ze.stopped,hasUnsavedEdits:Ze.pending||Be,toggleAutoSave:Pr,retrySave:jr,onChange:vr,flushSave:gr,onPublish:Hr,access:Le,readOnly:null!==I(Le)||null!==Pe||null!==Me,readOnlyReason:Pe,takeOverEditing:br,viewReadOnly:Ir,saveConflict:Me,saveUnreachable:Ne,reloadFromServer:yr,navigate:Or,pendingNav:He,cancelPendingNav:Br,discardAndNavigate:Cr,saveAndNavigate:Er},children:N})}export{M as ScreenDocumentContext,N as ScreenDocumentProvider,T as useScreenDocument};
@@ -0,0 +1 @@
1
+ import{HERO_SLIDER_GOTO_EVENT as t}from"./chunk-IQ5TA7AM.js";import{queryMainCopy as n}from"./chunk-LF3FUSCQ.js";import{isPreviewClick as o}from"./chunk-R5L2E7JX.js";var e=()=>document.querySelector(".sf-editor #preview-frame");function r(t){o()||requestAnimationFrame(()=>{const o=e()?.contentDocument;o&&n(o,`[data-puck-component="${CSS.escape(t)}"]`)?.scrollIntoView({behavior:"smooth",block:"start"})})}function c(n,o){const r=e()?.contentWindow;if(!r)return;const c={id:n,index:o};r.dispatchEvent(new CustomEvent(t,{detail:c}))}function i(){requestAnimationFrame(()=>{e()?.contentWindow?.scrollTo({top:0,behavior:"smooth"})})}function u(t,{passes:n=[150,400],onPinned:o}={}){let r=0,c=!1;const i=[],u=()=>{const r=e(),s=r?.contentWindow,l=r?.contentDocument;if(!s||!l)return!1;const m=t(s,l);if(null==m)return!1;if(s.scrollTo({left:s.scrollX,top:m,behavior:"instant"}),!c){c=!0,o?.();for(const t of n)i.push(setTimeout(u,t))}return!0},s=()=>{!u()&&r++<150&&i.push(setTimeout(s,32))};return s(),()=>i.forEach(clearTimeout)}function s(t){return u((o,e)=>{const r=n(e,`[data-puck-component="${CSS.escape(t)}"]`);return r?o.scrollY+r.getBoundingClientRect().top:null})}function l(t){return u((t,n)=>{if(!n.querySelector("[data-puck-component]"))return null;const o=Math.max(n.documentElement.scrollHeight,n.body?.scrollHeight??0);return o<=n.documentElement.clientHeight?null:o},{passes:[150,400,800,1300,2e3],onPinned:t})}export{c as gotoPreviewSlide,l as pinPreviewToBottom,s as pinPreviewToSection,e as previewFrame,r as scrollPreviewToSection,i as scrollPreviewToTop};
@@ -1 +1 @@
1
- import{useMediaPanel as o,usePanelPick as r,useMediaBrowsing as n,useCloseMediaPopup as t,settlePanelPick as e}from"./chunk-LNHT2KPX.js";import{jsx as i}from"react/jsx-runtime";function c(){const c=o(),s=r(),u=n(),m=t();return c?/* @__PURE__ */i(c,{pick:s,browsing:u,onPick:o=>{s&&e(s.requestId,o)},onClose:m}):null}export{c as MediaPopup};
1
+ import{useMediaPanel as o,usePanelPick as r,useMediaBrowsing as n,useCloseMediaPopup as t,settlePanelPick as e}from"./chunk-FHCKFOCD.js";import{jsx as i}from"react/jsx-runtime";function c(){const c=o(),s=r(),u=n(),m=t();return c?/* @__PURE__ */i(c,{pick:s,browsing:u,onPick:o=>{s&&e(s.requestId,o)},onClose:m}):null}export{c as MediaPopup};
@@ -1 +1 @@
1
- import{zoneKey as e}from"./chunk-KRXQM65X.js";import{useRef as t,useEffect as n,useState as r,useSyncExternalStore as o,useCallback as i}from"react";var l=56,c=16;function a(e){const t=Math.max(e,0);return t>=l?0:Math.ceil(16*(1-t/l))}function u(e,t,n){if(e<t-l||e>n+l)return 0;const r=e-t,o=n-e;return r<l&&r<=o?-a(r):o<l?a(o):0}function s(e){const t=e?.ownerDocument?.defaultView;for(let n=e?.parentElement??null;n;n=n.parentElement){const e=t?.getComputedStyle(n).overflowY;if(("auto"===e||"scroll"===e)&&n.scrollHeight>n.clientHeight)return n}return null}function f(e){const t=e?.ownerDocument?.defaultView?.getComputedStyle(e).overflowY;return e&&("auto"===t||"scroll"===t)&&e.scrollHeight>e.clientHeight?e:s(e)}function d(e){const t=e.scrollingElement??e.documentElement;return t&&t.scrollHeight>t.clientHeight?t:null}function g(e,t=e){const n=t.ownerDocument,r=n.defaultView;if(!r)return()=>{};let o=null,i=0;const l=e=>{o=e.clientY},c=()=>{if(null!==o){const n=t.getBoundingClientRect(),r=u(o,n.top,n.bottom);r&&(e.scrollTop+=r)}i=r.requestAnimationFrame(c)};return n.addEventListener("dragover",l,!0),i=r.requestAnimationFrame(c),()=>{n.removeEventListener("dragover",l,!0),r.cancelAnimationFrame(i)}}function p(e){return/move|all|uninitialized/i.test(e)?"move":"copy"}function m(){let e=null,t=null;const n=/* @__PURE__ */new Set,r=()=>{if(t!==e){t=e;for(const e of[...n])e()}};return{get:()=>e,shown:()=>t,start(t){e=t,globalThis.setTimeout(r,0)},end(){null===e&&null===t||(e=null,r())},subscribe:e=>(n.add(e),()=>{n.delete(e)})}}function v(e,t,n,r){if(e.into)return{side:"into",to:e.into};return"first"===e.pinned||"last"!==e.pinned&&t>n+r/2?{side:"after",to:{...e.place,index:e.place.index+1}}:{side:"before",to:{...e.place,index:e.place.index}}}var D=(t,n)=>e(t)===e(n);function w(e,t){return D(e,t)&&(t.index===e.index||t.index===e.index+1)}function y(e,t){return D(e,t)&&e.index<t.index?t.index-1:t.index}function x(e,t){return{...e,index:t<0?e.index-1:e.index+2}}function h(e,t){if(!t)return e;const n={...t,...e};for(const[r,o]of Object.entries(e)){const e=t[r];"function"==typeof o&&"function"==typeof e&&(n[r]=t=>{o(t),e(t)})}return n}function T(l){const c=t(l);n(()=>{c.current=l});const[a]=r(()=>m()),u=l.session??a,d=o(u.subscribe,u.shown,u.shown),[D,y]=r(null),x=t(null),T=i(()=>{x.current?.(),x.current=null},[]),b=i(()=>{T(),u.end(),y(null)},[u,T]);n(()=>u.subscribe(()=>{u.get()||(T(),y(null))}),[u,T]),n(()=>T,[T]);const k=i((e,t)=>{y(n=>n&&n.key===e&&n.side===t?n:{key:e,side:t})},[]),E=i(e=>{y(t=>t&&t.key===e?null:t)},[]),A=(e,t,n,r)=>!("into"===n?r===e.key:void 0!==e.from&&w(e.from,t))&&c.current.canDrop(e.item,t);return{dragging:d?.item??null,row:(e,t)=>{const{keyOf:n,readOnly:r}=c.current,o=n(e.item),i=!r&&!e.pinned&&!1!==e.canDrag,l=t=>{const n=t.currentTarget.getBoundingClientRect();return v(e,t.clientY,n.top,n.height)},a={draggable:i||void 0,onDragStart:i?t=>{const n=t.currentTarget;u.start({key:o,item:e.item,from:e.place}),t.dataTransfer.effectAllowed="move";try{t.dataTransfer.setData("text/plain",o)}catch{}n.classList.add("is-lifting");const r=n.getBoundingClientRect();t.dataTransfer.setDragImage?.(n,t.clientX-r.left,t.clientY-r.top),n.ownerDocument.defaultView?.setTimeout(()=>n.classList.remove("is-lifting"),0);const i=s(n);T(),x.current=i?g(i):null}:void 0,onDragEnd:i?()=>b():void 0,onDragOver:e=>{const t=u.get();if(!t)return;const n=l(e);A(t,n.to,n.side,o)?(e.preventDefault(),e.dataTransfer.dropEffect=p(e.dataTransfer.effectAllowed),k(o,n.side)):E(o)},onDrop:e=>{const t=u.get();if(!t)return;const n=l(e);A(t,n.to,n.side,o)&&(e.preventDefault(),b(),c.current.onDrop(t.item,n.to))},onKeyDown:t=>{if("ArrowUp"!==t.key&&"ArrowDown"!==t.key)return;if(!t.altKey||t.ctrlKey||t.metaKey||t.shiftKey)return;if(t.preventDefault(),t.repeat||!i)return;const{onStep:n,canStep:r}=c.current,o="ArrowUp"===t.key?-1:1;n&&!1!==r?.(e.item,o)&&n(e.item,o)}};return{draggable:i,dragging:d?.key===o,drop:D?.key===o?D.side:void 0,rowProps:h(a,t)}},seam:(t,n)=>{const r=(o=t.place,`seam:${e(o)}:${o.index}`);var o;const i={onDragOver:e=>{const n=u.get();n&&(A(n,t.place,"before",r)?(e.preventDefault(),e.dataTransfer.dropEffect=p(e.dataTransfer.effectAllowed),k(r,"before")):E(r))},onDrop:e=>{const n=u.get();n&&A(n,t.place,"before",r)&&(e.preventDefault(),b(),c.current.onDrop(n.item,t.place))}};return{drop:D?.key===r,seamProps:h(i,n)}},rootProps:e=>h({onDragEnter:e=>{if(!u.get()||x.current)return;const t=f(e.currentTarget);x.current=t?g(t):null},onDragLeave:e=>{const t=e.relatedTarget;t&&e.currentTarget.contains(t)||y(null)}},e)}}export{l as AUTO_SCROLL_EDGE,c as AUTO_SCROLL_MAX_SPEED,u as autoScrollDelta,a as autoScrollSpeed,m as createDragSession,p as dropEffectFor,v as dropOnRow,d as frameScrollBox,y as gapToMoveIndex,w as isNoOpDrop,f as scrollBoxOf,s as scrollParent,g as startAutoScroll,x as stepGap,T as useTreeDrag};
1
+ import{zoneKey as e}from"./chunk-K7BTCBWD.js";import{useRef as t,useEffect as n,useState as r,useSyncExternalStore as o,useCallback as i}from"react";var l=56,c=16;function a(e){const t=Math.max(e,0);return t>=l?0:Math.ceil(16*(1-t/l))}function u(e,t,n){if(e<t-l||e>n+l)return 0;const r=e-t,o=n-e;return r<l&&r<=o?-a(r):o<l?a(o):0}function s(e){const t=e?.ownerDocument?.defaultView;for(let n=e?.parentElement??null;n;n=n.parentElement){const e=t?.getComputedStyle(n).overflowY;if(("auto"===e||"scroll"===e)&&n.scrollHeight>n.clientHeight)return n}return null}function f(e){const t=e?.ownerDocument?.defaultView?.getComputedStyle(e).overflowY;return e&&("auto"===t||"scroll"===t)&&e.scrollHeight>e.clientHeight?e:s(e)}function d(e){const t=e.scrollingElement??e.documentElement;return t&&t.scrollHeight>t.clientHeight?t:null}function g(e,t=e){const n=t.ownerDocument,r=n.defaultView;if(!r)return()=>{};let o=null,i=0;const l=e=>{o=e.clientY},c=()=>{if(null!==o){const n=t.getBoundingClientRect(),r=u(o,n.top,n.bottom);r&&(e.scrollTop+=r)}i=r.requestAnimationFrame(c)};return n.addEventListener("dragover",l,!0),i=r.requestAnimationFrame(c),()=>{n.removeEventListener("dragover",l,!0),r.cancelAnimationFrame(i)}}function p(e){return/move|all|uninitialized/i.test(e)?"move":"copy"}function m(){let e=null,t=null;const n=/* @__PURE__ */new Set,r=()=>{if(t!==e){t=e;for(const e of[...n])e()}};return{get:()=>e,shown:()=>t,start(t){e=t,globalThis.setTimeout(r,0)},end(){null===e&&null===t||(e=null,r())},subscribe:e=>(n.add(e),()=>{n.delete(e)})}}function v(e,t,n,r){if(e.into)return{side:"into",to:e.into};return"first"===e.pinned||"last"!==e.pinned&&t>n+r/2?{side:"after",to:{...e.place,index:e.place.index+1}}:{side:"before",to:{...e.place,index:e.place.index}}}var D=(t,n)=>e(t)===e(n);function w(e,t){return D(e,t)&&(t.index===e.index||t.index===e.index+1)}function y(e,t){return D(e,t)&&e.index<t.index?t.index-1:t.index}function x(e,t){return{...e,index:t<0?e.index-1:e.index+2}}function h(e,t){if(!t)return e;const n={...t,...e};for(const[r,o]of Object.entries(e)){const e=t[r];"function"==typeof o&&"function"==typeof e&&(n[r]=t=>{o(t),e(t)})}return n}function T(l){const c=t(l);n(()=>{c.current=l});const[a]=r(()=>m()),u=l.session??a,d=o(u.subscribe,u.shown,u.shown),[D,y]=r(null),x=t(null),T=i(()=>{x.current?.(),x.current=null},[]),b=i(()=>{T(),u.end(),y(null)},[u,T]);n(()=>u.subscribe(()=>{u.get()||(T(),y(null))}),[u,T]),n(()=>T,[T]);const k=i((e,t)=>{y(n=>n&&n.key===e&&n.side===t?n:{key:e,side:t})},[]),E=i(e=>{y(t=>t&&t.key===e?null:t)},[]),A=(e,t,n,r)=>!("into"===n?r===e.key:void 0!==e.from&&w(e.from,t))&&c.current.canDrop(e.item,t);return{dragging:d?.item??null,row:(e,t)=>{const{keyOf:n,readOnly:r}=c.current,o=n(e.item),i=!r&&!e.pinned&&!1!==e.canDrag,l=t=>{const n=t.currentTarget.getBoundingClientRect();return v(e,t.clientY,n.top,n.height)},a={draggable:i||void 0,onDragStart:i?t=>{const n=t.currentTarget;u.start({key:o,item:e.item,from:e.place}),t.dataTransfer.effectAllowed="move";try{t.dataTransfer.setData("text/plain",o)}catch{}n.classList.add("is-lifting");const r=n.getBoundingClientRect();t.dataTransfer.setDragImage?.(n,t.clientX-r.left,t.clientY-r.top),n.ownerDocument.defaultView?.setTimeout(()=>n.classList.remove("is-lifting"),0);const i=s(n);T(),x.current=i?g(i):null}:void 0,onDragEnd:i?()=>b():void 0,onDragOver:e=>{const t=u.get();if(!t)return;const n=l(e);A(t,n.to,n.side,o)?(e.preventDefault(),e.dataTransfer.dropEffect=p(e.dataTransfer.effectAllowed),k(o,n.side)):E(o)},onDrop:e=>{const t=u.get();if(!t)return;const n=l(e);A(t,n.to,n.side,o)&&(e.preventDefault(),b(),c.current.onDrop(t.item,n.to))},onKeyDown:t=>{if("ArrowUp"!==t.key&&"ArrowDown"!==t.key)return;if(!t.altKey||t.ctrlKey||t.metaKey||t.shiftKey)return;if(t.preventDefault(),t.repeat||!i)return;const{onStep:n,canStep:r}=c.current,o="ArrowUp"===t.key?-1:1;n&&!1!==r?.(e.item,o)&&n(e.item,o)}};return{draggable:i,dragging:d?.key===o,drop:D?.key===o?D.side:void 0,rowProps:h(a,t)}},seam:(t,n)=>{const r=(o=t.place,`seam:${e(o)}:${o.index}`);var o;const i={onDragOver:e=>{const n=u.get();n&&(A(n,t.place,"before",r)?(e.preventDefault(),e.dataTransfer.dropEffect=p(e.dataTransfer.effectAllowed),k(r,"before")):E(r))},onDrop:e=>{const n=u.get();n&&A(n,t.place,"before",r)&&(e.preventDefault(),b(),c.current.onDrop(n.item,t.place))}};return{drop:D?.key===r,seamProps:h(i,n)}},rootProps:e=>h({onDragEnter:e=>{if(!u.get()||x.current)return;const t=f(e.currentTarget);x.current=t?g(t):null},onDragLeave:e=>{const t=e.relatedTarget;t&&e.currentTarget.contains(t)||y(null)}},e)}}export{l as AUTO_SCROLL_EDGE,c as AUTO_SCROLL_MAX_SPEED,u as autoScrollDelta,a as autoScrollSpeed,m as createDragSession,p as dropEffectFor,v as dropOnRow,d as frameScrollBox,y as gapToMoveIndex,w as isNoOpDrop,f as scrollBoxOf,s as scrollParent,g as startAutoScroll,x as stepGap,T as useTreeDrag};
@@ -0,0 +1 @@
1
+ import{useSectionOps as o}from"./chunk-PI6RFJR4.js";import{SELECTION_MODE as e}from"./chunk-LEZFSSQN.js";import{decodePartId as r,encodePartId as t}from"./chunk-IYT6NN2J.js";import{useEasel as n}from"./chunk-ROPYFLNZ.js";import{usePreviewParts as p}from"./chunk-I54UCYOU.js";import{useCallback as d,useEffect as c}from"react";var s=o=>"part"===o.kind;function m({mode:m,setMode:i,onOpenPart:I}){const{getSelectorForId:a}=n(o=>o),u=o(),{setSelectedPartId:f,setSelectHandler:k}=p(),l=d(o=>{const t=r(o);if(!t)return;const{nodeId:n,propKey:p}=t;p?(i(o=>s(o)&&o.nodeId===n&&o.propKey===p?o:{kind:"part",nodeId:n,propKey:p}),I?.(n)):i(o=>"part"===o.kind?e:o)},[i,I]);c(()=>{k(l)},[k,l]);const h=s(m)?t(m.nodeId,m.propKey):null;c(()=>{f(h)},[h,f]);return{selectNode:d(o=>{i(()=>e);const r=a(o);r&&u.select(r)},[i,a,u]),openPartId:h}}export{m as usePartBridge};
@@ -0,0 +1,8 @@
1
+ import{buildPaletteSections as e,pinnedSection as t,categoryLabel as n}from"./chunk-PA3PNTVV.js";import{blockTypesIn as o}from"./chunk-5ZBY24K7.js";import{sectionTemplatesOf as l}from"./chunk-BVN33R76.js";import{sharedSectionsOf as r}from"./chunk-43AEUUNQ.js";import{SidePanelHead as i,PanelModeExit as s}from"./chunk-SINAM2IT.js";import{blockRuns as c}from"./chunk-M2Z775ZC.js";import{useScreenBlockLook as a,useScreenBlockRules as d,useScreenPinned as p}from"./chunk-LEZFSSQN.js";import{useEaselSession as m}from"./chunk-O7Q4DDJT.js";import{DEFAULT_SCREEN_WORDS as f}from"./chunk-23DYNW6S.js";import{useEasel as u}from"./chunk-ROPYFLNZ.js";import{easelMenuEntries as y}from"./chunk-FIVU2COQ.js";import{useWords as h}from"./chunk-MFIRYGHW.js";import{AddPanel as k}from"./chunk-LDEEFLE3.js";import{DEFAULT_DRAG_WORDS as g}from"./chunk-KAML3KQH.js";import{useState as b,useEffect as v,useMemo as j,useRef as w}from"react";import{SharedIcon as C,AddIcon as E}from"efficient-shell/icons/efficient";import{ContextMenu as F,toast as L,Dialog as N,Button as O}from"efficient-shell/ui";import{jsx as S,jsxs as T,Fragment as $}from"react/jsx-runtime";function x({name:e,pages:t,onDelete:n,onCancel:o}){const l=h("screen",f).shared,[r,i]=b(!1),s=w(null);/* @__PURE__ */
2
+ return S(N,{open:!0,role:"alertdialog",size:"sm",title:l.deleteTitle({name:e}),onClose:o,initialFocus:s,footer:/* @__PURE__ */T($,{children:[
3
+ /* @__PURE__ */S(O,{ref:s,variant:"secondary",onClick:o,children:l.cancel}),
4
+ /* @__PURE__ */S(O,{variant:"danger",loading:r,onClick:()=>{(async()=>{i(!0);try{await n()}finally{i(!1)}})()},children:l.deleteShared})]}),children:l.deleteMessage({count:t})})}var A=e=>`section:${e}`,D=e=>`block:${e}`,I=e=>`template:${e}`,M=e=>`shared:${e}`;function B({at:w,placeBlocks:N,canTake:O,onPick:B,itemFor:P,session:Q,siteWide:Z,onClose:z,onHide:H,readOnly:R}){const V=u(e=>e.config),W=a(),{labelAtLevel:Y,categoryLabel:K,firstSection:U,Icon:_,Thumbnail:G}=W,{blockIsOffered:J,canAddTo:q}=d(),X=h("screen",f).add,ee=h("drag",g).add,te=m(),[ne,oe]=b([]);v(()=>{let e=!1;const t=e=>J(e,te);return l(te).list().then(n=>{if(e)return;const l=V.components;oe(n.filter(e=>e.node?.type&&l[e.node.type]&&o(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[V,te]);const le=p().shared,re=h("screen",f).shared,[ie,se]=b([]),[ce,ae]=b(0);v(()=>{if(!le)return;let e=!1;const t=e=>J(e,te);return r(te).list().then(n=>{if(e)return;const l=V.components;se(n.filter(e=>e.node?.type&&l[e.node.type]&&o(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[V,te,ce]);const[de,pe]=b(null),[me,fe]=b(null),ue=j(()=>e(V,W),[V]),ye=e=>Y(e,"section",V.components[e]?.label??e),he=e=>({type:A(e.type),label:e.name,cover:/* @__PURE__ */S(G,{type:e.type}),title:e.desc?`${e.name} — ${e.desc}`:X.tile({name:e.name}),keywords:[e.alias??"",e.desc,e.type,e.catLabel].filter(Boolean)}),ke=e=>{const t=e.indexOf(":"),n=e.slice(0,t),o=e.slice(t+1);if("section"===n)return{kind:"section",type:o};if("block"===n)return{kind:"block",type:o};if("template"===n){const e=ne.find(e=>e.id===o);return e?{kind:"template",template:e}:null}if("shared"===n){const e=ie.find(e=>e.id===o);return e?{kind:"shared",section:e}:null}return null},ge=e=>/* @__PURE__ */S("span",{className:"es-add-glyph-cover",children:/* @__PURE__ */S(_,{type:e,size:26})}),be=j(()=>{const e=t(ue,U),o=/* @__PURE__ */new Map,l=e=>{e.retired||o.has(e.type)||!J(e.type,te)||o.set(e.type,e)};for(const t of e?[e]:ue){const e=q(t.type)?.choices??[];e.forEach(l),e.forEach(e=>q(e.type,1)?.choices?.forEach(l))}N?.forEach(l);const r=new Set(ue.map(e=>e.type)),i=[...o.values()].filter(e=>!r.has(e.type)),s=e=>({type:D(e.type),label:e.label,cover:ge(e.type),title:X.tile({name:e.label}),keywords:[e.group??"",e.type].filter(Boolean)}),a=e=>o.has(e.type)?{...he(e),cover:ge(e.type)}:he(e),d=[];ie.length>0&&d.push({key:"shared",title:re.group,tiles:ie.map(e=>({type:M(e.id),label:e.title,cover:/* @__PURE__ */S(G,{type:e.node.type}),mark:/* @__PURE__ */S(C,{size:12}),title:re.onPages({count:e.used_on.length}),keywords:[ye(e.node.type),e.node.type]}))}),ne.length>0&&d.push({key:"templates",title:X.templates,tiles:ne.map(e=>({type:I(e.id),label:e.name,cover:/* @__PURE__ */S(G,{type:e.node.type}),keywords:[ye(e.node.type),e.node.type]}))});const p=i.filter(e=>!e.group);let m=!1;for(const t of Object.keys(V.categories??{})){const o=ue.filter(e=>e.cat===t);if(0===o.length)continue;const l=e&&o.some(t=>t.type===e.type)?e:null,r=(l?[l,...o.filter(e=>e.type!==l.type)]:o).map(a);l&&!m&&(r.splice(1,0,...p.map(s)),m=!0),d.push({key:`category:${t}`,title:n(V,t,K),tiles:r})}const f=d.find(e=>e.key?.startsWith("category:"));if(!m&&f&&p.length>0&&(f.tiles=[...f.tiles,...p.map(s)],m=!0),c(i.filter(e=>e.group||!m)).forEach((e,t)=>{d.push({key:`blocks:${t}`,title:e.group??"",tiles:e.items.map(s)})}),!O)return d;const u=d.map(e=>({...e,tiles:e.tiles.map(e=>{const t=ke(e.type),n=t?O(t):null;return n?{...e,disabled:!0,disabledReason:n}:e})})),y=e=>e.tiles.some(e=>!e.disabled);return[...u.filter(y),...u.filter(e=>!y(e))]},[ne,ie,re,ue,V,X,O,N,te]);/* @__PURE__ */
5
+ return T($,{children:[
6
+ /* @__PURE__ */S(i,{icon:/* @__PURE__ */S(E,{size:15}),title:X.title,context:X.contextAll,actions:/* @__PURE__ */S(s,{label:X.done,description:X.doneDescription,onClick:z}),onHide:H}),
7
+ /* @__PURE__ */T("div",{className:"sf-addside sf-scroll",children:[
8
+ /* @__PURE__ */S(k,{groups:be,session:Q,itemFor:e=>P(ke(e)??{kind:"section",type:e}),onInsert:B?e=>{const t=ke(e);t&&B(t)}:void 0,onTileMenu:(e,t)=>{const n=ke(e);return"shared"===n?.kind&&!R&&(pe({section:n.section,...t}),!0)},at:w,hint:X.hint,searchLabel:X.search,readOnly:R,words:ee}),Z??null]}),de?/* @__PURE__ */S(F,{at:{x:de.x,y:de.y},owner:de.owner,onClose:()=>pe(null),"aria-label":de.section.title,items:y([{label:re.deleteShared,danger:!0,onClick:()=>{fe(de.section),pe(null)}}])}):null,me?/* @__PURE__ */S(x,{name:me.title,pages:me.used_on.length,onDelete:()=>(async e=>{try{await r(te).remove(e.id)}catch{return void L.error(re.deleteFailed)}fe(null),le?.removed?.(e),se(t=>t.filter(t=>t.id!==e.id)),ae(e=>e+1)})(me),onCancel:()=>fe(null)}):null]})}export{B as AddSidePanel,D as blockKey,A as sectionKey,M as sharedKey,I as templateKey};
@@ -1,4 +1,4 @@
1
- import{blockRuns as e,offeredChoices as r}from"./chunk-M2Z775ZC.js";import{useScreenBlockLook as s}from"./chunk-OGBYHQE6.js";import{DEFAULT_SCREEN_WORDS as t}from"./chunk-23DYNW6S.js";import{useWords as n}from"./chunk-MFIRYGHW.js";import{DropdownMenu as c}from"efficient-shell/ui";import{jsxs as i,Fragment as o,jsx as l}from"react/jsx-runtime";function p({choices:p,onPick:a}){const{Icon:m}=s(),u=n("screen",t),f=e(r(p)).flatMap(e=>[...e.group?[{type:"label",key:`group:${e.group}`,label:/* @__PURE__ */i(o,{children:[e.group," ",
1
+ import{blockRuns as e,offeredChoices as r}from"./chunk-M2Z775ZC.js";import{useScreenBlockLook as s}from"./chunk-LEZFSSQN.js";import{DEFAULT_SCREEN_WORDS as t}from"./chunk-23DYNW6S.js";import{useWords as n}from"./chunk-MFIRYGHW.js";import{DropdownMenu as c}from"efficient-shell/ui";import{jsxs as i,Fragment as o,jsx as l}from"react/jsx-runtime";function p({choices:p,onPick:a}){const{Icon:m}=s(),u=n("screen",t),f=e(r(p)).flatMap(e=>[...e.group?[{type:"label",key:`group:${e.group}`,label:/* @__PURE__ */i(o,{children:[e.group," ",
2
2
  /* @__PURE__ */l("span",{className:"sf-menugroup-count",children:e.items.length})]})}]:[],...e.items.map(e=>({key:e.type,label:e.label,icon:/* @__PURE__ */l("span",{className:"sf-chip",children:/* @__PURE__ */l(m,{type:e.type,size:13})}),onSelect:()=>a(e.type)}))]);/* @__PURE__ */
3
3
  return l(c,{align:"start",triggerClassName:"sf-add-card",items:f,trigger:/* @__PURE__ */i(o,{children:[
4
4
  /* @__PURE__ */l("span",{className:"sf-plus sf-plus--sm",children:"+"}),u.addBlockMenu]})})}export{p as AddBlockRow};
@@ -1 +1 @@
1
- import{resolveMediaPick as e}from"./chunk-RYNBSKE7.js";function t(t){const r=t;switch(r?.type){case"storefront-editor:media-picked":{const r=t;return r.requestId&&e(r.requestId,r.media??null),!0}case"storefront-editor:media-pick-cancelled":{const r=t;return r.requestId&&e(r.requestId,null),!0}default:return!1}}export{t as routeSharedHostMessage};
1
+ import{resolveMediaPick as e}from"./chunk-UNVKPVZW.js";function t(t){const r=t;switch(r?.type){case"storefront-editor:media-picked":{const r=t;return r.requestId&&e(r.requestId,r.media??null),!0}case"storefront-editor:media-pick-cancelled":{const r=t;return r.requestId&&e(r.requestId,null),!0}default:return!1}}export{t as routeSharedHostMessage};
@@ -1,21 +1,21 @@
1
- import{fieldIsShown as e,shownFields as n}from"./chunk-BPXEFVSQ.js";import{TreeSeam as t}from"./chunk-A6Z4SD3I.js";import{DEFAULT_TREE_WORDS as l}from"./chunk-K56YDHYQ.js";import{easelMenuEntries as a}from"./chunk-FIVU2COQ.js";import{SETTINGS_BUCKETS as r,SettingsGroup as o}from"./chunk-RC25EGHD.js";import{DEFAULT_PANEL_WORDS as i}from"./chunk-KFV7N2DJ.js";import{FieldNumber as s}from"./chunk-ZOBSIXRD.js";import{FieldSelect as c}from"./chunk-QAJAEWCZ.js";import{DEFAULT_FIELDS_WORDS as d}from"./chunk-WRFD4EXD.js";import{SettingsField as u,SettingsSegmented as m}from"./chunk-36LVP5WD.js";import{useWords as h}from"./chunk-MFIRYGHW.js";import{useTreeDrag as p,gapToMoveIndex as f}from"./chunk-67GNT6PF.js";import{withTip as b}from"./chunk-P2VEMZH5.js";import{Textarea as g,Input as v,SortableList as y,ListRow as k,ContextMenu as x,tabPanelId as w,Tabs as C,tabButtonId as N}from"efficient-shell/ui";export{LinkPicker}from"efficient-shell/ui";import{useRef as O,useState as D,useLayoutEffect as j,useId as $}from"react";import{jsx as S,jsxs as I}from"react/jsx-runtime";import{ChevronIcon as P,LockIcon as F,MoveUpIcon as L,MoveDownIcon as E,DuplicateIcon as R,TrashIcon as A}from"efficient-shell/icons/efficient";function M({id:e,value:n,onChange:t,placeholder:l,multiline:a=!1,rows:r=3,readOnly:o=!1,ariaLabel:i,ariaLabelledBy:s}){const c=n??"";return a?/* @__PURE__ */S(g,{id:e,size:"sm",className:"es-fin",value:c,rows:r,placeholder:l,readOnly:o,"aria-label":i,"aria-labelledby":s,onChange:e=>t(e.target.value)}):/* @__PURE__ */S(v,{id:e,size:"md",className:"es-fin",type:"text",value:c,placeholder:l,readOnly:o,"aria-label":i,"aria-labelledby":s,onChange:e=>t(e.target.value)})}function T(e,n,t){const l=e.slice();return l.splice(Math.max(0,Math.min(n,l.length)),0,t),l}function W(e,n,t){const l=e.slice(),[a]=l.splice(n,1);return l.splice(Math.max(0,Math.min(t,l.length)),0,a),l}function z(e,n){return e.filter((e,t)=>t!==n)}function H(e){return null===e||"object"!=typeof e?e:JSON.parse(JSON.stringify(e))}var B='input, textarea, select, button, [contenteditable]:not([contenteditable="false"]), [tabindex]',V={parentId:"list",slot:"items"};function K({label:e,icon:n,noun:r,items:o,onChange:i,newItem:s,summary:c,itemName:u,thumb:m,min:g=0,max:v,readOnly:w=!1,open:C,onOpen:N,renderItem:$,renderRow:M,canRemove:K,lockedReason:Z,fixed:J=!1,removeOnRow:Q=!0,canDuplicate:X,above:Y,head:G=!0}){const q=h("fields",d).list,U=h("tree",l),_=r??q.item,ee=!w&&!J&&("number"!=typeof v||o.length<v),ne=o.length<=g,te=e=>!!K&&!K(o[e],e),le=e=>!w&&!J&&Q&&!ne&&!te(e),ae=e=>ee&&(!X||X(o[e],e)),re=(e,n)=>u?u(e,n):q.itemName({noun:_,n:n+1}),oe=O([]),ie=O(null),[se,ce]=D(null),de=O(null),[ue,me]=D(null),[he,pe]=D("");j(()=>{const e=ie.current;if(!e)return;ie.current=null;const n=oe.current[e.index]?.querySelectorAll(B)[e.nth]??oe.current[e.index];if(n?.focus(),n&&null!==e.start&&"setSelectionRange"in n)try{n.setSelectionRange(e.start,e.end)}catch{}});const fe=(e,n)=>{if(n<0||n>=o.length||n===e)return;const t=oe.current[e],l=t?.ownerDocument.activeElement;if(t&&l&&t.contains(l)){const e=[...t.querySelectorAll(B)].indexOf(l),a=l;ie.current={index:n,nth:e,start:"number"==typeof a.selectionStart?a.selectionStart:null,end:"number"==typeof a.selectionEnd?a.selectionEnd:null}}i(W(o,e,n));const a=function(e,n,t){return null===e?null:e===n?t:n<e&&t>=e?e-1:n>e&&t<=e?e+1:e}(C,e,n);a!==C&&N(a),pe(q.moved({n:n+1,total:o.length}))},be=e=>{ee&&(i(T(o,e,s())),M?(ie.current={index:e,nth:0,start:null,end:null},null!==C&&C>=e&&N(C+1)):N(e))},ge=e=>{le(e)&&(i(z(o,e)),C===e?N(null):null!==C&&C>e&&N(C-1))},ve=p({keyOf:e=>String(e),canDrop:(e,n)=>n.parentId===V.parentId&&n.slot===V.slot,onDrop:(e,n)=>{const t=f({...V,index:e},n);t!==e&&fe(e,t)},onStep:(e,n)=>fe(e,e+n),canStep:(e,n)=>e+n>=0&&e+n<o.length,readOnly:w}),ye=e=>{const n=[];return e>0&&n.push({label:q.moveUp,icon:/* @__PURE__ */S(L,{size:14}),shortcut:"⌥↑",onClick:()=>fe(e,e-1)}),e<o.length-1&&n.push({label:q.moveDown,icon:/* @__PURE__ */S(E,{size:14}),shortcut:"⌥↓",onClick:()=>fe(e,e+1)}),ae(e)&&n.push({label:q.duplicate,icon:/* @__PURE__ */S(R,{size:14}),onClick:()=>(e=>{ae(e)&&(i(T(o,e+1,H(o[e]))),null!==C&&C>e&&N(C+1))})(e)}),le(e)&&n.push({label:q.delete,icon:/* @__PURE__ */S(A,{size:14}),danger:!0,onClick:()=>ge(e)}),n},ke=(e,n,t,l)=>{w||0===ye(e).length||me({index:e,x:n,y:t,owner:l})},xe=e=>n=>{const t=o.slice();t[e]=n,i(t)};/* @__PURE__ */
2
- return I("div",{className:"es-list",children:[G?/* @__PURE__ */I("div",{className:"es-list-head",children:[
3
- /* @__PURE__ */I("span",{className:"es-list-label",children:[n?/* @__PURE__ */S("span",{className:"es-field-icon","aria-hidden":"true",children:n}):null,e]}),
4
- /* @__PURE__ */S("span",{className:"es-list-count",children:o.length})]}):null,Y?/* @__PURE__ */S("div",{className:"es-list-above",children:Y}):null,o.length?/* @__PURE__ */I(y,{"aria-label":e,spacing:"comfortable",className:"es-list-rows",rootProps:ve.rootProps(),children:[o.map((e,n)=>{const l=ve.row({item:n,place:{...V,index:n}}),a=l.draggable&&se!==n,r=!M&&C===n,o=!w&&!J&&Q&&te(n),i=["es-list-row",M?"is-inline":"is-item",r?"is-open":"",a?"is-draggable":"",l.dragging?"is-dragging":"",l.drop?`is-drop-${l.drop}`:""].filter(Boolean).join(" ");return[n>0?/* @__PURE__ */S(t,{...ve.seam({place:{...V,index:n}}),onAdd:ee?()=>be(n):void 0,label:q.addHere({noun:_})},`seam-${n}`):null,
5
- /* @__PURE__ */S(k,{className:i,flat:!!M,active:r,draggable:l.draggable,dragHint:U.dragHint,dragging:l.dragging,drop:"before"===l.drop||"after"===l.drop?l.drop:void 0,onMove:l.draggable?e=>fe(n,"up"===e?n-1:n+1):void 0,rowRef:e=>{oe.current[n]=e},rowProps:{...l.rowProps,draggable:a||void 0,onPointerDown:e=>{const t=e.target.closest?.('input, textarea, select, [contenteditable]:not([contenteditable="false"])'),a=!!t&&t===t.ownerDocument.activeElement;e.currentTarget.draggable=l.draggable&&!a,de.current=t&&!a?t:null,ce(a?n:null)},onDragStart:e=>{const n=de.current;de.current=null,n&&n.ownerDocument.activeElement===n&&n.blur(),l.rowProps.onDragStart?.(e)},onContextMenu:e=>{w||(e.preventDefault(),e.stopPropagation(),ke(n,e.clientX,e.clientY,e.currentTarget))},onKeyDown:e=>{if("ContextMenu"===e.key||e.shiftKey&&"F10"===e.key){e.preventDefault();const t=e.currentTarget.ownerDocument,l=e=>e.preventDefault();t.addEventListener("contextmenu",l,{capture:!0,once:!0}),t.defaultView?.setTimeout(()=>t.removeEventListener("contextmenu",l,{capture:!0}),500);const a=e.currentTarget.getBoundingClientRect();return void ke(n,a.left+24,a.bottom,e.currentTarget)}l.rowProps.onKeyDown?.(e)}},actions:w||J||!Q?void 0:o?b(Z?Z(e,n):q.locked,/* @__PURE__ */S("span",{className:"es-list-lock",role:"img","aria-label":Z?Z(e,n):q.locked,children:/* @__PURE__ */S(F,{size:13})})):b(q.deleteItem({noun:_}),/* @__PURE__ */S("button",{type:"button",className:"es-list-x","aria-label":q.deleteItem({noun:_}),disabled:!le(n),onClick:()=>ge(n),children:"×"})),below:r?/* @__PURE__ */S("div",{className:"es-list-item",children:$(e,n,xe(n))}):void 0,children:M?/* @__PURE__ */S("div",{className:"es-list-row-main",children:M(e,n,xe(n))}):/* @__PURE__ */I("button",{type:"button",className:"es-list-open","aria-expanded":r,onClick:()=>N(r?null:n),children:[m?/* @__PURE__ */S("span",{className:"es-list-thumb","aria-hidden":"true",children:m(e,n)}):null,
6
- /* @__PURE__ */S("span",{className:"es-list-row-name",children:re(e,n)}),/* @__PURE__ */S("span",c?{className:"es-list-row-summary",children:c(e,n)}:{className:"es-list-row-summary"}),
7
- /* @__PURE__ */S(P,{size:14,className:"es-list-chev","aria-hidden":"true"})]})},n)]}),
8
- /* @__PURE__ */S(t,{...ve.seam({place:{...V,index:o.length}})})]}):null,w||J?null:/* @__PURE__ */S("button",{type:"button",className:"es-list-add",disabled:!ee,onClick:()=>be(o.length),children:q.add({noun:_})}),
9
- /* @__PURE__ */S("span",{className:"es-list-said","aria-live":"polite",children:he}),ue&&ue.index<o.length?
10
- /* @__PURE__ */S(x,{at:{x:ue.x,y:ue.y},owner:ue.owner,onClose:()=>me(null),items:a(ye(ue.index))}):null]})}var Z=e=>e<6?e+1:6,J=(e,n)=>"string"==typeof e.label&&e.label?e.label:n;function Q({field:e,name:t,id:l,value:a,onChange:r,readOnly:i,context:s,showWhenContext:c,renderers:d,headingLevel:u=3}){const[m,h]=D(!0),p=a&&"object"==typeof a?a:{};/* @__PURE__ */
11
- return S(o,{id:`${l}-group`,title:J(e,t),open:m,onToggle:h,level:u,children:Object.entries(n(e.objectFields,{values:p,context:c})).map(([e,n])=>/* @__PURE__ */S(Y,{field:n,name:`${t}.${e}`,id:`${l}-${e}`,value:p[e],onChange:n=>r({...p,[e]:n}),readOnly:i,context:s,showWhenContext:c,renderers:d,headingLevel:Z(u)},e))})}function X({field:e,name:t,id:l,value:a,onChange:r,readOnly:o,context:i,showWhenContext:s,renderers:c,openItem:d,onOpenItem:u,headingLevel:m}){const[h,p]=D(null),f=u?d??null:h,b=u??p,g=Array.isArray(a)?a:[],v=e.getItemSummary;/* @__PURE__ */
12
- return S(K,{label:J(e,t),icon:e.icon,noun:"string"==typeof e.noun?e.noun:void 0,items:g,onChange:r,newItem:()=>H({...e.defaultItemProps??{}}),summary:v?(e,n)=>v(e,n):void 0,min:e.min,max:e.max,readOnly:o,open:f,onOpen:b,renderItem:(a,r,d)=>Object.entries(n(e.arrayFields,{values:a,context:s})).map(([e,n])=>/* @__PURE__ */S(Y,{field:n,name:`${t}[${r}].${e}`,id:`${l}-${r}-${e}`,value:a?.[e],onChange:n=>d({...a,[e]:n}),readOnly:o,context:i,showWhenContext:s,renderers:c,headingLevel:m},e))})}function Y(e){const{field:n,name:t,id:l,value:a,onChange:r,readOnly:o,context:i,renderers:d}=e;if(!n||n.marker||!1===n.visible)return null;const h=d?.[n.type];if(h)return h({field:n,name:t,id:l,value:a,onChange:r,readOnly:o});switch(n.type){case"custom":{const e={...i,field:n,name:t,id:l,value:a,onChange:r,readOnly:o};return n.render(e)}case"text":case"textarea":/* @__PURE__ */
13
- return S(u,{label:J(n,t),htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */S(M,{id:l,value:"string"==typeof a?a:null==a?"":String(a),onChange:r,placeholder:n.placeholder,multiline:"textarea"===n.type,readOnly:o})});case"number":/* @__PURE__ */
14
- return S(u,{label:J(n,t),htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */S(s,{id:l,value:"number"==typeof a?a:void 0,onChange:r,min:n.min,max:n.max,step:n.step,placeholder:n.placeholder,readOnly:o})});case"select":{const e=`${l}-label`;/* @__PURE__ */
15
- return S(u,{label:J(n,t),labelId:e,htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */S(c,{id:l,value:a,options:n.options,onChange:r,readOnly:o,ariaLabelledBy:e})})}case"radio":/* @__PURE__ */
16
- return S(u,{label:J(n,t),icon:n.icon,hint:n.hint,children:/* @__PURE__ */S(m,{ariaLabel:J(n,t),value:a,options:n.options.map(e=>({id:e.value,label:e.label,icon:e.icon,disabled:e.disabled||o})),onChange:e=>{o||r(e)}})});case"object":/* @__PURE__ */
17
- return S(Q,{...e,field:n});case"array":/* @__PURE__ */
18
- return S(X,{...e,field:n});case"slot":return null}}var G=e=>r.includes(e);function q(n,t){let l,a=r[0];const o=[],i=/* @__PURE__ */new Set;for(const[r,s]of Object.entries(n))s&&(G(s.bucket)&&((s.marker||s.bucket!==a)&&(l=void 0),a=s.bucket),s.marker&&"string"==typeof s.fold?l={key:r,title:s.fold}:s.marker&&!1===s.fold&&(l=void 0),s.marker||!1===s.visible||t&&!e(s,t)||(o.push(l?{name:r,field:s,bucket:a,fold:l}:{name:r,field:s,bucket:a}),"slot"!==s.type&&i.add(a)));return{rows:o,buckets:r.filter(e=>i.has(e))}}function U(e){return new Map(q(e).rows.map(e=>[e.name,e.bucket]))}function _(e){const n=[];for(const t of e){const e=n[n.length-1];e&&e.fold?.key===t.fold?.key?e.rows.push(t):n.push({fold:t.fold,rows:[t]})}return n}function ee({fields:e,values:n,onChange:t,readOnly:l=!1,context:a,showWhenContext:r,tab:s,onTab:c,tabs:d=!0,tabIcons:u,renderers:m,idPrefix:p,ariaLabel:f,lead:b,children:g,leadFold:v,closedFolds:y,onFold:k,headingLevel:x=3}){const O=h("panel",i),j=$(),P=p??`es-insp${j.replace(/:/g,"")}`,F=q(e,{values:n,context:r}),[L,E]=D(void 0),R=s??L,A=R&&F.buckets.includes(R)?R:F.buckets[0],[M,T]=D(null),W=M&&M.panel===P&&F.rows.some(e=>e.name===M.name)?M:null,z=d&&F.buckets.length>1,H=z&&A?w(P,A):`${P}-rows`,[B,V]=D(()=>/* @__PURE__ */new Set),K=y??B,J=(e,n)=>{/* @__PURE__ */return S(o,{title:e.title,open:!K.has(e.key),onToggle:n=>((e,n)=>{void 0===y&&V(t=>{const l=new Set(t);return n?l.delete(e):l.add(e),l}),k?.(e,n)})(e.key,n),id:`${P}-fold-${t=e.key,[...t].map(e=>/[A-Za-z0-9_-]/.test(e)?e:`-u${e.codePointAt(0).toString(16)}-`).join("")}`,level:x,children:n});var t},Q=e=>z&&e!==A,X=({name:e,field:o,bucket:i,fold:s})=>/* @__PURE__ */S("div",{className:"es-insp-row","data-field":e,"data-bucket":i,hidden:!!Q(i)||void 0,children:/* @__PURE__ */S(Y,{field:o,name:e,id:`${P}-${e}`,value:n[e],onChange:n=>t(e,n),readOnly:l,context:a,showWhenContext:r,renderers:m,openItem:W&&W.name===e?W.index:null,onOpenItem:n=>T(null===n?null:{panel:P,name:e,index:n}),headingLevel:s?Z(x):x})},e);/* @__PURE__ */
19
- return I("div",{className:"es-insp",children:[z?/* @__PURE__ */S("div",{className:"es-insp-tabs",children:/* @__PURE__ */S(C,{variant:"underline",block:!0,"aria-label":f??O.settings,idPrefix:P,value:A,onChange:e=>{const n=e;void 0===s&&E(n),c?.(n)},items:F.buckets.map(e=>{const n=O.buckets[e],t=u?.[e];return t?{id:e,icon:t,label:/* @__PURE__ */S("span",{className:"sr-only",children:n}),tooltip:n}:{id:e,label:n}})})}):null,
20
- /* @__PURE__ */I("div",{className:"es-insp-rows",id:H,role:z?"tabpanel":void 0,"aria-labelledby":z&&A?N(P,A):void 0,children:[b?v?/* @__PURE__ */S("div",{className:"es-insp-band","data-fold":v.key,children:J(v,b)}):b:null,_(F.rows).map((e,n)=>{if(!e.fold)return e.rows.map(X);const t=e.rows[0].bucket,l=e.rows.every(e=>"slot"===e.field.type);/* @__PURE__ */
21
- return S("div",{className:"es-insp-band","data-fold":e.fold.key,"data-bucket":t,hidden:!(!Q(t)&&!l)||void 0,children:J(e.fold,e.rows.map(X))},`fold-${e.fold.key}-${n}`)}),g]})]})}export{M as FieldText,ee as Inspector,Y as InspectorField,K as ListField,U as bucketsOf,H as copyItem,T as insertAt,J as labelOf,W as moveTo,q as planFields,z as removeAt};
1
+ import{fieldIsShown as e,shownFields as n}from"./chunk-BPXEFVSQ.js";import{TreeSeam as t}from"./chunk-A6Z4SD3I.js";import{DEFAULT_TREE_WORDS as l}from"./chunk-K56YDHYQ.js";import{easelMenuEntries as a}from"./chunk-FIVU2COQ.js";import{SETTINGS_BUCKETS as r,SettingsGroup as o}from"./chunk-RC25EGHD.js";import{DEFAULT_PANEL_WORDS as i}from"./chunk-KFV7N2DJ.js";import{FieldNumber as s}from"./chunk-ZOBSIXRD.js";import{FieldSelect as c}from"./chunk-QAJAEWCZ.js";import{DEFAULT_FIELDS_WORDS as d}from"./chunk-WRFD4EXD.js";import{SettingsField as u,SettingsSegmented as m}from"./chunk-VANKQVOW.js";import{useWords as h}from"./chunk-MFIRYGHW.js";import{useTreeDrag as p,gapToMoveIndex as f}from"./chunk-3S5N4HLJ.js";import{withTip as b}from"./chunk-P2VEMZH5.js";import{Textarea as g,Input as v,SortableList as y,ListRow as k,ContextMenu as x,tabPanelId as w,Tabs as C,tabButtonId as N}from"efficient-shell/ui";export{LinkPicker}from"efficient-shell/ui";import{useRef as O,useState as j,useLayoutEffect as D,useId as S}from"react";import{jsx as $,jsxs as I}from"react/jsx-runtime";import{ChevronIcon as L,LockIcon as P,MoveUpIcon as F,MoveDownIcon as E,DuplicateIcon as R,TrashIcon as A}from"efficient-shell/icons/efficient";function M({id:e,value:n,onChange:t,placeholder:l,multiline:a=!1,rows:r=3,readOnly:o=!1,ariaLabel:i,ariaLabelledBy:s}){const c=n??"";return a?/* @__PURE__ */$(g,{id:e,size:"sm",className:"es-fin",value:c,rows:r,placeholder:l,readOnly:o,"aria-label":i,"aria-labelledby":s,onChange:e=>t(e.target.value)}):/* @__PURE__ */$(v,{id:e,size:"md",className:"es-fin",type:"text",value:c,placeholder:l,readOnly:o,"aria-label":i,"aria-labelledby":s,onChange:e=>t(e.target.value)})}function W(e,n,t){const l=e.slice();return l.splice(Math.max(0,Math.min(n,l.length)),0,t),l}function z(e,n,t){const l=e.slice(),[a]=l.splice(n,1);return l.splice(Math.max(0,Math.min(t,l.length)),0,a),l}function T(e,n){return e.filter((e,t)=>t!==n)}function H(e){return null===e||"object"!=typeof e?e:JSON.parse(JSON.stringify(e))}var V='input, textarea, select, button, [contenteditable]:not([contenteditable="false"]), [tabindex]',B={parentId:"list",slot:"items"};function K({label:e,icon:n,noun:r,items:o,onChange:i,newItem:s,summary:c,itemName:u,thumb:m,min:g=0,max:v,readOnly:w=!1,open:C,onOpen:N,renderItem:S,renderRow:M,canRemove:K,lockedReason:J,fixed:Q=!1,removeOnRow:Z=!0,canDuplicate:X,above:Y,head:q=!0}){const G=h("fields",d).list,U=h("tree",l),_=r??G.item,ee=!w&&!Q&&("number"!=typeof v||o.length<v),ne=o.length<=g,te=e=>!!K&&!K(o[e],e),le=e=>!w&&!Q&&Z&&!ne&&!te(e),ae=e=>ee&&(!X||X(o[e],e)),re=(e,n)=>u?u(e,n):G.itemName({noun:_,n:n+1}),oe=O([]),ie=O(null),[se,ce]=j(null),de=O(null),[ue,me]=j(null),[he,pe]=j("");D(()=>{const e=ie.current;if(!e)return;ie.current=null;const n=oe.current[e.index]?.querySelectorAll(V)[e.nth]??oe.current[e.index];if(n?.focus(),n&&null!==e.start&&"setSelectionRange"in n)try{n.setSelectionRange(e.start,e.end)}catch{}});const fe=(e,n)=>{if(n<0||n>=o.length||n===e)return;const t=oe.current[e],l=t?.ownerDocument.activeElement;if(t&&l&&t.contains(l)){const e=[...t.querySelectorAll(V)].indexOf(l),a=l;ie.current={index:n,nth:e,start:"number"==typeof a.selectionStart?a.selectionStart:null,end:"number"==typeof a.selectionEnd?a.selectionEnd:null}}i(z(o,e,n));const a=function(e,n,t){return null===e?null:e===n?t:n<e&&t>=e?e-1:n>e&&t<=e?e+1:e}(C,e,n);a!==C&&N(a),pe(G.moved({n:n+1,total:o.length}))},be=e=>{ee&&(i(W(o,e,s())),M?(ie.current={index:e,nth:0,start:null,end:null},null!==C&&C>=e&&N(C+1)):N(e))},ge=e=>{le(e)&&(i(T(o,e)),C===e?N(null):null!==C&&C>e&&N(C-1))},ve=p({keyOf:e=>String(e),canDrop:(e,n)=>n.parentId===B.parentId&&n.slot===B.slot,onDrop:(e,n)=>{const t=f({...B,index:e},n);t!==e&&fe(e,t)},onStep:(e,n)=>fe(e,e+n),canStep:(e,n)=>e+n>=0&&e+n<o.length,readOnly:w}),ye=e=>{const n=[];return e>0&&n.push({label:G.moveUp,icon:/* @__PURE__ */$(F,{size:14}),shortcut:"⌥↑",onClick:()=>fe(e,e-1)}),e<o.length-1&&n.push({label:G.moveDown,icon:/* @__PURE__ */$(E,{size:14}),shortcut:"⌥↓",onClick:()=>fe(e,e+1)}),ae(e)&&n.push({label:G.duplicate,icon:/* @__PURE__ */$(R,{size:14}),onClick:()=>(e=>{ae(e)&&(i(W(o,e+1,H(o[e]))),null!==C&&C>e&&N(C+1))})(e)}),le(e)&&n.push({label:G.delete,icon:/* @__PURE__ */$(A,{size:14}),danger:!0,onClick:()=>ge(e)}),n},ke=(e,n,t,l)=>{w||0===ye(e).length||me({index:e,x:n,y:t,owner:l})},xe=e=>n=>{const t=o.slice();t[e]=n,i(t)};/* @__PURE__ */
2
+ return I("div",{className:"es-list",children:[q?/* @__PURE__ */I("div",{className:"es-list-head",children:[
3
+ /* @__PURE__ */I("span",{className:"es-list-label",children:[n?/* @__PURE__ */$("span",{className:"es-field-icon","aria-hidden":"true",children:n}):null,e]}),
4
+ /* @__PURE__ */$("span",{className:"es-list-count",children:o.length})]}):null,Y?/* @__PURE__ */$("div",{className:"es-list-above",children:Y}):null,o.length?/* @__PURE__ */I(y,{"aria-label":e,spacing:"comfortable",className:"es-list-rows",rootProps:ve.rootProps(),children:[o.map((e,n)=>{const l=ve.row({item:n,place:{...B,index:n}}),a=l.draggable&&se!==n,r=!M&&C===n,o=!w&&!Q&&Z&&te(n),i=["es-list-row",M?"is-inline":"is-item",r?"is-open":"",a?"is-draggable":"",l.dragging?"is-dragging":"",l.drop?`is-drop-${l.drop}`:""].filter(Boolean).join(" ");return[n>0?/* @__PURE__ */$(t,{...ve.seam({place:{...B,index:n}}),onAdd:ee?()=>be(n):void 0,label:G.addHere({noun:_})},`seam-${n}`):null,
5
+ /* @__PURE__ */$(k,{className:i,flat:!!M,active:r,draggable:l.draggable,dragHint:U.dragHint,dragging:l.dragging,drop:"before"===l.drop||"after"===l.drop?l.drop:void 0,onMove:l.draggable?e=>fe(n,"up"===e?n-1:n+1):void 0,rowRef:e=>{oe.current[n]=e},rowProps:{...l.rowProps,draggable:a||void 0,onPointerDown:e=>{const t=e.target.closest?.('input, textarea, select, [contenteditable]:not([contenteditable="false"])'),a=!!t&&t===t.ownerDocument.activeElement;e.currentTarget.draggable=l.draggable&&!a,de.current=t&&!a?t:null,ce(a?n:null)},onDragStart:e=>{const n=de.current;de.current=null,n&&n.ownerDocument.activeElement===n&&n.blur(),l.rowProps.onDragStart?.(e)},onContextMenu:e=>{w||(e.preventDefault(),e.stopPropagation(),ke(n,e.clientX,e.clientY,e.currentTarget))},onKeyDown:e=>{if("ContextMenu"===e.key||e.shiftKey&&"F10"===e.key){e.preventDefault();const t=e.currentTarget.ownerDocument,l=e=>e.preventDefault();t.addEventListener("contextmenu",l,{capture:!0,once:!0}),t.defaultView?.setTimeout(()=>t.removeEventListener("contextmenu",l,{capture:!0}),500);const a=e.currentTarget.getBoundingClientRect();return void ke(n,a.left+24,a.bottom,e.currentTarget)}l.rowProps.onKeyDown?.(e)}},actions:w||Q||!Z?void 0:o?b(J?J(e,n):G.locked,/* @__PURE__ */$("span",{className:"es-list-lock",role:"img","aria-label":J?J(e,n):G.locked,children:/* @__PURE__ */$(P,{size:13})})):b(G.deleteItem({noun:_}),/* @__PURE__ */$("button",{type:"button",className:"es-list-x","aria-label":G.deleteItem({noun:_}),disabled:!le(n),onClick:()=>ge(n),children:"×"})),below:r?/* @__PURE__ */$("div",{className:"es-list-item",children:S(e,n,xe(n))}):void 0,children:M?/* @__PURE__ */$("div",{className:"es-list-row-main",children:M(e,n,xe(n))}):/* @__PURE__ */I("button",{type:"button",className:"es-list-open","aria-expanded":r,onClick:()=>N(r?null:n),children:[m?/* @__PURE__ */$("span",{className:"es-list-thumb","aria-hidden":"true",children:m(e,n)}):null,
6
+ /* @__PURE__ */$("span",{className:"es-list-row-name",children:re(e,n)}),/* @__PURE__ */$("span",c?{className:"es-list-row-summary",children:c(e,n)}:{className:"es-list-row-summary"}),
7
+ /* @__PURE__ */$(L,{size:14,className:"es-list-chev","aria-hidden":"true"})]})},n)]}),
8
+ /* @__PURE__ */$(t,{...ve.seam({place:{...B,index:o.length}})})]}):null,w||Q?null:/* @__PURE__ */$("button",{type:"button",className:"es-list-add",disabled:!ee,onClick:()=>be(o.length),children:G.add({noun:_})}),
9
+ /* @__PURE__ */$("span",{className:"es-list-said","aria-live":"polite",children:he}),ue&&ue.index<o.length?
10
+ /* @__PURE__ */$(x,{at:{x:ue.x,y:ue.y},owner:ue.owner,onClose:()=>me(null),items:a(ye(ue.index))}):null]})}var J=e=>e<6?e+1:6,Q=(e,n)=>"string"==typeof e.label&&e.label?e.label:n;function Z({field:e,name:t,id:l,value:a,onChange:r,readOnly:i,context:s,showWhenContext:c,renderers:d,headingLevel:u=3}){const[m,h]=j(!0),p=a&&"object"==typeof a?a:{};/* @__PURE__ */
11
+ return $(o,{id:`${l}-group`,title:Q(e,t),open:m,onToggle:h,level:u,children:Object.entries(n(e.objectFields,{values:p,context:c})).map(([e,n])=>/* @__PURE__ */$(Y,{field:n,name:`${t}.${e}`,id:`${l}-${e}`,value:p[e],onChange:n=>r({...p,[e]:n}),readOnly:i,context:s,showWhenContext:c,renderers:d,headingLevel:J(u)},e))})}function X({field:e,name:t,id:l,value:a,onChange:r,readOnly:o,context:i,showWhenContext:s,renderers:c,openItem:d,onOpenItem:u,headingLevel:m}){const[h,p]=j(null),f=u?d??null:h,b=u??p,g=Array.isArray(a)?a:[],v=e.getItemSummary;/* @__PURE__ */
12
+ return $(K,{label:Q(e,t),icon:e.icon,noun:"string"==typeof e.noun?e.noun:void 0,items:g,onChange:r,newItem:()=>H({...e.defaultItemProps??{}}),summary:v?(e,n)=>v(e,n):void 0,min:e.min,max:e.max,readOnly:o,open:f,onOpen:b,renderItem:(a,r,d)=>Object.entries(n(e.arrayFields,{values:a,context:s})).map(([e,n])=>/* @__PURE__ */$(Y,{field:n,name:`${t}[${r}].${e}`,id:`${l}-${r}-${e}`,value:a?.[e],onChange:n=>d({...a,[e]:n}),readOnly:o,context:i,showWhenContext:s,renderers:c,headingLevel:m},e))})}function Y(e){const{field:n,name:t,id:l,value:a,onChange:r,readOnly:o,context:i,renderers:d}=e;if(!n||n.marker||!1===n.visible)return null;const h=d?.[n.type];if(h)return h({field:n,name:t,id:l,value:a,onChange:r,readOnly:o});switch(n.type){case"custom":{const e={...i,field:n,name:t,id:l,value:a,onChange:r,readOnly:o};return n.render(e)}case"text":case"textarea":/* @__PURE__ */
13
+ return $(u,{label:Q(n,t),htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */$(M,{id:l,value:"string"==typeof a?a:null==a?"":String(a),onChange:r,placeholder:n.placeholder,multiline:"textarea"===n.type,readOnly:o})});case"number":/* @__PURE__ */
14
+ return $(u,{label:Q(n,t),htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */$(s,{id:l,value:"number"==typeof a?a:void 0,onChange:r,min:n.min,max:n.max,step:n.step,placeholder:n.placeholder,readOnly:o})});case"select":{const e=`${l}-label`;/* @__PURE__ */
15
+ return $(u,{label:Q(n,t),labelId:e,htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */$(c,{id:l,value:a,options:n.options,onChange:r,readOnly:o,ariaLabelledBy:e})})}case"radio":/* @__PURE__ */
16
+ return $(u,{label:Q(n,t),icon:n.icon,hint:n.hint,children:/* @__PURE__ */$(m,{ariaLabel:Q(n,t),value:a,options:n.options.map(e=>({id:e.value,label:e.label,icon:e.icon,disabled:e.disabled||o})),onChange:e=>{o||r(e)}})});case"object":/* @__PURE__ */
17
+ return $(Z,{...e,field:n});case"array":/* @__PURE__ */
18
+ return $(X,{...e,field:n});case"slot":return null}}var q=e=>r.includes(e);function G(n,t){let l,a=r[0];const o=[],i=/* @__PURE__ */new Set;for(const[r,s]of Object.entries(n))s&&(q(s.bucket)&&((s.marker||s.bucket!==a)&&(l=void 0),a=s.bucket),s.marker&&"string"==typeof s.fold?l={key:r,title:s.fold}:s.marker&&!1===s.fold&&(l=void 0),s.marker||!1===s.visible||t&&!e(s,t)||(o.push(l?{name:r,field:s,bucket:a,fold:l}:{name:r,field:s,bucket:a}),"slot"!==s.type&&i.add(a)));return{rows:o,buckets:r.filter(e=>i.has(e))}}function U(e){return new Map(G(e).rows.map(e=>[e.name,e.bucket]))}function _(e){const n=[];for(const t of e){const e=n[n.length-1];e&&e.fold?.key===t.fold?.key?e.rows.push(t):n.push({fold:t.fold,rows:[t]})}return n}function ee({fields:e,values:n,onChange:t,readOnly:l=!1,context:a,showWhenContext:r,tab:s,onTab:c,tabs:d=!0,tabIcons:u,renderers:m,idPrefix:p,ariaLabel:f,lead:b,children:g,leadFold:v,closedFolds:y,onFold:k,headingLevel:x=3}){const O=h("panel",i),D=S(),L=p??`es-insp${D.replace(/:/g,"")}`,P=G(e,{values:n,context:r}),[F,E]=j(void 0),R=s??F,A=R&&P.buckets.includes(R)?R:P.buckets[0],[M,W]=j(null),z=M&&M.panel===L&&P.rows.some(e=>e.name===M.name)?M:null,T=d&&P.buckets.length>1,H=T&&A?w(L,A):`${L}-rows`,[V,B]=j(()=>/* @__PURE__ */new Set),K=y??V,Q=(e,n)=>{/* @__PURE__ */return $(o,{title:e.title,open:!K.has(e.key),onToggle:n=>((e,n)=>{void 0===y&&B(t=>{const l=new Set(t);return n?l.delete(e):l.add(e),l}),k?.(e,n)})(e.key,n),id:`${L}-fold-${t=e.key,[...t].map(e=>/[A-Za-z0-9_-]/.test(e)?e:`-u${e.codePointAt(0).toString(16)}-`).join("")}`,level:x,children:n});var t},Z=e=>T&&e!==A,X=({name:e,field:o,bucket:i,fold:s})=>/* @__PURE__ */$("div",{className:"es-insp-row","data-field":e,"data-bucket":i,hidden:!!Z(i)||void 0,children:/* @__PURE__ */$(Y,{field:o,name:e,id:`${L}-${e}`,value:n[e],onChange:n=>t(e,n),readOnly:l,context:a,showWhenContext:r,renderers:m,openItem:z&&z.name===e?z.index:null,onOpenItem:n=>W(null===n?null:{panel:L,name:e,index:n}),headingLevel:s?J(x):x})},e);/* @__PURE__ */
19
+ return I("div",{className:"es-insp",children:[T?/* @__PURE__ */$("div",{className:"es-insp-tabs",children:/* @__PURE__ */$(C,{variant:"underline",block:!0,"aria-label":f??O.settings,idPrefix:L,value:A,onChange:e=>{const n=e;void 0===s&&E(n),c?.(n)},items:P.buckets.map(e=>{const n=O.buckets[e],t=u?.[e];return t?{id:e,icon:t,label:/* @__PURE__ */$("span",{className:"sr-only",children:n}),tooltip:n}:{id:e,label:n}})})}):null,
20
+ /* @__PURE__ */I("div",{className:"es-insp-rows",id:H,role:T?"tabpanel":void 0,"aria-labelledby":T&&A?N(L,A):void 0,children:[b?v?/* @__PURE__ */$("div",{className:"es-insp-band","data-fold":v.key,children:Q(v,b)}):b:null,_(P.rows).map((e,n)=>{if(!e.fold)return e.rows.map(X);const t=e.rows[0].bucket,l=e.rows.every(e=>"slot"===e.field.type);/* @__PURE__ */
21
+ return $("div",{className:"es-insp-band","data-fold":e.fold.key,"data-bucket":t,hidden:!(!Z(t)&&!l)||void 0,children:Q(e.fold,e.rows.map(X))},`fold-${e.fold.key}-${n}`)}),g]})]})}export{M as FieldText,ee as Inspector,Y as InspectorField,K as ListField,U as bucketsOf,H as copyItem,W as insertAt,Q as labelOf,z as moveTo,G as planFields,T as removeAt};
@@ -1 +1 @@
1
- import{find as n,remove as t,getList as e,newId as r,duplicate as o,move as l,copyNode as a,insert as c,setProps as i,slotsOf as d}from"./chunk-KRXQM65X.js";import{useRef as s,useSyncExternalStore as p,useCallback as u,useMemo as f}from"react";var m=n=>({kind:"node",id:n});function x(r,o,l,a="none"){const c=n(r,o,l),i=t(r,o,l);if("none"===a||!c)return{data:i,select:null};const d=e(r,o,c.place)??[],s=d[c.place.index+1]??d[c.place.index-1];return s?.props?.id?{data:i,select:m(s.props.id)}:"root"!==c.place.parentId?{data:i,select:m(c.place.parentId)}:{data:i,select:null}}function g(t,e,l,a={}){const c=n(t,e,l)?.node,i=a.id??r(c?.type??"Node");return{data:o(t,e,l,{strip:a.strip,id:i}),select:m(i)}}function I(n,t,e,r){return{data:l(n,t,e,r),select:m(e)}}var h=(n,t)=>({min:0,max:t-1});function v(t,r,o,l,a=h){const c=n(t,r,o);if(!c)return!1;const i=e(t,r,c.place)?.length??0,{min:d,max:s}=a(c.place,i),p=c.place.index+l;return c.place.index>=d&&c.place.index<=s&&p>=d&&p<=s}function b(t,e,r,o,l=h){if(!v(t,e,r,o,l))return null;const a=n(t,e,r);return I(t,e,r,{...a.place,index:a.place.index+o})}function k(n,t,e,r,o={}){const l=a(e,t,{strip:o.strip});return{data:c(n,t,r,l),select:m(l.props.id)}}function y(t,r,o,l){if(n(t,r,o.props.id))return null;const a=e(t,r,l)??[],i={...l,index:Math.max(0,Math.min(l.index,a.length))};return{data:c(t,r,i,o),select:m(o.props.id)}}function M(e,r,o,l){const a=n(e,r,o);return a?l.props.id!==o&&n(e,r,l.props.id)?null:{data:c(t(e,r,o),r,a.place,l),select:m(l.props.id)}:null}function O(n,t,e,r){return{data:i(n,t,e,r),select:void 0}}function z(t,e,r,o=()=>!1){if(!r)return null;if("slot"===r.kind)return n(t,e,r.parentId)?m(r.parentId):null;const l=n(t,e,r.id);if(!l||"root"===l.place.parentId)return null;const a=n(t,e,l.place.parentId);return a?o(a.node,l.place.slot)?{kind:"slot",parentId:a.node.props.id,slot:l.place.slot}:m(a.node.props.id):null}function R(t,e,r,o){const l=n(t,e,r);if(!l)return[];const a=l.path.filter(n=>"root"!==n.parentId).map(n=>n.parentId);return o?[...a.filter(r=>{const l=n(t,e,r);return!l||!o(l.node)}),r]:[...a,r]}function B(n,t){if(0===n.length)return null;const e=null===t?-1:n.indexOf(t);return-1===e?n[0]:n[Math.min(e+1,n.length-1)]}function X(t,e,r,o,l){const a=n(t,e,r);return a?0===d(a.node,e).length?r:B(R(t,e,r,l),o):null}function $(t,e,r,o,l,a,c){const i=n(t,e,r);if(!i)return null;if(0===d(i.node,e).length)return{node:r,part:o};const s="\0part:"+o,p=B([...R(t,e,r,c),s],l===r&&a===o?s:l);return p===s?{node:r,part:o}:{node:p??r,part:null}}function j(t,e,r){if(!r||"node"!==r.kind)return null;const o=n(t,e,r.id);return o?{zone:`${o.place.parentId}:${o.place.slot}`,index:o.place.index}:null}function w(n,t,r){if(!r)return null;const[o,l]=(r.zone??"root:default-zone").split(/:(.*)/s),a={parentId:o,slot:l},c=e(n,t,a)?.[r.index];return c?.props?.id?m(c.props.id):null}var K={get:()=>null,set:()=>{},subscribe:()=>()=>{}};function L(t){const e=s(t);e.current=t;const r=t.clipboard??K,o=p(r.subscribe,r.get,r.get),l=u(n=>{const t=e.current;if(t.readOnly)return!1;const r=n(t.data,t.config);return!!r&&((r.data!==t.data||void 0!==r.select)&&(t.commit(r.data,{select:r.select}),e.current={...t,data:r.data},!0))},[]);return f(()=>{const t=()=>e.current,r=(e,r)=>{const o=n(t().data,t().config,e);return o?{node:o.node,label:r,from:{parentId:o.place.parentId,slot:o.place.slot}}:null};return{held:o,remove:n=>l((e,r)=>x(e,r,n,t().afterRemove)),duplicate:n=>l((e,r)=>g(e,r,n,{strip:t().strip})),move:(n,t)=>l((e,r)=>I(e,r,n,t)),step:(n,e)=>l((r,o)=>b(r,o,n,e,t().stepBounds)),canStep:(n,e)=>v(t().data,t().config,n,e,t().stepBounds),setProps:(n,t)=>l((e,r)=>O(e,r,n,t)),copy:(n,e)=>{const o=r(n,e);return o&&(t().clipboard??K).set(o),!!o},cut:(n,e)=>{if(t().readOnly)return!1;const o=r(n,e);return!!o&&((t().clipboard??K).set(o),l((e,r)=>x(e,r,n,t().afterRemove)))},paste:n=>{const e=(t().clipboard??K).get();return!!e&&l((r,o)=>k(r,o,e.node,n,{strip:t().strip}))},restore:(n,t)=>l((e,r)=>y(e,r,n,t)),swap:(n,t)=>l((e,r)=>M(e,r,n,t)),parentOf:n=>z(t().data,t().config,n,t().slotIsLevel)}},[o,l])}export{v as canStep,X as clickPick,$ as clickPickPart,w as fromItemSelector,B as nextInChain,R as nodeChain,z as parentStep,g as planDuplicate,I as planMove,k as planPaste,x as planRemove,y as planRestore,O as planSetProps,b as planStep,M as planSwap,j as toItemSelector,L as useNodeOps};
1
+ import{find as n,remove as t,getList as e,newId as r,duplicate as o,move as l,copyNode as a,insert as c,setProps as i,slotsOf as d}from"./chunk-K7BTCBWD.js";import{useRef as s,useSyncExternalStore as p,useCallback as u,useMemo as f}from"react";var m=n=>({kind:"node",id:n});function x(r,o,l,a="none"){const c=n(r,o,l),i=t(r,o,l);if("none"===a||!c)return{data:i,select:null};const d=e(r,o,c.place)??[],s=d[c.place.index+1]??d[c.place.index-1];return s?.props?.id?{data:i,select:m(s.props.id)}:"root"!==c.place.parentId?{data:i,select:m(c.place.parentId)}:{data:i,select:null}}function g(t,e,l,a={}){const c=n(t,e,l)?.node,i=a.id??r(c?.type??"Node");return{data:o(t,e,l,{strip:a.strip,id:i}),select:m(i)}}function I(n,t,e,r){return{data:l(n,t,e,r),select:m(e)}}var h=(n,t)=>({min:0,max:t-1});function v(t,r,o,l,a=h){const c=n(t,r,o);if(!c)return!1;const i=e(t,r,c.place)?.length??0,{min:d,max:s}=a(c.place,i),p=c.place.index+l;return c.place.index>=d&&c.place.index<=s&&p>=d&&p<=s}function b(t,e,r,o,l=h){if(!v(t,e,r,o,l))return null;const a=n(t,e,r);return I(t,e,r,{...a.place,index:a.place.index+o})}function k(n,t,e,r,o={}){const l=a(e,t,{strip:o.strip});return{data:c(n,t,r,l),select:m(l.props.id)}}function y(t,r,o,l){if(n(t,r,o.props.id))return null;const a=e(t,r,l)??[],i={...l,index:Math.max(0,Math.min(l.index,a.length))};return{data:c(t,r,i,o),select:m(o.props.id)}}function B(e,r,o,l){const a=n(e,r,o);return a?l.props.id!==o&&n(e,r,l.props.id)?null:{data:c(t(e,r,o),r,a.place,l),select:m(l.props.id)}:null}function O(n,t,e,r){return{data:i(n,t,e,r),select:void 0}}function z(t,e,r,o=()=>!1){if(!r)return null;if("slot"===r.kind)return n(t,e,r.parentId)?m(r.parentId):null;const l=n(t,e,r.id);if(!l||"root"===l.place.parentId)return null;const a=n(t,e,l.place.parentId);return a?o(a.node,l.place.slot)?{kind:"slot",parentId:a.node.props.id,slot:l.place.slot}:m(a.node.props.id):null}function M(t,e,r,o){const l=n(t,e,r);if(!l)return[];const a=l.path.filter(n=>"root"!==n.parentId).map(n=>n.parentId);return o?[...a.filter(r=>{const l=n(t,e,r);return!l||!o(l.node)}),r]:[...a,r]}function R(n,t){if(0===n.length)return null;const e=null===t?-1:n.indexOf(t);return-1===e?n[0]:n[Math.min(e+1,n.length-1)]}function $(t,e,r,o,l){const a=n(t,e,r);return a?0===d(a.node,e).length?r:R(M(t,e,r,l),o):null}function j(t,e,r,o,l,a,c){const i=n(t,e,r);if(!i)return null;if(0===d(i.node,e).length)return{node:r,part:o};const s="\0part:"+o,p=R([...M(t,e,r,c),s],l===r&&a===o?s:l);return p===s?{node:r,part:o}:{node:p??r,part:null}}function w(t,e,r){if(!r||"node"!==r.kind)return null;const o=n(t,e,r.id);return o?{zone:`${o.place.parentId}:${o.place.slot}`,index:o.place.index}:null}function C(n,t,r){if(!r)return null;const[o,l]=(r.zone??"root:default-zone").split(/:(.*)/s),a={parentId:o,slot:l},c=e(n,t,a)?.[r.index];return c?.props?.id?m(c.props.id):null}var D={get:()=>null,set:()=>{},subscribe:()=>()=>{}};function K(t){const e=s(t);e.current=t;const r=t.clipboard??D,o=p(r.subscribe,r.get,r.get),l=u(n=>{const t=e.current;if(t.readOnly)return!1;const r=n(t.data,t.config);return!!r&&((r.data!==t.data||void 0!==r.select)&&(t.commit(r.data,{select:r.select}),e.current={...t,data:r.data},!0))},[]);return f(()=>{const t=()=>e.current,r=(e,r)=>{const o=n(t().data,t().config,e);return o?{node:o.node,label:r,from:{parentId:o.place.parentId,slot:o.place.slot}}:null};return{held:o,remove:n=>l((e,r)=>x(e,r,n,t().afterRemove)),duplicate:n=>l((e,r)=>g(e,r,n,{strip:t().strip})),move:(n,t)=>l((e,r)=>I(e,r,n,t)),step:(n,e)=>l((r,o)=>b(r,o,n,e,t().stepBounds)),canStep:(n,e)=>v(t().data,t().config,n,e,t().stepBounds),setProps:(n,t)=>l((e,r)=>O(e,r,n,t)),copy:(n,e)=>{const o=r(n,e);return o&&(t().clipboard??D).set(o),!!o},cut:(n,e)=>{if(t().readOnly)return!1;const o=r(n,e);return!!o&&((t().clipboard??D).set(o),l((e,r)=>x(e,r,n,t().afterRemove)))},paste:n=>{const e=(t().clipboard??D).get();return!!e&&l((r,o)=>k(r,o,e.node,n,{strip:t().strip}))},restore:(n,t)=>l((e,r)=>y(e,r,n,t)),swap:(n,t)=>l((e,r)=>B(e,r,n,t)),parentOf:n=>z(t().data,t().config,n,t().slotIsLevel)}},[o,l])}export{v as canStep,$ as clickPick,j as clickPickPart,C as fromItemSelector,R as nextInChain,M as nodeChain,z as parentStep,g as planDuplicate,I as planMove,k as planPaste,x as planRemove,y as planRestore,O as planSetProps,b as planStep,B as planSwap,w as toItemSelector,K as useNodeOps};
@@ -1,2 +1,2 @@
1
- import{useEaselHost as e}from"./chunk-U3JP4VGF.js";import{createContext as n,useState as t,useEffect as r,useMemo as l,useContext as o,useSyncExternalStore as s,useRef as u}from"react";import{jsx as c}from"react/jsx-runtime";var i=/* @__PURE__ */new Set,f=()=>{for(const e of[...i])e()};function a(){let e=null,n=!1;const t=/* @__PURE__ */new Set,r=()=>{for(const e of[...t])e();f()},l=(t,l)=>{if(!e||e.request.requestId!==t)return;const{resolve:o}=e;e=null,n=!1,r(),o(l)};return{current:()=>e?.request??null,request:n=>new Promise(t=>{const l=e;e={request:n,resolve:t},r(),l?.resolve(null)}),settle:l,cancel:()=>{e&&l(e.request.requestId,null)},browsing:()=>n,browse:()=>{n||(n=!0,r())},close:()=>{e&&l(e.request.requestId,null),n&&(n=!1,r())},subscribe:e=>(t.add(e),()=>{t.delete(e)})}}var p=[],b=null,d=a(),h=()=>p[p.length-1]??b,w=()=>h()?.store??d,q=n(null);function v({panel:n,place:o=null,children:s}){const u=e(),[i]=t(()=>({panel:n,place:o,host:u,store:a()}));i.panel=n,i.place=o,i.host=u,p.includes(i)||(b=i),r(()=>{const e=p.indexOf(i);return e>=0&&p.splice(e,1),p.push(i),b?.host===i.host&&(b=null),f(),()=>{const e=p.indexOf(i);e>=0&&p.splice(e,1),b===i&&(b=null),i.store.cancel(),f()}},[i]);const d=l(()=>({panel:n,place:o,store:i.store}),[n,o,i]);/* @__PURE__ */
2
- return c(q.Provider,{value:d,children:s})}function m(){return o(q)?.place??null}function g(){return o(q)?.panel??null}function x(e){let n=null;for(let t=p.length-1;t>=0&&!n;t-=1)p[t].host===e&&(n=p[t]);n||b?.host!==e||(n=b);const t=n??h();return t?.panel?t.store:null}function j(){return null!=h()?.panel}function I(e){return w().request(e)}function O(e,n){for(const{store:t}of[...p])t.settle(e,n);b?.store.settle(e,n),d.settle(e,n)}function P(){w().cancel()}var S={current:()=>w().current(),browsing:()=>w().browsing(),browse:()=>w().browse(),close:()=>w().close(),subscribe:e=>(i.add(e),()=>{i.delete(e)}),cancel:()=>w().cancel()};function k(){return o(q)?.store??S}var F=()=>null,G=()=>!1;function J(){const e=k();return s(e.subscribe,e.current,F)}function U(){const e=k();return s(e.subscribe,e.browsing,G)}function V(){return k().browse}function y(){return k().close}function z(e,n){const t=k(),l=u(n);r(()=>{Object.is(l.current,n)||(l.current=n,e&&t.cancel())},[e,n,t])}export{v as MediaPanelProvider,P as cancelPanelPick,a as createMediaPickStore,j as hasMediaPanel,x as mediaPickStoreFor,I as requestPanelPick,O as settlePanelPick,y as useCloseMediaPopup,U as useMediaBrowsing,g as useMediaPanel,m as useMediaPlace,V as useOpenMediaBrowse,J as usePanelPick,z as usePickFollowsSelection};
1
+ import{useEaselHost as e}from"./chunk-MQA7OFRA.js";import{createContext as n,useState as t,useEffect as r,useMemo as l,useContext as o,useSyncExternalStore as s,useRef as u}from"react";import{jsx as c}from"react/jsx-runtime";var i=/* @__PURE__ */new Set,f=()=>{for(const e of[...i])e()};function a(){let e=null,n=!1;const t=/* @__PURE__ */new Set,r=()=>{for(const e of[...t])e();f()},l=(t,l)=>{if(!e||e.request.requestId!==t)return;const{resolve:o}=e;e=null,n=!1,r(),o(l)};return{current:()=>e?.request??null,request:n=>new Promise(t=>{const l=e;e={request:n,resolve:t},r(),l?.resolve(null)}),settle:l,cancel:()=>{e&&l(e.request.requestId,null)},browsing:()=>n,browse:()=>{n||(n=!0,r())},close:()=>{e&&l(e.request.requestId,null),n&&(n=!1,r())},subscribe:e=>(t.add(e),()=>{t.delete(e)})}}var p=[],b=null,d=a(),h=()=>p[p.length-1]??b,w=()=>h()?.store??d,q=n(null);function v({panel:n,place:o=null,children:s}){const u=e(),[i]=t(()=>({panel:n,place:o,host:u,store:a()}));i.panel=n,i.place=o,i.host=u,p.includes(i)||(b=i),r(()=>{const e=p.indexOf(i);return e>=0&&p.splice(e,1),p.push(i),b?.host===i.host&&(b=null),f(),()=>{const e=p.indexOf(i);e>=0&&p.splice(e,1),b===i&&(b=null),i.store.cancel(),f()}},[i]);const d=l(()=>({panel:n,place:o,store:i.store}),[n,o,i]);/* @__PURE__ */
2
+ return c(q.Provider,{value:d,children:s})}function m(){return o(q)?.place??null}function g(){return o(q)?.panel??null}function x(e){let n=null;for(let t=p.length-1;t>=0&&!n;t-=1)p[t].host===e&&(n=p[t]);n||b?.host!==e||(n=b);const t=n??h();return t?.panel?t.store:null}function O(){return null!=h()?.panel}function j(e){return w().request(e)}function I(e,n){for(const{store:t}of[...p])t.settle(e,n);b?.store.settle(e,n),d.settle(e,n)}function A(){w().cancel()}var P={current:()=>w().current(),browsing:()=>w().browsing(),browse:()=>w().browse(),close:()=>w().close(),subscribe:e=>(i.add(e),()=>{i.delete(e)}),cancel:()=>w().cancel()};function S(){return o(q)?.store??P}var k=()=>null,F=()=>!1;function M(){const e=S();return s(e.subscribe,e.current,k)}function Q(){const e=S();return s(e.subscribe,e.browsing,F)}function R(){return S().browse}function y(){return S().close}function z(e,n){const t=S(),l=u(n);r(()=>{Object.is(l.current,n)||(l.current=n,e&&t.cancel())},[e,n,t])}export{v as MediaPanelProvider,A as cancelPanelPick,a as createMediaPickStore,O as hasMediaPanel,x as mediaPickStoreFor,j as requestPanelPick,I as settlePanelPick,y as useCloseMediaPopup,Q as useMediaBrowsing,g as useMediaPanel,m as useMediaPlace,R as useOpenMediaBrowse,M as usePanelPick,z as usePickFollowsSelection};
@@ -1,2 +1,2 @@
1
- import{ScreenPartsProvider as t}from"./chunk-OGBYHQE6.js";import{useEaselHost as e}from"./chunk-U3JP4VGF.js";import{createEasel as r,EaselProvider as o}from"./chunk-KOVJODTY.js";import{useState as n,useEffect as s}from"react";import{jsx as a}from"react/jsx-runtime";function i({config:i,data:c,onChange:m,permissions:p,parts:f,children:u}){const[d]=n(()=>r({config:i,data:c,permissions:p}));s(()=>{d.setConfig(i)},[d,i]),s(()=>{if(!m)return;let t=d.getState().appState.data,e=!1;return d.subscribe(()=>{const r=d.getState().appState.data;r!==t&&(t=r,(e||r!==d.loaded)&&(e=!0,m(r)))})},[d,m]),s(()=>{p&&d.setPermissions(p)},[d,p]);const h=e();/* @__PURE__ */
1
+ import{ScreenPartsProvider as t}from"./chunk-LEZFSSQN.js";import{useEaselHost as e}from"./chunk-MQA7OFRA.js";import{createEasel as r,EaselProvider as o}from"./chunk-ROPYFLNZ.js";import{useState as n,useEffect as s}from"react";import{jsx as a}from"react/jsx-runtime";function i({config:i,data:c,onChange:m,permissions:p,parts:f,children:u}){const[d]=n(()=>r({config:i,data:c,permissions:p}));s(()=>{d.setConfig(i)},[d,i]),s(()=>{if(!m)return;let t=d.getState().appState.data,e=!1;return d.subscribe(()=>{const r=d.getState().appState.data;r!==t&&(t=r,(e||r!==d.loaded)&&(e=!0,m(r)))})},[d,m]),s(()=>{p&&d.setPermissions(p)},[d,p]);const h=e();/* @__PURE__ */
2
2
  return a(o,{easel:d,hotkeys:h.ownsDocument,children:/* @__PURE__ */a(t,{parts:f,children:u})})}export{i as ScreenStoreProvider};
@@ -1 +1 @@
1
- import{useEaselHost as n}from"./chunk-U3JP4VGF.js";import{useEaselApi as e,bindUndoKeys as t}from"./chunk-KOVJODTY.js";import{useState as r,useEffect as o,useRef as u}from"react";function c(e){const t=n(),[u,c]=r(null);return o(()=>c(e.current),[e]),t.ownsDocument?"undefined"==typeof document?null:document:u}function i(r,u){const i=n(),s=e(),f=c(r);o(()=>{if(!i.ownsDocument&&f)return t(f,s,{leaveTyping:!0})},[i,s,f]);const m=u?.document??null;o(()=>{if(!i.ownsDocument&&m)return t(m,s,{leaveTyping:!0})},[i,s,m])}function s(n){return n.ownsDocument?{}:{tabIndex:-1}}function f(n){return!n.altKey&&!n.shiftKey&&(!(!n.metaKey&&!n.ctrlKey)&&("s"===n.key||"S"===n.key||"KeyS"===n.code))}function m(n,e,t){const r=c(n),i=u(t);o(()=>{i.current=t}),o(()=>{if(!r)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return r.addEventListener("keydown",n),()=>r.removeEventListener("keydown",n)},[r]);const s=e?.document??null;o(()=>{if(!s)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return s.addEventListener("keydown",n),()=>s.removeEventListener("keydown",n)},[s])}export{s as editorRootFocus,f as isSaveShortcut,c as useEaselKeyTarget,m as useEaselSaveKey,i as useEaselUndoKeys};
1
+ import{useEaselHost as n}from"./chunk-MQA7OFRA.js";import{useEaselApi as e,bindUndoKeys as t}from"./chunk-ROPYFLNZ.js";import{useState as r,useEffect as o,useRef as u}from"react";function c(e){const t=n(),[u,c]=r(null);return o(()=>c(e.current),[e]),t.ownsDocument?"undefined"==typeof document?null:document:u}function i(r,u){const i=n(),s=e(),f=c(r);o(()=>{if(!i.ownsDocument&&f)return t(f,s,{leaveTyping:!0})},[i,s,f]);const m=u?.document??null;o(()=>{if(!i.ownsDocument&&m)return t(m,s,{leaveTyping:!0})},[i,s,m])}function s(n){return n.ownsDocument?{}:{tabIndex:-1}}function f(n){return!n.altKey&&!n.shiftKey&&(!(!n.metaKey&&!n.ctrlKey)&&("s"===n.key||"S"===n.key||"KeyS"===n.code))}function m(n,e,t){const r=c(n),i=u(t);o(()=>{i.current=t}),o(()=>{if(!r)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return r.addEventListener("keydown",n),()=>r.removeEventListener("keydown",n)},[r]);const s=e?.document??null;o(()=>{if(!s)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return s.addEventListener("keydown",n),()=>s.removeEventListener("keydown",n)},[s])}export{s as editorRootFocus,f as isSaveShortcut,c as useEaselKeyTarget,m as useEaselSaveKey,i as useEaselUndoKeys};
@@ -0,0 +1 @@
1
+ var t=["desktop","tablet","mobile"],e={desktop:"Desktop",tablet:"Tablet",mobile:"Mobile"},n=720,o=1100;function a(t){return t>=1100?"desktop":t>=720?"tablet":"mobile"}function r(t){return`${t}Tablet`}function u(t){return`${t}Phone`}function b(t){return null==t}var l=t=>e=>"number"==typeof e?e*t:e,p=t=>t;var h={spacing:{tablet:l(.75),phone:l(2/3),round:function(t){const e=Math.ceil(Math.abs(t)/4-.5);return 4*(t<0?-e:e)+0}},columns:{tablet:t=>"number"==typeof t?Math.min(t,2):t,phone:t=>"number"==typeof t?1:t},stack:{tablet:p,phone:t=>void 0===t?t:"stacked"},textSize:{tablet:l(.85),phone:l(.7/.85),round:Math.round},heightMode:{tablet:p,phone:t=>"px"===t?"fit":t},heightPx:{tablet:l(.75),phone:p,round:Math.round},same:{tablet:p,phone:p}};function i(t,e,n,o){const a=h[t],r=t=>a.round&&"number"==typeof t?a.round(t):t,u=b(n)?a.tablet(e):n,l=b(o)?a.phone(u):o;return{desktop:e,tablet:b(n)?r(u):n,phone:b(o)?r(l):o}}export{h as AUTO_RULES,o as VIEW_DESKTOP_MIN,n as VIEW_TABLET_MIN,t as VIEW_TIERS,e as VIEW_TIER_LABEL,b as isAuto,u as phoneKey,i as resolveViewValue,r as tabletKey,a as viewTierForWidth};
@@ -1 +1 @@
1
- import{changedProps as e}from"./chunk-KRXQM65X.js";import{useState as t,useRef as r,useEffect as n}from"react";function i({id:i,node:l,block:d,parent:o=null,appState:a=null}){const u=d?.fields??{},[s,c]=t(()=>({id:i,fields:u,loading:!1})),p=r(null),f=r(null),g=r({parent:o,appState:a,id:i});return g.current={parent:o,appState:a,id:i},n(()=>{if(!l||!d)return;const t=f.current!==i;f.current=i;let r=s.fields;t&&(r=u,p.current=null,c({id:i,fields:u,loading:!1}));const n=d.resolveFields;if(!n)return void(t||c(e=>({...e,fields:u})));let o=!1;const a=p.current&&(p.current.props?.id??"root")===(l.props?.id??"root")?p.current:null,m=setTimeout(()=>{o||c(e=>e.id===i?{...e,loading:!0}:e)},50);return Promise.resolve(n(l,{changed:e(l,a),fields:u,lastFields:r,lastData:a,appState:g.current.appState,parent:g.current.parent})).then(e=>{clearTimeout(m),o||g.current.id!==i||(p.current=l,c({id:i,fields:e,loading:!1}))}),()=>{o=!0,clearTimeout(m)}},[i,l,d]),s.id===i?{fields:s.fields,loading:s.loading}:{fields:u,loading:!1}}export{i as useResolvedFields};
1
+ import{changedProps as e}from"./chunk-K7BTCBWD.js";import{useState as t,useRef as r,useEffect as n}from"react";function i({id:i,node:l,block:d,parent:o=null,appState:a=null}){const u=d?.fields??{},[s,c]=t(()=>({id:i,fields:u,loading:!1})),p=r(null),f=r(null),g=r({parent:o,appState:a,id:i});return g.current={parent:o,appState:a,id:i},n(()=>{if(!l||!d)return;const t=f.current!==i;f.current=i;let r=s.fields;t&&(r=u,p.current=null,c({id:i,fields:u,loading:!1}));const n=d.resolveFields;if(!n)return void(t||c(e=>({...e,fields:u})));let o=!1;const a=p.current&&(p.current.props?.id??"root")===(l.props?.id??"root")?p.current:null,m=setTimeout(()=>{o||c(e=>e.id===i?{...e,loading:!0}:e)},50);return Promise.resolve(n(l,{changed:e(l,a),fields:u,lastFields:r,lastData:a,appState:g.current.appState,parent:g.current.parent})).then(e=>{clearTimeout(m),o||g.current.id!==i||(p.current=l,c({id:i,fields:e,loading:!1}))}),()=>{o=!0,clearTimeout(m)}},[i,l,d]),s.id===i?{fields:s.fields,loading:s.loading}:{fields:u,loading:!1}}export{i as useResolvedFields};