@measured/puck 0.19.0-canary.020071e → 0.19.0-canary.036267f6

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.
package/dist/rsc.js CHANGED
@@ -9,6 +9,9 @@ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
9
  var __getProtoOf = Object.getPrototypeOf;
10
10
  var __hasOwnProp = Object.prototype.hasOwnProperty;
11
11
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __typeError = (msg) => {
13
+ throw TypeError(msg);
14
+ };
12
15
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
16
  var __spreadValues = (a, b) => {
14
17
  for (var prop in b || (b = {}))
@@ -22,6 +25,24 @@ var __spreadValues = (a, b) => {
22
25
  return a;
23
26
  };
24
27
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
28
+ var __objRest = (source, exclude) => {
29
+ var target = {};
30
+ for (var prop in source)
31
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
32
+ target[prop] = source[prop];
33
+ if (source != null && __getOwnPropSymbols)
34
+ for (var prop of __getOwnPropSymbols(source)) {
35
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
36
+ target[prop] = source[prop];
37
+ }
38
+ return target;
39
+ };
40
+ var __esm = (fn, res) => function __init() {
41
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
42
+ };
43
+ var __commonJS = (cb, mod) => function __require() {
44
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
45
+ };
25
46
  var __export = (target, all) => {
26
47
  for (var name in all)
27
48
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -43,6 +64,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
43
64
  mod
44
65
  ));
45
66
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
67
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
68
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
69
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
70
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
46
71
  var __async = (__this, __arguments, generator) => {
47
72
  return new Promise((resolve, reject) => {
48
73
  var fulfilled = (value) => {
@@ -64,6 +89,77 @@ var __async = (__this, __arguments, generator) => {
64
89
  });
65
90
  };
66
91
 
92
+ // ../tsup-config/react-import.js
93
+ var import_react;
94
+ var init_react_import = __esm({
95
+ "../tsup-config/react-import.js"() {
96
+ "use strict";
97
+ import_react = __toESM(require("react"));
98
+ }
99
+ });
100
+
101
+ // ../../node_modules/classnames/index.js
102
+ var require_classnames = __commonJS({
103
+ "../../node_modules/classnames/index.js"(exports2, module2) {
104
+ "use strict";
105
+ init_react_import();
106
+ (function() {
107
+ "use strict";
108
+ var hasOwn = {}.hasOwnProperty;
109
+ function classNames() {
110
+ var classes = "";
111
+ for (var i = 0; i < arguments.length; i++) {
112
+ var arg = arguments[i];
113
+ if (arg) {
114
+ classes = appendClass(classes, parseValue(arg));
115
+ }
116
+ }
117
+ return classes;
118
+ }
119
+ function parseValue(arg) {
120
+ if (typeof arg === "string" || typeof arg === "number") {
121
+ return arg;
122
+ }
123
+ if (typeof arg !== "object") {
124
+ return "";
125
+ }
126
+ if (Array.isArray(arg)) {
127
+ return classNames.apply(null, arg);
128
+ }
129
+ if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
130
+ return arg.toString();
131
+ }
132
+ var classes = "";
133
+ for (var key in arg) {
134
+ if (hasOwn.call(arg, key) && arg[key]) {
135
+ classes = appendClass(classes, key);
136
+ }
137
+ }
138
+ return classes;
139
+ }
140
+ function appendClass(value, newClass) {
141
+ if (!newClass) {
142
+ return value;
143
+ }
144
+ if (value) {
145
+ return value + " " + newClass;
146
+ }
147
+ return value + newClass;
148
+ }
149
+ if (typeof module2 !== "undefined" && module2.exports) {
150
+ classNames.default = classNames;
151
+ module2.exports = classNames;
152
+ } else if (typeof define === "function" && typeof define.amd === "object" && define.amd) {
153
+ define("classnames", [], function() {
154
+ return classNames;
155
+ });
156
+ } else {
157
+ window.classNames = classNames;
158
+ }
159
+ })();
160
+ }
161
+ });
162
+
67
163
  // rsc.tsx
68
164
  var rsc_exports = {};
69
165
  __export(rsc_exports, {
@@ -72,16 +168,19 @@ __export(rsc_exports, {
72
168
  transformProps: () => transformProps
73
169
  });
74
170
  module.exports = __toCommonJS(rsc_exports);
171
+ init_react_import();
75
172
 
76
- // ../tsup-config/react-import.js
77
- var import_react = __toESM(require("react"));
173
+ // components/ServerRender/index.tsx
174
+ init_react_import();
78
175
 
79
176
  // lib/root-droppable-id.ts
177
+ init_react_import();
80
178
  var rootAreaId = "root";
81
179
  var rootZone = "default-zone";
82
180
  var rootDroppableId = `${rootAreaId}:${rootZone}`;
83
181
 
84
182
  // lib/setup-zone.ts
183
+ init_react_import();
85
184
  var setupZone = (data, zoneKey) => {
86
185
  if (zoneKey === rootDroppableId) {
87
186
  return data;
@@ -93,266 +192,3690 @@ var setupZone = (data, zoneKey) => {
93
192
  return newData;
94
193
  };
95
194
 
96
- // components/ServerRender/index.tsx
97
- var import_jsx_runtime = require("react/jsx-runtime");
98
- function DropZoneRender({
99
- zone,
100
- data,
101
- areaId = "root",
102
- config,
103
- metadata = {}
104
- }) {
105
- let zoneCompound = rootDroppableId;
106
- let content = (data == null ? void 0 : data.content) || [];
107
- if (!data || !config) {
108
- return null;
109
- }
110
- if (areaId !== rootAreaId && zone !== rootZone) {
111
- zoneCompound = `${areaId}:${zone}`;
112
- content = setupZone(data, zoneCompound).zones[zoneCompound];
113
- }
114
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: content.map((item) => {
115
- const Component = config.components[item.type];
116
- if (Component) {
117
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
118
- Component.render,
119
- __spreadProps(__spreadValues({}, item.props), {
120
- puck: {
121
- renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
122
- DropZoneRender,
123
- {
124
- zone: zone2,
125
- data,
126
- areaId: item.props.id,
127
- config,
128
- metadata
129
- }
130
- ),
131
- metadata
132
- }
133
- }),
134
- item.props.id
135
- );
195
+ // lib/use-slots.ts
196
+ init_react_import();
197
+ var import_react2 = require("react");
198
+ function useSlots(config, props, renderSlot) {
199
+ return (0, import_react2.useMemo)(() => {
200
+ if (!(config == null ? void 0 : config.fields)) return props;
201
+ const newProps = __spreadValues({}, props);
202
+ const fieldKeys = Object.keys(config.fields);
203
+ for (let i = 0; i < fieldKeys.length; i++) {
204
+ const fieldKey = fieldKeys[i];
205
+ const field = config.fields[fieldKey];
206
+ if ((field == null ? void 0 : field.type) === "slot") {
207
+ newProps[fieldKey] = (dzProps) => renderSlot(__spreadProps(__spreadValues({}, dzProps), {
208
+ zone: fieldKey,
209
+ content: props[fieldKey] || []
210
+ }));
211
+ }
136
212
  }
137
- return null;
138
- }) });
213
+ return newProps;
214
+ }, [config, props]);
139
215
  }
140
- function Render({
141
- config,
142
- data,
143
- metadata
144
- }) {
145
- var _a;
146
- if ((_a = config.root) == null ? void 0 : _a.render) {
147
- const rootProps = data.root.props || data.root;
148
- const title = rootProps.title || "";
149
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
150
- config.root.render,
151
- __spreadProps(__spreadValues({}, rootProps), {
152
- puck: {
153
- renderDropZone: ({ zone }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
154
- DropZoneRender,
155
- {
156
- zone,
157
- data,
158
- config,
159
- metadata
160
- }
161
- ),
162
- isEditing: false,
163
- dragRef: null
164
- },
165
- title,
166
- editMode: false,
167
- id: "puck-root",
168
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
169
- DropZoneRender,
170
- {
171
- config,
172
- data,
173
- zone: rootZone,
174
- metadata
175
- }
176
- )
177
- })
216
+
217
+ // components/SlotRender/index.tsx
218
+ init_react_import();
219
+ var import_react26 = require("react");
220
+
221
+ // components/DropZone/index.tsx
222
+ init_react_import();
223
+ var import_react25 = require("react");
224
+
225
+ // components/DraggableComponent/index.tsx
226
+ init_react_import();
227
+ var import_react13 = require("react");
228
+
229
+ // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
230
+ init_react_import();
231
+ var styles_module_default = { "DraggableComponent": "_DraggableComponent_1ukn8_1", "DraggableComponent-overlay": "_DraggableComponent-overlay_1ukn8_12", "DraggableComponent-loadingOverlay": "_DraggableComponent-loadingOverlay_1ukn8_29", "DraggableComponent--hover": "_DraggableComponent--hover_1ukn8_45", "DraggableComponent--isLocked": "_DraggableComponent--isLocked_1ukn8_45", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_1ukn8_54", "DraggableComponent-actionsOverlay": "_DraggableComponent-actionsOverlay_1ukn8_66", "DraggableComponent-actions": "_DraggableComponent-actions_1ukn8_66" };
232
+
233
+ // lib/get-class-name-factory.ts
234
+ init_react_import();
235
+ var import_classnames = __toESM(require_classnames());
236
+ var getClassNameFactory = (rootClass, styles, config = { baseClass: "" }) => (options = {}) => {
237
+ if (typeof options === "string") {
238
+ const descendant = options;
239
+ const style = styles[`${rootClass}-${descendant}`];
240
+ if (style) {
241
+ return config.baseClass + styles[`${rootClass}-${descendant}`] || "";
242
+ }
243
+ return "";
244
+ } else if (typeof options === "object") {
245
+ const modifiers = options;
246
+ const prefixedModifiers = {};
247
+ for (let modifier in modifiers) {
248
+ prefixedModifiers[styles[`${rootClass}--${modifier}`]] = modifiers[modifier];
249
+ }
250
+ const c = styles[rootClass];
251
+ return config.baseClass + (0, import_classnames.default)(__spreadValues({
252
+ [c]: !!c
253
+ }, prefixedModifiers));
254
+ } else {
255
+ return config.baseClass + styles[rootClass] || "";
256
+ }
257
+ };
258
+ var get_class_name_factory_default = getClassNameFactory;
259
+
260
+ // ../../node_modules/lucide-react/dist/esm/lucide-react.js
261
+ init_react_import();
262
+
263
+ // ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
264
+ init_react_import();
265
+ var import_react4 = require("react");
266
+
267
+ // ../../node_modules/lucide-react/dist/esm/shared/src/utils.js
268
+ init_react_import();
269
+ var toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
270
+ var mergeClasses = (...classes) => classes.filter((className, index, array) => {
271
+ return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
272
+ }).join(" ").trim();
273
+
274
+ // ../../node_modules/lucide-react/dist/esm/Icon.js
275
+ init_react_import();
276
+ var import_react3 = require("react");
277
+
278
+ // ../../node_modules/lucide-react/dist/esm/defaultAttributes.js
279
+ init_react_import();
280
+ var defaultAttributes = {
281
+ xmlns: "http://www.w3.org/2000/svg",
282
+ width: 24,
283
+ height: 24,
284
+ viewBox: "0 0 24 24",
285
+ fill: "none",
286
+ stroke: "currentColor",
287
+ strokeWidth: 2,
288
+ strokeLinecap: "round",
289
+ strokeLinejoin: "round"
290
+ };
291
+
292
+ // ../../node_modules/lucide-react/dist/esm/Icon.js
293
+ var Icon = (0, import_react3.forwardRef)(
294
+ (_a, ref) => {
295
+ var _b = _a, {
296
+ color = "currentColor",
297
+ size = 24,
298
+ strokeWidth = 2,
299
+ absoluteStrokeWidth,
300
+ className = "",
301
+ children,
302
+ iconNode
303
+ } = _b, rest = __objRest(_b, [
304
+ "color",
305
+ "size",
306
+ "strokeWidth",
307
+ "absoluteStrokeWidth",
308
+ "className",
309
+ "children",
310
+ "iconNode"
311
+ ]);
312
+ return (0, import_react3.createElement)(
313
+ "svg",
314
+ __spreadValues(__spreadProps(__spreadValues({
315
+ ref
316
+ }, defaultAttributes), {
317
+ width: size,
318
+ height: size,
319
+ stroke: color,
320
+ strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
321
+ className: mergeClasses("lucide", className)
322
+ }), rest),
323
+ [
324
+ ...iconNode.map(([tag, attrs]) => (0, import_react3.createElement)(tag, attrs)),
325
+ ...Array.isArray(children) ? children : [children]
326
+ ]
178
327
  );
179
328
  }
180
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
181
- DropZoneRender,
182
- {
183
- config,
184
- data,
185
- zone: rootZone,
186
- metadata
329
+ );
330
+
331
+ // ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
332
+ var createLucideIcon = (iconName, iconNode) => {
333
+ const Component = (0, import_react4.forwardRef)(
334
+ (_a, ref) => {
335
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
336
+ return (0, import_react4.createElement)(Icon, __spreadValues({
337
+ ref,
338
+ iconNode,
339
+ className: mergeClasses(`lucide-${toKebabCase(iconName)}`, className)
340
+ }, props));
187
341
  }
188
342
  );
343
+ Component.displayName = `${iconName}`;
344
+ return Component;
345
+ };
346
+
347
+ // ../../node_modules/lucide-react/dist/esm/icons/copy.js
348
+ init_react_import();
349
+ var Copy = createLucideIcon("Copy", [
350
+ ["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
351
+ ["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" }]
352
+ ]);
353
+
354
+ // ../../node_modules/lucide-react/dist/esm/icons/corner-left-up.js
355
+ init_react_import();
356
+ var CornerLeftUp = createLucideIcon("CornerLeftUp", [
357
+ ["polyline", { points: "14 9 9 4 4 9", key: "m9oyvo" }],
358
+ ["path", { d: "M20 20h-7a4 4 0 0 1-4-4V4", key: "1blwi3" }]
359
+ ]);
360
+
361
+ // ../../node_modules/lucide-react/dist/esm/icons/trash.js
362
+ init_react_import();
363
+ var Trash = createLucideIcon("Trash", [
364
+ ["path", { d: "M3 6h18", key: "d0wm0j" }],
365
+ ["path", { d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6", key: "4alrt4" }],
366
+ ["path", { d: "M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2", key: "v07s0e" }]
367
+ ]);
368
+
369
+ // store/index.ts
370
+ init_react_import();
371
+
372
+ // reducer/index.ts
373
+ init_react_import();
374
+
375
+ // reducer/reduce.ts
376
+ init_react_import();
377
+
378
+ // lib/insert.ts
379
+ init_react_import();
380
+ var insert = (list, index, item) => {
381
+ const result = Array.from(list || []);
382
+ result.splice(index, 0, item);
383
+ return result;
384
+ };
385
+
386
+ // lib/remove.ts
387
+ init_react_import();
388
+ var remove = (list, index) => {
389
+ const result = Array.from(list);
390
+ result.splice(index, 1);
391
+ return result;
392
+ };
393
+
394
+ // lib/get-item.ts
395
+ init_react_import();
396
+ function getItem(selector, state) {
397
+ var _a, _b;
398
+ const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
399
+ return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
189
400
  }
190
401
 
191
- // lib/get-changed.ts
192
- var getChanged = (newItem, oldItem) => {
193
- return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
194
- const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
195
- const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
196
- return __spreadProps(__spreadValues({}, acc), {
197
- [item]: oldItemProps[item] !== newItemProps[item]
198
- });
199
- }, {}) : {};
402
+ // lib/generate-id.ts
403
+ init_react_import();
404
+ var import_uuid = require("uuid");
405
+ var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, import_uuid.v4)();
406
+
407
+ // lib/walk-tree.ts
408
+ init_react_import();
409
+
410
+ // lib/for-each-slot.ts
411
+ init_react_import();
412
+
413
+ // lib/is-slot.ts
414
+ init_react_import();
415
+ var isSlot = (prop) => {
416
+ var _a, _b;
417
+ return Array.isArray(prop) && typeof ((_a = prop[0]) == null ? void 0 : _a.type) === "string" && typeof ((_b = prop[0]) == null ? void 0 : _b.props) === "object";
200
418
  };
201
419
 
202
- // lib/resolve-component-data.ts
203
- var cache = { lastChange: {} };
204
- var resolveAllComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (content, config, metadata = {}, onResolveStart, onResolveEnd) {
205
- return yield Promise.all(
206
- content.map((item) => __async(void 0, null, function* () {
207
- return yield resolveComponentData(
208
- item,
209
- config,
210
- metadata,
211
- onResolveStart,
212
- onResolveEnd
213
- );
214
- }))
215
- );
216
- });
217
- var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd) {
218
- const configForItem = config.components[item.type];
219
- if (configForItem.resolveData) {
220
- const { item: oldItem = null, resolved = {} } = cache.lastChange[item.props.id] || {};
221
- if (item && item === oldItem) {
222
- return resolved;
223
- }
224
- const changed = getChanged(item, oldItem);
225
- if (onResolveStart) {
226
- onResolveStart(item);
227
- }
228
- const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
229
- changed,
230
- lastData: oldItem,
231
- metadata
232
- });
233
- const resolvedItem = __spreadProps(__spreadValues({}, item), {
234
- props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
235
- });
236
- if (Object.keys(readOnly).length) {
237
- resolvedItem.readOnly = readOnly;
238
- }
239
- cache.lastChange[item.props.id] = {
240
- item,
241
- resolved: resolvedItem
242
- };
243
- if (onResolveEnd) {
244
- onResolveEnd(resolvedItem);
420
+ // lib/for-each-slot.ts
421
+ var forEachSlot = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, cb, recursive = false, isSlot2 = isSlot) {
422
+ const props = item.props || {};
423
+ const propKeys = Object.keys(props);
424
+ for (let i = 0; i < propKeys.length; i++) {
425
+ const propKey = propKeys[i];
426
+ const itemType = "type" in item ? item.type : "root";
427
+ if (isSlot2(itemType, propKey, props[propKey])) {
428
+ const content = props[propKey];
429
+ yield cb(props.id, propKey, content);
430
+ if (recursive) {
431
+ content.forEach(
432
+ (childItem) => __async(void 0, null, function* () {
433
+ return yield forEachSlot(childItem, cb, true, isSlot2);
434
+ })
435
+ );
436
+ }
245
437
  }
246
- return resolvedItem;
247
438
  }
248
- return item;
249
439
  });
250
440
 
251
- // lib/resolve-root-data.ts
252
- var cache2 = {};
253
- function resolveRootData(data, config, metadata) {
254
- return __async(this, null, function* () {
255
- var _a, _b, _c, _d, _e;
256
- if (((_a = config.root) == null ? void 0 : _a.resolveData) && data.root.props) {
257
- if (((_b = cache2.lastChange) == null ? void 0 : _b.original) === data.root) {
258
- return cache2.lastChange.resolved;
259
- }
260
- const changed = getChanged(data.root, (_c = cache2.lastChange) == null ? void 0 : _c.original);
261
- const rootWithProps = data.root;
262
- const resolvedRoot = yield (_e = config.root) == null ? void 0 : _e.resolveData(rootWithProps, {
263
- changed,
264
- lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {},
265
- metadata: metadata || {}
266
- });
267
- cache2.lastChange = {
268
- original: data.root,
269
- resolved: resolvedRoot
270
- };
271
- return __spreadProps(__spreadValues(__spreadValues({}, data.root), resolvedRoot), {
272
- props: __spreadValues(__spreadValues({}, data.root.props), resolvedRoot.props)
273
- });
441
+ // lib/for-related-zones.ts
442
+ init_react_import();
443
+
444
+ // lib/get-zone-id.ts
445
+ init_react_import();
446
+ var getZoneId = (zoneCompound) => {
447
+ if (!zoneCompound) {
448
+ return [];
449
+ }
450
+ if (zoneCompound && zoneCompound.indexOf(":") > -1) {
451
+ return zoneCompound.split(":");
452
+ }
453
+ return [rootDroppableId, zoneCompound];
454
+ };
455
+
456
+ // lib/for-related-zones.ts
457
+ function forRelatedZones(item, data, cb, path = []) {
458
+ Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
459
+ const [parentId] = getZoneId(zoneCompound);
460
+ if (parentId === item.props.id) {
461
+ const newPath = [...path, zoneCompound];
462
+ content.forEach((item2) => forRelatedZones(item2, data, cb, newPath));
463
+ cb(path, zoneCompound, content);
274
464
  }
275
- return data.root;
276
465
  });
277
466
  }
278
467
 
279
- // lib/default-data.ts
280
- var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
281
- root: data.root || {},
282
- content: data.content || []
283
- });
468
+ // lib/strip-slots.ts
469
+ init_react_import();
470
+ var stripSlots = (data) => {
471
+ return __spreadProps(__spreadValues({}, data), {
472
+ props: Object.entries(data.props).reduce(
473
+ (acc, [propKey, propVal]) => {
474
+ if (isSlot(propVal)) {
475
+ return acc;
476
+ }
477
+ return __spreadProps(__spreadValues({}, acc), { [propKey]: propVal });
478
+ },
479
+ { id: data.props.id }
480
+ )
481
+ });
482
+ };
284
483
 
285
- // lib/resolve-all-data.ts
286
- function resolveAllData(_0, _1) {
287
- return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
288
- const defaultedData = defaultData(data);
289
- const dynamicRoot = yield resolveRootData(
290
- defaultedData,
291
- config,
292
- metadata
484
+ // lib/walk-tree.ts
485
+ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
486
+ var _a;
487
+ let newZones = {};
488
+ const newZoneIndex = {};
489
+ const newNodeIndex = {};
490
+ const processContent = (path, zoneCompound, content, zoneType, newId) => {
491
+ var _a2;
492
+ const [parentId] = zoneCompound.split(":");
493
+ const mappedContent = ((_a2 = mapContent(content, zoneCompound, zoneType)) != null ? _a2 : content) || [];
494
+ const [_2, zone] = zoneCompound.split(":");
495
+ const newZoneCompound = `${newId || parentId}:${zone}`;
496
+ const newContent2 = mappedContent.map(
497
+ (zoneChild, index) => processItem(zoneChild, [...path, newZoneCompound], index)
293
498
  );
294
- const { zones = {} } = data;
295
- const zoneKeys = Object.keys(zones);
296
- const resolvedZones = {};
297
- for (let i = 0; i < zoneKeys.length; i++) {
298
- const zoneKey = zoneKeys[i];
299
- resolvedZones[zoneKey] = yield resolveAllComponentData(
300
- zones[zoneKey],
301
- config,
302
- metadata,
303
- onResolveStart,
304
- onResolveEnd
305
- );
499
+ newZoneIndex[newZoneCompound] = {
500
+ contentIds: newContent2.map((item) => item.props.id),
501
+ type: zoneType
502
+ };
503
+ return [newZoneCompound, newContent2];
504
+ };
505
+ const processRelatedZones = (item, newId, initialPath) => {
506
+ forRelatedZones(
507
+ item,
508
+ state.data,
509
+ (relatedPath, relatedZoneCompound, relatedContent) => {
510
+ const [zoneCompound, newContent2] = processContent(
511
+ relatedPath,
512
+ relatedZoneCompound,
513
+ relatedContent,
514
+ "dropzone",
515
+ newId
516
+ );
517
+ newZones[zoneCompound] = newContent2;
518
+ },
519
+ initialPath
520
+ );
521
+ };
522
+ const processItem = (item, path, index) => {
523
+ const mappedItem = mapNodeOrSkip(item, path, index);
524
+ if (!mappedItem) return item;
525
+ const id = mappedItem.props.id;
526
+ processRelatedZones(item, id, path);
527
+ const newProps = __spreadValues({}, mappedItem.props);
528
+ forEachSlot(
529
+ mappedItem,
530
+ (parentId2, slotId, content) => {
531
+ const zoneCompound = `${parentId2}:${slotId}`;
532
+ const [_2, newContent2] = processContent(
533
+ path,
534
+ zoneCompound,
535
+ content,
536
+ "slot",
537
+ parentId2
538
+ );
539
+ newProps[slotId] = newContent2;
540
+ },
541
+ false,
542
+ (itemType, propName, propValue) => {
543
+ var _a2, _b;
544
+ const configForComponent = itemType === "root" ? config == null ? void 0 : config.root : config == null ? void 0 : config.components[itemType];
545
+ if (!configForComponent) return isSlot(propValue);
546
+ return ((_b = (_a2 = configForComponent.fields) == null ? void 0 : _a2[propName]) == null ? void 0 : _b.type) === "slot";
547
+ }
548
+ );
549
+ const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
550
+ const thisZoneCompound = path[path.length - 1];
551
+ const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
552
+ newNodeIndex[id] = {
553
+ data: newItem,
554
+ flatData: stripSlots(newItem),
555
+ path,
556
+ parentId,
557
+ zone
558
+ };
559
+ const finalData = newItem;
560
+ if (newProps.id === "root") {
561
+ delete finalData["type"];
562
+ delete finalData.props["id"];
563
+ }
564
+ return finalData;
565
+ };
566
+ const zones = state.data.zones || {};
567
+ const [_, newContent] = processContent(
568
+ [],
569
+ rootDroppableId,
570
+ state.data.content,
571
+ "root"
572
+ );
573
+ const processedContent = newContent;
574
+ Object.keys(zones || {}).forEach((zoneCompound) => {
575
+ const [parentId] = zoneCompound.split(":");
576
+ const [_2, newContent2] = processContent(
577
+ [rootDroppableId],
578
+ zoneCompound,
579
+ zones[zoneCompound],
580
+ "dropzone",
581
+ parentId
582
+ );
583
+ newZones[zoneCompound] = newContent2;
584
+ }, newZones);
585
+ const processedRoot = processItem(
586
+ {
587
+ type: "root",
588
+ props: __spreadProps(__spreadValues({}, (_a = state.data.root.props) != null ? _a : state.data.root), { id: "root" })
589
+ },
590
+ [],
591
+ -1
592
+ );
593
+ const root = __spreadProps(__spreadValues({}, state.data.root), {
594
+ props: processedRoot.props
595
+ });
596
+ return __spreadProps(__spreadValues({}, state), {
597
+ data: {
598
+ root,
599
+ // root: state.data.root, // TODO changing root causes it's entire subtree to re-render. Let's keep this disabled until the performance issues are resolved in #644.
600
+ content: processedContent,
601
+ zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
602
+ },
603
+ indexes: {
604
+ nodes: __spreadValues(__spreadValues({}, state.indexes.nodes), newNodeIndex),
605
+ zones: __spreadValues(__spreadValues({}, state.indexes.zones), newZoneIndex)
306
606
  }
307
- return __spreadProps(__spreadValues({}, defaultedData), {
308
- root: dynamicRoot,
309
- content: yield resolveAllComponentData(
310
- defaultedData.content,
311
- config,
312
- metadata,
313
- onResolveStart,
314
- onResolveEnd
315
- ),
316
- zones: resolvedZones
317
- });
318
607
  });
319
608
  }
320
609
 
321
- // lib/transform-props.ts
322
- function transformProps(data, propTransforms) {
323
- const mapItem = (item) => {
324
- if (propTransforms[item.type]) {
325
- return __spreadProps(__spreadValues({}, item), {
326
- props: propTransforms[item.type](item.props)
610
+ // lib/deindex.ts
611
+ init_react_import();
612
+ var deindex = (state, componentData) => {
613
+ let zones = __spreadValues({}, state.indexes.zones);
614
+ let nodes = __spreadValues({}, state.indexes.nodes);
615
+ const dindexRelatedZones = (item) => {
616
+ forRelatedZones(item, state.data, (_path, zoneCompound, content) => {
617
+ content.forEach((subItem) => {
618
+ dindexChildren(subItem);
619
+ delete nodes[subItem.props.id];
327
620
  });
328
- }
329
- return item;
621
+ delete zones[zoneCompound];
622
+ });
330
623
  };
331
- const defaultedData = defaultData(data);
332
- const rootProps = defaultedData.root.props || defaultedData.root;
333
- let newRoot = __spreadValues({}, defaultedData.root);
334
- if (propTransforms["root"]) {
335
- if (defaultedData.root.props) {
336
- newRoot.props = propTransforms["root"](rootProps);
337
- } else {
338
- newRoot = propTransforms["root"](rootProps);
624
+ const dindexChildren = (item) => {
625
+ forEachSlot(
626
+ item,
627
+ (parentId, slotId, content) => {
628
+ const zoneCompound = `${parentId}:${slotId}`;
629
+ delete zones[zoneCompound];
630
+ content.forEach((item2) => {
631
+ dindexRelatedZones(item2);
632
+ delete nodes[item2.props.id];
633
+ });
634
+ },
635
+ true
636
+ );
637
+ };
638
+ dindexRelatedZones(componentData);
639
+ dindexChildren(componentData);
640
+ delete nodes[componentData.props.id];
641
+ return { nodes, zones };
642
+ };
643
+
644
+ // reducer/reduce.ts
645
+ var zoneCache = {};
646
+ var getIdsForParent = (zoneCompound, state) => {
647
+ const [parentId] = zoneCompound.split(":");
648
+ const node = state.indexes.nodes[parentId];
649
+ return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
650
+ };
651
+ function insertAction(state, action, config) {
652
+ const id = action.id || generateId(action.componentType);
653
+ const emptyComponentData = {
654
+ type: action.componentType,
655
+ props: __spreadProps(__spreadValues({}, config.components[action.componentType].defaultProps || {}), {
656
+ id
657
+ })
658
+ };
659
+ const [parentId] = action.destinationZone.split(":");
660
+ const idsInPath = getIdsForParent(action.destinationZone, state);
661
+ return walkTree(
662
+ state,
663
+ config,
664
+ (content, zoneCompound) => {
665
+ if (zoneCompound === action.destinationZone) {
666
+ return insert(
667
+ content || [],
668
+ action.destinationIndex,
669
+ emptyComponentData
670
+ );
671
+ }
672
+ return content;
673
+ },
674
+ (childItem, path) => {
675
+ if (childItem.props.id === id || childItem.props.id === parentId) {
676
+ return childItem;
677
+ } else if (idsInPath.includes(childItem.props.id)) {
678
+ return childItem;
679
+ } else if (path.includes(action.destinationZone)) {
680
+ return childItem;
681
+ }
682
+ return null;
339
683
  }
340
- }
341
- const afterPropTransforms = __spreadProps(__spreadValues({}, defaultedData), {
342
- root: newRoot,
343
- content: defaultedData.content.map(mapItem),
344
- zones: Object.keys(data.zones || {}).reduce(
345
- (acc, zoneKey) => __spreadProps(__spreadValues({}, acc), {
346
- [zoneKey]: data.zones[zoneKey].map(mapItem)
347
- }),
348
- {}
349
- )
350
- });
351
- return afterPropTransforms;
684
+ );
352
685
  }
353
- // Annotate the CommonJS export names for ESM import in node:
354
- 0 && (module.exports = {
355
- Render,
356
- resolveAllData,
357
- transformProps
358
- });
686
+ var moveAction = (state, action, appStore) => {
687
+ if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
688
+ return state;
689
+ }
690
+ const item = getItem(
691
+ { zone: action.sourceZone, index: action.sourceIndex },
692
+ state
693
+ );
694
+ if (!item) return state;
695
+ const idsInSourcePath = getIdsForParent(action.sourceZone, state);
696
+ const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
697
+ return walkTree(
698
+ state,
699
+ appStore.config,
700
+ (content, zoneCompound) => {
701
+ if (zoneCompound === action.sourceZone && zoneCompound === action.destinationZone) {
702
+ return insert(
703
+ remove(content, action.sourceIndex),
704
+ action.destinationIndex,
705
+ item
706
+ );
707
+ } else if (zoneCompound === action.sourceZone) {
708
+ return remove(content, action.sourceIndex);
709
+ } else if (zoneCompound === action.destinationZone) {
710
+ return insert(content, action.destinationIndex, item);
711
+ }
712
+ return content;
713
+ },
714
+ (childItem, path) => {
715
+ const [sourceZoneParent] = action.sourceZone.split(":");
716
+ const [destinationZoneParent] = action.destinationZone.split(":");
717
+ const childId = childItem.props.id;
718
+ if (sourceZoneParent === childId || destinationZoneParent === childId || item.props.id === childId || idsInSourcePath.indexOf(childId) > -1 || idsInDestinationPath.indexOf(childId) > -1 || path.includes(action.destinationZone)) {
719
+ return childItem;
720
+ }
721
+ return null;
722
+ }
723
+ );
724
+ };
725
+ var replaceAction = (state, action, appStore) => {
726
+ const [parentId] = action.destinationZone.split(":");
727
+ const idsInPath = getIdsForParent(action.destinationZone, state);
728
+ return walkTree(
729
+ state,
730
+ appStore.config,
731
+ (content) => content,
732
+ (childItem, path) => {
733
+ const pathIds = path.map((p) => p.split(":")[0]);
734
+ if (childItem.props.id === action.data.props.id) {
735
+ return action.data;
736
+ } else if (childItem.props.id === parentId) {
737
+ return childItem;
738
+ } else if (idsInPath.indexOf(childItem.props.id) > -1) {
739
+ return childItem;
740
+ } else if (pathIds.indexOf(action.data.props.id) > -1) {
741
+ return childItem;
742
+ }
743
+ return null;
744
+ }
745
+ );
746
+ };
747
+ var setAction = (state, action, appStore) => {
748
+ if (typeof action.state === "object") {
749
+ const newState = __spreadValues(__spreadValues({}, state), action.state);
750
+ if (action.state.indexes) {
751
+ console.warn(
752
+ "`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
753
+ );
754
+ return newState;
755
+ }
756
+ return walkTree(newState, appStore.config);
757
+ }
758
+ return __spreadValues(__spreadValues({}, state), action.state(state));
759
+ };
760
+ function reduce(state, action, appStore) {
761
+ if (action.type === "set") {
762
+ return setAction(state, action, appStore);
763
+ }
764
+ if (action.type === "insert") {
765
+ return insertAction(state, action, appStore.config);
766
+ }
767
+ if (action.type === "replace") {
768
+ return replaceAction(state, action, appStore);
769
+ }
770
+ if (action.type === "replaceRoot") {
771
+ return walkTree(
772
+ state,
773
+ appStore.config,
774
+ (content) => content,
775
+ (childItem) => {
776
+ if (childItem.props.id === "root") {
777
+ return __spreadProps(__spreadValues({}, childItem), {
778
+ props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
779
+ readOnly: action.root.readOnly
780
+ });
781
+ }
782
+ return childItem;
783
+ }
784
+ );
785
+ }
786
+ if (action.type === "duplicate") {
787
+ const item = getItem(
788
+ { index: action.sourceIndex, zone: action.sourceZone },
789
+ state
790
+ );
791
+ const idsInPath = getIdsForParent(action.sourceZone, state);
792
+ const newItem = __spreadProps(__spreadValues({}, item), {
793
+ props: __spreadProps(__spreadValues({}, item.props), {
794
+ id: generateId(item.type)
795
+ })
796
+ });
797
+ const modified = walkTree(
798
+ state,
799
+ appStore.config,
800
+ (content, zoneCompound) => {
801
+ if (zoneCompound === action.sourceZone) {
802
+ return insert(content, action.sourceIndex + 1, item);
803
+ }
804
+ return content;
805
+ },
806
+ (childItem, path, index) => {
807
+ const zoneCompound = path[path.length - 1];
808
+ const parents = path.map((p) => p.split(":")[0]);
809
+ if (parents.indexOf(newItem.props.id) > -1) {
810
+ return __spreadProps(__spreadValues({}, childItem), {
811
+ props: __spreadProps(__spreadValues({}, childItem.props), {
812
+ id: generateId(childItem.type)
813
+ })
814
+ });
815
+ }
816
+ if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
817
+ return newItem;
818
+ }
819
+ const [sourceZoneParent] = action.sourceZone.split(":");
820
+ if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
821
+ return childItem;
822
+ }
823
+ return null;
824
+ }
825
+ );
826
+ return __spreadProps(__spreadValues({}, modified), {
827
+ ui: __spreadProps(__spreadValues({}, modified.ui), {
828
+ itemSelector: {
829
+ index: action.sourceIndex + 1,
830
+ zone: action.sourceZone
831
+ }
832
+ })
833
+ });
834
+ }
835
+ if (action.type === "reorder") {
836
+ return moveAction(
837
+ state,
838
+ {
839
+ type: "move",
840
+ sourceIndex: action.sourceIndex,
841
+ sourceZone: action.destinationZone,
842
+ destinationIndex: action.destinationIndex,
843
+ destinationZone: action.destinationZone
844
+ },
845
+ appStore
846
+ );
847
+ }
848
+ if (action.type === "move") {
849
+ return moveAction(state, action, appStore);
850
+ }
851
+ if (action.type === "remove") {
852
+ const item = getItem({ index: action.index, zone: action.zone }, state);
853
+ let deindexed = deindex(state, item);
854
+ const [parentId] = action.zone.split(":");
855
+ return walkTree(
856
+ __spreadProps(__spreadValues({}, state), { indexes: deindexed }),
857
+ appStore.config,
858
+ (content, zoneCompound) => {
859
+ if (zoneCompound === action.zone) {
860
+ return remove(content, action.index);
861
+ }
862
+ return content;
863
+ },
864
+ (childItem, path) => {
865
+ const parentIds = path.map((p) => p.split(":")[0]);
866
+ if (childItem.props.id === parentId || childItem.props.id === item.props.id || parentIds.indexOf(item.props.id) > -1) {
867
+ return childItem;
868
+ }
869
+ return null;
870
+ }
871
+ );
872
+ }
873
+ if (action.type === "registerZone") {
874
+ if (zoneCache[action.zone]) {
875
+ return __spreadProps(__spreadValues({}, state), {
876
+ data: __spreadProps(__spreadValues({}, state.data), {
877
+ zones: __spreadProps(__spreadValues({}, state.data.zones), {
878
+ [action.zone]: zoneCache[action.zone]
879
+ })
880
+ }),
881
+ indexes: __spreadProps(__spreadValues({}, state.indexes), {
882
+ zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
883
+ [action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
884
+ contentIds: zoneCache[action.zone].map((item) => item.props.id),
885
+ type: "dropzone"
886
+ })
887
+ })
888
+ })
889
+ });
890
+ }
891
+ return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
892
+ }
893
+ if (action.type === "unregisterZone") {
894
+ const _zones = __spreadValues({}, state.data.zones || {});
895
+ const zoneIndex = __spreadValues({}, state.indexes.zones || {});
896
+ if (_zones[action.zone]) {
897
+ zoneCache[action.zone] = _zones[action.zone];
898
+ delete _zones[action.zone];
899
+ }
900
+ delete zoneIndex[action.zone];
901
+ return __spreadProps(__spreadValues({}, state), {
902
+ data: __spreadProps(__spreadValues({}, state.data), {
903
+ zones: _zones
904
+ }),
905
+ indexes: __spreadProps(__spreadValues({}, state.indexes), {
906
+ zones: zoneIndex
907
+ })
908
+ });
909
+ }
910
+ if (action.type === "setData") {
911
+ if (typeof action.data === "object") {
912
+ console.warn(
913
+ "`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
914
+ );
915
+ return walkTree(
916
+ __spreadProps(__spreadValues({}, state), {
917
+ data: __spreadValues(__spreadValues({}, state.data), action.data)
918
+ }),
919
+ appStore.config
920
+ );
921
+ }
922
+ return walkTree(
923
+ __spreadProps(__spreadValues({}, state), {
924
+ data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
925
+ }),
926
+ appStore.config
927
+ );
928
+ }
929
+ if (action.type === "setUi") {
930
+ if (typeof action.ui === "object") {
931
+ return __spreadProps(__spreadValues({}, state), {
932
+ ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
933
+ });
934
+ }
935
+ return __spreadProps(__spreadValues({}, state), {
936
+ ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
937
+ });
938
+ }
939
+ return state;
940
+ }
941
+
942
+ // reducer/actions.tsx
943
+ init_react_import();
944
+
945
+ // reducer/index.ts
946
+ function storeInterceptor(reducer, record, onAction) {
947
+ return (state, action) => {
948
+ const newAppState = reducer(state, action);
949
+ const isValidType = ![
950
+ "registerZone",
951
+ "unregisterZone",
952
+ "setData",
953
+ "setUi",
954
+ "set"
955
+ ].includes(action.type);
956
+ if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
957
+ if (record) record(newAppState);
958
+ }
959
+ onAction == null ? void 0 : onAction(action, newAppState, state);
960
+ return newAppState;
961
+ };
962
+ }
963
+ function createReducer({
964
+ record,
965
+ onAction,
966
+ appStore
967
+ }) {
968
+ return storeInterceptor(
969
+ (state, action) => {
970
+ const result = reduce(state, action, appStore);
971
+ return result;
972
+ },
973
+ record,
974
+ onAction
975
+ );
976
+ }
977
+
978
+ // components/ViewportControls/default-viewports.ts
979
+ init_react_import();
980
+ var defaultViewports = [
981
+ { width: 360, height: "auto", icon: "Smartphone", label: "Small" },
982
+ { width: 768, height: "auto", icon: "Tablet", label: "Medium" },
983
+ { width: 1280, height: "auto", icon: "Monitor", label: "Large" }
984
+ ];
985
+
986
+ // store/index.ts
987
+ var import_zustand2 = require("zustand");
988
+ var import_middleware2 = require("zustand/middleware");
989
+ var import_react9 = require("react");
990
+
991
+ // store/slices/history.ts
992
+ init_react_import();
993
+ var import_react6 = require("react");
994
+
995
+ // lib/use-hotkey.ts
996
+ init_react_import();
997
+ var import_react5 = require("react");
998
+ var import_zustand = require("zustand");
999
+ var import_middleware = require("zustand/middleware");
1000
+ var useHotkeyStore = (0, import_zustand.create)()(
1001
+ (0, import_middleware.subscribeWithSelector)((set) => ({
1002
+ held: {},
1003
+ hold: (key) => set((s) => s.held[key] ? s : { held: __spreadProps(__spreadValues({}, s.held), { [key]: true }) }),
1004
+ release: (key) => set((s) => s.held[key] ? { held: __spreadProps(__spreadValues({}, s.held), { [key]: false }) } : s),
1005
+ reset: (held = {}) => set(() => ({ held })),
1006
+ triggers: {}
1007
+ }))
1008
+ );
1009
+
1010
+ // store/slices/history.ts
1011
+ var EMPTY_HISTORY_INDEX = 0;
1012
+ function debounce(func, timeout2 = 300) {
1013
+ let timer;
1014
+ return (...args) => {
1015
+ clearTimeout(timer);
1016
+ timer = setTimeout(() => {
1017
+ func(...args);
1018
+ }, timeout2);
1019
+ };
1020
+ }
1021
+ var tidyState = (state) => {
1022
+ return __spreadProps(__spreadValues({}, state), {
1023
+ ui: __spreadProps(__spreadValues({}, state.ui), {
1024
+ field: {
1025
+ focus: null
1026
+ }
1027
+ })
1028
+ });
1029
+ };
1030
+ var createHistorySlice = (set, get) => {
1031
+ const record = debounce((state) => {
1032
+ const { histories, index } = get().history;
1033
+ const history = {
1034
+ state,
1035
+ id: generateId("history")
1036
+ };
1037
+ const newHistories = [...histories.slice(0, index + 1), history];
1038
+ set({
1039
+ history: __spreadProps(__spreadValues({}, get().history), {
1040
+ histories: newHistories,
1041
+ index: newHistories.length - 1
1042
+ })
1043
+ });
1044
+ }, 250);
1045
+ return {
1046
+ initialAppState: {},
1047
+ index: EMPTY_HISTORY_INDEX,
1048
+ histories: [],
1049
+ hasPast: () => get().history.index > EMPTY_HISTORY_INDEX,
1050
+ hasFuture: () => get().history.index < get().history.histories.length - 1,
1051
+ prevHistory: () => {
1052
+ const { history } = get();
1053
+ return history.hasPast() ? history.histories[history.index - 1] : null;
1054
+ },
1055
+ nextHistory: () => {
1056
+ const s = get().history;
1057
+ return s.hasFuture() ? s.histories[s.index + 1] : null;
1058
+ },
1059
+ currentHistory: () => get().history.histories[get().history.index],
1060
+ back: () => {
1061
+ var _a;
1062
+ const { history, dispatch } = get();
1063
+ if (history.hasPast()) {
1064
+ const state = tidyState(
1065
+ ((_a = history.prevHistory()) == null ? void 0 : _a.state) || history.initialAppState
1066
+ );
1067
+ dispatch({
1068
+ type: "set",
1069
+ state
1070
+ });
1071
+ set({ history: __spreadProps(__spreadValues({}, history), { index: history.index - 1 }) });
1072
+ }
1073
+ },
1074
+ forward: () => {
1075
+ var _a;
1076
+ const { history, dispatch } = get();
1077
+ if (history.hasFuture()) {
1078
+ const state = (_a = history.nextHistory()) == null ? void 0 : _a.state;
1079
+ dispatch({ type: "set", state: state ? tidyState(state) : {} });
1080
+ set({ history: __spreadProps(__spreadValues({}, history), { index: history.index + 1 }) });
1081
+ }
1082
+ },
1083
+ setHistories: (histories) => {
1084
+ var _a;
1085
+ const { dispatch, history } = get();
1086
+ dispatch({
1087
+ type: "set",
1088
+ state: ((_a = history.histories[history.histories.length - 1]) == null ? void 0 : _a.state) || history.initialAppState
1089
+ });
1090
+ set({ history: __spreadProps(__spreadValues({}, history), { histories, index: histories.length - 1 }) });
1091
+ },
1092
+ setHistoryIndex: (index) => {
1093
+ var _a;
1094
+ const { dispatch, history } = get();
1095
+ dispatch({
1096
+ type: "set",
1097
+ state: ((_a = history.histories[history.index]) == null ? void 0 : _a.state) || history.initialAppState
1098
+ });
1099
+ set({ history: __spreadProps(__spreadValues({}, history), { index }) });
1100
+ },
1101
+ record
1102
+ };
1103
+ };
1104
+
1105
+ // store/slices/nodes.ts
1106
+ init_react_import();
1107
+ var createNodesSlice = (set, get) => ({
1108
+ nodes: {},
1109
+ registerNode: (id, node) => {
1110
+ const s = get().nodes;
1111
+ const emptyNode = {
1112
+ id,
1113
+ methods: { sync: () => null },
1114
+ element: null
1115
+ };
1116
+ const existingNode = s.nodes[id];
1117
+ set({
1118
+ nodes: __spreadProps(__spreadValues({}, s), {
1119
+ nodes: __spreadProps(__spreadValues({}, s.nodes), {
1120
+ [id]: __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, emptyNode), existingNode), node), {
1121
+ id
1122
+ })
1123
+ })
1124
+ })
1125
+ });
1126
+ },
1127
+ unregisterNode: (id) => {
1128
+ const s = get().nodes;
1129
+ const existingNode = s.nodes[id];
1130
+ if (existingNode) {
1131
+ const newNodes = __spreadValues({}, s.nodes);
1132
+ delete newNodes[id];
1133
+ set({
1134
+ nodes: __spreadProps(__spreadValues({}, s), {
1135
+ nodes: newNodes
1136
+ })
1137
+ });
1138
+ }
1139
+ }
1140
+ });
1141
+
1142
+ // store/slices/permissions.ts
1143
+ init_react_import();
1144
+ var import_react7 = require("react");
1145
+
1146
+ // lib/flatten-data.ts
1147
+ init_react_import();
1148
+ var flattenData = (state, config) => {
1149
+ const data = [];
1150
+ walkTree(
1151
+ state,
1152
+ config,
1153
+ (content) => content,
1154
+ (item) => {
1155
+ data.push(item);
1156
+ return null;
1157
+ }
1158
+ );
1159
+ return data;
1160
+ };
1161
+
1162
+ // lib/get-changed.ts
1163
+ init_react_import();
1164
+ var getChanged = (newItem, oldItem) => {
1165
+ return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
1166
+ const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
1167
+ const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
1168
+ return __spreadProps(__spreadValues({}, acc), {
1169
+ [item]: oldItemProps[item] !== newItemProps[item]
1170
+ });
1171
+ }, {}) : {};
1172
+ };
1173
+
1174
+ // store/slices/permissions.ts
1175
+ var createPermissionsSlice = (set, get) => {
1176
+ const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
1177
+ const { state, permissions, config } = get();
1178
+ const { cache: cache2, globalPermissions } = permissions;
1179
+ const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
1180
+ var _a, _b, _c;
1181
+ const {
1182
+ config: config2,
1183
+ state: appState,
1184
+ setComponentLoading,
1185
+ unsetComponentLoading
1186
+ } = get();
1187
+ const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
1188
+ if (!componentConfig) {
1189
+ return;
1190
+ }
1191
+ const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
1192
+ if (componentConfig.resolvePermissions) {
1193
+ const changed = getChanged(item2, (_a = cache2[item2.props.id]) == null ? void 0 : _a.lastData);
1194
+ if (Object.values(changed).some((el) => el === true) || force2) {
1195
+ setComponentLoading(item2.props.id);
1196
+ const resolvedPermissions = yield componentConfig.resolvePermissions(
1197
+ item2,
1198
+ {
1199
+ changed,
1200
+ lastPermissions: ((_b = cache2[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
1201
+ permissions: initialPermissions,
1202
+ appState,
1203
+ lastData: ((_c = cache2[item2.props.id]) == null ? void 0 : _c.lastData) || null
1204
+ }
1205
+ );
1206
+ const latest = get().permissions;
1207
+ set({
1208
+ permissions: __spreadProps(__spreadValues({}, latest), {
1209
+ cache: __spreadProps(__spreadValues({}, latest.cache), {
1210
+ [item2.props.id]: {
1211
+ lastData: item2,
1212
+ lastPermissions: resolvedPermissions
1213
+ }
1214
+ }),
1215
+ resolvedPermissions: __spreadProps(__spreadValues({}, latest.resolvedPermissions), {
1216
+ [item2.props.id]: resolvedPermissions
1217
+ })
1218
+ })
1219
+ });
1220
+ unsetComponentLoading(item2.props.id);
1221
+ }
1222
+ }
1223
+ });
1224
+ const resolveDataForRoot = (force2 = false) => {
1225
+ const { state: appState } = get();
1226
+ resolveDataForItem(
1227
+ // Shim the root data in by conforming to component data shape
1228
+ {
1229
+ type: "root",
1230
+ props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "puck-root" })
1231
+ },
1232
+ force2
1233
+ );
1234
+ };
1235
+ const { item, type, root } = params;
1236
+ if (item) {
1237
+ yield resolveDataForItem(item, force);
1238
+ } else if (type) {
1239
+ flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(void 0, null, function* () {
1240
+ yield resolveDataForItem(item2, force);
1241
+ }));
1242
+ } else if (root) {
1243
+ resolveDataForRoot(force);
1244
+ } else {
1245
+ resolveDataForRoot(force);
1246
+ flattenData(state, config).map((item2) => __async(void 0, null, function* () {
1247
+ yield resolveDataForItem(item2, force);
1248
+ }));
1249
+ }
1250
+ });
1251
+ const refreshPermissions = (params) => resolvePermissions(params, true);
1252
+ return {
1253
+ cache: {},
1254
+ globalPermissions: {
1255
+ drag: true,
1256
+ edit: true,
1257
+ delete: true,
1258
+ duplicate: true,
1259
+ insert: true
1260
+ },
1261
+ resolvedPermissions: {},
1262
+ getPermissions: ({ item, type, root } = {}) => {
1263
+ const { config, permissions } = get();
1264
+ const { globalPermissions, resolvedPermissions } = permissions;
1265
+ if (item) {
1266
+ const componentConfig = config.components[item.type];
1267
+ const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
1268
+ const resolvedForItem = resolvedPermissions[item.props.id];
1269
+ return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
1270
+ } else if (type) {
1271
+ const componentConfig = config.components[type];
1272
+ return __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
1273
+ } else if (root) {
1274
+ const rootConfig = config.root;
1275
+ const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
1276
+ const resolvedForItem = resolvedPermissions["puck-root"];
1277
+ return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
1278
+ }
1279
+ return globalPermissions;
1280
+ },
1281
+ resolvePermissions,
1282
+ refreshPermissions
1283
+ };
1284
+ };
1285
+
1286
+ // store/slices/fields.ts
1287
+ init_react_import();
1288
+ var import_react8 = require("react");
1289
+ var createFieldsSlice = (_set, _get) => {
1290
+ return {
1291
+ fields: {},
1292
+ loading: false,
1293
+ lastResolvedData: {}
1294
+ };
1295
+ };
1296
+
1297
+ // lib/resolve-component-data.ts
1298
+ init_react_import();
1299
+
1300
+ // lib/map-slots.ts
1301
+ init_react_import();
1302
+ function mapSlots(item, map, recursive = true, isSlot2) {
1303
+ return __async(this, null, function* () {
1304
+ const props = __spreadValues({}, item.props);
1305
+ yield forEachSlot(
1306
+ item,
1307
+ (_parentId, propName, content) => __async(this, null, function* () {
1308
+ const mappedContent = recursive ? yield Promise.all(
1309
+ content.map((item2) => __async(this, null, function* () {
1310
+ return yield mapSlots(item2, map, recursive, isSlot2);
1311
+ }))
1312
+ ) : content;
1313
+ props[propName] = yield map(mappedContent, propName);
1314
+ }),
1315
+ false,
1316
+ isSlot2
1317
+ );
1318
+ return __spreadProps(__spreadValues({}, item), { props });
1319
+ });
1320
+ }
1321
+
1322
+ // lib/resolve-component-data.ts
1323
+ var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
1324
+ var cache = { lastChange: {} };
1325
+ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
1326
+ const configForItem = "type" in item ? config.components[item.type] : config.root;
1327
+ if ((configForItem == null ? void 0 : configForItem.resolveData) && item.props) {
1328
+ const id = "id" in item.props ? item.props.id : "root";
1329
+ const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
1330
+ if (item && item === oldItem) {
1331
+ return resolved;
1332
+ }
1333
+ const changed = getChanged(item, oldItem);
1334
+ if (onResolveStart) {
1335
+ onResolveStart(item);
1336
+ }
1337
+ const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
1338
+ changed,
1339
+ lastData: oldItem,
1340
+ metadata,
1341
+ trigger
1342
+ });
1343
+ let resolvedItem = __spreadProps(__spreadValues({}, item), {
1344
+ props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
1345
+ });
1346
+ if (recursive) {
1347
+ resolvedItem = yield mapSlots(resolvedItem, (content) => __async(void 0, null, function* () {
1348
+ return Promise.all(
1349
+ content.map(
1350
+ (childItem) => __async(void 0, null, function* () {
1351
+ return (yield resolveComponentData(
1352
+ childItem,
1353
+ config,
1354
+ metadata,
1355
+ onResolveStart,
1356
+ onResolveEnd,
1357
+ trigger,
1358
+ false
1359
+ )).node;
1360
+ })
1361
+ )
1362
+ );
1363
+ }));
1364
+ }
1365
+ if (Object.keys(readOnly).length) {
1366
+ resolvedItem.readOnly = readOnly;
1367
+ }
1368
+ cache.lastChange[id] = {
1369
+ item,
1370
+ resolved: resolvedItem
1371
+ };
1372
+ if (onResolveEnd) {
1373
+ onResolveEnd(resolvedItem);
1374
+ }
1375
+ return { node: resolvedItem, didChange: !(0, import_fast_deep_equal.default)(item, resolvedItem) };
1376
+ }
1377
+ return { node: item, didChange: false };
1378
+ });
1379
+
1380
+ // lib/to-root.ts
1381
+ init_react_import();
1382
+ var toRoot = (item) => {
1383
+ if ("type" in item && item.type !== "root") {
1384
+ throw new Error("Converting non-root item to root.");
1385
+ }
1386
+ const { readOnly } = item;
1387
+ if (item.props) {
1388
+ if ("id" in item.props) {
1389
+ const _a = item.props, { id } = _a, props = __objRest(_a, ["id"]);
1390
+ return { props, readOnly };
1391
+ }
1392
+ return { props: item.props, readOnly };
1393
+ }
1394
+ return { props: {}, readOnly };
1395
+ };
1396
+
1397
+ // store/index.ts
1398
+ var defaultAppState = {
1399
+ data: { content: [], root: {}, zones: {} },
1400
+ ui: {
1401
+ leftSideBarVisible: true,
1402
+ rightSideBarVisible: true,
1403
+ arrayState: {},
1404
+ itemSelector: null,
1405
+ componentList: {},
1406
+ isDragging: false,
1407
+ previewMode: "edit",
1408
+ viewports: {
1409
+ current: {
1410
+ width: defaultViewports[0].width,
1411
+ height: defaultViewports[0].height || "auto"
1412
+ },
1413
+ options: [],
1414
+ controlsVisible: true
1415
+ },
1416
+ field: { focus: null }
1417
+ },
1418
+ indexes: {
1419
+ nodes: {},
1420
+ zones: {}
1421
+ }
1422
+ };
1423
+ var defaultPageFields = {
1424
+ title: { type: "text" }
1425
+ };
1426
+ var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
1427
+ (0, import_middleware2.subscribeWithSelector)((set, get) => __spreadProps(__spreadValues({
1428
+ state: defaultAppState,
1429
+ config: { components: {} },
1430
+ componentState: {},
1431
+ plugins: [],
1432
+ overrides: {},
1433
+ viewports: defaultViewports,
1434
+ zoomConfig: {
1435
+ autoZoom: 1,
1436
+ rootHeight: 0,
1437
+ zoom: 1
1438
+ },
1439
+ status: "LOADING",
1440
+ iframe: {},
1441
+ metadata: {}
1442
+ }, initialAppStore), {
1443
+ fields: createFieldsSlice(set, get),
1444
+ history: createHistorySlice(set, get),
1445
+ nodes: createNodesSlice(set, get),
1446
+ permissions: createPermissionsSlice(set, get),
1447
+ getComponentConfig: (type) => {
1448
+ var _a;
1449
+ const { config, selectedItem } = get();
1450
+ const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
1451
+ return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
1452
+ },
1453
+ dispatch: (action) => set((s) => {
1454
+ var _a, _b;
1455
+ const { record } = get().history;
1456
+ const dispatch = createReducer({
1457
+ record,
1458
+ appStore: s
1459
+ });
1460
+ const state = dispatch(s.state, action);
1461
+ const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
1462
+ (_b = (_a = get()).onAction) == null ? void 0 : _b.call(_a, action, state, get().state);
1463
+ return __spreadProps(__spreadValues({}, s), { state, selectedItem });
1464
+ }),
1465
+ setZoomConfig: (zoomConfig) => set({ zoomConfig }),
1466
+ setStatus: (status) => set({ status }),
1467
+ setComponentState: (componentState) => set({ componentState }),
1468
+ pendingComponentLoads: {},
1469
+ setComponentLoading: (id, loading = true, defer = 0) => {
1470
+ const { setComponentState, pendingComponentLoads } = get();
1471
+ const thisPendingComponentLoads = __spreadValues({}, pendingComponentLoads);
1472
+ const setLoading = () => {
1473
+ var _a;
1474
+ const { componentState } = get();
1475
+ setComponentState(__spreadProps(__spreadValues({}, componentState), {
1476
+ [id]: __spreadProps(__spreadValues({}, componentState[id]), {
1477
+ loadingCount: (((_a = componentState[id]) == null ? void 0 : _a.loadingCount) || 0) + 1
1478
+ })
1479
+ }));
1480
+ };
1481
+ const unsetLoading = () => {
1482
+ var _a;
1483
+ const { componentState } = get();
1484
+ setComponentState(__spreadProps(__spreadValues({}, componentState), {
1485
+ [id]: __spreadProps(__spreadValues({}, componentState[id]), {
1486
+ loadingCount: Math.max(
1487
+ (((_a = componentState[id]) == null ? void 0 : _a.loadingCount) || 0) - 1,
1488
+ 0
1489
+ )
1490
+ })
1491
+ }));
1492
+ };
1493
+ if (thisPendingComponentLoads[id]) {
1494
+ clearTimeout(thisPendingComponentLoads[id]);
1495
+ delete thisPendingComponentLoads[id];
1496
+ set({ pendingComponentLoads: thisPendingComponentLoads });
1497
+ }
1498
+ const timeout2 = setTimeout(() => {
1499
+ if (loading) {
1500
+ setLoading();
1501
+ } else {
1502
+ unsetLoading();
1503
+ }
1504
+ delete thisPendingComponentLoads[id];
1505
+ set({ pendingComponentLoads: thisPendingComponentLoads });
1506
+ }, defer);
1507
+ set({
1508
+ pendingComponentLoads: __spreadProps(__spreadValues({}, thisPendingComponentLoads), {
1509
+ [id]: timeout2
1510
+ })
1511
+ });
1512
+ },
1513
+ unsetComponentLoading: (id) => {
1514
+ const { setComponentLoading } = get();
1515
+ setComponentLoading(id, false);
1516
+ },
1517
+ // Helper
1518
+ setUi: (ui, recordHistory) => set((s) => {
1519
+ const dispatch = createReducer({
1520
+ record: () => {
1521
+ },
1522
+ appStore: s
1523
+ });
1524
+ const state = dispatch(s.state, {
1525
+ type: "setUi",
1526
+ ui,
1527
+ recordHistory
1528
+ });
1529
+ const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
1530
+ return __spreadProps(__spreadValues({}, s), { state, selectedItem });
1531
+ }),
1532
+ // resolveDataRuns: 0,
1533
+ // resolveData: (newAppState) =>
1534
+ // set((s) => {
1535
+ // resolveData(newAppState, get);
1536
+ // return { ...s, resolveDataRuns: s.resolveDataRuns + 1 };
1537
+ // }),
1538
+ resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
1539
+ const { config, metadata, setComponentLoading } = get();
1540
+ return yield resolveComponentData(
1541
+ componentData,
1542
+ config,
1543
+ metadata,
1544
+ (item) => setComponentLoading(
1545
+ "id" in item.props ? item.props.id : "root",
1546
+ true,
1547
+ 50
1548
+ ),
1549
+ (item) => setComponentLoading(
1550
+ "id" in item.props ? item.props.id : "root",
1551
+ false,
1552
+ 0
1553
+ ),
1554
+ trigger
1555
+ );
1556
+ }),
1557
+ resolveAndCommitData: () => __async(void 0, null, function* () {
1558
+ const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
1559
+ walkTree(
1560
+ state,
1561
+ config,
1562
+ (content) => content,
1563
+ (childItem) => {
1564
+ resolveComponentData2(childItem, "load").then((resolved) => {
1565
+ const { state: state2 } = get();
1566
+ const node = state2.indexes.nodes[resolved.node.props.id];
1567
+ if (node && resolved.didChange) {
1568
+ if (resolved.node.props.id === "root") {
1569
+ dispatch({
1570
+ type: "replaceRoot",
1571
+ root: toRoot(resolved.node)
1572
+ });
1573
+ } else {
1574
+ const zoneCompound = `${node.parentId}:${node.zone}`;
1575
+ const parentZone = state2.indexes.zones[zoneCompound];
1576
+ const index = parentZone.contentIds.indexOf(
1577
+ resolved.node.props.id
1578
+ );
1579
+ dispatch({
1580
+ type: "replace",
1581
+ data: resolved.node,
1582
+ destinationIndex: index,
1583
+ destinationZone: zoneCompound
1584
+ });
1585
+ }
1586
+ }
1587
+ });
1588
+ return childItem;
1589
+ }
1590
+ );
1591
+ })
1592
+ }))
1593
+ );
1594
+ var appStoreContext = (0, import_react9.createContext)(createAppStore());
1595
+ function useAppStore(selector) {
1596
+ const context = (0, import_react9.useContext)(appStoreContext);
1597
+ return (0, import_zustand2.useStore)(context, selector);
1598
+ }
1599
+ function useAppStoreApi() {
1600
+ return (0, import_react9.useContext)(appStoreContext);
1601
+ }
1602
+
1603
+ // components/Loader/index.tsx
1604
+ init_react_import();
1605
+
1606
+ // lib/index.ts
1607
+ init_react_import();
1608
+
1609
+ // lib/filter.ts
1610
+ init_react_import();
1611
+
1612
+ // lib/reorder.ts
1613
+ init_react_import();
1614
+
1615
+ // lib/replace.ts
1616
+ init_react_import();
1617
+
1618
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Loader/styles.module.css#css-module
1619
+ init_react_import();
1620
+ var styles_module_default2 = { "Loader": "_Loader_nacdm_13", "loader-animation": "_loader-animation_nacdm_1" };
1621
+
1622
+ // components/Loader/index.tsx
1623
+ var import_jsx_runtime = require("react/jsx-runtime");
1624
+ var getClassName = get_class_name_factory_default("Loader", styles_module_default2);
1625
+ var Loader = (_a) => {
1626
+ var _b = _a, {
1627
+ color,
1628
+ size = 16
1629
+ } = _b, props = __objRest(_b, [
1630
+ "color",
1631
+ "size"
1632
+ ]);
1633
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1634
+ "span",
1635
+ __spreadValues({
1636
+ className: getClassName(),
1637
+ style: {
1638
+ width: size,
1639
+ height: size,
1640
+ color
1641
+ },
1642
+ "aria-label": "loading"
1643
+ }, props)
1644
+ );
1645
+ };
1646
+
1647
+ // components/ActionBar/index.tsx
1648
+ init_react_import();
1649
+
1650
+ // css-module:/home/runner/work/puck/puck/packages/core/components/ActionBar/styles.module.css#css-module
1651
+ init_react_import();
1652
+ var styles_module_default3 = { "ActionBar": "_ActionBar_rvadt_1", "ActionBar-label": "_ActionBar-label_rvadt_18", "ActionBar-action": "_ActionBar-action_rvadt_30", "ActionBar-group": "_ActionBar-group_rvadt_38" };
1653
+
1654
+ // components/ActionBar/index.tsx
1655
+ var import_jsx_runtime2 = require("react/jsx-runtime");
1656
+ var getClassName2 = get_class_name_factory_default("ActionBar", styles_module_default3);
1657
+ var ActionBar = ({
1658
+ label,
1659
+ children
1660
+ }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1661
+ "div",
1662
+ {
1663
+ className: getClassName2(),
1664
+ onClick: (e) => {
1665
+ e.stopPropagation();
1666
+ },
1667
+ children: [
1668
+ label && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ActionBar.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: getClassName2("label"), children: label }) }),
1669
+ children
1670
+ ]
1671
+ }
1672
+ );
1673
+ var Action = ({
1674
+ children,
1675
+ label,
1676
+ onClick
1677
+ }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1678
+ "button",
1679
+ {
1680
+ type: "button",
1681
+ className: getClassName2("action"),
1682
+ onClick,
1683
+ title: label,
1684
+ children
1685
+ }
1686
+ );
1687
+ var Group = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: getClassName2("group"), children });
1688
+ var Label = ({ label }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: getClassName2("label"), children: label });
1689
+ ActionBar.Action = Action;
1690
+ ActionBar.Label = Label;
1691
+ ActionBar.Group = Group;
1692
+
1693
+ // components/DraggableComponent/index.tsx
1694
+ var import_react_dom = require("react-dom");
1695
+
1696
+ // lib/dnd/collision/dynamic/index.ts
1697
+ init_react_import();
1698
+ var import_abstract8 = require("@dnd-kit/abstract");
1699
+
1700
+ // lib/dnd/collision/directional/index.ts
1701
+ init_react_import();
1702
+ var import_abstract = require("@dnd-kit/abstract");
1703
+
1704
+ // lib/dnd/collision/collision-debug.ts
1705
+ init_react_import();
1706
+ var DEBUG = false;
1707
+ var debugElements = {};
1708
+ var timeout;
1709
+ var collisionDebug = (a, b, id, color, label) => {
1710
+ if (!DEBUG) return;
1711
+ const debugId = `${id}-debug`;
1712
+ clearTimeout(timeout);
1713
+ timeout = setTimeout(() => {
1714
+ Object.entries(debugElements).forEach(([id2, { svg }]) => {
1715
+ svg.remove();
1716
+ delete debugElements[id2];
1717
+ });
1718
+ }, 1e3);
1719
+ requestAnimationFrame(() => {
1720
+ var _a, _b;
1721
+ const existingEl = debugElements[debugId];
1722
+ let line = (_a = debugElements[debugId]) == null ? void 0 : _a.line;
1723
+ let text = (_b = debugElements[debugId]) == null ? void 0 : _b.text;
1724
+ if (!existingEl) {
1725
+ const svgNs = "http://www.w3.org/2000/svg";
1726
+ const svg = document.createElementNS(svgNs, "svg");
1727
+ line = document.createElementNS(svgNs, "line");
1728
+ text = document.createElementNS(svgNs, "text");
1729
+ svg.setAttribute("id", debugId);
1730
+ svg.setAttribute(
1731
+ "style",
1732
+ "position: fixed; height: 100%; width: 100%; pointer-events: none; top: 0px; left: 0px;"
1733
+ );
1734
+ svg.appendChild(line);
1735
+ svg.appendChild(text);
1736
+ text.setAttribute("fill", `black`);
1737
+ document.body.appendChild(svg);
1738
+ debugElements[debugId] = { svg, line, text };
1739
+ }
1740
+ line.setAttribute("x1", a.x.toString());
1741
+ line.setAttribute("x2", b.x.toString());
1742
+ line.setAttribute("y1", a.y.toString());
1743
+ line.setAttribute("y2", b.y.toString());
1744
+ line.setAttribute("style", `stroke:${color};stroke-width:2`);
1745
+ text.setAttribute("x", (a.x - (a.x - b.x) / 2).toString());
1746
+ text.setAttribute("y", (a.y - (a.y - b.y) / 2).toString());
1747
+ if (label) {
1748
+ text.innerHTML = label;
1749
+ }
1750
+ });
1751
+ };
1752
+
1753
+ // lib/dnd/collision/directional/index.ts
1754
+ var distanceChange = "increasing";
1755
+ var directionalCollision = (input, previous) => {
1756
+ var _a;
1757
+ const { dragOperation, droppable } = input;
1758
+ const { shape: dropShape } = droppable;
1759
+ const { position } = dragOperation;
1760
+ const dragShape = (_a = dragOperation.shape) == null ? void 0 : _a.current;
1761
+ if (!dragShape || !dropShape) return null;
1762
+ const dropCenter = dropShape.center;
1763
+ const distanceToPrevious = Math.sqrt(
1764
+ Math.pow(dropCenter.x - previous.x, 2) + Math.pow(dropCenter.y - previous.y, 2)
1765
+ );
1766
+ const distanceToCurrent = Math.sqrt(
1767
+ Math.pow(dropCenter.x - position.current.x, 2) + Math.pow(dropCenter.y - position.current.y, 2)
1768
+ );
1769
+ distanceChange = distanceToCurrent === distanceToPrevious ? distanceChange : distanceToCurrent < distanceToPrevious ? "decreasing" : "increasing";
1770
+ collisionDebug(
1771
+ dragShape.center,
1772
+ dropCenter,
1773
+ droppable.id.toString(),
1774
+ "rebeccapurple"
1775
+ );
1776
+ if (distanceChange === "decreasing") {
1777
+ return {
1778
+ id: droppable.id,
1779
+ value: 1,
1780
+ type: import_abstract.CollisionType.Collision
1781
+ };
1782
+ }
1783
+ return null;
1784
+ };
1785
+
1786
+ // lib/dnd/collision/dynamic/get-direction.ts
1787
+ init_react_import();
1788
+ var getDirection = (dragAxis, delta) => {
1789
+ if (dragAxis === "dynamic") {
1790
+ if (Math.abs(delta.y) > Math.abs(delta.x)) {
1791
+ return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
1792
+ } else {
1793
+ return delta.x === 0 ? null : delta.x > 0 ? "right" : "left";
1794
+ }
1795
+ } else if (dragAxis === "x") {
1796
+ return delta.x === 0 ? null : delta.x > 0 ? "right" : "left";
1797
+ }
1798
+ return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
1799
+ };
1800
+
1801
+ // lib/dnd/collision/dynamic/get-midpoint-impact.ts
1802
+ init_react_import();
1803
+ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0) => {
1804
+ const dragRect = dragShape.boundingRectangle;
1805
+ const dropCenter = dropShape.center;
1806
+ if (direction === "down") {
1807
+ const offset2 = offsetMultiplier * dropShape.boundingRectangle.height;
1808
+ return dragRect.bottom >= dropCenter.y + offset2;
1809
+ } else if (direction === "up") {
1810
+ const offset2 = offsetMultiplier * dropShape.boundingRectangle.height;
1811
+ return dragRect.top < dropCenter.y - offset2;
1812
+ } else if (direction === "left") {
1813
+ const offset2 = offsetMultiplier * dropShape.boundingRectangle.width;
1814
+ return dropCenter.x - offset2 >= dragRect.left;
1815
+ }
1816
+ const offset = offsetMultiplier * dropShape.boundingRectangle.width;
1817
+ return dragRect.right - offset >= dropCenter.x;
1818
+ };
1819
+
1820
+ // lib/dnd/collision/dynamic/track-movement-interval.ts
1821
+ init_react_import();
1822
+ var import_geometry = require("@dnd-kit/geometry");
1823
+ var INTERVAL_SENSITIVITY = 10;
1824
+ var intervalCache = {
1825
+ current: { x: 0, y: 0 },
1826
+ delta: { x: 0, y: 0 },
1827
+ previous: { x: 0, y: 0 },
1828
+ direction: null
1829
+ };
1830
+ var trackMovementInterval = (point, dragAxis = "dynamic") => {
1831
+ intervalCache.current = point;
1832
+ intervalCache.delta = {
1833
+ x: point.x - intervalCache.previous.x,
1834
+ y: point.y - intervalCache.previous.y
1835
+ };
1836
+ intervalCache.direction = getDirection(dragAxis, intervalCache.delta) || intervalCache.direction;
1837
+ if (Math.abs(intervalCache.delta.x) > INTERVAL_SENSITIVITY || Math.abs(intervalCache.delta.y) > INTERVAL_SENSITIVITY) {
1838
+ intervalCache.previous = import_geometry.Point.from(point);
1839
+ }
1840
+ return intervalCache;
1841
+ };
1842
+
1843
+ // ../../node_modules/@dnd-kit/collision/dist/index.js
1844
+ init_react_import();
1845
+ var import_abstract2 = require("@dnd-kit/abstract");
1846
+ var import_geometry2 = require("@dnd-kit/geometry");
1847
+ var import_abstract3 = require("@dnd-kit/abstract");
1848
+ var import_geometry3 = require("@dnd-kit/geometry");
1849
+ var import_abstract4 = require("@dnd-kit/abstract");
1850
+ var import_geometry4 = require("@dnd-kit/geometry");
1851
+ var import_abstract5 = require("@dnd-kit/abstract");
1852
+ var import_geometry5 = require("@dnd-kit/geometry");
1853
+ var import_abstract6 = require("@dnd-kit/abstract");
1854
+ var import_geometry6 = require("@dnd-kit/geometry");
1855
+ var import_abstract7 = require("@dnd-kit/abstract");
1856
+ var import_geometry7 = require("@dnd-kit/geometry");
1857
+ var pointerIntersection = ({
1858
+ dragOperation,
1859
+ droppable
1860
+ }) => {
1861
+ const pointerCoordinates = dragOperation.position.current;
1862
+ if (!pointerCoordinates) {
1863
+ return null;
1864
+ }
1865
+ const { id } = droppable;
1866
+ if (!droppable.shape) {
1867
+ return null;
1868
+ }
1869
+ if (droppable.shape.containsPoint(pointerCoordinates)) {
1870
+ const distance = import_geometry2.Point.distance(droppable.shape.center, pointerCoordinates);
1871
+ return {
1872
+ id,
1873
+ value: 1 / distance,
1874
+ type: import_abstract2.CollisionType.PointerIntersection,
1875
+ priority: import_abstract2.CollisionPriority.High
1876
+ };
1877
+ }
1878
+ return null;
1879
+ };
1880
+ var closestCorners = (input) => {
1881
+ const { dragOperation, droppable } = input;
1882
+ const { shape, position } = dragOperation;
1883
+ if (!droppable.shape) {
1884
+ return null;
1885
+ }
1886
+ const { left, top, right, bottom } = droppable.shape.boundingRectangle;
1887
+ const corners = [
1888
+ {
1889
+ x: left,
1890
+ y: top
1891
+ },
1892
+ {
1893
+ x: right,
1894
+ y: top
1895
+ },
1896
+ {
1897
+ x: left,
1898
+ y: bottom
1899
+ },
1900
+ {
1901
+ x: right,
1902
+ y: bottom
1903
+ }
1904
+ ];
1905
+ const distance = corners.reduce(
1906
+ (acc, corner) => {
1907
+ var _a;
1908
+ return acc + import_geometry4.Point.distance(
1909
+ import_geometry4.Point.from(corner),
1910
+ (_a = shape == null ? void 0 : shape.current.center) != null ? _a : position.current
1911
+ );
1912
+ },
1913
+ 0
1914
+ );
1915
+ const value = distance / 4;
1916
+ return {
1917
+ id: droppable.id,
1918
+ value: 1 / value,
1919
+ type: import_abstract4.CollisionType.Collision,
1920
+ priority: import_abstract4.CollisionPriority.Normal
1921
+ };
1922
+ };
1923
+
1924
+ // lib/dnd/collision/dynamic/store.ts
1925
+ init_react_import();
1926
+ var import_vanilla = require("zustand/vanilla");
1927
+ var collisionStore = (0, import_vanilla.createStore)(() => ({
1928
+ fallbackEnabled: false
1929
+ }));
1930
+
1931
+ // lib/dnd/collision/dynamic/index.ts
1932
+ var flushNext = "";
1933
+ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
1934
+ var _a, _b, _c, _d, _e;
1935
+ const { dragOperation, droppable } = input;
1936
+ const { position } = dragOperation;
1937
+ const dragShape = (_a = dragOperation.shape) == null ? void 0 : _a.current;
1938
+ const { shape: dropShape } = droppable;
1939
+ if (!dragShape || !dropShape) {
1940
+ return null;
1941
+ }
1942
+ const { center: dragCenter } = dragShape;
1943
+ const { fallbackEnabled } = collisionStore.getState();
1944
+ const interval = trackMovementInterval(position.current, dragAxis);
1945
+ dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
1946
+ direction: interval.direction
1947
+ });
1948
+ const collisionMap = dragOperation.data.collisionMap || {};
1949
+ dragOperation.data.collisionMap = collisionMap;
1950
+ collisionMap[droppable.id] = {
1951
+ direction: interval.direction
1952
+ };
1953
+ const { center: dropCenter } = dropShape;
1954
+ const overMidpoint = getMidpointImpact(
1955
+ dragShape,
1956
+ dropShape,
1957
+ interval.direction,
1958
+ midpointOffset
1959
+ );
1960
+ if (((_b = dragOperation.source) == null ? void 0 : _b.id) === droppable.id) {
1961
+ const collision = directionalCollision(input, interval.previous);
1962
+ collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "yellow");
1963
+ if (collision) {
1964
+ return __spreadProps(__spreadValues({}, collision), {
1965
+ priority: import_abstract8.CollisionPriority.Highest
1966
+ });
1967
+ }
1968
+ }
1969
+ const intersectionArea = dragShape.intersectionArea(dropShape);
1970
+ const intersectionRatio = intersectionArea / dropShape.area;
1971
+ if (intersectionArea && overMidpoint) {
1972
+ collisionDebug(
1973
+ dragCenter,
1974
+ dropCenter,
1975
+ droppable.id.toString(),
1976
+ "green",
1977
+ interval.direction
1978
+ );
1979
+ const collision = {
1980
+ id: droppable.id,
1981
+ value: intersectionRatio,
1982
+ priority: import_abstract8.CollisionPriority.High,
1983
+ type: import_abstract8.CollisionType.Collision
1984
+ };
1985
+ const shouldFlushId = flushNext === droppable.id;
1986
+ flushNext = "";
1987
+ return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
1988
+ }
1989
+ if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
1990
+ const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
1991
+ const yAxisIntersection = dropShape.boundingRectangle.bottom > dragShape.boundingRectangle.top && dropShape.boundingRectangle.top < dragShape.boundingRectangle.bottom;
1992
+ if (dragAxis === "y" && xAxisIntersection || yAxisIntersection) {
1993
+ const fallbackCollision = closestCorners(input);
1994
+ if (fallbackCollision) {
1995
+ const direction = getDirection(dragAxis, {
1996
+ x: dragShape.center.x - (((_d = droppable.shape) == null ? void 0 : _d.center.x) || 0),
1997
+ y: dragShape.center.y - (((_e = droppable.shape) == null ? void 0 : _e.center.y) || 0)
1998
+ });
1999
+ collisionMap[droppable.id] = {
2000
+ direction
2001
+ };
2002
+ if (intersectionArea) {
2003
+ collisionDebug(
2004
+ dragCenter,
2005
+ dropCenter,
2006
+ droppable.id.toString(),
2007
+ "red",
2008
+ direction || ""
2009
+ );
2010
+ flushNext = droppable.id;
2011
+ return __spreadProps(__spreadValues({}, fallbackCollision), {
2012
+ priority: import_abstract8.CollisionPriority.Low
2013
+ });
2014
+ }
2015
+ collisionDebug(
2016
+ dragCenter,
2017
+ dropCenter,
2018
+ droppable.id.toString(),
2019
+ "orange",
2020
+ direction || ""
2021
+ );
2022
+ return __spreadProps(__spreadValues({}, fallbackCollision), { priority: import_abstract8.CollisionPriority.Lowest });
2023
+ }
2024
+ }
2025
+ }
2026
+ collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
2027
+ delete collisionMap[droppable.id];
2028
+ return null;
2029
+ };
2030
+
2031
+ // lib/dnd/dnd-kit/safe.ts
2032
+ init_react_import();
2033
+ var import_react10 = require("@dnd-kit/react");
2034
+ var import_sortable = require("@dnd-kit/react/sortable");
2035
+ function useDroppableSafe(input) {
2036
+ if (typeof window === "undefined") {
2037
+ return { ref: () => {
2038
+ } };
2039
+ }
2040
+ return (0, import_react10.useDroppable)(input);
2041
+ }
2042
+ function useDraggableSafe(input) {
2043
+ if (typeof window === "undefined") {
2044
+ return { ref: () => {
2045
+ } };
2046
+ }
2047
+ return (0, import_react10.useDraggable)(input);
2048
+ }
2049
+ function useSortableSafe(input) {
2050
+ if (typeof window === "undefined") {
2051
+ return { ref: () => {
2052
+ }, status: "idle", handleRef: () => {
2053
+ } };
2054
+ }
2055
+ return (0, import_sortable.useSortable)(input);
2056
+ }
2057
+
2058
+ // lib/get-deep-scroll-position.ts
2059
+ init_react_import();
2060
+ function getDeepScrollPosition(element) {
2061
+ let totalScroll = {
2062
+ x: 0,
2063
+ y: 0
2064
+ };
2065
+ let current = element;
2066
+ while (current && current !== document.documentElement) {
2067
+ const parent = current.parentElement;
2068
+ if (parent) {
2069
+ totalScroll.x += parent.scrollLeft;
2070
+ totalScroll.y += parent.scrollTop;
2071
+ }
2072
+ current = parent;
2073
+ }
2074
+ return totalScroll;
2075
+ }
2076
+
2077
+ // components/DropZone/context.tsx
2078
+ init_react_import();
2079
+ var import_react11 = require("react");
2080
+ var import_zustand3 = require("zustand");
2081
+ var import_jsx_runtime3 = require("react/jsx-runtime");
2082
+ var dropZoneContext = (0, import_react11.createContext)(null);
2083
+ var ZoneStoreContext = (0, import_react11.createContext)(
2084
+ (0, import_zustand3.createStore)(() => ({
2085
+ zoneDepthIndex: {},
2086
+ nextZoneDepthIndex: {},
2087
+ areaDepthIndex: {},
2088
+ nextAreaDepthIndex: {},
2089
+ draggedItem: null,
2090
+ previewIndex: {}
2091
+ }))
2092
+ );
2093
+ var DropZoneProvider = ({
2094
+ children,
2095
+ value
2096
+ }) => {
2097
+ const [hoveringComponent, setHoveringComponent] = (0, import_react11.useState)();
2098
+ const [activeZones, setActiveZones] = (0, import_react11.useState)({});
2099
+ const dispatch = useAppStore((s) => s.dispatch);
2100
+ const registerZone = (0, import_react11.useCallback)(
2101
+ (zoneCompound) => {
2102
+ dispatch({
2103
+ type: "registerZone",
2104
+ zone: zoneCompound
2105
+ });
2106
+ },
2107
+ [setActiveZones, dispatch]
2108
+ );
2109
+ const unregisterZone = (0, import_react11.useCallback)(
2110
+ (zoneCompound) => {
2111
+ dispatch({
2112
+ type: "unregisterZone",
2113
+ zone: zoneCompound
2114
+ });
2115
+ },
2116
+ [setActiveZones, dispatch]
2117
+ );
2118
+ const memoValue = (0, import_react11.useMemo)(
2119
+ () => __spreadValues({
2120
+ hoveringComponent,
2121
+ setHoveringComponent,
2122
+ registerZone,
2123
+ unregisterZone,
2124
+ activeZones
2125
+ }, value),
2126
+ [value, hoveringComponent, activeZones]
2127
+ );
2128
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
2129
+ };
2130
+
2131
+ // lib/use-context-store.ts
2132
+ init_react_import();
2133
+ var import_react12 = require("react");
2134
+ var import_zustand4 = require("zustand");
2135
+ var import_shallow = require("zustand/react/shallow");
2136
+ function useContextStore(context, selector) {
2137
+ const store = (0, import_react12.useContext)(context);
2138
+ if (!store) {
2139
+ throw new Error("useContextStore must be used inside context");
2140
+ }
2141
+ return (0, import_zustand4.useStore)(store, (0, import_shallow.useShallow)(selector));
2142
+ }
2143
+
2144
+ // components/DraggableComponent/index.tsx
2145
+ var import_shallow2 = require("zustand/react/shallow");
2146
+ var import_jsx_runtime4 = require("react/jsx-runtime");
2147
+ var getClassName3 = get_class_name_factory_default("DraggableComponent", styles_module_default);
2148
+ var DEBUG2 = false;
2149
+ var space = 8;
2150
+ var actionsOverlayTop = space * 6.5;
2151
+ var actionsTop = -(actionsOverlayTop - 8);
2152
+ var actionsSide = space;
2153
+ var DefaultActionBar = ({
2154
+ label,
2155
+ children,
2156
+ parentAction
2157
+ }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(ActionBar, { children: [
2158
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(ActionBar.Group, { children: [
2159
+ parentAction,
2160
+ label && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ActionBar.Label, { label })
2161
+ ] }),
2162
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ActionBar.Group, { children })
2163
+ ] });
2164
+ var DraggableComponent = ({
2165
+ children,
2166
+ depth,
2167
+ componentType,
2168
+ id,
2169
+ index,
2170
+ zoneCompound,
2171
+ isLoading = false,
2172
+ isSelected = false,
2173
+ debug,
2174
+ label,
2175
+ isEnabled,
2176
+ autoDragAxis,
2177
+ userDragAxis,
2178
+ inDroppableZone = true
2179
+ }) => {
2180
+ const zoom = useAppStore(
2181
+ (s) => {
2182
+ var _a;
2183
+ return ((_a = s.selectedItem) == null ? void 0 : _a.props.id) === id ? s.zoomConfig.zoom : 1;
2184
+ }
2185
+ );
2186
+ const overrides = useAppStore((s) => s.overrides);
2187
+ const dispatch = useAppStore((s) => s.dispatch);
2188
+ const iframe = useAppStore((s) => s.iframe);
2189
+ const ctx = (0, import_react13.useContext)(dropZoneContext);
2190
+ const [localZones, setLocalZones] = (0, import_react13.useState)({});
2191
+ const registerLocalZone = (0, import_react13.useCallback)(
2192
+ (zoneCompound2, active) => {
2193
+ var _a;
2194
+ (_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
2195
+ setLocalZones((obj) => __spreadProps(__spreadValues({}, obj), {
2196
+ [zoneCompound2]: active
2197
+ }));
2198
+ },
2199
+ [setLocalZones]
2200
+ );
2201
+ const unregisterLocalZone = (0, import_react13.useCallback)(
2202
+ (zoneCompound2) => {
2203
+ var _a;
2204
+ (_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
2205
+ setLocalZones((obj) => {
2206
+ const newLocalZones = __spreadValues({}, obj);
2207
+ delete newLocalZones[zoneCompound2];
2208
+ return newLocalZones;
2209
+ });
2210
+ },
2211
+ [setLocalZones]
2212
+ );
2213
+ const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
2214
+ const path = useAppStore((0, import_shallow2.useShallow)((s) => {
2215
+ var _a;
2216
+ return (_a = s.state.indexes.nodes[id]) == null ? void 0 : _a.path;
2217
+ }));
2218
+ const permissions = useAppStore(
2219
+ (0, import_shallow2.useShallow)((s) => s.permissions.getPermissions())
2220
+ // TODO call using id
2221
+ );
2222
+ const userIsDragging = useContextStore(
2223
+ ZoneStoreContext,
2224
+ (s) => !!s.draggedItem
2225
+ );
2226
+ const canCollide = permissions.drag || userIsDragging;
2227
+ const disabled = !isEnabled || !canCollide;
2228
+ const [dragAxis, setDragAxis] = (0, import_react13.useState)(userDragAxis || autoDragAxis);
2229
+ const { ref: sortableRef, status } = useSortableSafe({
2230
+ id,
2231
+ index,
2232
+ group: zoneCompound,
2233
+ type: "component",
2234
+ data: {
2235
+ areaId: ctx == null ? void 0 : ctx.areaId,
2236
+ zone: zoneCompound,
2237
+ index,
2238
+ componentType,
2239
+ containsActiveZone,
2240
+ depth,
2241
+ path: path || [],
2242
+ inDroppableZone
2243
+ },
2244
+ collisionPriority: isEnabled ? depth : 0,
2245
+ collisionDetector: createDynamicCollisionDetector(dragAxis),
2246
+ disabled,
2247
+ // "Out of the way" transition from react-beautiful-dnd
2248
+ transition: {
2249
+ duration: 200,
2250
+ easing: "cubic-bezier(0.2, 0, 0, 1)"
2251
+ }
2252
+ });
2253
+ const thisIsDragging = status === "dragging";
2254
+ const ref = (0, import_react13.useRef)(null);
2255
+ const refSetter = (0, import_react13.useCallback)(
2256
+ (el) => {
2257
+ sortableRef(el);
2258
+ if (el) {
2259
+ ref.current = el;
2260
+ }
2261
+ },
2262
+ [sortableRef]
2263
+ );
2264
+ const [portalEl, setPortalEl] = (0, import_react13.useState)();
2265
+ (0, import_react13.useEffect)(() => {
2266
+ var _a, _b, _c;
2267
+ setPortalEl(
2268
+ iframe.enabled ? (_a = ref.current) == null ? void 0 : _a.ownerDocument.body : (_c = (_b = ref.current) == null ? void 0 : _b.closest("[data-puck-preview]")) != null ? _c : document.body
2269
+ );
2270
+ }, [iframe.enabled, ref.current]);
2271
+ const getStyle = (0, import_react13.useCallback)(() => {
2272
+ var _a, _b, _c;
2273
+ if (!ref.current) return;
2274
+ const rect = ref.current.getBoundingClientRect();
2275
+ const deepScrollPosition = getDeepScrollPosition(ref.current);
2276
+ const portalContainerEl = iframe.enabled ? null : (_a = ref.current) == null ? void 0 : _a.closest("[data-puck-preview]");
2277
+ const portalContainerRect = portalContainerEl == null ? void 0 : portalContainerEl.getBoundingClientRect();
2278
+ const portalScroll = portalContainerEl ? getDeepScrollPosition(portalContainerEl) : { x: 0, y: 0 };
2279
+ const scroll = {
2280
+ x: deepScrollPosition.x - portalScroll.x - ((_b = portalContainerRect == null ? void 0 : portalContainerRect.left) != null ? _b : 0),
2281
+ y: deepScrollPosition.y - portalScroll.y - ((_c = portalContainerRect == null ? void 0 : portalContainerRect.top) != null ? _c : 0)
2282
+ };
2283
+ const style2 = {
2284
+ left: `${rect.left + scroll.x}px`,
2285
+ top: `${rect.top + scroll.y}px`,
2286
+ height: `${rect.height}px`,
2287
+ width: `${rect.width}px`
2288
+ };
2289
+ return style2;
2290
+ }, [ref.current]);
2291
+ const [style, setStyle] = (0, import_react13.useState)();
2292
+ const sync = (0, import_react13.useCallback)(() => {
2293
+ setStyle(getStyle());
2294
+ }, [ref.current, iframe]);
2295
+ (0, import_react13.useEffect)(() => {
2296
+ if (ref.current && !userIsDragging) {
2297
+ const observer = new ResizeObserver(sync);
2298
+ observer.observe(ref.current);
2299
+ return () => {
2300
+ observer.disconnect();
2301
+ };
2302
+ }
2303
+ }, [ref.current, userIsDragging]);
2304
+ const registerNode = useAppStore((s) => s.nodes.registerNode);
2305
+ (0, import_react13.useEffect)(() => {
2306
+ var _a;
2307
+ registerNode(id, { methods: { sync }, element: (_a = ref.current) != null ? _a : null });
2308
+ return () => {
2309
+ registerNode(id, { methods: { sync: () => null }, element: null });
2310
+ };
2311
+ }, [id, zoneCompound, index, componentType, sync]);
2312
+ const CustomActionBar = (0, import_react13.useMemo)(
2313
+ () => overrides.actionBar || DefaultActionBar,
2314
+ [overrides.actionBar]
2315
+ );
2316
+ const onClick = (0, import_react13.useCallback)(
2317
+ (e) => {
2318
+ e.stopPropagation();
2319
+ dispatch({
2320
+ type: "setUi",
2321
+ ui: {
2322
+ itemSelector: { index, zone: zoneCompound }
2323
+ }
2324
+ });
2325
+ },
2326
+ [index, zoneCompound, id]
2327
+ );
2328
+ const appStore = useAppStoreApi();
2329
+ const onSelectParent = (0, import_react13.useCallback)(() => {
2330
+ const { nodes, zones } = appStore.getState().state.indexes;
2331
+ const node = nodes[id];
2332
+ const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
2333
+ if (!parentNode || !node.parentId) {
2334
+ return;
2335
+ }
2336
+ const parentZoneCompound = `${parentNode.parentId}:${parentNode.zone}`;
2337
+ const parentIndex = zones[parentZoneCompound].contentIds.indexOf(
2338
+ node.parentId
2339
+ );
2340
+ dispatch({
2341
+ type: "setUi",
2342
+ ui: {
2343
+ itemSelector: {
2344
+ zone: parentZoneCompound,
2345
+ index: parentIndex
2346
+ }
2347
+ }
2348
+ });
2349
+ }, [ctx, path]);
2350
+ const onDuplicate = (0, import_react13.useCallback)(() => {
2351
+ dispatch({
2352
+ type: "duplicate",
2353
+ sourceIndex: index,
2354
+ sourceZone: zoneCompound
2355
+ });
2356
+ }, [index, zoneCompound]);
2357
+ const onDelete = (0, import_react13.useCallback)(() => {
2358
+ dispatch({
2359
+ type: "remove",
2360
+ index,
2361
+ zone: zoneCompound
2362
+ });
2363
+ }, [index, zoneCompound]);
2364
+ const [hover, setHover] = (0, import_react13.useState)(false);
2365
+ const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
2366
+ (0, import_react13.useEffect)(() => {
2367
+ if (!ref.current) {
2368
+ return;
2369
+ }
2370
+ const el = ref.current;
2371
+ const _onMouseOver = (e) => {
2372
+ if (userIsDragging) {
2373
+ if (thisIsDragging) {
2374
+ setHover(true);
2375
+ } else {
2376
+ setHover(false);
2377
+ }
2378
+ } else {
2379
+ setHover(true);
2380
+ }
2381
+ e.stopPropagation();
2382
+ };
2383
+ const _onMouseOut = (e) => {
2384
+ e.stopPropagation();
2385
+ setHover(false);
2386
+ };
2387
+ el.setAttribute("data-puck-component", id);
2388
+ el.setAttribute("data-puck-dnd", id);
2389
+ el.style.position = "relative";
2390
+ el.addEventListener("click", onClick);
2391
+ el.addEventListener("mouseover", _onMouseOver);
2392
+ el.addEventListener("mouseout", _onMouseOut);
2393
+ if (thisIsDragging) {
2394
+ el.setAttribute("data-puck-dragging", "");
2395
+ } else {
2396
+ el.removeAttribute("data-puck-dragging");
2397
+ }
2398
+ return () => {
2399
+ el.removeAttribute("data-puck-component");
2400
+ el.removeAttribute("data-puck-dnd");
2401
+ el.removeEventListener("click", onClick);
2402
+ el.removeEventListener("mouseover", _onMouseOver);
2403
+ el.removeEventListener("mouseout", _onMouseOut);
2404
+ el.removeAttribute("data-puck-dragging");
2405
+ };
2406
+ }, [
2407
+ ref,
2408
+ onClick,
2409
+ containsActiveZone,
2410
+ zoneCompound,
2411
+ id,
2412
+ userIsDragging,
2413
+ thisIsDragging,
2414
+ inDroppableZone
2415
+ ]);
2416
+ (0, import_react13.useEffect)(() => {
2417
+ if (ref.current && disabled) {
2418
+ ref.current.setAttribute("data-puck-disabled", "");
2419
+ return () => {
2420
+ var _a;
2421
+ (_a = ref.current) == null ? void 0 : _a.removeAttribute("data-puck-disabled");
2422
+ };
2423
+ }
2424
+ }, [disabled, ref]);
2425
+ const [isVisible, setIsVisible] = (0, import_react13.useState)(false);
2426
+ (0, import_react13.useEffect)(() => {
2427
+ sync();
2428
+ if ((isSelected || hover || indicativeHover) && !userIsDragging) {
2429
+ setIsVisible(true);
2430
+ } else {
2431
+ setIsVisible(false);
2432
+ }
2433
+ }, [isSelected, hover, indicativeHover, iframe, userIsDragging]);
2434
+ const syncActionsPosition = (0, import_react13.useCallback)(
2435
+ (el) => {
2436
+ if (el) {
2437
+ const view = el.ownerDocument.defaultView;
2438
+ if (view) {
2439
+ const rect = el.getBoundingClientRect();
2440
+ const diffLeft = rect.x;
2441
+ const exceedsBoundsLeft = diffLeft < 0;
2442
+ const diffTop = rect.y;
2443
+ const exceedsBoundsTop = diffTop < 0;
2444
+ if (exceedsBoundsLeft) {
2445
+ el.style.transformOrigin = "left top";
2446
+ el.style.left = "0px";
2447
+ }
2448
+ if (exceedsBoundsTop) {
2449
+ el.style.top = "12px";
2450
+ if (!exceedsBoundsLeft) {
2451
+ el.style.transformOrigin = "right top";
2452
+ }
2453
+ }
2454
+ }
2455
+ }
2456
+ },
2457
+ [zoom]
2458
+ );
2459
+ (0, import_react13.useEffect)(() => {
2460
+ if (userDragAxis) {
2461
+ setDragAxis(userDragAxis);
2462
+ return;
2463
+ }
2464
+ if (ref.current) {
2465
+ const computedStyle = window.getComputedStyle(ref.current);
2466
+ if (computedStyle.display === "inline" || computedStyle.display === "inline-block") {
2467
+ setDragAxis("x");
2468
+ return;
2469
+ }
2470
+ }
2471
+ setDragAxis(autoDragAxis);
2472
+ }, [ref, userDragAxis, autoDragAxis]);
2473
+ const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CornerLeftUp, { size: 16 }) });
2474
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
2475
+ DropZoneProvider,
2476
+ {
2477
+ value: __spreadProps(__spreadValues({}, ctx), {
2478
+ areaId: id,
2479
+ zoneCompound,
2480
+ index,
2481
+ depth: depth + 1,
2482
+ registerLocalZone,
2483
+ unregisterLocalZone
2484
+ }),
2485
+ children: [
2486
+ isVisible && (0, import_react_dom.createPortal)(
2487
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
2488
+ "div",
2489
+ {
2490
+ className: getClassName3({
2491
+ isSelected,
2492
+ isDragging: thisIsDragging,
2493
+ hover: hover || indicativeHover
2494
+ }),
2495
+ style: __spreadValues({}, style),
2496
+ "data-puck-overlay": true,
2497
+ children: [
2498
+ debug,
2499
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassName3("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Loader, {}) }),
2500
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2501
+ "div",
2502
+ {
2503
+ className: getClassName3("actionsOverlay"),
2504
+ style: {
2505
+ top: actionsOverlayTop / zoom
2506
+ },
2507
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2508
+ "div",
2509
+ {
2510
+ className: getClassName3("actions"),
2511
+ style: {
2512
+ transform: `scale(${1 / zoom}`,
2513
+ top: actionsTop / zoom,
2514
+ right: 0,
2515
+ paddingLeft: actionsSide,
2516
+ paddingRight: actionsSide
2517
+ },
2518
+ ref: syncActionsPosition,
2519
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
2520
+ CustomActionBar,
2521
+ {
2522
+ parentAction,
2523
+ label: DEBUG2 ? id : label,
2524
+ children: [
2525
+ permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Copy, { size: 16 }) }),
2526
+ permissions.delete && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Trash, { size: 16 }) })
2527
+ ]
2528
+ }
2529
+ )
2530
+ }
2531
+ )
2532
+ }
2533
+ ),
2534
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassName3("overlay") })
2535
+ ]
2536
+ }
2537
+ ),
2538
+ portalEl || document.body
2539
+ ),
2540
+ children(refSetter)
2541
+ ]
2542
+ }
2543
+ );
2544
+ };
2545
+
2546
+ // css-module:/home/runner/work/puck/puck/packages/core/components/DropZone/styles.module.css#css-module
2547
+ init_react_import();
2548
+ var styles_module_default4 = { "DropZone": "_DropZone_3dmev_1", "DropZone--hasChildren": "_DropZone--hasChildren_3dmev_11", "DropZone--userIsDragging": "_DropZone--userIsDragging_3dmev_19", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_3dmev_23", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_3dmev_24", "DropZone--isRootZone": "_DropZone--isRootZone_3dmev_24", "DropZone--isDestination": "_DropZone--isDestination_3dmev_34", "DropZone-item": "_DropZone-item_3dmev_46", "DropZone-hitbox": "_DropZone-hitbox_3dmev_50", "DropZone--isEnabled": "_DropZone--isEnabled_3dmev_58", "DropZone--isAnimating": "_DropZone--isAnimating_3dmev_67" };
2549
+
2550
+ // components/Drawer/index.tsx
2551
+ init_react_import();
2552
+
2553
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Drawer/styles.module.css#css-module
2554
+ init_react_import();
2555
+ var styles_module_default5 = { "Drawer": "_Drawer_fkqfo_1", "Drawer-draggable": "_Drawer-draggable_fkqfo_8", "Drawer-draggableBg": "_Drawer-draggableBg_fkqfo_12", "Drawer-draggableFg": "_Drawer-draggableFg_fkqfo_21", "DrawerItem-draggable": "_DrawerItem-draggable_fkqfo_25", "DrawerItem--disabled": "_DrawerItem--disabled_fkqfo_38", "DrawerItem": "_DrawerItem_fkqfo_25", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_fkqfo_48", "DrawerItem-name": "_DrawerItem-name_fkqfo_66" };
2556
+
2557
+ // components/DragIcon/index.tsx
2558
+ init_react_import();
2559
+
2560
+ // css-module:/home/runner/work/puck/puck/packages/core/components/DragIcon/styles.module.css#css-module
2561
+ init_react_import();
2562
+ var styles_module_default6 = { "DragIcon": "_DragIcon_17p8x_1", "DragIcon--disabled": "_DragIcon--disabled_17p8x_8" };
2563
+
2564
+ // components/DragIcon/index.tsx
2565
+ var import_jsx_runtime5 = require("react/jsx-runtime");
2566
+ var getClassName4 = get_class_name_factory_default("DragIcon", styles_module_default6);
2567
+ var DragIcon = ({ isDragDisabled }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: getClassName4({ disabled: isDragDisabled }), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 20 20", width: "12", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M7 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 2zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 14zm6-8a2 2 0 1 0-.001-4.001A2 2 0 0 0 13 6zm0 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 14z" }) }) });
2568
+
2569
+ // components/Drawer/index.tsx
2570
+ var import_react18 = require("react");
2571
+
2572
+ // components/DragDropContext/index.tsx
2573
+ init_react_import();
2574
+ var import_react16 = require("@dnd-kit/react");
2575
+ var import_react17 = require("react");
2576
+ var import_dom = require("@dnd-kit/dom");
2577
+
2578
+ // lib/dnd/NestedDroppablePlugin.ts
2579
+ init_react_import();
2580
+ var import_abstract9 = require("@dnd-kit/abstract");
2581
+ var import_state = require("@dnd-kit/state");
2582
+
2583
+ // lib/throttle.ts
2584
+ init_react_import();
2585
+
2586
+ // lib/get-frame.ts
2587
+ init_react_import();
2588
+
2589
+ // lib/global-position.ts
2590
+ init_react_import();
2591
+
2592
+ // lib/bubble-pointer-event.ts
2593
+ init_react_import();
2594
+
2595
+ // lib/insert-component.ts
2596
+ init_react_import();
2597
+
2598
+ // components/DragDropContext/index.tsx
2599
+ var import_use_debounce = require("use-debounce");
2600
+ var import_zustand5 = require("zustand");
2601
+
2602
+ // lib/get-deep-dir.ts
2603
+ init_react_import();
2604
+
2605
+ // lib/dnd/use-sensors.ts
2606
+ init_react_import();
2607
+ var import_react14 = require("react");
2608
+
2609
+ // lib/dnd/PointerSensor.ts
2610
+ init_react_import();
2611
+ var import_state2 = require("@dnd-kit/state");
2612
+ var import_abstract10 = require("@dnd-kit/abstract");
2613
+ var import_geometry8 = require("@dnd-kit/geometry");
2614
+ var import_utilities = require("@dnd-kit/dom/utilities");
2615
+ var _clearTimeout;
2616
+ var _PointerSensor = class _PointerSensor extends import_abstract10.Sensor {
2617
+ constructor(manager, options) {
2618
+ super(manager);
2619
+ this.manager = manager;
2620
+ this.options = options;
2621
+ this.listeners = new import_utilities.Listeners();
2622
+ this.cleanup = /* @__PURE__ */ new Set();
2623
+ this.source = void 0;
2624
+ this.started = false;
2625
+ __privateAdd(this, _clearTimeout);
2626
+ this.handleCancel = this.handleCancel.bind(this);
2627
+ this.handlePointerUp = this.handlePointerUp.bind(this);
2628
+ this.handleKeyDown = this.handleKeyDown.bind(this);
2629
+ (0, import_state2.effect)(() => {
2630
+ const unbindGlobal = this.bindGlobal(options != null ? options : {});
2631
+ return () => {
2632
+ unbindGlobal();
2633
+ };
2634
+ });
2635
+ }
2636
+ bind(source, options = this.options) {
2637
+ const unbind = (0, import_state2.effect)(() => {
2638
+ var _a;
2639
+ const target = (_a = source.handle) != null ? _a : source.element;
2640
+ const listener = (event) => {
2641
+ if ((0, import_utilities.isPointerEvent)(event)) {
2642
+ this.handlePointerDown(event, source, options);
2643
+ }
2644
+ };
2645
+ if (target) {
2646
+ patchWindow(target.ownerDocument.defaultView);
2647
+ target.addEventListener("pointerdown", listener);
2648
+ return () => {
2649
+ target.removeEventListener("pointerdown", listener);
2650
+ };
2651
+ }
2652
+ });
2653
+ return unbind;
2654
+ }
2655
+ bindGlobal(options) {
2656
+ const documents = /* @__PURE__ */ new Set();
2657
+ for (const draggable of this.manager.registry.draggables.value) {
2658
+ if (draggable.element) {
2659
+ documents.add((0, import_utilities.getDocument)(draggable.element));
2660
+ }
2661
+ }
2662
+ for (const droppable of this.manager.registry.droppables.value) {
2663
+ if (droppable.element) {
2664
+ documents.add((0, import_utilities.getDocument)(droppable.element));
2665
+ }
2666
+ }
2667
+ const unbindFns = Array.from(documents).map(
2668
+ (doc) => this.listeners.bind(doc, [
2669
+ {
2670
+ type: "pointermove",
2671
+ listener: (event) => this.handlePointerMove(event, doc, options)
2672
+ },
2673
+ {
2674
+ type: "pointerup",
2675
+ listener: this.handlePointerUp,
2676
+ options: {
2677
+ capture: true
2678
+ }
2679
+ },
2680
+ {
2681
+ // Cancel activation if there is a competing Drag and Drop interaction
2682
+ type: "dragstart",
2683
+ listener: this.handleDragStart
2684
+ }
2685
+ ])
2686
+ );
2687
+ return () => {
2688
+ unbindFns.forEach((unbind) => unbind());
2689
+ };
2690
+ }
2691
+ handlePointerDown(event, source, options = {}) {
2692
+ if (this.disabled || !event.isPrimary || event.button !== 0 || !(0, import_utilities.isElement)(event.target) || source.disabled) {
2693
+ return;
2694
+ }
2695
+ const offset = (0, import_utilities.getFrameTransform)(source.element);
2696
+ this.initialCoordinates = {
2697
+ x: event.clientX * offset.scaleX + offset.x,
2698
+ y: event.clientY * offset.scaleY + offset.y
2699
+ };
2700
+ this.source = source;
2701
+ const { activationConstraints } = options;
2702
+ const constraints = typeof activationConstraints === "function" ? activationConstraints(event, source) : activationConstraints;
2703
+ event.stopImmediatePropagation();
2704
+ if (!(constraints == null ? void 0 : constraints.delay) && !(constraints == null ? void 0 : constraints.distance)) {
2705
+ this.handleStart(source, event);
2706
+ } else {
2707
+ const { delay } = constraints;
2708
+ if (delay) {
2709
+ const timeout2 = setTimeout(
2710
+ () => this.handleStart(source, event),
2711
+ delay.value
2712
+ );
2713
+ __privateSet(this, _clearTimeout, () => {
2714
+ clearTimeout(timeout2);
2715
+ __privateSet(this, _clearTimeout, void 0);
2716
+ });
2717
+ }
2718
+ }
2719
+ const cleanup = () => {
2720
+ var _a;
2721
+ (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
2722
+ this.initialCoordinates = void 0;
2723
+ this.source = void 0;
2724
+ };
2725
+ this.cleanup.add(cleanup);
2726
+ }
2727
+ handlePointerMove(event, doc, options) {
2728
+ if (!this.source) {
2729
+ return;
2730
+ }
2731
+ const ownerDocument = this.source.element && (0, import_utilities.getDocument)(this.source.element);
2732
+ if (doc !== ownerDocument) {
2733
+ return;
2734
+ }
2735
+ const coordinates = {
2736
+ x: event.clientX,
2737
+ y: event.clientY
2738
+ };
2739
+ const offset = (0, import_utilities.getFrameTransform)(this.source.element);
2740
+ coordinates.x = coordinates.x * offset.scaleX + offset.x;
2741
+ coordinates.y = coordinates.y * offset.scaleY + offset.y;
2742
+ if (this.manager.dragOperation.status.dragging) {
2743
+ event.preventDefault();
2744
+ event.stopPropagation();
2745
+ this.manager.actions.move({ to: coordinates });
2746
+ return;
2747
+ }
2748
+ if (!this.initialCoordinates) {
2749
+ return;
2750
+ }
2751
+ const delta = {
2752
+ x: coordinates.x - this.initialCoordinates.x,
2753
+ y: coordinates.y - this.initialCoordinates.y
2754
+ };
2755
+ const { activationConstraints } = options;
2756
+ const constraints = typeof activationConstraints === "function" ? activationConstraints(event, this.source) : activationConstraints;
2757
+ const { distance, delay } = constraints != null ? constraints : {};
2758
+ if (distance) {
2759
+ if (distance.tolerance != null && (0, import_geometry8.exceedsDistance)(delta, distance.tolerance)) {
2760
+ return this.handleCancel();
2761
+ }
2762
+ if ((0, import_geometry8.exceedsDistance)(delta, distance.value)) {
2763
+ return this.handleStart(this.source, event);
2764
+ }
2765
+ }
2766
+ if (delay) {
2767
+ if ((0, import_geometry8.exceedsDistance)(delta, delay.tolerance)) {
2768
+ return this.handleCancel();
2769
+ }
2770
+ }
2771
+ }
2772
+ handlePointerUp(event) {
2773
+ if (!this.source) {
2774
+ return;
2775
+ }
2776
+ event.preventDefault();
2777
+ event.stopPropagation();
2778
+ const { status } = this.manager.dragOperation;
2779
+ if (!status.idle) {
2780
+ const canceled = !status.initialized;
2781
+ this.manager.actions.stop({ canceled });
2782
+ } else if (this.started) {
2783
+ setTimeout(() => {
2784
+ if (!this.manager.dragOperation.status.idle) {
2785
+ this.manager.actions.stop({ canceled: false });
2786
+ }
2787
+ }, 10);
2788
+ }
2789
+ this.cleanup.forEach((cleanup) => cleanup());
2790
+ this.cleanup.clear();
2791
+ }
2792
+ handleKeyDown(event) {
2793
+ if (event.key === "Escape") {
2794
+ event.preventDefault();
2795
+ this.handleCancel();
2796
+ }
2797
+ }
2798
+ handleStart(source, event) {
2799
+ var _a;
2800
+ const { manager, initialCoordinates } = this;
2801
+ (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
2802
+ if (!initialCoordinates || manager.dragOperation.status.initialized || this.started) {
2803
+ return;
2804
+ }
2805
+ if (event.defaultPrevented) {
2806
+ return;
2807
+ }
2808
+ this.started = true;
2809
+ event.preventDefault();
2810
+ (0, import_state2.batch)(() => {
2811
+ manager.actions.setDragSource(source.id);
2812
+ manager.actions.start({ coordinates: initialCoordinates, event });
2813
+ });
2814
+ const ownerDocument = (0, import_utilities.getDocument)(event.target);
2815
+ const unbind = this.listeners.bind(ownerDocument, [
2816
+ {
2817
+ // Prevent scrolling on touch devices
2818
+ type: "touchmove",
2819
+ listener: preventDefault,
2820
+ options: {
2821
+ passive: false
2822
+ }
2823
+ },
2824
+ {
2825
+ // Prevent click events
2826
+ type: "click",
2827
+ listener: preventDefault
2828
+ },
2829
+ {
2830
+ type: "keydown",
2831
+ listener: this.handleKeyDown
2832
+ }
2833
+ ]);
2834
+ ownerDocument.body.setPointerCapture(event.pointerId);
2835
+ this.cleanup.add(unbind);
2836
+ this.cleanup.add(() => {
2837
+ this.started = false;
2838
+ });
2839
+ }
2840
+ handleDragStart(event) {
2841
+ const { target } = event;
2842
+ if (!(0, import_utilities.isElement)(target)) {
2843
+ return;
2844
+ }
2845
+ const isNativeDraggable = (0, import_utilities.isHTMLElement)(target) && target.draggable && target.getAttribute("draggable") === "true";
2846
+ if (isNativeDraggable) {
2847
+ this.handleCancel();
2848
+ } else {
2849
+ preventDefault(event);
2850
+ }
2851
+ }
2852
+ handleCancel() {
2853
+ const { dragOperation } = this.manager;
2854
+ if (dragOperation.status.initialized) {
2855
+ this.manager.actions.stop({ canceled: true });
2856
+ }
2857
+ this.cleanup.forEach((cleanup) => cleanup());
2858
+ this.cleanup.clear();
2859
+ }
2860
+ destroy() {
2861
+ this.listeners.clear();
2862
+ }
2863
+ };
2864
+ _clearTimeout = new WeakMap();
2865
+ _PointerSensor.configure = (0, import_abstract10.configurator)(_PointerSensor);
2866
+ var PointerSensor = _PointerSensor;
2867
+ function preventDefault(event) {
2868
+ event.preventDefault();
2869
+ }
2870
+ function noop() {
2871
+ }
2872
+ var windows = /* @__PURE__ */ new WeakSet();
2873
+ function patchWindow(window2) {
2874
+ if (!window2 || windows.has(window2)) {
2875
+ return;
2876
+ }
2877
+ window2.addEventListener("touchmove", noop, {
2878
+ capture: false,
2879
+ passive: false
2880
+ });
2881
+ windows.add(window2);
2882
+ }
2883
+
2884
+ // lib/dnd/use-sensors.ts
2885
+ var import_utilities2 = require("@dnd-kit/dom/utilities");
2886
+
2887
+ // lib/use-safe-id.ts
2888
+ init_react_import();
2889
+ var import_react15 = __toESM(require("react"));
2890
+ var useSafeId = () => {
2891
+ if (typeof import_react15.default.useId !== "undefined") {
2892
+ return import_react15.default.useId();
2893
+ }
2894
+ const [id] = (0, import_react15.useState)(generateId());
2895
+ return id;
2896
+ };
2897
+
2898
+ // components/DragDropContext/index.tsx
2899
+ var import_jsx_runtime6 = require("react/jsx-runtime");
2900
+ var dragListenerContext = (0, import_react17.createContext)({
2901
+ dragListeners: {}
2902
+ });
2903
+ function useDragListener(type, fn, deps = []) {
2904
+ const { setDragListeners } = (0, import_react17.useContext)(dragListenerContext);
2905
+ (0, import_react17.useEffect)(() => {
2906
+ if (setDragListeners) {
2907
+ setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
2908
+ [type]: [...old[type] || [], fn]
2909
+ }));
2910
+ }
2911
+ }, deps);
2912
+ }
2913
+
2914
+ // components/Drawer/index.tsx
2915
+ var import_jsx_runtime7 = require("react/jsx-runtime");
2916
+ var getClassName5 = get_class_name_factory_default("Drawer", styles_module_default5);
2917
+ var getClassNameItem = get_class_name_factory_default("DrawerItem", styles_module_default5);
2918
+ var DrawerItemInner = ({
2919
+ children,
2920
+ name,
2921
+ label,
2922
+ dragRef,
2923
+ isDragDisabled
2924
+ }) => {
2925
+ const CustomInner = (0, import_react18.useMemo)(
2926
+ () => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("default"), children: children2 })),
2927
+ [children]
2928
+ );
2929
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2930
+ "div",
2931
+ {
2932
+ className: getClassNameItem({ disabled: isDragDisabled }),
2933
+ ref: dragRef,
2934
+ onMouseDown: (e) => e.preventDefault(),
2935
+ "data-testid": dragRef ? `drawer-item:${name}` : "",
2936
+ "data-puck-drawer-item": true,
2937
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CustomInner, { name, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("draggableWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassNameItem("draggable"), children: [
2938
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("name"), children: label != null ? label : name }),
2939
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DragIcon, {}) })
2940
+ ] }) }) })
2941
+ }
2942
+ );
2943
+ };
2944
+ var DrawerItemDraggable = ({
2945
+ children,
2946
+ name,
2947
+ label,
2948
+ id,
2949
+ isDragDisabled
2950
+ }) => {
2951
+ const { ref } = useDraggableSafe({
2952
+ id,
2953
+ data: { type: "drawer", componentType: name },
2954
+ disabled: isDragDisabled
2955
+ });
2956
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassName5("draggable"), children: [
2957
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName5("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DrawerItemInner, { name, label, children }) }),
2958
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName5("draggableFg"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2959
+ DrawerItemInner,
2960
+ {
2961
+ name,
2962
+ label,
2963
+ dragRef: ref,
2964
+ isDragDisabled,
2965
+ children
2966
+ }
2967
+ ) })
2968
+ ] });
2969
+ };
2970
+ var DrawerItem = ({
2971
+ name,
2972
+ children,
2973
+ id,
2974
+ label,
2975
+ index,
2976
+ isDragDisabled
2977
+ }) => {
2978
+ const resolvedId = id || name;
2979
+ const [dynamicId, setDynamicId] = (0, import_react18.useState)(generateId(resolvedId));
2980
+ if (typeof index !== "undefined") {
2981
+ console.error(
2982
+ "Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
2983
+ );
2984
+ }
2985
+ useDragListener(
2986
+ "dragend",
2987
+ () => {
2988
+ setDynamicId(generateId(resolvedId));
2989
+ },
2990
+ [resolvedId]
2991
+ );
2992
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2993
+ DrawerItemDraggable,
2994
+ {
2995
+ name,
2996
+ label,
2997
+ id: dynamicId,
2998
+ isDragDisabled,
2999
+ children
3000
+ }
3001
+ ) }, dynamicId);
3002
+ };
3003
+ var Drawer = ({
3004
+ children,
3005
+ droppableId,
3006
+ direction
3007
+ }) => {
3008
+ if (droppableId) {
3009
+ console.error(
3010
+ "Warning: The `droppableId` prop on Drawer is deprecated and no longer required."
3011
+ );
3012
+ }
3013
+ if (direction) {
3014
+ console.error(
3015
+ "Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
3016
+ );
3017
+ }
3018
+ const id = useSafeId();
3019
+ const { ref } = useDroppableSafe({
3020
+ id,
3021
+ type: "void",
3022
+ collisionPriority: 0
3023
+ // Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
3024
+ });
3025
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3026
+ "div",
3027
+ {
3028
+ className: getClassName5(),
3029
+ ref,
3030
+ "data-puck-dnd": id,
3031
+ "data-puck-drawer": true,
3032
+ children
3033
+ }
3034
+ );
3035
+ };
3036
+ Drawer.Item = DrawerItem;
3037
+
3038
+ // components/DropZone/lib/use-min-empty-height.ts
3039
+ init_react_import();
3040
+ var import_react19 = require("react");
3041
+ var useMinEmptyHeight = ({
3042
+ zoneCompound,
3043
+ userMinEmptyHeight,
3044
+ ref
3045
+ }) => {
3046
+ const appStore = useAppStoreApi();
3047
+ const [prevHeight, setPrevHeight] = (0, import_react19.useState)(0);
3048
+ const [isAnimating, setIsAnimating] = (0, import_react19.useState)(false);
3049
+ const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
3050
+ var _a, _b;
3051
+ return {
3052
+ draggedItem: ((_a = s.draggedItem) == null ? void 0 : _a.data.zone) === zoneCompound ? s.draggedItem : null,
3053
+ isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
3054
+ };
3055
+ });
3056
+ (0, import_react19.useEffect)(() => {
3057
+ if (draggedItem && ref.current) {
3058
+ if (isZone) {
3059
+ const rect = ref.current.getBoundingClientRect();
3060
+ setPrevHeight(rect.height);
3061
+ setIsAnimating(true);
3062
+ return;
3063
+ }
3064
+ }
3065
+ setPrevHeight(0);
3066
+ setTimeout(() => {
3067
+ var _a, _b;
3068
+ const zones = appStore.getState().state.indexes.zones;
3069
+ const nodes = appStore.getState().nodes;
3070
+ const selectedItem = appStore.getState().selectedItem;
3071
+ const contentIds = ((_a = zones[zoneCompound]) == null ? void 0 : _a.contentIds) || [];
3072
+ contentIds.forEach((contentId) => {
3073
+ const node = nodes.nodes[contentId];
3074
+ node == null ? void 0 : node.methods.sync();
3075
+ });
3076
+ if (selectedItem) {
3077
+ (_b = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _b.methods.sync();
3078
+ }
3079
+ setIsAnimating(false);
3080
+ }, 400);
3081
+ }, [ref.current, draggedItem, zoneCompound]);
3082
+ return [prevHeight || userMinEmptyHeight, isAnimating];
3083
+ };
3084
+
3085
+ // lib/assign-refs.ts
3086
+ init_react_import();
3087
+ function assignRef(ref, node) {
3088
+ if (typeof ref === "function") {
3089
+ ref(node);
3090
+ } else if (ref && typeof ref === "object" && "current" in ref) {
3091
+ ref.current = node;
3092
+ }
3093
+ }
3094
+ function assignRefs(refs, node) {
3095
+ refs.forEach((ref) => {
3096
+ assignRef(ref, node);
3097
+ });
3098
+ }
3099
+
3100
+ // components/DropZone/lib/use-content-with-preview.ts
3101
+ init_react_import();
3102
+ var import_react22 = require("react");
3103
+
3104
+ // lib/dnd/use-rendered-callback.ts
3105
+ init_react_import();
3106
+ var import_react20 = require("@dnd-kit/react");
3107
+ var import_react21 = require("react");
3108
+ function useRenderedCallback(callback, deps) {
3109
+ const manager = (0, import_react20.useDragDropManager)();
3110
+ return (0, import_react21.useCallback)(
3111
+ (...args) => __async(this, null, function* () {
3112
+ yield manager == null ? void 0 : manager.renderer.rendering;
3113
+ return callback(...args);
3114
+ }),
3115
+ [...deps, manager]
3116
+ );
3117
+ }
3118
+
3119
+ // components/DropZone/lib/use-content-with-preview.ts
3120
+ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
3121
+ const { draggedItemId, preview, previewExists } = useContextStore(
3122
+ ZoneStoreContext,
3123
+ (s) => {
3124
+ var _a;
3125
+ return {
3126
+ draggedItemId: (_a = s.draggedItem) == null ? void 0 : _a.id,
3127
+ preview: s.previewIndex[zoneCompound],
3128
+ previewExists: Object.keys(s.previewIndex || {}).length > 0
3129
+ };
3130
+ }
3131
+ );
3132
+ const isDragging = useAppStore((s) => s.state.ui.isDragging);
3133
+ const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react22.useState)(contentIds);
3134
+ const [localPreview, setLocalPreview] = (0, import_react22.useState)(
3135
+ preview
3136
+ );
3137
+ const updateContent = useRenderedCallback(
3138
+ (contentIds2, preview2, isDragging2) => {
3139
+ if (isDragging2 && !previewExists) {
3140
+ return;
3141
+ }
3142
+ if (preview2) {
3143
+ if (preview2.type === "insert") {
3144
+ setContentIdsWithPreview(
3145
+ insert(
3146
+ contentIds2.filter((id) => id !== preview2.props.id),
3147
+ preview2.index,
3148
+ preview2.props.id
3149
+ )
3150
+ );
3151
+ } else {
3152
+ setContentIdsWithPreview(
3153
+ insert(
3154
+ contentIds2.filter((id) => id !== preview2.props.id),
3155
+ preview2.index,
3156
+ preview2.props.id
3157
+ )
3158
+ );
3159
+ }
3160
+ } else {
3161
+ setContentIdsWithPreview(
3162
+ previewExists ? contentIds2.filter((id) => id !== draggedItemId) : contentIds2
3163
+ );
3164
+ }
3165
+ setLocalPreview(preview2);
3166
+ },
3167
+ [draggedItemId, previewExists]
3168
+ );
3169
+ (0, import_react22.useEffect)(() => {
3170
+ updateContent(contentIds, preview, isDragging);
3171
+ }, [contentIds, preview, isDragging]);
3172
+ return [contentIdsWithPreview, localPreview];
3173
+ };
3174
+
3175
+ // components/DropZone/lib/use-drag-axis.ts
3176
+ init_react_import();
3177
+ var import_react23 = require("react");
3178
+ var GRID_DRAG_AXIS = "dynamic";
3179
+ var FLEX_ROW_DRAG_AXIS = "x";
3180
+ var DEFAULT_DRAG_AXIS = "y";
3181
+ var useDragAxis = (ref, collisionAxis) => {
3182
+ const status = useAppStore((s) => s.status);
3183
+ const [dragAxis, setDragAxis] = (0, import_react23.useState)(
3184
+ collisionAxis || DEFAULT_DRAG_AXIS
3185
+ );
3186
+ const calculateDragAxis = (0, import_react23.useCallback)(() => {
3187
+ if (ref.current) {
3188
+ const computedStyle = window.getComputedStyle(ref.current);
3189
+ if (computedStyle.display === "grid") {
3190
+ setDragAxis(GRID_DRAG_AXIS);
3191
+ } else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
3192
+ setDragAxis(FLEX_ROW_DRAG_AXIS);
3193
+ } else {
3194
+ setDragAxis(DEFAULT_DRAG_AXIS);
3195
+ }
3196
+ }
3197
+ }, [ref.current]);
3198
+ (0, import_react23.useEffect)(() => {
3199
+ const onViewportChange = () => {
3200
+ calculateDragAxis();
3201
+ };
3202
+ window.addEventListener("viewportchange", onViewportChange);
3203
+ return () => {
3204
+ window.removeEventListener("viewportchange", onViewportChange);
3205
+ };
3206
+ }, []);
3207
+ (0, import_react23.useEffect)(calculateDragAxis, [status, collisionAxis]);
3208
+ return [dragAxis, calculateDragAxis];
3209
+ };
3210
+
3211
+ // components/DropZone/index.tsx
3212
+ var import_shallow3 = require("zustand/react/shallow");
3213
+
3214
+ // components/Render/index.tsx
3215
+ init_react_import();
3216
+ var import_react24 = __toESM(require("react"));
3217
+ var import_jsx_runtime8 = require("react/jsx-runtime");
3218
+ var renderContext = import_react24.default.createContext({
3219
+ config: { components: {} },
3220
+ data: { root: {}, content: [] },
3221
+ metadata: {}
3222
+ });
3223
+
3224
+ // components/DropZone/index.tsx
3225
+ var import_jsx_runtime9 = require("react/jsx-runtime");
3226
+ var getClassName6 = get_class_name_factory_default("DropZone", styles_module_default4);
3227
+ var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
3228
+ var RENDER_DEBUG = false;
3229
+ var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DropZoneEdit, __spreadValues({}, props));
3230
+ var DropZoneChild = ({
3231
+ zoneCompound,
3232
+ componentId,
3233
+ preview,
3234
+ index,
3235
+ isEnabled,
3236
+ dragAxis,
3237
+ collisionAxis,
3238
+ inDroppableZone
3239
+ }) => {
3240
+ var _a, _b;
3241
+ const metadata = useAppStore((s) => s.metadata);
3242
+ const puckProps = {
3243
+ renderDropZone: DropZoneEditPure,
3244
+ isEditing: true,
3245
+ dragRef: null,
3246
+ metadata
3247
+ };
3248
+ const ctx = (0, import_react25.useContext)(dropZoneContext);
3249
+ const { depth } = ctx;
3250
+ const nodeProps = useAppStore(
3251
+ (0, import_shallow3.useShallow)((s) => {
3252
+ var _a2;
3253
+ return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.flatData.props;
3254
+ })
3255
+ );
3256
+ const nodeType = useAppStore(
3257
+ (s) => {
3258
+ var _a2;
3259
+ return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.type;
3260
+ }
3261
+ );
3262
+ const node = { type: nodeType, props: nodeProps };
3263
+ const item = nodeProps ? node : (preview == null ? void 0 : preview.componentType) ? { type: preview.componentType, props: preview.props } : null;
3264
+ const componentConfig = useAppStore(
3265
+ (s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
3266
+ );
3267
+ const overrides = useAppStore((s) => s.overrides);
3268
+ const isLoading = useAppStore(
3269
+ (s) => {
3270
+ var _a2;
3271
+ return ((_a2 = s.componentState[componentId]) == null ? void 0 : _a2.loadingCount) > 0;
3272
+ }
3273
+ );
3274
+ const isSelected = useAppStore(
3275
+ (s) => {
3276
+ var _a2;
3277
+ return ((_a2 = s.selectedItem) == null ? void 0 : _a2.props.id) === componentId || false;
3278
+ }
3279
+ );
3280
+ let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
3281
+ const renderPreview = (0, import_react25.useMemo)(
3282
+ () => function Preview3() {
3283
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DrawerItemInner, { name: label, children: overrides.componentItem });
3284
+ },
3285
+ [componentId, label, overrides]
3286
+ );
3287
+ const defaultsProps = (0, import_react25.useMemo)(
3288
+ () => __spreadProps(__spreadValues(__spreadValues({}, componentConfig == null ? void 0 : componentConfig.defaultProps), item == null ? void 0 : item.props), {
3289
+ puck: puckProps,
3290
+ editMode: true
3291
+ // DEPRECATED
3292
+ }),
3293
+ [componentConfig == null ? void 0 : componentConfig.defaultProps, item == null ? void 0 : item.props, puckProps]
3294
+ );
3295
+ const defaultedPropsWithSlots = useSlots(
3296
+ componentConfig,
3297
+ defaultsProps,
3298
+ DropZoneEditPure
3299
+ );
3300
+ if (!item) return;
3301
+ let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
3302
+ "No configuration for ",
3303
+ item.type
3304
+ ] });
3305
+ let componentType = item.type;
3306
+ const isPreview = componentId === (preview == null ? void 0 : preview.props.id) && preview.type === "insert";
3307
+ if (isPreview) {
3308
+ Render2 = renderPreview;
3309
+ }
3310
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3311
+ DraggableComponent,
3312
+ {
3313
+ id: componentId,
3314
+ componentType,
3315
+ zoneCompound,
3316
+ depth: depth + 1,
3317
+ index,
3318
+ isLoading,
3319
+ isSelected,
3320
+ label,
3321
+ isEnabled,
3322
+ autoDragAxis: dragAxis,
3323
+ userDragAxis: collisionAxis,
3324
+ inDroppableZone,
3325
+ children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isPreview ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3326
+ Render2,
3327
+ __spreadProps(__spreadValues({}, defaultedPropsWithSlots), {
3328
+ puck: __spreadProps(__spreadValues({}, defaultedPropsWithSlots.puck), {
3329
+ dragRef
3330
+ })
3331
+ })
3332
+ ) }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Render2, __spreadValues({}, defaultedPropsWithSlots)) })
3333
+ }
3334
+ );
3335
+ };
3336
+ var DropZoneEdit = (0, import_react25.forwardRef)(
3337
+ function DropZoneEditInternal({
3338
+ zone,
3339
+ allow,
3340
+ disallow,
3341
+ style,
3342
+ className,
3343
+ minEmptyHeight: userMinEmptyHeight = 128,
3344
+ collisionAxis
3345
+ }, userRef) {
3346
+ const ctx = (0, import_react25.useContext)(dropZoneContext);
3347
+ const {
3348
+ // These all need setting via context
3349
+ areaId,
3350
+ depth,
3351
+ registerLocalZone,
3352
+ unregisterLocalZone
3353
+ } = ctx;
3354
+ const path = useAppStore(
3355
+ (0, import_shallow3.useShallow)((s) => {
3356
+ var _a;
3357
+ return areaId ? (_a = s.state.indexes.nodes[areaId]) == null ? void 0 : _a.path : null;
3358
+ })
3359
+ );
3360
+ let zoneCompound = rootDroppableId;
3361
+ if (areaId) {
3362
+ if (zone !== rootDroppableId) {
3363
+ zoneCompound = `${areaId}:${zone}`;
3364
+ }
3365
+ }
3366
+ const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
3367
+ const {
3368
+ isDeepestZone,
3369
+ inNextDeepestArea,
3370
+ draggedComponentType,
3371
+ userIsDragging
3372
+ } = useContextStore(ZoneStoreContext, (s) => {
3373
+ var _a, _b;
3374
+ return {
3375
+ isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
3376
+ inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
3377
+ draggedComponentType: (_b = s.draggedItem) == null ? void 0 : _b.data.componentType,
3378
+ userIsDragging: !!s.draggedItem
3379
+ };
3380
+ });
3381
+ const zoneContentIds = useAppStore(
3382
+ (0, import_shallow3.useShallow)((s) => {
3383
+ var _a;
3384
+ return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds;
3385
+ })
3386
+ );
3387
+ const zoneType = useAppStore(
3388
+ (0, import_shallow3.useShallow)((s) => {
3389
+ var _a;
3390
+ return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
3391
+ })
3392
+ );
3393
+ (0, import_react25.useEffect)(() => {
3394
+ if (!zoneType || zoneType === "dropzone") {
3395
+ if (ctx == null ? void 0 : ctx.registerZone) {
3396
+ ctx == null ? void 0 : ctx.registerZone(zoneCompound);
3397
+ }
3398
+ return () => {
3399
+ if (ctx == null ? void 0 : ctx.unregisterZone) {
3400
+ ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
3401
+ }
3402
+ };
3403
+ }
3404
+ }, [zoneType]);
3405
+ const contentIds = (0, import_react25.useMemo)(() => {
3406
+ return zoneContentIds || [];
3407
+ }, [zoneContentIds]);
3408
+ const ref = (0, import_react25.useRef)(null);
3409
+ const acceptsTarget = (0, import_react25.useCallback)(
3410
+ (componentType) => {
3411
+ if (!componentType) {
3412
+ return true;
3413
+ }
3414
+ if (disallow) {
3415
+ const defaultedAllow = allow || [];
3416
+ const filteredDisallow = (disallow || []).filter(
3417
+ (item) => defaultedAllow.indexOf(item) === -1
3418
+ );
3419
+ if (filteredDisallow.indexOf(componentType) !== -1) {
3420
+ return false;
3421
+ }
3422
+ } else if (allow) {
3423
+ if (allow.indexOf(componentType) === -1) {
3424
+ return false;
3425
+ }
3426
+ }
3427
+ return true;
3428
+ },
3429
+ [allow, disallow]
3430
+ );
3431
+ (0, import_react25.useEffect)(() => {
3432
+ if (registerLocalZone) {
3433
+ registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
3434
+ }
3435
+ return () => {
3436
+ if (unregisterLocalZone) {
3437
+ unregisterLocalZone(zoneCompound);
3438
+ }
3439
+ };
3440
+ }, [draggedComponentType, zoneCompound]);
3441
+ const hoveringOverArea = inNextDeepestArea || isRootZone;
3442
+ let isEnabled = true;
3443
+ if (userIsDragging) {
3444
+ isEnabled = isDeepestZone;
3445
+ }
3446
+ if (isEnabled) {
3447
+ isEnabled = acceptsTarget(draggedComponentType);
3448
+ }
3449
+ const [contentIdsWithPreview, preview] = useContentIdsWithPreview(
3450
+ contentIds,
3451
+ zoneCompound
3452
+ );
3453
+ const isDropEnabled = isEnabled && (preview ? contentIdsWithPreview.length === 1 : contentIdsWithPreview.length === 0);
3454
+ const droppableConfig = {
3455
+ id: zoneCompound,
3456
+ collisionPriority: isEnabled ? depth : 0,
3457
+ disabled: !isDropEnabled,
3458
+ collisionDetector: pointerIntersection,
3459
+ type: "dropzone",
3460
+ data: {
3461
+ areaId,
3462
+ depth,
3463
+ isDroppableTarget: acceptsTarget(draggedComponentType),
3464
+ path: path || []
3465
+ }
3466
+ };
3467
+ const { ref: dropRef } = useDroppableSafe(droppableConfig);
3468
+ const isAreaSelected = useAppStore(
3469
+ (s) => (s == null ? void 0 : s.selectedItem) && areaId === (s == null ? void 0 : s.selectedItem.props.id)
3470
+ );
3471
+ const [dragAxis] = useDragAxis(ref, collisionAxis);
3472
+ const [minEmptyHeight, isAnimating] = useMinEmptyHeight({
3473
+ zoneCompound,
3474
+ userMinEmptyHeight,
3475
+ ref
3476
+ });
3477
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3478
+ "div",
3479
+ {
3480
+ className: `${getClassName6({
3481
+ isRootZone,
3482
+ userIsDragging,
3483
+ hoveringOverArea,
3484
+ isEnabled,
3485
+ isAreaSelected,
3486
+ hasChildren: contentIds.length > 0,
3487
+ isAnimating
3488
+ })}${className ? ` ${className}` : ""}`,
3489
+ ref: (node) => {
3490
+ assignRefs([ref, dropRef, userRef], node);
3491
+ },
3492
+ "data-testid": `dropzone:${zoneCompound}`,
3493
+ "data-puck-dropzone": zoneCompound,
3494
+ style: __spreadProps(__spreadValues({}, style), {
3495
+ "--min-empty-height": `${minEmptyHeight}px`,
3496
+ backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
3497
+ }),
3498
+ children: contentIdsWithPreview.map((componentId, i) => {
3499
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3500
+ DropZoneChild,
3501
+ {
3502
+ zoneCompound,
3503
+ componentId,
3504
+ preview,
3505
+ dragAxis,
3506
+ isEnabled,
3507
+ index: i,
3508
+ collisionAxis,
3509
+ inDroppableZone: acceptsTarget(draggedComponentType)
3510
+ },
3511
+ componentId
3512
+ );
3513
+ })
3514
+ }
3515
+ );
3516
+ }
3517
+ );
3518
+ var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DropZoneRender, __spreadValues({}, props));
3519
+ var DropZoneRender = (0, import_react25.forwardRef)(
3520
+ function DropZoneRenderInternal({ className, style, zone }, ref) {
3521
+ const ctx = (0, import_react25.useContext)(dropZoneContext);
3522
+ const { areaId = "root" } = ctx || {};
3523
+ const { config, data, metadata } = (0, import_react25.useContext)(renderContext);
3524
+ let zoneCompound = rootDroppableId;
3525
+ let content = (data == null ? void 0 : data.content) || [];
3526
+ (0, import_react25.useEffect)(() => {
3527
+ if (!content) {
3528
+ if (ctx == null ? void 0 : ctx.registerZone) {
3529
+ ctx == null ? void 0 : ctx.registerZone(zoneCompound);
3530
+ }
3531
+ return () => {
3532
+ if (ctx == null ? void 0 : ctx.unregisterZone) {
3533
+ ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
3534
+ }
3535
+ };
3536
+ }
3537
+ }, [content]);
3538
+ if (!data || !config) {
3539
+ return null;
3540
+ }
3541
+ if (areaId !== rootAreaId && zone !== rootZone) {
3542
+ zoneCompound = `${areaId}:${zone}`;
3543
+ content = setupZone(data, zoneCompound).zones[zoneCompound];
3544
+ }
3545
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className, style, ref, children: content.map((item) => {
3546
+ const Component = config.components[item.type];
3547
+ if (Component) {
3548
+ const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3549
+ SlotRenderPure,
3550
+ __spreadProps(__spreadValues({}, slotProps), {
3551
+ config,
3552
+ metadata
3553
+ })
3554
+ ));
3555
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3556
+ DropZoneProvider,
3557
+ {
3558
+ value: {
3559
+ areaId: props.id,
3560
+ depth: 1
3561
+ },
3562
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3563
+ Component.render,
3564
+ __spreadProps(__spreadValues({}, props), {
3565
+ puck: {
3566
+ renderDropZone: DropZoneRenderPure,
3567
+ metadata: metadata || {}
3568
+ }
3569
+ })
3570
+ )
3571
+ },
3572
+ props.id
3573
+ );
3574
+ }
3575
+ return null;
3576
+ }) });
3577
+ }
3578
+ );
3579
+ var DropZone = (0, import_react25.forwardRef)(
3580
+ function DropZone2(props, ref) {
3581
+ const ctx = (0, import_react25.useContext)(dropZoneContext);
3582
+ if ((ctx == null ? void 0 : ctx.mode) === "edit") {
3583
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
3584
+ }
3585
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
3586
+ }
3587
+ );
3588
+
3589
+ // components/SlotRender/index.tsx
3590
+ var import_jsx_runtime10 = require("react/jsx-runtime");
3591
+ var SlotRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SlotRender, __spreadValues({}, props));
3592
+ var SlotRender = (0, import_react26.forwardRef)(
3593
+ function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
3594
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className, style, ref, children: content.map((item) => {
3595
+ const Component = config.components[item.type];
3596
+ if (Component) {
3597
+ const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
3598
+ SlotRenderPure,
3599
+ __spreadProps(__spreadValues({}, slotProps), {
3600
+ config,
3601
+ metadata
3602
+ })
3603
+ ));
3604
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
3605
+ Component.render,
3606
+ __spreadProps(__spreadValues({}, props), {
3607
+ puck: {
3608
+ renderDropZone: DropZoneRenderPure,
3609
+ metadata: metadata || {}
3610
+ }
3611
+ }),
3612
+ props.id
3613
+ );
3614
+ }
3615
+ return null;
3616
+ }) });
3617
+ }
3618
+ );
3619
+
3620
+ // components/ServerRender/index.tsx
3621
+ var import_jsx_runtime11 = require("react/jsx-runtime");
3622
+ function DropZoneRender2({
3623
+ zone,
3624
+ data,
3625
+ areaId = "root",
3626
+ config,
3627
+ metadata = {}
3628
+ }) {
3629
+ let zoneCompound = rootDroppableId;
3630
+ let content = (data == null ? void 0 : data.content) || [];
3631
+ if (!data || !config) {
3632
+ return null;
3633
+ }
3634
+ if (areaId !== rootAreaId && zone !== rootZone) {
3635
+ zoneCompound = `${areaId}:${zone}`;
3636
+ content = setupZone(data, zoneCompound).zones[zoneCompound];
3637
+ }
3638
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children: content.map((item) => {
3639
+ const Component = config.components[item.type];
3640
+ const props = __spreadProps(__spreadValues({}, item.props), {
3641
+ puck: {
3642
+ renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3643
+ DropZoneRender2,
3644
+ {
3645
+ zone: zone2,
3646
+ data,
3647
+ areaId: item.props.id,
3648
+ config,
3649
+ metadata
3650
+ }
3651
+ ),
3652
+ metadata
3653
+ }
3654
+ });
3655
+ const propsWithSlots = useSlots(config.root, props, (props2) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
3656
+ if (Component) {
3657
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Component.render, __spreadValues({}, propsWithSlots), item.props.id);
3658
+ }
3659
+ return null;
3660
+ }) });
3661
+ }
3662
+ function Render({
3663
+ config,
3664
+ data,
3665
+ metadata = {}
3666
+ }) {
3667
+ var _a;
3668
+ const rootProps = data.root.props || data.root;
3669
+ const title = rootProps.title || "";
3670
+ const props = __spreadProps(__spreadValues({}, rootProps), {
3671
+ puck: {
3672
+ renderDropZone: ({ zone }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3673
+ DropZoneRender2,
3674
+ {
3675
+ zone,
3676
+ data,
3677
+ config,
3678
+ metadata
3679
+ }
3680
+ ),
3681
+ isEditing: false,
3682
+ dragRef: null,
3683
+ metadata
3684
+ },
3685
+ title,
3686
+ editMode: false,
3687
+ id: "puck-root"
3688
+ });
3689
+ const propsWithSlots = useSlots(config.root, props, (props2) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
3690
+ if ((_a = config.root) == null ? void 0 : _a.render) {
3691
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(config.root.render, __spreadProps(__spreadValues({}, propsWithSlots), { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3692
+ DropZoneRender2,
3693
+ {
3694
+ config,
3695
+ data,
3696
+ zone: rootZone,
3697
+ metadata
3698
+ }
3699
+ ) }));
3700
+ }
3701
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3702
+ DropZoneRender2,
3703
+ {
3704
+ config,
3705
+ data,
3706
+ zone: rootZone,
3707
+ metadata
3708
+ }
3709
+ );
3710
+ }
3711
+
3712
+ // lib/resolve-all-data.ts
3713
+ init_react_import();
3714
+
3715
+ // lib/default-data.ts
3716
+ init_react_import();
3717
+ var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
3718
+ root: data.root || {},
3719
+ content: data.content || []
3720
+ });
3721
+
3722
+ // lib/to-component.ts
3723
+ init_react_import();
3724
+ var toComponent = (item) => {
3725
+ return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
3726
+ props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
3727
+ type: "root"
3728
+ });
3729
+ };
3730
+
3731
+ // lib/resolve-all-data.ts
3732
+ function resolveAllData(_0, _1) {
3733
+ return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
3734
+ var _a;
3735
+ const defaultedData = defaultData(data);
3736
+ const resolveNode = (_node) => __async(this, null, function* () {
3737
+ const node = toComponent(_node);
3738
+ onResolveStart == null ? void 0 : onResolveStart(node);
3739
+ const resolved = (yield resolveComponentData(
3740
+ node,
3741
+ config,
3742
+ metadata,
3743
+ () => {
3744
+ },
3745
+ () => {
3746
+ },
3747
+ "force",
3748
+ false
3749
+ )).node;
3750
+ const resolvedDeep = yield mapSlots(resolved, processContent, false);
3751
+ onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
3752
+ return resolvedDeep;
3753
+ });
3754
+ const processContent = (content) => __async(this, null, function* () {
3755
+ return Promise.all(content.map(resolveNode));
3756
+ });
3757
+ const dynamic = {
3758
+ root: yield resolveNode(defaultedData.root),
3759
+ content: yield processContent(defaultedData.content),
3760
+ zones: {}
3761
+ };
3762
+ Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(this, null, function* () {
3763
+ const content = defaultedData.zones[zoneKey];
3764
+ dynamic.zones[zoneKey] = yield processContent(content);
3765
+ }), {});
3766
+ return dynamic;
3767
+ });
3768
+ }
3769
+
3770
+ // lib/transform-props.ts
3771
+ init_react_import();
3772
+ function transformProps(data, propTransforms) {
3773
+ const mapItem = (item) => {
3774
+ if (propTransforms[item.type]) {
3775
+ return __spreadProps(__spreadValues({}, item), {
3776
+ props: propTransforms[item.type](item.props)
3777
+ });
3778
+ }
3779
+ return item;
3780
+ };
3781
+ const defaultedData = defaultData(data);
3782
+ const rootProps = defaultedData.root.props || defaultedData.root;
3783
+ let newRoot = __spreadValues({}, defaultedData.root);
3784
+ if (propTransforms["root"]) {
3785
+ if (defaultedData.root.props) {
3786
+ newRoot.props = propTransforms["root"](rootProps);
3787
+ } else {
3788
+ newRoot = propTransforms["root"](rootProps);
3789
+ }
3790
+ }
3791
+ const afterPropTransforms = __spreadProps(__spreadValues({}, defaultedData), {
3792
+ root: newRoot,
3793
+ content: defaultedData.content.map(mapItem),
3794
+ zones: Object.keys(data.zones || {}).reduce(
3795
+ (acc, zoneKey) => __spreadProps(__spreadValues({}, acc), {
3796
+ [zoneKey]: data.zones[zoneKey].map(mapItem)
3797
+ }),
3798
+ {}
3799
+ )
3800
+ });
3801
+ return afterPropTransforms;
3802
+ }
3803
+ // Annotate the CommonJS export names for ESM import in node:
3804
+ 0 && (module.exports = {
3805
+ Render,
3806
+ resolveAllData,
3807
+ transformProps
3808
+ });
3809
+ /*! Bundled license information:
3810
+
3811
+ classnames/index.js:
3812
+ (*!
3813
+ Copyright (c) 2018 Jed Watson.
3814
+ Licensed under the MIT License (MIT), see
3815
+ http://jedwatson.github.io/classnames
3816
+ *)
3817
+
3818
+ lucide-react/dist/esm/shared/src/utils.js:
3819
+ (**
3820
+ * @license lucide-react v0.468.0 - ISC
3821
+ *
3822
+ * This source code is licensed under the ISC license.
3823
+ * See the LICENSE file in the root directory of this source tree.
3824
+ *)
3825
+
3826
+ lucide-react/dist/esm/defaultAttributes.js:
3827
+ (**
3828
+ * @license lucide-react v0.468.0 - ISC
3829
+ *
3830
+ * This source code is licensed under the ISC license.
3831
+ * See the LICENSE file in the root directory of this source tree.
3832
+ *)
3833
+
3834
+ lucide-react/dist/esm/Icon.js:
3835
+ (**
3836
+ * @license lucide-react v0.468.0 - ISC
3837
+ *
3838
+ * This source code is licensed under the ISC license.
3839
+ * See the LICENSE file in the root directory of this source tree.
3840
+ *)
3841
+
3842
+ lucide-react/dist/esm/createLucideIcon.js:
3843
+ (**
3844
+ * @license lucide-react v0.468.0 - ISC
3845
+ *
3846
+ * This source code is licensed under the ISC license.
3847
+ * See the LICENSE file in the root directory of this source tree.
3848
+ *)
3849
+
3850
+ lucide-react/dist/esm/icons/copy.js:
3851
+ (**
3852
+ * @license lucide-react v0.468.0 - ISC
3853
+ *
3854
+ * This source code is licensed under the ISC license.
3855
+ * See the LICENSE file in the root directory of this source tree.
3856
+ *)
3857
+
3858
+ lucide-react/dist/esm/icons/corner-left-up.js:
3859
+ (**
3860
+ * @license lucide-react v0.468.0 - ISC
3861
+ *
3862
+ * This source code is licensed under the ISC license.
3863
+ * See the LICENSE file in the root directory of this source tree.
3864
+ *)
3865
+
3866
+ lucide-react/dist/esm/icons/trash.js:
3867
+ (**
3868
+ * @license lucide-react v0.468.0 - ISC
3869
+ *
3870
+ * This source code is licensed under the ISC license.
3871
+ * See the LICENSE file in the root directory of this source tree.
3872
+ *)
3873
+
3874
+ lucide-react/dist/esm/lucide-react.js:
3875
+ (**
3876
+ * @license lucide-react v0.468.0 - ISC
3877
+ *
3878
+ * This source code is licensed under the ISC license.
3879
+ * See the LICENSE file in the root directory of this source tree.
3880
+ *)
3881
+ */