@burger-editor/client 4.0.0-alpha.8 → 4.0.0-alpha.80

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 (137) hide show
  1. package/README.md +169 -2
  2. package/dist/__tests__/setup.d.ts +2 -0
  3. package/dist/__tests__/setup.d.ts.map +1 -0
  4. package/dist/animate-insertion.d.ts +17 -0
  5. package/dist/animate-insertion.d.ts.map +1 -0
  6. package/dist/block-swap-view-transition-css.d.ts +7 -0
  7. package/dist/block-swap-view-transition-css.d.ts.map +1 -0
  8. package/dist/burger-editor-root.d.ts +7 -0
  9. package/dist/burger-editor-root.d.ts.map +1 -0
  10. package/dist/client.css +981 -573
  11. package/dist/client.js +28193 -14074
  12. package/dist/client.js.map +1 -1
  13. package/dist/commands/register-engine-commands.d.ts +18 -0
  14. package/dist/commands/register-engine-commands.d.ts.map +1 -0
  15. package/dist/components/block-catalog.d.ts +18 -0
  16. package/dist/components/block-catalog.d.ts.map +1 -0
  17. package/dist/components/block-menu-anchors.d.ts +25 -0
  18. package/dist/components/block-menu-anchors.d.ts.map +1 -0
  19. package/dist/components/block-menu-button.d.ts +33 -0
  20. package/dist/components/block-menu-button.d.ts.map +1 -0
  21. package/dist/components/block-menu-view.d.ts +88 -0
  22. package/dist/components/block-menu-view.d.ts.map +1 -0
  23. package/dist/components/block-menu.d.ts +25 -0
  24. package/dist/components/block-menu.d.ts.map +1 -0
  25. package/dist/components/block-options.d.ts +23 -0
  26. package/dist/components/block-options.d.ts.map +1 -0
  27. package/dist/components/draft-switcher.d.ts +24 -0
  28. package/dist/components/draft-switcher.d.ts.map +1 -0
  29. package/dist/components/editable-area-view.d.ts +41 -0
  30. package/dist/components/editable-area-view.d.ts.map +1 -0
  31. package/dist/components/file-list.d.ts +19 -0
  32. package/dist/components/file-list.d.ts.map +1 -0
  33. package/dist/components/file-uploader.d.ts +18 -0
  34. package/dist/components/file-uploader.d.ts.map +1 -0
  35. package/dist/components/front-matter-editor.d.ts +115 -0
  36. package/dist/components/front-matter-editor.d.ts.map +1 -0
  37. package/dist/components/index.d.ts +23 -0
  38. package/dist/components/index.d.ts.map +1 -0
  39. package/dist/components/initial-insertion-button.d.ts +15 -0
  40. package/dist/components/initial-insertion-button.d.ts.map +1 -0
  41. package/dist/components/item-editor-host.d.ts +24 -0
  42. package/dist/components/item-editor-host.d.ts.map +1 -0
  43. package/dist/components/preview.d.ts +15 -0
  44. package/dist/components/preview.d.ts.map +1 -0
  45. package/dist/components/table-editor.d.ts +28 -0
  46. package/dist/components/table-editor.d.ts.map +1 -0
  47. package/dist/components/tabs.d.ts +27 -0
  48. package/dist/components/tabs.d.ts.map +1 -0
  49. package/dist/components/thumbnail-button.d.ts +39 -0
  50. package/dist/components/thumbnail-button.d.ts.map +1 -0
  51. package/dist/components/thumbnail.d.ts +17 -0
  52. package/dist/components/thumbnail.d.ts.map +1 -0
  53. package/dist/components/wysiwyg-field.d.ts +50 -0
  54. package/dist/components/wysiwyg-field.d.ts.map +1 -0
  55. package/dist/create-mock-engine-BloCpuEu.js +87 -0
  56. package/dist/create-mock-engine-BloCpuEu.js.map +1 -0
  57. package/dist/dist-DYydjVsL.js +16188 -0
  58. package/dist/dist-DYydjVsL.js.map +1 -0
  59. package/dist/editable-area-view-DhEipEQV.js +2962 -0
  60. package/dist/editable-area-view-DhEipEQV.js.map +1 -0
  61. package/dist/editor-dialog.d.ts +50 -0
  62. package/dist/editor-dialog.d.ts.map +1 -0
  63. package/dist/engine-context-oEEsvNSx.js +49 -0
  64. package/dist/engine-context-oEEsvNSx.js.map +1 -0
  65. package/dist/engine-context.d.ts +43 -0
  66. package/dist/engine-context.d.ts.map +1 -0
  67. package/dist/file-browser/store.d.ts +132 -0
  68. package/dist/file-browser/store.d.ts.map +1 -0
  69. package/dist/file-browser/use-external-file-selection.d.ts +39 -0
  70. package/dist/file-browser/use-external-file-selection.d.ts.map +1 -0
  71. package/dist/file-browser/use-file-browser.d.ts +17 -0
  72. package/dist/file-browser/use-file-browser.d.ts.map +1 -0
  73. package/dist/form/checkbox.d.ts +34 -0
  74. package/dist/form/checkbox.d.ts.map +1 -0
  75. package/dist/form/fieldset.d.ts +31 -0
  76. package/dist/form/fieldset.d.ts.map +1 -0
  77. package/dist/form/index.d.ts +8 -0
  78. package/dist/form/index.d.ts.map +1 -0
  79. package/dist/form/number-field.d.ts +37 -0
  80. package/dist/form/number-field.d.ts.map +1 -0
  81. package/dist/form/radio-group.d.ts +38 -0
  82. package/dist/form/radio-group.d.ts.map +1 -0
  83. package/dist/form/select-field.d.ts +41 -0
  84. package/dist/form/select-field.d.ts.map +1 -0
  85. package/dist/form/text-area.d.ts +33 -0
  86. package/dist/form/text-area.d.ts.map +1 -0
  87. package/dist/form/text-field.d.ts +47 -0
  88. package/dist/form/text-field.d.ts.map +1 -0
  89. package/dist/index.d.ts +42 -6
  90. package/dist/index.d.ts.map +1 -1
  91. package/dist/interest-hints.d.ts +21 -0
  92. package/dist/interest-hints.d.ts.map +1 -0
  93. package/dist/invoker-commands.d.ts +24 -0
  94. package/dist/invoker-commands.d.ts.map +1 -0
  95. package/dist/mount.d.ts +24 -0
  96. package/dist/mount.d.ts.map +1 -0
  97. package/dist/replace-element.d.ts +12 -4
  98. package/dist/replace-element.d.ts.map +1 -1
  99. package/dist/root-error-boundary.d.ts +34 -0
  100. package/dist/root-error-boundary.d.ts.map +1 -0
  101. package/dist/testing/create-mock-engine.d.ts +33 -0
  102. package/dist/testing/create-mock-engine.d.ts.map +1 -0
  103. package/dist/testing/index.d.ts +4 -0
  104. package/dist/testing/index.d.ts.map +1 -0
  105. package/dist/testing/render-with-engine.d.ts +20 -0
  106. package/dist/testing/render-with-engine.d.ts.map +1 -0
  107. package/dist/testing/suppress-console-error.d.ts +24 -0
  108. package/dist/testing/suppress-console-error.d.ts.map +1 -0
  109. package/dist/testing-mock-engine.js +1 -0
  110. package/dist/testing.js +68 -0
  111. package/dist/testing.js.map +1 -0
  112. package/dist/ui.d.ts +17 -0
  113. package/dist/ui.d.ts.map +1 -0
  114. package/dist/ui.js +2830 -0
  115. package/dist/ui.js.map +1 -0
  116. package/dist/use-command.d.ts +38 -0
  117. package/dist/use-command.d.ts.map +1 -0
  118. package/dist/use-engine.d.ts +37 -0
  119. package/dist/use-engine.d.ts.map +1 -0
  120. package/dist/use-mount-effect.d.ts +20 -0
  121. package/dist/use-mount-effect.d.ts.map +1 -0
  122. package/dist/view/create-react-view.d.ts +41 -0
  123. package/dist/view/create-react-view.d.ts.map +1 -0
  124. package/package.json +61 -16
  125. package/dist/block-catalog.svelte.d.ts +0 -1
  126. package/dist/block-menu-button.svelte.d.ts +0 -1
  127. package/dist/block-menu.svelte.d.ts +0 -1
  128. package/dist/block-options.svelte.d.ts +0 -1
  129. package/dist/draft-switcher.svelte.d.ts +0 -1
  130. package/dist/file-list.svelte.d.ts +0 -1
  131. package/dist/file-uploader.svelte.d.ts +0 -1
  132. package/dist/preview.svelte.d.ts +0 -1
  133. package/dist/svelte-mount.d.ts +0 -10
  134. package/dist/svelte-mount.d.ts.map +0 -1
  135. package/dist/table-editor.svelte.d.ts +0 -1
  136. package/dist/tabs.svelte.d.ts +0 -1
  137. package/dist/thumbnail.svelte.d.ts +0 -1
@@ -0,0 +1,2962 @@
1
+ import { a as beginProcessing, i as createBgeEvent, s as Item, t as getBlockAtPosition, u as CSS_LAYER } from "./dist-DYydjVsL.js";
2
+ import { n as useEngine } from "./engine-context-oEEsvNSx.js";
3
+ import { c } from "react/compiler-runtime";
4
+ import { Component, Fragment, Suspense, createContext, createElement, forwardRef, useActionState, useEffect, useEffectEvent, useId, useMemo, useRef, useState } from "react";
5
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
6
+ import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector";
7
+ import { createRoot } from "react-dom/client";
8
+ import { createPortal } from "react-dom";
9
+ // ../utils/dist/append-stylesheet-to.js
10
+ /**
11
+ * Append a `<link rel="stylesheet">` to a document's `<head>`.
12
+ * @param doc - The target document
13
+ * @param url - The stylesheet URL (often a blob URL)
14
+ * @param id - A cache-busting fragment identifier appended to `url`
15
+ * @example
16
+ * ```ts
17
+ * appendStylesheetTo(iframeDoc, blobUrl, 'block-menu-ui');
18
+ * ```
19
+ */
20
+ function appendStylesheetTo(doc, url, id) {
21
+ const link = doc.createElement("link");
22
+ link.rel = "stylesheet";
23
+ link.crossOrigin = "anonymous";
24
+ link.href = `${url}#${id}`;
25
+ doc.head.append(link);
26
+ }
27
+ // ../core/dist/command/commands.js
28
+ /**
29
+ * The engine's command vocabulary — every custom command accepted by the
30
+ * central command bus. Buttons declare these with
31
+ * `commandfor={engine.commandBus.receiverId}`; the dispatch table is
32
+ * registered by the UI layer at engine setup.
33
+ *
34
+ * Parameters travel on the invoker button (`value` / `data-*` attributes)
35
+ * and are read from `CommandEvent.source`.
36
+ * @example
37
+ * ```tsx
38
+ * <button command={BGE_COMMAND.moveBlock} commandfor={engine.commandBus.receiverId} value="up">
39
+ * 上に移動
40
+ * </button>
41
+ * ```
42
+ */
43
+ var BGE_COMMAND = {
44
+ /** Append a new block from the catalog. `value`: catalog index. */
45
+ addBlock: "--add-block",
46
+ /** Paste the block currently held in the clipboard. */
47
+ pasteBlock: "--paste-block",
48
+ /** Move the current block. `value`: `up` | `down`. */
49
+ moveBlock: "--move-block",
50
+ /** Open the catalog to insert a block. `value`: `before` | `after`. */
51
+ insertBlock: "--insert-block",
52
+ /** Add or remove a grid item in the current block. `value`: `+1` | `-1`. */
53
+ updateGridItems: "--update-grid-items",
54
+ /** Open the options dialog for the current block. */
55
+ openBlockOptions: "--open-block-options",
56
+ /** Copy the current block to the clipboard. */
57
+ copyBlock: "--copy-block",
58
+ /** Remove the current block. */
59
+ removeBlock: "--remove-block",
60
+ /** Insert the first block into an empty editable area. */
61
+ insertInitialBlock: "--insert-initial-block",
62
+ /** Switch the visible content. `value`: `main` | `draft`. */
63
+ switchContent: "--switch-content",
64
+ /** Copy the main content over the draft. */
65
+ copyMainToDraft: "--copy-main-to-draft",
66
+ /** Copy the draft content over the main. */
67
+ copyDraftToMain: "--copy-draft-to-main",
68
+ /** Open the item editor for the item hosting the invoker button. */
69
+ openItemEditor: "--open-item-editor"
70
+ };
71
+ // ../../../node_modules/@tabler/icons-react/dist/esm/defaultAttributes.mjs
72
+ /**
73
+ * @license @tabler/icons-react v3.52.0 - MIT
74
+ *
75
+ * This source code is licensed under the MIT license.
76
+ * See the LICENSE file in the root directory of this source tree.
77
+ */
78
+ var defaultAttributes = {
79
+ outline: {
80
+ xmlns: "http://www.w3.org/2000/svg",
81
+ width: 24,
82
+ height: 24,
83
+ viewBox: "0 0 24 24",
84
+ fill: "none",
85
+ stroke: "currentColor",
86
+ strokeWidth: 2,
87
+ strokeLinecap: "round",
88
+ strokeLinejoin: "round"
89
+ },
90
+ filled: {
91
+ xmlns: "http://www.w3.org/2000/svg",
92
+ width: 24,
93
+ height: 24,
94
+ viewBox: "0 0 24 24",
95
+ fill: "currentColor",
96
+ stroke: "none"
97
+ }
98
+ };
99
+ // ../../../node_modules/@tabler/icons-react/dist/esm/createReactComponent.mjs
100
+ /**
101
+ * @license @tabler/icons-react v3.52.0 - MIT
102
+ *
103
+ * This source code is licensed under the MIT license.
104
+ * See the LICENSE file in the root directory of this source tree.
105
+ */
106
+ var createReactComponent = (type, iconName, iconNamePascal, iconNode) => {
107
+ const Component = forwardRef(({ color = "currentColor", size = 24, stroke = 2, title, className, children, ...rest }, ref) => createElement("svg", {
108
+ ref,
109
+ ...defaultAttributes[type],
110
+ width: size,
111
+ height: size,
112
+ className: [
113
+ `tabler-icon`,
114
+ `tabler-icon-${iconName}`,
115
+ className
116
+ ].filter(Boolean).join(" "),
117
+ ...type === "filled" ? { fill: color } : {
118
+ strokeWidth: stroke,
119
+ stroke: color
120
+ },
121
+ ...rest
122
+ }, [
123
+ title && createElement("title", { key: "svg-title" }, title),
124
+ ...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),
125
+ ...Array.isArray(children) ? children : [children]
126
+ ]));
127
+ Component.displayName = `${iconNamePascal}`;
128
+ return Component;
129
+ };
130
+ /**
131
+ * @license @tabler/icons-react v3.52.0 - MIT
132
+ *
133
+ * This source code is licensed under the MIT license.
134
+ * See the LICENSE file in the root directory of this source tree.
135
+ */
136
+ var IconArrowBigDownLine = /* @__PURE__ */ createReactComponent("outline", "arrow-big-down-line", "ArrowBigDownLine", [["path", {
137
+ "d": "M15 12h3.586a1 1 0 0 1 .707 1.707l-6.586 6.586a1 1 0 0 1 -1.414 0l-6.586 -6.586a1 1 0 0 1 .707 -1.707h3.586v-6h6v6",
138
+ "key": "svg-0"
139
+ }], ["path", {
140
+ "d": "M15 3h-6",
141
+ "key": "svg-1"
142
+ }]]);
143
+ /**
144
+ * @license @tabler/icons-react v3.52.0 - MIT
145
+ *
146
+ * This source code is licensed under the MIT license.
147
+ * See the LICENSE file in the root directory of this source tree.
148
+ */
149
+ var IconArrowBigUpLine = /* @__PURE__ */ createReactComponent("outline", "arrow-big-up-line", "ArrowBigUpLine", [["path", {
150
+ "d": "M9 12h-3.586a1 1 0 0 1 -.707 -1.707l6.586 -6.586a1 1 0 0 1 1.414 0l6.586 6.586a1 1 0 0 1 -.707 1.707h-3.586v6h-6v-6",
151
+ "key": "svg-0"
152
+ }], ["path", {
153
+ "d": "M9 21h6",
154
+ "key": "svg-1"
155
+ }]]);
156
+ /**
157
+ * @license @tabler/icons-react v3.52.0 - MIT
158
+ *
159
+ * This source code is licensed under the MIT license.
160
+ * See the LICENSE file in the root directory of this source tree.
161
+ */
162
+ var IconClipboardPlus = /* @__PURE__ */ createReactComponent("outline", "clipboard-plus", "ClipboardPlus", [
163
+ ["path", {
164
+ "d": "M9 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2h-2",
165
+ "key": "svg-0"
166
+ }],
167
+ ["path", {
168
+ "d": "M9 5a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2",
169
+ "key": "svg-1"
170
+ }],
171
+ ["path", {
172
+ "d": "M10 14h4",
173
+ "key": "svg-2"
174
+ }],
175
+ ["path", {
176
+ "d": "M12 12v4",
177
+ "key": "svg-3"
178
+ }]
179
+ ]);
180
+ /**
181
+ * @license @tabler/icons-react v3.52.0 - MIT
182
+ *
183
+ * This source code is licensed under the MIT license.
184
+ * See the LICENSE file in the root directory of this source tree.
185
+ */
186
+ var IconClipboard = /* @__PURE__ */ createReactComponent("outline", "clipboard", "Clipboard", [["path", {
187
+ "d": "M9 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2h-2",
188
+ "key": "svg-0"
189
+ }], ["path", {
190
+ "d": "M9 5a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2",
191
+ "key": "svg-1"
192
+ }]]);
193
+ /**
194
+ * @license @tabler/icons-react v3.52.0 - MIT
195
+ *
196
+ * This source code is licensed under the MIT license.
197
+ * See the LICENSE file in the root directory of this source tree.
198
+ */
199
+ var IconLayoutGridAdd = /* @__PURE__ */ createReactComponent("outline", "layout-grid-add", "LayoutGridAdd", [
200
+ ["path", {
201
+ "d": "M4 5a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4",
202
+ "key": "svg-0"
203
+ }],
204
+ ["path", {
205
+ "d": "M14 5a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4",
206
+ "key": "svg-1"
207
+ }],
208
+ ["path", {
209
+ "d": "M4 15a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4",
210
+ "key": "svg-2"
211
+ }],
212
+ ["path", {
213
+ "d": "M14 17h6m-3 -3v6",
214
+ "key": "svg-3"
215
+ }]
216
+ ]);
217
+ /**
218
+ * @license @tabler/icons-react v3.52.0 - MIT
219
+ *
220
+ * This source code is licensed under the MIT license.
221
+ * See the LICENSE file in the root directory of this source tree.
222
+ */
223
+ var IconLayoutGridRemove = /* @__PURE__ */ createReactComponent("outline", "layout-grid-remove", "LayoutGridRemove", [
224
+ ["path", {
225
+ "d": "M4 5a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1v-4",
226
+ "key": "svg-0"
227
+ }],
228
+ ["path", {
229
+ "d": "M14 5a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1v-4",
230
+ "key": "svg-1"
231
+ }],
232
+ ["path", {
233
+ "d": "M4 15a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1v-4",
234
+ "key": "svg-2"
235
+ }],
236
+ ["path", {
237
+ "d": "M14 17h6",
238
+ "key": "svg-3"
239
+ }]
240
+ ]);
241
+ /**
242
+ * @license @tabler/icons-react v3.52.0 - MIT
243
+ *
244
+ * This source code is licensed under the MIT license.
245
+ * See the LICENSE file in the root directory of this source tree.
246
+ */
247
+ var IconRowInsertBottom = /* @__PURE__ */ createReactComponent("outline", "row-insert-bottom", "RowInsertBottom", [
248
+ ["path", {
249
+ "d": "M20 6v4a1 1 0 0 1 -1 1h-14a1 1 0 0 1 -1 -1v-4a1 1 0 0 1 1 -1h14a1 1 0 0 1 1 1",
250
+ "key": "svg-0"
251
+ }],
252
+ ["path", {
253
+ "d": "M12 15l0 4",
254
+ "key": "svg-1"
255
+ }],
256
+ ["path", {
257
+ "d": "M14 17l-4 0",
258
+ "key": "svg-2"
259
+ }]
260
+ ]);
261
+ /**
262
+ * @license @tabler/icons-react v3.52.0 - MIT
263
+ *
264
+ * This source code is licensed under the MIT license.
265
+ * See the LICENSE file in the root directory of this source tree.
266
+ */
267
+ var IconRowInsertTop = /* @__PURE__ */ createReactComponent("outline", "row-insert-top", "RowInsertTop", [
268
+ ["path", {
269
+ "d": "M4 18v-4a1 1 0 0 1 1 -1h14a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-14a1 1 0 0 1 -1 -1",
270
+ "key": "svg-0"
271
+ }],
272
+ ["path", {
273
+ "d": "M12 9v-4",
274
+ "key": "svg-1"
275
+ }],
276
+ ["path", {
277
+ "d": "M10 7l4 0",
278
+ "key": "svg-2"
279
+ }]
280
+ ]);
281
+ /**
282
+ * @license @tabler/icons-react v3.52.0 - MIT
283
+ *
284
+ * This source code is licensed under the MIT license.
285
+ * See the LICENSE file in the root directory of this source tree.
286
+ */
287
+ var IconSettings = /* @__PURE__ */ createReactComponent("outline", "settings", "Settings", [["path", {
288
+ "d": "M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065",
289
+ "key": "svg-0"
290
+ }], ["path", {
291
+ "d": "M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0",
292
+ "key": "svg-1"
293
+ }]]);
294
+ /**
295
+ * @license @tabler/icons-react v3.52.0 - MIT
296
+ *
297
+ * This source code is licensed under the MIT license.
298
+ * See the LICENSE file in the root directory of this source tree.
299
+ */
300
+ var IconTrash = /* @__PURE__ */ createReactComponent("outline", "trash", "Trash", [
301
+ ["path", {
302
+ "d": "M4 7l16 0",
303
+ "key": "svg-0"
304
+ }],
305
+ ["path", {
306
+ "d": "M10 11l0 6",
307
+ "key": "svg-1"
308
+ }],
309
+ ["path", {
310
+ "d": "M14 11l0 6",
311
+ "key": "svg-2"
312
+ }],
313
+ ["path", {
314
+ "d": "M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12",
315
+ "key": "svg-3"
316
+ }],
317
+ ["path", {
318
+ "d": "M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3",
319
+ "key": "svg-4"
320
+ }]
321
+ ]);
322
+ var block_catalog_module_default = {
323
+ blockCatalog: "_blockCatalog_96ih6_1",
324
+ figure: "_figure_96ih6_36",
325
+ img: "_img_96ih6_42",
326
+ figcaption: "_figcaption_96ih6_56",
327
+ pasteSection: "_pasteSection_96ih6_66",
328
+ pasteButton: "_pasteButton_96ih6_72"
329
+ };
330
+ // src/components/block-catalog.tsx
331
+ /**
332
+ * Block catalog dialog content. Adding and pasting blocks are declared
333
+ * as engine commands; the catalog entry is identified by
334
+ * `data-category` / `data-index` on the invoker button.
335
+ * @param root0
336
+ * @param root0.catalog
337
+ * @example
338
+ * ```tsx
339
+ * <EditorDialog name="catalog" open={open} onClose={close} buttons={{ close: 'キャンセル' }}>
340
+ * <BlockCatalog catalog={engine.catalog} />
341
+ * </EditorDialog>
342
+ * ```
343
+ */
344
+ function BlockCatalog(t0) {
345
+ const $ = c(11);
346
+ const { catalog } = t0;
347
+ const engine = useEngine();
348
+ let t1;
349
+ if ($[0] !== engine.storageKey.blockClipboard) {
350
+ t1 = sessionStorage.getItem(engine.storageKey.blockClipboard);
351
+ $[0] = engine.storageKey.blockClipboard;
352
+ $[1] = t1;
353
+ } else t1 = $[1];
354
+ const hasCopiedBlock = !!t1;
355
+ let t2;
356
+ if ($[2] !== engine.commandBus || $[3] !== hasCopiedBlock) {
357
+ t2 = hasCopiedBlock ? /* @__PURE__ */ jsx("div", {
358
+ className: block_catalog_module_default.pasteSection,
359
+ children: /* @__PURE__ */ jsxs("button", {
360
+ type: "button",
361
+ className: block_catalog_module_default.pasteButton,
362
+ command: BGE_COMMAND.pasteBlock,
363
+ commandfor: engine.commandBus.receiverId,
364
+ children: [/* @__PURE__ */ jsx(IconClipboard, {}), /* @__PURE__ */ jsx("span", { children: "クリップボードから貼り付け" })]
365
+ })
366
+ }) : null;
367
+ $[2] = engine.commandBus;
368
+ $[3] = hasCopiedBlock;
369
+ $[4] = t2;
370
+ } else t2 = $[4];
371
+ let t3;
372
+ if ($[5] !== catalog || $[6] !== engine.commandBus) {
373
+ t3 = /* @__PURE__ */ jsx("dl", { children: Object.entries(catalog).map((t4) => {
374
+ const [category, blocks] = t4;
375
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("dt", { children: category }), /* @__PURE__ */ jsx("div", { children: blocks.map((blockInfo, index) => /* @__PURE__ */ jsx("dd", { children: /* @__PURE__ */ jsx("button", {
376
+ type: "button",
377
+ command: BGE_COMMAND.addBlock,
378
+ commandfor: engine.commandBus.receiverId,
379
+ "data-category": category,
380
+ "data-index": index,
381
+ children: blockInfo.definition.img || blockInfo.definition.svg ? /* @__PURE__ */ jsxs("span", {
382
+ className: block_catalog_module_default.figure,
383
+ children: [blockInfo.definition.img ? /* @__PURE__ */ jsx("span", {
384
+ className: block_catalog_module_default.img,
385
+ children: /* @__PURE__ */ jsx("img", {
386
+ src: blockInfo.definition.img,
387
+ alt: "",
388
+ loading: "lazy"
389
+ })
390
+ }) : /* @__PURE__ */ jsx("span", {
391
+ className: block_catalog_module_default.img,
392
+ "aria-hidden": "true",
393
+ dangerouslySetInnerHTML: { __html: blockInfo.definition.svg ?? "" }
394
+ }), /* @__PURE__ */ jsx("span", {
395
+ className: block_catalog_module_default.figcaption,
396
+ children: blockInfo.label
397
+ })]
398
+ }) : blockInfo.label
399
+ }) }, category + blockInfo.label + blockInfo.definition.name)) })] }, category);
400
+ }) });
401
+ $[5] = catalog;
402
+ $[6] = engine.commandBus;
403
+ $[7] = t3;
404
+ } else t3 = $[7];
405
+ let t4;
406
+ if ($[8] !== t2 || $[9] !== t3) {
407
+ t4 = /* @__PURE__ */ jsxs("div", {
408
+ className: block_catalog_module_default.blockCatalog,
409
+ children: [t2, t3]
410
+ });
411
+ $[8] = t2;
412
+ $[9] = t3;
413
+ $[10] = t4;
414
+ } else t4 = $[10];
415
+ return t4;
416
+ }
417
+ // src/components/block-options.tsx
418
+ var containerTypeLabel = {
419
+ grid: "グリッド",
420
+ inline: "横並び",
421
+ float: "左右折り返し"
422
+ };
423
+ /**
424
+ * Block options dialog content. Values are read out of the dialog form
425
+ * on submit (uncontrolled, `name="bge-options-*"`); only the fields that
426
+ * drive conditional rendering are controlled.
427
+ * @param root0
428
+ * @param root0.block
429
+ * @example
430
+ * ```tsx
431
+ * <EditorDialog
432
+ * name="options"
433
+ * open={block !== null}
434
+ * onClose={close}
435
+ * action={(formData) => applyBlockOptions(block, formData)}
436
+ * buttons={{ close: 'キャンセル', complete: '決定' }}>
437
+ * {block ? <BlockOptions block={block} /> : null}
438
+ * </EditorDialog>
439
+ * ```
440
+ */
441
+ function BlockOptions(t0) {
442
+ const $ = c(73);
443
+ const { block } = t0;
444
+ const engine = useEngine();
445
+ const currentBlock = block;
446
+ const uid = useId();
447
+ let t1;
448
+ if ($[0] !== currentBlock) {
449
+ t1 = () => currentBlock.exportOptions();
450
+ $[0] = currentBlock;
451
+ $[1] = t1;
452
+ } else t1 = $[1];
453
+ const [options] = useState(t1);
454
+ let t2;
455
+ if ($[2] !== engine || $[3] !== options.containerProps.type) {
456
+ t2 = engine.getCustomProperties(options.containerProps.type);
457
+ $[2] = engine;
458
+ $[3] = options.containerProps.type;
459
+ $[4] = t2;
460
+ } else t2 = $[4];
461
+ const cssProps = t2;
462
+ let t3;
463
+ if ($[5] !== engine) {
464
+ t3 = engine.getRepeatMinInlineSizeVariants();
465
+ $[5] = engine;
466
+ $[6] = t3;
467
+ } else t3 = $[6];
468
+ const repeatMinInlineSizeVariants = t3;
469
+ const [currentColumns, setCurrentColumns] = useState(options.containerProps.columns ?? 1);
470
+ const [currentContainerType, setCurrentContainerType] = useState(options.containerProps.type);
471
+ const [currentFrameSemantics, setCurrentFrameSemantics] = useState(options.containerProps.frameSemantics);
472
+ const [currentAutoRepeat, setCurrentAutoRepeat] = useState(options.containerProps.autoRepeat ?? "fixed");
473
+ const itemCount = currentBlock.items.length;
474
+ const effectiveContainerType = options.containerProps.type === "float" ? options.containerProps.type : currentContainerType;
475
+ let t4;
476
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
477
+ t4 = /* @__PURE__ */ jsx("legend", { children: "コンテナ特性" });
478
+ $[7] = t4;
479
+ } else t4 = $[7];
480
+ let t5;
481
+ if ($[8] !== currentContainerType || $[9] !== options.containerProps.immutable || $[10] !== options.containerProps.type) {
482
+ t5 = options.containerProps.immutable || options.containerProps.type === "float" ? /* @__PURE__ */ jsxs("label", { children: [/* @__PURE__ */ jsx("span", { children: "コンテナタイプ" }), /* @__PURE__ */ jsxs("output", { children: [
483
+ containerTypeLabel[options.containerProps.type ?? "inline"],
484
+ " (",
485
+ options.containerProps.type ?? "inline",
486
+ ")"
487
+ ] })] }) : /* @__PURE__ */ jsxs("label", { children: [/* @__PURE__ */ jsx("span", { children: "コンテナタイプ" }), /* @__PURE__ */ jsxs("select", {
488
+ name: "bge-options-container-type",
489
+ value: currentContainerType,
490
+ onChange: (e) => {
491
+ setCurrentContainerType(e.currentTarget.value);
492
+ },
493
+ children: [/* @__PURE__ */ jsx("option", {
494
+ value: "grid",
495
+ children: containerTypeLabel.grid
496
+ }), /* @__PURE__ */ jsx("option", {
497
+ value: "inline",
498
+ children: containerTypeLabel.inline
499
+ })]
500
+ })] });
501
+ $[8] = currentContainerType;
502
+ $[9] = options.containerProps.immutable;
503
+ $[10] = options.containerProps.type;
504
+ $[11] = t5;
505
+ } else t5 = $[11];
506
+ let t6;
507
+ if ($[12] !== currentFrameSemantics || $[13] !== options.containerProps.immutable || $[14] !== options.containerProps.type) {
508
+ t6 = !options.containerProps.immutable && options.containerProps.type !== "float" ? /* @__PURE__ */ jsxs("label", { children: [/* @__PURE__ */ jsx("span", { children: "セマンティック要素" }), /* @__PURE__ */ jsxs("select", {
509
+ name: "bge-options-frame-semantics",
510
+ value: currentFrameSemantics,
511
+ onChange: (e_0) => {
512
+ setCurrentFrameSemantics(e_0.currentTarget.value);
513
+ },
514
+ children: [
515
+ /* @__PURE__ */ jsx("option", {
516
+ value: "div",
517
+ children: "div(汎用)"
518
+ }),
519
+ /* @__PURE__ */ jsx("option", {
520
+ value: "ul",
521
+ children: "ul(順序なしリスト)"
522
+ }),
523
+ /* @__PURE__ */ jsx("option", {
524
+ value: "ol",
525
+ children: "ol(順序ありリスト)"
526
+ })
527
+ ]
528
+ })] }) : null;
529
+ $[12] = currentFrameSemantics;
530
+ $[13] = options.containerProps.immutable;
531
+ $[14] = options.containerProps.type;
532
+ $[15] = t6;
533
+ } else t6 = $[15];
534
+ let t7;
535
+ if ($[16] !== effectiveContainerType || $[17] !== itemCount || $[18] !== options.containerProps.align || $[19] !== options.containerProps.immutable || $[20] !== options.containerProps.justify || $[21] !== uid) {
536
+ t7 = effectiveContainerType === "inline" && !(options.containerProps.immutable && itemCount === 1) ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("div", {
537
+ role: "radiogroup",
538
+ "aria-labelledby": `${uid}-justify`,
539
+ children: [/* @__PURE__ */ jsx("div", {
540
+ id: `${uid}-justify`,
541
+ children: "横方向配置"
542
+ }), [
543
+ ["center", "中央寄せ"],
544
+ ["start", "左寄せ"],
545
+ ["end", "右寄せ"],
546
+ ["between", "両端寄せ"],
547
+ ["around", "要素間余白均等"],
548
+ ["evenly", "要素間均等"]
549
+ ].map((t8) => {
550
+ const [value, label] = t8;
551
+ return /* @__PURE__ */ jsxs("label", { children: [/* @__PURE__ */ jsx("input", {
552
+ type: "radio",
553
+ name: "bge-options-justify",
554
+ value,
555
+ defaultChecked: options.containerProps.justify === value
556
+ }), /* @__PURE__ */ jsx("span", { children: label })] }, value);
557
+ })]
558
+ }), /* @__PURE__ */ jsxs("div", {
559
+ role: "radiogroup",
560
+ "aria-labelledby": `${uid}-align`,
561
+ children: [/* @__PURE__ */ jsx("div", {
562
+ id: `${uid}-align`,
563
+ children: "縦向配置"
564
+ }), [
565
+ ["align-center", "垂直中央寄せ"],
566
+ ["align-start", "上寄せ"],
567
+ ["align-end", "下寄せ"],
568
+ ["align-stretch", "伸縮"],
569
+ ["align-baseline", "ベースライン"]
570
+ ].map((t9) => {
571
+ const [value_0, label_0] = t9;
572
+ return /* @__PURE__ */ jsxs("label", { children: [/* @__PURE__ */ jsx("input", {
573
+ type: "radio",
574
+ name: "bge-options-align",
575
+ value: value_0,
576
+ defaultChecked: options.containerProps.align === value_0
577
+ }), /* @__PURE__ */ jsx("span", { children: label_0 })] }, value_0);
578
+ })]
579
+ })] }) : null;
580
+ $[16] = effectiveContainerType;
581
+ $[17] = itemCount;
582
+ $[18] = options.containerProps.align;
583
+ $[19] = options.containerProps.immutable;
584
+ $[20] = options.containerProps.justify;
585
+ $[21] = uid;
586
+ $[22] = t7;
587
+ } else t7 = $[22];
588
+ let t8;
589
+ if ($[23] !== currentAutoRepeat || $[24] !== currentColumns || $[25] !== effectiveContainerType || $[26] !== options.containerProps.immutable || $[27] !== options.containerProps.repeatMinInlineSize || $[28] !== options.containerProps.type || $[29] !== repeatMinInlineSizeVariants || $[30] !== uid) {
590
+ t8 = effectiveContainerType === "grid" ? options.containerProps.immutable || options.containerProps.type === "float" ? /* @__PURE__ */ jsx("p", { children: "このブロックはコンテナタイプを変更できません。" }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
591
+ /* @__PURE__ */ jsxs("label", { children: [/* @__PURE__ */ jsx("span", { children: "列の自動調整" }), /* @__PURE__ */ jsxs("select", {
592
+ name: "bge-options-auto-repeat",
593
+ value: currentAutoRepeat,
594
+ onChange: (e_1) => {
595
+ setCurrentAutoRepeat(e_1.currentTarget.value);
596
+ },
597
+ children: [
598
+ /* @__PURE__ */ jsx("option", {
599
+ value: "fixed",
600
+ children: "固定列数"
601
+ }),
602
+ /* @__PURE__ */ jsx("option", {
603
+ value: "auto-fill",
604
+ children: "auto-fill(空白保持)"
605
+ }),
606
+ /* @__PURE__ */ jsx("option", {
607
+ value: "auto-fit",
608
+ children: "auto-fit(空白最小)"
609
+ })
610
+ ]
611
+ })] }),
612
+ currentAutoRepeat === "fixed" ? /* @__PURE__ */ jsxs("span", { children: [/* @__PURE__ */ jsxs("label", { children: [/* @__PURE__ */ jsx("span", { children: "基準列数" }), /* @__PURE__ */ jsx("input", {
613
+ id: `${uid}-columns`,
614
+ name: "bge-options-columns",
615
+ type: "range",
616
+ value: currentColumns,
617
+ onChange: (e_2) => {
618
+ setCurrentColumns(e_2.currentTarget.valueAsNumber);
619
+ },
620
+ min: "1",
621
+ max: "5"
622
+ })] }), /* @__PURE__ */ jsx("output", {
623
+ htmlFor: `${uid}-columns`,
624
+ children: currentColumns
625
+ })] }) : null,
626
+ currentAutoRepeat !== "fixed" && repeatMinInlineSizeVariants ? /* @__PURE__ */ jsxs("label", { children: [/* @__PURE__ */ jsx("span", { children: "折り返し基準幅" }), /* @__PURE__ */ jsx("select", {
627
+ name: "bge-options-repeat-min-inline-size",
628
+ defaultValue: [...repeatMinInlineSizeVariants.properties].find((t9) => {
629
+ const [variantName, data] = t9;
630
+ return options.containerProps.repeatMinInlineSize == null ? data.isDefault : options.containerProps.repeatMinInlineSize === variantName;
631
+ })?.[0],
632
+ children: [...repeatMinInlineSizeVariants.properties].map(_temp$4)
633
+ })] }) : null
634
+ ] }) : null;
635
+ $[23] = currentAutoRepeat;
636
+ $[24] = currentColumns;
637
+ $[25] = effectiveContainerType;
638
+ $[26] = options.containerProps.immutable;
639
+ $[27] = options.containerProps.repeatMinInlineSize;
640
+ $[28] = options.containerProps.type;
641
+ $[29] = repeatMinInlineSizeVariants;
642
+ $[30] = uid;
643
+ $[31] = t8;
644
+ } else t8 = $[31];
645
+ let t9;
646
+ if ($[32] !== effectiveContainerType || $[33] !== options.containerProps.float || $[34] !== uid) {
647
+ t9 = effectiveContainerType === "float" ? /* @__PURE__ */ jsxs("div", {
648
+ role: "radiogroup",
649
+ "aria-labelledby": `${uid}-float`,
650
+ children: [/* @__PURE__ */ jsx("div", {
651
+ id: `${uid}-float`,
652
+ children: "回り込み"
653
+ }), [["start", "左寄せ"], ["end", "右寄せ"]].map((t10) => {
654
+ const [value_1, label_1] = t10;
655
+ return /* @__PURE__ */ jsxs("label", { children: [/* @__PURE__ */ jsx("input", {
656
+ type: "radio",
657
+ name: "bge-options-float",
658
+ value: value_1,
659
+ defaultChecked: options.containerProps.float === value_1
660
+ }), /* @__PURE__ */ jsx("span", { children: label_1 })] }, value_1);
661
+ })]
662
+ }) : null;
663
+ $[32] = effectiveContainerType;
664
+ $[33] = options.containerProps.float;
665
+ $[34] = uid;
666
+ $[35] = t9;
667
+ } else t9 = $[35];
668
+ const t10 = options.containerProps.linkarea ?? false;
669
+ let t11;
670
+ if ($[36] !== t10) {
671
+ t11 = /* @__PURE__ */ jsx("input", {
672
+ type: "checkbox",
673
+ name: "bge-options-linkarea",
674
+ value: "true",
675
+ defaultChecked: t10
676
+ });
677
+ $[36] = t10;
678
+ $[37] = t11;
679
+ } else t11 = $[37];
680
+ let t12;
681
+ if ($[38] === Symbol.for("react.memo_cache_sentinel")) {
682
+ t12 = /* @__PURE__ */ jsx("span", { children: "リンクエリア機能を有効にする" });
683
+ $[38] = t12;
684
+ } else t12 = $[38];
685
+ let t13;
686
+ if ($[39] !== t11) {
687
+ t13 = /* @__PURE__ */ jsxs("label", { children: [t11, t12] });
688
+ $[39] = t11;
689
+ $[40] = t13;
690
+ } else t13 = $[40];
691
+ let t14;
692
+ if ($[41] !== t13 || $[42] !== t5 || $[43] !== t6 || $[44] !== t7 || $[45] !== t8 || $[46] !== t9) {
693
+ t14 = /* @__PURE__ */ jsxs("fieldset", { children: [
694
+ t4,
695
+ t5,
696
+ t6,
697
+ t7,
698
+ t8,
699
+ t9,
700
+ t13
701
+ ] });
702
+ $[41] = t13;
703
+ $[42] = t5;
704
+ $[43] = t6;
705
+ $[44] = t7;
706
+ $[45] = t8;
707
+ $[46] = t9;
708
+ $[47] = t14;
709
+ } else t14 = $[47];
710
+ let t15;
711
+ if ($[48] !== cssProps || $[49] !== options.style) {
712
+ t15 = cssProps.size > 0 ? /* @__PURE__ */ jsxs("fieldset", { children: [/* @__PURE__ */ jsx("legend", { children: "ブロックのスタイル拡張" }), [...cssProps].map((t16) => {
713
+ const [, category] = t16;
714
+ const selected = [...category.properties].find((t17) => {
715
+ const [propName, data_1] = t17;
716
+ return options.style?.[category.id] == null ? data_1.isDefault : options.style[category.id] === propName;
717
+ });
718
+ return /* @__PURE__ */ jsxs("label", { children: [/* @__PURE__ */ jsx("span", { children: category.name }), /* @__PURE__ */ jsx("select", {
719
+ name: `bge-options-style-${category.id}`,
720
+ defaultValue: selected ? selected[1].isDefault ? "@@default" : selected[0] : void 0,
721
+ children: [...category.properties].map(_temp2$3)
722
+ })] }, `bge-options-style-${category.id}`);
723
+ })] }) : null;
724
+ $[48] = cssProps;
725
+ $[49] = options.style;
726
+ $[50] = t15;
727
+ } else t15 = $[50];
728
+ let t16;
729
+ if ($[51] === Symbol.for("react.memo_cache_sentinel")) {
730
+ t16 = /* @__PURE__ */ jsx("span", { children: "独自class設定" });
731
+ $[51] = t16;
732
+ } else t16 = $[51];
733
+ let t17;
734
+ if ($[52] !== options.classList) {
735
+ t17 = options.classList?.join(" ") ?? "";
736
+ $[52] = options.classList;
737
+ $[53] = t17;
738
+ } else t17 = $[53];
739
+ const t18 = `${uid}-classes-desc`;
740
+ let t19;
741
+ if ($[54] !== t17 || $[55] !== t18) {
742
+ t19 = /* @__PURE__ */ jsxs("label", { children: [t16, /* @__PURE__ */ jsx("input", {
743
+ type: "text",
744
+ name: "bge-options-classes",
745
+ defaultValue: t17,
746
+ "aria-describedby": t18
747
+ })] });
748
+ $[54] = t17;
749
+ $[55] = t18;
750
+ $[56] = t19;
751
+ } else t19 = $[56];
752
+ const t20 = `${uid}-classes-desc`;
753
+ let t21;
754
+ if ($[57] !== t20) {
755
+ t21 = /* @__PURE__ */ jsx("small", {
756
+ id: t20,
757
+ children: "複数指定する場合はスペース(空白文字)で区切ってください。"
758
+ });
759
+ $[57] = t20;
760
+ $[58] = t21;
761
+ } else t21 = $[58];
762
+ let t22;
763
+ if ($[59] === Symbol.for("react.memo_cache_sentinel")) {
764
+ t22 = /* @__PURE__ */ jsxs("span", { children: ["ID設定: ", /* @__PURE__ */ jsx("code", { children: "bge-" })] });
765
+ $[59] = t22;
766
+ } else t22 = $[59];
767
+ const t23 = options.id ?? "";
768
+ const t24 = `${uid}-id-desc`;
769
+ let t25;
770
+ if ($[60] !== t23 || $[61] !== t24) {
771
+ t25 = /* @__PURE__ */ jsxs("label", { children: [t22, /* @__PURE__ */ jsx("input", {
772
+ name: "bge-options-id",
773
+ type: "text",
774
+ defaultValue: t23,
775
+ "aria-describedby": t24
776
+ })] });
777
+ $[60] = t23;
778
+ $[61] = t24;
779
+ $[62] = t25;
780
+ } else t25 = $[62];
781
+ const t26 = `${uid}-id-desc`;
782
+ let t27;
783
+ if ($[63] === Symbol.for("react.memo_cache_sentinel")) {
784
+ t27 = /* @__PURE__ */ jsx("code", { children: "bge-" });
785
+ $[63] = t27;
786
+ } else t27 = $[63];
787
+ let t28;
788
+ if ($[64] !== t26) {
789
+ t28 = /* @__PURE__ */ jsxs("small", {
790
+ id: t26,
791
+ children: [
792
+ "アンカーリンク用のID属性を設定します。実際のIDは",
793
+ t27,
794
+ "が自動的に先頭に付加されます。"
795
+ ]
796
+ });
797
+ $[64] = t26;
798
+ $[65] = t28;
799
+ } else t28 = $[65];
800
+ let t29;
801
+ if ($[66] !== t14 || $[67] !== t15 || $[68] !== t19 || $[69] !== t21 || $[70] !== t25 || $[71] !== t28) {
802
+ t29 = /* @__PURE__ */ jsxs(Fragment$1, { children: [
803
+ t14,
804
+ t15,
805
+ t19,
806
+ t21,
807
+ t25,
808
+ t28
809
+ ] });
810
+ $[66] = t14;
811
+ $[67] = t15;
812
+ $[68] = t19;
813
+ $[69] = t21;
814
+ $[70] = t25;
815
+ $[71] = t28;
816
+ $[72] = t29;
817
+ } else t29 = $[72];
818
+ return t29;
819
+ }
820
+ function _temp2$3(t0) {
821
+ const [propName_0, data_2] = t0;
822
+ return /* @__PURE__ */ jsx("option", {
823
+ value: data_2.isDefault ? "@@default" : propName_0,
824
+ children: `${propName_0} (${data_2.value})`
825
+ }, propName_0);
826
+ }
827
+ function _temp$4(t0) {
828
+ const [variantName_0, data_0] = t0;
829
+ return /* @__PURE__ */ jsx("option", {
830
+ value: variantName_0,
831
+ children: `${variantName_0} (${data_0.value})`
832
+ }, variantName_0);
833
+ }
834
+ // ../../../node_modules/react-error-boundary/dist/react-error-boundary.js
835
+ var f = createContext(null);
836
+ function m({ children: r, didCatch: e, error: t, resetErrorBoundary: o }) {
837
+ const n = useMemo(() => ({
838
+ didCatch: e,
839
+ error: t,
840
+ resetErrorBoundary: o
841
+ }), [
842
+ e,
843
+ t,
844
+ o
845
+ ]);
846
+ return createElement(f.Provider, { value: n }, r);
847
+ }
848
+ var d = {
849
+ didCatch: !1,
850
+ error: null
851
+ };
852
+ var C = class extends Component {
853
+ constructor(e) {
854
+ super(e), this.resetErrorBoundary = this.resetErrorBoundary.bind(this), this.state = d;
855
+ }
856
+ static getDerivedStateFromError(e) {
857
+ return {
858
+ didCatch: !0,
859
+ error: e
860
+ };
861
+ }
862
+ resetErrorBoundary(...e) {
863
+ const { didCatch: t } = this.state;
864
+ t && (this.props.onReset?.({
865
+ args: e,
866
+ reason: "imperative-api"
867
+ }), this.setState(d));
868
+ }
869
+ componentDidCatch(e, t) {
870
+ this.props.onError?.(e, t);
871
+ }
872
+ componentDidUpdate(e, t) {
873
+ const { didCatch: o } = this.state, { resetKeys: n } = this.props;
874
+ o && t.didCatch && g(e.resetKeys, n) && (this.props.onReset?.({
875
+ next: n,
876
+ prev: e.resetKeys,
877
+ reason: "keys"
878
+ }), this.setState(d));
879
+ }
880
+ render() {
881
+ const { children: e, fallbackRender: t, FallbackComponent: o, fallback: n } = this.props, { didCatch: s, error: a } = this.state;
882
+ let c = e;
883
+ if (s) {
884
+ const u = {
885
+ error: a,
886
+ resetErrorBoundary: this.resetErrorBoundary
887
+ };
888
+ if (typeof t == "function") c = t(u);
889
+ else if (o) c = createElement(o, u);
890
+ else if ("fallback" in this.props) c = n;
891
+ else throw a;
892
+ }
893
+ return createElement(m, {
894
+ didCatch: s,
895
+ error: a,
896
+ resetErrorBoundary: this.resetErrorBoundary
897
+ }, c);
898
+ }
899
+ };
900
+ function g(r = [], e = []) {
901
+ return r.length !== e.length || r.some((t, o) => !Object.is(t, e[o]));
902
+ }
903
+ // src/invoker-commands.ts
904
+ /**
905
+ * Invoker Commands API attributes for buttons. Re-exported (rather than
906
+ * imported for side effects only) so that the module augmentation above
907
+ * survives d.ts bundling and reaches consumers.
908
+ */
909
+ // src/editor-dialog.tsx
910
+ /**
911
+ * Minimal fallback for a dialog body that suspended and then threw.
912
+ * Display-only — the dialog's own close button (outside this boundary,
913
+ * in the footer) is always available as a way out.
914
+ * @param root0
915
+ * @param root0.error
916
+ */
917
+ function DialogErrorFallback(t0) {
918
+ const $ = c(2);
919
+ const { error } = t0;
920
+ const t1 = error instanceof Error ? error.message : String(error);
921
+ let t2;
922
+ if ($[0] !== t1) {
923
+ t2 = /* @__PURE__ */ jsxs("p", {
924
+ role: "alert",
925
+ children: ["エラーが発生しました: ", t1]
926
+ });
927
+ $[0] = t1;
928
+ $[1] = t2;
929
+ } else t2 = $[1];
930
+ return t2;
931
+ }
932
+ /**
933
+ * Suspense fallback shown while a dialog body's `use()` calls are
934
+ * pending (e.g. content stylesheet fetch). Kept intentionally small —
935
+ * the dialog chrome (title, footer buttons) renders immediately.
936
+ */
937
+ function DialogSkeleton() {
938
+ const $ = c(1);
939
+ let t0;
940
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
941
+ t0 = /* @__PURE__ */ jsx("p", {
942
+ "aria-busy": "true",
943
+ children: "読み込み中…"
944
+ });
945
+ $[0] = t0;
946
+ } else t0 = $[0];
947
+ return t0;
948
+ }
949
+ /**
950
+ * Declarative `<dialog>` shell.
951
+ *
952
+ * The markup follows the `dialog.bge-dialog > div > form > div` + `footer`
953
+ * structure that `ui.css` styles. Opening/closing is driven by the `open`
954
+ * prop; the close button uses the built-in `close` command — no click
955
+ * handlers. Submission goes through `<form action>` (`useActionState`):
956
+ * on success the dialog stays under the caller's control (the action is
957
+ * responsible for closing it — typically `engine.uiState.closeDialog()`
958
+ * + `engine.save()`); on a thrown error the dialog stays open and shows
959
+ * the message via `role="alert"`, and the submit button is disabled
960
+ * while pending.
961
+ * @param root0
962
+ * @param root0.name
963
+ * @param root0.open
964
+ * @param root0.onClose
965
+ * @param root0.action
966
+ * @param root0.buttons
967
+ * @param root0.buttons.close
968
+ * @param root0.buttons.complete
969
+ * @param root0.children
970
+ * @example
971
+ * ```tsx
972
+ * <EditorDialog
973
+ * name="options"
974
+ * open={block !== null}
975
+ * onClose={() => { engine.uiState.closeDialog(); engine.save(); }}
976
+ * action={(formData) => {
977
+ * applyBlockOptions(block, formData);
978
+ * engine.uiState.closeDialog();
979
+ * engine.save();
980
+ * }}
981
+ * buttons={{ close: 'キャンセル', complete: '決定' }}>
982
+ * {block ? <BlockOptions block={block} /> : null}
983
+ * </EditorDialog>
984
+ * ```
985
+ */
986
+ function EditorDialog(t0) {
987
+ const $ = c(18);
988
+ const { name, open, onClose, action, buttons, children } = t0;
989
+ const dialogRef = useRef(null);
990
+ const uid = useId();
991
+ const dialogId = `${uid}-dialog`;
992
+ const formId = `${uid}-form`;
993
+ const [prevOpen, setPrevOpen] = useState(open);
994
+ const [generation, setGeneration] = useState(0);
995
+ if (open !== prevOpen) {
996
+ setPrevOpen(open);
997
+ if (open) setGeneration(_temp$3);
998
+ }
999
+ let t1;
1000
+ let t2;
1001
+ if ($[0] !== open) {
1002
+ t1 = () => {
1003
+ const dialog = dialogRef.current;
1004
+ if (!dialog) return;
1005
+ if (open && !dialog.open) dialog.showModal();
1006
+ else if (!open && dialog.open) dialog.close();
1007
+ };
1008
+ t2 = [open];
1009
+ $[0] = open;
1010
+ $[1] = t1;
1011
+ $[2] = t2;
1012
+ } else {
1013
+ t1 = $[1];
1014
+ t2 = $[2];
1015
+ }
1016
+ useEffect(t1, t2);
1017
+ let t3;
1018
+ if ($[3] !== onClose) {
1019
+ t3 = (e) => {
1020
+ if (e.target !== e.currentTarget) return;
1021
+ onClose();
1022
+ };
1023
+ $[3] = onClose;
1024
+ $[4] = t3;
1025
+ } else t3 = $[4];
1026
+ let t4;
1027
+ if ($[5] !== action || $[6] !== buttons || $[7] !== children || $[8] !== dialogId || $[9] !== formId || $[10] !== generation || $[11] !== name || $[12] !== open) {
1028
+ t4 = /* @__PURE__ */ jsx(EditorDialogBody, {
1029
+ name,
1030
+ formId,
1031
+ dialogId,
1032
+ open,
1033
+ action,
1034
+ buttons,
1035
+ children
1036
+ }, generation);
1037
+ $[5] = action;
1038
+ $[6] = buttons;
1039
+ $[7] = children;
1040
+ $[8] = dialogId;
1041
+ $[9] = formId;
1042
+ $[10] = generation;
1043
+ $[11] = name;
1044
+ $[12] = open;
1045
+ $[13] = t4;
1046
+ } else t4 = $[13];
1047
+ let t5;
1048
+ if ($[14] !== dialogId || $[15] !== t3 || $[16] !== t4) {
1049
+ t5 = /* @__PURE__ */ jsx("dialog", {
1050
+ ref: dialogRef,
1051
+ id: dialogId,
1052
+ className: "bge-dialog",
1053
+ closedby: "any",
1054
+ onClose: t3,
1055
+ children: t4
1056
+ });
1057
+ $[14] = dialogId;
1058
+ $[15] = t3;
1059
+ $[16] = t4;
1060
+ $[17] = t5;
1061
+ } else t5 = $[17];
1062
+ return t5;
1063
+ }
1064
+ /**
1065
+ * The form + footer, split out from {@link EditorDialog} solely so it can
1066
+ * be remounted (via a `key` the caller bumps on each open) without also
1067
+ * remounting the `<dialog>` element itself — see the comment at the
1068
+ * `key={generation}` call site for why.
1069
+ * @param root0
1070
+ * @param root0.name
1071
+ * @param root0.formId
1072
+ * @param root0.dialogId
1073
+ * @param root0.open
1074
+ * @param root0.action
1075
+ * @param root0.buttons
1076
+ * @param root0.buttons.close
1077
+ * @param root0.buttons.complete
1078
+ * @param root0.children
1079
+ */
1080
+ function _temp$3(g) {
1081
+ return g + 1;
1082
+ }
1083
+ function EditorDialogBody({ name, formId, dialogId, open, action, buttons, children }) {
1084
+ const [error, submitAction, isPending] = useActionState(async (_prevError, formData) => {
1085
+ try {
1086
+ await action?.(formData);
1087
+ return null;
1088
+ } catch (error_) {
1089
+ return error_ instanceof Error ? error_.message : String(error_);
1090
+ }
1091
+ }, null);
1092
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("form", {
1093
+ id: formId,
1094
+ action: submitAction,
1095
+ noValidate: true,
1096
+ autoComplete: "off",
1097
+ autoCapitalize: "off",
1098
+ children: [/* @__PURE__ */ jsx("div", {
1099
+ "data-bge-component": `${name}-dialog`,
1100
+ children: open ? /* @__PURE__ */ jsx(C, {
1101
+ FallbackComponent: DialogErrorFallback,
1102
+ children: /* @__PURE__ */ jsx(Suspense, {
1103
+ fallback: /* @__PURE__ */ jsx(DialogSkeleton, {}),
1104
+ children
1105
+ })
1106
+ }) : null
1107
+ }), error ? /* @__PURE__ */ jsx("p", {
1108
+ role: "alert",
1109
+ children: error
1110
+ }) : null]
1111
+ }) }), /* @__PURE__ */ jsxs("footer", { children: [buttons?.close ? /* @__PURE__ */ jsx("button", {
1112
+ type: "button",
1113
+ command: "close",
1114
+ commandfor: dialogId,
1115
+ children: buttons.close
1116
+ }) : null, buttons?.complete ? /* @__PURE__ */ jsx("button", {
1117
+ type: "submit",
1118
+ form: formId,
1119
+ disabled: isPending,
1120
+ "aria-busy": isPending,
1121
+ children: buttons.complete
1122
+ }) : null] })] });
1123
+ }
1124
+ // src/components/item-editor-host.tsx
1125
+ /**
1126
+ * Declarative item editor dialog. Renders the item's `Editor` component
1127
+ * with editor state derived via `toEditorState`; on submit the state is
1128
+ * converted back with `toItemData` and imported into the item. Reads the
1129
+ * engine via {@link useEngine}.
1130
+ * @param root0
1131
+ * @param root0.item
1132
+ * @param root0.containerType
1133
+ * @example
1134
+ * ```tsx
1135
+ * <ItemEditorHost
1136
+ * item={open?.type === 'item-editor' ? open.item : null}
1137
+ * containerType={open?.type === 'item-editor' ? open.containerType : undefined}
1138
+ * />
1139
+ * ```
1140
+ */
1141
+ function ItemEditorHost(t0) {
1142
+ const $ = c(13);
1143
+ const { item, containerType } = t0;
1144
+ const engine = useEngine();
1145
+ const submitRef = useRef(null);
1146
+ let t1;
1147
+ if ($[0] !== engine) {
1148
+ t1 = () => {
1149
+ engine.uiState.closeDialog();
1150
+ engine.save();
1151
+ };
1152
+ $[0] = engine;
1153
+ $[1] = t1;
1154
+ } else t1 = $[1];
1155
+ const closeAndSave = t1;
1156
+ const t2 = !!item;
1157
+ let t3;
1158
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
1159
+ t3 = {
1160
+ close: "キャンセル",
1161
+ complete: "決定"
1162
+ };
1163
+ $[2] = t3;
1164
+ } else t3 = $[2];
1165
+ let t4;
1166
+ if ($[3] !== closeAndSave) {
1167
+ t4 = async () => {
1168
+ await submitRef.current?.();
1169
+ closeAndSave();
1170
+ };
1171
+ $[3] = closeAndSave;
1172
+ $[4] = t4;
1173
+ } else t4 = $[4];
1174
+ let t5;
1175
+ if ($[5] !== containerType || $[6] !== item) {
1176
+ t5 = item ? /* @__PURE__ */ jsx(ItemEditorBody, {
1177
+ item,
1178
+ containerType,
1179
+ submitRef
1180
+ }) : null;
1181
+ $[5] = containerType;
1182
+ $[6] = item;
1183
+ $[7] = t5;
1184
+ } else t5 = $[7];
1185
+ let t6;
1186
+ if ($[8] !== closeAndSave || $[9] !== t2 || $[10] !== t4 || $[11] !== t5) {
1187
+ t6 = /* @__PURE__ */ jsx(EditorDialog, {
1188
+ name: "item-editor",
1189
+ open: t2,
1190
+ buttons: t3,
1191
+ onClose: closeAndSave,
1192
+ action: t4,
1193
+ children: t5
1194
+ });
1195
+ $[8] = closeAndSave;
1196
+ $[9] = t2;
1197
+ $[10] = t4;
1198
+ $[11] = t5;
1199
+ $[12] = t6;
1200
+ } else t6 = $[12];
1201
+ return t6;
1202
+ }
1203
+ /**
1204
+ * The editor form body. Owns the editor state for the currently edited
1205
+ * item.
1206
+ * @param root0
1207
+ * @param root0.item
1208
+ * @param root0.containerType
1209
+ * @param root0.submitRef
1210
+ */
1211
+ function ItemEditorBody(t0) {
1212
+ const $ = c(24);
1213
+ const { item, containerType, submitRef } = t0;
1214
+ const engine = useEngine();
1215
+ const seed = item.seed;
1216
+ let t1;
1217
+ if ($[0] !== engine || $[1] !== item || $[2] !== seed) {
1218
+ t1 = () => {
1219
+ const data = item.export();
1220
+ return seed.toEditorState ? seed.toEditorState(data, engine.config) : data;
1221
+ };
1222
+ $[0] = engine;
1223
+ $[1] = item;
1224
+ $[2] = seed;
1225
+ $[3] = t1;
1226
+ } else t1 = $[3];
1227
+ const [state, setState] = useState(t1);
1228
+ let t2;
1229
+ if ($[4] !== engine || $[5] !== seed || $[6] !== state) {
1230
+ t2 = async () => seed.toItemData ? await seed.toItemData(state, engine.config) : state;
1231
+ $[4] = engine;
1232
+ $[5] = seed;
1233
+ $[6] = state;
1234
+ $[7] = t2;
1235
+ } else t2 = $[7];
1236
+ const resolveSubmitData = useEffectEvent(t2);
1237
+ let t3;
1238
+ if ($[8] !== item || $[9] !== resolveSubmitData || $[10] !== submitRef) {
1239
+ t3 = () => {
1240
+ submitRef.current = async () => {
1241
+ const data_0 = await resolveSubmitData();
1242
+ await item.import(data_0);
1243
+ };
1244
+ return () => {
1245
+ submitRef.current = null;
1246
+ };
1247
+ };
1248
+ $[8] = item;
1249
+ $[9] = resolveSubmitData;
1250
+ $[10] = submitRef;
1251
+ $[11] = t3;
1252
+ } else t3 = $[11];
1253
+ let t4;
1254
+ if ($[12] !== item || $[13] !== submitRef) {
1255
+ t4 = [item, submitRef];
1256
+ $[12] = item;
1257
+ $[13] = submitRef;
1258
+ $[14] = t4;
1259
+ } else t4 = $[14];
1260
+ useEffect(t3, t4);
1261
+ const Editor = seed.Editor;
1262
+ if (!Editor) {
1263
+ let t5;
1264
+ if ($[15] !== item.name) {
1265
+ t5 = /* @__PURE__ */ jsxs("p", { children: [
1266
+ "編集できないコンテンツです (Error: Editor not found: \"",
1267
+ item.name,
1268
+ "\")"
1269
+ ] });
1270
+ $[15] = item.name;
1271
+ $[16] = t5;
1272
+ } else t5 = $[16];
1273
+ return t5;
1274
+ }
1275
+ let t5;
1276
+ if ($[17] !== Editor || $[18] !== item || $[19] !== state) {
1277
+ t5 = /* @__PURE__ */ jsx(Editor, {
1278
+ state,
1279
+ setState,
1280
+ item
1281
+ });
1282
+ $[17] = Editor;
1283
+ $[18] = item;
1284
+ $[19] = state;
1285
+ $[20] = t5;
1286
+ } else t5 = $[20];
1287
+ let t6;
1288
+ if ($[21] !== containerType || $[22] !== t5) {
1289
+ t6 = /* @__PURE__ */ jsx("div", {
1290
+ "data-bge-container": containerType,
1291
+ children: t5
1292
+ });
1293
+ $[21] = containerType;
1294
+ $[22] = t5;
1295
+ $[23] = t6;
1296
+ } else t6 = $[23];
1297
+ return t6;
1298
+ }
1299
+ // src/use-engine.ts
1300
+ var identity = (state) => state;
1301
+ /**
1302
+ * Subscribe to the engine's UI state store.
1303
+ *
1304
+ * Wraps `useSyncExternalStoreWithSelector` so call sites don't repeat the
1305
+ * subscribe/getSnapshot/selector wiring. `engine.uiState.subscribe` and
1306
+ * `.getSnapshot` are stable per-instance methods (see `UIStateStore`), so
1307
+ * passing them directly — instead of a new inline closure each render —
1308
+ * means React doesn't unsubscribe and resubscribe on every render. The
1309
+ * engine is read from the nearest `EngineProvider`.
1310
+ * @returns The current UI state snapshot
1311
+ * @example
1312
+ * ```tsx
1313
+ * const { openDialog } = useUIState();
1314
+ * return <ItemEditorHost item={openDialog?.type === 'item-editor' ? openDialog.item : null} />;
1315
+ * ```
1316
+ */
1317
+ /**
1318
+ * Subscribe to a projection of the engine's UI state store.
1319
+ *
1320
+ * 選択的な状態(`processing` や `sourceMode[type]` など)だけを読む
1321
+ * コンポーネントは、`selector` でそのフィールドだけを取り出すと無関係な
1322
+ * 状態変化(例: ダイアログの開閉)での再レンダーを避けられる —
1323
+ * `useSyncExternalStoreWithSelector` が選択後の値を `Object.is` で比較し、
1324
+ * 変化がなければ再レンダーをスキップする(selector 自体は毎レンダー
1325
+ * 新しい関数でよい。比較されるのは戻り値であって関数の同一性ではない)。
1326
+ * @param selector - Projection of the snapshot
1327
+ * @returns The selected value
1328
+ * @example
1329
+ * ```tsx
1330
+ * // 無関係な状態変化での再レンダーを避ける
1331
+ * const processing = useUIState((s) => s.processing);
1332
+ * ```
1333
+ */
1334
+ function useUIState(selector) {
1335
+ const engine = useEngine();
1336
+ return useSyncExternalStoreWithSelector(engine.uiState.subscribe, engine.uiState.getSnapshot, engine.uiState.getSnapshot, selector ?? identity);
1337
+ }
1338
+ // src/replace-element.ts
1339
+ var nextViewTransitionId = 0;
1340
+ /**
1341
+ * Swap two adjacent sibling blocks with a View Transition, then wait until it
1342
+ * finishes so `beginProcessing()` covers the same window as before.
1343
+ *
1344
+ * Animation length and `prefers-reduced-motion: reduce` are controlled by CSS
1345
+ * injected into the editable-area iframe (`editable-area-view.tsx`), not here.
1346
+ * @param elA - First sibling element
1347
+ * @param elB - Second sibling element (same parent as `elA`)
1348
+ * @example
1349
+ * ```ts
1350
+ * await replaceElement(currentBlock.el, currentBlock.el.nextElementSibling as HTMLElement);
1351
+ * // The two blocks have exchanged positions in the DOM.
1352
+ * ```
1353
+ */
1354
+ async function replaceElement(elA, elB) {
1355
+ if (elA.parentElement !== elB.parentElement) throw new Error("The parent element of the two elements is different.");
1356
+ const doc = elA.ownerDocument;
1357
+ const startViewTransition = doc.startViewTransition?.bind(doc);
1358
+ if (!startViewTransition) {
1359
+ elB.remove();
1360
+ elA.before(elB);
1361
+ return;
1362
+ }
1363
+ const id = ++nextViewTransitionId;
1364
+ const nameA = `bge-block-swap-${id}-a`;
1365
+ const nameB = `bge-block-swap-${id}-b`;
1366
+ const previousNameA = elA.style.viewTransitionName;
1367
+ const previousNameB = elB.style.viewTransitionName;
1368
+ elA.style.viewTransitionName = nameA;
1369
+ elB.style.viewTransitionName = nameB;
1370
+ try {
1371
+ await startViewTransition(() => {
1372
+ elB.remove();
1373
+ elA.before(elB);
1374
+ }).finished;
1375
+ } finally {
1376
+ if (previousNameA) elA.style.viewTransitionName = previousNameA;
1377
+ else elA.style.removeProperty("view-transition-name");
1378
+ if (previousNameB) elB.style.viewTransitionName = previousNameB;
1379
+ else elB.style.removeProperty("view-transition-name");
1380
+ }
1381
+ }
1382
+ // src/commands/register-engine-commands.ts
1383
+ /**
1384
+ * Register the engine's central command dispatch table.
1385
+ *
1386
+ * This is the single place where engine-mutating UI commands are
1387
+ * implemented; buttons anywhere (main document or EditableArea iframes)
1388
+ * declare them with `commandfor={engine.commandBus.receiverId}`. Call once
1389
+ * per engine.
1390
+ * @param engine - The engine instance
1391
+ * @param catalog - The block catalog used by `--add-block`
1392
+ * @example
1393
+ * ```ts
1394
+ * const engine = await BurgerEditorEngine.new(options);
1395
+ * registerEngineCommands(engine, options.catalog);
1396
+ * ```
1397
+ */
1398
+ function registerEngineCommands(engine, catalog) {
1399
+ const bus = engine.commandBus;
1400
+ bus.define(BGE_COMMAND.moveBlock, async (e) => {
1401
+ const currentBlock = engine.getCurrentBlock();
1402
+ if (engine.isProcessed || !currentBlock) return;
1403
+ const toTop = e.source?.value === "up";
1404
+ let fromEl;
1405
+ let toEl;
1406
+ if (toTop) {
1407
+ fromEl = currentBlock.el.previousElementSibling;
1408
+ toEl = currentBlock.el;
1409
+ } else {
1410
+ fromEl = currentBlock.el;
1411
+ toEl = currentBlock.el.nextElementSibling;
1412
+ }
1413
+ if (!fromEl || !toEl) return;
1414
+ {
1415
+ using _processing = beginProcessing(engine);
1416
+ await replaceElement(fromEl, toEl);
1417
+ }
1418
+ engine.save();
1419
+ });
1420
+ bus.define(BGE_COMMAND.insertBlock, (e) => {
1421
+ const currentBlock = engine.getCurrentBlock();
1422
+ if (engine.isProcessed || !currentBlock) return;
1423
+ const toTop = e.source?.value === "before";
1424
+ engine.content.insertionPoint.set(currentBlock, toTop);
1425
+ engine.uiState.openBlockCatalog();
1426
+ });
1427
+ bus.define(BGE_COMMAND.updateGridItems, (e) => {
1428
+ const currentBlock = engine.getCurrentBlock();
1429
+ if (engine.isProcessed || !currentBlock) return;
1430
+ const addOrRemove = e.source?.value === "-1" ? -1 : 1;
1431
+ if (addOrRemove === -1 && !confirm("ブロック内の最後の要素を削除します。\n削除した要素はもとに戻すことはできません。\n削除してもよろしいですか?")) return;
1432
+ currentBlock.updateGridItems(addOrRemove, engine);
1433
+ engine.save();
1434
+ });
1435
+ bus.define(BGE_COMMAND.openBlockOptions, () => {
1436
+ const currentBlock = engine.getCurrentBlock();
1437
+ if (engine.isProcessed || !currentBlock) return;
1438
+ engine.uiState.openBlockOptions(currentBlock);
1439
+ });
1440
+ bus.define(BGE_COMMAND.copyBlock, () => {
1441
+ const currentBlock = engine.getCurrentBlock();
1442
+ if (engine.isProcessed || !currentBlock) return;
1443
+ const json = currentBlock.toJSONStringify();
1444
+ sessionStorage.setItem(engine.storageKey.blockClipboard, json);
1445
+ alert("ブロックをコピーしました。\nブロックの追加ボタンからペースト(貼り付け)することができます。");
1446
+ });
1447
+ bus.define(BGE_COMMAND.removeBlock, async () => {
1448
+ const currentBlock = engine.getCurrentBlock();
1449
+ if (engine.isProcessed || !currentBlock) return;
1450
+ if (!confirm("ブロックを削除します。\n削除したブロックはもとに戻すことはできません。\n削除してもよろしいですか?")) return;
1451
+ {
1452
+ using _processing = beginProcessing(engine);
1453
+ await Promise.resolve();
1454
+ currentBlock.remove();
1455
+ engine.clearCurrentBlock();
1456
+ }
1457
+ engine.save();
1458
+ });
1459
+ bus.define(BGE_COMMAND.insertInitialBlock, () => {
1460
+ if (engine.isProcessed) return;
1461
+ engine.content.insertionPoint.set(null, false);
1462
+ engine.uiState.openBlockCatalog();
1463
+ });
1464
+ bus.define(BGE_COMMAND.addBlock, async (e) => {
1465
+ const source = e.source;
1466
+ const category = source?.dataset["category"];
1467
+ const index = Number(source?.dataset["index"]);
1468
+ const definition = category ? catalog[category]?.[index]?.definition : void 0;
1469
+ if (!definition) return;
1470
+ engine.uiState.closeDialog();
1471
+ await engine.addBlock(definition);
1472
+ });
1473
+ bus.define(BGE_COMMAND.switchContent, (e) => {
1474
+ if (e.source?.value === "main") engine.showMain();
1475
+ else engine.showDraft();
1476
+ });
1477
+ bus.define(BGE_COMMAND.copyMainToDraft, async () => {
1478
+ if (await engine.mainToDraft(() => confirm("本稿内容を下書きへ上書きしてもよろしいですか?"))) engine.showDraft();
1479
+ });
1480
+ bus.define(BGE_COMMAND.copyDraftToMain, async () => {
1481
+ if (await engine.draftToMain(() => confirm("下書き内容を本稿へ上書きしてもよろしいですか?"))) engine.showMain();
1482
+ });
1483
+ bus.define(BGE_COMMAND.pasteBlock, async () => {
1484
+ const jsonString = sessionStorage.getItem(engine.storageKey.blockClipboard);
1485
+ if (!jsonString) {
1486
+ alert("クリップボードにブロックデータがありません。");
1487
+ return;
1488
+ }
1489
+ let blockData;
1490
+ try {
1491
+ blockData = JSON.parse(jsonString);
1492
+ } catch (error) {
1493
+ console.error("Invalid JSON in clipboard:", error);
1494
+ alert("ブロックの貼り付けに失敗しました。\nクリップボードのデータが破損している可能性があります。\nもう一度ブロックをコピーしてください。");
1495
+ return;
1496
+ }
1497
+ engine.uiState.closeDialog();
1498
+ await engine.addBlock(blockData);
1499
+ sessionStorage.removeItem(engine.storageKey.blockClipboard);
1500
+ });
1501
+ }
1502
+ var draft_switcher_module_default = {
1503
+ draftBtn: "_draftBtn_14xtl_1",
1504
+ draftTabBtn: "_draftTabBtn_14xtl_16",
1505
+ draftCopyBtn: "_draftCopyBtn_14xtl_47"
1506
+ };
1507
+ // src/components/draft-switcher.tsx
1508
+ /**
1509
+ * Main/draft content switcher. Switching and copying are declared as
1510
+ * engine commands; the pressed state follows `engine.uiState.activeArea`
1511
+ * and the source-view indicator follows `engine.uiState.sourceMode` — no
1512
+ * state is duplicated locally. Reads the engine via {@link useEngine} —
1513
+ * the caller wraps this in an `EngineProvider`.
1514
+ *
1515
+ * The alt+double-click source-view toggle is kept as a DOM event —
1516
+ * double-click has no Invoker Commands equivalent (the no-click rule
1517
+ * targets single-click activation).
1518
+ * @example
1519
+ * ```tsx
1520
+ * const container = document.createElement('div');
1521
+ * engine.viewArea.insertAdjacentElement('beforebegin', container);
1522
+ * reactMount(
1523
+ * <EngineProvider engine={engine}>
1524
+ * <DraftSwitcher />
1525
+ * </EngineProvider>,
1526
+ * container,
1527
+ * );
1528
+ * ```
1529
+ */
1530
+ function DraftSwitcher() {
1531
+ const $ = c(36);
1532
+ const engine = useEngine();
1533
+ const sourceMode = useUIState(_temp$2);
1534
+ const isMain = useUIState(_temp2$2);
1535
+ const isVisualMode = !sourceMode[isMain ? "main" : "draft"];
1536
+ let t0;
1537
+ if ($[0] !== engine.content.type || $[1] !== engine.uiState) {
1538
+ t0 = () => {
1539
+ engine.uiState.toggleSourceMode(engine.content.type);
1540
+ };
1541
+ $[0] = engine.content.type;
1542
+ $[1] = engine.uiState;
1543
+ $[2] = t0;
1544
+ } else t0 = $[2];
1545
+ const toggleDisplayMode = t0;
1546
+ let t1;
1547
+ if ($[3] !== engine || $[4] !== isMain || $[5] !== toggleDisplayMode) {
1548
+ t1 = (e) => {
1549
+ if (!e.altKey || !isMain) return;
1550
+ engine.showMain();
1551
+ toggleDisplayMode();
1552
+ };
1553
+ $[3] = engine;
1554
+ $[4] = isMain;
1555
+ $[5] = toggleDisplayMode;
1556
+ $[6] = t1;
1557
+ } else t1 = $[6];
1558
+ const onDblClickMain = t1;
1559
+ let t2;
1560
+ if ($[7] !== engine || $[8] !== isMain || $[9] !== toggleDisplayMode) {
1561
+ t2 = (e_0) => {
1562
+ if (!e_0.altKey || isMain) return;
1563
+ engine.showDraft();
1564
+ toggleDisplayMode();
1565
+ };
1566
+ $[7] = engine;
1567
+ $[8] = isMain;
1568
+ $[9] = toggleDisplayMode;
1569
+ $[10] = t2;
1570
+ } else t2 = $[10];
1571
+ const onDblClickDraft = t2;
1572
+ let t3;
1573
+ if ($[11] !== isMain || $[12] !== isVisualMode) {
1574
+ t3 = isMain && !isVisualMode ? /* @__PURE__ */ jsx("span", { children: "ソース表示" }) : null;
1575
+ $[11] = isMain;
1576
+ $[12] = isVisualMode;
1577
+ $[13] = t3;
1578
+ } else t3 = $[13];
1579
+ let t4;
1580
+ if ($[14] !== engine.commandBus.receiverId || $[15] !== isMain || $[16] !== onDblClickMain || $[17] !== t3) {
1581
+ t4 = /* @__PURE__ */ jsxs("button", {
1582
+ type: "button",
1583
+ "aria-pressed": isMain,
1584
+ command: BGE_COMMAND.switchContent,
1585
+ commandfor: engine.commandBus.receiverId,
1586
+ value: "main",
1587
+ onDoubleClick: onDblClickMain,
1588
+ children: ["本稿モード", t3]
1589
+ });
1590
+ $[14] = engine.commandBus.receiverId;
1591
+ $[15] = isMain;
1592
+ $[16] = onDblClickMain;
1593
+ $[17] = t3;
1594
+ $[18] = t4;
1595
+ } else t4 = $[18];
1596
+ const t5 = !isMain;
1597
+ let t6;
1598
+ if ($[19] !== isMain || $[20] !== isVisualMode) {
1599
+ t6 = !isMain && !isVisualMode ? /* @__PURE__ */ jsx("span", { children: "ソース表示" }) : null;
1600
+ $[19] = isMain;
1601
+ $[20] = isVisualMode;
1602
+ $[21] = t6;
1603
+ } else t6 = $[21];
1604
+ let t7;
1605
+ if ($[22] !== engine.commandBus.receiverId || $[23] !== onDblClickDraft || $[24] !== t5 || $[25] !== t6) {
1606
+ t7 = /* @__PURE__ */ jsxs("button", {
1607
+ type: "button",
1608
+ "aria-pressed": t5,
1609
+ command: BGE_COMMAND.switchContent,
1610
+ commandfor: engine.commandBus.receiverId,
1611
+ value: "draft",
1612
+ onDoubleClick: onDblClickDraft,
1613
+ children: ["下書きモード", t6]
1614
+ });
1615
+ $[22] = engine.commandBus.receiverId;
1616
+ $[23] = onDblClickDraft;
1617
+ $[24] = t5;
1618
+ $[25] = t6;
1619
+ $[26] = t7;
1620
+ } else t7 = $[26];
1621
+ let t8;
1622
+ if ($[27] !== t4 || $[28] !== t7) {
1623
+ t8 = /* @__PURE__ */ jsxs("div", {
1624
+ className: draft_switcher_module_default.draftTabBtn,
1625
+ children: [t4, t7]
1626
+ });
1627
+ $[27] = t4;
1628
+ $[28] = t7;
1629
+ $[29] = t8;
1630
+ } else t8 = $[29];
1631
+ let t9;
1632
+ if ($[30] !== engine.commandBus.receiverId || $[31] !== isMain) {
1633
+ t9 = /* @__PURE__ */ jsx("div", {
1634
+ className: draft_switcher_module_default.draftCopyBtn,
1635
+ children: isMain ? /* @__PURE__ */ jsx("button", {
1636
+ type: "button",
1637
+ command: BGE_COMMAND.copyMainToDraft,
1638
+ commandfor: engine.commandBus.receiverId,
1639
+ children: "本稿を下書きにコピー"
1640
+ }) : /* @__PURE__ */ jsx("button", {
1641
+ type: "button",
1642
+ command: BGE_COMMAND.copyDraftToMain,
1643
+ commandfor: engine.commandBus.receiverId,
1644
+ children: "下書きを本稿にコピー"
1645
+ })
1646
+ });
1647
+ $[30] = engine.commandBus.receiverId;
1648
+ $[31] = isMain;
1649
+ $[32] = t9;
1650
+ } else t9 = $[32];
1651
+ let t10;
1652
+ if ($[33] !== t8 || $[34] !== t9) {
1653
+ t10 = /* @__PURE__ */ jsxs("div", {
1654
+ className: draft_switcher_module_default.draftBtn,
1655
+ children: [t8, t9]
1656
+ });
1657
+ $[33] = t8;
1658
+ $[34] = t9;
1659
+ $[35] = t10;
1660
+ } else t10 = $[35];
1661
+ return t10;
1662
+ }
1663
+ function _temp2$2(s_0) {
1664
+ return s_0.activeArea === "main";
1665
+ }
1666
+ function _temp$2(s) {
1667
+ return s.sourceMode;
1668
+ }
1669
+ // src/mount.tsx
1670
+ /**
1671
+ * Mount a React node into a DOM container and return a `Disposable`
1672
+ * teardown handle, matching the `UICreator` contract shape used across
1673
+ * the engine.
1674
+ * @param node - The React node to render
1675
+ * @param target - The DOM container
1676
+ * @returns A handle that unmounts the root, via `using` or `cleanUp()`
1677
+ * @example
1678
+ * ```tsx
1679
+ * using mount = reactMount(
1680
+ * <EngineProvider engine={engine}>
1681
+ * <DraftSwitcher />
1682
+ * </EngineProvider>,
1683
+ * container,
1684
+ * );
1685
+ * // Root is unmounted automatically when `mount` goes out of scope.
1686
+ * ```
1687
+ */
1688
+ function reactMount(node, target) {
1689
+ const root = createRoot(target);
1690
+ root.render(node);
1691
+ const teardown = () => {
1692
+ root.unmount();
1693
+ };
1694
+ return {
1695
+ cleanUp: teardown,
1696
+ [Symbol.dispose]: teardown
1697
+ };
1698
+ }
1699
+ // src/root-error-boundary.tsx
1700
+ /**
1701
+ * Report a render error onto the engine element as `bge:error`. This is
1702
+ * the only way an in-tree failure reaches code outside React — `core`
1703
+ * never reads the event, platform layers (e.g. `local`) may log it.
1704
+ * @param engine - The engine instance to report on
1705
+ * @param error - The thrown value
1706
+ * @param componentStack - The React component stack, when available
1707
+ */
1708
+ function reportRenderError(engine, error, componentStack) {
1709
+ engine.el.dispatchEvent(createBgeEvent("bge:error", {
1710
+ error,
1711
+ componentStack
1712
+ }));
1713
+ }
1714
+ /**
1715
+ * Fallback for {@link RootErrorBoundary}: reports the error and renders
1716
+ * nothing. Only *this boundary's own subtree* is replaced — how big that
1717
+ * subtree is depends entirely on where the boundary is placed. Placed
1718
+ * once around the whole single-root tree (as `createReactView` does for
1719
+ * the top level), it is a last resort: the whole editor blanks. Nested
1720
+ * one level per editable area (as `createReactView` also does) or per
1721
+ * dialog (`EditorDialog`'s own boundary around each dialog's body), it
1722
+ * instead isolates a failure to that one area/dialog and leaves sibling
1723
+ * areas, other dialogs, and the chrome running.
1724
+ * @param root0
1725
+ * @param root0.error
1726
+ */
1727
+ function RootErrorFallback(t0) {
1728
+ const $ = c(4);
1729
+ const { error } = t0;
1730
+ const engine = useEngine();
1731
+ let t1;
1732
+ let t2;
1733
+ if ($[0] !== engine || $[1] !== error) {
1734
+ t1 = () => {
1735
+ reportRenderError(engine, error);
1736
+ };
1737
+ t2 = [engine, error];
1738
+ $[0] = engine;
1739
+ $[1] = error;
1740
+ $[2] = t1;
1741
+ $[3] = t2;
1742
+ } else {
1743
+ t1 = $[2];
1744
+ t2 = $[3];
1745
+ }
1746
+ useEffect(t1, t2);
1747
+ return null;
1748
+ }
1749
+ /**
1750
+ * Reusable error boundary for the client UI tree: reports the caught
1751
+ * error as `bge:error` and blanks only its own subtree. Deliberately not
1752
+ * scoped to any one tree position — `createReactView` places one around
1753
+ * the whole single-root tree as a last resort, and one more per editable
1754
+ * area so a failure in one area (or the `BlockMenu` inside it) does not
1755
+ * blank sibling areas or the dialog chrome. `EditorDialog` places its own
1756
+ * around each dialog's body for the same reason at that granularity.
1757
+ * @param root0
1758
+ * @param root0.children
1759
+ * @example
1760
+ * ```tsx
1761
+ * <EngineProvider engine={engine}>
1762
+ * <RootErrorBoundary>
1763
+ * <BurgerEditorRoot />
1764
+ * </RootErrorBoundary>
1765
+ * </EngineProvider>
1766
+ * ```
1767
+ */
1768
+ function RootErrorBoundary(t0) {
1769
+ const $ = c(2);
1770
+ const { children } = t0;
1771
+ let t1;
1772
+ if ($[0] !== children) {
1773
+ t1 = /* @__PURE__ */ jsx(C, {
1774
+ FallbackComponent: RootErrorFallback,
1775
+ children
1776
+ });
1777
+ $[0] = children;
1778
+ $[1] = t1;
1779
+ } else t1 = $[1];
1780
+ return t1;
1781
+ }
1782
+ // src/animate-insertion.ts
1783
+ var INSERTION_ANIMATION_DURATION_MS = 400;
1784
+ /**
1785
+ * Expand the block-insertion marker from zero to its natural height.
1786
+ *
1787
+ * Implemented with `Element.animate()` because its `finished` promise
1788
+ * settles regardless of the animation's duration — a CSS transition +
1789
+ * `transitionend` never fires when the duration is 0 (e.g. under
1790
+ * `prefers-reduced-motion: reduce`), which would leave the engine's
1791
+ * processing flag stuck. Cancellation is also treated as completion.
1792
+ * @param markerEl - The marker element wrapping the inserted block
1793
+ * @example
1794
+ * ```ts
1795
+ * await animateInsertion(markerEl);
1796
+ * // The marker is fully expanded (or the animation was skipped).
1797
+ * ```
1798
+ */
1799
+ async function animateInsertion(markerEl) {
1800
+ markerEl.style.height = "auto";
1801
+ const targetHeight = markerEl.getBoundingClientRect().height;
1802
+ markerEl.style.overflow = "hidden";
1803
+ const reducedMotion = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
1804
+ await markerEl.animate([{ height: "0px" }, { height: `${targetHeight}px` }], {
1805
+ duration: reducedMotion ? 0 : INSERTION_ANIMATION_DURATION_MS,
1806
+ easing: "ease"
1807
+ }).finished.then(() => {}, () => {});
1808
+ }
1809
+ // src/block-swap-view-transition-css.ts
1810
+ /**
1811
+ * Editable-area iframe 文書に注入するブロック入れ替え View Transition 用 CSS。
1812
+ * アニメ時間と prefers-reduced-motion はここが正であり、`replace-element.spec.ts`
1813
+ * でも同じ文字列を注入して検証する。
1814
+ */
1815
+ var BLOCK_SWAP_VIEW_TRANSITION_CSS = `
1816
+ ::view-transition {
1817
+ pointer-events: none;
1818
+ }
1819
+
1820
+ ::view-transition-group(*) {
1821
+ animation-duration: 600ms;
1822
+ }
1823
+
1824
+ @media (prefers-reduced-motion: reduce) {
1825
+ ::view-transition-group(*),
1826
+ ::view-transition-old(*),
1827
+ ::view-transition-new(*) {
1828
+ animation: none;
1829
+ }
1830
+ }
1831
+ `.trim();
1832
+ // src/use-command.ts
1833
+ /**
1834
+ * Receive Invoker Commands API `command` events on the element the returned
1835
+ * ref callback is attached to. Buttons address the element with
1836
+ * `commandfor={idOfElement}`; `CommandEvent` does not bubble, so the ref
1837
+ * must be on the exact `commandfor` target.
1838
+ *
1839
+ * Returns a ref **callback** (not a `RefObject`) so the listener attaches
1840
+ * as soon as the element mounts, including when the element appears later
1841
+ * from a conditional render — a `useRef` + `useEffect(..., [])` pair only
1842
+ * reads `ref.current` once, at the first commit, and would miss an
1843
+ * element that shows up afterward. `handlers` is read through
1844
+ * `useEffectEvent` so the listener always calls the latest render's
1845
+ * closure without needing `handlers` in the attach effect's deps (and
1846
+ * without re-attaching the DOM listener on every render).
1847
+ * @param handlers - Map of custom command names to handlers
1848
+ * @returns A ref callback to attach to the receiving element
1849
+ * @example
1850
+ * ```tsx
1851
+ * const rootId = useId();
1852
+ * const rootRef = useCommand<HTMLDivElement>({
1853
+ * '--select-tab': (e) => {
1854
+ * setCurrent(Number((e.source as HTMLButtonElement | null)?.value));
1855
+ * },
1856
+ * });
1857
+ * return (
1858
+ * <div ref={rootRef} id={rootId}>
1859
+ * <button command="--select-tab" commandfor={rootId} value="1">タブ1</button>
1860
+ * </div>
1861
+ * );
1862
+ * ```
1863
+ */
1864
+ function useCommand(handlers) {
1865
+ const $ = c(7);
1866
+ const [el, setEl] = useState(null);
1867
+ let t0;
1868
+ if ($[0] !== handlers) {
1869
+ t0 = (event) => {
1870
+ const handler = handlers[event.command];
1871
+ handler?.(event);
1872
+ };
1873
+ $[0] = handlers;
1874
+ $[1] = t0;
1875
+ } else t0 = $[1];
1876
+ const onCommand = useEffectEvent(t0);
1877
+ let t1;
1878
+ if ($[2] !== el || $[3] !== onCommand) {
1879
+ t1 = () => {
1880
+ if (!el) return;
1881
+ const listener = (event_0) => onCommand(event_0);
1882
+ el.addEventListener("command", listener);
1883
+ return () => {
1884
+ el.removeEventListener("command", listener);
1885
+ };
1886
+ };
1887
+ $[2] = el;
1888
+ $[3] = onCommand;
1889
+ $[4] = t1;
1890
+ } else t1 = $[4];
1891
+ let t2;
1892
+ if ($[5] !== el) {
1893
+ t2 = [el];
1894
+ $[5] = el;
1895
+ $[6] = t2;
1896
+ } else t2 = $[6];
1897
+ useEffect(t1, t2);
1898
+ return setEl;
1899
+ }
1900
+ // src/components/block-menu-anchors.ts
1901
+ /** ホバー中ブロックの CSS アンカー名(`position-anchor` の参照先) */
1902
+ var BGE_BLOCK_MENU_BLOCK_ANCHOR = "--bge-current-block";
1903
+ /**
1904
+ * ブロック内アイテム(`[data-bgi]`)の CSS アンカー名を返す。
1905
+ * @param index - ブロック内の出現順(0 始まり)
1906
+ * @example
1907
+ * ```ts
1908
+ * bgeBlockMenuItemAnchorName(0); // '--bge-block-menu-item-0'
1909
+ * ```
1910
+ */
1911
+ function bgeBlockMenuItemAnchorName(index) {
1912
+ return `--bge-block-menu-item-${index}`;
1913
+ }
1914
+ /**
1915
+ * @param blockEl - `[data-bge-container]` のブロック要素
1916
+ */
1917
+ function clearBlockMenuAnchors(blockEl) {
1918
+ blockEl.style.removeProperty("anchor-name");
1919
+ for (const itemEl of blockEl.querySelectorAll("[data-bgi]")) itemEl.style.removeProperty("anchor-name");
1920
+ }
1921
+ /**
1922
+ * メニューとアイテムオーバーレイが参照するアンカーをブロック DOM に付与する。
1923
+ * `itemEls` は `Item.getInstance` で解決済みの `[data-bgi]` だけを渡す(オーバーレイの
1924
+ * `value` インデックスと `itemsRef` が同じ並びになる)。
1925
+ * @param blockEl - `[data-bge-container]` のブロック要素
1926
+ * @param itemEls - アンカーを付与するアイテム要素(出現順)
1927
+ * @returns 付与したアイテムアンカー名の一覧(オーバーレイの `position-anchor` 用)
1928
+ */
1929
+ function applyBlockMenuAnchors(blockEl, itemEls) {
1930
+ blockEl.style.setProperty("anchor-name", BGE_BLOCK_MENU_BLOCK_ANCHOR);
1931
+ const anchorNames = [];
1932
+ for (const [index, itemEl] of itemEls.entries()) {
1933
+ const name = bgeBlockMenuItemAnchorName(index);
1934
+ itemEl.style.setProperty("anchor-name", name);
1935
+ anchorNames.push(name);
1936
+ }
1937
+ return anchorNames;
1938
+ }
1939
+ var block_menu_button_module_default = { wrapper: "_wrapper_rfa8x_1" };
1940
+ // src/components/block-menu-button.tsx
1941
+ /**
1942
+ * Icon button of the block menu with an anchored hint tooltip (`interestfor`
1943
+ * + `popover="hint"`). Esc dismisses the tooltip without moving pointer or
1944
+ * focus (WCAG 1.4.13). The admin UI targets the latest stable Chrome, which
1945
+ * implements Interest Invokers; without `HTMLButtonElement.prototype
1946
+ * .interestForElement`, hints do not open (there is no CSS-only fallback).
1947
+ * The action is declared with the Invoker Commands API instead of a click
1948
+ * handler.
1949
+ * @param root0
1950
+ * @param root0.label
1951
+ * @param root0.command
1952
+ * @param root0.commandfor
1953
+ * @param root0.value
1954
+ * @param root0.children
1955
+ * @example
1956
+ * ```tsx
1957
+ * <BlockMenuButton
1958
+ * label="ブロックを削除"
1959
+ * command={BGE_COMMAND.removeBlock}
1960
+ * commandfor={engine.commandBus.receiverId}>
1961
+ * <IconTrash />
1962
+ * </BlockMenuButton>
1963
+ * ```
1964
+ */
1965
+ function BlockMenuButton(t0) {
1966
+ const $ = c(17);
1967
+ const { label, command, commandfor, value, children } = t0;
1968
+ const uid = useId();
1969
+ let t1;
1970
+ if ($[0] !== uid) {
1971
+ t1 = CSS.escape(uid);
1972
+ $[0] = uid;
1973
+ $[1] = t1;
1974
+ } else t1 = $[1];
1975
+ const t2 = `--anchor-${t1}`;
1976
+ let t3;
1977
+ if ($[2] !== t2) {
1978
+ t3 = { "--name": t2 };
1979
+ $[2] = t2;
1980
+ $[3] = t3;
1981
+ } else t3 = $[3];
1982
+ const t4 = t3;
1983
+ let t5;
1984
+ if ($[4] !== children || $[5] !== command || $[6] !== commandfor || $[7] !== uid || $[8] !== value) {
1985
+ t5 = /* @__PURE__ */ jsx("button", {
1986
+ type: "button",
1987
+ "aria-labelledby": uid,
1988
+ interestfor: uid,
1989
+ command,
1990
+ commandfor,
1991
+ value,
1992
+ children
1993
+ });
1994
+ $[4] = children;
1995
+ $[5] = command;
1996
+ $[6] = commandfor;
1997
+ $[7] = uid;
1998
+ $[8] = value;
1999
+ $[9] = t5;
2000
+ } else t5 = $[9];
2001
+ let t6;
2002
+ if ($[10] !== label || $[11] !== uid) {
2003
+ t6 = /* @__PURE__ */ jsx("span", {
2004
+ id: uid,
2005
+ popover: "hint",
2006
+ children: label
2007
+ });
2008
+ $[10] = label;
2009
+ $[11] = uid;
2010
+ $[12] = t6;
2011
+ } else t6 = $[12];
2012
+ let t7;
2013
+ if ($[13] !== t4 || $[14] !== t5 || $[15] !== t6) {
2014
+ t7 = /* @__PURE__ */ jsxs("div", {
2015
+ className: block_menu_button_module_default.wrapper,
2016
+ style: t4,
2017
+ children: [t5, t6]
2018
+ });
2019
+ $[13] = t4;
2020
+ $[14] = t5;
2021
+ $[15] = t6;
2022
+ $[16] = t7;
2023
+ } else t7 = $[16];
2024
+ return t7;
2025
+ }
2026
+ var block_menu_module_default = {
2027
+ bgeMenuBase: "_bgeMenuBase_ry5ak_1",
2028
+ bgeMenuMargin: "_bgeMenuMargin_ry5ak_11",
2029
+ bgeMenu: "_bgeMenu_ry5ak_1",
2030
+ bgeItemOverlay: "_bgeItemOverlay_ry5ak_69",
2031
+ bgeMoveGroup: "_bgeMoveGroup_ry5ak_91",
2032
+ bgeStandardGroup: "_bgeStandardGroup_ry5ak_92"
2033
+ };
2034
+ // src/components/block-menu-view.tsx
2035
+ /**
2036
+ * 選択中ブロックの下マージン表示用。`BlockMenu` がブロック要素の
2037
+ * 算出スタイルから読み取り、余白インジケータ(`.bgeMenuMargin`)に渡す。
2038
+ * 位置とサイズは CSS アンカー配置(`--bge-current-block`)で追従する。
2039
+ * @example
2040
+ * ```ts
2041
+ * const margin: BlockMenuMargin = {
2042
+ * marginBlockEnd: 16,
2043
+ * marginBlockEndValue: '1em',
2044
+ * };
2045
+ * ```
2046
+ */
2047
+ /**
2048
+ * ブロック内の各アイテム(`[data-bgi]`)に付与した CSS アンカー名。
2049
+ * 対応する DOM 要素の `anchor-name` と一致し、オーバーレイの
2050
+ * `position-anchor` が参照する。
2051
+ * @example
2052
+ * ```ts
2053
+ * const anchor: ItemOverlayAnchor = { anchorName: '--bge-block-menu-item-0' };
2054
+ * ```
2055
+ */
2056
+ /**
2057
+ * @deprecated {@link BlockMenuMargin} に置き換え。位置・サイズはアンカー配置で決まる。
2058
+ */
2059
+ /**
2060
+ * @deprecated {@link ItemOverlayAnchor} に置き換え。
2061
+ */
2062
+ /**
2063
+ * `BlockMenu` の描画専用の中身。マウス追跡・`BurgerBlock` 解決・
2064
+ * `engine` 接続は一切持たず、マージンとアイテムアンカーを props で
2065
+ * 受け取って並べるだけの純粋なプレゼンテーションコンポーネント。
2066
+ *
2067
+ * `BurgerBlock` の実インスタンス生成なしに見た目だけ確認したい用途
2068
+ * (Storybook)のために `BlockMenu` から切り出されている。
2069
+ * @param root0
2070
+ * @param root0.rootRef
2071
+ * @param root0.menuId
2072
+ * @param root0.commandBusId
2073
+ * @param root0.visible
2074
+ * @param root0.margin
2075
+ * @param root0.itemAnchors
2076
+ * @param root0.isMutable
2077
+ * @example
2078
+ * ```tsx
2079
+ * <BlockMenuView
2080
+ * rootRef={rootRef}
2081
+ * menuId="bge-block-menu"
2082
+ * commandBusId={engine.commandBus.receiverId}
2083
+ * visible
2084
+ * margin={{ marginBlockEnd: 0, marginBlockEndValue: '0px' }}
2085
+ * itemAnchors={[{ anchorName: '--bge-block-menu-item-0' }]}
2086
+ * isMutable
2087
+ * />
2088
+ * ```
2089
+ */
2090
+ function BlockMenuView(t0) {
2091
+ const $ = c(55);
2092
+ const { rootRef, menuId, commandBusId, visible, margin, itemAnchors, isMutable } = t0;
2093
+ const t1 = !visible;
2094
+ const t2 = `${margin.marginBlockEnd}px`;
2095
+ let t3;
2096
+ if ($[0] !== t2) {
2097
+ t3 = { "--margin-block-end": t2 };
2098
+ $[0] = t2;
2099
+ $[1] = t3;
2100
+ } else t3 = $[1];
2101
+ const t4 = t3;
2102
+ let t5;
2103
+ if ($[2] !== itemAnchors || $[3] !== menuId) {
2104
+ let t6;
2105
+ if ($[5] !== menuId) {
2106
+ t6 = (item, index) => /* @__PURE__ */ jsx("button", {
2107
+ type: "button",
2108
+ className: block_menu_module_default.bgeItemOverlay,
2109
+ "aria-label": "コンテンツを編集",
2110
+ command: "--open-item-editor",
2111
+ commandfor: menuId,
2112
+ value: index,
2113
+ style: { "--item-anchor": item.anchorName }
2114
+ }, item.anchorName);
2115
+ $[5] = menuId;
2116
+ $[6] = t6;
2117
+ } else t6 = $[6];
2118
+ t5 = itemAnchors.map(t6);
2119
+ $[2] = itemAnchors;
2120
+ $[3] = menuId;
2121
+ $[4] = t5;
2122
+ } else t5 = $[4];
2123
+ let t6;
2124
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
2125
+ t6 = /* @__PURE__ */ jsx(IconArrowBigUpLine, {});
2126
+ $[7] = t6;
2127
+ } else t6 = $[7];
2128
+ let t7;
2129
+ if ($[8] !== commandBusId) {
2130
+ t7 = /* @__PURE__ */ jsx(BlockMenuButton, {
2131
+ label: "ひとつ上へ移動",
2132
+ command: BGE_COMMAND.moveBlock,
2133
+ commandfor: commandBusId,
2134
+ value: "up",
2135
+ children: t6
2136
+ });
2137
+ $[8] = commandBusId;
2138
+ $[9] = t7;
2139
+ } else t7 = $[9];
2140
+ let t8;
2141
+ if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
2142
+ t8 = /* @__PURE__ */ jsx(IconArrowBigDownLine, {});
2143
+ $[10] = t8;
2144
+ } else t8 = $[10];
2145
+ let t9;
2146
+ if ($[11] !== commandBusId) {
2147
+ t9 = /* @__PURE__ */ jsx(BlockMenuButton, {
2148
+ label: "ひとつ下へ移動",
2149
+ command: BGE_COMMAND.moveBlock,
2150
+ commandfor: commandBusId,
2151
+ value: "down",
2152
+ children: t8
2153
+ });
2154
+ $[11] = commandBusId;
2155
+ $[12] = t9;
2156
+ } else t9 = $[12];
2157
+ let t10;
2158
+ if ($[13] !== t7 || $[14] !== t9) {
2159
+ t10 = /* @__PURE__ */ jsxs("div", {
2160
+ className: block_menu_module_default.bgeMoveGroup,
2161
+ children: [t7, t9]
2162
+ });
2163
+ $[13] = t7;
2164
+ $[14] = t9;
2165
+ $[15] = t10;
2166
+ } else t10 = $[15];
2167
+ let t11;
2168
+ if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
2169
+ t11 = /* @__PURE__ */ jsx(IconRowInsertTop, {});
2170
+ $[16] = t11;
2171
+ } else t11 = $[16];
2172
+ let t12;
2173
+ if ($[17] !== commandBusId) {
2174
+ t12 = /* @__PURE__ */ jsx(BlockMenuButton, {
2175
+ label: "上にブロックを追加",
2176
+ command: BGE_COMMAND.insertBlock,
2177
+ commandfor: commandBusId,
2178
+ value: "before",
2179
+ children: t11
2180
+ });
2181
+ $[17] = commandBusId;
2182
+ $[18] = t12;
2183
+ } else t12 = $[18];
2184
+ let t13;
2185
+ if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
2186
+ t13 = /* @__PURE__ */ jsx(IconRowInsertBottom, {});
2187
+ $[19] = t13;
2188
+ } else t13 = $[19];
2189
+ let t14;
2190
+ if ($[20] !== commandBusId) {
2191
+ t14 = /* @__PURE__ */ jsx(BlockMenuButton, {
2192
+ label: "下にブロックを追加",
2193
+ command: BGE_COMMAND.insertBlock,
2194
+ commandfor: commandBusId,
2195
+ value: "after",
2196
+ children: t13
2197
+ });
2198
+ $[20] = commandBusId;
2199
+ $[21] = t14;
2200
+ } else t14 = $[21];
2201
+ let t15;
2202
+ if ($[22] !== commandBusId || $[23] !== isMutable) {
2203
+ t15 = isMutable ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(BlockMenuButton, {
2204
+ label: "ブロック内に要素を追加",
2205
+ command: BGE_COMMAND.updateGridItems,
2206
+ commandfor: commandBusId,
2207
+ value: "+1",
2208
+ children: /* @__PURE__ */ jsx(IconLayoutGridAdd, {})
2209
+ }), /* @__PURE__ */ jsx(BlockMenuButton, {
2210
+ label: "ブロック内の要素を削除",
2211
+ command: BGE_COMMAND.updateGridItems,
2212
+ commandfor: commandBusId,
2213
+ value: "-1",
2214
+ children: /* @__PURE__ */ jsx(IconLayoutGridRemove, {})
2215
+ })] }) : null;
2216
+ $[22] = commandBusId;
2217
+ $[23] = isMutable;
2218
+ $[24] = t15;
2219
+ } else t15 = $[24];
2220
+ let t16;
2221
+ if ($[25] === Symbol.for("react.memo_cache_sentinel")) {
2222
+ t16 = /* @__PURE__ */ jsx(IconSettings, {});
2223
+ $[25] = t16;
2224
+ } else t16 = $[25];
2225
+ let t17;
2226
+ if ($[26] !== commandBusId) {
2227
+ t17 = /* @__PURE__ */ jsx(BlockMenuButton, {
2228
+ label: "オプション設定",
2229
+ command: BGE_COMMAND.openBlockOptions,
2230
+ commandfor: commandBusId,
2231
+ children: t16
2232
+ });
2233
+ $[26] = commandBusId;
2234
+ $[27] = t17;
2235
+ } else t17 = $[27];
2236
+ let t18;
2237
+ if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
2238
+ t18 = /* @__PURE__ */ jsx(IconClipboardPlus, {});
2239
+ $[28] = t18;
2240
+ } else t18 = $[28];
2241
+ let t19;
2242
+ if ($[29] !== commandBusId) {
2243
+ t19 = /* @__PURE__ */ jsx(BlockMenuButton, {
2244
+ label: "ブロックをコピー",
2245
+ command: BGE_COMMAND.copyBlock,
2246
+ commandfor: commandBusId,
2247
+ children: t18
2248
+ });
2249
+ $[29] = commandBusId;
2250
+ $[30] = t19;
2251
+ } else t19 = $[30];
2252
+ let t20;
2253
+ if ($[31] === Symbol.for("react.memo_cache_sentinel")) {
2254
+ t20 = /* @__PURE__ */ jsx(IconTrash, {});
2255
+ $[31] = t20;
2256
+ } else t20 = $[31];
2257
+ let t21;
2258
+ if ($[32] !== commandBusId) {
2259
+ t21 = /* @__PURE__ */ jsx(BlockMenuButton, {
2260
+ label: "ブロックを削除",
2261
+ command: BGE_COMMAND.removeBlock,
2262
+ commandfor: commandBusId,
2263
+ children: t20
2264
+ });
2265
+ $[32] = commandBusId;
2266
+ $[33] = t21;
2267
+ } else t21 = $[33];
2268
+ let t22;
2269
+ if ($[34] !== t12 || $[35] !== t14 || $[36] !== t15 || $[37] !== t17 || $[38] !== t19 || $[39] !== t21) {
2270
+ t22 = /* @__PURE__ */ jsxs("div", {
2271
+ className: block_menu_module_default.bgeStandardGroup,
2272
+ children: [
2273
+ t12,
2274
+ t14,
2275
+ t15,
2276
+ t17,
2277
+ t19,
2278
+ t21
2279
+ ]
2280
+ });
2281
+ $[34] = t12;
2282
+ $[35] = t14;
2283
+ $[36] = t15;
2284
+ $[37] = t17;
2285
+ $[38] = t19;
2286
+ $[39] = t21;
2287
+ $[40] = t22;
2288
+ } else t22 = $[40];
2289
+ let t23;
2290
+ if ($[41] !== t10 || $[42] !== t22) {
2291
+ t23 = /* @__PURE__ */ jsxs("div", {
2292
+ className: block_menu_module_default.bgeMenu,
2293
+ children: [t10, t22]
2294
+ });
2295
+ $[41] = t10;
2296
+ $[42] = t22;
2297
+ $[43] = t23;
2298
+ } else t23 = $[43];
2299
+ let t24;
2300
+ if ($[44] !== margin.marginBlockEnd || $[45] !== margin.marginBlockEndValue) {
2301
+ t24 = /* @__PURE__ */ jsx("div", {
2302
+ className: block_menu_module_default.bgeMenuMargin,
2303
+ children: /* @__PURE__ */ jsxs("span", { children: [
2304
+ "余白: ",
2305
+ margin.marginBlockEndValue,
2306
+ " (",
2307
+ margin.marginBlockEnd,
2308
+ "px)"
2309
+ ] })
2310
+ });
2311
+ $[44] = margin.marginBlockEnd;
2312
+ $[45] = margin.marginBlockEndValue;
2313
+ $[46] = t24;
2314
+ } else t24 = $[46];
2315
+ let t25;
2316
+ if ($[47] !== menuId || $[48] !== rootRef || $[49] !== t1 || $[50] !== t23 || $[51] !== t24 || $[52] !== t4 || $[53] !== t5) {
2317
+ t25 = /* @__PURE__ */ jsxs("div", {
2318
+ ref: rootRef,
2319
+ id: menuId,
2320
+ hidden: t1,
2321
+ className: block_menu_module_default.bgeMenuBase,
2322
+ style: t4,
2323
+ children: [
2324
+ t5,
2325
+ t23,
2326
+ t24
2327
+ ]
2328
+ });
2329
+ $[47] = menuId;
2330
+ $[48] = rootRef;
2331
+ $[49] = t1;
2332
+ $[50] = t23;
2333
+ $[51] = t24;
2334
+ $[52] = t4;
2335
+ $[53] = t5;
2336
+ $[54] = t25;
2337
+ } else t25 = $[54];
2338
+ return t25;
2339
+ }
2340
+ // src/components/block-menu.tsx
2341
+ /**
2342
+ * Hover menu over the selected block inside the editable area iframe.
2343
+ * Block operations are declared as engine commands; positioning and
2344
+ * visibility are React state owned entirely by this component — the
2345
+ * single source of truth. While `engine.uiState.processing` is true the
2346
+ * menu hides itself by subscribing to the store; nothing outside React
2347
+ * ever writes this component's `hidden` attribute (a direct DOM write
2348
+ * would leave React's `visible` state out of sync and a later same-value
2349
+ * `setVisible(true)` would be skipped, leaving the menu stuck hidden).
2350
+ *
2351
+ * マウス追跡・`BurgerBlock` 解決・`engine` 接続を担うコンテナで、
2352
+ * 実際の描画は {@link BlockMenuView} に委譲する。`BlockMenuView` は
2353
+ * `BurgerBlock` の実インスタンスなしに見た目だけ確認できるため、
2354
+ * Storybook 等では `BlockMenuView` を直接使う。
2355
+ * @param root0
2356
+ * @param root0.container
2357
+ * @example
2358
+ * ```tsx
2359
+ * <BlockMenu container={frameBody} />
2360
+ * ```
2361
+ */
2362
+ function BlockMenu(t0) {
2363
+ const $ = c(33);
2364
+ const { container } = t0;
2365
+ const engine = useEngine();
2366
+ const menuId = useId();
2367
+ const currentBlock = useUIState(_temp$1);
2368
+ const [visible, setVisible] = useState(false);
2369
+ let t1;
2370
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
2371
+ t1 = [];
2372
+ $[0] = t1;
2373
+ } else t1 = $[0];
2374
+ const [itemAnchors, setItemAnchors] = useState(t1);
2375
+ let t2;
2376
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
2377
+ t2 = [];
2378
+ $[1] = t2;
2379
+ } else t2 = $[1];
2380
+ const itemsRef = useRef(t2);
2381
+ const anchoredBlockElRef = useRef(null);
2382
+ let t3;
2383
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
2384
+ t3 = {
2385
+ marginBlockEnd: 0,
2386
+ marginBlockEndValue: "0px"
2387
+ };
2388
+ $[2] = t3;
2389
+ } else t3 = $[2];
2390
+ const [margin, setMargin] = useState(t3);
2391
+ let t4;
2392
+ if ($[3] !== engine.isProcessed || $[4] !== engine.uiState) {
2393
+ t4 = { "--open-item-editor": (e) => {
2394
+ if (engine.isProcessed) return;
2395
+ const index = Number(e.source?.value);
2396
+ const item = itemsRef.current[index];
2397
+ if (!item) throw new Error(`item overlay index ${index} does not resolve to an Item`);
2398
+ engine.uiState.openItemEditor(item);
2399
+ } };
2400
+ $[3] = engine.isProcessed;
2401
+ $[4] = engine.uiState;
2402
+ $[5] = t4;
2403
+ } else t4 = $[5];
2404
+ const rootRef = useCommand(t4);
2405
+ let t5;
2406
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
2407
+ t5 = () => {
2408
+ const el = anchoredBlockElRef.current;
2409
+ if (el) {
2410
+ clearBlockMenuAnchors(el);
2411
+ anchoredBlockElRef.current = null;
2412
+ }
2413
+ };
2414
+ $[6] = t5;
2415
+ } else t5 = $[6];
2416
+ const clearAnchoredBlock = t5;
2417
+ let t6;
2418
+ if ($[7] !== engine) {
2419
+ t6 = () => {
2420
+ setVisible(false);
2421
+ clearAnchoredBlock();
2422
+ setItemAnchors([]);
2423
+ itemsRef.current = [];
2424
+ engine.clearCurrentBlock();
2425
+ };
2426
+ $[7] = engine;
2427
+ $[8] = t6;
2428
+ } else t6 = $[8];
2429
+ const hide = t6;
2430
+ let t7;
2431
+ if ($[9] !== engine.uiState || $[10] !== hide) {
2432
+ t7 = () => engine.uiState.subscribe(() => {
2433
+ if (engine.uiState.getSnapshot().processing) hide();
2434
+ });
2435
+ $[9] = engine.uiState;
2436
+ $[10] = hide;
2437
+ $[11] = t7;
2438
+ } else t7 = $[11];
2439
+ let t8;
2440
+ if ($[12] !== engine || $[13] !== hide) {
2441
+ t8 = [engine, hide];
2442
+ $[12] = engine;
2443
+ $[13] = hide;
2444
+ $[14] = t8;
2445
+ } else t8 = $[14];
2446
+ useEffect(t7, t8);
2447
+ let t9;
2448
+ if ($[15] !== container.ownerDocument || $[16] !== engine || $[17] !== hide) {
2449
+ t9 = () => {
2450
+ const doc = container.ownerDocument;
2451
+ const body = doc.body;
2452
+ const win = doc.defaultView;
2453
+ const stack = new DisposableStack();
2454
+ const listeners = new AbortController();
2455
+ const { signal } = listeners;
2456
+ let mouseX = 0;
2457
+ let mouseY = 0;
2458
+ let raf = 0;
2459
+ stack.defer(() => cancelAnimationFrame(raf));
2460
+ stack.defer(() => listeners.abort());
2461
+ stack.defer(() => clearAnchoredBlock());
2462
+ const updatePosition = () => {
2463
+ const selected = getBlockAtPosition(doc, mouseX, mouseY);
2464
+ if (!selected) {
2465
+ hide();
2466
+ return;
2467
+ }
2468
+ setVisible(true);
2469
+ const { block, marginBlockEnd } = selected;
2470
+ const blockEl = block.el;
2471
+ if (anchoredBlockElRef.current !== blockEl) {
2472
+ clearAnchoredBlock();
2473
+ anchoredBlockElRef.current = blockEl;
2474
+ }
2475
+ const itemEntries = [...blockEl.querySelectorAll("[data-bgi]")].map(_temp2$1).filter(_temp3);
2476
+ itemsRef.current = itemEntries.map(_temp4);
2477
+ const anchorNames = applyBlockMenuAnchors(blockEl, itemEntries.map(_temp5));
2478
+ setItemAnchors(anchorNames.map(_temp6));
2479
+ setMargin({
2480
+ marginBlockEnd,
2481
+ marginBlockEndValue: win?.getComputedStyle(blockEl).getPropertyValue("--bge-block-margin") ?? "0px"
2482
+ });
2483
+ engine.setCurrentBlock(block);
2484
+ };
2485
+ const scheduleUpdate = () => {
2486
+ if (signal.aborted) return;
2487
+ cancelAnimationFrame(raf);
2488
+ if (engine.isProcessed) {
2489
+ hide();
2490
+ return;
2491
+ }
2492
+ raf = requestAnimationFrame(() => {
2493
+ updatePosition();
2494
+ });
2495
+ };
2496
+ const onMouseMove = (e_0) => {
2497
+ mouseX = e_0.pageX;
2498
+ mouseY = e_0.pageY;
2499
+ scheduleUpdate();
2500
+ };
2501
+ const onHideEvent = () => hide();
2502
+ body.addEventListener("mousemove", onMouseMove, { signal });
2503
+ body.addEventListener("mouseleave", onHideEvent, { signal });
2504
+ doc.addEventListener("mouseleave", onHideEvent, { signal });
2505
+ win?.addEventListener("mouseleave", onHideEvent, { signal });
2506
+ globalThis.addEventListener("resize", onHideEvent, { signal });
2507
+ return () => stack.dispose();
2508
+ };
2509
+ $[15] = container.ownerDocument;
2510
+ $[16] = engine;
2511
+ $[17] = hide;
2512
+ $[18] = t9;
2513
+ } else t9 = $[18];
2514
+ let t10;
2515
+ if ($[19] !== container || $[20] !== engine || $[21] !== hide) {
2516
+ t10 = [
2517
+ engine,
2518
+ container,
2519
+ hide,
2520
+ clearAnchoredBlock
2521
+ ];
2522
+ $[19] = container;
2523
+ $[20] = engine;
2524
+ $[21] = hide;
2525
+ $[22] = t10;
2526
+ } else t10 = $[22];
2527
+ useEffect(t9, t10);
2528
+ let t11;
2529
+ if ($[23] !== currentBlock) {
2530
+ t11 = currentBlock?.isMutable() ?? false;
2531
+ $[23] = currentBlock;
2532
+ $[24] = t11;
2533
+ } else t11 = $[24];
2534
+ const isMutable = t11;
2535
+ let t12;
2536
+ if ($[25] !== engine.commandBus.receiverId || $[26] !== isMutable || $[27] !== itemAnchors || $[28] !== margin || $[29] !== menuId || $[30] !== rootRef || $[31] !== visible) {
2537
+ t12 = /* @__PURE__ */ jsx(BlockMenuView, {
2538
+ rootRef,
2539
+ menuId,
2540
+ commandBusId: engine.commandBus.receiverId,
2541
+ visible,
2542
+ margin,
2543
+ itemAnchors,
2544
+ isMutable
2545
+ });
2546
+ $[25] = engine.commandBus.receiverId;
2547
+ $[26] = isMutable;
2548
+ $[27] = itemAnchors;
2549
+ $[28] = margin;
2550
+ $[29] = menuId;
2551
+ $[30] = rootRef;
2552
+ $[31] = visible;
2553
+ $[32] = t12;
2554
+ } else t12 = $[32];
2555
+ return t12;
2556
+ }
2557
+ function _temp6(anchorName) {
2558
+ return { anchorName };
2559
+ }
2560
+ function _temp5(entry_1) {
2561
+ return entry_1.el;
2562
+ }
2563
+ function _temp4(entry_0) {
2564
+ return entry_0.item;
2565
+ }
2566
+ function _temp3(entry) {
2567
+ return entry.item != null;
2568
+ }
2569
+ function _temp2$1(itemEl) {
2570
+ return {
2571
+ el: itemEl,
2572
+ item: Item.getInstance(itemEl)
2573
+ };
2574
+ }
2575
+ function _temp$1(s) {
2576
+ return s.currentBlock;
2577
+ }
2578
+ // src/components/initial-insertion-button.tsx
2579
+ /**
2580
+ * Button shown in an empty editable area to insert the first block.
2581
+ * Declares the engine command instead of taking a callback.
2582
+ * @param root0
2583
+ * @param root0.commandBusId
2584
+ * @example
2585
+ * ```tsx
2586
+ * reactMount(<InitialInsertionButton commandBusId={engine.commandBus.receiverId} />, container);
2587
+ * ```
2588
+ */
2589
+ function InitialInsertionButton(t0) {
2590
+ const $ = c(2);
2591
+ const { commandBusId } = t0;
2592
+ let t1;
2593
+ if ($[0] !== commandBusId) {
2594
+ t1 = /* @__PURE__ */ jsx("button", {
2595
+ className: "insert_after",
2596
+ type: "button",
2597
+ command: BGE_COMMAND.insertInitialBlock,
2598
+ commandfor: commandBusId,
2599
+ children: "下に要素を追加"
2600
+ });
2601
+ $[0] = commandBusId;
2602
+ $[1] = t1;
2603
+ } else t1 = $[1];
2604
+ return t1;
2605
+ }
2606
+ // src/components/editable-area-view.tsx
2607
+ var CONTAINER_PADDING = 10;
2608
+ var CONTENT_ID = "bge-editable-area";
2609
+ /**
2610
+ * The React shell of one editable area: the iframe hosting the edited
2611
+ * content, the HTML source textarea, and the in-frame UI islands
2612
+ * (block menu, initial insertion button) rendered through a portal.
2613
+ *
2614
+ * All presentation state is React state derived from `engine.uiState`
2615
+ * and engine events — the engine never touches this component's DOM.
2616
+ * The iframe is rendered unconditionally at a fixed position in the
2617
+ * tree (visibility is `hidden` only) because unmounting an iframe
2618
+ * destroys its document, and the engine owns the content inside it.
2619
+ * Reads the engine via {@link useEngine}, wired up by the view that
2620
+ * portals this component in (`createReactView`).
2621
+ * @param root0
2622
+ * @param root0.type
2623
+ * @param root0.initialContent
2624
+ * @param root0.stylesheets
2625
+ * @param root0.classList
2626
+ * @param root0.onReady
2627
+ * @example
2628
+ * ```tsx
2629
+ * <EditableAreaView
2630
+ * type="main"
2631
+ * initialContent={html}
2632
+ * stylesheets={stylesheets}
2633
+ * classList={classList}
2634
+ * onReady={(host) => resolve(host)}
2635
+ * />
2636
+ * ```
2637
+ */
2638
+ function EditableAreaView(t0) {
2639
+ const $ = c(61);
2640
+ const { type, initialContent, stylesheets, classList, onReady } = t0;
2641
+ const engine = useEngine();
2642
+ let t1;
2643
+ if ($[0] !== type) {
2644
+ t1 = (s) => s.sourceMode[type];
2645
+ $[0] = type;
2646
+ $[1] = t1;
2647
+ } else t1 = $[1];
2648
+ const sourceMode = useUIState(t1);
2649
+ const processing = useUIState(_temp);
2650
+ const dialogOpen = useUIState(_temp2);
2651
+ let t2;
2652
+ if ($[2] !== type) {
2653
+ t2 = (s_2) => s_2.activeArea === type;
2654
+ $[2] = type;
2655
+ $[3] = t2;
2656
+ } else t2 = $[3];
2657
+ const active = useUIState(t2);
2658
+ const [sourceText, setSourceText] = useState(initialContent);
2659
+ let t3;
2660
+ if ($[4] !== initialContent) {
2661
+ t3 = initialContent.trim();
2662
+ $[4] = initialContent;
2663
+ $[5] = t3;
2664
+ } else t3 = $[5];
2665
+ const [isEmpty, setIsEmpty] = useState(t3 === "");
2666
+ const [height, setHeight] = useState(0);
2667
+ const [containerElement, setContainerElement] = useState(null);
2668
+ const frameBody = containerElement?.ownerDocument.body ?? null;
2669
+ const initializedRef = useRef(false);
2670
+ let t4;
2671
+ if ($[6] !== classList || $[7] !== engine.commandBus || $[8] !== onReady || $[9] !== stylesheets) {
2672
+ t4 = (iframe) => {
2673
+ if (!iframe || initializedRef.current) return;
2674
+ initializedRef.current = true;
2675
+ const frameWindow = iframe.contentWindow;
2676
+ if (!frameWindow) throw new Error("Impossible error: The contentWindow of created iframe is null.");
2677
+ const frameDoc = frameWindow.document;
2678
+ frameDoc.open();
2679
+ frameDoc.write("<!doctype html><html><head></head><body></body></html>");
2680
+ frameDoc.close();
2681
+ for (const { path, id } of stylesheets) appendStylesheetTo(frameDoc, path, id);
2682
+ const injectedUiStyle = frameDoc.createElement("style");
2683
+ injectedUiStyle.textContent = `@layer ${CSS_LAYER.ui} {
2684
+ [data-bge-component='block-menu'] {
2685
+ position: static;
2686
+ z-index: 2147483647;
2687
+ pointer-events: none;
2688
+ }
2689
+
2690
+ /* #0c7e9e はui.cssの--bge-ui-primary-colorと同じ値。iframe文書には
2691
+ その:root変数定義が読み込まれない(このstyleタグがそもそも
2692
+ その代替)ため、ここではvar()参照できずハードコードしている。
2693
+ 将来テーマカラーを変更する際はこの値も揃えて更新すること */
2694
+ @keyframes bge-highlight-blink {
2695
+ 0%, 100% {
2696
+ outline-color: transparent;
2697
+ background-color: transparent;
2698
+ }
2699
+ 50% {
2700
+ outline-color: #0c7e9e;
2701
+ background-color: rgb(12 126 158 / 12%);
2702
+ }
2703
+ }
2704
+
2705
+ [data-bge-highlight] {
2706
+ outline: 3px solid transparent;
2707
+ outline-offset: 2px;
2708
+ animation: bge-highlight-blink 0.5s ease-in-out 2;
2709
+ }
2710
+ }
2711
+
2712
+ ${BLOCK_SWAP_VIEW_TRANSITION_CSS}`;
2713
+ frameDoc.head.append(injectedUiStyle);
2714
+ frameDoc.body.setAttribute("style", "margin: 0; border: 0;");
2715
+ engine.commandBus.createReceiver(frameDoc.body);
2716
+ const content = frameDoc.createElement("div");
2717
+ content.id = CONTENT_ID;
2718
+ content.style.setProperty("padding", `${CONTAINER_PADDING}px`, "important");
2719
+ content.style.setProperty("overflow", "hidden", "important");
2720
+ content.style.setProperty("margin", "0", "important");
2721
+ content.style.setProperty("box-sizing", "border-box", "important");
2722
+ content.classList.add(...classList);
2723
+ content.dataset.bgeComponent = "editable-area";
2724
+ frameDoc.body.append(content);
2725
+ setContainerElement(content);
2726
+ onReady({
2727
+ containerElement: content,
2728
+ animateInsertion
2729
+ });
2730
+ };
2731
+ $[6] = classList;
2732
+ $[7] = engine.commandBus;
2733
+ $[8] = onReady;
2734
+ $[9] = stylesheets;
2735
+ $[10] = t4;
2736
+ } else t4 = $[10];
2737
+ const initFrame = t4;
2738
+ let t5;
2739
+ let t6;
2740
+ if ($[11] !== containerElement) {
2741
+ t5 = () => {
2742
+ if (!containerElement || typeof ResizeObserver === "undefined") return;
2743
+ const stack = new DisposableStack();
2744
+ let raf = 0;
2745
+ stack.defer(() => cancelAnimationFrame(raf));
2746
+ const observer = new ResizeObserver(() => {
2747
+ cancelAnimationFrame(raf);
2748
+ raf = requestAnimationFrame(() => {
2749
+ setHeight(containerElement.getBoundingClientRect().height + 20);
2750
+ });
2751
+ });
2752
+ observer.observe(containerElement);
2753
+ stack.defer(() => observer.disconnect());
2754
+ return () => stack.dispose();
2755
+ };
2756
+ t6 = [containerElement];
2757
+ $[11] = containerElement;
2758
+ $[12] = t5;
2759
+ $[13] = t6;
2760
+ } else {
2761
+ t5 = $[12];
2762
+ t6 = $[13];
2763
+ }
2764
+ useEffect(t5, t6);
2765
+ let t7;
2766
+ if ($[14] !== engine.el || $[15] !== type) {
2767
+ t7 = () => {
2768
+ const onSaved = (e) => {
2769
+ const value = type === "main" ? e.detail.main : e.detail.draft ?? "";
2770
+ setSourceText(value);
2771
+ setIsEmpty(value.trim() === "");
2772
+ };
2773
+ engine.el.addEventListener("bge:saved", onSaved);
2774
+ return () => {
2775
+ engine.el.removeEventListener("bge:saved", onSaved);
2776
+ };
2777
+ };
2778
+ $[14] = engine.el;
2779
+ $[15] = type;
2780
+ $[16] = t7;
2781
+ } else t7 = $[16];
2782
+ let t8;
2783
+ if ($[17] !== engine || $[18] !== type) {
2784
+ t8 = [engine, type];
2785
+ $[17] = engine;
2786
+ $[18] = type;
2787
+ $[19] = t8;
2788
+ } else t8 = $[19];
2789
+ useEffect(t7, t8);
2790
+ let t9;
2791
+ if ($[20] !== sourceText) {
2792
+ t9 = () => sourceText;
2793
+ $[20] = sourceText;
2794
+ $[21] = t9;
2795
+ } else t9 = $[21];
2796
+ const getPendingSourceText = useEffectEvent(t9);
2797
+ let t10;
2798
+ if ($[22] !== engine || $[23] !== type) {
2799
+ t10 = (value_0) => {
2800
+ engine.commitSourceEdit(type, value_0).then(() => {
2801
+ const committed = engine.getEditableContent(type)?.getContentsAsString() ?? "";
2802
+ setSourceText(committed);
2803
+ setIsEmpty(committed.trim() === "");
2804
+ });
2805
+ };
2806
+ $[22] = engine;
2807
+ $[23] = type;
2808
+ $[24] = t10;
2809
+ } else t10 = $[24];
2810
+ const commitSource = t10;
2811
+ const [prevSourceMode, setPrevSourceMode] = useState(sourceMode);
2812
+ if (sourceMode !== prevSourceMode) {
2813
+ setPrevSourceMode(sourceMode);
2814
+ if (sourceMode) {
2815
+ const value_1 = engine.getEditableContent(type)?.getContentsAsString() ?? "";
2816
+ setSourceText(value_1);
2817
+ setIsEmpty(value_1.trim() === "");
2818
+ }
2819
+ }
2820
+ const wasSourceModeRef = useRef(sourceMode);
2821
+ let t11;
2822
+ if ($[25] !== engine || $[26] !== getPendingSourceText || $[27] !== sourceMode || $[28] !== type) {
2823
+ t11 = () => {
2824
+ const wasSourceMode = wasSourceModeRef.current;
2825
+ wasSourceModeRef.current = sourceMode;
2826
+ if (!wasSourceMode || sourceMode) return;
2827
+ let cancelled = false;
2828
+ engine.commitSourceEdit(type, getPendingSourceText()).then(() => {
2829
+ if (cancelled) return;
2830
+ const value_2 = engine.getEditableContent(type)?.getContentsAsString() ?? "";
2831
+ setSourceText(value_2);
2832
+ setIsEmpty(value_2.trim() === "");
2833
+ });
2834
+ return () => {
2835
+ cancelled = true;
2836
+ };
2837
+ };
2838
+ $[25] = engine;
2839
+ $[26] = getPendingSourceText;
2840
+ $[27] = sourceMode;
2841
+ $[28] = type;
2842
+ $[29] = t11;
2843
+ } else t11 = $[29];
2844
+ let t12;
2845
+ if ($[30] !== engine || $[31] !== sourceMode || $[32] !== type) {
2846
+ t12 = [
2847
+ engine,
2848
+ type,
2849
+ sourceMode
2850
+ ];
2851
+ $[30] = engine;
2852
+ $[31] = sourceMode;
2853
+ $[32] = type;
2854
+ $[33] = t12;
2855
+ } else t12 = $[33];
2856
+ useEffect(t11, t12);
2857
+ const t13 = `${type}-editable-area`;
2858
+ const t14 = sourceMode ? "source" : "visual";
2859
+ const t15 = !active;
2860
+ const t16 = !sourceMode;
2861
+ const t17 = !sourceMode;
2862
+ let t18;
2863
+ if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
2864
+ t18 = (e_0) => setSourceText(e_0.currentTarget.value);
2865
+ $[34] = t18;
2866
+ } else t18 = $[34];
2867
+ let t19;
2868
+ if ($[35] !== commitSource) {
2869
+ t19 = (e_1) => commitSource(e_1.currentTarget.value);
2870
+ $[35] = commitSource;
2871
+ $[36] = t19;
2872
+ } else t19 = $[36];
2873
+ let t20;
2874
+ if ($[37] !== sourceText || $[38] !== t16 || $[39] !== t17 || $[40] !== t19) {
2875
+ t20 = /* @__PURE__ */ jsx("textarea", {
2876
+ "aria-label": "HTMLソース",
2877
+ spellCheck: false,
2878
+ hidden: t16,
2879
+ disabled: t17,
2880
+ value: sourceText,
2881
+ onChange: t18,
2882
+ onBlur: t19
2883
+ });
2884
+ $[37] = sourceText;
2885
+ $[38] = t16;
2886
+ $[39] = t17;
2887
+ $[40] = t19;
2888
+ $[41] = t20;
2889
+ } else t20 = $[41];
2890
+ const t21 = type === "main" ? "本稿の編集エリア" : "下書きの編集エリア";
2891
+ let t22;
2892
+ if ($[42] === Symbol.for("react.memo_cache_sentinel")) {
2893
+ t22 = {
2894
+ inlineSize: "100%",
2895
+ overflow: "hidden"
2896
+ };
2897
+ $[42] = t22;
2898
+ } else t22 = $[42];
2899
+ let t23;
2900
+ if ($[43] !== height || $[44] !== initFrame || $[45] !== sourceMode || $[46] !== t21) {
2901
+ t23 = /* @__PURE__ */ jsx("iframe", {
2902
+ title: t21,
2903
+ loading: "lazy",
2904
+ style: t22,
2905
+ height,
2906
+ hidden: sourceMode,
2907
+ ref: initFrame
2908
+ });
2909
+ $[43] = height;
2910
+ $[44] = initFrame;
2911
+ $[45] = sourceMode;
2912
+ $[46] = t21;
2913
+ $[47] = t23;
2914
+ } else t23 = $[47];
2915
+ let t24;
2916
+ if ($[48] !== dialogOpen || $[49] !== engine.commandBus || $[50] !== frameBody || $[51] !== isEmpty || $[52] !== processing) {
2917
+ t24 = frameBody ? createPortal(/* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
2918
+ "data-bge-component": "block-menu",
2919
+ children: /* @__PURE__ */ jsx(BlockMenu, { container: frameBody })
2920
+ }), /* @__PURE__ */ jsx("div", {
2921
+ "data-bge-component": "initial-insertion",
2922
+ hidden: !(isEmpty && !processing && !dialogOpen),
2923
+ children: /* @__PURE__ */ jsx(InitialInsertionButton, { commandBusId: engine.commandBus.receiverId })
2924
+ })] }), frameBody) : null;
2925
+ $[48] = dialogOpen;
2926
+ $[49] = engine.commandBus;
2927
+ $[50] = frameBody;
2928
+ $[51] = isEmpty;
2929
+ $[52] = processing;
2930
+ $[53] = t24;
2931
+ } else t24 = $[53];
2932
+ let t25;
2933
+ if ($[54] !== t13 || $[55] !== t14 || $[56] !== t15 || $[57] !== t20 || $[58] !== t23 || $[59] !== t24) {
2934
+ t25 = /* @__PURE__ */ jsxs("div", {
2935
+ "data-bge-component": t13,
2936
+ "data-bge-component-mode": t14,
2937
+ hidden: t15,
2938
+ children: [
2939
+ t20,
2940
+ t23,
2941
+ t24
2942
+ ]
2943
+ });
2944
+ $[54] = t13;
2945
+ $[55] = t14;
2946
+ $[56] = t15;
2947
+ $[57] = t20;
2948
+ $[58] = t23;
2949
+ $[59] = t24;
2950
+ $[60] = t25;
2951
+ } else t25 = $[60];
2952
+ return t25;
2953
+ }
2954
+ function _temp2(s_1) {
2955
+ return s_1.openDialog !== null;
2956
+ }
2957
+ function _temp(s_0) {
2958
+ return s_0.processing;
2959
+ }
2960
+ export { BlockCatalog as _, BlockMenuButton as a, createReactComponent as b, RootErrorBoundary as c, DraftSwitcher as d, registerEngineCommands as f, BlockOptions as g, EditorDialog as h, BlockMenuView as i, reportRenderError as l, ItemEditorHost as m, InitialInsertionButton as n, BGE_BLOCK_MENU_BLOCK_ANCHOR as o, useUIState as p, BlockMenu as r, useCommand as s, EditableAreaView as t, reactMount as u, IconTrash as v, IconRowInsertBottom as y };
2961
+
2962
+ //# sourceMappingURL=editable-area-view-DhEipEQV.js.map