@measured/puck 0.21.0-canary.eb8ea5ce → 0.21.0-canary.ece26d91

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 (46) hide show
  1. package/dist/{Editor-DR57V55X.mjs → Editor-O447AVCX.mjs} +17 -7
  2. package/dist/{Render-6Q5WP25Y.mjs → Render-OFE6QLI2.mjs} +8 -4
  3. package/dist/{walk-tree-Ja9bNCM9.d.mts → actions-ONhOkrvf.d.mts} +1 -27
  4. package/dist/{walk-tree-Ja9bNCM9.d.ts → actions-ONhOkrvf.d.ts} +1 -27
  5. package/dist/chunk-2Q4PACDA.mjs +111 -0
  6. package/dist/chunk-62AAYNXG.mjs +63 -0
  7. package/dist/chunk-BSDEIOEK.mjs +706 -0
  8. package/dist/chunk-CSSRLPHM.mjs +11 -0
  9. package/dist/{chunk-OPXWLTPM.mjs → chunk-DAQLMM2T.mjs} +1377 -2795
  10. package/dist/chunk-M6W7YEVX.mjs +95 -0
  11. package/dist/{chunk-YZQENDBP.mjs → chunk-NLUHDYVR.mjs} +2 -123
  12. package/dist/chunk-PLXSMBAA.mjs +53 -0
  13. package/dist/chunk-QAWJTCV5.mjs +33 -0
  14. package/dist/chunk-QBGM4ELA.mjs +528 -0
  15. package/dist/{chunk-MSIUWPEI.mjs → chunk-QBJ2LDJB.mjs} +36 -20
  16. package/dist/chunk-T3WX7XJ6.mjs +132 -0
  17. package/dist/{chunk-CF5XA6LF.mjs → chunk-V5I7CVLT.mjs} +1 -1
  18. package/dist/chunk-Y2EFNT5P.mjs +108 -0
  19. package/dist/{chunk-A7EMVTSK.mjs → chunk-Y656T6AQ.mjs} +13 -7
  20. package/dist/full-2GJTAAZE.css +301 -0
  21. package/dist/full-BEMDJKDS.mjs +93 -0
  22. package/dist/index-BEoNHRI1.d.ts +116 -0
  23. package/dist/index-DfxZ7tZF.d.mts +116 -0
  24. package/dist/index.d.mts +9 -125
  25. package/dist/index.d.ts +9 -125
  26. package/dist/index.js +1002 -775
  27. package/dist/index.mjs +14 -5
  28. package/dist/internal.d.mts +27 -0
  29. package/dist/internal.d.ts +27 -0
  30. package/dist/internal.js +908 -0
  31. package/dist/internal.mjs +13 -0
  32. package/dist/loaded-JU3A7Y4L.mjs +57 -0
  33. package/dist/loaded-N3FYGF2Y.mjs +57 -0
  34. package/dist/loaded-OBY7OMS6.mjs +60 -0
  35. package/dist/loaded-RVWBFK7L.css +87 -0
  36. package/dist/no-external.d.mts +3 -1
  37. package/dist/no-external.d.ts +3 -1
  38. package/dist/no-external.js +1002 -775
  39. package/dist/no-external.mjs +14 -5
  40. package/dist/rsc.d.mts +2 -2
  41. package/dist/rsc.d.ts +2 -2
  42. package/dist/rsc.mjs +6 -3
  43. package/dist/walk-tree-CdriEzFJ.d.mts +29 -0
  44. package/dist/walk-tree-DHbAZ4wF.d.ts +29 -0
  45. package/package.json +7 -2
  46. package/dist/chunk-GQ457KMA.mjs +0 -199
@@ -1,2298 +1,1509 @@
1
+ import {
2
+ createReducer,
3
+ generateId,
4
+ getItem,
5
+ makeStatePublic
6
+ } from "./chunk-QBGM4ELA.mjs";
1
7
  import {
2
8
  defaultAppState,
3
9
  defaultViewports,
4
10
  getChanged,
5
- resolveComponentData,
6
- rootDroppableId,
7
- setupZone,
8
- walkAppState,
9
- walkTree
10
- } from "./chunk-YZQENDBP.mjs";
11
+ resolveComponentData
12
+ } from "./chunk-T3WX7XJ6.mjs";
13
+ import {
14
+ get_class_name_factory_default
15
+ } from "./chunk-Y2EFNT5P.mjs";
16
+ import {
17
+ walkAppState
18
+ } from "./chunk-NLUHDYVR.mjs";
11
19
  import {
12
20
  __async,
13
21
  __objRest,
14
22
  __spreadProps,
15
23
  __spreadValues,
16
- get_class_name_factory_default,
17
- init_react_import,
18
- styles_module_default
19
- } from "./chunk-GQ457KMA.mjs";
24
+ init_react_import
25
+ } from "./chunk-M6W7YEVX.mjs";
20
26
 
21
- // components/ActionBar/index.tsx
27
+ // ../../node_modules/lucide-react/dist/esm/icons/align-left.js
22
28
  init_react_import();
23
29
 
24
- // css-module:/home/runner/work/puck/puck/packages/core/components/ActionBar/styles.module.css#css-module
30
+ // ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
25
31
  init_react_import();
26
- var styles_module_default2 = { "ActionBar": "_ActionBar_1nmyk_1", "ActionBar-label": "_ActionBar-label_1nmyk_18", "ActionBarAction": "_ActionBarAction_1nmyk_30", "ActionBar-group": "_ActionBar-group_1nmyk_38", "ActionBarAction--disabled": "_ActionBarAction--disabled_1nmyk_71", "ActionBarAction--active": "_ActionBarAction--active_1nmyk_93", "ActionBar-separator": "_ActionBar-separator_1nmyk_102" };
27
-
28
- // components/ActionBar/index.tsx
29
- import { jsx, jsxs } from "react/jsx-runtime";
30
- var getClassName = get_class_name_factory_default("ActionBar", styles_module_default2);
31
- var getActionClassName = get_class_name_factory_default("ActionBarAction", styles_module_default2);
32
- var ActionBar = ({
33
- label,
34
- children
35
- }) => /* @__PURE__ */ jsxs(
36
- "div",
37
- {
38
- className: getClassName(),
39
- onClick: (e) => {
40
- e.stopPropagation();
41
- },
42
- children: [
43
- label && /* @__PURE__ */ jsx(ActionBar.Group, { children: /* @__PURE__ */ jsx("div", { className: getClassName("label"), children: label }) }),
44
- children
45
- ]
46
- }
47
- );
48
- var Action = ({
49
- children,
50
- label,
51
- onClick,
52
- active = false,
53
- disabled
54
- }) => /* @__PURE__ */ jsx(
55
- "button",
56
- {
57
- type: "button",
58
- className: getActionClassName({ active, disabled }),
59
- onClick,
60
- title: label,
61
- tabIndex: 0,
62
- disabled,
63
- children
64
- }
65
- );
66
- var Group = ({ children }) => /* @__PURE__ */ jsx("div", { className: getClassName("group"), children });
67
- var Label = ({ label }) => /* @__PURE__ */ jsx("div", { className: getClassName("label"), children: label });
68
- var Separator = () => /* @__PURE__ */ jsx("div", { className: getClassName("separator") });
69
- ActionBar.Action = Action;
70
- ActionBar.Label = Label;
71
- ActionBar.Group = Group;
72
- ActionBar.Separator = Separator;
32
+ import { forwardRef as forwardRef2, createElement as createElement2 } from "react";
73
33
 
74
- // store/index.ts
34
+ // ../../node_modules/lucide-react/dist/esm/shared/src/utils.js
75
35
  init_react_import();
36
+ var toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
37
+ var mergeClasses = (...classes) => classes.filter((className, index, array) => {
38
+ return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
39
+ }).join(" ").trim();
76
40
 
77
- // reducer/index.ts
41
+ // ../../node_modules/lucide-react/dist/esm/Icon.js
78
42
  init_react_import();
43
+ import { forwardRef, createElement } from "react";
79
44
 
80
- // reducer/actions/set.ts
45
+ // ../../node_modules/lucide-react/dist/esm/defaultAttributes.js
81
46
  init_react_import();
82
- var setAction = (state, action, appStore) => {
83
- if (typeof action.state === "object") {
84
- const newState = __spreadValues(__spreadValues({}, state), action.state);
85
- if (action.state.indexes) {
86
- return newState;
87
- }
88
- console.warn(
89
- "`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
47
+ var defaultAttributes = {
48
+ xmlns: "http://www.w3.org/2000/svg",
49
+ width: 24,
50
+ height: 24,
51
+ viewBox: "0 0 24 24",
52
+ fill: "none",
53
+ stroke: "currentColor",
54
+ strokeWidth: 2,
55
+ strokeLinecap: "round",
56
+ strokeLinejoin: "round"
57
+ };
58
+
59
+ // ../../node_modules/lucide-react/dist/esm/Icon.js
60
+ var Icon = forwardRef(
61
+ (_a, ref) => {
62
+ var _b = _a, {
63
+ color = "currentColor",
64
+ size = 24,
65
+ strokeWidth = 2,
66
+ absoluteStrokeWidth,
67
+ className = "",
68
+ children,
69
+ iconNode
70
+ } = _b, rest = __objRest(_b, [
71
+ "color",
72
+ "size",
73
+ "strokeWidth",
74
+ "absoluteStrokeWidth",
75
+ "className",
76
+ "children",
77
+ "iconNode"
78
+ ]);
79
+ return createElement(
80
+ "svg",
81
+ __spreadValues(__spreadProps(__spreadValues({
82
+ ref
83
+ }, defaultAttributes), {
84
+ width: size,
85
+ height: size,
86
+ stroke: color,
87
+ strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
88
+ className: mergeClasses("lucide", className)
89
+ }), rest),
90
+ [
91
+ ...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),
92
+ ...Array.isArray(children) ? children : [children]
93
+ ]
90
94
  );
91
- return walkAppState(newState, appStore.config);
92
95
  }
93
- return __spreadValues(__spreadValues({}, state), action.state(state));
96
+ );
97
+
98
+ // ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
99
+ var createLucideIcon = (iconName, iconNode) => {
100
+ const Component = forwardRef2(
101
+ (_a, ref) => {
102
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
103
+ return createElement2(Icon, __spreadValues({
104
+ ref,
105
+ iconNode,
106
+ className: mergeClasses(`lucide-${toKebabCase(iconName)}`, className)
107
+ }, props));
108
+ }
109
+ );
110
+ Component.displayName = `${iconName}`;
111
+ return Component;
94
112
  };
95
113
 
96
- // reducer/actions/insert.ts
97
- init_react_import();
114
+ // ../../node_modules/lucide-react/dist/esm/icons/align-left.js
115
+ var AlignLeft = createLucideIcon("AlignLeft", [
116
+ ["path", { d: "M15 12H3", key: "6jk70r" }],
117
+ ["path", { d: "M17 18H3", key: "1amg6g" }],
118
+ ["path", { d: "M21 6H3", key: "1jwq7v" }]
119
+ ]);
98
120
 
99
- // lib/data/insert.ts
121
+ // ../../node_modules/lucide-react/dist/esm/icons/heading.js
100
122
  init_react_import();
101
- var insert = (list, index, item) => {
102
- const result = Array.from(list || []);
103
- result.splice(index, 0, item);
104
- return result;
105
- };
123
+ var Heading = createLucideIcon("Heading", [
124
+ ["path", { d: "M6 12h12", key: "8npq4p" }],
125
+ ["path", { d: "M6 20V4", key: "1w1bmo" }],
126
+ ["path", { d: "M18 20V4", key: "o2hl4u" }]
127
+ ]);
106
128
 
107
- // lib/generate-id.ts
129
+ // ../../node_modules/lucide-react/dist/esm/icons/list.js
108
130
  init_react_import();
109
- import { v4 as uuidv4 } from "uuid";
110
- var generateId = (type) => type ? `${type}-${uuidv4()}` : uuidv4();
131
+ var List = createLucideIcon("List", [
132
+ ["path", { d: "M3 12h.01", key: "nlz23k" }],
133
+ ["path", { d: "M3 18h.01", key: "1tta3j" }],
134
+ ["path", { d: "M3 6h.01", key: "1rqtza" }],
135
+ ["path", { d: "M8 12h13", key: "1za7za" }],
136
+ ["path", { d: "M8 18h13", key: "1lx6n3" }],
137
+ ["path", { d: "M8 6h13", key: "ik3vkj" }]
138
+ ]);
111
139
 
112
- // lib/data/get-ids-for-parent.ts
140
+ // ../../node_modules/lucide-react/dist/esm/lucide-react.js
113
141
  init_react_import();
114
- var getIdsForParent = (zoneCompound, state) => {
115
- const [parentId] = zoneCompound.split(":");
116
- const node = state.indexes.nodes[parentId];
117
- return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
118
- };
119
142
 
120
- // lib/data/populate-ids.ts
143
+ // ../../node_modules/lucide-react/dist/esm/icons/align-center.js
121
144
  init_react_import();
122
- var populateIds = (data, config, override = false) => {
123
- const id = generateId(data.type);
124
- return walkTree(
125
- __spreadProps(__spreadValues({}, data), {
126
- props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({}, data.props)
127
- }),
128
- config,
129
- (contents) => contents.map((item) => {
130
- const id2 = generateId(item.type);
131
- return __spreadProps(__spreadValues({}, item), {
132
- props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
133
- });
134
- })
135
- );
136
- };
137
-
138
- // reducer/actions/insert.ts
139
- function insertAction(state, action, appStore) {
140
- const id = action.id || generateId(action.componentType);
141
- const emptyComponentData = populateIds(
142
- {
143
- type: action.componentType,
144
- props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
145
- id
146
- })
147
- },
148
- appStore.config
149
- );
150
- const [parentId] = action.destinationZone.split(":");
151
- const idsInPath = getIdsForParent(action.destinationZone, state);
152
- return walkAppState(
153
- state,
154
- appStore.config,
155
- (content, zoneCompound) => {
156
- if (zoneCompound === action.destinationZone) {
157
- return insert(
158
- content || [],
159
- action.destinationIndex,
160
- emptyComponentData
161
- );
162
- }
163
- return content;
164
- },
165
- (childItem, path) => {
166
- if (childItem.props.id === id || childItem.props.id === parentId) {
167
- return childItem;
168
- } else if (idsInPath.includes(childItem.props.id)) {
169
- return childItem;
170
- } else if (path.includes(action.destinationZone)) {
171
- return childItem;
172
- }
173
- return null;
174
- }
175
- );
176
- }
145
+ var AlignCenter = createLucideIcon("AlignCenter", [
146
+ ["path", { d: "M17 12H7", key: "16if0g" }],
147
+ ["path", { d: "M19 18H5", key: "18s9l3" }],
148
+ ["path", { d: "M21 6H3", key: "1jwq7v" }]
149
+ ]);
177
150
 
178
- // reducer/actions/replace.ts
151
+ // ../../node_modules/lucide-react/dist/esm/icons/align-justify.js
179
152
  init_react_import();
180
- var replaceAction = (state, action, appStore) => {
181
- const [parentId] = action.destinationZone.split(":");
182
- const idsInPath = getIdsForParent(action.destinationZone, state);
183
- const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
184
- const idChanged = originalId !== action.data.props.id;
185
- if (idChanged) {
186
- throw new Error(
187
- `Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
188
- );
189
- }
190
- const newSlotIds = [];
191
- const data = walkTree(action.data, appStore.config, (contents, opts) => {
192
- newSlotIds.push(`${opts.parentId}:${opts.propName}`);
193
- return contents.map((item) => {
194
- const id = generateId(item.type);
195
- return __spreadProps(__spreadValues({}, item), {
196
- props: __spreadValues({ id }, item.props)
197
- });
198
- });
199
- });
200
- const stateWithDeepSlotsRemoved = __spreadProps(__spreadValues({}, state), {
201
- ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
202
- });
203
- Object.keys(state.indexes.zones).forEach((zoneCompound) => {
204
- const id = zoneCompound.split(":")[0];
205
- if (id === originalId) {
206
- if (!newSlotIds.includes(zoneCompound)) {
207
- delete stateWithDeepSlotsRemoved.indexes.zones[zoneCompound];
208
- }
209
- }
210
- });
211
- return walkAppState(
212
- stateWithDeepSlotsRemoved,
213
- appStore.config,
214
- (content, zoneCompound) => {
215
- const newContent = [...content];
216
- if (zoneCompound === action.destinationZone) {
217
- newContent[action.destinationIndex] = data;
218
- }
219
- return newContent;
220
- },
221
- (childItem, path) => {
222
- const pathIds = path.map((p) => p.split(":")[0]);
223
- if (childItem.props.id === data.props.id) {
224
- return data;
225
- } else if (childItem.props.id === parentId) {
226
- return childItem;
227
- } else if (idsInPath.indexOf(childItem.props.id) > -1) {
228
- return childItem;
229
- } else if (pathIds.indexOf(data.props.id) > -1) {
230
- return childItem;
231
- }
232
- return null;
233
- }
234
- );
235
- };
153
+ var AlignJustify = createLucideIcon("AlignJustify", [
154
+ ["path", { d: "M3 12h18", key: "1i2n21" }],
155
+ ["path", { d: "M3 18h18", key: "1h113x" }],
156
+ ["path", { d: "M3 6h18", key: "d0wm0j" }]
157
+ ]);
236
158
 
237
- // reducer/actions/replace-root.ts
159
+ // ../../node_modules/lucide-react/dist/esm/icons/align-right.js
238
160
  init_react_import();
239
- var replaceRootAction = (state, action, appStore) => {
240
- return walkAppState(
241
- state,
242
- appStore.config,
243
- (content) => content,
244
- (childItem) => {
245
- if (childItem.props.id === "root") {
246
- return __spreadProps(__spreadValues({}, childItem), {
247
- props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
248
- readOnly: action.root.readOnly
249
- });
250
- }
251
- return childItem;
252
- }
253
- );
254
- };
161
+ var AlignRight = createLucideIcon("AlignRight", [
162
+ ["path", { d: "M21 12H9", key: "dn1m92" }],
163
+ ["path", { d: "M21 18H7", key: "1ygte8" }],
164
+ ["path", { d: "M21 6H3", key: "1jwq7v" }]
165
+ ]);
255
166
 
256
- // reducer/actions/duplicate.ts
167
+ // ../../node_modules/lucide-react/dist/esm/icons/bold.js
257
168
  init_react_import();
169
+ var Bold = createLucideIcon("Bold", [
170
+ [
171
+ "path",
172
+ { d: "M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8", key: "mg9rjx" }
173
+ ]
174
+ ]);
258
175
 
259
- // lib/data/get-item.ts
176
+ // ../../node_modules/lucide-react/dist/esm/icons/chevron-down.js
260
177
  init_react_import();
261
- function getItem(selector, state) {
262
- var _a, _b;
263
- const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
264
- return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
265
- }
178
+ var ChevronDown = createLucideIcon("ChevronDown", [
179
+ ["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]
180
+ ]);
266
181
 
267
- // reducer/actions/duplicate.ts
268
- function duplicateAction(state, action, appStore) {
269
- const item = getItem(
270
- { index: action.sourceIndex, zone: action.sourceZone },
271
- state
272
- );
273
- const idsInPath = getIdsForParent(action.sourceZone, state);
274
- const newItem = __spreadProps(__spreadValues({}, item), {
275
- props: __spreadProps(__spreadValues({}, item.props), {
276
- id: generateId(item.type)
277
- })
278
- });
279
- const modified = walkAppState(
280
- state,
281
- appStore.config,
282
- (content, zoneCompound) => {
283
- if (zoneCompound === action.sourceZone) {
284
- return insert(content, action.sourceIndex + 1, item);
285
- }
286
- return content;
287
- },
288
- (childItem, path, index) => {
289
- const zoneCompound = path[path.length - 1];
290
- const parents = path.map((p) => p.split(":")[0]);
291
- if (parents.indexOf(newItem.props.id) > -1) {
292
- return __spreadProps(__spreadValues({}, childItem), {
293
- props: __spreadProps(__spreadValues({}, childItem.props), {
294
- id: generateId(childItem.type)
295
- })
296
- });
297
- }
298
- if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
299
- return newItem;
300
- }
301
- const [sourceZoneParent] = action.sourceZone.split(":");
302
- if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
303
- return childItem;
304
- }
305
- return null;
306
- }
307
- );
308
- return __spreadProps(__spreadValues({}, modified), {
309
- ui: __spreadProps(__spreadValues({}, modified.ui), {
310
- itemSelector: {
311
- index: action.sourceIndex + 1,
312
- zone: action.sourceZone
313
- }
314
- })
315
- });
316
- }
182
+ // ../../node_modules/lucide-react/dist/esm/icons/chevron-right.js
183
+ init_react_import();
184
+ var ChevronRight = createLucideIcon("ChevronRight", [
185
+ ["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]
186
+ ]);
317
187
 
318
- // reducer/actions/reorder.ts
188
+ // ../../node_modules/lucide-react/dist/esm/icons/chevron-up.js
319
189
  init_react_import();
190
+ var ChevronUp = createLucideIcon("ChevronUp", [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]]);
320
191
 
321
- // reducer/actions/move.ts
192
+ // ../../node_modules/lucide-react/dist/esm/icons/circle-check-big.js
322
193
  init_react_import();
194
+ var CircleCheckBig = createLucideIcon("CircleCheckBig", [
195
+ ["path", { d: "M21.801 10A10 10 0 1 1 17 3.335", key: "yps3ct" }],
196
+ ["path", { d: "m9 11 3 3L22 4", key: "1pflzl" }]
197
+ ]);
323
198
 
324
- // lib/data/remove.ts
199
+ // ../../node_modules/lucide-react/dist/esm/icons/code.js
325
200
  init_react_import();
326
- var remove = (list, index) => {
327
- const result = Array.from(list);
328
- result.splice(index, 1);
329
- return result;
330
- };
201
+ var Code = createLucideIcon("Code", [
202
+ ["polyline", { points: "16 18 22 12 16 6", key: "z7tu5w" }],
203
+ ["polyline", { points: "8 6 2 12 8 18", key: "1eg1df" }]
204
+ ]);
331
205
 
332
- // reducer/actions/move.ts
333
- var moveAction = (state, action, appStore) => {
334
- if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
335
- return state;
336
- }
337
- const item = getItem(
338
- { zone: action.sourceZone, index: action.sourceIndex },
339
- state
340
- );
341
- if (!item) return state;
342
- const idsInSourcePath = getIdsForParent(action.sourceZone, state);
343
- const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
344
- return walkAppState(
345
- state,
346
- appStore.config,
347
- (content, zoneCompound) => {
348
- if (zoneCompound === action.sourceZone && zoneCompound === action.destinationZone) {
349
- return insert(
350
- remove(content, action.sourceIndex),
351
- action.destinationIndex,
352
- item
353
- );
354
- } else if (zoneCompound === action.sourceZone) {
355
- return remove(content, action.sourceIndex);
356
- } else if (zoneCompound === action.destinationZone) {
357
- return insert(content, action.destinationIndex, item);
358
- }
359
- return content;
360
- },
361
- (childItem, path) => {
362
- const [sourceZoneParent] = action.sourceZone.split(":");
363
- const [destinationZoneParent] = action.destinationZone.split(":");
364
- const childId = childItem.props.id;
365
- if (sourceZoneParent === childId || destinationZoneParent === childId || item.props.id === childId || idsInSourcePath.indexOf(childId) > -1 || idsInDestinationPath.indexOf(childId) > -1 || path.includes(action.destinationZone)) {
366
- return childItem;
367
- }
368
- return null;
369
- }
370
- );
371
- };
206
+ // ../../node_modules/lucide-react/dist/esm/icons/copy.js
207
+ init_react_import();
208
+ var Copy = createLucideIcon("Copy", [
209
+ ["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
210
+ ["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2", key: "zix9uf" }]
211
+ ]);
372
212
 
373
- // reducer/actions/reorder.ts
374
- var reorderAction = (state, action, appStore) => {
375
- return moveAction(
376
- state,
377
- {
378
- type: "move",
379
- sourceIndex: action.sourceIndex,
380
- sourceZone: action.destinationZone,
381
- destinationIndex: action.destinationIndex,
382
- destinationZone: action.destinationZone
383
- },
384
- appStore
385
- );
386
- };
213
+ // ../../node_modules/lucide-react/dist/esm/icons/corner-left-up.js
214
+ init_react_import();
215
+ var CornerLeftUp = createLucideIcon("CornerLeftUp", [
216
+ ["polyline", { points: "14 9 9 4 4 9", key: "m9oyvo" }],
217
+ ["path", { d: "M20 20h-7a4 4 0 0 1-4-4V4", key: "1blwi3" }]
218
+ ]);
387
219
 
388
- // reducer/actions/remove.ts
220
+ // ../../node_modules/lucide-react/dist/esm/icons/ellipsis-vertical.js
389
221
  init_react_import();
390
- var removeAction = (state, action, appStore) => {
391
- const item = getItem({ index: action.index, zone: action.zone }, state);
392
- const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
393
- (acc, [nodeId, nodeData]) => {
394
- const pathIds = nodeData.path.map((p) => p.split(":")[0]);
395
- if (pathIds.includes(item.props.id)) {
396
- return [...acc, nodeId];
397
- }
398
- return acc;
399
- },
400
- [item.props.id]
401
- );
402
- const newState = walkAppState(
403
- state,
404
- appStore.config,
405
- (content, zoneCompound) => {
406
- if (zoneCompound === action.zone) {
407
- return remove(content, action.index);
408
- }
409
- return content;
410
- }
411
- );
412
- Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
413
- const parentId = zoneCompound.split(":")[0];
414
- if (nodesToDelete.includes(parentId) && newState.data.zones) {
415
- delete newState.data.zones[zoneCompound];
416
- }
417
- });
418
- Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
419
- const parentId = zoneCompound.split(":")[0];
420
- if (nodesToDelete.includes(parentId)) {
421
- delete newState.indexes.zones[zoneCompound];
422
- }
423
- });
424
- nodesToDelete.forEach((id) => {
425
- delete newState.indexes.nodes[id];
426
- });
427
- return newState;
428
- };
222
+ var EllipsisVertical = createLucideIcon("EllipsisVertical", [
223
+ ["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
224
+ ["circle", { cx: "12", cy: "5", r: "1", key: "gxeob9" }],
225
+ ["circle", { cx: "12", cy: "19", r: "1", key: "lyex9k" }]
226
+ ]);
429
227
 
430
- // reducer/actions/register-zone.ts
228
+ // ../../node_modules/lucide-react/dist/esm/icons/globe.js
431
229
  init_react_import();
432
- var zoneCache = {};
433
- function registerZoneAction(state, action) {
434
- if (zoneCache[action.zone]) {
435
- return __spreadProps(__spreadValues({}, state), {
436
- data: __spreadProps(__spreadValues({}, state.data), {
437
- zones: __spreadProps(__spreadValues({}, state.data.zones), {
438
- [action.zone]: zoneCache[action.zone]
439
- })
440
- }),
441
- indexes: __spreadProps(__spreadValues({}, state.indexes), {
442
- zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
443
- [action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
444
- contentIds: zoneCache[action.zone].map((item) => item.props.id),
445
- type: "dropzone"
446
- })
447
- })
448
- })
449
- });
450
- }
451
- return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
452
- }
453
- function unregisterZoneAction(state, action) {
454
- const _zones = __spreadValues({}, state.data.zones || {});
455
- const zoneIndex = __spreadValues({}, state.indexes.zones || {});
456
- if (_zones[action.zone]) {
457
- zoneCache[action.zone] = _zones[action.zone];
458
- delete _zones[action.zone];
459
- }
460
- delete zoneIndex[action.zone];
461
- return __spreadProps(__spreadValues({}, state), {
462
- data: __spreadProps(__spreadValues({}, state.data), {
463
- zones: _zones
464
- }),
465
- indexes: __spreadProps(__spreadValues({}, state.indexes), {
466
- zones: zoneIndex
467
- })
468
- });
469
- }
230
+ var Globe = createLucideIcon("Globe", [
231
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
232
+ ["path", { d: "M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20", key: "13o1zl" }],
233
+ ["path", { d: "M2 12h20", key: "9i4pu4" }]
234
+ ]);
470
235
 
471
- // reducer/actions/set-data.ts
236
+ // ../../node_modules/lucide-react/dist/esm/icons/hash.js
472
237
  init_react_import();
473
- var setDataAction = (state, action, appStore) => {
474
- if (typeof action.data === "object") {
475
- console.warn(
476
- "`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
477
- );
478
- return walkAppState(
479
- __spreadProps(__spreadValues({}, state), {
480
- data: __spreadValues(__spreadValues({}, state.data), action.data)
481
- }),
482
- appStore.config
483
- );
484
- }
485
- return walkAppState(
486
- __spreadProps(__spreadValues({}, state), {
487
- data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
488
- }),
489
- appStore.config
490
- );
491
- };
238
+ var Hash = createLucideIcon("Hash", [
239
+ ["line", { x1: "4", x2: "20", y1: "9", y2: "9", key: "4lhtct" }],
240
+ ["line", { x1: "4", x2: "20", y1: "15", y2: "15", key: "vyu0kd" }],
241
+ ["line", { x1: "10", x2: "8", y1: "3", y2: "21", key: "1ggp8o" }],
242
+ ["line", { x1: "16", x2: "14", y1: "3", y2: "21", key: "weycgp" }]
243
+ ]);
492
244
 
493
- // reducer/actions/set-ui.ts
245
+ // ../../node_modules/lucide-react/dist/esm/icons/heading-1.js
494
246
  init_react_import();
495
- var setUiAction = (state, action) => {
496
- if (typeof action.ui === "object") {
497
- return __spreadProps(__spreadValues({}, state), {
498
- ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
499
- });
500
- }
501
- return __spreadProps(__spreadValues({}, state), {
502
- ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
503
- });
504
- };
247
+ var Heading1 = createLucideIcon("Heading1", [
248
+ ["path", { d: "M4 12h8", key: "17cfdx" }],
249
+ ["path", { d: "M4 18V6", key: "1rz3zl" }],
250
+ ["path", { d: "M12 18V6", key: "zqpxq5" }],
251
+ ["path", { d: "m17 12 3-2v8", key: "1hhhft" }]
252
+ ]);
505
253
 
506
- // lib/data/make-state-public.ts
254
+ // ../../node_modules/lucide-react/dist/esm/icons/heading-2.js
507
255
  init_react_import();
508
- var makeStatePublic = (state) => {
509
- const { data, ui } = state;
510
- return { data, ui };
511
- };
256
+ var Heading2 = createLucideIcon("Heading2", [
257
+ ["path", { d: "M4 12h8", key: "17cfdx" }],
258
+ ["path", { d: "M4 18V6", key: "1rz3zl" }],
259
+ ["path", { d: "M12 18V6", key: "zqpxq5" }],
260
+ ["path", { d: "M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1", key: "9jr5yi" }]
261
+ ]);
512
262
 
513
- // reducer/actions.tsx
514
- init_react_import();
515
-
516
- // reducer/index.ts
517
- function storeInterceptor(reducer, record, onAction) {
518
- return (state, action) => {
519
- const newAppState = reducer(state, action);
520
- const isValidType = ![
521
- "registerZone",
522
- "unregisterZone",
523
- "setData",
524
- "setUi",
525
- "set"
526
- ].includes(action.type);
527
- if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
528
- if (record) record(newAppState);
529
- }
530
- onAction == null ? void 0 : onAction(action, makeStatePublic(newAppState), makeStatePublic(state));
531
- return newAppState;
532
- };
533
- }
534
- function createReducer({
535
- record,
536
- onAction,
537
- appStore
538
- }) {
539
- return storeInterceptor(
540
- (state, action) => {
541
- if (action.type === "set") {
542
- return setAction(state, action, appStore);
543
- }
544
- if (action.type === "insert") {
545
- return insertAction(state, action, appStore);
546
- }
547
- if (action.type === "replace") {
548
- return replaceAction(state, action, appStore);
549
- }
550
- if (action.type === "replaceRoot") {
551
- return replaceRootAction(state, action, appStore);
552
- }
553
- if (action.type === "duplicate") {
554
- return duplicateAction(state, action, appStore);
555
- }
556
- if (action.type === "reorder") {
557
- return reorderAction(state, action, appStore);
558
- }
559
- if (action.type === "move") {
560
- return moveAction(state, action, appStore);
561
- }
562
- if (action.type === "remove") {
563
- return removeAction(state, action, appStore);
564
- }
565
- if (action.type === "registerZone") {
566
- return registerZoneAction(state, action);
567
- }
568
- if (action.type === "unregisterZone") {
569
- return unregisterZoneAction(state, action);
570
- }
571
- if (action.type === "setData") {
572
- return setDataAction(state, action, appStore);
573
- }
574
- if (action.type === "setUi") {
575
- return setUiAction(state, action);
576
- }
577
- return state;
578
- },
579
- record,
580
- onAction
581
- );
582
- }
263
+ // ../../node_modules/lucide-react/dist/esm/icons/heading-3.js
264
+ init_react_import();
265
+ var Heading3 = createLucideIcon("Heading3", [
266
+ ["path", { d: "M4 12h8", key: "17cfdx" }],
267
+ ["path", { d: "M4 18V6", key: "1rz3zl" }],
268
+ ["path", { d: "M12 18V6", key: "zqpxq5" }],
269
+ ["path", { d: "M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2", key: "68ncm8" }],
270
+ ["path", { d: "M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2", key: "1ejuhz" }]
271
+ ]);
583
272
 
584
- // store/index.ts
585
- import { create as create2, useStore } from "zustand";
586
- import { subscribeWithSelector as subscribeWithSelector2 } from "zustand/middleware";
587
- import { createContext, useContext } from "react";
273
+ // ../../node_modules/lucide-react/dist/esm/icons/heading-4.js
274
+ init_react_import();
275
+ var Heading4 = createLucideIcon("Heading4", [
276
+ ["path", { d: "M12 18V6", key: "zqpxq5" }],
277
+ ["path", { d: "M17 10v3a1 1 0 0 0 1 1h3", key: "tj5zdr" }],
278
+ ["path", { d: "M21 10v8", key: "1kdml4" }],
279
+ ["path", { d: "M4 12h8", key: "17cfdx" }],
280
+ ["path", { d: "M4 18V6", key: "1rz3zl" }]
281
+ ]);
588
282
 
589
- // store/slices/history.ts
283
+ // ../../node_modules/lucide-react/dist/esm/icons/heading-5.js
590
284
  init_react_import();
591
- import { useEffect as useEffect2 } from "react";
285
+ var Heading5 = createLucideIcon("Heading5", [
286
+ ["path", { d: "M4 12h8", key: "17cfdx" }],
287
+ ["path", { d: "M4 18V6", key: "1rz3zl" }],
288
+ ["path", { d: "M12 18V6", key: "zqpxq5" }],
289
+ ["path", { d: "M17 13v-3h4", key: "1nvgqp" }],
290
+ [
291
+ "path",
292
+ { d: "M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17", key: "2nebdn" }
293
+ ]
294
+ ]);
592
295
 
593
- // lib/use-hotkey.ts
296
+ // ../../node_modules/lucide-react/dist/esm/icons/heading-6.js
594
297
  init_react_import();
595
- import { useEffect } from "react";
596
- import { create } from "zustand";
597
- import { subscribeWithSelector } from "zustand/middleware";
598
- var keyCodeMap = {
599
- ControlLeft: "ctrl",
600
- ControlRight: "ctrl",
601
- MetaLeft: "meta",
602
- MetaRight: "meta",
603
- ShiftLeft: "shift",
604
- ShiftRight: "shift",
605
- KeyA: "a",
606
- KeyB: "b",
607
- KeyC: "c",
608
- KeyD: "d",
609
- KeyE: "e",
610
- KeyF: "f",
611
- KeyG: "g",
612
- KeyH: "h",
613
- KeyI: "i",
614
- KeyJ: "j",
615
- KeyK: "k",
616
- KeyL: "l",
617
- KeyM: "m",
618
- KeyN: "n",
619
- KeyO: "o",
620
- KeyP: "p",
621
- KeyQ: "q",
622
- KeyR: "r",
623
- KeyS: "s",
624
- KeyT: "t",
625
- KeyU: "u",
626
- KeyV: "v",
627
- KeyW: "w",
628
- KeyX: "x",
629
- KeyY: "y",
630
- KeyZ: "z",
631
- Delete: "delete",
632
- Backspace: "backspace"
633
- };
634
- var useHotkeyStore = create()(
635
- subscribeWithSelector((set) => ({
636
- held: {},
637
- hold: (key) => set((s) => s.held[key] ? s : { held: __spreadProps(__spreadValues({}, s.held), { [key]: true }) }),
638
- release: (key) => set((s) => s.held[key] ? { held: __spreadProps(__spreadValues({}, s.held), { [key]: false }) } : s),
639
- reset: (held = {}) => set(() => ({ held })),
640
- triggers: {}
641
- }))
642
- );
643
- var monitorHotkeys = (doc) => {
644
- const onKeyDown = (e) => {
645
- const key = keyCodeMap[e.code];
646
- if (key) {
647
- useHotkeyStore.getState().hold(key);
648
- const { held, triggers } = useHotkeyStore.getState();
649
- Object.values(triggers).forEach(({ combo, cb }) => {
650
- const conditionMet = Object.entries(combo).every(
651
- ([key2, value]) => value === !!held[key2]
652
- ) && Object.entries(held).every(
653
- ([key2, value]) => value === !!combo[key2]
654
- );
655
- if (conditionMet) {
656
- const handled = cb(e);
657
- if (handled !== false) {
658
- e.preventDefault();
659
- }
660
- }
661
- });
662
- if (key !== "meta" && key !== "ctrl" && key !== "shift") {
663
- useHotkeyStore.getState().release(key);
664
- }
298
+ var Heading6 = createLucideIcon("Heading6", [
299
+ ["path", { d: "M4 12h8", key: "17cfdx" }],
300
+ ["path", { d: "M4 18V6", key: "1rz3zl" }],
301
+ ["path", { d: "M12 18V6", key: "zqpxq5" }],
302
+ ["circle", { cx: "19", cy: "16", r: "2", key: "15mx69" }],
303
+ ["path", { d: "M20 10c-2 2-3 3.5-3 6", key: "f35dl0" }]
304
+ ]);
305
+
306
+ // ../../node_modules/lucide-react/dist/esm/icons/italic.js
307
+ init_react_import();
308
+ var Italic = createLucideIcon("Italic", [
309
+ ["line", { x1: "19", x2: "10", y1: "4", y2: "4", key: "15jd3p" }],
310
+ ["line", { x1: "14", x2: "5", y1: "20", y2: "20", key: "bu0au3" }],
311
+ ["line", { x1: "15", x2: "9", y1: "4", y2: "20", key: "uljnxc" }]
312
+ ]);
313
+
314
+ // ../../node_modules/lucide-react/dist/esm/icons/layers.js
315
+ init_react_import();
316
+ var Layers = createLucideIcon("Layers", [
317
+ [
318
+ "path",
319
+ {
320
+ d: "M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",
321
+ key: "zw3jo"
665
322
  }
666
- };
667
- const onKeyUp = (e) => {
668
- const key = keyCodeMap[e.code];
669
- if (key) {
670
- if (key === "meta") {
671
- useHotkeyStore.getState().reset();
672
- } else {
673
- useHotkeyStore.getState().release(key);
674
- }
323
+ ],
324
+ [
325
+ "path",
326
+ {
327
+ d: "M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",
328
+ key: "1wduqc"
675
329
  }
676
- };
677
- const onVisibilityChanged = (e) => {
678
- if (document.visibilityState === "hidden") {
679
- useHotkeyStore.getState().reset();
330
+ ],
331
+ [
332
+ "path",
333
+ {
334
+ d: "M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",
335
+ key: "kqbvx6"
680
336
  }
681
- };
682
- const onBlur = () => {
683
- useHotkeyStore.getState().reset();
684
- };
685
- window.addEventListener("blur", onBlur);
686
- doc.addEventListener("keydown", onKeyDown);
687
- doc.addEventListener("keyup", onKeyUp);
688
- doc.addEventListener("visibilitychange", onVisibilityChanged);
689
- return () => {
690
- doc.removeEventListener("keydown", onKeyDown);
691
- doc.removeEventListener("keyup", onKeyUp);
692
- doc.removeEventListener("visibilitychange", onVisibilityChanged);
693
- window.removeEventListener("blur", onBlur);
694
- };
695
- };
696
- var useMonitorHotkeys = () => {
697
- useEffect(() => monitorHotkeys(document), []);
698
- };
699
- var useHotkey = (combo, cb) => {
700
- useEffect(
701
- () => useHotkeyStore.setState((s) => ({
702
- triggers: __spreadProps(__spreadValues({}, s.triggers), {
703
- [`${Object.keys(combo).join("+")}`]: { combo, cb }
704
- })
705
- })),
706
- []
707
- );
708
- };
337
+ ]
338
+ ]);
709
339
 
710
- // store/slices/history.ts
711
- var EMPTY_HISTORY_INDEX = 0;
712
- function debounce(func, timeout = 300) {
713
- let timer;
714
- return (...args) => {
715
- clearTimeout(timer);
716
- timer = setTimeout(() => {
717
- func(...args);
718
- }, timeout);
719
- };
720
- }
721
- var tidyState = (state) => {
722
- return __spreadProps(__spreadValues({}, state), {
723
- ui: __spreadProps(__spreadValues({}, state.ui), {
724
- field: __spreadProps(__spreadValues({}, state.ui.field), {
725
- focus: null
726
- })
727
- })
728
- });
729
- };
730
- var createHistorySlice = (set, get) => {
731
- const record = debounce((state) => {
732
- const { histories, index } = get().history;
733
- const history = {
734
- state,
735
- id: generateId("history")
736
- };
737
- const newHistories = [...histories.slice(0, index + 1), history];
738
- set({
739
- history: __spreadProps(__spreadValues({}, get().history), {
740
- histories: newHistories,
741
- index: newHistories.length - 1
742
- })
743
- });
744
- }, 250);
745
- return {
746
- initialAppState: {},
747
- index: EMPTY_HISTORY_INDEX,
748
- histories: [],
749
- hasPast: () => get().history.index > EMPTY_HISTORY_INDEX,
750
- hasFuture: () => get().history.index < get().history.histories.length - 1,
751
- prevHistory: () => {
752
- const { history } = get();
753
- return history.hasPast() ? history.histories[history.index - 1] : null;
754
- },
755
- nextHistory: () => {
756
- const s = get().history;
757
- return s.hasFuture() ? s.histories[s.index + 1] : null;
758
- },
759
- currentHistory: () => get().history.histories[get().history.index],
760
- back: () => {
761
- var _a;
762
- const { history, dispatch } = get();
763
- if (history.hasPast()) {
764
- const state = tidyState(
765
- ((_a = history.prevHistory()) == null ? void 0 : _a.state) || history.initialAppState
766
- );
767
- dispatch({
768
- type: "set",
769
- state
770
- });
771
- set({ history: __spreadProps(__spreadValues({}, history), { index: history.index - 1 }) });
772
- }
773
- },
774
- forward: () => {
775
- var _a;
776
- const { history, dispatch } = get();
777
- if (history.hasFuture()) {
778
- const state = (_a = history.nextHistory()) == null ? void 0 : _a.state;
779
- dispatch({ type: "set", state: state ? tidyState(state) : {} });
780
- set({ history: __spreadProps(__spreadValues({}, history), { index: history.index + 1 }) });
781
- }
782
- },
783
- setHistories: (histories) => {
784
- var _a;
785
- const { dispatch, history } = get();
786
- dispatch({
787
- type: "set",
788
- state: ((_a = histories[histories.length - 1]) == null ? void 0 : _a.state) || history.initialAppState
789
- });
790
- set({ history: __spreadProps(__spreadValues({}, history), { histories, index: histories.length - 1 }) });
791
- },
792
- setHistoryIndex: (index) => {
793
- var _a;
794
- const { dispatch, history } = get();
795
- dispatch({
796
- type: "set",
797
- state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
798
- });
799
- set({ history: __spreadProps(__spreadValues({}, history), { index }) });
800
- },
801
- record
802
- };
803
- };
804
- function useRegisterHistorySlice(appStore, {
805
- histories,
806
- index,
807
- initialAppState
808
- }) {
809
- useEffect2(
810
- () => appStore.setState({
811
- history: __spreadProps(__spreadValues({}, appStore.getState().history), {
812
- histories,
813
- index,
814
- initialAppState
815
- })
816
- }),
817
- [histories, index, initialAppState]
818
- );
819
- const back = () => {
820
- appStore.getState().history.back();
821
- };
822
- const forward = () => {
823
- appStore.getState().history.forward();
824
- };
825
- useHotkey({ meta: true, z: true }, back);
826
- useHotkey({ meta: true, shift: true, z: true }, forward);
827
- useHotkey({ meta: true, y: true }, forward);
828
- useHotkey({ ctrl: true, z: true }, back);
829
- useHotkey({ ctrl: true, shift: true, z: true }, forward);
830
- useHotkey({ ctrl: true, y: true }, forward);
831
- }
340
+ // ../../node_modules/lucide-react/dist/esm/icons/layout-grid.js
341
+ init_react_import();
342
+ var LayoutGrid = createLucideIcon("LayoutGrid", [
343
+ ["rect", { width: "7", height: "7", x: "3", y: "3", rx: "1", key: "1g98yp" }],
344
+ ["rect", { width: "7", height: "7", x: "14", y: "3", rx: "1", key: "6d4xhi" }],
345
+ ["rect", { width: "7", height: "7", x: "14", y: "14", rx: "1", key: "nxv5o0" }],
346
+ ["rect", { width: "7", height: "7", x: "3", y: "14", rx: "1", key: "1bb6yr" }]
347
+ ]);
832
348
 
833
- // store/slices/nodes.ts
349
+ // ../../node_modules/lucide-react/dist/esm/icons/link.js
834
350
  init_react_import();
835
- var createNodesSlice = (set, get) => ({
836
- nodes: {},
837
- registerNode: (id, node) => {
838
- const s = get().nodes;
839
- const emptyNode = {
840
- id,
841
- methods: {
842
- sync: () => null,
843
- hideOverlay: () => null,
844
- showOverlay: () => null
845
- },
846
- element: null
847
- };
848
- const existingNode = s.nodes[id];
849
- set({
850
- nodes: __spreadProps(__spreadValues({}, s), {
851
- nodes: __spreadProps(__spreadValues({}, s.nodes), {
852
- [id]: __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, emptyNode), existingNode), node), {
853
- id
854
- })
855
- })
856
- })
857
- });
858
- },
859
- unregisterNode: (id) => {
860
- const s = get().nodes;
861
- const existingNode = s.nodes[id];
862
- if (existingNode) {
863
- const newNodes = __spreadValues({}, s.nodes);
864
- delete newNodes[id];
865
- set({
866
- nodes: __spreadProps(__spreadValues({}, s), {
867
- nodes: newNodes
868
- })
869
- });
870
- }
871
- }
872
- });
351
+ var Link = createLucideIcon("Link", [
352
+ ["path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71", key: "1cjeqo" }],
353
+ ["path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71", key: "19qd67" }]
354
+ ]);
873
355
 
874
- // store/slices/permissions.ts
356
+ // ../../node_modules/lucide-react/dist/esm/icons/list-ordered.js
875
357
  init_react_import();
876
- import { useEffect as useEffect3 } from "react";
358
+ var ListOrdered = createLucideIcon("ListOrdered", [
359
+ ["path", { d: "M10 12h11", key: "6m4ad9" }],
360
+ ["path", { d: "M10 18h11", key: "11hvi2" }],
361
+ ["path", { d: "M10 6h11", key: "c7qv1k" }],
362
+ ["path", { d: "M4 10h2", key: "16xx2s" }],
363
+ ["path", { d: "M4 6h1v4", key: "cnovpq" }],
364
+ ["path", { d: "M6 18H4c0-1 2-2 2-3s-1-1.5-2-1", key: "m9a95d" }]
365
+ ]);
877
366
 
878
- // lib/data/flatten-data.ts
367
+ // ../../node_modules/lucide-react/dist/esm/icons/lock-open.js
879
368
  init_react_import();
880
- var flattenData = (state, config) => {
881
- const data = [];
882
- walkAppState(
883
- state,
884
- config,
885
- (content) => content,
886
- (item) => {
887
- data.push(item);
888
- return item;
889
- }
890
- );
891
- return data;
892
- };
369
+ var LockOpen = createLucideIcon("LockOpen", [
370
+ ["rect", { width: "18", height: "11", x: "3", y: "11", rx: "2", ry: "2", key: "1w4ew1" }],
371
+ ["path", { d: "M7 11V7a5 5 0 0 1 9.9-1", key: "1mm8w8" }]
372
+ ]);
893
373
 
894
- // store/slices/permissions.ts
895
- var createPermissionsSlice = (set, get) => {
896
- const resolvePermissions = (..._0) => __async(null, [..._0], function* (params = {}, force) {
897
- const { state, permissions, config } = get();
898
- const { cache, globalPermissions } = permissions;
899
- const resolvePermissionsForItem = (item2, force2 = false) => __async(null, null, function* () {
900
- var _a, _b;
901
- const { config: config2, state: appState, setComponentLoading } = get();
902
- const itemCache = cache[item2.props.id];
903
- const nodes = appState.indexes.nodes;
904
- const parentId = (_a = nodes[item2.props.id]) == null ? void 0 : _a.parentId;
905
- const parentNode = parentId ? nodes[parentId] : null;
906
- const parentData = (_b = parentNode == null ? void 0 : parentNode.data) != null ? _b : null;
907
- const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
908
- if (!componentConfig) {
909
- return;
910
- }
911
- const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
912
- if (componentConfig.resolvePermissions) {
913
- const changed = getChanged(item2, itemCache == null ? void 0 : itemCache.lastData);
914
- const propsChanged = Object.values(changed).some((el) => el === true);
915
- const parentChanged = (itemCache == null ? void 0 : itemCache.lastParentId) !== parentId;
916
- if (propsChanged || parentChanged || force2) {
917
- const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
918
- const resolvedPermissions = yield componentConfig.resolvePermissions(
919
- item2,
920
- {
921
- changed,
922
- lastPermissions: (itemCache == null ? void 0 : itemCache.lastPermissions) || null,
923
- permissions: initialPermissions,
924
- appState: makeStatePublic(appState),
925
- lastData: (itemCache == null ? void 0 : itemCache.lastData) || null,
926
- parent: parentData
927
- }
928
- );
929
- const latest = get().permissions;
930
- set({
931
- permissions: __spreadProps(__spreadValues({}, latest), {
932
- cache: __spreadProps(__spreadValues({}, latest.cache), {
933
- [item2.props.id]: {
934
- lastParentId: parentId,
935
- lastData: item2,
936
- lastPermissions: resolvedPermissions
937
- }
938
- }),
939
- resolvedPermissions: __spreadProps(__spreadValues({}, latest.resolvedPermissions), {
940
- [item2.props.id]: resolvedPermissions
941
- })
942
- })
943
- });
944
- clearTimeout2();
945
- }
946
- }
947
- });
948
- const resolvePermissionsForRoot = (force2 = false) => {
949
- const { state: appState } = get();
950
- resolvePermissionsForItem(
951
- // Shim the root data in by conforming to component data shape
952
- {
953
- type: "root",
954
- props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "root" })
955
- },
956
- force2
957
- );
958
- };
959
- const { item, type, root } = params;
960
- if (item) {
961
- yield resolvePermissionsForItem(item, force);
962
- } else if (type) {
963
- flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(null, null, function* () {
964
- yield resolvePermissionsForItem(item2, force);
965
- }));
966
- } else if (root) {
967
- resolvePermissionsForRoot(force);
968
- } else {
969
- flattenData(state, config).map((item2) => __async(null, null, function* () {
970
- yield resolvePermissionsForItem(item2, force);
971
- }));
972
- }
973
- });
974
- const refreshPermissions = (params) => resolvePermissions(params, true);
975
- return {
976
- cache: {},
977
- globalPermissions: {
978
- drag: true,
979
- edit: true,
980
- delete: true,
981
- duplicate: true,
982
- insert: true
983
- },
984
- resolvedPermissions: {},
985
- getPermissions: ({ item, type, root } = {}) => {
986
- const { config, permissions } = get();
987
- const { globalPermissions, resolvedPermissions } = permissions;
988
- if (item) {
989
- const componentConfig = config.components[item.type];
990
- const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
991
- const resolvedForItem = resolvedPermissions[item.props.id];
992
- return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
993
- } else if (type) {
994
- const componentConfig = config.components[type];
995
- return __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
996
- } else if (root) {
997
- const rootConfig = config.root;
998
- const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
999
- const resolvedForItem = resolvedPermissions["root"];
1000
- return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
1001
- }
1002
- return globalPermissions;
1003
- },
1004
- resolvePermissions,
1005
- refreshPermissions
1006
- };
1007
- };
1008
- var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
1009
- useEffect3(() => {
1010
- const { permissions } = appStore.getState();
1011
- const { globalPermissions: existingGlobalPermissions } = permissions;
1012
- appStore.setState({
1013
- permissions: __spreadProps(__spreadValues({}, permissions), {
1014
- globalPermissions: __spreadValues(__spreadValues({}, existingGlobalPermissions), globalPermissions)
1015
- })
1016
- });
1017
- permissions.resolvePermissions();
1018
- }, [globalPermissions]);
1019
- useEffect3(() => {
1020
- return appStore.subscribe(
1021
- (s) => s.state.data,
1022
- () => {
1023
- appStore.getState().permissions.resolvePermissions();
1024
- }
1025
- );
1026
- }, []);
1027
- useEffect3(() => {
1028
- return appStore.subscribe(
1029
- (s) => s.config,
1030
- () => {
1031
- appStore.getState().permissions.resolvePermissions();
1032
- }
1033
- );
1034
- }, []);
1035
- };
374
+ // ../../node_modules/lucide-react/dist/esm/icons/lock.js
375
+ init_react_import();
376
+ var Lock = createLucideIcon("Lock", [
377
+ ["rect", { width: "18", height: "11", x: "3", y: "11", rx: "2", ry: "2", key: "1w4ew1" }],
378
+ ["path", { d: "M7 11V7a5 5 0 0 1 10 0v4", key: "fwvmzm" }]
379
+ ]);
1036
380
 
1037
- // store/slices/fields.ts
381
+ // ../../node_modules/lucide-react/dist/esm/icons/minus.js
1038
382
  init_react_import();
1039
- import { useCallback, useEffect as useEffect4 } from "react";
1040
- var createFieldsSlice = (_set, _get) => {
1041
- return {
1042
- fields: {},
1043
- loading: false,
1044
- lastResolvedData: {},
1045
- id: void 0
1046
- };
1047
- };
1048
- var useRegisterFieldsSlice = (appStore, id) => {
1049
- const resolveFields = useCallback(
1050
- (reset) => __async(null, null, function* () {
1051
- var _a, _b;
1052
- const { fields, lastResolvedData } = appStore.getState().fields;
1053
- const metadata = appStore.getState().metadata;
1054
- const nodes = appStore.getState().state.indexes.nodes;
1055
- const node = nodes[id || "root"];
1056
- const componentData = node == null ? void 0 : node.data;
1057
- const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node.parentId] : null;
1058
- const parent = (parentNode == null ? void 0 : parentNode.data) || null;
1059
- const { getComponentConfig, state } = appStore.getState();
1060
- const componentConfig = getComponentConfig(componentData == null ? void 0 : componentData.type);
1061
- if (!componentData || !componentConfig) return;
1062
- const defaultFields = componentConfig.fields || {};
1063
- const resolver = componentConfig.resolveFields;
1064
- let lastFields = fields;
1065
- if (reset) {
1066
- appStore.setState((s) => ({
1067
- fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
1068
- }));
1069
- lastFields = defaultFields;
1070
- }
1071
- if (resolver) {
1072
- const timeout = setTimeout(() => {
1073
- appStore.setState((s) => ({
1074
- fields: __spreadProps(__spreadValues({}, s.fields), { loading: true })
1075
- }));
1076
- }, 50);
1077
- const lastData = ((_a = lastResolvedData.props) == null ? void 0 : _a.id) === id ? lastResolvedData : null;
1078
- const changed = getChanged(componentData, lastData);
1079
- const newFields = yield resolver(componentData, {
1080
- changed,
1081
- fields: defaultFields,
1082
- lastFields,
1083
- metadata: __spreadValues(__spreadValues({}, metadata), componentConfig.metadata),
1084
- lastData,
1085
- appState: makeStatePublic(state),
1086
- parent
1087
- });
1088
- clearTimeout(timeout);
1089
- if (((_b = appStore.getState().selectedItem) == null ? void 0 : _b.props.id) !== id) {
1090
- return;
1091
- }
1092
- appStore.setState({
1093
- fields: {
1094
- fields: newFields,
1095
- loading: false,
1096
- lastResolvedData: componentData,
1097
- id
1098
- }
1099
- });
1100
- } else {
1101
- appStore.setState((s) => ({
1102
- fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
1103
- }));
1104
- }
1105
- }),
1106
- [id]
1107
- );
1108
- useEffect4(() => {
1109
- resolveFields(true);
1110
- return appStore.subscribe(
1111
- (s) => s.state.indexes.nodes[id || "root"],
1112
- () => resolveFields()
1113
- );
1114
- }, [id]);
1115
- };
383
+ var Minus = createLucideIcon("Minus", [["path", { d: "M5 12h14", key: "1ays0h" }]]);
1116
384
 
1117
- // lib/data/to-root.ts
385
+ // ../../node_modules/lucide-react/dist/esm/icons/monitor.js
1118
386
  init_react_import();
1119
- var toRoot = (item) => {
1120
- if ("type" in item && item.type !== "root") {
1121
- throw new Error("Converting non-root item to root.");
1122
- }
1123
- const { readOnly } = item;
1124
- if (item.props) {
1125
- if ("id" in item.props) {
1126
- const _a = item.props, { id } = _a, props = __objRest(_a, ["id"]);
1127
- return { props, readOnly };
387
+ var Monitor = createLucideIcon("Monitor", [
388
+ ["rect", { width: "20", height: "14", x: "2", y: "3", rx: "2", key: "48i651" }],
389
+ ["line", { x1: "8", x2: "16", y1: "21", y2: "21", key: "1svkeh" }],
390
+ ["line", { x1: "12", x2: "12", y1: "17", y2: "21", key: "vw1qmm" }]
391
+ ]);
392
+
393
+ // ../../node_modules/lucide-react/dist/esm/icons/panel-left.js
394
+ init_react_import();
395
+ var PanelLeft = createLucideIcon("PanelLeft", [
396
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
397
+ ["path", { d: "M9 3v18", key: "fh3hqa" }]
398
+ ]);
399
+
400
+ // ../../node_modules/lucide-react/dist/esm/icons/panel-right.js
401
+ init_react_import();
402
+ var PanelRight = createLucideIcon("PanelRight", [
403
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
404
+ ["path", { d: "M15 3v18", key: "14nvp0" }]
405
+ ]);
406
+
407
+ // ../../node_modules/lucide-react/dist/esm/icons/plus.js
408
+ init_react_import();
409
+ var Plus = createLucideIcon("Plus", [
410
+ ["path", { d: "M5 12h14", key: "1ays0h" }],
411
+ ["path", { d: "M12 5v14", key: "s699le" }]
412
+ ]);
413
+
414
+ // ../../node_modules/lucide-react/dist/esm/icons/quote.js
415
+ init_react_import();
416
+ var Quote = createLucideIcon("Quote", [
417
+ [
418
+ "path",
419
+ {
420
+ d: "M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",
421
+ key: "rib7q0"
1128
422
  }
1129
- return { props: item.props, readOnly };
1130
- }
1131
- return { props: {}, readOnly };
1132
- };
423
+ ],
424
+ [
425
+ "path",
426
+ {
427
+ d: "M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",
428
+ key: "1ymkrd"
429
+ }
430
+ ]
431
+ ]);
1133
432
 
1134
- // store/index.ts
1135
- var defaultPageFields = {
1136
- title: { type: "text" }
1137
- };
1138
- var createAppStore = (initialAppStore) => create2()(
1139
- subscribeWithSelector2((set, get) => {
1140
- var _a, _b;
1141
- return __spreadProps(__spreadValues({
1142
- state: defaultAppState,
1143
- config: { components: {} },
1144
- componentState: {},
1145
- plugins: [],
1146
- overrides: {},
1147
- viewports: defaultViewports,
1148
- zoomConfig: {
1149
- autoZoom: 1,
1150
- rootHeight: 0,
1151
- zoom: 1
1152
- },
1153
- status: "LOADING",
1154
- iframe: {},
1155
- metadata: {},
1156
- fieldTransforms: {}
1157
- }, initialAppStore), {
1158
- fields: createFieldsSlice(set, get),
1159
- history: createHistorySlice(set, get),
1160
- nodes: createNodesSlice(set, get),
1161
- permissions: createPermissionsSlice(set, get),
1162
- getComponentConfig: (type) => {
1163
- var _a2;
1164
- const { config, selectedItem } = get();
1165
- const rootFields = ((_a2 = config.root) == null ? void 0 : _a2.fields) || defaultPageFields;
1166
- return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
1167
- },
1168
- selectedItem: ((_a = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _a.ui.itemSelector) ? getItem(
1169
- (_b = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _b.ui.itemSelector,
1170
- initialAppStore.state
1171
- ) : null,
1172
- dispatch: (action) => set((s) => {
1173
- var _a2, _b2;
1174
- const { record } = get().history;
1175
- const dispatch = createReducer({
1176
- record,
1177
- appStore: s
1178
- });
1179
- const state = dispatch(s.state, action);
1180
- const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
1181
- (_b2 = (_a2 = get()).onAction) == null ? void 0 : _b2.call(_a2, action, state, get().state);
1182
- return __spreadProps(__spreadValues({}, s), { state, selectedItem });
1183
- }),
1184
- setZoomConfig: (zoomConfig) => set({ zoomConfig }),
1185
- setStatus: (status) => set({ status }),
1186
- setComponentState: (componentState) => set({ componentState }),
1187
- pendingLoadTimeouts: {},
1188
- setComponentLoading: (id, loading = true, defer = 0) => {
1189
- const { setComponentState, pendingLoadTimeouts } = get();
1190
- const loadId = generateId();
1191
- const setLoading = () => {
1192
- var _a2;
1193
- const { componentState } = get();
1194
- setComponentState(__spreadProps(__spreadValues({}, componentState), {
1195
- [id]: __spreadProps(__spreadValues({}, componentState[id]), {
1196
- loadingCount: (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) + 1
1197
- })
1198
- }));
1199
- };
1200
- const unsetLoading = () => {
1201
- var _a2;
1202
- const { componentState } = get();
1203
- clearTimeout(timeout);
1204
- delete pendingLoadTimeouts[loadId];
1205
- set({ pendingLoadTimeouts });
1206
- setComponentState(__spreadProps(__spreadValues({}, componentState), {
1207
- [id]: __spreadProps(__spreadValues({}, componentState[id]), {
1208
- loadingCount: Math.max(
1209
- (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) - 1,
1210
- 0
1211
- )
1212
- })
1213
- }));
1214
- };
1215
- const timeout = setTimeout(() => {
1216
- if (loading) {
1217
- setLoading();
1218
- } else {
1219
- unsetLoading();
1220
- }
1221
- delete pendingLoadTimeouts[loadId];
1222
- set({ pendingLoadTimeouts });
1223
- }, defer);
1224
- set({
1225
- pendingLoadTimeouts: __spreadProps(__spreadValues({}, pendingLoadTimeouts), {
1226
- [id]: timeout
1227
- })
1228
- });
1229
- return unsetLoading;
1230
- },
1231
- unsetComponentLoading: (id) => {
1232
- const { setComponentLoading } = get();
1233
- setComponentLoading(id, false);
1234
- },
1235
- // Helper
1236
- setUi: (ui, recordHistory) => set((s) => {
1237
- const dispatch = createReducer({
1238
- record: () => {
1239
- },
1240
- appStore: s
1241
- });
1242
- const state = dispatch(s.state, {
1243
- type: "setUi",
1244
- ui,
1245
- recordHistory
1246
- });
1247
- const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
1248
- return __spreadProps(__spreadValues({}, s), { state, selectedItem });
1249
- }),
1250
- resolveComponentData: (componentData, trigger) => __async(null, null, function* () {
1251
- const { config, metadata, setComponentLoading, permissions } = get();
1252
- const timeouts = {};
1253
- return yield resolveComponentData(
1254
- componentData,
1255
- config,
1256
- metadata,
1257
- (item) => {
1258
- const id = "id" in item.props ? item.props.id : "root";
1259
- timeouts[id] = setComponentLoading(id, true, 50);
1260
- },
1261
- (item) => __async(null, null, function* () {
1262
- const id = "id" in item.props ? item.props.id : "root";
1263
- if ("type" in item) {
1264
- yield permissions.refreshPermissions({ item });
1265
- } else {
1266
- yield permissions.refreshPermissions({ root: true });
1267
- }
1268
- timeouts[id]();
1269
- }),
1270
- trigger
1271
- );
1272
- }),
1273
- resolveAndCommitData: () => __async(null, null, function* () {
1274
- const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
1275
- walkAppState(
1276
- state,
1277
- config,
1278
- (content) => content,
1279
- (childItem) => {
1280
- resolveComponentData2(childItem, "load").then((resolved) => {
1281
- const { state: state2 } = get();
1282
- const node = state2.indexes.nodes[resolved.node.props.id];
1283
- if (node && resolved.didChange) {
1284
- if (resolved.node.props.id === "root") {
1285
- dispatch({
1286
- type: "replaceRoot",
1287
- root: toRoot(resolved.node)
1288
- });
1289
- } else {
1290
- const zoneCompound = `${node.parentId}:${node.zone}`;
1291
- const parentZone = state2.indexes.zones[zoneCompound];
1292
- const index = parentZone.contentIds.indexOf(
1293
- resolved.node.props.id
1294
- );
1295
- dispatch({
1296
- type: "replace",
1297
- data: resolved.node,
1298
- destinationIndex: index,
1299
- destinationZone: zoneCompound
1300
- });
1301
- }
1302
- }
1303
- });
1304
- return childItem;
1305
- }
1306
- );
1307
- })
1308
- });
1309
- })
1310
- );
1311
- var appStoreContext = createContext(createAppStore());
1312
- function useAppStore(selector) {
1313
- const context = useContext(appStoreContext);
1314
- return useStore(context, selector);
1315
- }
1316
- function useAppStoreApi() {
1317
- return useContext(appStoreContext);
1318
- }
1319
-
1320
- // components/IconButton/IconButton.tsx
1321
- init_react_import();
1322
- import { useState } from "react";
1323
-
1324
- // css-module:/home/runner/work/puck/puck/packages/core/components/IconButton/IconButton.module.css#css-module
433
+ // ../../node_modules/lucide-react/dist/esm/icons/redo-2.js
1325
434
  init_react_import();
1326
- var IconButton_module_default = { "IconButton": "_IconButton_ffob9_1", "IconButton--active": "_IconButton--active_ffob9_14", "IconButton--disabled": "_IconButton--disabled_ffob9_24", "IconButton-title": "_IconButton-title_ffob9_37" };
435
+ var Redo2 = createLucideIcon("Redo2", [
436
+ ["path", { d: "m15 14 5-5-5-5", key: "12vg1m" }],
437
+ ["path", { d: "M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13", key: "6uklza" }]
438
+ ]);
1327
439
 
1328
- // components/Loader/index.tsx
440
+ // ../../node_modules/lucide-react/dist/esm/icons/search.js
1329
441
  init_react_import();
442
+ var Search = createLucideIcon("Search", [
443
+ ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
444
+ ["path", { d: "m21 21-4.3-4.3", key: "1qie3q" }]
445
+ ]);
1330
446
 
1331
- // lib/index.ts
447
+ // ../../node_modules/lucide-react/dist/esm/icons/sliders-horizontal.js
1332
448
  init_react_import();
449
+ var SlidersHorizontal = createLucideIcon("SlidersHorizontal", [
450
+ ["line", { x1: "21", x2: "14", y1: "4", y2: "4", key: "obuewd" }],
451
+ ["line", { x1: "10", x2: "3", y1: "4", y2: "4", key: "1q6298" }],
452
+ ["line", { x1: "21", x2: "12", y1: "12", y2: "12", key: "1iu8h1" }],
453
+ ["line", { x1: "8", x2: "3", y1: "12", y2: "12", key: "ntss68" }],
454
+ ["line", { x1: "21", x2: "16", y1: "20", y2: "20", key: "14d8ph" }],
455
+ ["line", { x1: "12", x2: "3", y1: "20", y2: "20", key: "m0wm8r" }],
456
+ ["line", { x1: "14", x2: "14", y1: "2", y2: "6", key: "14e1ph" }],
457
+ ["line", { x1: "8", x2: "8", y1: "10", y2: "14", key: "1i6ji0" }],
458
+ ["line", { x1: "16", x2: "16", y1: "18", y2: "22", key: "1lctlv" }]
459
+ ]);
1333
460
 
1334
- // lib/filter.ts
461
+ // ../../node_modules/lucide-react/dist/esm/icons/smartphone.js
1335
462
  init_react_import();
463
+ var Smartphone = createLucideIcon("Smartphone", [
464
+ ["rect", { width: "14", height: "20", x: "5", y: "2", rx: "2", ry: "2", key: "1yt0o3" }],
465
+ ["path", { d: "M12 18h.01", key: "mhygvu" }]
466
+ ]);
1336
467
 
1337
- // lib/data/reorder.ts
468
+ // ../../node_modules/lucide-react/dist/esm/icons/square-code.js
1338
469
  init_react_import();
1339
- var reorder = (list, startIndex, endIndex) => {
1340
- const result = Array.from(list);
1341
- const [removed] = result.splice(startIndex, 1);
1342
- result.splice(endIndex, 0, removed);
1343
- return result;
1344
- };
470
+ var SquareCode = createLucideIcon("SquareCode", [
471
+ ["path", { d: "M10 9.5 8 12l2 2.5", key: "3mjy60" }],
472
+ ["path", { d: "m14 9.5 2 2.5-2 2.5", key: "1bir2l" }],
473
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }]
474
+ ]);
1345
475
 
1346
- // lib/data/replace.ts
476
+ // ../../node_modules/lucide-react/dist/esm/icons/strikethrough.js
1347
477
  init_react_import();
1348
- var replace = (list, index, newItem) => {
1349
- const result = Array.from(list);
1350
- result.splice(index, 1);
1351
- result.splice(index, 0, newItem);
1352
- return result;
1353
- };
478
+ var Strikethrough = createLucideIcon("Strikethrough", [
479
+ ["path", { d: "M16 4H9a3 3 0 0 0-2.83 4", key: "43sutm" }],
480
+ ["path", { d: "M14 12a4 4 0 0 1 0 8H6", key: "nlfj13" }],
481
+ ["line", { x1: "4", x2: "20", y1: "12", y2: "12", key: "1e0a9i" }]
482
+ ]);
1354
483
 
1355
- // lib/use-reset-auto-zoom.ts
484
+ // ../../node_modules/lucide-react/dist/esm/icons/tablet.js
1356
485
  init_react_import();
486
+ var Tablet = createLucideIcon("Tablet", [
487
+ ["rect", { width: "16", height: "20", x: "4", y: "2", rx: "2", ry: "2", key: "76otgf" }],
488
+ ["line", { x1: "12", x2: "12.01", y1: "18", y2: "18", key: "1dp563" }]
489
+ ]);
1357
490
 
1358
- // lib/get-zoom-config.ts
491
+ // ../../node_modules/lucide-react/dist/esm/icons/trash.js
1359
492
  init_react_import();
493
+ var Trash = createLucideIcon("Trash", [
494
+ ["path", { d: "M3 6h18", key: "d0wm0j" }],
495
+ ["path", { d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6", key: "4alrt4" }],
496
+ ["path", { d: "M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2", key: "v07s0e" }]
497
+ ]);
1360
498
 
1361
- // ../../node_modules/css-box-model/dist/css-box-model.esm.js
499
+ // ../../node_modules/lucide-react/dist/esm/icons/type.js
1362
500
  init_react_import();
501
+ var Type = createLucideIcon("Type", [
502
+ ["polyline", { points: "4 7 4 4 20 4 20 7", key: "1nosan" }],
503
+ ["line", { x1: "9", x2: "15", y1: "20", y2: "20", key: "swin9y" }],
504
+ ["line", { x1: "12", x2: "12", y1: "4", y2: "20", key: "1tx1rr" }]
505
+ ]);
1363
506
 
1364
- // ../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
1365
- init_react_import();
1366
- var isProduction = process.env.NODE_ENV === "production";
1367
- var prefix = "Invariant failed";
1368
- function invariant(condition, message) {
1369
- if (condition) {
1370
- return;
1371
- }
1372
- if (isProduction) {
1373
- throw new Error(prefix);
1374
- }
1375
- var provided = typeof message === "function" ? message() : message;
1376
- var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
1377
- throw new Error(value);
1378
- }
1379
-
1380
- // ../../node_modules/css-box-model/dist/css-box-model.esm.js
1381
- var getRect = function getRect2(_ref) {
1382
- var top = _ref.top, right = _ref.right, bottom = _ref.bottom, left = _ref.left;
1383
- var width = right - left;
1384
- var height = bottom - top;
1385
- var rect = {
1386
- top,
1387
- right,
1388
- bottom,
1389
- left,
1390
- width,
1391
- height,
1392
- x: left,
1393
- y: top,
1394
- center: {
1395
- x: (right + left) / 2,
1396
- y: (bottom + top) / 2
1397
- }
1398
- };
1399
- return rect;
1400
- };
1401
- var expand = function expand2(target, expandBy) {
1402
- return {
1403
- top: target.top - expandBy.top,
1404
- left: target.left - expandBy.left,
1405
- bottom: target.bottom + expandBy.bottom,
1406
- right: target.right + expandBy.right
1407
- };
1408
- };
1409
- var shrink = function shrink2(target, shrinkBy) {
1410
- return {
1411
- top: target.top + shrinkBy.top,
1412
- left: target.left + shrinkBy.left,
1413
- bottom: target.bottom - shrinkBy.bottom,
1414
- right: target.right - shrinkBy.right
1415
- };
1416
- };
1417
- var noSpacing = {
1418
- top: 0,
1419
- right: 0,
1420
- bottom: 0,
1421
- left: 0
1422
- };
1423
- var createBox = function createBox2(_ref2) {
1424
- var borderBox = _ref2.borderBox, _ref2$margin = _ref2.margin, margin = _ref2$margin === void 0 ? noSpacing : _ref2$margin, _ref2$border = _ref2.border, border = _ref2$border === void 0 ? noSpacing : _ref2$border, _ref2$padding = _ref2.padding, padding = _ref2$padding === void 0 ? noSpacing : _ref2$padding;
1425
- var marginBox = getRect(expand(borderBox, margin));
1426
- var paddingBox = getRect(shrink(borderBox, border));
1427
- var contentBox = getRect(shrink(paddingBox, padding));
1428
- return {
1429
- marginBox,
1430
- borderBox: getRect(borderBox),
1431
- paddingBox,
1432
- contentBox,
1433
- margin,
1434
- border,
1435
- padding
1436
- };
1437
- };
1438
- var parse = function parse2(raw) {
1439
- var value = raw.slice(0, -2);
1440
- var suffix = raw.slice(-2);
1441
- if (suffix !== "px") {
1442
- return 0;
1443
- }
1444
- var result = Number(value);
1445
- !!isNaN(result) ? process.env.NODE_ENV !== "production" ? invariant(false, "Could not parse value [raw: " + raw + ", without suffix: " + value + "]") : invariant(false) : void 0;
1446
- return result;
1447
- };
1448
- var calculateBox = function calculateBox2(borderBox, styles) {
1449
- var margin = {
1450
- top: parse(styles.marginTop),
1451
- right: parse(styles.marginRight),
1452
- bottom: parse(styles.marginBottom),
1453
- left: parse(styles.marginLeft)
1454
- };
1455
- var padding = {
1456
- top: parse(styles.paddingTop),
1457
- right: parse(styles.paddingRight),
1458
- bottom: parse(styles.paddingBottom),
1459
- left: parse(styles.paddingLeft)
1460
- };
1461
- var border = {
1462
- top: parse(styles.borderTopWidth),
1463
- right: parse(styles.borderRightWidth),
1464
- bottom: parse(styles.borderBottomWidth),
1465
- left: parse(styles.borderLeftWidth)
1466
- };
1467
- return createBox({
1468
- borderBox,
1469
- margin,
1470
- padding,
1471
- border
1472
- });
1473
- };
1474
- var getBox = function getBox2(el) {
1475
- var borderBox = el.getBoundingClientRect();
1476
- var styles = window.getComputedStyle(el);
1477
- return calculateBox(borderBox, styles);
1478
- };
1479
-
1480
- // lib/get-zoom-config.ts
1481
- var RESET_ZOOM_SMALLER_THAN_FRAME = true;
1482
- var getZoomConfig = (uiViewport, frame, zoom) => {
1483
- const box = getBox(frame);
1484
- const { width: frameWidth, height: frameHeight } = box.contentBox;
1485
- const viewportHeight = uiViewport.height === "auto" ? frameHeight : uiViewport.height;
1486
- let rootHeight = 0;
1487
- let autoZoom = 1;
1488
- if (uiViewport.width > frameWidth || viewportHeight > frameHeight) {
1489
- const widthZoom = Math.min(frameWidth / uiViewport.width, 1);
1490
- const heightZoom = Math.min(frameHeight / viewportHeight, 1);
1491
- zoom = widthZoom;
1492
- if (widthZoom < heightZoom) {
1493
- rootHeight = viewportHeight / zoom;
1494
- } else {
1495
- rootHeight = viewportHeight;
1496
- zoom = heightZoom;
1497
- }
1498
- autoZoom = zoom;
1499
- } else {
1500
- if (RESET_ZOOM_SMALLER_THAN_FRAME) {
1501
- autoZoom = 1;
1502
- zoom = 1;
1503
- rootHeight = viewportHeight;
1504
- }
1505
- }
1506
- return { autoZoom, rootHeight, zoom };
1507
- };
1508
-
1509
- // lib/use-reset-auto-zoom.ts
1510
- var useResetAutoZoom = (frameRef) => {
1511
- const appStoreApi = useAppStoreApi();
1512
- const resetAutoZoom = (options) => {
1513
- const { state, zoomConfig, setZoomConfig } = appStoreApi.getState();
1514
- const { viewports } = state.ui;
1515
- const newViewports = (options == null ? void 0 : options.viewports) || viewports;
1516
- if (frameRef.current) {
1517
- setZoomConfig(
1518
- getZoomConfig(newViewports == null ? void 0 : newViewports.current, frameRef.current, zoomConfig.zoom)
1519
- );
1520
- }
1521
- };
1522
- return resetAutoZoom;
1523
- };
1524
-
1525
- // css-module:/home/runner/work/puck/puck/packages/core/components/Loader/styles.module.css#css-module
1526
- init_react_import();
1527
- var styles_module_default3 = { "Loader": "_Loader_nacdm_13", "loader-animation": "_loader-animation_nacdm_1" };
1528
-
1529
- // components/Loader/index.tsx
1530
- import { jsx as jsx2 } from "react/jsx-runtime";
1531
- var getClassName2 = get_class_name_factory_default("Loader", styles_module_default3);
1532
- var Loader = (_a) => {
1533
- var _b = _a, {
1534
- color,
1535
- size = 16
1536
- } = _b, props = __objRest(_b, [
1537
- "color",
1538
- "size"
1539
- ]);
1540
- return /* @__PURE__ */ jsx2(
1541
- "span",
1542
- __spreadValues({
1543
- className: getClassName2(),
1544
- style: {
1545
- width: size,
1546
- height: size,
1547
- color
1548
- },
1549
- "aria-label": "loading"
1550
- }, props)
1551
- );
1552
- };
1553
-
1554
- // components/IconButton/IconButton.tsx
1555
- import { Fragment, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
1556
- var getClassName3 = get_class_name_factory_default("IconButton", IconButton_module_default);
1557
- var IconButton = ({
1558
- active = false,
1559
- children,
1560
- href,
1561
- onClick,
1562
- type,
1563
- disabled,
1564
- tabIndex,
1565
- newTab,
1566
- fullWidth,
1567
- title
1568
- }) => {
1569
- const [loading, setLoading] = useState(false);
1570
- const ElementType = href ? "a" : "button";
1571
- const el = /* @__PURE__ */ jsxs2(
1572
- ElementType,
1573
- {
1574
- className: getClassName3({
1575
- active,
1576
- disabled,
1577
- fullWidth
1578
- }),
1579
- onClick: (e) => {
1580
- if (!onClick) return;
1581
- setLoading(true);
1582
- Promise.resolve(onClick(e)).then(() => {
1583
- setLoading(false);
1584
- });
1585
- },
1586
- type,
1587
- disabled: disabled || loading,
1588
- tabIndex,
1589
- target: newTab ? "_blank" : void 0,
1590
- rel: newTab ? "noreferrer" : void 0,
1591
- href,
1592
- title,
1593
- children: [
1594
- /* @__PURE__ */ jsx3("span", { className: getClassName3("title"), children: title }),
1595
- children,
1596
- loading && /* @__PURE__ */ jsxs2(Fragment, { children: [
1597
- "\xA0\xA0",
1598
- /* @__PURE__ */ jsx3(Loader, { size: 14 })
1599
- ] })
1600
- ]
1601
- }
1602
- );
1603
- return el;
1604
- };
1605
-
1606
- // components/RichTextMenu/inner.tsx
1607
- init_react_import();
1608
-
1609
- // css-module:/home/runner/work/puck/puck/packages/core/components/RichTextMenu/styles.module.css#css-module
1610
- init_react_import();
1611
- var styles_module_default4 = { "RichTextMenu": "_RichTextMenu_k97eh_1", "RichTextMenu--form": "_RichTextMenu--form_k97eh_7", "RichTextMenu-group": "_RichTextMenu-group_k97eh_17", "RichTextMenu--inline": "_RichTextMenu--inline_k97eh_35" };
1612
-
1613
- // components/RichTextMenu/inner.tsx
1614
- import { useMemo as useMemo5 } from "react";
1615
-
1616
- // components/RichTextMenu/controls/index.ts
507
+ // ../../node_modules/lucide-react/dist/esm/icons/underline.js
1617
508
  init_react_import();
509
+ var Underline = createLucideIcon("Underline", [
510
+ ["path", { d: "M6 4v6a6 6 0 0 0 12 0V4", key: "9kb039" }],
511
+ ["line", { x1: "4", x2: "20", y1: "20", y2: "20", key: "nun2al" }]
512
+ ]);
1618
513
 
1619
- // components/RichTextMenu/controls/AlignLeft.tsx
514
+ // ../../node_modules/lucide-react/dist/esm/icons/undo-2.js
1620
515
  init_react_import();
516
+ var Undo2 = createLucideIcon("Undo2", [
517
+ ["path", { d: "M9 14 4 9l5-5", key: "102s5s" }],
518
+ ["path", { d: "M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11", key: "f3b9sd" }]
519
+ ]);
1621
520
 
1622
- // ../../node_modules/lucide-react/dist/esm/lucide-react.js
521
+ // ../../node_modules/lucide-react/dist/esm/icons/zoom-in.js
1623
522
  init_react_import();
523
+ var ZoomIn = createLucideIcon("ZoomIn", [
524
+ ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
525
+ ["line", { x1: "21", x2: "16.65", y1: "21", y2: "16.65", key: "13gj7c" }],
526
+ ["line", { x1: "11", x2: "11", y1: "8", y2: "14", key: "1vmskp" }],
527
+ ["line", { x1: "8", x2: "14", y1: "11", y2: "11", key: "durymu" }]
528
+ ]);
1624
529
 
1625
- // ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
530
+ // ../../node_modules/lucide-react/dist/esm/icons/zoom-out.js
1626
531
  init_react_import();
1627
- import { forwardRef as forwardRef2, createElement as createElement2 } from "react";
532
+ var ZoomOut = createLucideIcon("ZoomOut", [
533
+ ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
534
+ ["line", { x1: "21", x2: "16.65", y1: "21", y2: "16.65", key: "13gj7c" }],
535
+ ["line", { x1: "8", x2: "14", y1: "11", y2: "11", key: "durymu" }]
536
+ ]);
1628
537
 
1629
- // ../../node_modules/lucide-react/dist/esm/shared/src/utils.js
538
+ // store/index.ts
1630
539
  init_react_import();
1631
- var toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
1632
- var mergeClasses = (...classes) => classes.filter((className, index, array) => {
1633
- return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
1634
- }).join(" ").trim();
540
+ import { create as create2, useStore } from "zustand";
541
+ import { subscribeWithSelector as subscribeWithSelector2 } from "zustand/middleware";
542
+ import { createContext, useContext } from "react";
1635
543
 
1636
- // ../../node_modules/lucide-react/dist/esm/Icon.js
544
+ // store/slices/history.ts
1637
545
  init_react_import();
1638
- import { forwardRef, createElement } from "react";
546
+ import { useEffect as useEffect2 } from "react";
1639
547
 
1640
- // ../../node_modules/lucide-react/dist/esm/defaultAttributes.js
548
+ // lib/use-hotkey.ts
1641
549
  init_react_import();
1642
- var defaultAttributes = {
1643
- xmlns: "http://www.w3.org/2000/svg",
1644
- width: 24,
1645
- height: 24,
1646
- viewBox: "0 0 24 24",
1647
- fill: "none",
1648
- stroke: "currentColor",
1649
- strokeWidth: 2,
1650
- strokeLinecap: "round",
1651
- strokeLinejoin: "round"
1652
- };
1653
-
1654
- // ../../node_modules/lucide-react/dist/esm/Icon.js
1655
- var Icon = forwardRef(
1656
- (_a, ref) => {
1657
- var _b = _a, {
1658
- color = "currentColor",
1659
- size = 24,
1660
- strokeWidth = 2,
1661
- absoluteStrokeWidth,
1662
- className = "",
1663
- children,
1664
- iconNode
1665
- } = _b, rest = __objRest(_b, [
1666
- "color",
1667
- "size",
1668
- "strokeWidth",
1669
- "absoluteStrokeWidth",
1670
- "className",
1671
- "children",
1672
- "iconNode"
1673
- ]);
1674
- return createElement(
1675
- "svg",
1676
- __spreadValues(__spreadProps(__spreadValues({
1677
- ref
1678
- }, defaultAttributes), {
1679
- width: size,
1680
- height: size,
1681
- stroke: color,
1682
- strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
1683
- className: mergeClasses("lucide", className)
1684
- }), rest),
1685
- [
1686
- ...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),
1687
- ...Array.isArray(children) ? children : [children]
1688
- ]
1689
- );
1690
- }
550
+ import { useEffect } from "react";
551
+ import { create } from "zustand";
552
+ import { subscribeWithSelector } from "zustand/middleware";
553
+ var keyCodeMap = {
554
+ ControlLeft: "ctrl",
555
+ ControlRight: "ctrl",
556
+ MetaLeft: "meta",
557
+ MetaRight: "meta",
558
+ ShiftLeft: "shift",
559
+ ShiftRight: "shift",
560
+ KeyA: "a",
561
+ KeyB: "b",
562
+ KeyC: "c",
563
+ KeyD: "d",
564
+ KeyE: "e",
565
+ KeyF: "f",
566
+ KeyG: "g",
567
+ KeyH: "h",
568
+ KeyI: "i",
569
+ KeyJ: "j",
570
+ KeyK: "k",
571
+ KeyL: "l",
572
+ KeyM: "m",
573
+ KeyN: "n",
574
+ KeyO: "o",
575
+ KeyP: "p",
576
+ KeyQ: "q",
577
+ KeyR: "r",
578
+ KeyS: "s",
579
+ KeyT: "t",
580
+ KeyU: "u",
581
+ KeyV: "v",
582
+ KeyW: "w",
583
+ KeyX: "x",
584
+ KeyY: "y",
585
+ KeyZ: "z",
586
+ Delete: "delete",
587
+ Backspace: "backspace"
588
+ };
589
+ var useHotkeyStore = create()(
590
+ subscribeWithSelector((set) => ({
591
+ held: {},
592
+ hold: (key) => set((s) => s.held[key] ? s : { held: __spreadProps(__spreadValues({}, s.held), { [key]: true }) }),
593
+ release: (key) => set((s) => s.held[key] ? { held: __spreadProps(__spreadValues({}, s.held), { [key]: false }) } : s),
594
+ reset: (held = {}) => set(() => ({ held })),
595
+ triggers: {}
596
+ }))
1691
597
  );
1692
-
1693
- // ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
1694
- var createLucideIcon = (iconName, iconNode) => {
1695
- const Component = forwardRef2(
1696
- (_a, ref) => {
1697
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1698
- return createElement2(Icon, __spreadValues({
1699
- ref,
1700
- iconNode,
1701
- className: mergeClasses(`lucide-${toKebabCase(iconName)}`, className)
1702
- }, props));
598
+ var monitorHotkeys = (doc) => {
599
+ const onKeyDown = (e) => {
600
+ const key = keyCodeMap[e.code];
601
+ if (key) {
602
+ useHotkeyStore.getState().hold(key);
603
+ const { held, triggers } = useHotkeyStore.getState();
604
+ Object.values(triggers).forEach(({ combo, cb }) => {
605
+ const conditionMet = Object.entries(combo).every(
606
+ ([key2, value]) => value === !!held[key2]
607
+ ) && Object.entries(held).every(
608
+ ([key2, value]) => value === !!combo[key2]
609
+ );
610
+ if (conditionMet) {
611
+ const handled = cb(e);
612
+ if (handled !== false) {
613
+ e.preventDefault();
614
+ }
615
+ }
616
+ });
617
+ if (key !== "meta" && key !== "ctrl" && key !== "shift") {
618
+ useHotkeyStore.getState().release(key);
619
+ }
620
+ }
621
+ };
622
+ const onKeyUp = (e) => {
623
+ const key = keyCodeMap[e.code];
624
+ if (key) {
625
+ if (key === "meta") {
626
+ useHotkeyStore.getState().reset();
627
+ } else {
628
+ useHotkeyStore.getState().release(key);
629
+ }
630
+ }
631
+ };
632
+ const onVisibilityChanged = (e) => {
633
+ if (document.visibilityState === "hidden") {
634
+ useHotkeyStore.getState().reset();
1703
635
  }
636
+ };
637
+ const onBlur = () => {
638
+ useHotkeyStore.getState().reset();
639
+ };
640
+ window.addEventListener("blur", onBlur);
641
+ doc.addEventListener("keydown", onKeyDown);
642
+ doc.addEventListener("keyup", onKeyUp);
643
+ doc.addEventListener("visibilitychange", onVisibilityChanged);
644
+ return () => {
645
+ doc.removeEventListener("keydown", onKeyDown);
646
+ doc.removeEventListener("keyup", onKeyUp);
647
+ doc.removeEventListener("visibilitychange", onVisibilityChanged);
648
+ window.removeEventListener("blur", onBlur);
649
+ };
650
+ };
651
+ var useMonitorHotkeys = () => {
652
+ useEffect(() => monitorHotkeys(document), []);
653
+ };
654
+ var useHotkey = (combo, cb) => {
655
+ useEffect(
656
+ () => useHotkeyStore.setState((s) => ({
657
+ triggers: __spreadProps(__spreadValues({}, s.triggers), {
658
+ [`${Object.keys(combo).join("+")}`]: { combo, cb }
659
+ })
660
+ })),
661
+ []
1704
662
  );
1705
- Component.displayName = `${iconName}`;
1706
- return Component;
1707
663
  };
1708
664
 
1709
- // ../../node_modules/lucide-react/dist/esm/icons/align-center.js
1710
- init_react_import();
1711
- var AlignCenter = createLucideIcon("AlignCenter", [
1712
- ["path", { d: "M17 12H7", key: "16if0g" }],
1713
- ["path", { d: "M19 18H5", key: "18s9l3" }],
1714
- ["path", { d: "M21 6H3", key: "1jwq7v" }]
1715
- ]);
1716
-
1717
- // ../../node_modules/lucide-react/dist/esm/icons/align-justify.js
1718
- init_react_import();
1719
- var AlignJustify = createLucideIcon("AlignJustify", [
1720
- ["path", { d: "M3 12h18", key: "1i2n21" }],
1721
- ["path", { d: "M3 18h18", key: "1h113x" }],
1722
- ["path", { d: "M3 6h18", key: "d0wm0j" }]
1723
- ]);
1724
-
1725
- // ../../node_modules/lucide-react/dist/esm/icons/align-left.js
1726
- init_react_import();
1727
- var AlignLeft = createLucideIcon("AlignLeft", [
1728
- ["path", { d: "M15 12H3", key: "6jk70r" }],
1729
- ["path", { d: "M17 18H3", key: "1amg6g" }],
1730
- ["path", { d: "M21 6H3", key: "1jwq7v" }]
1731
- ]);
1732
-
1733
- // ../../node_modules/lucide-react/dist/esm/icons/align-right.js
1734
- init_react_import();
1735
- var AlignRight = createLucideIcon("AlignRight", [
1736
- ["path", { d: "M21 12H9", key: "dn1m92" }],
1737
- ["path", { d: "M21 18H7", key: "1ygte8" }],
1738
- ["path", { d: "M21 6H3", key: "1jwq7v" }]
1739
- ]);
1740
-
1741
- // ../../node_modules/lucide-react/dist/esm/icons/bold.js
1742
- init_react_import();
1743
- var Bold = createLucideIcon("Bold", [
1744
- [
1745
- "path",
1746
- { d: "M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8", key: "mg9rjx" }
1747
- ]
1748
- ]);
1749
-
1750
- // ../../node_modules/lucide-react/dist/esm/icons/chevron-down.js
1751
- init_react_import();
1752
- var ChevronDown = createLucideIcon("ChevronDown", [
1753
- ["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]
1754
- ]);
1755
-
1756
- // ../../node_modules/lucide-react/dist/esm/icons/chevron-right.js
1757
- init_react_import();
1758
- var ChevronRight = createLucideIcon("ChevronRight", [
1759
- ["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]
1760
- ]);
1761
-
1762
- // ../../node_modules/lucide-react/dist/esm/icons/chevron-up.js
1763
- init_react_import();
1764
- var ChevronUp = createLucideIcon("ChevronUp", [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]]);
1765
-
1766
- // ../../node_modules/lucide-react/dist/esm/icons/circle-check-big.js
1767
- init_react_import();
1768
- var CircleCheckBig = createLucideIcon("CircleCheckBig", [
1769
- ["path", { d: "M21.801 10A10 10 0 1 1 17 3.335", key: "yps3ct" }],
1770
- ["path", { d: "m9 11 3 3L22 4", key: "1pflzl" }]
1771
- ]);
1772
-
1773
- // ../../node_modules/lucide-react/dist/esm/icons/code.js
1774
- init_react_import();
1775
- var Code = createLucideIcon("Code", [
1776
- ["polyline", { points: "16 18 22 12 16 6", key: "z7tu5w" }],
1777
- ["polyline", { points: "8 6 2 12 8 18", key: "1eg1df" }]
1778
- ]);
1779
-
1780
- // ../../node_modules/lucide-react/dist/esm/icons/copy.js
1781
- init_react_import();
1782
- var Copy = createLucideIcon("Copy", [
1783
- ["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
1784
- ["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2", key: "zix9uf" }]
1785
- ]);
1786
-
1787
- // ../../node_modules/lucide-react/dist/esm/icons/corner-left-up.js
1788
- init_react_import();
1789
- var CornerLeftUp = createLucideIcon("CornerLeftUp", [
1790
- ["polyline", { points: "14 9 9 4 4 9", key: "m9oyvo" }],
1791
- ["path", { d: "M20 20h-7a4 4 0 0 1-4-4V4", key: "1blwi3" }]
1792
- ]);
1793
-
1794
- // ../../node_modules/lucide-react/dist/esm/icons/ellipsis-vertical.js
1795
- init_react_import();
1796
- var EllipsisVertical = createLucideIcon("EllipsisVertical", [
1797
- ["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
1798
- ["circle", { cx: "12", cy: "5", r: "1", key: "gxeob9" }],
1799
- ["circle", { cx: "12", cy: "19", r: "1", key: "lyex9k" }]
1800
- ]);
1801
-
1802
- // ../../node_modules/lucide-react/dist/esm/icons/globe.js
1803
- init_react_import();
1804
- var Globe = createLucideIcon("Globe", [
1805
- ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
1806
- ["path", { d: "M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20", key: "13o1zl" }],
1807
- ["path", { d: "M2 12h20", key: "9i4pu4" }]
1808
- ]);
1809
-
1810
- // ../../node_modules/lucide-react/dist/esm/icons/hash.js
1811
- init_react_import();
1812
- var Hash = createLucideIcon("Hash", [
1813
- ["line", { x1: "4", x2: "20", y1: "9", y2: "9", key: "4lhtct" }],
1814
- ["line", { x1: "4", x2: "20", y1: "15", y2: "15", key: "vyu0kd" }],
1815
- ["line", { x1: "10", x2: "8", y1: "3", y2: "21", key: "1ggp8o" }],
1816
- ["line", { x1: "16", x2: "14", y1: "3", y2: "21", key: "weycgp" }]
1817
- ]);
1818
-
1819
- // ../../node_modules/lucide-react/dist/esm/icons/heading-1.js
1820
- init_react_import();
1821
- var Heading1 = createLucideIcon("Heading1", [
1822
- ["path", { d: "M4 12h8", key: "17cfdx" }],
1823
- ["path", { d: "M4 18V6", key: "1rz3zl" }],
1824
- ["path", { d: "M12 18V6", key: "zqpxq5" }],
1825
- ["path", { d: "m17 12 3-2v8", key: "1hhhft" }]
1826
- ]);
1827
-
1828
- // ../../node_modules/lucide-react/dist/esm/icons/heading-2.js
1829
- init_react_import();
1830
- var Heading2 = createLucideIcon("Heading2", [
1831
- ["path", { d: "M4 12h8", key: "17cfdx" }],
1832
- ["path", { d: "M4 18V6", key: "1rz3zl" }],
1833
- ["path", { d: "M12 18V6", key: "zqpxq5" }],
1834
- ["path", { d: "M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1", key: "9jr5yi" }]
1835
- ]);
1836
-
1837
- // ../../node_modules/lucide-react/dist/esm/icons/heading-3.js
1838
- init_react_import();
1839
- var Heading3 = createLucideIcon("Heading3", [
1840
- ["path", { d: "M4 12h8", key: "17cfdx" }],
1841
- ["path", { d: "M4 18V6", key: "1rz3zl" }],
1842
- ["path", { d: "M12 18V6", key: "zqpxq5" }],
1843
- ["path", { d: "M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2", key: "68ncm8" }],
1844
- ["path", { d: "M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2", key: "1ejuhz" }]
1845
- ]);
1846
-
1847
- // ../../node_modules/lucide-react/dist/esm/icons/heading-4.js
1848
- init_react_import();
1849
- var Heading4 = createLucideIcon("Heading4", [
1850
- ["path", { d: "M12 18V6", key: "zqpxq5" }],
1851
- ["path", { d: "M17 10v3a1 1 0 0 0 1 1h3", key: "tj5zdr" }],
1852
- ["path", { d: "M21 10v8", key: "1kdml4" }],
1853
- ["path", { d: "M4 12h8", key: "17cfdx" }],
1854
- ["path", { d: "M4 18V6", key: "1rz3zl" }]
1855
- ]);
1856
-
1857
- // ../../node_modules/lucide-react/dist/esm/icons/heading-5.js
1858
- init_react_import();
1859
- var Heading5 = createLucideIcon("Heading5", [
1860
- ["path", { d: "M4 12h8", key: "17cfdx" }],
1861
- ["path", { d: "M4 18V6", key: "1rz3zl" }],
1862
- ["path", { d: "M12 18V6", key: "zqpxq5" }],
1863
- ["path", { d: "M17 13v-3h4", key: "1nvgqp" }],
1864
- [
1865
- "path",
1866
- { d: "M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17", key: "2nebdn" }
1867
- ]
1868
- ]);
1869
-
1870
- // ../../node_modules/lucide-react/dist/esm/icons/heading-6.js
1871
- init_react_import();
1872
- var Heading6 = createLucideIcon("Heading6", [
1873
- ["path", { d: "M4 12h8", key: "17cfdx" }],
1874
- ["path", { d: "M4 18V6", key: "1rz3zl" }],
1875
- ["path", { d: "M12 18V6", key: "zqpxq5" }],
1876
- ["circle", { cx: "19", cy: "16", r: "2", key: "15mx69" }],
1877
- ["path", { d: "M20 10c-2 2-3 3.5-3 6", key: "f35dl0" }]
1878
- ]);
665
+ // store/slices/history.ts
666
+ var EMPTY_HISTORY_INDEX = 0;
667
+ function debounce(func, timeout = 300) {
668
+ let timer;
669
+ return (...args) => {
670
+ clearTimeout(timer);
671
+ timer = setTimeout(() => {
672
+ func(...args);
673
+ }, timeout);
674
+ };
675
+ }
676
+ var tidyState = (state) => {
677
+ return __spreadProps(__spreadValues({}, state), {
678
+ ui: __spreadProps(__spreadValues({}, state.ui), {
679
+ field: __spreadProps(__spreadValues({}, state.ui.field), {
680
+ focus: null
681
+ })
682
+ })
683
+ });
684
+ };
685
+ var createHistorySlice = (set, get) => {
686
+ const record = debounce((state) => {
687
+ const { histories, index } = get().history;
688
+ const history = {
689
+ state,
690
+ id: generateId("history")
691
+ };
692
+ const newHistories = [...histories.slice(0, index + 1), history];
693
+ set({
694
+ history: __spreadProps(__spreadValues({}, get().history), {
695
+ histories: newHistories,
696
+ index: newHistories.length - 1
697
+ })
698
+ });
699
+ }, 250);
700
+ return {
701
+ initialAppState: {},
702
+ index: EMPTY_HISTORY_INDEX,
703
+ histories: [],
704
+ hasPast: () => get().history.index > EMPTY_HISTORY_INDEX,
705
+ hasFuture: () => get().history.index < get().history.histories.length - 1,
706
+ prevHistory: () => {
707
+ const { history } = get();
708
+ return history.hasPast() ? history.histories[history.index - 1] : null;
709
+ },
710
+ nextHistory: () => {
711
+ const s = get().history;
712
+ return s.hasFuture() ? s.histories[s.index + 1] : null;
713
+ },
714
+ currentHistory: () => get().history.histories[get().history.index],
715
+ back: () => {
716
+ var _a;
717
+ const { history, dispatch } = get();
718
+ if (history.hasPast()) {
719
+ const state = tidyState(
720
+ ((_a = history.prevHistory()) == null ? void 0 : _a.state) || history.initialAppState
721
+ );
722
+ dispatch({
723
+ type: "set",
724
+ state
725
+ });
726
+ set({ history: __spreadProps(__spreadValues({}, history), { index: history.index - 1 }) });
727
+ }
728
+ },
729
+ forward: () => {
730
+ var _a;
731
+ const { history, dispatch } = get();
732
+ if (history.hasFuture()) {
733
+ const state = (_a = history.nextHistory()) == null ? void 0 : _a.state;
734
+ dispatch({ type: "set", state: state ? tidyState(state) : {} });
735
+ set({ history: __spreadProps(__spreadValues({}, history), { index: history.index + 1 }) });
736
+ }
737
+ },
738
+ setHistories: (histories) => {
739
+ var _a;
740
+ const { dispatch, history } = get();
741
+ dispatch({
742
+ type: "set",
743
+ state: ((_a = histories[histories.length - 1]) == null ? void 0 : _a.state) || history.initialAppState
744
+ });
745
+ set({ history: __spreadProps(__spreadValues({}, history), { histories, index: histories.length - 1 }) });
746
+ },
747
+ setHistoryIndex: (index) => {
748
+ var _a;
749
+ const { dispatch, history } = get();
750
+ dispatch({
751
+ type: "set",
752
+ state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
753
+ });
754
+ set({ history: __spreadProps(__spreadValues({}, history), { index }) });
755
+ },
756
+ record
757
+ };
758
+ };
759
+ function useRegisterHistorySlice(appStore, {
760
+ histories,
761
+ index,
762
+ initialAppState
763
+ }) {
764
+ useEffect2(
765
+ () => appStore.setState({
766
+ history: __spreadProps(__spreadValues({}, appStore.getState().history), {
767
+ histories,
768
+ index,
769
+ initialAppState
770
+ })
771
+ }),
772
+ [histories, index, initialAppState]
773
+ );
774
+ const back = () => {
775
+ appStore.getState().history.back();
776
+ };
777
+ const forward = () => {
778
+ appStore.getState().history.forward();
779
+ };
780
+ useHotkey({ meta: true, z: true }, back);
781
+ useHotkey({ meta: true, shift: true, z: true }, forward);
782
+ useHotkey({ meta: true, y: true }, forward);
783
+ useHotkey({ ctrl: true, z: true }, back);
784
+ useHotkey({ ctrl: true, shift: true, z: true }, forward);
785
+ useHotkey({ ctrl: true, y: true }, forward);
786
+ }
1879
787
 
1880
- // ../../node_modules/lucide-react/dist/esm/icons/heading.js
788
+ // store/slices/nodes.ts
1881
789
  init_react_import();
1882
- var Heading = createLucideIcon("Heading", [
1883
- ["path", { d: "M6 12h12", key: "8npq4p" }],
1884
- ["path", { d: "M6 20V4", key: "1w1bmo" }],
1885
- ["path", { d: "M18 20V4", key: "o2hl4u" }]
1886
- ]);
790
+ var createNodesSlice = (set, get) => ({
791
+ nodes: {},
792
+ registerNode: (id, node) => {
793
+ const s = get().nodes;
794
+ const emptyNode = {
795
+ id,
796
+ methods: {
797
+ sync: () => null,
798
+ hideOverlay: () => null,
799
+ showOverlay: () => null
800
+ },
801
+ element: null
802
+ };
803
+ const existingNode = s.nodes[id];
804
+ set({
805
+ nodes: __spreadProps(__spreadValues({}, s), {
806
+ nodes: __spreadProps(__spreadValues({}, s.nodes), {
807
+ [id]: __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, emptyNode), existingNode), node), {
808
+ id
809
+ })
810
+ })
811
+ })
812
+ });
813
+ },
814
+ unregisterNode: (id) => {
815
+ const s = get().nodes;
816
+ const existingNode = s.nodes[id];
817
+ if (existingNode) {
818
+ const newNodes = __spreadValues({}, s.nodes);
819
+ delete newNodes[id];
820
+ set({
821
+ nodes: __spreadProps(__spreadValues({}, s), {
822
+ nodes: newNodes
823
+ })
824
+ });
825
+ }
826
+ }
827
+ });
1887
828
 
1888
- // ../../node_modules/lucide-react/dist/esm/icons/italic.js
829
+ // store/slices/permissions.ts
1889
830
  init_react_import();
1890
- var Italic = createLucideIcon("Italic", [
1891
- ["line", { x1: "19", x2: "10", y1: "4", y2: "4", key: "15jd3p" }],
1892
- ["line", { x1: "14", x2: "5", y1: "20", y2: "20", key: "bu0au3" }],
1893
- ["line", { x1: "15", x2: "9", y1: "4", y2: "20", key: "uljnxc" }]
1894
- ]);
831
+ import { useEffect as useEffect3 } from "react";
1895
832
 
1896
- // ../../node_modules/lucide-react/dist/esm/icons/layers.js
833
+ // lib/data/flatten-data.ts
1897
834
  init_react_import();
1898
- var Layers = createLucideIcon("Layers", [
1899
- [
1900
- "path",
1901
- {
1902
- d: "M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",
1903
- key: "zw3jo"
835
+ var flattenData = (state, config) => {
836
+ const data = [];
837
+ walkAppState(
838
+ state,
839
+ config,
840
+ (content) => content,
841
+ (item) => {
842
+ data.push(item);
843
+ return item;
1904
844
  }
1905
- ],
1906
- [
1907
- "path",
1908
- {
1909
- d: "M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",
1910
- key: "1wduqc"
1911
- }
1912
- ],
1913
- [
1914
- "path",
1915
- {
1916
- d: "M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",
1917
- key: "kqbvx6"
1918
- }
1919
- ]
1920
- ]);
845
+ );
846
+ return data;
847
+ };
1921
848
 
1922
- // ../../node_modules/lucide-react/dist/esm/icons/layout-grid.js
1923
- init_react_import();
1924
- var LayoutGrid = createLucideIcon("LayoutGrid", [
1925
- ["rect", { width: "7", height: "7", x: "3", y: "3", rx: "1", key: "1g98yp" }],
1926
- ["rect", { width: "7", height: "7", x: "14", y: "3", rx: "1", key: "6d4xhi" }],
1927
- ["rect", { width: "7", height: "7", x: "14", y: "14", rx: "1", key: "nxv5o0" }],
1928
- ["rect", { width: "7", height: "7", x: "3", y: "14", rx: "1", key: "1bb6yr" }]
1929
- ]);
849
+ // store/slices/permissions.ts
850
+ var createPermissionsSlice = (set, get) => {
851
+ const resolvePermissions = (..._0) => __async(null, [..._0], function* (params = {}, force) {
852
+ const { state, permissions, config } = get();
853
+ const { cache, globalPermissions } = permissions;
854
+ const resolvePermissionsForItem = (item2, force2 = false) => __async(null, null, function* () {
855
+ var _a, _b;
856
+ const { config: config2, state: appState, setComponentLoading } = get();
857
+ const itemCache = cache[item2.props.id];
858
+ const nodes = appState.indexes.nodes;
859
+ const parentId = (_a = nodes[item2.props.id]) == null ? void 0 : _a.parentId;
860
+ const parentNode = parentId ? nodes[parentId] : null;
861
+ const parentData = (_b = parentNode == null ? void 0 : parentNode.data) != null ? _b : null;
862
+ const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
863
+ if (!componentConfig) {
864
+ return;
865
+ }
866
+ const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
867
+ if (componentConfig.resolvePermissions) {
868
+ const changed = getChanged(item2, itemCache == null ? void 0 : itemCache.lastData);
869
+ const propsChanged = Object.values(changed).some((el) => el === true);
870
+ const parentChanged = (itemCache == null ? void 0 : itemCache.lastParentId) !== parentId;
871
+ if (propsChanged || parentChanged || force2) {
872
+ const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
873
+ const resolvedPermissions = yield componentConfig.resolvePermissions(
874
+ item2,
875
+ {
876
+ changed,
877
+ lastPermissions: (itemCache == null ? void 0 : itemCache.lastPermissions) || null,
878
+ permissions: initialPermissions,
879
+ appState: makeStatePublic(appState),
880
+ lastData: (itemCache == null ? void 0 : itemCache.lastData) || null,
881
+ parent: parentData
882
+ }
883
+ );
884
+ const latest = get().permissions;
885
+ set({
886
+ permissions: __spreadProps(__spreadValues({}, latest), {
887
+ cache: __spreadProps(__spreadValues({}, latest.cache), {
888
+ [item2.props.id]: {
889
+ lastParentId: parentId,
890
+ lastData: item2,
891
+ lastPermissions: resolvedPermissions
892
+ }
893
+ }),
894
+ resolvedPermissions: __spreadProps(__spreadValues({}, latest.resolvedPermissions), {
895
+ [item2.props.id]: resolvedPermissions
896
+ })
897
+ })
898
+ });
899
+ clearTimeout2();
900
+ }
901
+ }
902
+ });
903
+ const resolvePermissionsForRoot = (force2 = false) => {
904
+ const { state: appState } = get();
905
+ resolvePermissionsForItem(
906
+ // Shim the root data in by conforming to component data shape
907
+ {
908
+ type: "root",
909
+ props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "root" })
910
+ },
911
+ force2
912
+ );
913
+ };
914
+ const { item, type, root } = params;
915
+ if (item) {
916
+ yield resolvePermissionsForItem(item, force);
917
+ } else if (type) {
918
+ flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(null, null, function* () {
919
+ yield resolvePermissionsForItem(item2, force);
920
+ }));
921
+ } else if (root) {
922
+ resolvePermissionsForRoot(force);
923
+ } else {
924
+ flattenData(state, config).map((item2) => __async(null, null, function* () {
925
+ yield resolvePermissionsForItem(item2, force);
926
+ }));
927
+ }
928
+ });
929
+ const refreshPermissions = (params) => resolvePermissions(params, true);
930
+ return {
931
+ cache: {},
932
+ globalPermissions: {
933
+ drag: true,
934
+ edit: true,
935
+ delete: true,
936
+ duplicate: true,
937
+ insert: true
938
+ },
939
+ resolvedPermissions: {},
940
+ getPermissions: ({ item, type, root } = {}) => {
941
+ const { config, permissions } = get();
942
+ const { globalPermissions, resolvedPermissions } = permissions;
943
+ if (item) {
944
+ const componentConfig = config.components[item.type];
945
+ const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
946
+ const resolvedForItem = resolvedPermissions[item.props.id];
947
+ return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
948
+ } else if (type) {
949
+ const componentConfig = config.components[type];
950
+ return __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
951
+ } else if (root) {
952
+ const rootConfig = config.root;
953
+ const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
954
+ const resolvedForItem = resolvedPermissions["root"];
955
+ return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
956
+ }
957
+ return globalPermissions;
958
+ },
959
+ resolvePermissions,
960
+ refreshPermissions
961
+ };
962
+ };
963
+ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
964
+ useEffect3(() => {
965
+ const { permissions } = appStore.getState();
966
+ const { globalPermissions: existingGlobalPermissions } = permissions;
967
+ appStore.setState({
968
+ permissions: __spreadProps(__spreadValues({}, permissions), {
969
+ globalPermissions: __spreadValues(__spreadValues({}, existingGlobalPermissions), globalPermissions)
970
+ })
971
+ });
972
+ permissions.resolvePermissions();
973
+ }, [globalPermissions]);
974
+ useEffect3(() => {
975
+ return appStore.subscribe(
976
+ (s) => s.state.data,
977
+ () => {
978
+ appStore.getState().permissions.resolvePermissions();
979
+ }
980
+ );
981
+ }, []);
982
+ useEffect3(() => {
983
+ return appStore.subscribe(
984
+ (s) => s.config,
985
+ () => {
986
+ appStore.getState().permissions.resolvePermissions();
987
+ }
988
+ );
989
+ }, []);
990
+ };
1930
991
 
1931
- // ../../node_modules/lucide-react/dist/esm/icons/link.js
992
+ // store/slices/fields.ts
1932
993
  init_react_import();
1933
- var Link = createLucideIcon("Link", [
1934
- ["path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71", key: "1cjeqo" }],
1935
- ["path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71", key: "19qd67" }]
1936
- ]);
994
+ import { useCallback, useEffect as useEffect4 } from "react";
995
+ var createFieldsSlice = (_set, _get) => {
996
+ return {
997
+ fields: {},
998
+ loading: false,
999
+ lastResolvedData: {},
1000
+ id: void 0
1001
+ };
1002
+ };
1003
+ var useRegisterFieldsSlice = (appStore, id) => {
1004
+ const resolveFields = useCallback(
1005
+ (reset) => __async(null, null, function* () {
1006
+ var _a, _b;
1007
+ const { fields, lastResolvedData } = appStore.getState().fields;
1008
+ const metadata = appStore.getState().metadata;
1009
+ const nodes = appStore.getState().state.indexes.nodes;
1010
+ const node = nodes[id || "root"];
1011
+ const componentData = node == null ? void 0 : node.data;
1012
+ const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node.parentId] : null;
1013
+ const parent = (parentNode == null ? void 0 : parentNode.data) || null;
1014
+ const { getComponentConfig, state } = appStore.getState();
1015
+ const componentConfig = getComponentConfig(componentData == null ? void 0 : componentData.type);
1016
+ if (!componentData || !componentConfig) return;
1017
+ const defaultFields = componentConfig.fields || {};
1018
+ const resolver = componentConfig.resolveFields;
1019
+ let lastFields = fields;
1020
+ if (reset) {
1021
+ appStore.setState((s) => ({
1022
+ fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
1023
+ }));
1024
+ lastFields = defaultFields;
1025
+ }
1026
+ if (resolver) {
1027
+ const timeout = setTimeout(() => {
1028
+ appStore.setState((s) => ({
1029
+ fields: __spreadProps(__spreadValues({}, s.fields), { loading: true })
1030
+ }));
1031
+ }, 50);
1032
+ const lastData = ((_a = lastResolvedData.props) == null ? void 0 : _a.id) === id ? lastResolvedData : null;
1033
+ const changed = getChanged(componentData, lastData);
1034
+ const newFields = yield resolver(componentData, {
1035
+ changed,
1036
+ fields: defaultFields,
1037
+ lastFields,
1038
+ metadata: __spreadValues(__spreadValues({}, metadata), componentConfig.metadata),
1039
+ lastData,
1040
+ appState: makeStatePublic(state),
1041
+ parent
1042
+ });
1043
+ clearTimeout(timeout);
1044
+ if (((_b = appStore.getState().selectedItem) == null ? void 0 : _b.props.id) !== id) {
1045
+ return;
1046
+ }
1047
+ appStore.setState({
1048
+ fields: {
1049
+ fields: newFields,
1050
+ loading: false,
1051
+ lastResolvedData: componentData,
1052
+ id
1053
+ }
1054
+ });
1055
+ } else {
1056
+ appStore.setState((s) => ({
1057
+ fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
1058
+ }));
1059
+ }
1060
+ }),
1061
+ [id]
1062
+ );
1063
+ useEffect4(() => {
1064
+ resolveFields(true);
1065
+ return appStore.subscribe(
1066
+ (s) => s.state.indexes.nodes[id || "root"],
1067
+ () => resolveFields()
1068
+ );
1069
+ }, [id]);
1070
+ };
1937
1071
 
1938
- // ../../node_modules/lucide-react/dist/esm/icons/list-ordered.js
1072
+ // lib/data/to-root.ts
1939
1073
  init_react_import();
1940
- var ListOrdered = createLucideIcon("ListOrdered", [
1941
- ["path", { d: "M10 12h11", key: "6m4ad9" }],
1942
- ["path", { d: "M10 18h11", key: "11hvi2" }],
1943
- ["path", { d: "M10 6h11", key: "c7qv1k" }],
1944
- ["path", { d: "M4 10h2", key: "16xx2s" }],
1945
- ["path", { d: "M4 6h1v4", key: "cnovpq" }],
1946
- ["path", { d: "M6 18H4c0-1 2-2 2-3s-1-1.5-2-1", key: "m9a95d" }]
1947
- ]);
1948
-
1949
- // ../../node_modules/lucide-react/dist/esm/icons/list.js
1950
- init_react_import();
1951
- var List = createLucideIcon("List", [
1952
- ["path", { d: "M3 12h.01", key: "nlz23k" }],
1953
- ["path", { d: "M3 18h.01", key: "1tta3j" }],
1954
- ["path", { d: "M3 6h.01", key: "1rqtza" }],
1955
- ["path", { d: "M8 12h13", key: "1za7za" }],
1956
- ["path", { d: "M8 18h13", key: "1lx6n3" }],
1957
- ["path", { d: "M8 6h13", key: "ik3vkj" }]
1958
- ]);
1959
-
1960
- // ../../node_modules/lucide-react/dist/esm/icons/lock-open.js
1961
- init_react_import();
1962
- var LockOpen = createLucideIcon("LockOpen", [
1963
- ["rect", { width: "18", height: "11", x: "3", y: "11", rx: "2", ry: "2", key: "1w4ew1" }],
1964
- ["path", { d: "M7 11V7a5 5 0 0 1 9.9-1", key: "1mm8w8" }]
1965
- ]);
1966
-
1967
- // ../../node_modules/lucide-react/dist/esm/icons/lock.js
1968
- init_react_import();
1969
- var Lock = createLucideIcon("Lock", [
1970
- ["rect", { width: "18", height: "11", x: "3", y: "11", rx: "2", ry: "2", key: "1w4ew1" }],
1971
- ["path", { d: "M7 11V7a5 5 0 0 1 10 0v4", key: "fwvmzm" }]
1972
- ]);
1973
-
1974
- // ../../node_modules/lucide-react/dist/esm/icons/minus.js
1975
- init_react_import();
1976
- var Minus = createLucideIcon("Minus", [["path", { d: "M5 12h14", key: "1ays0h" }]]);
1977
-
1978
- // ../../node_modules/lucide-react/dist/esm/icons/monitor.js
1979
- init_react_import();
1980
- var Monitor = createLucideIcon("Monitor", [
1981
- ["rect", { width: "20", height: "14", x: "2", y: "3", rx: "2", key: "48i651" }],
1982
- ["line", { x1: "8", x2: "16", y1: "21", y2: "21", key: "1svkeh" }],
1983
- ["line", { x1: "12", x2: "12", y1: "17", y2: "21", key: "vw1qmm" }]
1984
- ]);
1985
-
1986
- // ../../node_modules/lucide-react/dist/esm/icons/panel-left.js
1987
- init_react_import();
1988
- var PanelLeft = createLucideIcon("PanelLeft", [
1989
- ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
1990
- ["path", { d: "M9 3v18", key: "fh3hqa" }]
1991
- ]);
1992
-
1993
- // ../../node_modules/lucide-react/dist/esm/icons/panel-right.js
1994
- init_react_import();
1995
- var PanelRight = createLucideIcon("PanelRight", [
1996
- ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
1997
- ["path", { d: "M15 3v18", key: "14nvp0" }]
1998
- ]);
1999
-
2000
- // ../../node_modules/lucide-react/dist/esm/icons/plus.js
2001
- init_react_import();
2002
- var Plus = createLucideIcon("Plus", [
2003
- ["path", { d: "M5 12h14", key: "1ays0h" }],
2004
- ["path", { d: "M12 5v14", key: "s699le" }]
2005
- ]);
2006
-
2007
- // ../../node_modules/lucide-react/dist/esm/icons/quote.js
2008
- init_react_import();
2009
- var Quote = createLucideIcon("Quote", [
2010
- [
2011
- "path",
2012
- {
2013
- d: "M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",
2014
- key: "rib7q0"
2015
- }
2016
- ],
2017
- [
2018
- "path",
2019
- {
2020
- d: "M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",
2021
- key: "1ymkrd"
1074
+ var toRoot = (item) => {
1075
+ if ("type" in item && item.type !== "root") {
1076
+ throw new Error("Converting non-root item to root.");
1077
+ }
1078
+ const { readOnly } = item;
1079
+ if (item.props) {
1080
+ if ("id" in item.props) {
1081
+ const _a = item.props, { id } = _a, props = __objRest(_a, ["id"]);
1082
+ return { props, readOnly };
2022
1083
  }
2023
- ]
2024
- ]);
2025
-
2026
- // ../../node_modules/lucide-react/dist/esm/icons/redo-2.js
2027
- init_react_import();
2028
- var Redo2 = createLucideIcon("Redo2", [
2029
- ["path", { d: "m15 14 5-5-5-5", key: "12vg1m" }],
2030
- ["path", { d: "M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13", key: "6uklza" }]
2031
- ]);
2032
-
2033
- // ../../node_modules/lucide-react/dist/esm/icons/search.js
2034
- init_react_import();
2035
- var Search = createLucideIcon("Search", [
2036
- ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
2037
- ["path", { d: "m21 21-4.3-4.3", key: "1qie3q" }]
2038
- ]);
2039
-
2040
- // ../../node_modules/lucide-react/dist/esm/icons/sliders-horizontal.js
2041
- init_react_import();
2042
- var SlidersHorizontal = createLucideIcon("SlidersHorizontal", [
2043
- ["line", { x1: "21", x2: "14", y1: "4", y2: "4", key: "obuewd" }],
2044
- ["line", { x1: "10", x2: "3", y1: "4", y2: "4", key: "1q6298" }],
2045
- ["line", { x1: "21", x2: "12", y1: "12", y2: "12", key: "1iu8h1" }],
2046
- ["line", { x1: "8", x2: "3", y1: "12", y2: "12", key: "ntss68" }],
2047
- ["line", { x1: "21", x2: "16", y1: "20", y2: "20", key: "14d8ph" }],
2048
- ["line", { x1: "12", x2: "3", y1: "20", y2: "20", key: "m0wm8r" }],
2049
- ["line", { x1: "14", x2: "14", y1: "2", y2: "6", key: "14e1ph" }],
2050
- ["line", { x1: "8", x2: "8", y1: "10", y2: "14", key: "1i6ji0" }],
2051
- ["line", { x1: "16", x2: "16", y1: "18", y2: "22", key: "1lctlv" }]
2052
- ]);
1084
+ return { props: item.props, readOnly };
1085
+ }
1086
+ return { props: {}, readOnly };
1087
+ };
2053
1088
 
2054
- // ../../node_modules/lucide-react/dist/esm/icons/smartphone.js
2055
- init_react_import();
2056
- var Smartphone = createLucideIcon("Smartphone", [
2057
- ["rect", { width: "14", height: "20", x: "5", y: "2", rx: "2", ry: "2", key: "1yt0o3" }],
2058
- ["path", { d: "M12 18h.01", key: "mhygvu" }]
2059
- ]);
1089
+ // store/index.ts
1090
+ var defaultPageFields = {
1091
+ title: { type: "text" }
1092
+ };
1093
+ var createAppStore = (initialAppStore) => create2()(
1094
+ subscribeWithSelector2((set, get) => {
1095
+ var _a, _b;
1096
+ return __spreadProps(__spreadValues({
1097
+ state: defaultAppState,
1098
+ config: { components: {} },
1099
+ componentState: {},
1100
+ plugins: [],
1101
+ overrides: {},
1102
+ viewports: defaultViewports,
1103
+ zoomConfig: {
1104
+ autoZoom: 1,
1105
+ rootHeight: 0,
1106
+ zoom: 1
1107
+ },
1108
+ status: "LOADING",
1109
+ iframe: {},
1110
+ metadata: {},
1111
+ fieldTransforms: {}
1112
+ }, initialAppStore), {
1113
+ fields: createFieldsSlice(set, get),
1114
+ history: createHistorySlice(set, get),
1115
+ nodes: createNodesSlice(set, get),
1116
+ permissions: createPermissionsSlice(set, get),
1117
+ getComponentConfig: (type) => {
1118
+ var _a2;
1119
+ const { config, selectedItem } = get();
1120
+ const rootFields = ((_a2 = config.root) == null ? void 0 : _a2.fields) || defaultPageFields;
1121
+ return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
1122
+ },
1123
+ selectedItem: ((_a = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _a.ui.itemSelector) ? getItem(
1124
+ (_b = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _b.ui.itemSelector,
1125
+ initialAppStore.state
1126
+ ) : null,
1127
+ dispatch: (action) => set((s) => {
1128
+ var _a2, _b2;
1129
+ const { record } = get().history;
1130
+ const dispatch = createReducer({
1131
+ record,
1132
+ appStore: s
1133
+ });
1134
+ const state = dispatch(s.state, action);
1135
+ const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
1136
+ (_b2 = (_a2 = get()).onAction) == null ? void 0 : _b2.call(_a2, action, state, get().state);
1137
+ return __spreadProps(__spreadValues({}, s), { state, selectedItem });
1138
+ }),
1139
+ setZoomConfig: (zoomConfig) => set({ zoomConfig }),
1140
+ setStatus: (status) => set({ status }),
1141
+ setComponentState: (componentState) => set({ componentState }),
1142
+ pendingLoadTimeouts: {},
1143
+ setComponentLoading: (id, loading = true, defer = 0) => {
1144
+ const { setComponentState, pendingLoadTimeouts } = get();
1145
+ const loadId = generateId();
1146
+ const setLoading = () => {
1147
+ var _a2;
1148
+ const { componentState } = get();
1149
+ setComponentState(__spreadProps(__spreadValues({}, componentState), {
1150
+ [id]: __spreadProps(__spreadValues({}, componentState[id]), {
1151
+ loadingCount: (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) + 1
1152
+ })
1153
+ }));
1154
+ };
1155
+ const unsetLoading = () => {
1156
+ var _a2;
1157
+ const { componentState } = get();
1158
+ clearTimeout(timeout);
1159
+ delete pendingLoadTimeouts[loadId];
1160
+ set({ pendingLoadTimeouts });
1161
+ setComponentState(__spreadProps(__spreadValues({}, componentState), {
1162
+ [id]: __spreadProps(__spreadValues({}, componentState[id]), {
1163
+ loadingCount: Math.max(
1164
+ (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) - 1,
1165
+ 0
1166
+ )
1167
+ })
1168
+ }));
1169
+ };
1170
+ const timeout = setTimeout(() => {
1171
+ if (loading) {
1172
+ setLoading();
1173
+ } else {
1174
+ unsetLoading();
1175
+ }
1176
+ delete pendingLoadTimeouts[loadId];
1177
+ set({ pendingLoadTimeouts });
1178
+ }, defer);
1179
+ set({
1180
+ pendingLoadTimeouts: __spreadProps(__spreadValues({}, pendingLoadTimeouts), {
1181
+ [id]: timeout
1182
+ })
1183
+ });
1184
+ return unsetLoading;
1185
+ },
1186
+ unsetComponentLoading: (id) => {
1187
+ const { setComponentLoading } = get();
1188
+ setComponentLoading(id, false);
1189
+ },
1190
+ // Helper
1191
+ setUi: (ui, recordHistory) => set((s) => {
1192
+ const dispatch = createReducer({
1193
+ record: () => {
1194
+ },
1195
+ appStore: s
1196
+ });
1197
+ const state = dispatch(s.state, {
1198
+ type: "setUi",
1199
+ ui,
1200
+ recordHistory
1201
+ });
1202
+ const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
1203
+ return __spreadProps(__spreadValues({}, s), { state, selectedItem });
1204
+ }),
1205
+ resolveComponentData: (componentData, trigger) => __async(null, null, function* () {
1206
+ const { config, metadata, setComponentLoading, permissions } = get();
1207
+ const timeouts = {};
1208
+ return yield resolveComponentData(
1209
+ componentData,
1210
+ config,
1211
+ metadata,
1212
+ (item) => {
1213
+ const id = "id" in item.props ? item.props.id : "root";
1214
+ timeouts[id] = setComponentLoading(id, true, 50);
1215
+ },
1216
+ (item) => __async(null, null, function* () {
1217
+ const id = "id" in item.props ? item.props.id : "root";
1218
+ if ("type" in item) {
1219
+ yield permissions.refreshPermissions({ item });
1220
+ } else {
1221
+ yield permissions.refreshPermissions({ root: true });
1222
+ }
1223
+ timeouts[id]();
1224
+ }),
1225
+ trigger
1226
+ );
1227
+ }),
1228
+ resolveAndCommitData: () => __async(null, null, function* () {
1229
+ const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
1230
+ walkAppState(
1231
+ state,
1232
+ config,
1233
+ (content) => content,
1234
+ (childItem) => {
1235
+ resolveComponentData2(childItem, "load").then((resolved) => {
1236
+ const { state: state2 } = get();
1237
+ const node = state2.indexes.nodes[resolved.node.props.id];
1238
+ if (node && resolved.didChange) {
1239
+ if (resolved.node.props.id === "root") {
1240
+ dispatch({
1241
+ type: "replaceRoot",
1242
+ root: toRoot(resolved.node)
1243
+ });
1244
+ } else {
1245
+ const zoneCompound = `${node.parentId}:${node.zone}`;
1246
+ const parentZone = state2.indexes.zones[zoneCompound];
1247
+ const index = parentZone.contentIds.indexOf(
1248
+ resolved.node.props.id
1249
+ );
1250
+ dispatch({
1251
+ type: "replace",
1252
+ data: resolved.node,
1253
+ destinationIndex: index,
1254
+ destinationZone: zoneCompound
1255
+ });
1256
+ }
1257
+ }
1258
+ });
1259
+ return childItem;
1260
+ }
1261
+ );
1262
+ })
1263
+ });
1264
+ })
1265
+ );
1266
+ var appStoreContext = createContext(createAppStore());
1267
+ function useAppStore(selector) {
1268
+ const context = useContext(appStoreContext);
1269
+ return useStore(context, selector);
1270
+ }
1271
+ function useAppStoreApi() {
1272
+ return useContext(appStoreContext);
1273
+ }
2060
1274
 
2061
- // ../../node_modules/lucide-react/dist/esm/icons/square-code.js
1275
+ // components/RichTextMenu/lib/use-control-context.ts
2062
1276
  init_react_import();
2063
- var SquareCode = createLucideIcon("SquareCode", [
2064
- ["path", { d: "M10 9.5 8 12l2 2.5", key: "3mjy60" }],
2065
- ["path", { d: "m14 9.5 2 2.5-2 2.5", key: "1bir2l" }],
2066
- ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }]
2067
- ]);
1277
+ import { createContext as createContext2, useContext as useContext2 } from "react";
1278
+ var ControlContext = createContext2({});
1279
+ var useControlContext = () => {
1280
+ return useContext2(ControlContext);
1281
+ };
2068
1282
 
2069
- // ../../node_modules/lucide-react/dist/esm/icons/strikethrough.js
1283
+ // components/RichTextMenu/components/SelectControl/index.tsx
2070
1284
  init_react_import();
2071
- var Strikethrough = createLucideIcon("Strikethrough", [
2072
- ["path", { d: "M16 4H9a3 3 0 0 0-2.83 4", key: "43sutm" }],
2073
- ["path", { d: "M14 12a4 4 0 0 1 0 8H6", key: "nlfj13" }],
2074
- ["line", { x1: "4", x2: "20", y1: "12", y2: "12", key: "1e0a9i" }]
2075
- ]);
1285
+ import { useMemo } from "react";
2076
1286
 
2077
- // ../../node_modules/lucide-react/dist/esm/icons/tablet.js
1287
+ // components/Select/index.tsx
2078
1288
  init_react_import();
2079
- var Tablet = createLucideIcon("Tablet", [
2080
- ["rect", { width: "16", height: "20", x: "4", y: "2", rx: "2", ry: "2", key: "76otgf" }],
2081
- ["line", { x1: "12", x2: "12.01", y1: "18", y2: "18", key: "1dp563" }]
2082
- ]);
2083
1289
 
2084
- // ../../node_modules/lucide-react/dist/esm/icons/trash.js
1290
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Select/styles.module.css#css-module
2085
1291
  init_react_import();
2086
- var Trash = createLucideIcon("Trash", [
2087
- ["path", { d: "M3 6h18", key: "d0wm0j" }],
2088
- ["path", { d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6", key: "4alrt4" }],
2089
- ["path", { d: "M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2", key: "v07s0e" }]
2090
- ]);
1292
+ var styles_module_default = { "Select": "_Select_xjbef_1", "Select-button": "_Select-button_xjbef_6", "Select--hasOptions": "_Select--hasOptions_xjbef_19", "Select--disabled": "_Select--disabled_xjbef_23", "Select-buttonIcon": "_Select-buttonIcon_xjbef_27", "Select--standalone": "_Select--standalone_xjbef_33", "Select--actionBar": "_Select--actionBar_xjbef_38", "Select--hasValue": "_Select--hasValue_xjbef_44", "Select-items": "_Select-items_xjbef_61", "SelectItem": "_SelectItem_xjbef_72", "SelectItem--isSelected": "_SelectItem--isSelected_xjbef_87", "SelectItem-icon": "_SelectItem-icon_xjbef_93" };
2091
1293
 
2092
- // ../../node_modules/lucide-react/dist/esm/icons/type.js
2093
- init_react_import();
2094
- var Type = createLucideIcon("Type", [
2095
- ["polyline", { points: "4 7 4 4 20 4 20 7", key: "1nosan" }],
2096
- ["line", { x1: "9", x2: "15", y1: "20", y2: "20", key: "swin9y" }],
2097
- ["line", { x1: "12", x2: "12", y1: "4", y2: "20", key: "1tx1rr" }]
2098
- ]);
1294
+ // components/Select/index.tsx
1295
+ import { useState } from "react";
1296
+ import {
1297
+ Popover,
1298
+ PopoverContent,
1299
+ PopoverPortal,
1300
+ PopoverTrigger
1301
+ } from "@radix-ui/react-popover";
2099
1302
 
2100
- // ../../node_modules/lucide-react/dist/esm/icons/underline.js
1303
+ // lib/index.ts
2101
1304
  init_react_import();
2102
- var Underline = createLucideIcon("Underline", [
2103
- ["path", { d: "M6 4v6a6 6 0 0 0 12 0V4", key: "9kb039" }],
2104
- ["line", { x1: "4", x2: "20", y1: "20", y2: "20", key: "nun2al" }]
2105
- ]);
2106
1305
 
2107
- // ../../node_modules/lucide-react/dist/esm/icons/undo-2.js
1306
+ // lib/filter.ts
2108
1307
  init_react_import();
2109
- var Undo2 = createLucideIcon("Undo2", [
2110
- ["path", { d: "M9 14 4 9l5-5", key: "102s5s" }],
2111
- ["path", { d: "M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11", key: "f3b9sd" }]
2112
- ]);
2113
1308
 
2114
- // ../../node_modules/lucide-react/dist/esm/icons/zoom-in.js
1309
+ // lib/data/reorder.ts
2115
1310
  init_react_import();
2116
- var ZoomIn = createLucideIcon("ZoomIn", [
2117
- ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
2118
- ["line", { x1: "21", x2: "16.65", y1: "21", y2: "16.65", key: "13gj7c" }],
2119
- ["line", { x1: "11", x2: "11", y1: "8", y2: "14", key: "1vmskp" }],
2120
- ["line", { x1: "8", x2: "14", y1: "11", y2: "11", key: "durymu" }]
2121
- ]);
1311
+ var reorder = (list, startIndex, endIndex) => {
1312
+ const result = Array.from(list);
1313
+ const [removed] = result.splice(startIndex, 1);
1314
+ result.splice(endIndex, 0, removed);
1315
+ return result;
1316
+ };
2122
1317
 
2123
- // ../../node_modules/lucide-react/dist/esm/icons/zoom-out.js
1318
+ // lib/data/replace.ts
2124
1319
  init_react_import();
2125
- var ZoomOut = createLucideIcon("ZoomOut", [
2126
- ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
2127
- ["line", { x1: "21", x2: "16.65", y1: "21", y2: "16.65", key: "13gj7c" }],
2128
- ["line", { x1: "8", x2: "14", y1: "11", y2: "11", key: "durymu" }]
2129
- ]);
1320
+ var replace = (list, index, newItem) => {
1321
+ const result = Array.from(list);
1322
+ result.splice(index, 1);
1323
+ result.splice(index, 0, newItem);
1324
+ return result;
1325
+ };
2130
1326
 
2131
- // components/RichTextMenu/components/Control/index.tsx
1327
+ // lib/use-reset-auto-zoom.ts
2132
1328
  init_react_import();
2133
1329
 
2134
- // components/IconButton/index.ts
1330
+ // lib/get-zoom-config.ts
2135
1331
  init_react_import();
2136
1332
 
2137
- // css-module:/home/runner/work/puck/puck/packages/core/components/RichTextMenu/components/Control/styles.module.css#css-module
1333
+ // ../../node_modules/css-box-model/dist/css-box-model.esm.js
2138
1334
  init_react_import();
2139
- var styles_module_default5 = { "Control": "_Control_1aveu_1", "Control--inline": "_Control--inline_1aveu_6" };
2140
1335
 
2141
- // components/RichTextMenu/lib/use-control-context.ts
1336
+ // ../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
2142
1337
  init_react_import();
2143
- import { createContext as createContext2, useContext as useContext2 } from "react";
2144
- var ControlContext = createContext2({});
2145
- var useControlContext = () => {
2146
- return useContext2(ControlContext);
2147
- };
2148
-
2149
- // components/RichTextMenu/components/Control/index.tsx
2150
- import { jsx as jsx4 } from "react/jsx-runtime";
2151
- var getClassName4 = get_class_name_factory_default("Control", styles_module_default5);
2152
- function Control({
2153
- icon,
2154
- disabled,
2155
- active,
2156
- onClick,
2157
- title
2158
- }) {
2159
- const { inline } = useControlContext();
2160
- if (inline) {
2161
- return /* @__PURE__ */ jsx4("span", { className: getClassName4({ inline: true }), children: /* @__PURE__ */ jsx4(
2162
- Action,
2163
- {
2164
- onClick,
2165
- disabled,
2166
- active,
2167
- label: title,
2168
- children: icon
2169
- }
2170
- ) });
1338
+ var isProduction = process.env.NODE_ENV === "production";
1339
+ var prefix = "Invariant failed";
1340
+ function invariant(condition, message) {
1341
+ if (condition) {
1342
+ return;
2171
1343
  }
2172
- return /* @__PURE__ */ jsx4("span", { className: getClassName4(), children: /* @__PURE__ */ jsx4(
2173
- IconButton,
2174
- {
2175
- onClick,
2176
- disabled,
2177
- active,
2178
- title,
2179
- children: icon
2180
- }
2181
- ) });
2182
- }
2183
-
2184
- // components/RichTextMenu/controls/AlignLeft.tsx
2185
- import { jsx as jsx5 } from "react/jsx-runtime";
2186
- function AlignLeft2() {
2187
- const { editor, editorState } = useControlContext();
2188
- return /* @__PURE__ */ jsx5(
2189
- Control,
2190
- {
2191
- icon: /* @__PURE__ */ jsx5(AlignLeft, {}),
2192
- onClick: (e) => {
2193
- e.stopPropagation();
2194
- editor == null ? void 0 : editor.chain().focus().setTextAlign("left").run();
2195
- },
2196
- disabled: !(editorState == null ? void 0 : editorState.canAlignLeft),
2197
- active: editorState == null ? void 0 : editorState.isAlignLeft,
2198
- title: "Align left"
2199
- }
2200
- );
1344
+ if (isProduction) {
1345
+ throw new Error(prefix);
1346
+ }
1347
+ var provided = typeof message === "function" ? message() : message;
1348
+ var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
1349
+ throw new Error(value);
2201
1350
  }
2202
1351
 
2203
- // components/RichTextMenu/controls/AlignCenter.tsx
2204
- init_react_import();
2205
- import { jsx as jsx6 } from "react/jsx-runtime";
2206
- function AlignCenter2() {
2207
- const { editor, editorState } = useControlContext();
2208
- return /* @__PURE__ */ jsx6(
2209
- Control,
2210
- {
2211
- icon: /* @__PURE__ */ jsx6(AlignCenter, {}),
2212
- onClick: (e) => {
2213
- e.stopPropagation();
2214
- editor == null ? void 0 : editor.chain().focus().setTextAlign("center").run();
2215
- },
2216
- disabled: !(editorState == null ? void 0 : editorState.canAlignCenter),
2217
- active: editorState == null ? void 0 : editorState.isAlignCenter,
2218
- title: "Align center"
1352
+ // ../../node_modules/css-box-model/dist/css-box-model.esm.js
1353
+ var getRect = function getRect2(_ref) {
1354
+ var top = _ref.top, right = _ref.right, bottom = _ref.bottom, left = _ref.left;
1355
+ var width = right - left;
1356
+ var height = bottom - top;
1357
+ var rect = {
1358
+ top,
1359
+ right,
1360
+ bottom,
1361
+ left,
1362
+ width,
1363
+ height,
1364
+ x: left,
1365
+ y: top,
1366
+ center: {
1367
+ x: (right + left) / 2,
1368
+ y: (bottom + top) / 2
2219
1369
  }
2220
- );
2221
- }
1370
+ };
1371
+ return rect;
1372
+ };
1373
+ var expand = function expand2(target, expandBy) {
1374
+ return {
1375
+ top: target.top - expandBy.top,
1376
+ left: target.left - expandBy.left,
1377
+ bottom: target.bottom + expandBy.bottom,
1378
+ right: target.right + expandBy.right
1379
+ };
1380
+ };
1381
+ var shrink = function shrink2(target, shrinkBy) {
1382
+ return {
1383
+ top: target.top + shrinkBy.top,
1384
+ left: target.left + shrinkBy.left,
1385
+ bottom: target.bottom - shrinkBy.bottom,
1386
+ right: target.right - shrinkBy.right
1387
+ };
1388
+ };
1389
+ var noSpacing = {
1390
+ top: 0,
1391
+ right: 0,
1392
+ bottom: 0,
1393
+ left: 0
1394
+ };
1395
+ var createBox = function createBox2(_ref2) {
1396
+ var borderBox = _ref2.borderBox, _ref2$margin = _ref2.margin, margin = _ref2$margin === void 0 ? noSpacing : _ref2$margin, _ref2$border = _ref2.border, border = _ref2$border === void 0 ? noSpacing : _ref2$border, _ref2$padding = _ref2.padding, padding = _ref2$padding === void 0 ? noSpacing : _ref2$padding;
1397
+ var marginBox = getRect(expand(borderBox, margin));
1398
+ var paddingBox = getRect(shrink(borderBox, border));
1399
+ var contentBox = getRect(shrink(paddingBox, padding));
1400
+ return {
1401
+ marginBox,
1402
+ borderBox: getRect(borderBox),
1403
+ paddingBox,
1404
+ contentBox,
1405
+ margin,
1406
+ border,
1407
+ padding
1408
+ };
1409
+ };
1410
+ var parse = function parse2(raw) {
1411
+ var value = raw.slice(0, -2);
1412
+ var suffix = raw.slice(-2);
1413
+ if (suffix !== "px") {
1414
+ return 0;
1415
+ }
1416
+ var result = Number(value);
1417
+ !!isNaN(result) ? process.env.NODE_ENV !== "production" ? invariant(false, "Could not parse value [raw: " + raw + ", without suffix: " + value + "]") : invariant(false) : void 0;
1418
+ return result;
1419
+ };
1420
+ var calculateBox = function calculateBox2(borderBox, styles) {
1421
+ var margin = {
1422
+ top: parse(styles.marginTop),
1423
+ right: parse(styles.marginRight),
1424
+ bottom: parse(styles.marginBottom),
1425
+ left: parse(styles.marginLeft)
1426
+ };
1427
+ var padding = {
1428
+ top: parse(styles.paddingTop),
1429
+ right: parse(styles.paddingRight),
1430
+ bottom: parse(styles.paddingBottom),
1431
+ left: parse(styles.paddingLeft)
1432
+ };
1433
+ var border = {
1434
+ top: parse(styles.borderTopWidth),
1435
+ right: parse(styles.borderRightWidth),
1436
+ bottom: parse(styles.borderBottomWidth),
1437
+ left: parse(styles.borderLeftWidth)
1438
+ };
1439
+ return createBox({
1440
+ borderBox,
1441
+ margin,
1442
+ padding,
1443
+ border
1444
+ });
1445
+ };
1446
+ var getBox = function getBox2(el) {
1447
+ var borderBox = el.getBoundingClientRect();
1448
+ var styles = window.getComputedStyle(el);
1449
+ return calculateBox(borderBox, styles);
1450
+ };
2222
1451
 
2223
- // components/RichTextMenu/controls/AlignRight.tsx
2224
- init_react_import();
2225
- import { jsx as jsx7 } from "react/jsx-runtime";
2226
- function AlignRight2() {
2227
- const { editor, editorState } = useControlContext();
2228
- return /* @__PURE__ */ jsx7(
2229
- Control,
2230
- {
2231
- icon: /* @__PURE__ */ jsx7(AlignRight, {}),
2232
- onClick: (e) => {
2233
- e.stopPropagation();
2234
- editor == null ? void 0 : editor.chain().focus().setTextAlign("right").run();
2235
- },
2236
- disabled: !(editorState == null ? void 0 : editorState.canAlignRight),
2237
- active: editorState == null ? void 0 : editorState.isAlignRight,
2238
- title: "Align right"
1452
+ // lib/get-zoom-config.ts
1453
+ var RESET_ZOOM_SMALLER_THAN_FRAME = true;
1454
+ var getZoomConfig = (uiViewport, frame, zoom) => {
1455
+ const box = getBox(frame);
1456
+ const { width: frameWidth, height: frameHeight } = box.contentBox;
1457
+ const viewportHeight = uiViewport.height === "auto" ? frameHeight : uiViewport.height;
1458
+ let rootHeight = 0;
1459
+ let autoZoom = 1;
1460
+ if (uiViewport.width > frameWidth || viewportHeight > frameHeight) {
1461
+ const widthZoom = Math.min(frameWidth / uiViewport.width, 1);
1462
+ const heightZoom = Math.min(frameHeight / viewportHeight, 1);
1463
+ zoom = widthZoom;
1464
+ if (widthZoom < heightZoom) {
1465
+ rootHeight = viewportHeight / zoom;
1466
+ } else {
1467
+ rootHeight = viewportHeight;
1468
+ zoom = heightZoom;
2239
1469
  }
2240
- );
2241
- }
2242
-
2243
- // components/RichTextMenu/controls/AlignJustify.tsx
2244
- init_react_import();
2245
- import { jsx as jsx8 } from "react/jsx-runtime";
2246
- function AlignJustify2() {
2247
- const { editor, editorState } = useControlContext();
2248
- return /* @__PURE__ */ jsx8(
2249
- Control,
2250
- {
2251
- icon: /* @__PURE__ */ jsx8(AlignJustify, {}),
2252
- onClick: (e) => {
2253
- e.stopPropagation();
2254
- editor == null ? void 0 : editor.chain().focus().setTextAlign("justify").run();
2255
- },
2256
- disabled: !(editorState == null ? void 0 : editorState.canAlignJustify),
2257
- active: editorState == null ? void 0 : editorState.isAlignJustify,
2258
- title: "Justify"
1470
+ autoZoom = zoom;
1471
+ } else {
1472
+ if (RESET_ZOOM_SMALLER_THAN_FRAME) {
1473
+ autoZoom = 1;
1474
+ zoom = 1;
1475
+ rootHeight = viewportHeight;
2259
1476
  }
2260
- );
2261
- }
2262
-
2263
- // components/RichTextMenu/controls/AlignSelect.tsx
2264
- init_react_import();
2265
- import { useEditorState } from "@tiptap/react";
2266
- import { useMemo as useMemo2 } from "react";
2267
-
2268
- // components/RichTextMenu/components/SelectControl/index.tsx
2269
- init_react_import();
2270
- import { useMemo } from "react";
2271
-
2272
- // components/Select/index.tsx
2273
- init_react_import();
1477
+ }
1478
+ return { autoZoom, rootHeight, zoom };
1479
+ };
2274
1480
 
2275
- // css-module:/home/runner/work/puck/puck/packages/core/components/Select/styles.module.css#css-module
2276
- init_react_import();
2277
- var styles_module_default6 = { "Select": "_Select_xjbef_1", "Select-button": "_Select-button_xjbef_6", "Select--hasOptions": "_Select--hasOptions_xjbef_19", "Select--disabled": "_Select--disabled_xjbef_23", "Select-buttonIcon": "_Select-buttonIcon_xjbef_27", "Select--standalone": "_Select--standalone_xjbef_33", "Select--actionBar": "_Select--actionBar_xjbef_38", "Select--hasValue": "_Select--hasValue_xjbef_44", "Select-items": "_Select-items_xjbef_61", "SelectItem": "_SelectItem_xjbef_72", "SelectItem--isSelected": "_SelectItem--isSelected_xjbef_87", "SelectItem-icon": "_SelectItem-icon_xjbef_93" };
1481
+ // lib/use-reset-auto-zoom.ts
1482
+ var useResetAutoZoom = (frameRef) => {
1483
+ const appStoreApi = useAppStoreApi();
1484
+ const resetAutoZoom = (options) => {
1485
+ const { state, zoomConfig, setZoomConfig } = appStoreApi.getState();
1486
+ const { viewports } = state.ui;
1487
+ const newViewports = (options == null ? void 0 : options.viewports) || viewports;
1488
+ if (frameRef.current) {
1489
+ setZoomConfig(
1490
+ getZoomConfig(newViewports == null ? void 0 : newViewports.current, frameRef.current, zoomConfig.zoom)
1491
+ );
1492
+ }
1493
+ };
1494
+ return resetAutoZoom;
1495
+ };
2278
1496
 
2279
1497
  // components/Select/index.tsx
2280
- import { useState as useState2 } from "react";
2281
- import {
2282
- Popover,
2283
- PopoverContent,
2284
- PopoverPortal,
2285
- PopoverTrigger
2286
- } from "@radix-ui/react-popover";
2287
- import { jsx as jsx9, jsxs as jsxs3 } from "react/jsx-runtime";
2288
- var getClassName5 = get_class_name_factory_default("Select", styles_module_default6);
2289
- var getItemClassName = get_class_name_factory_default("SelectItem", styles_module_default6);
1498
+ import { jsx, jsxs } from "react/jsx-runtime";
1499
+ var getClassName = get_class_name_factory_default("Select", styles_module_default);
1500
+ var getItemClassName = get_class_name_factory_default("SelectItem", styles_module_default);
2290
1501
  var Item = ({
2291
1502
  children,
2292
1503
  isSelected,
2293
1504
  onClick
2294
1505
  }) => {
2295
- return /* @__PURE__ */ jsx9("button", { className: getItemClassName({ isSelected }), onClick, children });
1506
+ return /* @__PURE__ */ jsx("button", { className: getItemClassName({ isSelected }), onClick, children });
2296
1507
  };
2297
1508
  var Select = ({
2298
1509
  children,
@@ -2303,29 +1514,29 @@ var Select = ({
2303
1514
  mode,
2304
1515
  disabled = false
2305
1516
  }) => {
2306
- const [open, setOpen] = useState2(false);
1517
+ const [open, setOpen] = useState(false);
2307
1518
  const hasOptions = options.length > 0;
2308
- return /* @__PURE__ */ jsx9(
1519
+ return /* @__PURE__ */ jsx(
2309
1520
  "div",
2310
1521
  {
2311
- className: getClassName5({
1522
+ className: getClassName({
2312
1523
  hasValue: value !== defaultValue,
2313
1524
  hasOptions,
2314
1525
  actionBar: mode === "actionBar",
2315
1526
  standalone: mode === "standalone",
2316
1527
  disabled
2317
1528
  }),
2318
- children: /* @__PURE__ */ jsxs3(Popover, { open, onOpenChange: setOpen, children: [
2319
- hasOptions ? /* @__PURE__ */ jsx9(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs3("button", { className: getClassName5("button"), children: [
2320
- /* @__PURE__ */ jsx9("span", { className: getClassName5("buttonIcon"), children }),
2321
- /* @__PURE__ */ jsx9(ChevronDown, { size: 12 })
2322
- ] }) }) : /* @__PURE__ */ jsx9("div", { children: /* @__PURE__ */ jsxs3("div", { className: getClassName5("button"), children: [
2323
- /* @__PURE__ */ jsx9("span", { className: getClassName5("buttonIcon"), children }),
2324
- /* @__PURE__ */ jsx9(ChevronDown, { size: 12 })
1529
+ children: /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
1530
+ hasOptions ? /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs("button", { className: getClassName("button"), children: [
1531
+ /* @__PURE__ */ jsx("span", { className: getClassName("buttonIcon"), children }),
1532
+ /* @__PURE__ */ jsx(ChevronDown, { size: 12 })
1533
+ ] }) }) : /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("div", { className: getClassName("button"), children: [
1534
+ /* @__PURE__ */ jsx("span", { className: getClassName("buttonIcon"), children }),
1535
+ /* @__PURE__ */ jsx(ChevronDown, { size: 12 })
2325
1536
  ] }) }),
2326
- options.length > 0 && /* @__PURE__ */ jsx9(PopoverPortal, { children: /* @__PURE__ */ jsx9(PopoverContent, { align: "start", children: /* @__PURE__ */ jsx9("ul", { className: getClassName5("items"), "data-puck-rte-menu": true, children: options.map((option) => {
1537
+ options.length > 0 && /* @__PURE__ */ jsx(PopoverPortal, { children: /* @__PURE__ */ jsx(PopoverContent, { align: "start", children: /* @__PURE__ */ jsx("ul", { className: getClassName("items"), "data-puck-rte-menu": true, children: options.map((option) => {
2327
1538
  const Icon2 = option.icon;
2328
- return /* @__PURE__ */ jsx9("li", { children: /* @__PURE__ */ jsxs3(
1539
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
2329
1540
  Item,
2330
1541
  {
2331
1542
  isSelected: value === option.value,
@@ -2334,7 +1545,7 @@ var Select = ({
2334
1545
  setOpen(false);
2335
1546
  },
2336
1547
  children: [
2337
- Icon2 && /* @__PURE__ */ jsx9("div", { className: getItemClassName("icon"), children: /* @__PURE__ */ jsx9(Icon2, { size: 16 }) }),
1548
+ Icon2 && /* @__PURE__ */ jsx("div", { className: getItemClassName("icon"), children: /* @__PURE__ */ jsx(Icon2, { size: 16 }) }),
2338
1549
  option.label
2339
1550
  ]
2340
1551
  }
@@ -2346,7 +1557,7 @@ var Select = ({
2346
1557
  };
2347
1558
 
2348
1559
  // components/RichTextMenu/components/SelectControl/index.tsx
2349
- import { jsx as jsx10 } from "react/jsx-runtime";
1560
+ import { jsx as jsx2 } from "react/jsx-runtime";
2350
1561
  function SelectControl({
2351
1562
  renderDefaultIcon,
2352
1563
  onChange,
@@ -2364,7 +1575,7 @@ function SelectControl({
2364
1575
  [options]
2365
1576
  );
2366
1577
  const Node = (_b = value && ((_a = optionsByValue[value]) == null ? void 0 : _a.icon)) != null ? _b : renderDefaultIcon;
2367
- return /* @__PURE__ */ jsx10(
1578
+ return /* @__PURE__ */ jsx2(
2368
1579
  Select,
2369
1580
  {
2370
1581
  options,
@@ -2373,689 +1584,63 @@ function SelectControl({
2373
1584
  defaultValue,
2374
1585
  mode: inline ? "actionBar" : "standalone",
2375
1586
  disabled: readOnly,
2376
- children: /* @__PURE__ */ jsx10(Node, {})
2377
- }
2378
- );
2379
- }
2380
-
2381
- // components/RichTextMenu/controls/AlignSelect.tsx
2382
- import { jsx as jsx11 } from "react/jsx-runtime";
2383
- var optionNodes = {
2384
- left: { label: "Left", icon: AlignLeft },
2385
- center: { label: "Center", icon: AlignCenter },
2386
- right: { label: "Right", icon: AlignRight },
2387
- justify: { label: "Justify", icon: AlignJustify }
2388
- };
2389
- function AlignSelect() {
2390
- var _a, _b;
2391
- const { options } = useControlContext();
2392
- let blockOptions = [];
2393
- if ((options == null ? void 0 : options.textAlign) !== false) {
2394
- if (!((_a = options == null ? void 0 : options.textAlign) == null ? void 0 : _a.alignments)) {
2395
- blockOptions = ["left", "center", "right", "justify"];
2396
- } else {
2397
- if (options == null ? void 0 : options.textAlign.alignments.includes("left")) {
2398
- blockOptions.push("left");
2399
- }
2400
- if (options == null ? void 0 : options.textAlign.alignments.includes("center")) {
2401
- blockOptions.push("center");
2402
- }
2403
- if (options == null ? void 0 : options.textAlign.alignments.includes("right")) {
2404
- blockOptions.push("right");
2405
- }
2406
- if (options == null ? void 0 : options.textAlign.alignments.includes("justify")) {
2407
- blockOptions.push("justify");
2408
- }
2409
- }
2410
- }
2411
- const { editor } = useControlContext();
2412
- const currentValue = (_b = useEditorState({
2413
- editor,
2414
- selector: (ctx) => {
2415
- var _a2, _b2, _c, _d;
2416
- if ((_a2 = ctx.editor) == null ? void 0 : _a2.isActive({ textAlign: "center" })) {
2417
- return "center";
2418
- } else if ((_b2 = ctx.editor) == null ? void 0 : _b2.isActive({ textAlign: "right" })) {
2419
- return "right";
2420
- } else if ((_c = ctx.editor) == null ? void 0 : _c.isActive({ textAlign: "justify" })) {
2421
- return "justify";
2422
- }
2423
- return (options == null ? void 0 : options.textAlign) ? (_d = options.textAlign.defaultAlignment) != null ? _d : "left" : "left";
2424
- }
2425
- })) != null ? _b : "left";
2426
- const handleChange = (val) => {
2427
- const chain = editor == null ? void 0 : editor.chain();
2428
- chain == null ? void 0 : chain.focus().setTextAlign(val).run();
2429
- };
2430
- const loadedOptions = useMemo2(
2431
- () => blockOptions.map((item) => ({
2432
- value: item,
2433
- label: optionNodes[item].label,
2434
- icon: optionNodes[item].icon
2435
- })),
2436
- [blockOptions]
2437
- );
2438
- return /* @__PURE__ */ jsx11(
2439
- SelectControl,
2440
- {
2441
- options: loadedOptions,
2442
- onChange: handleChange,
2443
- value: currentValue,
2444
- defaultValue: "left",
2445
- renderDefaultIcon: AlignLeft
2446
- }
2447
- );
2448
- }
2449
-
2450
- // components/RichTextMenu/controls/Bold.tsx
2451
- init_react_import();
2452
- import { jsx as jsx12 } from "react/jsx-runtime";
2453
- function Bold2() {
2454
- const { editor, editorState } = useControlContext();
2455
- return /* @__PURE__ */ jsx12(
2456
- Control,
2457
- {
2458
- icon: /* @__PURE__ */ jsx12(Bold, {}),
2459
- onClick: (e) => {
2460
- e.stopPropagation();
2461
- editor == null ? void 0 : editor.chain().focus().toggleBold().run();
2462
- },
2463
- disabled: !(editorState == null ? void 0 : editorState.canBold),
2464
- active: editorState == null ? void 0 : editorState.isBold,
2465
- title: "Bold"
2466
- }
2467
- );
2468
- }
2469
-
2470
- // components/RichTextMenu/controls/Italic.tsx
2471
- init_react_import();
2472
- import { jsx as jsx13 } from "react/jsx-runtime";
2473
- function Italic2() {
2474
- const { editor, editorState } = useControlContext();
2475
- return /* @__PURE__ */ jsx13(
2476
- Control,
2477
- {
2478
- icon: /* @__PURE__ */ jsx13(Italic, {}),
2479
- onClick: (e) => {
2480
- e.stopPropagation();
2481
- editor == null ? void 0 : editor.chain().focus().toggleItalic().run();
2482
- },
2483
- disabled: !(editorState == null ? void 0 : editorState.canItalic),
2484
- active: editorState == null ? void 0 : editorState.isItalic,
2485
- title: "Italic"
2486
- }
2487
- );
2488
- }
2489
-
2490
- // components/RichTextMenu/controls/Underline.tsx
2491
- init_react_import();
2492
- import { jsx as jsx14 } from "react/jsx-runtime";
2493
- function Underline2() {
2494
- const { editor, editorState } = useControlContext();
2495
- return /* @__PURE__ */ jsx14(
2496
- Control,
2497
- {
2498
- icon: /* @__PURE__ */ jsx14(Underline, {}),
2499
- onClick: (e) => {
2500
- e.stopPropagation();
2501
- editor == null ? void 0 : editor.chain().focus().toggleUnderline().run();
2502
- },
2503
- disabled: !(editorState == null ? void 0 : editorState.canUnderline),
2504
- active: editorState == null ? void 0 : editorState.isUnderline,
2505
- title: "Underline"
2506
- }
2507
- );
2508
- }
2509
-
2510
- // components/RichTextMenu/controls/Strikethrough.tsx
2511
- init_react_import();
2512
- import { jsx as jsx15 } from "react/jsx-runtime";
2513
- function Strikethrough2() {
2514
- const { editor, editorState } = useControlContext();
2515
- return /* @__PURE__ */ jsx15(
2516
- Control,
2517
- {
2518
- icon: /* @__PURE__ */ jsx15(Strikethrough, {}),
2519
- onClick: (e) => {
2520
- e.stopPropagation();
2521
- editor == null ? void 0 : editor.chain().focus().toggleStrike().run();
2522
- },
2523
- disabled: !(editorState == null ? void 0 : editorState.canStrike),
2524
- active: editorState == null ? void 0 : editorState.isStrike,
2525
- title: "Strikethrough"
2526
- }
2527
- );
2528
- }
2529
-
2530
- // components/RichTextMenu/controls/InlineCode.tsx
2531
- init_react_import();
2532
- import { jsx as jsx16 } from "react/jsx-runtime";
2533
- function InlineCode() {
2534
- const { editor, editorState } = useControlContext();
2535
- return /* @__PURE__ */ jsx16(
2536
- Control,
2537
- {
2538
- icon: /* @__PURE__ */ jsx16(Code, {}),
2539
- onClick: (e) => {
2540
- e.stopPropagation();
2541
- editor == null ? void 0 : editor.chain().focus().toggleCode().run();
2542
- },
2543
- disabled: !(editorState == null ? void 0 : editorState.canInlineCode),
2544
- active: editorState == null ? void 0 : editorState.isInlineCode,
2545
- title: "Inline code"
2546
- }
2547
- );
2548
- }
2549
-
2550
- // components/RichTextMenu/controls/BulletList.tsx
2551
- init_react_import();
2552
- import { jsx as jsx17 } from "react/jsx-runtime";
2553
- function BulletList() {
2554
- const { editor, editorState } = useControlContext();
2555
- return /* @__PURE__ */ jsx17(
2556
- Control,
2557
- {
2558
- icon: /* @__PURE__ */ jsx17(List, {}),
2559
- onClick: (e) => {
2560
- e.stopPropagation();
2561
- editor == null ? void 0 : editor.chain().focus().toggleBulletList().run();
2562
- },
2563
- disabled: !(editorState == null ? void 0 : editorState.canBulletList),
2564
- active: editorState == null ? void 0 : editorState.isBulletList,
2565
- title: "Bullet list"
2566
- }
2567
- );
2568
- }
2569
-
2570
- // components/RichTextMenu/controls/OrderedList.tsx
2571
- init_react_import();
2572
- import { jsx as jsx18 } from "react/jsx-runtime";
2573
- function OrderedList() {
2574
- const { editor, editorState } = useControlContext();
2575
- return /* @__PURE__ */ jsx18(
2576
- Control,
2577
- {
2578
- icon: /* @__PURE__ */ jsx18(ListOrdered, {}),
2579
- onClick: (e) => {
2580
- e.stopPropagation();
2581
- editor == null ? void 0 : editor.chain().focus().toggleOrderedList().run();
2582
- },
2583
- disabled: !(editorState == null ? void 0 : editorState.canOrderedList),
2584
- active: editorState == null ? void 0 : editorState.isOrderedList,
2585
- title: "Ordered list"
2586
- }
2587
- );
2588
- }
2589
-
2590
- // components/RichTextMenu/controls/CodeBlock.tsx
2591
- init_react_import();
2592
- import { jsx as jsx19 } from "react/jsx-runtime";
2593
- function CodeBlock() {
2594
- const { editor, editorState } = useControlContext();
2595
- return /* @__PURE__ */ jsx19(
2596
- Control,
2597
- {
2598
- icon: /* @__PURE__ */ jsx19(SquareCode, {}),
2599
- onClick: (e) => {
2600
- e.stopPropagation();
2601
- editor == null ? void 0 : editor.chain().focus().toggleCodeBlock().run();
2602
- },
2603
- disabled: !(editorState == null ? void 0 : editorState.canCodeBlock),
2604
- active: editorState == null ? void 0 : editorState.isCodeBlock,
2605
- title: "Code block"
2606
- }
2607
- );
2608
- }
2609
-
2610
- // components/RichTextMenu/controls/Blockquote.tsx
2611
- init_react_import();
2612
- import { jsx as jsx20 } from "react/jsx-runtime";
2613
- function Blockquote() {
2614
- const { editor, editorState } = useControlContext();
2615
- return /* @__PURE__ */ jsx20(
2616
- Control,
2617
- {
2618
- icon: /* @__PURE__ */ jsx20(Quote, {}),
2619
- onClick: (e) => {
2620
- e.stopPropagation();
2621
- editor == null ? void 0 : editor.chain().focus().toggleBlockquote().run();
2622
- },
2623
- disabled: !(editorState == null ? void 0 : editorState.canBlockquote),
2624
- active: editorState == null ? void 0 : editorState.isBlockquote,
2625
- title: "Blockquote"
2626
- }
2627
- );
2628
- }
2629
-
2630
- // components/RichTextMenu/controls/HorizontalRule.tsx
2631
- init_react_import();
2632
- import { jsx as jsx21 } from "react/jsx-runtime";
2633
- function HorizontalRule() {
2634
- const { editor, editorState } = useControlContext();
2635
- return /* @__PURE__ */ jsx21(
2636
- Control,
2637
- {
2638
- icon: /* @__PURE__ */ jsx21(Minus, {}),
2639
- onClick: (e) => {
2640
- e.stopPropagation();
2641
- editor == null ? void 0 : editor.chain().focus().setHorizontalRule().run();
2642
- },
2643
- disabled: !(editorState == null ? void 0 : editorState.canHorizontalRule),
2644
- title: "Horizontal rule"
2645
- }
2646
- );
2647
- }
2648
-
2649
- // components/RichTextMenu/controls/HeadingSelect.tsx
2650
- init_react_import();
2651
- import { useEditorState as useEditorState2 } from "@tiptap/react";
2652
- import { useMemo as useMemo3 } from "react";
2653
- import { jsx as jsx22 } from "react/jsx-runtime";
2654
- var optionNodes2 = {
2655
- h1: { label: "Heading 1", icon: Heading1 },
2656
- h2: { label: "Heading 2", icon: Heading2 },
2657
- h3: { label: "Heading 3", icon: Heading3 },
2658
- h4: { label: "Heading 4", icon: Heading4 },
2659
- h5: { label: "Heading 5", icon: Heading5 },
2660
- h6: { label: "Heading 6", icon: Heading6 }
2661
- };
2662
- function HeadingSelect() {
2663
- var _a;
2664
- const { options } = useControlContext();
2665
- let blockOptions = [];
2666
- if ((options == null ? void 0 : options.heading) !== false) {
2667
- if (!((_a = options == null ? void 0 : options.heading) == null ? void 0 : _a.levels)) {
2668
- blockOptions = ["h1", "h2", "h3", "h4", "h5", "h6"];
2669
- } else {
2670
- if (options == null ? void 0 : options.heading.levels.includes(1)) {
2671
- blockOptions.push("h1");
2672
- }
2673
- if (options == null ? void 0 : options.heading.levels.includes(2)) {
2674
- blockOptions.push("h2");
2675
- }
2676
- if (options == null ? void 0 : options.heading.levels.includes(3)) {
2677
- blockOptions.push("h3");
2678
- }
2679
- if (options == null ? void 0 : options.heading.levels.includes(4)) {
2680
- blockOptions.push("h4");
2681
- }
2682
- if (options == null ? void 0 : options.heading.levels.includes(5)) {
2683
- blockOptions.push("h5");
2684
- }
2685
- if (options == null ? void 0 : options.heading.levels.includes(6)) {
2686
- blockOptions.push("h6");
2687
- }
2688
- }
2689
- }
2690
- const { editor } = useControlContext();
2691
- const currentValue = useEditorState2({
2692
- editor,
2693
- selector: (ctx) => {
2694
- var _a2, _b;
2695
- if ((_a2 = ctx.editor) == null ? void 0 : _a2.isActive("paragraph")) return "p";
2696
- for (let level = 1; level <= 6; level++) {
2697
- if ((_b = ctx.editor) == null ? void 0 : _b.isActive("heading", { level })) {
2698
- return `h${level}`;
2699
- }
2700
- }
2701
- return "p";
2702
- }
2703
- });
2704
- const handleChange = (val) => {
2705
- const chain = editor == null ? void 0 : editor.chain();
2706
- if (val === "p") {
2707
- chain == null ? void 0 : chain.focus().setParagraph().run();
2708
- } else {
2709
- const level = parseInt(val.replace("h", ""), 10);
2710
- chain == null ? void 0 : chain.focus().toggleHeading({ level }).run();
2711
- }
2712
- };
2713
- const loadedOptions = useMemo3(
2714
- () => blockOptions.map((item) => ({
2715
- value: item,
2716
- label: optionNodes2[item].label,
2717
- icon: optionNodes2[item].icon
2718
- })),
2719
- [blockOptions]
2720
- );
2721
- return /* @__PURE__ */ jsx22(
2722
- SelectControl,
2723
- {
2724
- options: loadedOptions,
2725
- onChange: handleChange,
2726
- value: currentValue != null ? currentValue : "p",
2727
- defaultValue: "p",
2728
- renderDefaultIcon: Heading
2729
- }
2730
- );
2731
- }
2732
-
2733
- // components/RichTextMenu/controls/ListSelect.tsx
2734
- init_react_import();
2735
- import { useEditorState as useEditorState3 } from "@tiptap/react";
2736
- import { useMemo as useMemo4 } from "react";
2737
- import { jsx as jsx23 } from "react/jsx-runtime";
2738
- var optionNodes3 = {
2739
- ul: { label: "Bullet list", icon: List },
2740
- ol: { label: "Numbered list", icon: ListOrdered }
2741
- };
2742
- function ListSelect() {
2743
- const { options } = useControlContext();
2744
- let blockOptions = [];
2745
- if ((options == null ? void 0 : options.listItem) !== false) {
2746
- blockOptions = ["ul", "ol"];
2747
- }
2748
- const { editor } = useControlContext();
2749
- const currentValue = useEditorState3({
2750
- editor,
2751
- selector: (ctx) => {
2752
- var _a, _b;
2753
- if ((_a = ctx.editor) == null ? void 0 : _a.isActive("bulletList")) return "ul";
2754
- if ((_b = ctx.editor) == null ? void 0 : _b.isActive("orderedList")) return "ol";
2755
- return "p";
2756
- }
2757
- });
2758
- const handleChange = (val) => {
2759
- const chain = editor == null ? void 0 : editor.chain();
2760
- if (val === "p") {
2761
- chain == null ? void 0 : chain.focus().setParagraph().run();
2762
- } else if (val === "ol") {
2763
- chain == null ? void 0 : chain.focus().toggleOrderedList().run();
2764
- } else if (val === "ul") {
2765
- chain == null ? void 0 : chain.focus().toggleBulletList().run();
2766
- }
2767
- };
2768
- const loadedOptions = useMemo4(
2769
- () => blockOptions.map((item) => ({
2770
- value: item,
2771
- label: optionNodes3[item].label,
2772
- icon: optionNodes3[item].icon
2773
- })),
2774
- [blockOptions]
2775
- );
2776
- return /* @__PURE__ */ jsx23(
2777
- SelectControl,
2778
- {
2779
- options: loadedOptions,
2780
- onChange: handleChange,
2781
- value: currentValue != null ? currentValue : "p",
2782
- defaultValue: "p",
2783
- renderDefaultIcon: List
1587
+ children: /* @__PURE__ */ jsx2(Node, {})
2784
1588
  }
2785
1589
  );
2786
1590
  }
2787
1591
 
2788
- // components/RichTextMenu/inner.tsx
2789
- import { jsx as jsx24, jsxs as jsxs4 } from "react/jsx-runtime";
2790
- var getClassName6 = get_class_name_factory_default("RichTextMenu", styles_module_default4);
2791
- var DefaultMenu = ({ children }) => {
2792
- return /* @__PURE__ */ jsx24(RichTextMenu, { children });
2793
- };
2794
- var RichTextMenu = ({ children }) => {
2795
- const { inline } = useControlContext();
2796
- return /* @__PURE__ */ jsx24("div", { className: getClassName6({ inline, form: !inline }), "data-puck-rte-menu": true, children });
2797
- };
2798
- var Group2 = ({ children }) => {
2799
- return /* @__PURE__ */ jsx24("div", { className: getClassName6("group"), children });
2800
- };
2801
- RichTextMenu.Group = Group2;
2802
- RichTextMenu.Control = Control;
2803
- RichTextMenu.AlignCenter = AlignCenter2;
2804
- RichTextMenu.AlignJustify = AlignJustify2;
2805
- RichTextMenu.AlignLeft = AlignLeft2;
2806
- RichTextMenu.AlignRight = AlignRight2;
2807
- RichTextMenu.AlignSelect = AlignSelect;
2808
- RichTextMenu.Blockquote = Blockquote;
2809
- RichTextMenu.Bold = Bold2;
2810
- RichTextMenu.BulletList = BulletList;
2811
- RichTextMenu.CodeBlock = CodeBlock;
2812
- RichTextMenu.HeadingSelect = HeadingSelect;
2813
- RichTextMenu.HorizontalRule = HorizontalRule;
2814
- RichTextMenu.InlineCode = InlineCode;
2815
- RichTextMenu.Italic = Italic2;
2816
- RichTextMenu.ListSelect = ListSelect;
2817
- RichTextMenu.OrderedList = OrderedList;
2818
- RichTextMenu.Strikethrough = Strikethrough2;
2819
- RichTextMenu.Underline = Underline2;
2820
- var LoadedRichTextMenuInner = ({
2821
- editor,
2822
- editorState,
2823
- field,
2824
- readOnly,
2825
- inline
2826
- }) => {
2827
- const { renderMenu, renderInlineMenu } = field;
2828
- const InlineMenu = useMemo5(
2829
- () => renderInlineMenu || DefaultMenu,
2830
- [renderInlineMenu]
2831
- );
2832
- const Menu = useMemo5(() => renderMenu || DefaultMenu, [renderMenu]);
2833
- return /* @__PURE__ */ jsx24(
2834
- ControlContext.Provider,
2835
- {
2836
- value: { editor, editorState, inline, options: field.options, readOnly },
2837
- children: inline ? /* @__PURE__ */ jsx24(
2838
- InlineMenu,
2839
- {
2840
- editor,
2841
- editorState,
2842
- readOnly,
2843
- children: /* @__PURE__ */ jsxs4(Group2, { children: [
2844
- /* @__PURE__ */ jsx24(Bold2, {}),
2845
- /* @__PURE__ */ jsx24(Italic2, {}),
2846
- /* @__PURE__ */ jsx24(Underline2, {})
2847
- ] })
2848
- }
2849
- ) : /* @__PURE__ */ jsxs4(Menu, { editor, editorState, readOnly, children: [
2850
- /* @__PURE__ */ jsxs4(Group2, { children: [
2851
- /* @__PURE__ */ jsx24(HeadingSelect, {}),
2852
- /* @__PURE__ */ jsx24(ListSelect, {})
2853
- ] }),
2854
- /* @__PURE__ */ jsxs4(Group2, { children: [
2855
- /* @__PURE__ */ jsx24(Bold2, {}),
2856
- /* @__PURE__ */ jsx24(Italic2, {}),
2857
- /* @__PURE__ */ jsx24(Underline2, {})
2858
- ] }),
2859
- /* @__PURE__ */ jsx24(Group2, { children: /* @__PURE__ */ jsx24(AlignSelect, {}) })
2860
- ] })
2861
- }
2862
- );
2863
- };
2864
-
2865
- // components/RichTextEditor/components/EditorInner.tsx
2866
- init_react_import();
2867
- import {
2868
- memo,
2869
- useCallback as useCallback2
2870
- } from "react";
2871
- import { jsx as jsx25, jsxs as jsxs5 } from "react/jsx-runtime";
2872
- var getClassName7 = get_class_name_factory_default("RichTextEditor", styles_module_default);
2873
- var EditorInner = memo(
2874
- ({
2875
- children,
2876
- menu,
2877
- readOnly = false,
2878
- field,
2879
- inline = false,
2880
- editor,
2881
- id
2882
- }) => {
2883
- const { initialHeight } = field;
2884
- const isActive = useAppStore(
2885
- (s) => {
2886
- var _a;
2887
- return ((_a = s.currentRichText) == null ? void 0 : _a.id) === id && inline === s.currentRichText.inline;
2888
- }
2889
- );
2890
- const appStoreApi = useAppStoreApi();
2891
- const handleHotkeyCapture = useCallback2(
2892
- (event) => {
2893
- var _a, _b;
2894
- if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "i") {
2895
- event.stopPropagation();
2896
- event.preventDefault();
2897
- (_b = editor == null ? void 0 : (_a = editor.commands).toggleItalic) == null ? void 0 : _b.call(_a);
2898
- }
2899
- },
2900
- [editor]
2901
- );
2902
- const handleBlur = useCallback2(
2903
- (e) => {
2904
- var _a, _b;
2905
- const targetInMenu = !!((_b = (_a = e.relatedTarget) == null ? void 0 : _a.closest) == null ? void 0 : _b.call(
2906
- _a,
2907
- "[data-puck-rte-menu]"
2908
- ));
2909
- if (e.relatedTarget && !targetInMenu) {
2910
- appStoreApi.setState({
2911
- currentRichText: null
2912
- });
2913
- } else {
2914
- e.stopPropagation();
2915
- }
2916
- },
2917
- [appStoreApi]
2918
- );
2919
- return /* @__PURE__ */ jsxs5(
2920
- "div",
2921
- {
2922
- className: getClassName7({
2923
- editor: !inline,
2924
- inline,
2925
- isActive,
2926
- disabled: readOnly
2927
- }),
2928
- style: inline ? {} : { height: initialHeight != null ? initialHeight : 256, overflowY: "auto" },
2929
- onKeyDownCapture: handleHotkeyCapture,
2930
- onBlur: handleBlur,
2931
- children: [
2932
- !inline && /* @__PURE__ */ jsx25("div", { className: getClassName7("menu"), children: menu }),
2933
- children
2934
- ]
2935
- }
2936
- );
2937
- }
2938
- );
2939
- EditorInner.displayName = "EditorInner";
2940
-
2941
- // components/RichTextMenu/index.tsx
2942
- init_react_import();
2943
- import { useEditorState as useEditorState4 } from "@tiptap/react";
2944
- import { useMemo as useMemo6 } from "react";
2945
-
2946
- // components/RichTextEditor/selector.ts
2947
- init_react_import();
2948
- var defaultEditorState = (ctx, readOnly) => {
2949
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
2950
- const editor = ctx.editor;
2951
- if (!editor) return {};
2952
- const canChain = () => editor.can().chain();
2953
- return {
2954
- isAlignLeft: editor.isActive({ textAlign: "left" }),
2955
- canAlignLeft: !readOnly && ((_b = (_a = canChain()).setTextAlign) == null ? void 0 : _b.call(_a, "left").run()),
2956
- isAlignCenter: editor.isActive({ textAlign: "center" }),
2957
- canAlignCenter: !readOnly && ((_d = (_c = canChain()).setTextAlign) == null ? void 0 : _d.call(_c, "center").run()),
2958
- isAlignRight: editor.isActive({ textAlign: "right" }),
2959
- canAlignRight: !readOnly && ((_f = (_e = canChain()).setTextAlign) == null ? void 0 : _f.call(_e, "right").run()),
2960
- isAlignJustify: editor.isActive({ textAlign: "justify" }),
2961
- canAlignJustify: !readOnly && ((_h = (_g = canChain()).setTextAlign) == null ? void 0 : _h.call(_g, "justify").run()),
2962
- isBold: editor.isActive("bold"),
2963
- canBold: !readOnly && ((_j = (_i = canChain()).toggleBold) == null ? void 0 : _j.call(_i).run()),
2964
- isItalic: editor.isActive("italic"),
2965
- canItalic: !readOnly && ((_l = (_k = canChain()).toggleItalic) == null ? void 0 : _l.call(_k).run()),
2966
- isUnderline: editor.isActive("underline"),
2967
- canUnderline: !readOnly && ((_n = (_m = canChain()).toggleUnderline) == null ? void 0 : _n.call(_m).run()),
2968
- isStrike: editor.isActive("strike"),
2969
- canStrike: !readOnly && ((_p = (_o = canChain()).toggleStrike) == null ? void 0 : _p.call(_o).run()),
2970
- isInlineCode: editor.isActive("code"),
2971
- canInlineCode: !readOnly && ((_r = (_q = canChain()).toggleCode) == null ? void 0 : _r.call(_q).run()),
2972
- isBulletList: editor.isActive("bulletList"),
2973
- canBulletList: !readOnly && ((_t = (_s = canChain()).toggleBulletList) == null ? void 0 : _t.call(_s).run()),
2974
- isOrderedList: editor.isActive("orderedList"),
2975
- canOrderedList: !readOnly && ((_v = (_u = canChain()).toggleOrderedList) == null ? void 0 : _v.call(_u).run()),
2976
- isCodeBlock: editor.isActive("codeBlock"),
2977
- canCodeBlock: !readOnly && ((_x = (_w = canChain()).toggleCodeBlock) == null ? void 0 : _x.call(_w).run()),
2978
- isBlockquote: editor.isActive("blockquote"),
2979
- canBlockquote: !readOnly && ((_z = (_y = canChain()).toggleBlockquote) == null ? void 0 : _z.call(_y).run()),
2980
- canHorizontalRule: !readOnly && ((_B = (_A = canChain()).setHorizontalRule) == null ? void 0 : _B.call(_A).run())
2981
- };
2982
- };
2983
-
2984
- // components/RichTextMenu/index.tsx
2985
- import { jsx as jsx26 } from "react/jsx-runtime";
2986
- var LoadedRichTextMenu = ({
2987
- editor,
2988
- field,
2989
- readOnly,
2990
- inline
2991
- }) => {
2992
- const { tiptap = {} } = field;
2993
- const { selector } = tiptap;
2994
- const resolvedSelector = useMemo6(() => {
2995
- return (ctx) => __spreadValues(__spreadValues({}, defaultEditorState(ctx, readOnly)), selector ? selector(ctx, readOnly) : {});
2996
- }, [selector, readOnly]);
2997
- const editorState = useEditorState4({
2998
- editor,
2999
- selector: resolvedSelector
3000
- });
3001
- if (!editor || !editorState) {
3002
- return null;
3003
- }
3004
- return /* @__PURE__ */ jsx26(
3005
- LoadedRichTextMenuInner,
3006
- {
3007
- editor,
3008
- editorState,
3009
- field,
3010
- readOnly,
3011
- inline
3012
- }
3013
- );
3014
- };
3015
-
3016
1592
  export {
3017
- ActionBar,
3018
- Action,
3019
- Group,
3020
- Label,
3021
- Separator,
1593
+ AlignCenter,
1594
+ AlignJustify,
1595
+ AlignLeft,
1596
+ AlignRight,
1597
+ Bold,
3022
1598
  ChevronDown,
3023
1599
  ChevronRight,
3024
1600
  ChevronUp,
3025
1601
  CircleCheckBig,
1602
+ Code,
3026
1603
  Copy,
3027
1604
  CornerLeftUp,
3028
1605
  EllipsisVertical,
3029
1606
  Globe,
3030
1607
  Hash,
1608
+ Heading1,
1609
+ Heading2,
1610
+ Heading3,
1611
+ Heading4,
1612
+ Heading5,
1613
+ Heading6,
1614
+ Heading,
1615
+ Italic,
3031
1616
  Layers,
3032
1617
  LayoutGrid,
3033
1618
  Link,
1619
+ ListOrdered,
3034
1620
  List,
3035
1621
  LockOpen,
3036
1622
  Lock,
1623
+ Minus,
3037
1624
  Monitor,
3038
1625
  PanelLeft,
3039
1626
  PanelRight,
3040
1627
  Plus,
1628
+ Quote,
3041
1629
  Redo2,
3042
1630
  Search,
3043
1631
  SlidersHorizontal,
3044
1632
  Smartphone,
1633
+ SquareCode,
1634
+ Strikethrough,
3045
1635
  Tablet,
3046
1636
  Trash,
3047
1637
  Type,
1638
+ Underline,
3048
1639
  Undo2,
3049
1640
  ZoomIn,
3050
1641
  ZoomOut,
3051
1642
  reorder,
3052
1643
  replace,
3053
- insert,
3054
- generateId,
3055
- populateIds,
3056
- insertAction,
3057
- getItem,
3058
- makeStatePublic,
3059
1644
  monitorHotkeys,
3060
1645
  useMonitorHotkeys,
3061
1646
  useHotkey,
@@ -3068,12 +1653,9 @@ export {
3068
1653
  useAppStoreApi,
3069
1654
  getBox,
3070
1655
  useResetAutoZoom,
3071
- Loader,
3072
- IconButton,
3073
- RichTextMenu,
3074
- LoadedRichTextMenuInner,
3075
- EditorInner,
3076
- LoadedRichTextMenu
1656
+ ControlContext,
1657
+ useControlContext,
1658
+ SelectControl
3077
1659
  };
3078
1660
  /*! Bundled license information:
3079
1661
 
@@ -3081,9 +1663,11 @@ lucide-react/dist/esm/shared/src/utils.js:
3081
1663
  lucide-react/dist/esm/defaultAttributes.js:
3082
1664
  lucide-react/dist/esm/Icon.js:
3083
1665
  lucide-react/dist/esm/createLucideIcon.js:
1666
+ lucide-react/dist/esm/icons/align-left.js:
1667
+ lucide-react/dist/esm/icons/heading.js:
1668
+ lucide-react/dist/esm/icons/list.js:
3084
1669
  lucide-react/dist/esm/icons/align-center.js:
3085
1670
  lucide-react/dist/esm/icons/align-justify.js:
3086
- lucide-react/dist/esm/icons/align-left.js:
3087
1671
  lucide-react/dist/esm/icons/align-right.js:
3088
1672
  lucide-react/dist/esm/icons/bold.js:
3089
1673
  lucide-react/dist/esm/icons/chevron-down.js:
@@ -3102,13 +1686,11 @@ lucide-react/dist/esm/icons/heading-3.js:
3102
1686
  lucide-react/dist/esm/icons/heading-4.js:
3103
1687
  lucide-react/dist/esm/icons/heading-5.js:
3104
1688
  lucide-react/dist/esm/icons/heading-6.js:
3105
- lucide-react/dist/esm/icons/heading.js:
3106
1689
  lucide-react/dist/esm/icons/italic.js:
3107
1690
  lucide-react/dist/esm/icons/layers.js:
3108
1691
  lucide-react/dist/esm/icons/layout-grid.js:
3109
1692
  lucide-react/dist/esm/icons/link.js:
3110
1693
  lucide-react/dist/esm/icons/list-ordered.js:
3111
- lucide-react/dist/esm/icons/list.js:
3112
1694
  lucide-react/dist/esm/icons/lock-open.js:
3113
1695
  lucide-react/dist/esm/icons/lock.js:
3114
1696
  lucide-react/dist/esm/icons/minus.js: