@measured/puck 0.19.4-canary.fde74e8a → 0.20.0-canary.167a8f71

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/index.js CHANGED
@@ -153,9 +153,9 @@ var require_classnames = __commonJS({
153
153
  }
154
154
  });
155
155
 
156
- // index.ts
157
- var core_exports = {};
158
- __export(core_exports, {
156
+ // bundle/index.ts
157
+ var bundle_exports = {};
158
+ __export(bundle_exports, {
159
159
  Action: () => Action,
160
160
  ActionBar: () => ActionBar,
161
161
  AutoField: () => AutoField,
@@ -167,7 +167,7 @@ __export(core_exports, {
167
167
  IconButton: () => IconButton,
168
168
  Label: () => Label,
169
169
  Puck: () => Puck,
170
- Render: () => Render2,
170
+ Render: () => Render,
171
171
  createUsePuck: () => createUsePuck,
172
172
  migrate: () => migrate,
173
173
  overrideKeys: () => overrideKeys,
@@ -178,7 +178,10 @@ __export(core_exports, {
178
178
  usePuck: () => usePuck,
179
179
  walkTree: () => walkTree
180
180
  });
181
- module.exports = __toCommonJS(core_exports);
181
+ module.exports = __toCommonJS(bundle_exports);
182
+ init_react_import();
183
+
184
+ // bundle/core.ts
182
185
  init_react_import();
183
186
 
184
187
  // types/API/index.ts
@@ -306,7 +309,7 @@ init_react_import();
306
309
  var styles_module_default2 = { "InputWrapper": "_InputWrapper_py9hf_1", "Input-label": "_Input-label_py9hf_5", "Input-labelIcon": "_Input-labelIcon_py9hf_14", "Input-disabledIcon": "_Input-disabledIcon_py9hf_21", "Input-input": "_Input-input_py9hf_26", "Input": "_Input_py9hf_1", "Input--readOnly": "_Input--readOnly_py9hf_76", "Input-radioGroupItems": "_Input-radioGroupItems_py9hf_87", "Input-radio": "_Input-radio_py9hf_87", "Input-radioInner": "_Input-radioInner_py9hf_104", "Input-radioInput": "_Input-radioInput_py9hf_149" };
307
310
 
308
311
  // components/AutoField/index.tsx
309
- var import_react24 = require("react");
312
+ var import_react20 = require("react");
310
313
 
311
314
  // components/AutoField/fields/index.tsx
312
315
  init_react_import();
@@ -766,7 +769,7 @@ var IconButton = ({
766
769
  };
767
770
 
768
771
  // components/AutoField/fields/ArrayField/index.tsx
769
- var import_react16 = require("react");
772
+ var import_react14 = require("react");
770
773
 
771
774
  // components/DragIcon/index.tsx
772
775
  init_react_import();
@@ -1253,585 +1256,149 @@ function insertAction(state, action, appStore) {
1253
1256
 
1254
1257
  // reducer/actions/replace.ts
1255
1258
  init_react_import();
1256
-
1257
- // rsc.tsx
1258
- init_react_import();
1259
-
1260
- // components/ServerRender/index.tsx
1261
- init_react_import();
1262
-
1263
- // lib/data/setup-zone.ts
1264
- init_react_import();
1265
- var setupZone = (data, zoneKey) => {
1266
- if (zoneKey === rootDroppableId) {
1267
- return data;
1259
+ var replaceAction = (state, action, appStore) => {
1260
+ const [parentId] = action.destinationZone.split(":");
1261
+ const idsInPath = getIdsForParent(action.destinationZone, state);
1262
+ const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
1263
+ const idChanged = originalId !== action.data.props.id;
1264
+ if (idChanged) {
1265
+ throw new Error(
1266
+ `Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
1267
+ );
1268
1268
  }
1269
- const newData = __spreadProps(__spreadValues({}, data), {
1270
- zones: data.zones ? __spreadValues({}, data.zones) : {}
1269
+ const newSlotIds = [];
1270
+ const data = walkTree(action.data, appStore.config, (contents, opts) => {
1271
+ newSlotIds.push(`${opts.parentId}:${opts.propName}`);
1272
+ return contents.map((item) => {
1273
+ const id = generateId(item.type);
1274
+ return __spreadProps(__spreadValues({}, item), {
1275
+ props: __spreadValues({ id }, item.props)
1276
+ });
1277
+ });
1271
1278
  });
1272
- newData.zones[zoneKey] = newData.zones[zoneKey] || [];
1273
- return newData;
1279
+ const stateWithDeepSlotsRemoved = __spreadValues({}, state);
1280
+ Object.keys(state.indexes.zones).forEach((zoneCompound) => {
1281
+ const id = zoneCompound.split(":")[0];
1282
+ if (id === originalId) {
1283
+ if (!newSlotIds.includes(zoneCompound)) {
1284
+ delete stateWithDeepSlotsRemoved.indexes.zones[zoneCompound];
1285
+ }
1286
+ }
1287
+ });
1288
+ return walkAppState(
1289
+ stateWithDeepSlotsRemoved,
1290
+ appStore.config,
1291
+ (content, zoneCompound) => {
1292
+ const newContent = [...content];
1293
+ if (zoneCompound === action.destinationZone) {
1294
+ newContent[action.destinationIndex] = data;
1295
+ }
1296
+ return newContent;
1297
+ },
1298
+ (childItem, path) => {
1299
+ const pathIds = path.map((p) => p.split(":")[0]);
1300
+ if (childItem.props.id === data.props.id) {
1301
+ return data;
1302
+ } else if (childItem.props.id === parentId) {
1303
+ return childItem;
1304
+ } else if (idsInPath.indexOf(childItem.props.id) > -1) {
1305
+ return childItem;
1306
+ } else if (pathIds.indexOf(data.props.id) > -1) {
1307
+ return childItem;
1308
+ }
1309
+ return null;
1310
+ }
1311
+ );
1274
1312
  };
1275
1313
 
1276
- // lib/use-slots.tsx
1314
+ // reducer/actions/replace-root.ts
1277
1315
  init_react_import();
1278
- var import_react5 = require("react");
1279
- function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
1280
- const slotProps = (0, import_react5.useMemo)(() => {
1281
- const mapped = mapSlots(
1282
- item,
1283
- (content, _parentId, propName, field, propPath) => {
1284
- const wildcardPath = propPath.replace(/\[\d+\]/g, "[*]");
1285
- const isReadOnly = (readOnly == null ? void 0 : readOnly[propPath]) || (readOnly == null ? void 0 : readOnly[wildcardPath]) || forceReadOnly;
1286
- const render = isReadOnly ? renderSlotRender : renderSlotEdit;
1287
- const Slot = (dzProps) => render(__spreadProps(__spreadValues({
1288
- allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
1289
- disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
1290
- }, dzProps), {
1291
- zone: propName,
1292
- content
1293
- }));
1294
- return Slot;
1295
- },
1296
- config
1297
- ).props;
1298
- return mapped;
1299
- }, [config, item, readOnly, forceReadOnly]);
1300
- const mergedProps = (0, import_react5.useMemo)(
1301
- () => __spreadValues(__spreadValues({}, item.props), slotProps),
1302
- [item.props, slotProps]
1316
+ var replaceRootAction = (state, action, appStore) => {
1317
+ return walkAppState(
1318
+ state,
1319
+ appStore.config,
1320
+ (content) => content,
1321
+ (childItem) => {
1322
+ if (childItem.props.id === "root") {
1323
+ return __spreadProps(__spreadValues({}, childItem), {
1324
+ props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
1325
+ readOnly: action.root.readOnly
1326
+ });
1327
+ }
1328
+ return childItem;
1329
+ }
1303
1330
  );
1304
- return mergedProps;
1305
- }
1331
+ };
1306
1332
 
1307
- // components/SlotRender/server.tsx
1333
+ // reducer/actions/duplicate.ts
1308
1334
  init_react_import();
1309
- var import_react6 = require("react");
1310
- var import_jsx_runtime5 = require("react/jsx-runtime");
1311
- var SlotRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SlotRender, __spreadValues({}, props));
1312
- var Item = ({
1313
- config,
1314
- item,
1315
- metadata
1316
- }) => {
1317
- const Component = config.components[item.type];
1318
- const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
1319
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1320
- Component.render,
1321
- __spreadProps(__spreadValues({}, props), {
1322
- puck: __spreadProps(__spreadValues({}, props.puck), {
1323
- renderDropZone: DropZoneRender,
1324
- metadata: metadata || {}
1325
- })
1326
- })
1335
+
1336
+ // lib/data/get-item.ts
1337
+ init_react_import();
1338
+ function getItem(selector, state) {
1339
+ var _a, _b;
1340
+ const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
1341
+ return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
1342
+ }
1343
+
1344
+ // reducer/actions/duplicate.ts
1345
+ function duplicateAction(state, action, appStore) {
1346
+ const item = getItem(
1347
+ { index: action.sourceIndex, zone: action.sourceZone },
1348
+ state
1327
1349
  );
1328
- };
1329
- var SlotRender = (0, import_react6.forwardRef)(
1330
- function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
1331
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className, style, ref, children: content.map((item) => {
1332
- if (!config.components[item.type]) {
1333
- return null;
1350
+ const idsInPath = getIdsForParent(action.sourceZone, state);
1351
+ const newItem = __spreadProps(__spreadValues({}, item), {
1352
+ props: __spreadProps(__spreadValues({}, item.props), {
1353
+ id: generateId(item.type)
1354
+ })
1355
+ });
1356
+ const modified = walkAppState(
1357
+ state,
1358
+ appStore.config,
1359
+ (content, zoneCompound) => {
1360
+ if (zoneCompound === action.sourceZone) {
1361
+ return insert(content, action.sourceIndex + 1, item);
1334
1362
  }
1335
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1336
- Item,
1337
- {
1338
- config,
1339
- item,
1340
- metadata
1341
- },
1342
- item.props.id
1343
- );
1344
- }) });
1345
- }
1346
- );
1347
-
1348
- // components/ServerRender/index.tsx
1349
- var import_jsx_runtime6 = require("react/jsx-runtime");
1350
- function DropZoneRender({
1351
- zone,
1352
- data,
1353
- areaId = "root",
1354
- config,
1355
- metadata = {}
1356
- }) {
1357
- let zoneCompound = rootDroppableId;
1358
- let content = (data == null ? void 0 : data.content) || [];
1359
- if (!data || !config) {
1360
- return null;
1361
- }
1362
- if (areaId !== rootAreaId && zone !== rootZone) {
1363
- zoneCompound = `${areaId}:${zone}`;
1364
- content = setupZone(data, zoneCompound).zones[zoneCompound];
1365
- }
1366
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: content.map((item) => {
1367
- const Component = config.components[item.type];
1368
- const props = __spreadProps(__spreadValues({}, item.props), {
1369
- puck: {
1370
- renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1371
- DropZoneRender,
1372
- {
1373
- zone: zone2,
1374
- data,
1375
- areaId: item.props.id,
1376
- config,
1377
- metadata
1378
- }
1379
- ),
1380
- metadata,
1381
- dragRef: null,
1382
- isEditing: false
1363
+ return content;
1364
+ },
1365
+ (childItem, path, index) => {
1366
+ const zoneCompound = path[path.length - 1];
1367
+ const parents = path.map((p) => p.split(":")[0]);
1368
+ if (parents.indexOf(newItem.props.id) > -1) {
1369
+ return __spreadProps(__spreadValues({}, childItem), {
1370
+ props: __spreadProps(__spreadValues({}, childItem.props), {
1371
+ id: generateId(childItem.type)
1372
+ })
1373
+ });
1383
1374
  }
1384
- });
1385
- const renderItem = __spreadProps(__spreadValues({}, item), { props });
1386
- const propsWithSlots = useSlots(config, renderItem, (props2) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
1387
- if (Component) {
1388
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Component.render, __spreadValues({}, propsWithSlots), renderItem.props.id);
1375
+ if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
1376
+ return newItem;
1377
+ }
1378
+ const [sourceZoneParent] = action.sourceZone.split(":");
1379
+ if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
1380
+ return childItem;
1381
+ }
1382
+ return null;
1389
1383
  }
1390
- return null;
1391
- }) });
1384
+ );
1385
+ return __spreadProps(__spreadValues({}, modified), {
1386
+ ui: __spreadProps(__spreadValues({}, modified.ui), {
1387
+ itemSelector: {
1388
+ index: action.sourceIndex + 1,
1389
+ zone: action.sourceZone
1390
+ }
1391
+ })
1392
+ });
1392
1393
  }
1393
1394
 
1394
- // lib/resolve-all-data.ts
1395
+ // reducer/actions/reorder.ts
1395
1396
  init_react_import();
1396
1397
 
1397
- // lib/resolve-component-data.ts
1398
+ // reducer/actions/move.ts
1398
1399
  init_react_import();
1399
1400
 
1400
- // lib/get-changed.ts
1401
- init_react_import();
1402
- var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
1403
- var getChanged = (newItem, oldItem) => {
1404
- return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
1405
- const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
1406
- const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
1407
- return __spreadProps(__spreadValues({}, acc), {
1408
- [item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
1409
- });
1410
- }, {}) : {};
1411
- };
1412
-
1413
- // lib/resolve-component-data.ts
1414
- var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"));
1415
- var cache = { lastChange: {} };
1416
- var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
1417
- const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
1418
- const resolvedItem = __spreadValues({}, item);
1419
- const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
1420
- const id = "id" in item.props ? item.props.id : "root";
1421
- if (shouldRunResolver) {
1422
- const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
1423
- if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
1424
- return { node: resolved, didChange: false };
1425
- }
1426
- const changed = getChanged(item, oldItem);
1427
- if (onResolveStart) {
1428
- onResolveStart(item);
1429
- }
1430
- const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
1431
- changed,
1432
- lastData: oldItem,
1433
- metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
1434
- trigger
1435
- });
1436
- resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
1437
- if (Object.keys(readOnly).length) {
1438
- resolvedItem.readOnly = readOnly;
1439
- }
1440
- }
1441
- let itemWithResolvedChildren = yield mapSlots(
1442
- resolvedItem,
1443
- (content) => __async(void 0, null, function* () {
1444
- return yield Promise.all(
1445
- content.map(
1446
- (childItem) => __async(void 0, null, function* () {
1447
- return (yield resolveComponentData(
1448
- childItem,
1449
- config,
1450
- metadata,
1451
- onResolveStart,
1452
- onResolveEnd,
1453
- trigger
1454
- )).node;
1455
- })
1456
- )
1457
- );
1458
- }),
1459
- config
1460
- );
1461
- if (shouldRunResolver && onResolveEnd) {
1462
- onResolveEnd(resolvedItem);
1463
- }
1464
- cache.lastChange[id] = {
1465
- item,
1466
- resolved: itemWithResolvedChildren
1467
- };
1468
- return {
1469
- node: itemWithResolvedChildren,
1470
- didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
1471
- };
1472
- });
1473
-
1474
- // lib/data/default-data.ts
1475
- init_react_import();
1476
- var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
1477
- root: data.root || {},
1478
- content: data.content || []
1479
- });
1480
-
1481
- // lib/data/to-component.ts
1482
- init_react_import();
1483
- var toComponent = (item) => {
1484
- return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
1485
- props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
1486
- type: "root"
1487
- });
1488
- };
1489
-
1490
- // lib/resolve-all-data.ts
1491
- function resolveAllData(_0, _1) {
1492
- return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
1493
- var _a;
1494
- const defaultedData = defaultData(data);
1495
- const resolveNode = (_node) => __async(this, null, function* () {
1496
- const node = toComponent(_node);
1497
- onResolveStart == null ? void 0 : onResolveStart(node);
1498
- const resolved = (yield resolveComponentData(
1499
- node,
1500
- config,
1501
- metadata,
1502
- () => {
1503
- },
1504
- () => {
1505
- },
1506
- "force"
1507
- )).node;
1508
- const resolvedDeep = yield mapSlots(
1509
- resolved,
1510
- processContent,
1511
- config
1512
- );
1513
- onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
1514
- return resolvedDeep;
1515
- });
1516
- const processContent = (content) => __async(this, null, function* () {
1517
- return Promise.all(content.map(resolveNode));
1518
- });
1519
- const processZones = () => __async(this, null, function* () {
1520
- var _a2;
1521
- const zones = (_a2 = data.zones) != null ? _a2 : {};
1522
- Object.entries(zones).forEach((_02) => __async(this, [_02], function* ([zoneKey, content]) {
1523
- zones[zoneKey] = yield Promise.all(content.map(resolveNode));
1524
- }));
1525
- return zones;
1526
- });
1527
- const dynamic = {
1528
- root: yield resolveNode(defaultedData.root),
1529
- content: yield processContent(defaultedData.content),
1530
- zones: yield processZones()
1531
- };
1532
- Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(this, null, function* () {
1533
- const content = defaultedData.zones[zoneKey];
1534
- dynamic.zones[zoneKey] = yield processContent(content);
1535
- }), {});
1536
- return dynamic;
1537
- });
1538
- }
1539
-
1540
- // lib/transform-props.ts
1541
- init_react_import();
1542
- function transformProps(data, propTransforms, config = { components: {} }) {
1543
- const mapItem = (item) => {
1544
- if (propTransforms[item.type]) {
1545
- return __spreadProps(__spreadValues({}, item), {
1546
- props: __spreadValues({
1547
- id: item.props.id
1548
- }, propTransforms[item.type](item.props))
1549
- });
1550
- }
1551
- return item;
1552
- };
1553
- const defaultedData = defaultData(data);
1554
- const rootProps = defaultedData.root.props || defaultedData.root;
1555
- let newRoot = __spreadValues({}, defaultedData.root);
1556
- if (propTransforms["root"]) {
1557
- newRoot.props = propTransforms["root"](rootProps);
1558
- }
1559
- const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
1560
- const updatedData = walkTree(
1561
- dataWithUpdatedRoot,
1562
- config,
1563
- (content) => content.map(mapItem)
1564
- );
1565
- if (!defaultedData.root.props) {
1566
- updatedData.root = updatedData.root.props;
1567
- }
1568
- return updatedData;
1569
- }
1570
-
1571
- // lib/migrate.ts
1572
- init_react_import();
1573
-
1574
- // store/default-app-state.ts
1575
- init_react_import();
1576
-
1577
- // components/ViewportControls/default-viewports.ts
1578
- init_react_import();
1579
- var defaultViewports = [
1580
- { width: 360, height: "auto", icon: "Smartphone", label: "Small" },
1581
- { width: 768, height: "auto", icon: "Tablet", label: "Medium" },
1582
- { width: 1280, height: "auto", icon: "Monitor", label: "Large" }
1583
- ];
1584
-
1585
- // store/default-app-state.ts
1586
- var defaultAppState = {
1587
- data: { content: [], root: {}, zones: {} },
1588
- ui: {
1589
- leftSideBarVisible: true,
1590
- rightSideBarVisible: true,
1591
- arrayState: {},
1592
- itemSelector: null,
1593
- componentList: {},
1594
- isDragging: false,
1595
- previewMode: "edit",
1596
- viewports: {
1597
- current: {
1598
- width: defaultViewports[0].width,
1599
- height: defaultViewports[0].height || "auto"
1600
- },
1601
- options: [],
1602
- controlsVisible: true
1603
- },
1604
- field: { focus: null }
1605
- },
1606
- indexes: {
1607
- nodes: {},
1608
- zones: {}
1609
- }
1610
- };
1611
-
1612
- // lib/migrate.ts
1613
- var migrations = [
1614
- // Migrate root to root.props
1615
- (data) => {
1616
- const rootProps = data.root.props || data.root;
1617
- if (Object.keys(data.root).length > 0 && !data.root.props) {
1618
- console.warn(
1619
- "Migration applied: Root props moved from `root` to `root.props`."
1620
- );
1621
- return __spreadProps(__spreadValues({}, data), {
1622
- root: {
1623
- props: __spreadValues({}, rootProps)
1624
- }
1625
- });
1626
- }
1627
- return data;
1628
- },
1629
- // Migrate zones to slots
1630
- (data, config) => {
1631
- var _a;
1632
- if (!config) return data;
1633
- console.log("Migrating DropZones to slots...");
1634
- const updatedItems = {};
1635
- const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
1636
- const { indexes } = walkAppState(appState, config);
1637
- const deletedCompounds = [];
1638
- walkAppState(appState, config, (content, zoneCompound, zoneType) => {
1639
- var _a2, _b, _c;
1640
- if (zoneType === "dropzone") {
1641
- const [id, slotName] = zoneCompound.split(":");
1642
- const nodeData = indexes.nodes[id].data;
1643
- const componentType = nodeData.type;
1644
- const configForComponent = id === "root" ? config.root : config.components[componentType];
1645
- if (((_b = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b.type) === "slot") {
1646
- updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
1647
- props: __spreadProps(__spreadValues(__spreadValues({}, nodeData.props), (_c = updatedItems[id]) == null ? void 0 : _c.props), {
1648
- [slotName]: content
1649
- })
1650
- });
1651
- deletedCompounds.push(zoneCompound);
1652
- }
1653
- return content;
1654
- }
1655
- return content;
1656
- });
1657
- const updated = walkAppState(
1658
- appState,
1659
- config,
1660
- (content) => content,
1661
- (item) => {
1662
- var _a2;
1663
- return (_a2 = updatedItems[item.props.id]) != null ? _a2 : item;
1664
- }
1665
- );
1666
- deletedCompounds.forEach((zoneCompound) => {
1667
- var _a2;
1668
- const [_, propName] = zoneCompound.split(":");
1669
- console.log(
1670
- `\u2713 Success: Migrated "${zoneCompound}" from DropZone to slot field "${propName}"`
1671
- );
1672
- (_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
1673
- });
1674
- Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
1675
- const [_, propName] = zoneCompound.split(":");
1676
- throw new Error(
1677
- `Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
1678
- );
1679
- });
1680
- delete updated.data.zones;
1681
- return updated.data;
1682
- }
1683
- ];
1684
- function migrate(data, config) {
1685
- return migrations == null ? void 0 : migrations.reduce(
1686
- (acc, migration) => migration(acc, config),
1687
- data
1688
- );
1689
- }
1690
-
1691
- // reducer/actions/replace.ts
1692
- var replaceAction = (state, action, appStore) => {
1693
- const [parentId] = action.destinationZone.split(":");
1694
- const idsInPath = getIdsForParent(action.destinationZone, state);
1695
- const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
1696
- const idChanged = originalId !== action.data.props.id;
1697
- if (idChanged) {
1698
- throw new Error(
1699
- `Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
1700
- );
1701
- }
1702
- const newSlotIds = [];
1703
- const data = walkTree(action.data, appStore.config, (contents, opts) => {
1704
- newSlotIds.push(`${opts.parentId}:${opts.propName}`);
1705
- return contents.map((item) => {
1706
- const id = generateId(item.type);
1707
- return __spreadProps(__spreadValues({}, item), {
1708
- props: __spreadValues({ id }, item.props)
1709
- });
1710
- });
1711
- });
1712
- const stateWithDeepSlotsRemoved = __spreadValues({}, state);
1713
- Object.keys(state.indexes.zones).forEach((zoneCompound) => {
1714
- const id = zoneCompound.split(":")[0];
1715
- if (id === originalId) {
1716
- if (!newSlotIds.includes(zoneCompound)) {
1717
- delete stateWithDeepSlotsRemoved.indexes.zones[zoneCompound];
1718
- }
1719
- }
1720
- });
1721
- return walkAppState(
1722
- stateWithDeepSlotsRemoved,
1723
- appStore.config,
1724
- (content, zoneCompound) => {
1725
- const newContent = [...content];
1726
- if (zoneCompound === action.destinationZone) {
1727
- newContent[action.destinationIndex] = data;
1728
- }
1729
- return newContent;
1730
- },
1731
- (childItem, path) => {
1732
- const pathIds = path.map((p) => p.split(":")[0]);
1733
- if (childItem.props.id === data.props.id) {
1734
- return data;
1735
- } else if (childItem.props.id === parentId) {
1736
- return childItem;
1737
- } else if (idsInPath.indexOf(childItem.props.id) > -1) {
1738
- return childItem;
1739
- } else if (pathIds.indexOf(data.props.id) > -1) {
1740
- return childItem;
1741
- }
1742
- return null;
1743
- }
1744
- );
1745
- };
1746
-
1747
- // reducer/actions/replace-root.ts
1748
- init_react_import();
1749
- var replaceRootAction = (state, action, appStore) => {
1750
- return walkAppState(
1751
- state,
1752
- appStore.config,
1753
- (content) => content,
1754
- (childItem) => {
1755
- if (childItem.props.id === "root") {
1756
- return __spreadProps(__spreadValues({}, childItem), {
1757
- props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
1758
- readOnly: action.root.readOnly
1759
- });
1760
- }
1761
- return childItem;
1762
- }
1763
- );
1764
- };
1765
-
1766
- // reducer/actions/duplicate.ts
1767
- init_react_import();
1768
-
1769
- // lib/data/get-item.ts
1770
- init_react_import();
1771
- function getItem(selector, state) {
1772
- var _a, _b;
1773
- const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
1774
- return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
1775
- }
1776
-
1777
- // reducer/actions/duplicate.ts
1778
- function duplicateAction(state, action, appStore) {
1779
- const item = getItem(
1780
- { index: action.sourceIndex, zone: action.sourceZone },
1781
- state
1782
- );
1783
- const idsInPath = getIdsForParent(action.sourceZone, state);
1784
- const newItem = __spreadProps(__spreadValues({}, item), {
1785
- props: __spreadProps(__spreadValues({}, item.props), {
1786
- id: generateId(item.type)
1787
- })
1788
- });
1789
- const modified = walkAppState(
1790
- state,
1791
- appStore.config,
1792
- (content, zoneCompound) => {
1793
- if (zoneCompound === action.sourceZone) {
1794
- return insert(content, action.sourceIndex + 1, item);
1795
- }
1796
- return content;
1797
- },
1798
- (childItem, path, index) => {
1799
- const zoneCompound = path[path.length - 1];
1800
- const parents = path.map((p) => p.split(":")[0]);
1801
- if (parents.indexOf(newItem.props.id) > -1) {
1802
- return __spreadProps(__spreadValues({}, childItem), {
1803
- props: __spreadProps(__spreadValues({}, childItem.props), {
1804
- id: generateId(childItem.type)
1805
- })
1806
- });
1807
- }
1808
- if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
1809
- return newItem;
1810
- }
1811
- const [sourceZoneParent] = action.sourceZone.split(":");
1812
- if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
1813
- return childItem;
1814
- }
1815
- return null;
1816
- }
1817
- );
1818
- return __spreadProps(__spreadValues({}, modified), {
1819
- ui: __spreadProps(__spreadValues({}, modified.ui), {
1820
- itemSelector: {
1821
- index: action.sourceIndex + 1,
1822
- zone: action.sourceZone
1823
- }
1824
- })
1825
- });
1826
- }
1827
-
1828
- // reducer/actions/reorder.ts
1829
- init_react_import();
1830
-
1831
- // reducer/actions/move.ts
1832
- init_react_import();
1833
-
1834
- // lib/data/remove.ts
1401
+ // lib/data/remove.ts
1835
1402
  init_react_import();
1836
1403
  var remove = (list, index) => {
1837
1404
  const result = Array.from(list);
@@ -1939,6 +1506,21 @@ var removeAction = (state, action, appStore) => {
1939
1506
 
1940
1507
  // reducer/actions/register-zone.ts
1941
1508
  init_react_import();
1509
+
1510
+ // lib/data/setup-zone.ts
1511
+ init_react_import();
1512
+ var setupZone = (data, zoneKey) => {
1513
+ if (zoneKey === rootDroppableId) {
1514
+ return data;
1515
+ }
1516
+ const newData = __spreadProps(__spreadValues({}, data), {
1517
+ zones: data.zones ? __spreadValues({}, data.zones) : {}
1518
+ });
1519
+ newData.zones[zoneKey] = newData.zones[zoneKey] || [];
1520
+ return newData;
1521
+ };
1522
+
1523
+ // reducer/actions/register-zone.ts
1942
1524
  var zoneCache = {};
1943
1525
  function registerZoneAction(state, action) {
1944
1526
  if (zoneCache[action.zone]) {
@@ -2091,18 +1673,26 @@ function createReducer({
2091
1673
  );
2092
1674
  }
2093
1675
 
1676
+ // components/ViewportControls/default-viewports.ts
1677
+ init_react_import();
1678
+ var defaultViewports = [
1679
+ { width: 360, height: "auto", icon: "Smartphone", label: "Small" },
1680
+ { width: 768, height: "auto", icon: "Tablet", label: "Medium" },
1681
+ { width: 1280, height: "auto", icon: "Monitor", label: "Large" }
1682
+ ];
1683
+
2094
1684
  // store/index.ts
2095
1685
  var import_zustand2 = require("zustand");
2096
1686
  var import_middleware2 = require("zustand/middleware");
2097
- var import_react11 = require("react");
1687
+ var import_react9 = require("react");
2098
1688
 
2099
1689
  // store/slices/history.ts
2100
1690
  init_react_import();
2101
- var import_react8 = require("react");
1691
+ var import_react6 = require("react");
2102
1692
 
2103
1693
  // lib/use-hotkey.ts
2104
1694
  init_react_import();
2105
- var import_react7 = require("react");
1695
+ var import_react5 = require("react");
2106
1696
  var import_zustand = require("zustand");
2107
1697
  var import_middleware = require("zustand/middleware");
2108
1698
  var keyCodeMap = {
@@ -2195,10 +1785,10 @@ var monitorHotkeys = (doc) => {
2195
1785
  };
2196
1786
  };
2197
1787
  var useMonitorHotkeys = () => {
2198
- (0, import_react7.useEffect)(() => monitorHotkeys(document), []);
1788
+ (0, import_react5.useEffect)(() => monitorHotkeys(document), []);
2199
1789
  };
2200
1790
  var useHotkey = (combo, cb) => {
2201
- (0, import_react7.useEffect)(
1791
+ (0, import_react5.useEffect)(
2202
1792
  () => useHotkeyStore.setState((s) => ({
2203
1793
  triggers: __spreadProps(__spreadValues({}, s.triggers), {
2204
1794
  [`${Object.keys(combo).join("+")}`]: { combo, cb }
@@ -2307,7 +1897,7 @@ function useRegisterHistorySlice(appStore, {
2307
1897
  index,
2308
1898
  initialAppState
2309
1899
  }) {
2310
- (0, import_react8.useEffect)(
1900
+ (0, import_react6.useEffect)(
2311
1901
  () => appStore.setState({
2312
1902
  history: __spreadProps(__spreadValues({}, appStore.getState().history), {
2313
1903
  histories,
@@ -2374,7 +1964,7 @@ var createNodesSlice = (set, get) => ({
2374
1964
 
2375
1965
  // store/slices/permissions.ts
2376
1966
  init_react_import();
2377
- var import_react9 = require("react");
1967
+ var import_react7 = require("react");
2378
1968
 
2379
1969
  // lib/data/flatten-data.ts
2380
1970
  init_react_import();
@@ -2392,6 +1982,19 @@ var flattenData = (state, config) => {
2392
1982
  return data;
2393
1983
  };
2394
1984
 
1985
+ // lib/get-changed.ts
1986
+ init_react_import();
1987
+ var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
1988
+ var getChanged = (newItem, oldItem) => {
1989
+ return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
1990
+ const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
1991
+ const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
1992
+ return __spreadProps(__spreadValues({}, acc), {
1993
+ [item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
1994
+ });
1995
+ }, {}) : {};
1996
+ };
1997
+
2395
1998
  // store/slices/permissions.ts
2396
1999
  var createPermissionsSlice = (set, get) => {
2397
2000
  const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
@@ -2498,7 +2101,7 @@ var createPermissionsSlice = (set, get) => {
2498
2101
  };
2499
2102
  };
2500
2103
  var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
2501
- (0, import_react9.useEffect)(() => {
2104
+ (0, import_react7.useEffect)(() => {
2502
2105
  const { permissions } = appStore.getState();
2503
2106
  const { globalPermissions: existingGlobalPermissions } = permissions;
2504
2107
  appStore.setState({
@@ -2508,7 +2111,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
2508
2111
  });
2509
2112
  permissions.resolvePermissions();
2510
2113
  }, [globalPermissions]);
2511
- (0, import_react9.useEffect)(() => {
2114
+ (0, import_react7.useEffect)(() => {
2512
2115
  return appStore.subscribe(
2513
2116
  (s) => s.state.data,
2514
2117
  () => {
@@ -2516,7 +2119,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
2516
2119
  }
2517
2120
  );
2518
2121
  }, []);
2519
- (0, import_react9.useEffect)(() => {
2122
+ (0, import_react7.useEffect)(() => {
2520
2123
  return appStore.subscribe(
2521
2124
  (s) => s.config,
2522
2125
  () => {
@@ -2528,7 +2131,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
2528
2131
 
2529
2132
  // store/slices/fields.ts
2530
2133
  init_react_import();
2531
- var import_react10 = require("react");
2134
+ var import_react8 = require("react");
2532
2135
  var createFieldsSlice = (_set, _get) => {
2533
2136
  return {
2534
2137
  fields: {},
@@ -2538,7 +2141,7 @@ var createFieldsSlice = (_set, _get) => {
2538
2141
  };
2539
2142
  };
2540
2143
  var useRegisterFieldsSlice = (appStore, id) => {
2541
- const resolveFields = (0, import_react10.useCallback)(
2144
+ const resolveFields = (0, import_react8.useCallback)(
2542
2145
  (reset) => __async(void 0, null, function* () {
2543
2146
  var _a, _b;
2544
2147
  const { fields, lastResolvedData } = appStore.getState().fields;
@@ -2595,7 +2198,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
2595
2198
  }),
2596
2199
  [id]
2597
2200
  );
2598
- (0, import_react10.useEffect)(() => {
2201
+ (0, import_react8.useEffect)(() => {
2599
2202
  resolveFields(true);
2600
2203
  return appStore.subscribe(
2601
2204
  (s) => s.state.indexes.nodes[id || "root"],
@@ -2604,6 +2207,68 @@ var useRegisterFieldsSlice = (appStore, id) => {
2604
2207
  }, [id]);
2605
2208
  };
2606
2209
 
2210
+ // lib/resolve-component-data.ts
2211
+ init_react_import();
2212
+ var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"));
2213
+ var cache = { lastChange: {} };
2214
+ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
2215
+ const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
2216
+ const resolvedItem = __spreadValues({}, item);
2217
+ const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
2218
+ const id = "id" in item.props ? item.props.id : "root";
2219
+ if (shouldRunResolver) {
2220
+ const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
2221
+ if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
2222
+ return { node: resolved, didChange: false };
2223
+ }
2224
+ const changed = getChanged(item, oldItem);
2225
+ if (onResolveStart) {
2226
+ onResolveStart(item);
2227
+ }
2228
+ const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
2229
+ changed,
2230
+ lastData: oldItem,
2231
+ metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
2232
+ trigger
2233
+ });
2234
+ resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
2235
+ if (Object.keys(readOnly).length) {
2236
+ resolvedItem.readOnly = readOnly;
2237
+ }
2238
+ }
2239
+ let itemWithResolvedChildren = yield mapSlots(
2240
+ resolvedItem,
2241
+ (content) => __async(void 0, null, function* () {
2242
+ return yield Promise.all(
2243
+ content.map(
2244
+ (childItem) => __async(void 0, null, function* () {
2245
+ return (yield resolveComponentData(
2246
+ childItem,
2247
+ config,
2248
+ metadata,
2249
+ onResolveStart,
2250
+ onResolveEnd,
2251
+ trigger
2252
+ )).node;
2253
+ })
2254
+ )
2255
+ );
2256
+ }),
2257
+ config
2258
+ );
2259
+ if (shouldRunResolver && onResolveEnd) {
2260
+ onResolveEnd(resolvedItem);
2261
+ }
2262
+ cache.lastChange[id] = {
2263
+ item,
2264
+ resolved: itemWithResolvedChildren
2265
+ };
2266
+ return {
2267
+ node: itemWithResolvedChildren,
2268
+ didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
2269
+ };
2270
+ });
2271
+
2607
2272
  // lib/data/to-root.ts
2608
2273
  init_react_import();
2609
2274
  var toRoot = (item) => {
@@ -2621,6 +2286,34 @@ var toRoot = (item) => {
2621
2286
  return { props: {}, readOnly };
2622
2287
  };
2623
2288
 
2289
+ // store/default-app-state.ts
2290
+ init_react_import();
2291
+ var defaultAppState = {
2292
+ data: { content: [], root: {}, zones: {} },
2293
+ ui: {
2294
+ leftSideBarVisible: true,
2295
+ rightSideBarVisible: true,
2296
+ arrayState: {},
2297
+ itemSelector: null,
2298
+ componentList: {},
2299
+ isDragging: false,
2300
+ previewMode: "edit",
2301
+ viewports: {
2302
+ current: {
2303
+ width: defaultViewports[0].width,
2304
+ height: defaultViewports[0].height || "auto"
2305
+ },
2306
+ options: [],
2307
+ controlsVisible: true
2308
+ },
2309
+ field: { focus: null }
2310
+ },
2311
+ indexes: {
2312
+ nodes: {},
2313
+ zones: {}
2314
+ }
2315
+ };
2316
+
2624
2317
  // store/index.ts
2625
2318
  var defaultPageFields = {
2626
2319
  title: { type: "text" }
@@ -2797,23 +2490,23 @@ var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
2797
2490
  });
2798
2491
  })
2799
2492
  );
2800
- var appStoreContext = (0, import_react11.createContext)(createAppStore());
2493
+ var appStoreContext = (0, import_react9.createContext)(createAppStore());
2801
2494
  function useAppStore(selector) {
2802
- const context = (0, import_react11.useContext)(appStoreContext);
2495
+ const context = (0, import_react9.useContext)(appStoreContext);
2803
2496
  return (0, import_zustand2.useStore)(context, selector);
2804
2497
  }
2805
2498
  function useAppStoreApi() {
2806
- return (0, import_react11.useContext)(appStoreContext);
2499
+ return (0, import_react9.useContext)(appStoreContext);
2807
2500
  }
2808
2501
 
2809
2502
  // components/Sortable/index.tsx
2810
2503
  init_react_import();
2811
- var import_react14 = require("@dnd-kit/react");
2504
+ var import_react12 = require("@dnd-kit/react");
2812
2505
 
2813
2506
  // lib/dnd/use-sensors.ts
2814
2507
  init_react_import();
2815
- var import_react12 = require("react");
2816
- var import_react13 = require("@dnd-kit/react");
2508
+ var import_react10 = require("react");
2509
+ var import_react11 = require("@dnd-kit/react");
2817
2510
  var import_utilities = require("@dnd-kit/dom/utilities");
2818
2511
  var touchDefault = { delay: { value: 200, tolerance: 10 } };
2819
2512
  var otherDefault = {
@@ -2828,8 +2521,8 @@ var useSensors = ({
2828
2521
  touch: touchDefault,
2829
2522
  other: otherDefault
2830
2523
  }) => {
2831
- const [sensors] = (0, import_react12.useState)(() => [
2832
- import_react13.PointerSensor.configure({
2524
+ const [sensors] = (0, import_react10.useState)(() => [
2525
+ import_react11.PointerSensor.configure({
2833
2526
  activationConstraints(event, source) {
2834
2527
  var _a;
2835
2528
  const { pointerType, target } = event;
@@ -3164,7 +2857,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
3164
2857
 
3165
2858
  // components/Sortable/index.tsx
3166
2859
  var import_sortable = require("@dnd-kit/react/sortable");
3167
- var import_jsx_runtime7 = require("react/jsx-runtime");
2860
+ var import_jsx_runtime5 = require("react/jsx-runtime");
3168
2861
  var SortableProvider = ({
3169
2862
  children,
3170
2863
  onDragStart,
@@ -3174,8 +2867,8 @@ var SortableProvider = ({
3174
2867
  const sensors = useSensors({
3175
2868
  mouse: { distance: { value: 5 } }
3176
2869
  });
3177
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3178
- import_react14.DragDropProvider,
2870
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2871
+ import_react12.DragDropProvider,
3179
2872
  {
3180
2873
  sensors,
3181
2874
  onDragStart: (event) => {
@@ -3239,11 +2932,11 @@ var Sortable = ({
3239
2932
 
3240
2933
  // components/AutoField/context.tsx
3241
2934
  init_react_import();
3242
- var import_react15 = require("react");
3243
- var import_jsx_runtime8 = require("react/jsx-runtime");
3244
- var NestedFieldContext = (0, import_react15.createContext)({});
2935
+ var import_react13 = require("react");
2936
+ var import_jsx_runtime6 = require("react/jsx-runtime");
2937
+ var NestedFieldContext = (0, import_react13.createContext)({});
3245
2938
  var useNestedFieldContext = () => {
3246
- const context = (0, import_react15.useContext)(NestedFieldContext);
2939
+ const context = (0, import_react13.useContext)(NestedFieldContext);
3247
2940
  return __spreadProps(__spreadValues({}, context), {
3248
2941
  readOnlyFields: context.readOnlyFields || {}
3249
2942
  });
@@ -3257,7 +2950,7 @@ var NestedFieldProvider = ({
3257
2950
  }) => {
3258
2951
  const subPath = `${name}.${subName}`;
3259
2952
  const wildcardSubPath = `${wildcardName}.${subName}`;
3260
- const subReadOnlyFields = (0, import_react15.useMemo)(
2953
+ const subReadOnlyFields = (0, import_react13.useMemo)(
3261
2954
  () => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
3262
2955
  const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
3263
2956
  if (isLocal) {
@@ -3273,7 +2966,7 @@ var NestedFieldProvider = ({
3273
2966
  }, {}),
3274
2967
  [name, subName, wildcardName, readOnlyFields]
3275
2968
  );
3276
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2969
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3277
2970
  NestedFieldContext.Provider,
3278
2971
  {
3279
2972
  value: { readOnlyFields: subReadOnlyFields, localName: subName },
@@ -3283,7 +2976,7 @@ var NestedFieldProvider = ({
3283
2976
  };
3284
2977
 
3285
2978
  // components/AutoField/fields/ArrayField/index.tsx
3286
- var import_jsx_runtime9 = require("react/jsx-runtime");
2979
+ var import_jsx_runtime7 = require("react/jsx-runtime");
3287
2980
  var getClassName5 = get_class_name_factory_default("ArrayField", styles_module_default3);
3288
2981
  var getClassNameItem = get_class_name_factory_default("ArrayFieldItem", styles_module_default3);
3289
2982
  var ArrayField = ({
@@ -3295,7 +2988,7 @@ var ArrayField = ({
3295
2988
  labelIcon,
3296
2989
  readOnly,
3297
2990
  id,
3298
- Label: Label2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", __spreadValues({}, props))
2991
+ Label: Label2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", __spreadValues({}, props))
3299
2992
  }) => {
3300
2993
  const thisArrayState = useAppStore((s) => s.state.ui.arrayState[id]);
3301
2994
  const setUi = useAppStore((s) => s.setUi);
@@ -3310,14 +3003,14 @@ var ArrayField = ({
3310
3003
  }),
3311
3004
  openId: ""
3312
3005
  };
3313
- const [localState, setLocalState] = (0, import_react16.useState)({ arrayState, value });
3314
- (0, import_react16.useEffect)(() => {
3006
+ const [localState, setLocalState] = (0, import_react14.useState)({ arrayState, value });
3007
+ (0, import_react14.useEffect)(() => {
3315
3008
  var _a;
3316
3009
  const _arrayState = (_a = appStore.getState().state.ui.arrayState[id]) != null ? _a : arrayState;
3317
3010
  setLocalState({ arrayState: _arrayState, value });
3318
3011
  }, [value]);
3319
3012
  const appStore = useAppStoreApi();
3320
- const mapArrayStateToUi = (0, import_react16.useCallback)(
3013
+ const mapArrayStateToUi = (0, import_react14.useCallback)(
3321
3014
  (partialArrayState) => {
3322
3015
  const state = appStore.getState().state;
3323
3016
  return {
@@ -3328,13 +3021,13 @@ var ArrayField = ({
3328
3021
  },
3329
3022
  [arrayState, appStore]
3330
3023
  );
3331
- const getHighestIndex = (0, import_react16.useCallback)(() => {
3024
+ const getHighestIndex = (0, import_react14.useCallback)(() => {
3332
3025
  return arrayState.items.reduce(
3333
3026
  (acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
3334
3027
  -1
3335
3028
  );
3336
3029
  }, [arrayState]);
3337
- const regenerateArrayState = (0, import_react16.useCallback)(
3030
+ const regenerateArrayState = (0, import_react14.useCallback)(
3338
3031
  (value2) => {
3339
3032
  let highestIndex = getHighestIndex();
3340
3033
  const newItems = Array.from(value2 || []).map((item, idx) => {
@@ -3353,19 +3046,19 @@ var ArrayField = ({
3353
3046
  },
3354
3047
  [arrayState]
3355
3048
  );
3356
- (0, import_react16.useEffect)(() => {
3049
+ (0, import_react14.useEffect)(() => {
3357
3050
  if (arrayState.items.length > 0) {
3358
3051
  setUi(mapArrayStateToUi(arrayState));
3359
3052
  }
3360
3053
  }, []);
3361
- const [draggedItem, setDraggedItem] = (0, import_react16.useState)("");
3054
+ const [draggedItem, setDraggedItem] = (0, import_react14.useState)("");
3362
3055
  const isDraggingAny = !!draggedItem;
3363
3056
  const canEdit = useAppStore(
3364
3057
  (s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
3365
3058
  );
3366
3059
  const forceReadOnly = !canEdit;
3367
- const valueRef = (0, import_react16.useRef)(value);
3368
- const uniqifyItem = (0, import_react16.useCallback)(
3060
+ const valueRef = (0, import_react14.useRef)(value);
3061
+ const uniqifyItem = (0, import_react14.useCallback)(
3369
3062
  (val) => {
3370
3063
  if (field.type !== "array" || !field.arrayFields) return;
3371
3064
  const config = appStore.getState().config;
@@ -3382,14 +3075,14 @@ var ArrayField = ({
3382
3075
  return null;
3383
3076
  }
3384
3077
  const addDisabled = field.max !== void 0 && localState.arrayState.items.length >= field.max || readOnly;
3385
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3078
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3386
3079
  Label2,
3387
3080
  {
3388
3081
  label: label || name,
3389
- icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(List, { size: 16 }),
3082
+ icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(List, { size: 16 }),
3390
3083
  el: "div",
3391
3084
  readOnly,
3392
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3085
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3393
3086
  SortableProvider,
3394
3087
  {
3395
3088
  onDragStart: (id2) => setDraggedItem(id2),
@@ -3420,7 +3113,7 @@ var ArrayField = ({
3420
3113
  });
3421
3114
  valueRef.current = newValue;
3422
3115
  },
3423
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3116
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3424
3117
  "div",
3425
3118
  {
3426
3119
  className: getClassName5({
@@ -3428,16 +3121,16 @@ var ArrayField = ({
3428
3121
  addDisabled
3429
3122
  }),
3430
3123
  children: [
3431
- localState.arrayState.items.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassName5("inner"), "data-dnd-container": true, children: localState.arrayState.items.map((item, i) => {
3124
+ localState.arrayState.items.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName5("inner"), "data-dnd-container": true, children: localState.arrayState.items.map((item, i) => {
3432
3125
  const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
3433
3126
  const data = Array.from(localState.value || [])[i] || {};
3434
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3127
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3435
3128
  Sortable,
3436
3129
  {
3437
3130
  id: _arrayId,
3438
3131
  index: i,
3439
3132
  disabled: readOnly,
3440
- children: ({ isDragging, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3133
+ children: ({ isDragging, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3441
3134
  "div",
3442
3135
  {
3443
3136
  ref,
@@ -3447,7 +3140,7 @@ var ArrayField = ({
3447
3140
  readOnly
3448
3141
  }),
3449
3142
  children: [
3450
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3143
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3451
3144
  "div",
3452
3145
  {
3453
3146
  ref: handleRef,
@@ -3472,9 +3165,9 @@ var ArrayField = ({
3472
3165
  className: getClassNameItem("summary"),
3473
3166
  children: [
3474
3167
  field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
3475
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: getClassNameItem("rhs"), children: [
3476
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: getClassNameItem("actions"), children: [
3477
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3168
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassNameItem("rhs"), children: [
3169
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassNameItem("actions"), children: [
3170
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3478
3171
  IconButton,
3479
3172
  {
3480
3173
  type: "button",
@@ -3493,10 +3186,10 @@ var ArrayField = ({
3493
3186
  onChange(existingValue);
3494
3187
  },
3495
3188
  title: "Duplicate",
3496
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Copy, { size: 16 })
3189
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Copy, { size: 16 })
3497
3190
  }
3498
3191
  ) }),
3499
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3192
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3500
3193
  IconButton,
3501
3194
  {
3502
3195
  type: "button",
@@ -3518,16 +3211,16 @@ var ArrayField = ({
3518
3211
  onChange(existingValue);
3519
3212
  },
3520
3213
  title: "Delete",
3521
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Trash, { size: 16 })
3214
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Trash, { size: 16 })
3522
3215
  }
3523
3216
  ) })
3524
3217
  ] }),
3525
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DragIcon, {}) })
3218
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DragIcon, {}) })
3526
3219
  ] })
3527
3220
  ]
3528
3221
  }
3529
3222
  ),
3530
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((subName) => {
3223
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((subName) => {
3531
3224
  const subField = field.arrayFields[subName];
3532
3225
  const indexName = `${name}[${i}]`;
3533
3226
  const subPath = `${indexName}.${subName}`;
@@ -3537,14 +3230,14 @@ var ArrayField = ({
3537
3230
  const localWildcardSubPath = `${localWildcardName}.${subName}`;
3538
3231
  const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
3539
3232
  const label2 = subField.label || subName;
3540
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3233
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3541
3234
  NestedFieldProvider,
3542
3235
  {
3543
3236
  name: localIndexName,
3544
3237
  wildcardName: localWildcardName,
3545
3238
  subName,
3546
3239
  readOnlyFields,
3547
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3240
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3548
3241
  AutoFieldPrivate,
3549
3242
  {
3550
3243
  name: subPath,
@@ -3577,7 +3270,7 @@ var ArrayField = ({
3577
3270
  _arrayId
3578
3271
  );
3579
3272
  }) }),
3580
- !addDisabled && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3273
+ !addDisabled && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3581
3274
  "button",
3582
3275
  {
3583
3276
  type: "button",
@@ -3595,7 +3288,7 @@ var ArrayField = ({
3595
3288
  setUi(mapArrayStateToUi(newArrayState), false);
3596
3289
  onChange(newValue);
3597
3290
  },
3598
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Plus, { size: 21 })
3291
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Plus, { size: 21 })
3599
3292
  }
3600
3293
  )
3601
3294
  ]
@@ -3609,7 +3302,7 @@ var ArrayField = ({
3609
3302
 
3610
3303
  // components/AutoField/fields/DefaultField/index.tsx
3611
3304
  init_react_import();
3612
- var import_jsx_runtime10 = require("react/jsx-runtime");
3305
+ var import_jsx_runtime8 = require("react/jsx-runtime");
3613
3306
  var getClassName6 = get_class_name_factory_default("Input", styles_module_default2);
3614
3307
  var DefaultField = ({
3615
3308
  field,
@@ -3623,16 +3316,16 @@ var DefaultField = ({
3623
3316
  id
3624
3317
  }) => {
3625
3318
  const value = _value;
3626
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
3319
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3627
3320
  Label2,
3628
3321
  {
3629
3322
  label: label || name,
3630
- icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
3631
- field.type === "text" && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Type, { size: 16 }),
3632
- field.type === "number" && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Hash, { size: 16 })
3323
+ icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
3324
+ field.type === "text" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Type, { size: 16 }),
3325
+ field.type === "number" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Hash, { size: 16 })
3633
3326
  ] }),
3634
3327
  readOnly,
3635
- children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
3328
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3636
3329
  "input",
3637
3330
  {
3638
3331
  className: getClassName6("input"),
@@ -3670,11 +3363,11 @@ var DefaultField = ({
3670
3363
 
3671
3364
  // components/AutoField/fields/ExternalField/index.tsx
3672
3365
  init_react_import();
3673
- var import_react20 = require("react");
3366
+ var import_react18 = require("react");
3674
3367
 
3675
3368
  // components/ExternalInput/index.tsx
3676
3369
  init_react_import();
3677
- var import_react19 = require("react");
3370
+ var import_react17 = require("react");
3678
3371
 
3679
3372
  // css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
3680
3373
  init_react_import();
@@ -3682,7 +3375,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
3682
3375
 
3683
3376
  // components/Modal/index.tsx
3684
3377
  init_react_import();
3685
- var import_react17 = require("react");
3378
+ var import_react15 = require("react");
3686
3379
 
3687
3380
  // css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
3688
3381
  init_react_import();
@@ -3690,22 +3383,22 @@ var styles_module_default7 = { "Modal": "_Modal_ikbaj_1", "Modal--isOpen": "_Mod
3690
3383
 
3691
3384
  // components/Modal/index.tsx
3692
3385
  var import_react_dom = require("react-dom");
3693
- var import_jsx_runtime11 = require("react/jsx-runtime");
3386
+ var import_jsx_runtime9 = require("react/jsx-runtime");
3694
3387
  var getClassName7 = get_class_name_factory_default("Modal", styles_module_default7);
3695
3388
  var Modal = ({
3696
3389
  children,
3697
3390
  onClose,
3698
3391
  isOpen
3699
3392
  }) => {
3700
- const [rootEl, setRootEl] = (0, import_react17.useState)(null);
3701
- (0, import_react17.useEffect)(() => {
3393
+ const [rootEl, setRootEl] = (0, import_react15.useState)(null);
3394
+ (0, import_react15.useEffect)(() => {
3702
3395
  setRootEl(document.getElementById("puck-portal-root"));
3703
3396
  }, []);
3704
3397
  if (!rootEl) {
3705
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", {});
3398
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", {});
3706
3399
  }
3707
3400
  return (0, import_react_dom.createPortal)(
3708
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3401
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3709
3402
  "div",
3710
3403
  {
3711
3404
  className: getClassName7("inner"),
@@ -3725,11 +3418,11 @@ init_react_import();
3725
3418
  var styles_module_default8 = { "Heading": "_Heading_qxrry_1", "Heading--xxxxl": "_Heading--xxxxl_qxrry_12", "Heading--xxxl": "_Heading--xxxl_qxrry_18", "Heading--xxl": "_Heading--xxl_qxrry_22", "Heading--xl": "_Heading--xl_qxrry_26", "Heading--l": "_Heading--l_qxrry_30", "Heading--m": "_Heading--m_qxrry_34", "Heading--s": "_Heading--s_qxrry_38", "Heading--xs": "_Heading--xs_qxrry_42" };
3726
3419
 
3727
3420
  // components/Heading/index.tsx
3728
- var import_jsx_runtime12 = require("react/jsx-runtime");
3421
+ var import_jsx_runtime10 = require("react/jsx-runtime");
3729
3422
  var getClassName8 = get_class_name_factory_default("Heading", styles_module_default8);
3730
3423
  var Heading = ({ children, rank, size = "m" }) => {
3731
3424
  const Tag = rank ? `h${rank}` : "span";
3732
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3425
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
3733
3426
  Tag,
3734
3427
  {
3735
3428
  className: getClassName8({
@@ -3745,7 +3438,7 @@ init_react_import();
3745
3438
 
3746
3439
  // components/Button/Button.tsx
3747
3440
  init_react_import();
3748
- var import_react18 = require("react");
3441
+ var import_react16 = require("react");
3749
3442
 
3750
3443
  // css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
3751
3444
  init_react_import();
@@ -3765,7 +3458,7 @@ var filterDataAttrs = (props) => {
3765
3458
  };
3766
3459
 
3767
3460
  // components/Button/Button.tsx
3768
- var import_jsx_runtime13 = require("react/jsx-runtime");
3461
+ var import_jsx_runtime11 = require("react/jsx-runtime");
3769
3462
  var getClassName9 = get_class_name_factory_default("Button", Button_module_default);
3770
3463
  var Button = (_a) => {
3771
3464
  var _b = _a, {
@@ -3795,11 +3488,11 @@ var Button = (_a) => {
3795
3488
  "size",
3796
3489
  "loading"
3797
3490
  ]);
3798
- const [loading, setLoading] = (0, import_react18.useState)(loadingProp);
3799
- (0, import_react18.useEffect)(() => setLoading(loadingProp), [loadingProp]);
3491
+ const [loading, setLoading] = (0, import_react16.useState)(loadingProp);
3492
+ (0, import_react16.useEffect)(() => setLoading(loadingProp), [loadingProp]);
3800
3493
  const ElementType = href ? "a" : type ? "button" : "span";
3801
3494
  const dataAttrs = filterDataAttrs(props);
3802
- const el = /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
3495
+ const el = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
3803
3496
  ElementType,
3804
3497
  __spreadProps(__spreadValues({
3805
3498
  className: getClassName9({
@@ -3824,9 +3517,9 @@ var Button = (_a) => {
3824
3517
  href
3825
3518
  }, dataAttrs), {
3826
3519
  children: [
3827
- icon && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassName9("icon"), children: icon }),
3520
+ icon && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName9("icon"), children: icon }),
3828
3521
  children,
3829
- loading && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Loader, { size: 14 }) })
3522
+ loading && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Loader, { size: 14 }) })
3830
3523
  ]
3831
3524
  })
3832
3525
  );
@@ -3834,7 +3527,7 @@ var Button = (_a) => {
3834
3527
  };
3835
3528
 
3836
3529
  // components/ExternalInput/index.tsx
3837
- var import_jsx_runtime14 = require("react/jsx-runtime");
3530
+ var import_jsx_runtime12 = require("react/jsx-runtime");
3838
3531
  var getClassName10 = get_class_name_factory_default("ExternalInput", styles_module_default6);
3839
3532
  var getClassNameModal = get_class_name_factory_default("ExternalInputModal", styles_module_default6);
3840
3533
  var dataCache = {};
@@ -3851,28 +3544,28 @@ var ExternalInput = ({
3851
3544
  mapRow = (val) => val,
3852
3545
  filterFields
3853
3546
  } = field || {};
3854
- const [data, setData] = (0, import_react19.useState)([]);
3855
- const [isOpen, setOpen] = (0, import_react19.useState)(false);
3856
- const [isLoading, setIsLoading] = (0, import_react19.useState)(true);
3547
+ const [data, setData] = (0, import_react17.useState)([]);
3548
+ const [isOpen, setOpen] = (0, import_react17.useState)(false);
3549
+ const [isLoading, setIsLoading] = (0, import_react17.useState)(true);
3857
3550
  const hasFilterFields = !!filterFields;
3858
- const [filters, setFilters] = (0, import_react19.useState)(field.initialFilters || {});
3859
- const [filtersToggled, setFiltersToggled] = (0, import_react19.useState)(hasFilterFields);
3860
- const mappedData = (0, import_react19.useMemo)(() => {
3551
+ const [filters, setFilters] = (0, import_react17.useState)(field.initialFilters || {});
3552
+ const [filtersToggled, setFiltersToggled] = (0, import_react17.useState)(hasFilterFields);
3553
+ const mappedData = (0, import_react17.useMemo)(() => {
3861
3554
  return data.map(mapRow);
3862
3555
  }, [data]);
3863
- const keys = (0, import_react19.useMemo)(() => {
3556
+ const keys = (0, import_react17.useMemo)(() => {
3864
3557
  const validKeys = /* @__PURE__ */ new Set();
3865
3558
  for (const item of mappedData) {
3866
3559
  for (const key of Object.keys(item)) {
3867
- if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react19.isValidElement)(item[key])) {
3560
+ if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react17.isValidElement)(item[key])) {
3868
3561
  validKeys.add(key);
3869
3562
  }
3870
3563
  }
3871
3564
  }
3872
3565
  return Array.from(validKeys);
3873
3566
  }, [mappedData]);
3874
- const [searchQuery, setSearchQuery] = (0, import_react19.useState)(field.initialQuery || "");
3875
- const search = (0, import_react19.useCallback)(
3567
+ const [searchQuery, setSearchQuery] = (0, import_react17.useState)(field.initialQuery || "");
3568
+ const search = (0, import_react17.useCallback)(
3876
3569
  (query, filters2) => __async(void 0, null, function* () {
3877
3570
  setIsLoading(true);
3878
3571
  const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
@@ -3885,18 +3578,18 @@ var ExternalInput = ({
3885
3578
  }),
3886
3579
  [id, field]
3887
3580
  );
3888
- const Footer = (0, import_react19.useCallback)(
3889
- (props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: getClassNameModal("footer"), children: [
3581
+ const Footer = (0, import_react17.useCallback)(
3582
+ (props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: getClassNameModal("footer"), children: [
3890
3583
  props.items.length,
3891
3584
  " result",
3892
3585
  props.items.length === 1 ? "" : "s"
3893
3586
  ] }),
3894
3587
  [field.renderFooter]
3895
3588
  );
3896
- (0, import_react19.useEffect)(() => {
3589
+ (0, import_react17.useEffect)(() => {
3897
3590
  search(searchQuery, filters);
3898
3591
  }, []);
3899
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
3592
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
3900
3593
  "div",
3901
3594
  {
3902
3595
  className: getClassName10({
@@ -3906,21 +3599,21 @@ var ExternalInput = ({
3906
3599
  }),
3907
3600
  id,
3908
3601
  children: [
3909
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: getClassName10("actions"), children: [
3910
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3602
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassName10("actions"), children: [
3603
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3911
3604
  "button",
3912
3605
  {
3913
3606
  type: "button",
3914
3607
  onClick: () => setOpen(true),
3915
3608
  className: getClassName10("button"),
3916
3609
  disabled: readOnly,
3917
- children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
3918
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Link, { size: "16" }),
3919
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: field.placeholder })
3610
+ children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
3611
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Link, { size: "16" }),
3612
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: field.placeholder })
3920
3613
  ] })
3921
3614
  }
3922
3615
  ),
3923
- value && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3616
+ value && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3924
3617
  "button",
3925
3618
  {
3926
3619
  type: "button",
@@ -3929,11 +3622,11 @@ var ExternalInput = ({
3929
3622
  onChange(null);
3930
3623
  },
3931
3624
  disabled: readOnly,
3932
- children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(LockOpen, { size: 16 })
3625
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(LockOpen, { size: 16 })
3933
3626
  }
3934
3627
  )
3935
3628
  ] }),
3936
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
3629
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
3937
3630
  "form",
3938
3631
  {
3939
3632
  className: getClassNameModal({
@@ -3947,11 +3640,11 @@ var ExternalInput = ({
3947
3640
  search(searchQuery, filters);
3948
3641
  },
3949
3642
  children: [
3950
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: getClassNameModal("searchForm"), children: [
3951
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: getClassNameModal("search"), children: [
3952
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
3953
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Search, { size: "18" }) }),
3954
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3643
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassNameModal("searchForm"), children: [
3644
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: getClassNameModal("search"), children: [
3645
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
3646
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Search, { size: "18" }) }),
3647
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3955
3648
  "input",
3956
3649
  {
3957
3650
  className: getClassNameModal("searchInput"),
@@ -3966,9 +3659,9 @@ var ExternalInput = ({
3966
3659
  }
3967
3660
  )
3968
3661
  ] }),
3969
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: getClassNameModal("searchActions"), children: [
3970
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
3971
- hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3662
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassNameModal("searchActions"), children: [
3663
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
3664
+ hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3972
3665
  IconButton,
3973
3666
  {
3974
3667
  type: "button",
@@ -3978,19 +3671,19 @@ var ExternalInput = ({
3978
3671
  e.stopPropagation();
3979
3672
  setFiltersToggled(!filtersToggled);
3980
3673
  },
3981
- children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SlidersHorizontal, { size: 20 })
3674
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(SlidersHorizontal, { size: 20 })
3982
3675
  }
3983
3676
  ) })
3984
3677
  ] })
3985
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
3986
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: getClassNameModal("grid"), children: [
3987
- hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
3678
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
3679
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassNameModal("grid"), children: [
3680
+ hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
3988
3681
  const filterField = filterFields[fieldName];
3989
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3682
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3990
3683
  "div",
3991
3684
  {
3992
3685
  className: getClassNameModal("field"),
3993
- children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3686
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3994
3687
  AutoFieldPrivate,
3995
3688
  {
3996
3689
  field: filterField,
@@ -4011,9 +3704,9 @@ var ExternalInput = ({
4011
3704
  fieldName
4012
3705
  );
4013
3706
  }) }),
4014
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: getClassNameModal("tableWrapper"), children: [
4015
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("table", { className: getClassNameModal("table"), children: [
4016
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("thead", { className: getClassNameModal("thead"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("tr", { className: getClassNameModal("tr"), children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3707
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassNameModal("tableWrapper"), children: [
3708
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("table", { className: getClassNameModal("table"), children: [
3709
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("thead", { className: getClassNameModal("thead"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tr", { className: getClassNameModal("tr"), children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
4017
3710
  "th",
4018
3711
  {
4019
3712
  className: getClassNameModal("th"),
@@ -4022,8 +3715,8 @@ var ExternalInput = ({
4022
3715
  },
4023
3716
  key
4024
3717
  )) }) }),
4025
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
4026
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3718
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
3719
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
4027
3720
  "tr",
4028
3721
  {
4029
3722
  style: { whiteSpace: "nowrap" },
@@ -4032,16 +3725,16 @@ var ExternalInput = ({
4032
3725
  onChange(mapProp(data[i]));
4033
3726
  setOpen(false);
4034
3727
  },
4035
- children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("td", { className: getClassNameModal("td"), children: item[key] }, key))
3728
+ children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("td", { className: getClassNameModal("td"), children: item[key] }, key))
4036
3729
  },
4037
3730
  i
4038
3731
  );
4039
3732
  }) })
4040
3733
  ] }),
4041
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Loader, { size: 24 }) })
3734
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Loader, { size: 24 }) })
4042
3735
  ] })
4043
3736
  ] }),
4044
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Footer, { items: mappedData }) })
3737
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Footer, { items: mappedData }) })
4045
3738
  ]
4046
3739
  }
4047
3740
  ) })
@@ -4051,7 +3744,7 @@ var ExternalInput = ({
4051
3744
  };
4052
3745
 
4053
3746
  // components/AutoField/fields/ExternalField/index.tsx
4054
- var import_jsx_runtime15 = require("react/jsx-runtime");
3747
+ var import_jsx_runtime13 = require("react/jsx-runtime");
4055
3748
  var ExternalField = ({
4056
3749
  field,
4057
3750
  onChange,
@@ -4066,7 +3759,7 @@ var ExternalField = ({
4066
3759
  var _a, _b, _c;
4067
3760
  const validField = field;
4068
3761
  const deprecatedField = field;
4069
- (0, import_react20.useEffect)(() => {
3762
+ (0, import_react18.useEffect)(() => {
4070
3763
  if (deprecatedField.adaptor) {
4071
3764
  console.error(
4072
3765
  "Warning: The `adaptor` API is deprecated. Please use updated APIs on the `external` field instead. This will be a breaking change in a future release."
@@ -4076,13 +3769,13 @@ var ExternalField = ({
4076
3769
  if (field.type !== "external") {
4077
3770
  return null;
4078
3771
  }
4079
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3772
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
4080
3773
  Label2,
4081
3774
  {
4082
3775
  label: label || name,
4083
- icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Link, { size: 16 }),
3776
+ icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Link, { size: 16 }),
4084
3777
  el: "div",
4085
- children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3778
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
4086
3779
  ExternalInput,
4087
3780
  {
4088
3781
  name,
@@ -4109,21 +3802,7 @@ var ExternalField = ({
4109
3802
 
4110
3803
  // components/AutoField/fields/RadioField/index.tsx
4111
3804
  init_react_import();
4112
- var import_react21 = require("react");
4113
-
4114
- // lib/safe-json-parse.ts
4115
- init_react_import();
4116
- var safeJsonParse = (str) => {
4117
- try {
4118
- const jsonValue = JSON.parse(str);
4119
- return jsonValue;
4120
- } catch (e) {
4121
- return str;
4122
- }
4123
- };
4124
-
4125
- // components/AutoField/fields/RadioField/index.tsx
4126
- var import_jsx_runtime16 = require("react/jsx-runtime");
3805
+ var import_jsx_runtime14 = require("react/jsx-runtime");
4127
3806
  var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
4128
3807
  var RadioField = ({
4129
3808
  field,
@@ -4136,58 +3815,50 @@ var RadioField = ({
4136
3815
  labelIcon,
4137
3816
  Label: Label2
4138
3817
  }) => {
4139
- const flatOptions = (0, import_react21.useMemo)(
4140
- () => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
4141
- [field]
4142
- );
4143
3818
  if (field.type !== "radio" || !field.options) {
4144
3819
  return null;
4145
3820
  }
4146
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3821
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
4147
3822
  Label2,
4148
3823
  {
4149
- icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(CircleCheckBig, { size: 16 }),
3824
+ icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CircleCheckBig, { size: 16 }),
4150
3825
  label: label || name,
4151
3826
  readOnly,
4152
3827
  el: "div",
4153
- children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
4154
- "label",
4155
- {
4156
- className: getClassName11("radio"),
4157
- children: [
4158
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
4159
- "input",
4160
- {
4161
- type: "radio",
4162
- className: getClassName11("radioInput"),
4163
- value: option.value,
4164
- name,
4165
- onChange: (e) => {
4166
- var _a;
4167
- const jsonValue = (_a = safeJsonParse(e.target.value)) != null ? _a : e.target.value;
4168
- if (flatOptions.indexOf(jsonValue) > -1) {
4169
- onChange(jsonValue);
4170
- } else {
4171
- onChange(e.target.value);
4172
- }
4173
- },
4174
- disabled: readOnly,
4175
- checked: value === option.value
4176
- }
4177
- ),
4178
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: getClassName11("radioInner"), children: option.label || option.value })
4179
- ]
4180
- },
4181
- option.label + option.value
4182
- )) })
3828
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => {
3829
+ var _a;
3830
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
3831
+ "label",
3832
+ {
3833
+ className: getClassName11("radio"),
3834
+ children: [
3835
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3836
+ "input",
3837
+ {
3838
+ type: "radio",
3839
+ className: getClassName11("radioInput"),
3840
+ value: JSON.stringify({ value: option.value }),
3841
+ name,
3842
+ onChange: (e) => {
3843
+ onChange(JSON.parse(e.target.value).value);
3844
+ },
3845
+ disabled: readOnly,
3846
+ checked: value === option.value
3847
+ }
3848
+ ),
3849
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioInner"), children: option.label || ((_a = option.value) == null ? void 0 : _a.toString()) })
3850
+ ]
3851
+ },
3852
+ option.label + option.value
3853
+ );
3854
+ }) })
4183
3855
  }
4184
3856
  );
4185
3857
  };
4186
3858
 
4187
3859
  // components/AutoField/fields/SelectField/index.tsx
4188
3860
  init_react_import();
4189
- var import_react22 = require("react");
4190
- var import_jsx_runtime17 = require("react/jsx-runtime");
3861
+ var import_jsx_runtime15 = require("react/jsx-runtime");
4191
3862
  var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
4192
3863
  var SelectField = ({
4193
3864
  field,
@@ -4200,20 +3871,16 @@ var SelectField = ({
4200
3871
  readOnly,
4201
3872
  id
4202
3873
  }) => {
4203
- const flatOptions = (0, import_react22.useMemo)(
4204
- () => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
4205
- [field]
4206
- );
4207
3874
  if (field.type !== "select" || !field.options) {
4208
3875
  return null;
4209
3876
  }
4210
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
3877
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
4211
3878
  Label2,
4212
3879
  {
4213
3880
  label: label || name,
4214
- icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ChevronDown, { size: 16 }),
3881
+ icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChevronDown, { size: 16 }),
4215
3882
  readOnly,
4216
- children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
3883
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
4217
3884
  "select",
4218
3885
  {
4219
3886
  id,
@@ -4221,22 +3888,16 @@ var SelectField = ({
4221
3888
  className: getClassName12("input"),
4222
3889
  disabled: readOnly,
4223
3890
  onChange: (e) => {
4224
- var _a;
4225
- const jsonValue = (_a = safeJsonParse(e.target.value)) != null ? _a : e.target.value;
4226
- if (flatOptions.indexOf(jsonValue) > -1) {
4227
- onChange(jsonValue);
4228
- } else {
4229
- onChange(e.target.value);
4230
- }
3891
+ onChange(JSON.parse(e.target.value).value);
4231
3892
  },
4232
- value,
4233
- children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
3893
+ value: JSON.stringify({ value }),
3894
+ children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
4234
3895
  "option",
4235
3896
  {
4236
3897
  label: option.label,
4237
- value: option.value
3898
+ value: JSON.stringify({ value: option.value })
4238
3899
  },
4239
- option.label + option.value
3900
+ option.label + JSON.stringify(option.value)
4240
3901
  ))
4241
3902
  }
4242
3903
  )
@@ -4246,7 +3907,7 @@ var SelectField = ({
4246
3907
 
4247
3908
  // components/AutoField/fields/TextareaField/index.tsx
4248
3909
  init_react_import();
4249
- var import_jsx_runtime18 = require("react/jsx-runtime");
3910
+ var import_jsx_runtime16 = require("react/jsx-runtime");
4250
3911
  var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
4251
3912
  var TextareaField = ({
4252
3913
  field,
@@ -4259,13 +3920,13 @@ var TextareaField = ({
4259
3920
  Label: Label2,
4260
3921
  id
4261
3922
  }) => {
4262
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3923
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
4263
3924
  Label2,
4264
3925
  {
4265
3926
  label: label || name,
4266
- icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Type, { size: 16 }),
3927
+ icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Type, { size: 16 }),
4267
3928
  readOnly,
4268
- children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3929
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
4269
3930
  "textarea",
4270
3931
  {
4271
3932
  id,
@@ -4292,7 +3953,7 @@ init_react_import();
4292
3953
  var styles_module_default9 = { "ObjectField": "_ObjectField_1ua3y_5", "ObjectField-fieldset": "_ObjectField-fieldset_1ua3y_13" };
4293
3954
 
4294
3955
  // components/AutoField/fields/ObjectField/index.tsx
4295
- var import_jsx_runtime19 = require("react/jsx-runtime");
3956
+ var import_jsx_runtime17 = require("react/jsx-runtime");
4296
3957
  var getClassName14 = get_class_name_factory_default("ObjectField", styles_module_default9);
4297
3958
  var ObjectField = ({
4298
3959
  field,
@@ -4310,26 +3971,25 @@ var ObjectField = ({
4310
3971
  return null;
4311
3972
  }
4312
3973
  const data = value || {};
4313
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3974
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
4314
3975
  Label2,
4315
3976
  {
4316
3977
  label: label || name,
4317
- icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(EllipsisVertical, { size: 16 }),
3978
+ icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(EllipsisVertical, { size: 16 }),
4318
3979
  el: "div",
4319
3980
  readOnly,
4320
- children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName14(), children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
3981
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: getClassName14(), children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
4321
3982
  const subField = field.objectFields[subName];
4322
- const subPath = `${name}.${subName}`;
4323
- const localSubPath = `${localName || name}.${subName}`;
4324
- const subReadOnly = readOnly ? readOnly : readOnlyFields[localSubPath];
3983
+ const subPath = `${localName}.${subName}`;
3984
+ const subReadOnly = readOnly ? readOnly : readOnlyFields[subPath];
4325
3985
  const label2 = subField.label || subName;
4326
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3986
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
4327
3987
  NestedFieldProvider,
4328
3988
  {
4329
3989
  name: localName || id,
4330
3990
  subName,
4331
3991
  readOnlyFields,
4332
- children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3992
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
4333
3993
  AutoFieldPrivate,
4334
3994
  {
4335
3995
  name: subPath,
@@ -4361,17 +4021,17 @@ var ObjectField = ({
4361
4021
 
4362
4022
  // lib/use-safe-id.ts
4363
4023
  init_react_import();
4364
- var import_react23 = __toESM(require("react"));
4024
+ var import_react19 = __toESM(require("react"));
4365
4025
  var useSafeId = () => {
4366
- if (typeof import_react23.default.useId !== "undefined") {
4367
- return import_react23.default.useId();
4026
+ if (typeof import_react19.default.useId !== "undefined") {
4027
+ return import_react19.default.useId();
4368
4028
  }
4369
- const [id] = (0, import_react23.useState)(generateId());
4029
+ const [id] = (0, import_react19.useState)(generateId());
4370
4030
  return id;
4371
4031
  };
4372
4032
 
4373
4033
  // components/AutoField/index.tsx
4374
- var import_jsx_runtime20 = require("react/jsx-runtime");
4034
+ var import_jsx_runtime18 = require("react/jsx-runtime");
4375
4035
  var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
4376
4036
  var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
4377
4037
  var FieldLabel = ({
@@ -4383,11 +4043,11 @@ var FieldLabel = ({
4383
4043
  className
4384
4044
  }) => {
4385
4045
  const El = el;
4386
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(El, { className, children: [
4387
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: getClassName15("label"), children: [
4388
- icon ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, {}),
4046
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(El, { className, children: [
4047
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: getClassName15("label"), children: [
4048
+ icon ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, {}),
4389
4049
  label,
4390
- readOnly && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Lock, { size: "12" }) })
4050
+ readOnly && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Lock, { size: "12" }) })
4391
4051
  ] }),
4392
4052
  children
4393
4053
  ] });
@@ -4400,14 +4060,14 @@ var FieldLabelInternal = ({
4400
4060
  readOnly
4401
4061
  }) => {
4402
4062
  const overrides = useAppStore((s) => s.overrides);
4403
- const Wrapper = (0, import_react24.useMemo)(
4063
+ const Wrapper = (0, import_react20.useMemo)(
4404
4064
  () => overrides.fieldLabel || FieldLabel,
4405
4065
  [overrides]
4406
4066
  );
4407
4067
  if (!label) {
4408
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children });
4068
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children });
4409
4069
  }
4410
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4070
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4411
4071
  Wrapper,
4412
4072
  {
4413
4073
  label,
@@ -4420,14 +4080,14 @@ var FieldLabelInternal = ({
4420
4080
  );
4421
4081
  };
4422
4082
  function AutoFieldInternal(props) {
4423
- var _a, _b, _c, _d, _e, _f, _g, _h;
4083
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
4424
4084
  const dispatch = useAppStore((s) => s.dispatch);
4425
4085
  const overrides = useAppStore((s) => s.overrides);
4426
4086
  const readOnly = useAppStore((s) => {
4427
4087
  var _a2;
4428
4088
  return (_a2 = s.selectedItem) == null ? void 0 : _a2.readOnly;
4429
4089
  });
4430
- const nestedFieldContext = (0, import_react24.useContext)(NestedFieldContext);
4090
+ const nestedFieldContext = (0, import_react20.useContext)(NestedFieldContext);
4431
4091
  const { id, Label: Label2 = FieldLabelInternal } = props;
4432
4092
  const field = props.field;
4433
4093
  const label = field.label;
@@ -4461,7 +4121,7 @@ function AutoFieldInternal(props) {
4461
4121
  Label: Label2,
4462
4122
  id: resolvedId
4463
4123
  });
4464
- const onFocus = (0, import_react24.useCallback)(
4124
+ const onFocus = (0, import_react20.useCallback)(
4465
4125
  (e) => {
4466
4126
  if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
4467
4127
  e.stopPropagation();
@@ -4475,7 +4135,7 @@ function AutoFieldInternal(props) {
4475
4135
  },
4476
4136
  [mergedProps.name]
4477
4137
  );
4478
- const onBlur = (0, import_react24.useCallback)((e) => {
4138
+ const onBlur = (0, import_react20.useCallback)((e) => {
4479
4139
  if ("name" in e.target) {
4480
4140
  dispatch({
4481
4141
  type: "setUi",
@@ -4492,23 +4152,25 @@ function AutoFieldInternal(props) {
4492
4152
  if (field.type === "slot") {
4493
4153
  return null;
4494
4154
  }
4155
+ let children = null;
4156
+ let FieldComponent;
4495
4157
  if (field.type === "custom") {
4496
4158
  if (!field.render) {
4497
4159
  return null;
4498
4160
  }
4499
- const CustomField = field.render;
4500
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName15(), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CustomField, __spreadValues({}, mergedProps)) }) });
4161
+ FieldComponent = field.render;
4162
+ } else {
4163
+ children = defaultFields[field.type](mergedProps);
4164
+ FieldComponent = render[field.type];
4501
4165
  }
4502
- const children = defaultFields[field.type](mergedProps);
4503
- const Render3 = render[field.type];
4504
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4166
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4505
4167
  NestedFieldContext.Provider,
4506
4168
  {
4507
4169
  value: {
4508
4170
  readOnlyFields: nestedFieldContext.readOnlyFields || readOnly || {},
4509
- localName: nestedFieldContext.localName
4171
+ localName: (_i = nestedFieldContext.localName) != null ? _i : mergedProps.name
4510
4172
  },
4511
- children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4173
+ children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4512
4174
  "div",
4513
4175
  {
4514
4176
  className: getClassNameWrapper(),
@@ -4517,7 +4179,7 @@ function AutoFieldInternal(props) {
4517
4179
  onClick: (e) => {
4518
4180
  e.stopPropagation();
4519
4181
  },
4520
- children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Render3, __spreadProps(__spreadValues({}, mergedProps), { children }))
4182
+ children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FieldComponent, __spreadProps(__spreadValues({}, mergedProps), { children }))
4521
4183
  }
4522
4184
  )
4523
4185
  }
@@ -4526,20 +4188,20 @@ function AutoFieldInternal(props) {
4526
4188
  function AutoFieldPrivate(props) {
4527
4189
  const isFocused = useAppStore((s) => s.state.ui.field.focus === props.name);
4528
4190
  const { value, onChange } = props;
4529
- const [localValue, setLocalValue] = (0, import_react24.useState)(value);
4530
- const onChangeLocal = (0, import_react24.useCallback)(
4191
+ const [localValue, setLocalValue] = (0, import_react20.useState)(value);
4192
+ const onChangeLocal = (0, import_react20.useCallback)(
4531
4193
  (val, ui) => {
4532
4194
  setLocalValue(val);
4533
4195
  onChange(val, ui);
4534
4196
  },
4535
4197
  [onChange]
4536
4198
  );
4537
- (0, import_react24.useEffect)(() => {
4199
+ (0, import_react20.useEffect)(() => {
4538
4200
  if (!isFocused) {
4539
4201
  setLocalValue(value);
4540
4202
  }
4541
4203
  }, [value]);
4542
- (0, import_react24.useEffect)(() => {
4204
+ (0, import_react20.useEffect)(() => {
4543
4205
  if (!isFocused) {
4544
4206
  if (value !== localValue) {
4545
4207
  setLocalValue(value);
@@ -4550,11 +4212,11 @@ function AutoFieldPrivate(props) {
4550
4212
  value: localValue,
4551
4213
  onChange: onChangeLocal
4552
4214
  };
4553
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
4215
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
4554
4216
  }
4555
4217
  function AutoField(props) {
4556
- const DefaultLabel = (0, import_react24.useMemo)(() => {
4557
- const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4218
+ const DefaultLabel = (0, import_react20.useMemo)(() => {
4219
+ const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4558
4220
  "div",
4559
4221
  __spreadProps(__spreadValues({}, labelProps), {
4560
4222
  className: getClassName15({ readOnly: props.readOnly })
@@ -4565,7 +4227,7 @@ function AutoField(props) {
4565
4227
  if (props.field.type === "slot") {
4566
4228
  return null;
4567
4229
  }
4568
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
4230
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
4569
4231
  }
4570
4232
 
4571
4233
  // components/Drawer/index.tsx
@@ -4576,21 +4238,21 @@ init_react_import();
4576
4238
  var styles_module_default10 = { "Drawer": "_Drawer_pl7z0_1", "Drawer-draggable": "_Drawer-draggable_pl7z0_8", "Drawer-draggableBg": "_Drawer-draggableBg_pl7z0_12", "DrawerItem-draggable": "_DrawerItem-draggable_pl7z0_22", "DrawerItem--disabled": "_DrawerItem--disabled_pl7z0_35", "DrawerItem": "_DrawerItem_pl7z0_22", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_pl7z0_45", "DrawerItem-name": "_DrawerItem-name_pl7z0_63" };
4577
4239
 
4578
4240
  // components/Drawer/index.tsx
4579
- var import_react39 = require("react");
4241
+ var import_react37 = require("react");
4580
4242
 
4581
4243
  // components/DragDropContext/index.tsx
4582
4244
  init_react_import();
4583
- var import_react37 = require("@dnd-kit/react");
4584
- var import_react38 = require("react");
4245
+ var import_react35 = require("@dnd-kit/react");
4246
+ var import_react36 = require("react");
4585
4247
  var import_dom = require("@dnd-kit/dom");
4586
4248
 
4587
4249
  // components/DropZone/index.tsx
4588
4250
  init_react_import();
4589
- var import_react35 = require("react");
4251
+ var import_react33 = require("react");
4590
4252
 
4591
4253
  // components/DraggableComponent/index.tsx
4592
4254
  init_react_import();
4593
- var import_react28 = require("react");
4255
+ var import_react24 = require("react");
4594
4256
 
4595
4257
  // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
4596
4258
  init_react_import();
@@ -4620,11 +4282,11 @@ function getDeepScrollPosition(element) {
4620
4282
 
4621
4283
  // components/DropZone/context.tsx
4622
4284
  init_react_import();
4623
- var import_react25 = require("react");
4285
+ var import_react21 = require("react");
4624
4286
  var import_zustand3 = require("zustand");
4625
- var import_jsx_runtime21 = require("react/jsx-runtime");
4626
- var dropZoneContext = (0, import_react25.createContext)(null);
4627
- var ZoneStoreContext = (0, import_react25.createContext)(
4287
+ var import_jsx_runtime19 = require("react/jsx-runtime");
4288
+ var dropZoneContext = (0, import_react21.createContext)(null);
4289
+ var ZoneStoreContext = (0, import_react21.createContext)(
4628
4290
  (0, import_zustand3.createStore)(() => ({
4629
4291
  zoneDepthIndex: {},
4630
4292
  nextZoneDepthIndex: {},
@@ -4640,14 +4302,14 @@ var ZoneStoreProvider = ({
4640
4302
  children,
4641
4303
  store
4642
4304
  }) => {
4643
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ZoneStoreContext.Provider, { value: store, children });
4305
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ZoneStoreContext.Provider, { value: store, children });
4644
4306
  };
4645
4307
  var DropZoneProvider = ({
4646
4308
  children,
4647
4309
  value
4648
4310
  }) => {
4649
4311
  const dispatch = useAppStore((s) => s.dispatch);
4650
- const registerZone = (0, import_react25.useCallback)(
4312
+ const registerZone = (0, import_react21.useCallback)(
4651
4313
  (zoneCompound) => {
4652
4314
  dispatch({
4653
4315
  type: "registerZone",
@@ -4656,23 +4318,13 @@ var DropZoneProvider = ({
4656
4318
  },
4657
4319
  [dispatch]
4658
4320
  );
4659
- const unregisterZone = (0, import_react25.useCallback)(
4660
- (zoneCompound) => {
4661
- dispatch({
4662
- type: "unregisterZone",
4663
- zone: zoneCompound
4664
- });
4665
- },
4666
- [dispatch]
4667
- );
4668
- const memoValue = (0, import_react25.useMemo)(
4321
+ const memoValue = (0, import_react21.useMemo)(
4669
4322
  () => __spreadValues({
4670
- registerZone,
4671
- unregisterZone
4323
+ registerZone
4672
4324
  }, value),
4673
4325
  [value]
4674
4326
  );
4675
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
4327
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
4676
4328
  };
4677
4329
 
4678
4330
  // components/DraggableComponent/index.tsx
@@ -4696,11 +4348,11 @@ function accumulateTransform(el) {
4696
4348
 
4697
4349
  // lib/use-context-store.ts
4698
4350
  init_react_import();
4699
- var import_react26 = require("react");
4351
+ var import_react22 = require("react");
4700
4352
  var import_zustand4 = require("zustand");
4701
4353
  var import_shallow = require("zustand/react/shallow");
4702
4354
  function useContextStore(context, selector) {
4703
- const store = (0, import_react26.useContext)(context);
4355
+ const store = (0, import_react22.useContext)(context);
4704
4356
  if (!store) {
4705
4357
  throw new Error("useContextStore must be used inside context");
4706
4358
  }
@@ -4709,10 +4361,10 @@ function useContextStore(context, selector) {
4709
4361
 
4710
4362
  // lib/dnd/use-on-drag-finished.ts
4711
4363
  init_react_import();
4712
- var import_react27 = require("react");
4364
+ var import_react23 = require("react");
4713
4365
  var useOnDragFinished = (cb, deps = []) => {
4714
4366
  const appStore = useAppStoreApi();
4715
- return (0, import_react27.useCallback)(() => {
4367
+ return (0, import_react23.useCallback)(() => {
4716
4368
  let dispose = () => {
4717
4369
  };
4718
4370
  const processDragging = (isDragging2) => {
@@ -4740,7 +4392,7 @@ var useOnDragFinished = (cb, deps = []) => {
4740
4392
  };
4741
4393
 
4742
4394
  // components/DraggableComponent/index.tsx
4743
- var import_jsx_runtime22 = require("react/jsx-runtime");
4395
+ var import_jsx_runtime20 = require("react/jsx-runtime");
4744
4396
  var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
4745
4397
  var DEBUG2 = false;
4746
4398
  var space = 8;
@@ -4751,12 +4403,12 @@ var DefaultActionBar = ({
4751
4403
  label,
4752
4404
  children,
4753
4405
  parentAction
4754
- }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(ActionBar, { children: [
4755
- /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(ActionBar.Group, { children: [
4406
+ }) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(ActionBar, { children: [
4407
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(ActionBar.Group, { children: [
4756
4408
  parentAction,
4757
- label && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ActionBar.Label, { label })
4409
+ label && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Label, { label })
4758
4410
  ] }),
4759
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ActionBar.Group, { children })
4411
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Group, { children })
4760
4412
  ] });
4761
4413
  var DraggableComponent = ({
4762
4414
  children,
@@ -4782,9 +4434,9 @@ var DraggableComponent = ({
4782
4434
  const overrides = useAppStore((s) => s.overrides);
4783
4435
  const dispatch = useAppStore((s) => s.dispatch);
4784
4436
  const iframe = useAppStore((s) => s.iframe);
4785
- const ctx = (0, import_react28.useContext)(dropZoneContext);
4786
- const [localZones, setLocalZones] = (0, import_react28.useState)({});
4787
- const registerLocalZone = (0, import_react28.useCallback)(
4437
+ const ctx = (0, import_react24.useContext)(dropZoneContext);
4438
+ const [localZones, setLocalZones] = (0, import_react24.useState)({});
4439
+ const registerLocalZone = (0, import_react24.useCallback)(
4788
4440
  (zoneCompound2, active) => {
4789
4441
  var _a;
4790
4442
  (_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
@@ -4794,7 +4446,7 @@ var DraggableComponent = ({
4794
4446
  },
4795
4447
  [setLocalZones]
4796
4448
  );
4797
- const unregisterLocalZone = (0, import_react28.useCallback)(
4449
+ const unregisterLocalZone = (0, import_react24.useCallback)(
4798
4450
  (zoneCompound2) => {
4799
4451
  var _a;
4800
4452
  (_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
@@ -4817,9 +4469,9 @@ var DraggableComponent = ({
4817
4469
  return s.permissions.getPermissions({ item });
4818
4470
  })
4819
4471
  );
4820
- const zoneStore = (0, import_react28.useContext)(ZoneStoreContext);
4821
- const [dragAxis, setDragAxis] = (0, import_react28.useState)(userDragAxis || autoDragAxis);
4822
- const dynamicCollisionDetector = (0, import_react28.useMemo)(
4472
+ const zoneStore = (0, import_react24.useContext)(ZoneStoreContext);
4473
+ const [dragAxis, setDragAxis] = (0, import_react24.useState)(userDragAxis || autoDragAxis);
4474
+ const dynamicCollisionDetector = (0, import_react24.useMemo)(
4823
4475
  () => createDynamicCollisionDetector(dragAxis),
4824
4476
  [dragAxis]
4825
4477
  );
@@ -4851,7 +4503,7 @@ var DraggableComponent = ({
4851
4503
  },
4852
4504
  feedback: "clone"
4853
4505
  });
4854
- (0, import_react28.useEffect)(() => {
4506
+ (0, import_react24.useEffect)(() => {
4855
4507
  const isEnabled = zoneStore.getState().enabledIndex[zoneCompound];
4856
4508
  sortable.droppable.disabled = !isEnabled;
4857
4509
  sortable.draggable.disabled = !permissions.drag;
@@ -4868,8 +4520,8 @@ var DraggableComponent = ({
4868
4520
  }
4869
4521
  return cleanup;
4870
4522
  }, [permissions.drag, zoneCompound]);
4871
- const ref = (0, import_react28.useRef)(null);
4872
- const refSetter = (0, import_react28.useCallback)(
4523
+ const ref = (0, import_react24.useRef)(null);
4524
+ const refSetter = (0, import_react24.useCallback)(
4873
4525
  (el) => {
4874
4526
  sortableRef(el);
4875
4527
  if (el) {
@@ -4878,14 +4530,14 @@ var DraggableComponent = ({
4878
4530
  },
4879
4531
  [sortableRef]
4880
4532
  );
4881
- const [portalEl, setPortalEl] = (0, import_react28.useState)();
4882
- (0, import_react28.useEffect)(() => {
4533
+ const [portalEl, setPortalEl] = (0, import_react24.useState)();
4534
+ (0, import_react24.useEffect)(() => {
4883
4535
  var _a, _b, _c;
4884
4536
  setPortalEl(
4885
4537
  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
4886
4538
  );
4887
4539
  }, [iframe.enabled, ref.current]);
4888
- const getStyle = (0, import_react28.useCallback)(() => {
4540
+ const getStyle = (0, import_react24.useCallback)(() => {
4889
4541
  var _a, _b, _c;
4890
4542
  if (!ref.current) return;
4891
4543
  const rect = ref.current.getBoundingClientRect();
@@ -4910,11 +4562,11 @@ var DraggableComponent = ({
4910
4562
  };
4911
4563
  return style2;
4912
4564
  }, [ref.current]);
4913
- const [style, setStyle] = (0, import_react28.useState)();
4914
- const sync = (0, import_react28.useCallback)(() => {
4565
+ const [style, setStyle] = (0, import_react24.useState)();
4566
+ const sync = (0, import_react24.useCallback)(() => {
4915
4567
  setStyle(getStyle());
4916
4568
  }, [ref.current, iframe]);
4917
- (0, import_react28.useEffect)(() => {
4569
+ (0, import_react24.useEffect)(() => {
4918
4570
  if (ref.current) {
4919
4571
  const observer = new ResizeObserver(sync);
4920
4572
  observer.observe(ref.current);
@@ -4924,13 +4576,13 @@ var DraggableComponent = ({
4924
4576
  }
4925
4577
  }, [ref.current]);
4926
4578
  const registerNode = useAppStore((s) => s.nodes.registerNode);
4927
- const hideOverlay = (0, import_react28.useCallback)(() => {
4579
+ const hideOverlay = (0, import_react24.useCallback)(() => {
4928
4580
  setIsVisible(false);
4929
4581
  }, []);
4930
- const showOverlay = (0, import_react28.useCallback)(() => {
4582
+ const showOverlay = (0, import_react24.useCallback)(() => {
4931
4583
  setIsVisible(true);
4932
4584
  }, []);
4933
- (0, import_react28.useEffect)(() => {
4585
+ (0, import_react24.useEffect)(() => {
4934
4586
  var _a;
4935
4587
  registerNode(id, {
4936
4588
  methods: { sync, showOverlay, hideOverlay },
@@ -4947,11 +4599,11 @@ var DraggableComponent = ({
4947
4599
  });
4948
4600
  };
4949
4601
  }, [id, zoneCompound, index, componentType, sync]);
4950
- const CustomActionBar = (0, import_react28.useMemo)(
4602
+ const CustomActionBar = (0, import_react24.useMemo)(
4951
4603
  () => overrides.actionBar || DefaultActionBar,
4952
4604
  [overrides.actionBar]
4953
4605
  );
4954
- const onClick = (0, import_react28.useCallback)(
4606
+ const onClick = (0, import_react24.useCallback)(
4955
4607
  (e) => {
4956
4608
  e.stopPropagation();
4957
4609
  dispatch({
@@ -4964,7 +4616,7 @@ var DraggableComponent = ({
4964
4616
  [index, zoneCompound, id]
4965
4617
  );
4966
4618
  const appStore = useAppStoreApi();
4967
- const onSelectParent = (0, import_react28.useCallback)(() => {
4619
+ const onSelectParent = (0, import_react24.useCallback)(() => {
4968
4620
  const { nodes, zones } = appStore.getState().state.indexes;
4969
4621
  const node = nodes[id];
4970
4622
  const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
@@ -4985,26 +4637,26 @@ var DraggableComponent = ({
4985
4637
  }
4986
4638
  });
4987
4639
  }, [ctx, path]);
4988
- const onDuplicate = (0, import_react28.useCallback)(() => {
4640
+ const onDuplicate = (0, import_react24.useCallback)(() => {
4989
4641
  dispatch({
4990
4642
  type: "duplicate",
4991
4643
  sourceIndex: index,
4992
4644
  sourceZone: zoneCompound
4993
4645
  });
4994
4646
  }, [index, zoneCompound]);
4995
- const onDelete = (0, import_react28.useCallback)(() => {
4647
+ const onDelete = (0, import_react24.useCallback)(() => {
4996
4648
  dispatch({
4997
4649
  type: "remove",
4998
4650
  index,
4999
4651
  zone: zoneCompound
5000
4652
  });
5001
4653
  }, [index, zoneCompound]);
5002
- const [hover, setHover] = (0, import_react28.useState)(false);
4654
+ const [hover, setHover] = (0, import_react24.useState)(false);
5003
4655
  const indicativeHover = useContextStore(
5004
4656
  ZoneStoreContext,
5005
4657
  (s) => s.hoveringComponent === id
5006
4658
  );
5007
- (0, import_react28.useEffect)(() => {
4659
+ (0, import_react24.useEffect)(() => {
5008
4660
  if (!ref.current) {
5009
4661
  return;
5010
4662
  }
@@ -5040,7 +4692,8 @@ var DraggableComponent = ({
5040
4692
  el.removeEventListener("mouseout", _onMouseOut);
5041
4693
  };
5042
4694
  }, [
5043
- ref,
4695
+ ref.current,
4696
+ // Remount attributes if the element changes
5044
4697
  onClick,
5045
4698
  containsActiveZone,
5046
4699
  zoneCompound,
@@ -5048,10 +4701,10 @@ var DraggableComponent = ({
5048
4701
  thisIsDragging,
5049
4702
  inDroppableZone
5050
4703
  ]);
5051
- const [isVisible, setIsVisible] = (0, import_react28.useState)(false);
5052
- const [dragFinished, setDragFinished] = (0, import_react28.useState)(true);
5053
- const [_, startTransition] = (0, import_react28.useTransition)();
5054
- (0, import_react28.useEffect)(() => {
4704
+ const [isVisible, setIsVisible] = (0, import_react24.useState)(false);
4705
+ const [dragFinished, setDragFinished] = (0, import_react24.useState)(true);
4706
+ const [_, startTransition] = (0, import_react24.useTransition)();
4707
+ (0, import_react24.useEffect)(() => {
5055
4708
  startTransition(() => {
5056
4709
  if (hover || indicativeHover || isSelected) {
5057
4710
  sync();
@@ -5062,7 +4715,7 @@ var DraggableComponent = ({
5062
4715
  }
5063
4716
  });
5064
4717
  }, [hover, indicativeHover, isSelected, iframe]);
5065
- const [thisWasDragging, setThisWasDragging] = (0, import_react28.useState)(false);
4718
+ const [thisWasDragging, setThisWasDragging] = (0, import_react24.useState)(false);
5066
4719
  const onDragFinished = useOnDragFinished((finished) => {
5067
4720
  if (finished) {
5068
4721
  startTransition(() => {
@@ -5073,15 +4726,15 @@ var DraggableComponent = ({
5073
4726
  setDragFinished(false);
5074
4727
  }
5075
4728
  });
5076
- (0, import_react28.useEffect)(() => {
4729
+ (0, import_react24.useEffect)(() => {
5077
4730
  if (thisIsDragging) {
5078
4731
  setThisWasDragging(true);
5079
4732
  }
5080
4733
  }, [thisIsDragging]);
5081
- (0, import_react28.useEffect)(() => {
4734
+ (0, import_react24.useEffect)(() => {
5082
4735
  if (thisWasDragging) return onDragFinished();
5083
4736
  }, [thisWasDragging, onDragFinished]);
5084
- const syncActionsPosition = (0, import_react28.useCallback)(
4737
+ const syncActionsPosition = (0, import_react24.useCallback)(
5085
4738
  (el) => {
5086
4739
  if (el) {
5087
4740
  const view = el.ownerDocument.defaultView;
@@ -5106,7 +4759,7 @@ var DraggableComponent = ({
5106
4759
  },
5107
4760
  [zoom]
5108
4761
  );
5109
- (0, import_react28.useEffect)(() => {
4762
+ (0, import_react24.useEffect)(() => {
5110
4763
  if (userDragAxis) {
5111
4764
  setDragAxis(userDragAxis);
5112
4765
  return;
@@ -5120,11 +4773,11 @@ var DraggableComponent = ({
5120
4773
  }
5121
4774
  setDragAxis(autoDragAxis);
5122
4775
  }, [ref, userDragAxis, autoDragAxis]);
5123
- const parentAction = (0, import_react28.useMemo)(
5124
- () => (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(CornerLeftUp, { size: 16 }) }),
4776
+ const parentAction = (0, import_react24.useMemo)(
4777
+ () => (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CornerLeftUp, { size: 16 }) }),
5125
4778
  [ctx == null ? void 0 : ctx.areaId]
5126
4779
  );
5127
- const nextContextValue = (0, import_react28.useMemo)(
4780
+ const nextContextValue = (0, import_react24.useMemo)(
5128
4781
  () => __spreadProps(__spreadValues({}, ctx), {
5129
4782
  areaId: id,
5130
4783
  zoneCompound,
@@ -5143,9 +4796,9 @@ var DraggableComponent = ({
5143
4796
  unregisterLocalZone
5144
4797
  ]
5145
4798
  );
5146
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(DropZoneProvider, { value: nextContextValue, children: [
4799
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(DropZoneProvider, { value: nextContextValue, children: [
5147
4800
  dragFinished && isVisible && (0, import_react_dom2.createPortal)(
5148
- /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
4801
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
5149
4802
  "div",
5150
4803
  {
5151
4804
  className: getClassName16({
@@ -5157,15 +4810,15 @@ var DraggableComponent = ({
5157
4810
  "data-puck-overlay": true,
5158
4811
  children: [
5159
4812
  debug,
5160
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Loader, {}) }),
5161
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
4813
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Loader, {}) }),
4814
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
5162
4815
  "div",
5163
4816
  {
5164
4817
  className: getClassName16("actionsOverlay"),
5165
4818
  style: {
5166
4819
  top: actionsOverlayTop / zoom
5167
4820
  },
5168
- children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
4821
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
5169
4822
  "div",
5170
4823
  {
5171
4824
  className: getClassName16("actions"),
@@ -5177,14 +4830,14 @@ var DraggableComponent = ({
5177
4830
  paddingRight: actionsSide
5178
4831
  },
5179
4832
  ref: syncActionsPosition,
5180
- children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
4833
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
5181
4834
  CustomActionBar,
5182
4835
  {
5183
4836
  parentAction,
5184
4837
  label: DEBUG2 ? id : label,
5185
4838
  children: [
5186
- permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Copy, { size: 16 }) }),
5187
- permissions.delete && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Trash, { size: 16 }) })
4839
+ permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Copy, { size: 16 }) }),
4840
+ permissions.delete && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Trash, { size: 16 }) })
5188
4841
  ]
5189
4842
  }
5190
4843
  )
@@ -5192,7 +4845,7 @@ var DraggableComponent = ({
5192
4845
  )
5193
4846
  }
5194
4847
  ),
5195
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: getClassName16("overlay") })
4848
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("overlay") })
5196
4849
  ]
5197
4850
  }
5198
4851
  ),
@@ -5207,11 +4860,11 @@ init_react_import();
5207
4860
  var styles_module_default12 = { "DropZone": "_DropZone_1i2sv_1", "DropZone--hasChildren": "_DropZone--hasChildren_1i2sv_11", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_1i2sv_24", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_1i2sv_25", "DropZone--isRootZone": "_DropZone--isRootZone_1i2sv_25", "DropZone--isDestination": "_DropZone--isDestination_1i2sv_35", "DropZone-item": "_DropZone-item_1i2sv_47", "DropZone-hitbox": "_DropZone-hitbox_1i2sv_51", "DropZone--isEnabled": "_DropZone--isEnabled_1i2sv_59", "DropZone--isAnimating": "_DropZone--isAnimating_1i2sv_68" };
5208
4861
 
5209
4862
  // components/DropZone/index.tsx
5210
- var import_react36 = require("@dnd-kit/react");
4863
+ var import_react34 = require("@dnd-kit/react");
5211
4864
 
5212
4865
  // components/DropZone/lib/use-min-empty-height.ts
5213
4866
  init_react_import();
5214
- var import_react29 = require("react");
4867
+ var import_react25 = require("react");
5215
4868
  var getNumItems = (appStore, zoneCompound) => appStore.getState().state.indexes.zones[zoneCompound].contentIds.length;
5216
4869
  var useMinEmptyHeight = ({
5217
4870
  zoneCompound,
@@ -5219,8 +4872,8 @@ var useMinEmptyHeight = ({
5219
4872
  ref
5220
4873
  }) => {
5221
4874
  const appStore = useAppStoreApi();
5222
- const [prevHeight, setPrevHeight] = (0, import_react29.useState)(0);
5223
- const [isAnimating, setIsAnimating] = (0, import_react29.useState)(false);
4875
+ const [prevHeight, setPrevHeight] = (0, import_react25.useState)(0);
4876
+ const [isAnimating, setIsAnimating] = (0, import_react25.useState)(false);
5224
4877
  const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
5225
4878
  var _a, _b;
5226
4879
  return {
@@ -5228,7 +4881,7 @@ var useMinEmptyHeight = ({
5228
4881
  isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
5229
4882
  };
5230
4883
  });
5231
- const numItems = (0, import_react29.useRef)(0);
4884
+ const numItems = (0, import_react25.useRef)(0);
5232
4885
  const onDragFinished = useOnDragFinished(
5233
4886
  (finished) => {
5234
4887
  var _a;
@@ -5263,7 +4916,7 @@ var useMinEmptyHeight = ({
5263
4916
  },
5264
4917
  [appStore, prevHeight, zoneCompound]
5265
4918
  );
5266
- (0, import_react29.useEffect)(() => {
4919
+ (0, import_react25.useEffect)(() => {
5267
4920
  if (draggedItem && ref.current) {
5268
4921
  if (isZone) {
5269
4922
  const rect = ref.current.getBoundingClientRect();
@@ -5294,15 +4947,15 @@ function assignRefs(refs, node) {
5294
4947
 
5295
4948
  // components/DropZone/lib/use-content-with-preview.ts
5296
4949
  init_react_import();
5297
- var import_react32 = require("react");
4950
+ var import_react28 = require("react");
5298
4951
 
5299
4952
  // lib/dnd/use-rendered-callback.ts
5300
4953
  init_react_import();
5301
- var import_react30 = require("@dnd-kit/react");
5302
- var import_react31 = require("react");
4954
+ var import_react26 = require("@dnd-kit/react");
4955
+ var import_react27 = require("react");
5303
4956
  function useRenderedCallback(callback, deps) {
5304
- const manager = (0, import_react30.useDragDropManager)();
5305
- return (0, import_react31.useCallback)(
4957
+ const manager = (0, import_react26.useDragDropManager)();
4958
+ return (0, import_react27.useCallback)(
5306
4959
  (...args) => __async(this, null, function* () {
5307
4960
  yield manager == null ? void 0 : manager.renderer.rendering;
5308
4961
  return callback(...args);
@@ -5313,14 +4966,14 @@ function useRenderedCallback(callback, deps) {
5313
4966
 
5314
4967
  // components/DropZone/lib/use-content-with-preview.ts
5315
4968
  var useContentIdsWithPreview = (contentIds, zoneCompound) => {
5316
- const zoneStore = (0, import_react32.useContext)(ZoneStoreContext);
4969
+ const zoneStore = (0, import_react28.useContext)(ZoneStoreContext);
5317
4970
  const preview = useContextStore(
5318
4971
  ZoneStoreContext,
5319
4972
  (s) => s.previewIndex[zoneCompound]
5320
4973
  );
5321
4974
  const isDragging = useAppStore((s) => s.state.ui.isDragging);
5322
- const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react32.useState)(contentIds);
5323
- const [localPreview, setLocalPreview] = (0, import_react32.useState)(
4975
+ const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react28.useState)(contentIds);
4976
+ const [localPreview, setLocalPreview] = (0, import_react28.useState)(
5324
4977
  preview
5325
4978
  );
5326
4979
  const updateContent = useRenderedCallback(
@@ -5355,7 +5008,7 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
5355
5008
  },
5356
5009
  []
5357
5010
  );
5358
- (0, import_react32.useEffect)(() => {
5011
+ (0, import_react28.useEffect)(() => {
5359
5012
  var _a;
5360
5013
  const s = zoneStore.getState();
5361
5014
  const draggedItemId = (_a = s.draggedItem) == null ? void 0 : _a.id;
@@ -5373,16 +5026,16 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
5373
5026
 
5374
5027
  // components/DropZone/lib/use-drag-axis.ts
5375
5028
  init_react_import();
5376
- var import_react33 = require("react");
5029
+ var import_react29 = require("react");
5377
5030
  var GRID_DRAG_AXIS = "dynamic";
5378
5031
  var FLEX_ROW_DRAG_AXIS = "x";
5379
5032
  var DEFAULT_DRAG_AXIS = "y";
5380
5033
  var useDragAxis = (ref, collisionAxis) => {
5381
5034
  const status = useAppStore((s) => s.status);
5382
- const [dragAxis, setDragAxis] = (0, import_react33.useState)(
5035
+ const [dragAxis, setDragAxis] = (0, import_react29.useState)(
5383
5036
  collisionAxis || DEFAULT_DRAG_AXIS
5384
5037
  );
5385
- const calculateDragAxis = (0, import_react33.useCallback)(() => {
5038
+ const calculateDragAxis = (0, import_react29.useCallback)(() => {
5386
5039
  if (ref.current) {
5387
5040
  const computedStyle = window.getComputedStyle(ref.current);
5388
5041
  if (computedStyle.display === "grid") {
@@ -5394,7 +5047,7 @@ var useDragAxis = (ref, collisionAxis) => {
5394
5047
  }
5395
5048
  }
5396
5049
  }, [ref.current]);
5397
- (0, import_react33.useEffect)(() => {
5050
+ (0, import_react29.useEffect)(() => {
5398
5051
  const onViewportChange = () => {
5399
5052
  calculateDragAxis();
5400
5053
  };
@@ -5403,7 +5056,7 @@ var useDragAxis = (ref, collisionAxis) => {
5403
5056
  window.removeEventListener("viewportchange", onViewportChange);
5404
5057
  };
5405
5058
  }, []);
5406
- (0, import_react33.useEffect)(calculateDragAxis, [status, collisionAxis]);
5059
+ (0, import_react29.useEffect)(calculateDragAxis, [status, collisionAxis]);
5407
5060
  return [dragAxis, calculateDragAxis];
5408
5061
  };
5409
5062
 
@@ -5412,11 +5065,136 @@ var import_shallow4 = require("zustand/react/shallow");
5412
5065
 
5413
5066
  // components/Render/index.tsx
5414
5067
  init_react_import();
5415
- var import_react34 = __toESM(require("react"));
5068
+
5069
+ // lib/use-slots.tsx
5070
+ init_react_import();
5071
+ var import_react30 = require("react");
5072
+ function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
5073
+ const slotProps = (0, import_react30.useMemo)(() => {
5074
+ const mapped = mapSlots(
5075
+ item,
5076
+ (content, _parentId, propName, field, propPath) => {
5077
+ const wildcardPath = propPath.replace(/\[\d+\]/g, "[*]");
5078
+ const isReadOnly = (readOnly == null ? void 0 : readOnly[propPath]) || (readOnly == null ? void 0 : readOnly[wildcardPath]) || forceReadOnly;
5079
+ const render = isReadOnly ? renderSlotRender : renderSlotEdit;
5080
+ const Slot = (dzProps) => render(__spreadProps(__spreadValues({
5081
+ allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
5082
+ disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
5083
+ }, dzProps), {
5084
+ zone: propName,
5085
+ content
5086
+ }));
5087
+ return Slot;
5088
+ },
5089
+ config
5090
+ ).props;
5091
+ return mapped;
5092
+ }, [config, item, readOnly, forceReadOnly]);
5093
+ const mergedProps = (0, import_react30.useMemo)(
5094
+ () => __spreadValues(__spreadValues({}, item.props), slotProps),
5095
+ [item.props, slotProps]
5096
+ );
5097
+ return mergedProps;
5098
+ }
5099
+
5100
+ // components/Render/index.tsx
5101
+ var import_react32 = __toESM(require("react"));
5102
+
5103
+ // components/SlotRender/index.tsx
5104
+ init_react_import();
5105
+ var import_shallow3 = require("zustand/react/shallow");
5106
+
5107
+ // components/SlotRender/server.tsx
5108
+ init_react_import();
5109
+ var import_react31 = require("react");
5110
+
5111
+ // components/ServerRender/index.tsx
5112
+ init_react_import();
5113
+ var import_jsx_runtime21 = require("react/jsx-runtime");
5114
+ function DropZoneRender({
5115
+ zone,
5116
+ data,
5117
+ areaId = "root",
5118
+ config,
5119
+ metadata = {}
5120
+ }) {
5121
+ let zoneCompound = rootDroppableId;
5122
+ let content = (data == null ? void 0 : data.content) || [];
5123
+ if (!data || !config) {
5124
+ return null;
5125
+ }
5126
+ if (areaId !== rootAreaId && zone !== rootZone) {
5127
+ zoneCompound = `${areaId}:${zone}`;
5128
+ content = setupZone(data, zoneCompound).zones[zoneCompound];
5129
+ }
5130
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: content.map((item) => {
5131
+ const Component = config.components[item.type];
5132
+ const props = __spreadProps(__spreadValues({}, item.props), {
5133
+ puck: {
5134
+ renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
5135
+ DropZoneRender,
5136
+ {
5137
+ zone: zone2,
5138
+ data,
5139
+ areaId: item.props.id,
5140
+ config,
5141
+ metadata
5142
+ }
5143
+ ),
5144
+ metadata,
5145
+ dragRef: null,
5146
+ isEditing: false
5147
+ }
5148
+ });
5149
+ const renderItem = __spreadProps(__spreadValues({}, item), { props });
5150
+ const propsWithSlots = useSlots(config, renderItem, (props2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
5151
+ if (Component) {
5152
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Component.render, __spreadValues({}, propsWithSlots), renderItem.props.id);
5153
+ }
5154
+ return null;
5155
+ }) });
5156
+ }
5157
+
5158
+ // components/SlotRender/server.tsx
5159
+ var import_jsx_runtime22 = require("react/jsx-runtime");
5160
+ var SlotRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRender, __spreadValues({}, props));
5161
+ var Item = ({
5162
+ config,
5163
+ item,
5164
+ metadata
5165
+ }) => {
5166
+ const Component = config.components[item.type];
5167
+ const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
5168
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
5169
+ Component.render,
5170
+ __spreadProps(__spreadValues({}, props), {
5171
+ puck: __spreadProps(__spreadValues({}, props.puck), {
5172
+ renderDropZone: DropZoneRender,
5173
+ metadata: metadata || {}
5174
+ })
5175
+ })
5176
+ );
5177
+ };
5178
+ var SlotRender = (0, import_react31.forwardRef)(
5179
+ function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
5180
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
5181
+ if (!config.components[item.type]) {
5182
+ return null;
5183
+ }
5184
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
5185
+ Item,
5186
+ {
5187
+ config,
5188
+ item,
5189
+ metadata
5190
+ },
5191
+ item.props.id
5192
+ );
5193
+ }) });
5194
+ }
5195
+ );
5416
5196
 
5417
5197
  // components/SlotRender/index.tsx
5418
- init_react_import();
5419
- var import_shallow3 = require("zustand/react/shallow");
5420
5198
  var import_jsx_runtime23 = require("react/jsx-runtime");
5421
5199
  var ContextSlotRender = ({
5422
5200
  componentId,
@@ -5445,12 +5223,12 @@ var ContextSlotRender = ({
5445
5223
 
5446
5224
  // components/Render/index.tsx
5447
5225
  var import_jsx_runtime24 = require("react/jsx-runtime");
5448
- var renderContext = import_react34.default.createContext({
5226
+ var renderContext = import_react32.default.createContext({
5449
5227
  config: { components: {} },
5450
5228
  data: { root: {}, content: [] },
5451
5229
  metadata: {}
5452
5230
  });
5453
- function Render2({
5231
+ function Render({
5454
5232
  config,
5455
5233
  data,
5456
5234
  metadata = {}
@@ -5478,7 +5256,7 @@ function Render2({
5478
5256
  { type: "root", props: pageProps },
5479
5257
  (props) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata }))
5480
5258
  );
5481
- const nextContextValue = (0, import_react34.useMemo)(
5259
+ const nextContextValue = (0, import_react32.useMemo)(
5482
5260
  () => ({
5483
5261
  mode: "render",
5484
5262
  depth: 0
@@ -5507,9 +5285,9 @@ var DropZoneChild = ({
5507
5285
  }) => {
5508
5286
  var _a, _b;
5509
5287
  const metadata = useAppStore((s) => s.metadata);
5510
- const ctx = (0, import_react35.useContext)(dropZoneContext);
5288
+ const ctx = (0, import_react33.useContext)(dropZoneContext);
5511
5289
  const { depth = 1 } = ctx != null ? ctx : {};
5512
- const zoneStore = (0, import_react35.useContext)(ZoneStoreContext);
5290
+ const zoneStore = (0, import_react33.useContext)(ZoneStoreContext);
5513
5291
  const nodeProps = useAppStore(
5514
5292
  (0, import_shallow4.useShallow)((s) => {
5515
5293
  var _a2;
@@ -5529,7 +5307,7 @@ var DropZoneChild = ({
5529
5307
  })
5530
5308
  );
5531
5309
  const appStore = useAppStoreApi();
5532
- const item = (0, import_react35.useMemo)(() => {
5310
+ const item = (0, import_react33.useMemo)(() => {
5533
5311
  if (nodeProps) {
5534
5312
  const expanded = expandNode({
5535
5313
  type: nodeType,
@@ -5542,7 +5320,8 @@ var DropZoneChild = ({
5542
5320
  return {
5543
5321
  type: preview.componentType,
5544
5322
  props: preview.props,
5545
- previewType: preview.type
5323
+ previewType: preview.type,
5324
+ element: preview.element
5546
5325
  };
5547
5326
  }
5548
5327
  return null;
@@ -5550,7 +5329,7 @@ var DropZoneChild = ({
5550
5329
  const componentConfig = useAppStore(
5551
5330
  (s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
5552
5331
  );
5553
- const puckProps = (0, import_react35.useMemo)(
5332
+ const puckProps = (0, import_react33.useMemo)(
5554
5333
  () => ({
5555
5334
  renderDropZone: DropZoneEditPure,
5556
5335
  isEditing: true,
@@ -5573,13 +5352,19 @@ var DropZoneChild = ({
5573
5352
  }
5574
5353
  );
5575
5354
  let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
5576
- const renderPreview = (0, import_react35.useMemo)(
5355
+ const renderPreview = (0, import_react33.useMemo)(
5577
5356
  () => function Preview3() {
5357
+ if (item && "element" in item && item.element) {
5358
+ return (
5359
+ // Safe to use this since the HTML is set by the user
5360
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { dangerouslySetInnerHTML: { __html: item.element.outerHTML } })
5361
+ );
5362
+ }
5578
5363
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DrawerItemInner, { name: label, children: overrides.componentItem });
5579
5364
  },
5580
5365
  [componentId, label, overrides]
5581
5366
  );
5582
- const defaultsProps = (0, import_react35.useMemo)(
5367
+ const defaultsProps = (0, import_react33.useMemo)(
5583
5368
  () => __spreadProps(__spreadValues(__spreadValues({}, componentConfig == null ? void 0 : componentConfig.defaultProps), item == null ? void 0 : item.props), {
5584
5369
  puck: puckProps,
5585
5370
  editMode: true
@@ -5587,7 +5372,7 @@ var DropZoneChild = ({
5587
5372
  }),
5588
5373
  [componentConfig == null ? void 0 : componentConfig.defaultProps, item == null ? void 0 : item.props, puckProps]
5589
5374
  );
5590
- const defaultedNode = (0, import_react35.useMemo)(
5375
+ const defaultedNode = (0, import_react33.useMemo)(
5591
5376
  () => {
5592
5377
  var _a2;
5593
5378
  return { type: (_a2 = item == null ? void 0 : item.type) != null ? _a2 : nodeType, props: defaultsProps };
@@ -5604,14 +5389,14 @@ var DropZoneChild = ({
5604
5389
  isLoading
5605
5390
  );
5606
5391
  if (!item) return;
5607
- let Render3 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
5392
+ let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
5608
5393
  "No configuration for ",
5609
5394
  item.type
5610
5395
  ] });
5611
5396
  let componentType = item.type;
5612
5397
  const isInserting = "previewType" in item ? item.previewType === "insert" : false;
5613
5398
  if (isInserting) {
5614
- Render3 = renderPreview;
5399
+ Render2 = renderPreview;
5615
5400
  }
5616
5401
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5617
5402
  DraggableComponent,
@@ -5628,18 +5413,18 @@ var DropZoneChild = ({
5628
5413
  userDragAxis: collisionAxis,
5629
5414
  inDroppableZone,
5630
5415
  children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isInserting ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5631
- Render3,
5416
+ Render2,
5632
5417
  __spreadProps(__spreadValues({}, defaultedPropsWithSlots), {
5633
5418
  puck: __spreadProps(__spreadValues({}, defaultedPropsWithSlots.puck), {
5634
5419
  dragRef
5635
5420
  })
5636
5421
  })
5637
- ) }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Render3, __spreadValues({}, defaultedPropsWithSlots)) })
5422
+ ) }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Render2, __spreadValues({}, defaultedPropsWithSlots)) })
5638
5423
  }
5639
5424
  );
5640
5425
  };
5641
- var DropZoneChildMemo = (0, import_react35.memo)(DropZoneChild);
5642
- var DropZoneEdit = (0, import_react35.forwardRef)(
5426
+ var DropZoneChildMemo = (0, import_react33.memo)(DropZoneChild);
5427
+ var DropZoneEdit = (0, import_react33.forwardRef)(
5643
5428
  function DropZoneEditInternal({
5644
5429
  zone,
5645
5430
  allow,
@@ -5649,7 +5434,8 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
5649
5434
  minEmptyHeight: userMinEmptyHeight = 128,
5650
5435
  collisionAxis
5651
5436
  }, userRef) {
5652
- const ctx = (0, import_react35.useContext)(dropZoneContext);
5437
+ const ctx = (0, import_react33.useContext)(dropZoneContext);
5438
+ const appStoreApi = useAppStoreApi();
5653
5439
  const {
5654
5440
  // These all need setting via context
5655
5441
  areaId,
@@ -5686,19 +5472,14 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
5686
5472
  return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
5687
5473
  })
5688
5474
  );
5689
- (0, import_react35.useEffect)(() => {
5475
+ (0, import_react33.useEffect)(() => {
5690
5476
  if (!zoneType || zoneType === "dropzone") {
5691
5477
  if (ctx == null ? void 0 : ctx.registerZone) {
5692
5478
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
5693
5479
  }
5694
- return () => {
5695
- if (ctx == null ? void 0 : ctx.unregisterZone) {
5696
- ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
5697
- }
5698
- };
5699
5480
  }
5700
- }, [zoneType]);
5701
- (0, import_react35.useEffect)(() => {
5481
+ }, [zoneType, appStoreApi]);
5482
+ (0, import_react33.useEffect)(() => {
5702
5483
  if (zoneType === "dropzone") {
5703
5484
  if (zoneCompound !== rootDroppableId) {
5704
5485
  console.warn(
@@ -5707,11 +5488,11 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
5707
5488
  }
5708
5489
  }
5709
5490
  }, [zoneType]);
5710
- const contentIds = (0, import_react35.useMemo)(() => {
5491
+ const contentIds = (0, import_react33.useMemo)(() => {
5711
5492
  return zoneContentIds || [];
5712
5493
  }, [zoneContentIds]);
5713
- const ref = (0, import_react35.useRef)(null);
5714
- const acceptsTarget = (0, import_react35.useCallback)(
5494
+ const ref = (0, import_react33.useRef)(null);
5495
+ const acceptsTarget = (0, import_react33.useCallback)(
5715
5496
  (componentType) => {
5716
5497
  if (!componentType) {
5717
5498
  return true;
@@ -5749,7 +5530,7 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
5749
5530
  }
5750
5531
  return _isEnabled;
5751
5532
  });
5752
- (0, import_react35.useEffect)(() => {
5533
+ (0, import_react33.useEffect)(() => {
5753
5534
  if (registerLocalZone) {
5754
5535
  registerLocalZone(zoneCompound, targetAccepted || isEnabled);
5755
5536
  }
@@ -5764,8 +5545,8 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
5764
5545
  zoneCompound
5765
5546
  );
5766
5547
  const isDropEnabled = isEnabled && (preview ? contentIdsWithPreview.length === 1 : contentIdsWithPreview.length === 0);
5767
- const zoneStore = (0, import_react35.useContext)(ZoneStoreContext);
5768
- (0, import_react35.useEffect)(() => {
5548
+ const zoneStore = (0, import_react33.useContext)(ZoneStoreContext);
5549
+ (0, import_react33.useEffect)(() => {
5769
5550
  const { enabledIndex } = zoneStore.getState();
5770
5551
  zoneStore.setState({
5771
5552
  enabledIndex: __spreadProps(__spreadValues({}, enabledIndex), { [zoneCompound]: isEnabled })
@@ -5784,7 +5565,7 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
5784
5565
  path: path || []
5785
5566
  }
5786
5567
  };
5787
- const { ref: dropRef } = (0, import_react36.useDroppable)(droppableConfig);
5568
+ const { ref: dropRef } = (0, import_react34.useDroppable)(droppableConfig);
5788
5569
  const isAreaSelected = useAppStore(
5789
5570
  (s) => (s == null ? void 0 : s.selectedItem) && areaId === (s == null ? void 0 : s.selectedItem.props.id)
5790
5571
  );
@@ -5839,7 +5620,7 @@ var DropZoneRenderItem = ({
5839
5620
  }) => {
5840
5621
  const Component = config.components[item.type];
5841
5622
  const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
5842
- const nextContextValue = (0, import_react35.useMemo)(
5623
+ const nextContextValue = (0, import_react33.useMemo)(
5843
5624
  () => ({
5844
5625
  areaId: props.id,
5845
5626
  depth: 1
@@ -5857,23 +5638,18 @@ var DropZoneRenderItem = ({
5857
5638
  ) }, props.id);
5858
5639
  };
5859
5640
  var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneRender2, __spreadValues({}, props));
5860
- var DropZoneRender2 = (0, import_react35.forwardRef)(
5641
+ var DropZoneRender2 = (0, import_react33.forwardRef)(
5861
5642
  function DropZoneRenderInternal({ className, style, zone }, ref) {
5862
- const ctx = (0, import_react35.useContext)(dropZoneContext);
5643
+ const ctx = (0, import_react33.useContext)(dropZoneContext);
5863
5644
  const { areaId = "root" } = ctx || {};
5864
- const { config, data, metadata } = (0, import_react35.useContext)(renderContext);
5645
+ const { config, data, metadata } = (0, import_react33.useContext)(renderContext);
5865
5646
  let zoneCompound = `${areaId}:${zone}`;
5866
5647
  let content = (data == null ? void 0 : data.content) || [];
5867
- (0, import_react35.useEffect)(() => {
5648
+ (0, import_react33.useEffect)(() => {
5868
5649
  if (!content) {
5869
5650
  if (ctx == null ? void 0 : ctx.registerZone) {
5870
5651
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
5871
5652
  }
5872
- return () => {
5873
- if (ctx == null ? void 0 : ctx.unregisterZone) {
5874
- ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
5875
- }
5876
- };
5877
5653
  }
5878
5654
  }, [content]);
5879
5655
  if (!data || !config) {
@@ -5900,9 +5676,9 @@ var DropZoneRender2 = (0, import_react35.forwardRef)(
5900
5676
  }
5901
5677
  );
5902
5678
  var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZone, __spreadValues({}, props));
5903
- var DropZone = (0, import_react35.forwardRef)(
5679
+ var DropZone = (0, import_react33.forwardRef)(
5904
5680
  function DropZone2(props, ref) {
5905
- const ctx = (0, import_react35.useContext)(dropZoneContext);
5681
+ const ctx = (0, import_react33.useContext)(dropZoneContext);
5906
5682
  if ((ctx == null ? void 0 : ctx.mode) === "edit") {
5907
5683
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
5908
5684
  }
@@ -6134,6 +5910,7 @@ var findDeepestCandidate = (position, manager) => {
6134
5910
  });
6135
5911
  filteredCandidates.reverse();
6136
5912
  const primaryCandidate = filteredCandidates[0];
5913
+ if (!primaryCandidate) return { zone: null, area: null };
6137
5914
  const primaryCandidateData = primaryCandidate.data;
6138
5915
  const primaryCandidateIsComponent = "containsActiveZone" in primaryCandidateData;
6139
5916
  const zone = getZoneId2(primaryCandidate);
@@ -6243,12 +6020,12 @@ function getDeepDir(el) {
6243
6020
  var import_state = require("@dnd-kit/state");
6244
6021
  var import_jsx_runtime26 = require("react/jsx-runtime");
6245
6022
  var DEBUG3 = false;
6246
- var dragListenerContext = (0, import_react38.createContext)({
6023
+ var dragListenerContext = (0, import_react36.createContext)({
6247
6024
  dragListeners: {}
6248
6025
  });
6249
6026
  function useDragListener(type, fn, deps = []) {
6250
- const { setDragListeners } = (0, import_react38.useContext)(dragListenerContext);
6251
- (0, import_react38.useEffect)(() => {
6027
+ const { setDragListeners } = (0, import_react36.useContext)(dragListenerContext);
6028
+ (0, import_react36.useEffect)(() => {
6252
6029
  if (setDragListeners) {
6253
6030
  setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
6254
6031
  [type]: [...old[type] || [], fn]
@@ -6258,8 +6035,8 @@ function useDragListener(type, fn, deps = []) {
6258
6035
  }
6259
6036
  var AREA_CHANGE_DEBOUNCE_MS = 100;
6260
6037
  var useTempDisableFallback = (timeout3) => {
6261
- const lastFallbackDisable = (0, import_react38.useRef)(null);
6262
- return (0, import_react38.useCallback)((manager) => {
6038
+ const lastFallbackDisable = (0, import_react36.useRef)(null);
6039
+ return (0, import_react36.useCallback)((manager) => {
6263
6040
  collisionStore.setState({ fallbackEnabled: false });
6264
6041
  const fallbackId = generateId();
6265
6042
  lastFallbackDisable.current = fallbackId;
@@ -6278,9 +6055,9 @@ var DragDropContextClient = ({
6278
6055
  const dispatch = useAppStore((s) => s.dispatch);
6279
6056
  const appStore = useAppStoreApi();
6280
6057
  const id = useSafeId();
6281
- const debouncedParamsRef = (0, import_react38.useRef)(null);
6058
+ const debouncedParamsRef = (0, import_react36.useRef)(null);
6282
6059
  const tempDisableFallback = useTempDisableFallback(100);
6283
- const [zoneStore] = (0, import_react38.useState)(
6060
+ const [zoneStore] = (0, import_react36.useState)(
6284
6061
  () => (0, import_zustand5.createStore)(() => ({
6285
6062
  zoneDepthIndex: {},
6286
6063
  nextZoneDepthIndex: {},
@@ -6292,7 +6069,7 @@ var DragDropContextClient = ({
6292
6069
  hoveringComponent: null
6293
6070
  }))
6294
6071
  );
6295
- const getChanged2 = (0, import_react38.useCallback)(
6072
+ const getChanged2 = (0, import_react36.useCallback)(
6296
6073
  (params, id2) => {
6297
6074
  const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
6298
6075
  const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
@@ -6313,7 +6090,7 @@ var DragDropContextClient = ({
6313
6090
  },
6314
6091
  [zoneStore]
6315
6092
  );
6316
- const setDeepestAndCollide = (0, import_react38.useCallback)(
6093
+ const setDeepestAndCollide = (0, import_react36.useCallback)(
6317
6094
  (params, manager) => {
6318
6095
  const { zoneChanged, areaChanged } = getChanged2(params, id);
6319
6096
  if (!zoneChanged && !areaChanged) return;
@@ -6337,7 +6114,7 @@ var DragDropContextClient = ({
6337
6114
  setDeepestDb.cancel();
6338
6115
  debouncedParamsRef.current = null;
6339
6116
  };
6340
- (0, import_react38.useEffect)(() => {
6117
+ (0, import_react36.useEffect)(() => {
6341
6118
  if (DEBUG3) {
6342
6119
  zoneStore.subscribe(
6343
6120
  (s) => {
@@ -6351,7 +6128,7 @@ var DragDropContextClient = ({
6351
6128
  );
6352
6129
  }
6353
6130
  }, []);
6354
- const [plugins] = (0, import_react38.useState)(() => [
6131
+ const [plugins] = (0, import_react36.useState)(() => [
6355
6132
  ...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
6356
6133
  createNestedDroppablePlugin(
6357
6134
  {
@@ -6399,10 +6176,10 @@ var DragDropContextClient = ({
6399
6176
  )
6400
6177
  ]);
6401
6178
  const sensors = useSensors();
6402
- const [dragListeners, setDragListeners] = (0, import_react38.useState)({});
6403
- const dragMode = (0, import_react38.useRef)(null);
6404
- const initialSelector = (0, import_react38.useRef)(void 0);
6405
- const nextContextValue = (0, import_react38.useMemo)(
6179
+ const [dragListeners, setDragListeners] = (0, import_react36.useState)({});
6180
+ const dragMode = (0, import_react36.useRef)(null);
6181
+ const initialSelector = (0, import_react36.useRef)(void 0);
6182
+ const nextContextValue = (0, import_react36.useMemo)(
6406
6183
  () => ({
6407
6184
  mode: "edit",
6408
6185
  areaId: "root",
@@ -6418,7 +6195,7 @@ var DragDropContextClient = ({
6418
6195
  setDragListeners
6419
6196
  },
6420
6197
  children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
6421
- import_react37.DragDropProvider,
6198
+ import_react35.DragDropProvider,
6422
6199
  {
6423
6200
  plugins,
6424
6201
  sensors,
@@ -6538,6 +6315,7 @@ var DragDropContextClient = ({
6538
6315
  type: "insert",
6539
6316
  index: targetIndex,
6540
6317
  zone: targetZone,
6318
+ element: source.element,
6541
6319
  props: {
6542
6320
  id: source.id.toString()
6543
6321
  }
@@ -6563,7 +6341,8 @@ var DragDropContextClient = ({
6563
6341
  type: "move",
6564
6342
  index: targetIndex,
6565
6343
  zone: targetZone,
6566
- props: item.props
6344
+ props: item.props,
6345
+ element: source.element
6567
6346
  }
6568
6347
  }
6569
6348
  });
@@ -6593,7 +6372,8 @@ var DragDropContextClient = ({
6593
6372
  type: "move",
6594
6373
  index: sourceData.index,
6595
6374
  zone: sourceData.zone,
6596
- props: item.props
6375
+ props: item.props,
6376
+ element: source.element
6597
6377
  }
6598
6378
  }
6599
6379
  });
@@ -6648,7 +6428,7 @@ var DragDropContext = ({
6648
6428
  };
6649
6429
 
6650
6430
  // components/Drawer/index.tsx
6651
- var import_react40 = require("@dnd-kit/react");
6431
+ var import_react38 = require("@dnd-kit/react");
6652
6432
  var import_jsx_runtime27 = require("react/jsx-runtime");
6653
6433
  var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
6654
6434
  var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
@@ -6659,7 +6439,7 @@ var DrawerItemInner = ({
6659
6439
  dragRef,
6660
6440
  isDragDisabled
6661
6441
  }) => {
6662
- const CustomInner = (0, import_react39.useMemo)(
6442
+ const CustomInner = (0, import_react37.useMemo)(
6663
6443
  () => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
6664
6444
  [children]
6665
6445
  );
@@ -6685,7 +6465,7 @@ var DrawerItemDraggable = ({
6685
6465
  id,
6686
6466
  isDragDisabled
6687
6467
  }) => {
6688
- const { ref } = (0, import_react40.useDraggable)({
6468
+ const { ref } = (0, import_react38.useDraggable)({
6689
6469
  id,
6690
6470
  data: { componentType: name },
6691
6471
  disabled: isDragDisabled,
@@ -6714,7 +6494,7 @@ var DrawerItem = ({
6714
6494
  isDragDisabled
6715
6495
  }) => {
6716
6496
  const resolvedId = id || name;
6717
- const [dynamicId, setDynamicId] = (0, import_react39.useState)(generateId(resolvedId));
6497
+ const [dynamicId, setDynamicId] = (0, import_react37.useState)(generateId(resolvedId));
6718
6498
  if (typeof index !== "undefined") {
6719
6499
  console.error(
6720
6500
  "Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
@@ -6754,7 +6534,7 @@ var Drawer = ({
6754
6534
  );
6755
6535
  }
6756
6536
  const id = useSafeId();
6757
- const { ref } = (0, import_react40.useDroppable)({
6537
+ const { ref } = (0, import_react38.useDroppable)({
6758
6538
  id,
6759
6539
  type: "void",
6760
6540
  collisionPriority: 0
@@ -6776,7 +6556,7 @@ Drawer.Item = DrawerItem;
6776
6556
 
6777
6557
  // components/Puck/index.tsx
6778
6558
  init_react_import();
6779
- var import_react56 = require("react");
6559
+ var import_react54 = require("react");
6780
6560
 
6781
6561
  // components/SidebarSection/index.tsx
6782
6562
  init_react_import();
@@ -6787,7 +6567,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "Si
6787
6567
 
6788
6568
  // lib/use-breadcrumbs.ts
6789
6569
  init_react_import();
6790
- var import_react41 = require("react");
6570
+ var import_react39 = require("react");
6791
6571
  var useBreadcrumbs = (renderCount) => {
6792
6572
  const selectedId = useAppStore((s) => {
6793
6573
  var _a;
@@ -6799,7 +6579,7 @@ var useBreadcrumbs = (renderCount) => {
6799
6579
  return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
6800
6580
  });
6801
6581
  const appStore = useAppStoreApi();
6802
- return (0, import_react41.useMemo)(() => {
6582
+ return (0, import_react39.useMemo)(() => {
6803
6583
  const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
6804
6584
  var _a, _b, _c;
6805
6585
  const [componentId] = zoneCompound.split(":");
@@ -6883,7 +6663,7 @@ init_react_import();
6883
6663
  var styles_module_default15 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
6884
6664
 
6885
6665
  // components/Puck/components/Fields/index.tsx
6886
- var import_react42 = require("react");
6666
+ var import_react40 = require("react");
6887
6667
  var import_shallow5 = require("zustand/react/shallow");
6888
6668
  var import_jsx_runtime29 = require("react/jsx-runtime");
6889
6669
  var getClassName20 = get_class_name_factory_default("PuckFields", styles_module_default15);
@@ -6956,7 +6736,7 @@ var FieldsChild = ({ fieldName }) => {
6956
6736
  })
6957
6737
  );
6958
6738
  const appStore = useAppStoreApi();
6959
- const onChange = (0, import_react42.useCallback)(createOnChange(fieldName, appStore), [
6739
+ const onChange = (0, import_react40.useCallback)(createOnChange(fieldName, appStore), [
6960
6740
  fieldName
6961
6741
  ]);
6962
6742
  const { visible = true } = field != null ? field : {};
@@ -6974,7 +6754,7 @@ var FieldsChild = ({ fieldName }) => {
6974
6754
  }
6975
6755
  ) }, id);
6976
6756
  };
6977
- var FieldsChildMemo = (0, import_react42.memo)(FieldsChild);
6757
+ var FieldsChildMemo = (0, import_react40.memo)(FieldsChild);
6978
6758
  var FieldsInternal = ({ wrapFields = true }) => {
6979
6759
  const overrides = useAppStore((s) => s.overrides);
6980
6760
  const componentResolving = useAppStore((s) => {
@@ -6999,7 +6779,7 @@ var FieldsInternal = ({ wrapFields = true }) => {
6999
6779
  })
7000
6780
  );
7001
6781
  const isLoading = fieldsLoading || componentResolving;
7002
- const Wrapper = (0, import_react42.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
6782
+ const Wrapper = (0, import_react40.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
7003
6783
  return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
7004
6784
  "form",
7005
6785
  {
@@ -7014,14 +6794,14 @@ var FieldsInternal = ({ wrapFields = true }) => {
7014
6794
  }
7015
6795
  );
7016
6796
  };
7017
- var Fields = (0, import_react42.memo)(FieldsInternal);
6797
+ var Fields = (0, import_react40.memo)(FieldsInternal);
7018
6798
 
7019
6799
  // components/Puck/components/Components/index.tsx
7020
6800
  init_react_import();
7021
6801
 
7022
6802
  // lib/use-component-list.tsx
7023
6803
  init_react_import();
7024
- var import_react43 = require("react");
6804
+ var import_react41 = require("react");
7025
6805
 
7026
6806
  // components/ComponentList/index.tsx
7027
6807
  init_react_import();
@@ -7092,10 +6872,10 @@ ComponentList.Item = ComponentListItem;
7092
6872
  // lib/use-component-list.tsx
7093
6873
  var import_jsx_runtime31 = require("react/jsx-runtime");
7094
6874
  var useComponentList = () => {
7095
- const [componentList, setComponentList] = (0, import_react43.useState)();
6875
+ const [componentList, setComponentList] = (0, import_react41.useState)();
7096
6876
  const config = useAppStore((s) => s.config);
7097
6877
  const uiComponentList = useAppStore((s) => s.state.ui.componentList);
7098
- (0, import_react43.useEffect)(() => {
6878
+ (0, import_react41.useEffect)(() => {
7099
6879
  var _a, _b, _c;
7100
6880
  if (Object.keys(uiComponentList).length > 0) {
7101
6881
  const matchedComponents = [];
@@ -7164,22 +6944,22 @@ var useComponentList = () => {
7164
6944
  };
7165
6945
 
7166
6946
  // components/Puck/components/Components/index.tsx
7167
- var import_react44 = require("react");
6947
+ var import_react42 = require("react");
7168
6948
  var import_jsx_runtime32 = require("react/jsx-runtime");
7169
6949
  var Components = () => {
7170
6950
  const overrides = useAppStore((s) => s.overrides);
7171
6951
  const componentList = useComponentList();
7172
- const Wrapper = (0, import_react44.useMemo)(() => overrides.components || "div", [overrides]);
6952
+ const Wrapper = (0, import_react42.useMemo)(() => overrides.components || "div", [overrides]);
7173
6953
  return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ComponentList, { id: "all" }) });
7174
6954
  };
7175
6955
 
7176
6956
  // components/Puck/components/Preview/index.tsx
7177
6957
  init_react_import();
7178
- var import_react46 = require("react");
6958
+ var import_react44 = require("react");
7179
6959
 
7180
6960
  // components/AutoFrame/index.tsx
7181
6961
  init_react_import();
7182
- var import_react45 = require("react");
6962
+ var import_react43 = require("react");
7183
6963
  var import_object_hash = __toESM(require("object-hash"));
7184
6964
  var import_react_dom3 = require("react-dom");
7185
6965
  var import_jsx_runtime33 = require("react/jsx-runtime");
@@ -7232,7 +7012,7 @@ var CopyHostStyles = ({
7232
7012
  onStylesLoaded = () => null
7233
7013
  }) => {
7234
7014
  const { document: doc, window: win } = useFrame();
7235
- (0, import_react45.useEffect)(() => {
7015
+ (0, import_react43.useEffect)(() => {
7236
7016
  if (!win || !doc) {
7237
7017
  return () => {
7238
7018
  };
@@ -7391,8 +7171,8 @@ var CopyHostStyles = ({
7391
7171
  }, []);
7392
7172
  return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children });
7393
7173
  };
7394
- var autoFrameContext = (0, import_react45.createContext)({});
7395
- var useFrame = () => (0, import_react45.useContext)(autoFrameContext);
7174
+ var autoFrameContext = (0, import_react43.createContext)({});
7175
+ var useFrame = () => (0, import_react43.useContext)(autoFrameContext);
7396
7176
  function AutoFrame(_a) {
7397
7177
  var _b = _a, {
7398
7178
  children,
@@ -7413,11 +7193,11 @@ function AutoFrame(_a) {
7413
7193
  "onNotReady",
7414
7194
  "frameRef"
7415
7195
  ]);
7416
- const [loaded, setLoaded] = (0, import_react45.useState)(false);
7417
- const [ctx, setCtx] = (0, import_react45.useState)({});
7418
- const [mountTarget, setMountTarget] = (0, import_react45.useState)();
7419
- const [stylesLoaded, setStylesLoaded] = (0, import_react45.useState)(false);
7420
- (0, import_react45.useEffect)(() => {
7196
+ const [loaded, setLoaded] = (0, import_react43.useState)(false);
7197
+ const [ctx, setCtx] = (0, import_react43.useState)({});
7198
+ const [mountTarget, setMountTarget] = (0, import_react43.useState)();
7199
+ const [stylesLoaded, setStylesLoaded] = (0, import_react43.useState)(false);
7200
+ (0, import_react43.useEffect)(() => {
7421
7201
  var _a2;
7422
7202
  if (frameRef.current) {
7423
7203
  const doc = frameRef.current.contentDocument;
@@ -7469,7 +7249,7 @@ var import_jsx_runtime34 = require("react/jsx-runtime");
7469
7249
  var getClassName22 = get_class_name_factory_default("PuckPreview", styles_module_default17);
7470
7250
  var useBubbleIframeEvents = (ref) => {
7471
7251
  const status = useAppStore((s) => s.status);
7472
- (0, import_react46.useEffect)(() => {
7252
+ (0, import_react44.useEffect)(() => {
7473
7253
  if (ref.current && status === "READY") {
7474
7254
  const iframe = ref.current;
7475
7255
  const handlePointerMove = (event) => {
@@ -7518,7 +7298,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
7518
7298
  const renderData = useAppStore(
7519
7299
  (s) => s.state.ui.previewMode === "edit" ? null : s.state.data
7520
7300
  );
7521
- const Page = (0, import_react46.useCallback)(
7301
+ const Page = (0, import_react44.useCallback)(
7522
7302
  (pageProps) => {
7523
7303
  var _a, _b;
7524
7304
  const propsWithSlots = useSlots(
@@ -7532,9 +7312,9 @@ var Preview2 = ({ id = "puck-preview" }) => {
7532
7312
  },
7533
7313
  [config]
7534
7314
  );
7535
- const Frame = (0, import_react46.useMemo)(() => overrides.iframe, [overrides]);
7315
+ const Frame = (0, import_react44.useMemo)(() => overrides.iframe, [overrides]);
7536
7316
  const rootProps = root.props || root;
7537
- const ref = (0, import_react46.useRef)(null);
7317
+ const ref = (0, import_react44.useRef)(null);
7538
7318
  useBubbleIframeEvents(ref);
7539
7319
  const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7540
7320
  Page,
@@ -7548,8 +7328,8 @@ var Preview2 = ({ id = "puck-preview" }) => {
7548
7328
  editMode: true,
7549
7329
  children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(DropZonePure, { zone: rootDroppableId })
7550
7330
  })
7551
- ) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Render2, { data: renderData, config });
7552
- (0, import_react46.useEffect)(() => {
7331
+ ) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Render, { data: renderData, config, metadata });
7332
+ (0, import_react44.useEffect)(() => {
7553
7333
  if (!iframe.enabled) {
7554
7334
  setStatus("READY");
7555
7335
  }
@@ -7619,7 +7399,7 @@ var scrollIntoView = (el) => {
7619
7399
  };
7620
7400
 
7621
7401
  // components/LayerTree/index.tsx
7622
- var import_react47 = require("react");
7402
+ var import_react45 = require("react");
7623
7403
 
7624
7404
  // lib/on-scroll-end.ts
7625
7405
  init_react_import();
@@ -7654,7 +7434,7 @@ var Layer = ({
7654
7434
  const config = useAppStore((s) => s.config);
7655
7435
  const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
7656
7436
  const dispatch = useAppStore((s) => s.dispatch);
7657
- const setItemSelector = (0, import_react47.useCallback)(
7437
+ const setItemSelector = (0, import_react45.useCallback)(
7658
7438
  (itemSelector2) => {
7659
7439
  dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
7660
7440
  },
@@ -7674,7 +7454,7 @@ var Layer = ({
7674
7454
  )
7675
7455
  );
7676
7456
  const containsZone = zonesForItem.length > 0;
7677
- const zoneStore = (0, import_react47.useContext)(ZoneStoreContext);
7457
+ const zoneStore = (0, import_react45.useContext)(ZoneStoreContext);
7678
7458
  const isHovering = useContextStore(
7679
7459
  ZoneStoreContext,
7680
7460
  (s) => s.hoveringComponent === itemId
@@ -7801,7 +7581,7 @@ var LayerTree = ({
7801
7581
  };
7802
7582
 
7803
7583
  // components/Puck/components/Outline/index.tsx
7804
- var import_react48 = require("react");
7584
+ var import_react46 = require("react");
7805
7585
 
7806
7586
  // lib/data/find-zones-for-area.ts
7807
7587
  init_react_import();
@@ -7819,7 +7599,7 @@ var Outline = () => {
7819
7599
  const rootZones = useAppStore(
7820
7600
  (0, import_shallow7.useShallow)((s) => findZonesForArea(s.state, "root"))
7821
7601
  );
7822
- const Wrapper = (0, import_react48.useMemo)(() => outlineOverride || "div", [outlineOverride]);
7602
+ const Wrapper = (0, import_react46.useMemo)(() => outlineOverride || "div", [outlineOverride]);
7823
7603
  return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7824
7604
  LayerTree,
7825
7605
  {
@@ -7953,11 +7733,11 @@ var getBox = function getBox2(el) {
7953
7733
  };
7954
7734
 
7955
7735
  // components/Puck/components/Canvas/index.tsx
7956
- var import_react50 = require("react");
7736
+ var import_react48 = require("react");
7957
7737
 
7958
7738
  // components/ViewportControls/index.tsx
7959
7739
  init_react_import();
7960
- var import_react49 = require("react");
7740
+ var import_react47 = require("react");
7961
7741
 
7962
7742
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
7963
7743
  init_react_import();
@@ -7980,8 +7760,8 @@ var ViewportButton = ({
7980
7760
  onClick
7981
7761
  }) => {
7982
7762
  const viewports = useAppStore((s) => s.state.ui.viewports);
7983
- const [isActive, setIsActive] = (0, import_react49.useState)(false);
7984
- (0, import_react49.useEffect)(() => {
7763
+ const [isActive, setIsActive] = (0, import_react47.useState)(false);
7764
+ (0, import_react47.useEffect)(() => {
7985
7765
  setIsActive(width === viewports.current.width);
7986
7766
  }, [width, viewports.current.width]);
7987
7767
  return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
@@ -8018,7 +7798,7 @@ var ViewportControls = ({
8018
7798
  const defaultsContainAutoZoom = defaultZoomOptions.find(
8019
7799
  (option) => option.value === autoZoom
8020
7800
  );
8021
- const zoomOptions = (0, import_react49.useMemo)(
7801
+ const zoomOptions = (0, import_react47.useMemo)(
8022
7802
  () => [
8023
7803
  ...defaultZoomOptions,
8024
7804
  ...defaultsContainAutoZoom ? [] : [
@@ -8167,17 +7947,17 @@ var Canvas = () => {
8167
7947
  viewports: s.state.ui.viewports
8168
7948
  }))
8169
7949
  );
8170
- const frameRef = (0, import_react50.useRef)(null);
8171
- const [showTransition, setShowTransition] = (0, import_react50.useState)(false);
8172
- const defaultRender = (0, import_react50.useMemo)(() => {
7950
+ const frameRef = (0, import_react48.useRef)(null);
7951
+ const [showTransition, setShowTransition] = (0, import_react48.useState)(false);
7952
+ const defaultRender = (0, import_react48.useMemo)(() => {
8173
7953
  const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children });
8174
7954
  return PuckDefault;
8175
7955
  }, []);
8176
- const CustomPreview = (0, import_react50.useMemo)(
7956
+ const CustomPreview = (0, import_react48.useMemo)(
8177
7957
  () => overrides.preview || defaultRender,
8178
7958
  [overrides]
8179
7959
  );
8180
- const getFrameDimensions = (0, import_react50.useCallback)(() => {
7960
+ const getFrameDimensions = (0, import_react48.useCallback)(() => {
8181
7961
  if (frameRef.current) {
8182
7962
  const frame = frameRef.current;
8183
7963
  const box = getBox(frame);
@@ -8185,7 +7965,7 @@ var Canvas = () => {
8185
7965
  }
8186
7966
  return { width: 0, height: 0 };
8187
7967
  }, [frameRef]);
8188
- const resetAutoZoom = (0, import_react50.useCallback)(
7968
+ const resetAutoZoom = (0, import_react48.useCallback)(
8189
7969
  (newViewports = viewports) => {
8190
7970
  if (frameRef.current) {
8191
7971
  setZoomConfig(
@@ -8199,11 +7979,11 @@ var Canvas = () => {
8199
7979
  },
8200
7980
  [frameRef, zoomConfig, viewports]
8201
7981
  );
8202
- (0, import_react50.useEffect)(() => {
7982
+ (0, import_react48.useEffect)(() => {
8203
7983
  setShowTransition(false);
8204
7984
  resetAutoZoom(viewports);
8205
7985
  }, [frameRef, leftSideBarVisible, rightSideBarVisible]);
8206
- (0, import_react50.useEffect)(() => {
7986
+ (0, import_react48.useEffect)(() => {
8207
7987
  const { height: frameHeight } = getFrameDimensions();
8208
7988
  if (viewports.current.height === "auto") {
8209
7989
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -8211,13 +7991,13 @@ var Canvas = () => {
8211
7991
  }));
8212
7992
  }
8213
7993
  }, [zoomConfig.zoom]);
8214
- (0, import_react50.useEffect)(() => {
7994
+ (0, import_react48.useEffect)(() => {
8215
7995
  if (ZOOM_ON_CHANGE) {
8216
7996
  setShowTransition(true);
8217
7997
  resetAutoZoom(viewports);
8218
7998
  }
8219
7999
  }, [viewports.current.width]);
8220
- (0, import_react50.useEffect)(() => {
8000
+ (0, import_react48.useEffect)(() => {
8221
8001
  const cb = () => {
8222
8002
  setShowTransition(false);
8223
8003
  resetAutoZoom();
@@ -8227,8 +8007,8 @@ var Canvas = () => {
8227
8007
  window.removeEventListener("resize", cb);
8228
8008
  };
8229
8009
  }, []);
8230
- const [showLoader, setShowLoader] = (0, import_react50.useState)(false);
8231
- (0, import_react50.useEffect)(() => {
8010
+ const [showLoader, setShowLoader] = (0, import_react48.useState)(false);
8011
+ (0, import_react48.useEffect)(() => {
8232
8012
  setTimeout(() => {
8233
8013
  setShowLoader(true);
8234
8014
  }, 500);
@@ -8306,7 +8086,7 @@ var Canvas = () => {
8306
8086
 
8307
8087
  // lib/use-loaded-overrides.ts
8308
8088
  init_react_import();
8309
- var import_react51 = require("react");
8089
+ var import_react49 = require("react");
8310
8090
 
8311
8091
  // lib/load-overrides.ts
8312
8092
  init_react_import();
@@ -8345,7 +8125,7 @@ var useLoadedOverrides = ({
8345
8125
  overrides,
8346
8126
  plugins
8347
8127
  }) => {
8348
- return (0, import_react51.useMemo)(() => {
8128
+ return (0, import_react49.useMemo)(() => {
8349
8129
  return loadOverrides({ overrides, plugins });
8350
8130
  }, [plugins, overrides]);
8351
8131
  };
@@ -8357,14 +8137,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime39
8357
8137
 
8358
8138
  // lib/use-inject-css.ts
8359
8139
  init_react_import();
8360
- var import_react52 = require("react");
8140
+ var import_react50 = require("react");
8361
8141
  var styles = ``;
8362
8142
  var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
8363
- const [el, setEl] = (0, import_react52.useState)();
8364
- (0, import_react52.useEffect)(() => {
8143
+ const [el, setEl] = (0, import_react50.useState)();
8144
+ (0, import_react50.useEffect)(() => {
8365
8145
  setEl(document.createElement("style"));
8366
8146
  }, []);
8367
- (0, import_react52.useEffect)(() => {
8147
+ (0, import_react50.useEffect)(() => {
8368
8148
  var _a;
8369
8149
  if (!el || typeof window === "undefined") {
8370
8150
  return;
@@ -8384,10 +8164,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
8384
8164
 
8385
8165
  // lib/use-preview-mode-hotkeys.ts
8386
8166
  init_react_import();
8387
- var import_react53 = require("react");
8167
+ var import_react51 = require("react");
8388
8168
  var usePreviewModeHotkeys = () => {
8389
8169
  const appStore = useAppStoreApi();
8390
- const toggleInteractive = (0, import_react53.useCallback)(() => {
8170
+ const toggleInteractive = (0, import_react51.useCallback)(() => {
8391
8171
  const dispatch = appStore.getState().dispatch;
8392
8172
  dispatch({
8393
8173
  type: "setUi",
@@ -8402,7 +8182,7 @@ var usePreviewModeHotkeys = () => {
8402
8182
 
8403
8183
  // lib/use-puck.ts
8404
8184
  init_react_import();
8405
- var import_react54 = require("react");
8185
+ var import_react52 = require("react");
8406
8186
  var import_zustand6 = require("zustand");
8407
8187
  var generateUsePuck = (store) => {
8408
8188
  const history = {
@@ -8433,10 +8213,9 @@ var generateUsePuck = (store) => {
8433
8213
  return { zone: zoneCompound, index };
8434
8214
  }
8435
8215
  };
8436
- const get = () => storeData;
8437
- return __spreadProps(__spreadValues({}, storeData), { get });
8216
+ return storeData;
8438
8217
  };
8439
- var UsePuckStoreContext = (0, import_react54.createContext)(
8218
+ var UsePuckStoreContext = (0, import_react52.createContext)(
8440
8219
  null
8441
8220
  );
8442
8221
  var convertToPickedStore = (store) => {
@@ -8450,12 +8229,12 @@ var convertToPickedStore = (store) => {
8450
8229
  };
8451
8230
  };
8452
8231
  var useRegisterUsePuckStore = (appStore) => {
8453
- const [usePuckStore] = (0, import_react54.useState)(
8232
+ const [usePuckStore] = (0, import_react52.useState)(
8454
8233
  () => (0, import_zustand6.createStore)(
8455
8234
  () => generateUsePuck(convertToPickedStore(appStore.getState()))
8456
8235
  )
8457
8236
  );
8458
- (0, import_react54.useEffect)(() => {
8237
+ (0, import_react52.useEffect)(() => {
8459
8238
  return appStore.subscribe(
8460
8239
  (store) => convertToPickedStore(store),
8461
8240
  (pickedStore) => {
@@ -8467,7 +8246,7 @@ var useRegisterUsePuckStore = (appStore) => {
8467
8246
  };
8468
8247
  function createUsePuck() {
8469
8248
  return function usePuck2(selector) {
8470
- const usePuckApi = (0, import_react54.useContext)(UsePuckStoreContext);
8249
+ const usePuckApi = (0, import_react52.useContext)(UsePuckStoreContext);
8471
8250
  if (!usePuckApi) {
8472
8251
  throw new Error("usePuck must be used inside <Puck>.");
8473
8252
  }
@@ -8479,7 +8258,7 @@ function createUsePuck() {
8479
8258
  };
8480
8259
  }
8481
8260
  function usePuck() {
8482
- (0, import_react54.useEffect)(() => {
8261
+ (0, import_react52.useEffect)(() => {
8483
8262
  console.warn(
8484
8263
  "You're using the `usePuck` method without a selector, which may cause unnecessary re-renders. Replace with `createUsePuck` and provide a selector for improved performance."
8485
8264
  );
@@ -8487,7 +8266,7 @@ function usePuck() {
8487
8266
  return createUsePuck()((s) => s);
8488
8267
  }
8489
8268
  function useGetPuck() {
8490
- const usePuckApi = (0, import_react54.useContext)(UsePuckStoreContext);
8269
+ const usePuckApi = (0, import_react52.useContext)(UsePuckStoreContext);
8491
8270
  if (!usePuckApi) {
8492
8271
  throw new Error("usePuckGet must be used inside <Puck>.");
8493
8272
  }
@@ -8499,7 +8278,7 @@ var import_fast_deep_equal3 = __toESM(require("fast-deep-equal"));
8499
8278
 
8500
8279
  // components/Puck/components/Header/index.tsx
8501
8280
  init_react_import();
8502
- var import_react55 = require("react");
8281
+ var import_react53 = require("react");
8503
8282
 
8504
8283
  // components/MenuBar/index.tsx
8505
8284
  init_react_import();
@@ -8581,7 +8360,7 @@ var HeaderInner = () => {
8581
8360
  } = usePropsContext();
8582
8361
  const dispatch = useAppStore((s) => s.dispatch);
8583
8362
  const appStore = useAppStoreApi();
8584
- const defaultHeaderRender = (0, import_react55.useMemo)(() => {
8363
+ const defaultHeaderRender = (0, import_react53.useMemo)(() => {
8585
8364
  if (renderHeader) {
8586
8365
  console.warn(
8587
8366
  "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
@@ -8596,7 +8375,7 @@ var HeaderInner = () => {
8596
8375
  }
8597
8376
  return DefaultOverride;
8598
8377
  }, [renderHeader]);
8599
- const defaultHeaderActionsRender = (0, import_react55.useMemo)(() => {
8378
+ const defaultHeaderActionsRender = (0, import_react53.useMemo)(() => {
8600
8379
  if (renderHeaderActions) {
8601
8380
  console.warn(
8602
8381
  "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
@@ -8616,7 +8395,7 @@ var HeaderInner = () => {
8616
8395
  const CustomHeaderActions = useAppStore(
8617
8396
  (s) => s.overrides.headerActions || defaultHeaderActionsRender
8618
8397
  );
8619
- const [menuOpen, setMenuOpen] = (0, import_react55.useState)(false);
8398
+ const [menuOpen, setMenuOpen] = (0, import_react53.useState)(false);
8620
8399
  const rootTitle = useAppStore((s) => {
8621
8400
  var _a, _b;
8622
8401
  const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
@@ -8626,7 +8405,7 @@ var HeaderInner = () => {
8626
8405
  const rightSideBarVisible = useAppStore(
8627
8406
  (s) => s.state.ui.rightSideBarVisible
8628
8407
  );
8629
- const toggleSidebars = (0, import_react55.useCallback)(
8408
+ const toggleSidebars = (0, import_react53.useCallback)(
8630
8409
  (sidebar) => {
8631
8410
  const widerViewport = window.matchMedia("(min-width: 638px)").matches;
8632
8411
  const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
@@ -8729,7 +8508,7 @@ var HeaderInner = () => {
8729
8508
  }
8730
8509
  );
8731
8510
  };
8732
- var Header = (0, import_react55.memo)(HeaderInner);
8511
+ var Header = (0, import_react53.memo)(HeaderInner);
8733
8512
 
8734
8513
  // components/Puck/index.tsx
8735
8514
  var import_jsx_runtime42 = require("react/jsx-runtime");
@@ -8744,11 +8523,11 @@ var FieldSideBar = () => {
8744
8523
  );
8745
8524
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Fields, {}) });
8746
8525
  };
8747
- var propsContext = (0, import_react56.createContext)({});
8526
+ var propsContext = (0, import_react54.createContext)({});
8748
8527
  function PropsProvider(props) {
8749
8528
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(propsContext.Provider, { value: props, children: props.children });
8750
8529
  }
8751
- var usePropsContext = () => (0, import_react56.useContext)(propsContext);
8530
+ var usePropsContext = () => (0, import_react54.useContext)(propsContext);
8752
8531
  function PuckProvider({ children }) {
8753
8532
  const {
8754
8533
  config,
@@ -8764,14 +8543,14 @@ function PuckProvider({ children }) {
8764
8543
  metadata,
8765
8544
  onAction
8766
8545
  } = usePropsContext();
8767
- const iframe = (0, import_react56.useMemo)(
8546
+ const iframe = (0, import_react54.useMemo)(
8768
8547
  () => __spreadValues({
8769
8548
  enabled: true,
8770
8549
  waitForStyles: true
8771
8550
  }, _iframe),
8772
8551
  [_iframe]
8773
8552
  );
8774
- const [generatedAppState] = (0, import_react56.useState)(() => {
8553
+ const [generatedAppState] = (0, import_react54.useState)(() => {
8775
8554
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
8776
8555
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
8777
8556
  let clientUiState = {};
@@ -8831,7 +8610,7 @@ function PuckProvider({ children }) {
8831
8610
  return walkAppState(newAppState, config);
8832
8611
  });
8833
8612
  const { appendData = true } = _initialHistory || {};
8834
- const [blendedHistories] = (0, import_react56.useState)(
8613
+ const [blendedHistories] = (0, import_react54.useState)(
8835
8614
  [
8836
8615
  ...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
8837
8616
  ...appendData ? [{ state: generatedAppState }] : []
@@ -8851,7 +8630,7 @@ function PuckProvider({ children }) {
8851
8630
  overrides,
8852
8631
  plugins
8853
8632
  });
8854
- const generateAppStore = (0, import_react56.useCallback)(
8633
+ const generateAppStore = (0, import_react54.useCallback)(
8855
8634
  (state) => {
8856
8635
  return {
8857
8636
  state,
@@ -8875,15 +8654,15 @@ function PuckProvider({ children }) {
8875
8654
  metadata
8876
8655
  ]
8877
8656
  );
8878
- const [appStore] = (0, import_react56.useState)(
8657
+ const [appStore] = (0, import_react54.useState)(
8879
8658
  () => createAppStore(generateAppStore(initialAppState))
8880
8659
  );
8881
- (0, import_react56.useEffect)(() => {
8660
+ (0, import_react54.useEffect)(() => {
8882
8661
  if (process.env.NODE_ENV !== "production") {
8883
8662
  window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
8884
8663
  }
8885
8664
  }, [appStore]);
8886
- (0, import_react56.useEffect)(() => {
8665
+ (0, import_react54.useEffect)(() => {
8887
8666
  const state = appStore.getState().state;
8888
8667
  appStore.setState(__spreadValues({}, generateAppStore(state)));
8889
8668
  }, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
@@ -8892,8 +8671,8 @@ function PuckProvider({ children }) {
8892
8671
  index: initialHistoryIndex,
8893
8672
  initialAppState
8894
8673
  });
8895
- const previousData = (0, import_react56.useRef)(null);
8896
- (0, import_react56.useEffect)(() => {
8674
+ const previousData = (0, import_react54.useRef)(null);
8675
+ (0, import_react54.useEffect)(() => {
8897
8676
  appStore.subscribe(
8898
8677
  (s) => s.state.data,
8899
8678
  (data) => {
@@ -8907,7 +8686,7 @@ function PuckProvider({ children }) {
8907
8686
  }, []);
8908
8687
  useRegisterPermissionsSlice(appStore, permissions);
8909
8688
  const uPuckStore = useRegisterUsePuckStore(appStore);
8910
- (0, import_react56.useEffect)(() => {
8689
+ (0, import_react54.useEffect)(() => {
8911
8690
  const { resolveAndCommitData } = appStore.getState();
8912
8691
  resolveAndCommitData();
8913
8692
  }, []);
@@ -8919,7 +8698,7 @@ function PuckLayout({ children }) {
8919
8698
  dnd,
8920
8699
  initialHistory: _initialHistory
8921
8700
  } = usePropsContext();
8922
- const iframe = (0, import_react56.useMemo)(
8701
+ const iframe = (0, import_react54.useMemo)(
8923
8702
  () => __spreadValues({
8924
8703
  enabled: true,
8925
8704
  waitForStyles: true
@@ -8932,7 +8711,7 @@ function PuckLayout({ children }) {
8932
8711
  (s) => s.state.ui.rightSideBarVisible
8933
8712
  );
8934
8713
  const dispatch = useAppStore((s) => s.dispatch);
8935
- (0, import_react56.useEffect)(() => {
8714
+ (0, import_react54.useEffect)(() => {
8936
8715
  if (!window.matchMedia("(min-width: 638px)").matches) {
8937
8716
  dispatch({
8938
8717
  type: "setUi",
@@ -8956,17 +8735,17 @@ function PuckLayout({ children }) {
8956
8735
  };
8957
8736
  }, []);
8958
8737
  const overrides = useAppStore((s) => s.overrides);
8959
- const CustomPuck = (0, import_react56.useMemo)(
8738
+ const CustomPuck = (0, import_react54.useMemo)(
8960
8739
  () => overrides.puck || DefaultOverride,
8961
8740
  [overrides]
8962
8741
  );
8963
- const [mounted, setMounted] = (0, import_react56.useState)(false);
8964
- (0, import_react56.useEffect)(() => {
8742
+ const [mounted, setMounted] = (0, import_react54.useState)(false);
8743
+ (0, import_react54.useEffect)(() => {
8965
8744
  setMounted(true);
8966
8745
  }, []);
8967
8746
  const ready = useAppStore((s) => s.status === "READY");
8968
8747
  useMonitorHotkeys();
8969
- (0, import_react56.useEffect)(() => {
8748
+ (0, import_react54.useEffect)(() => {
8970
8749
  if (ready && iframe.enabled) {
8971
8750
  const frameDoc = getFrame();
8972
8751
  if (frameDoc) {
@@ -9005,6 +8784,230 @@ Puck.Components = Components;
9005
8784
  Puck.Fields = Fields;
9006
8785
  Puck.Outline = Outline;
9007
8786
  Puck.Preview = Preview2;
8787
+
8788
+ // lib/migrate.ts
8789
+ init_react_import();
8790
+ var migrations = [
8791
+ // Migrate root to root.props
8792
+ (data) => {
8793
+ const rootProps = data.root.props || data.root;
8794
+ if (Object.keys(data.root).length > 0 && !data.root.props) {
8795
+ console.warn(
8796
+ "Migration applied: Root props moved from `root` to `root.props`."
8797
+ );
8798
+ return __spreadProps(__spreadValues({}, data), {
8799
+ root: {
8800
+ props: __spreadValues({}, rootProps)
8801
+ }
8802
+ });
8803
+ }
8804
+ return data;
8805
+ },
8806
+ // Migrate zones to slots
8807
+ (data, config, migrationOptions) => {
8808
+ var _a, _b;
8809
+ if (!config) return data;
8810
+ console.log("Migrating DropZones to slots...");
8811
+ const updatedItems = {};
8812
+ const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
8813
+ const { indexes } = walkAppState(appState, config);
8814
+ const deletedCompounds = [];
8815
+ walkAppState(appState, config, (content, zoneCompound, zoneType) => {
8816
+ var _a2, _b2, _c;
8817
+ if (zoneType === "dropzone") {
8818
+ const [id, slotName] = zoneCompound.split(":");
8819
+ const nodeData = indexes.nodes[id].data;
8820
+ const componentType = nodeData.type;
8821
+ const configForComponent = id === "root" ? config.root : config.components[componentType];
8822
+ if (((_b2 = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b2.type) === "slot") {
8823
+ updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
8824
+ props: __spreadProps(__spreadValues(__spreadValues({}, nodeData.props), (_c = updatedItems[id]) == null ? void 0 : _c.props), {
8825
+ [slotName]: content
8826
+ })
8827
+ });
8828
+ deletedCompounds.push(zoneCompound);
8829
+ }
8830
+ return content;
8831
+ }
8832
+ return content;
8833
+ });
8834
+ const updated = walkAppState(
8835
+ appState,
8836
+ config,
8837
+ (content) => content,
8838
+ (item) => {
8839
+ var _a2;
8840
+ return (_a2 = updatedItems[item.props.id]) != null ? _a2 : item;
8841
+ }
8842
+ );
8843
+ deletedCompounds.forEach((zoneCompound) => {
8844
+ var _a2;
8845
+ const [_, propName] = zoneCompound.split(":");
8846
+ console.log(
8847
+ `\u2713 Success: Migrated "${zoneCompound}" from DropZone to slot field "${propName}"`
8848
+ );
8849
+ (_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
8850
+ });
8851
+ if (migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) {
8852
+ const unmigratedZonesGrouped = {};
8853
+ Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
8854
+ var _a2;
8855
+ const [componentId, propName] = zoneCompound.split(":");
8856
+ const content = (_a2 = updated.data.zones) == null ? void 0 : _a2[zoneCompound];
8857
+ if (!content) {
8858
+ return;
8859
+ }
8860
+ if (!unmigratedZonesGrouped[componentId]) {
8861
+ unmigratedZonesGrouped[componentId] = {};
8862
+ }
8863
+ if (!unmigratedZonesGrouped[componentId][propName]) {
8864
+ unmigratedZonesGrouped[componentId][propName] = content;
8865
+ }
8866
+ });
8867
+ Object.keys(unmigratedZonesGrouped).forEach((componentId) => {
8868
+ updated.data = walkTree(updated.data, config, (content) => {
8869
+ return content.map((child) => {
8870
+ var _a2;
8871
+ if (child.props.id !== componentId) {
8872
+ return child;
8873
+ }
8874
+ const migrateFn = (_a2 = migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) == null ? void 0 : _a2[child.type];
8875
+ if (!migrateFn) {
8876
+ return child;
8877
+ }
8878
+ const zones = unmigratedZonesGrouped[componentId];
8879
+ const migratedProps = migrateFn(child.props, zones);
8880
+ Object.keys(zones).forEach((propName) => {
8881
+ var _a3;
8882
+ const zoneCompound = `${componentId}:${propName}`;
8883
+ console.log(`\u2713 Success: Migrated "${zoneCompound}" DropZone`);
8884
+ (_a3 = updated.data.zones) == null ? true : delete _a3[zoneCompound];
8885
+ });
8886
+ return __spreadProps(__spreadValues({}, child), {
8887
+ props: migratedProps
8888
+ });
8889
+ });
8890
+ });
8891
+ });
8892
+ }
8893
+ Object.keys((_b = updated.data.zones) != null ? _b : {}).forEach((zoneCompound) => {
8894
+ const [_, propName] = zoneCompound.split(":");
8895
+ throw new Error(
8896
+ `Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
8897
+ );
8898
+ });
8899
+ delete updated.data.zones;
8900
+ return updated.data;
8901
+ }
8902
+ ];
8903
+ function migrate(data, config, migrationOptions) {
8904
+ return migrations == null ? void 0 : migrations.reduce(
8905
+ (acc, migration) => migration(acc, config, migrationOptions),
8906
+ data
8907
+ );
8908
+ }
8909
+
8910
+ // lib/transform-props.ts
8911
+ init_react_import();
8912
+
8913
+ // lib/data/default-data.ts
8914
+ init_react_import();
8915
+ var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
8916
+ root: data.root || {},
8917
+ content: data.content || []
8918
+ });
8919
+
8920
+ // lib/transform-props.ts
8921
+ function transformProps(data, propTransforms, config = { components: {} }) {
8922
+ const mapItem = (item) => {
8923
+ if (propTransforms[item.type]) {
8924
+ return __spreadProps(__spreadValues({}, item), {
8925
+ props: __spreadValues({
8926
+ id: item.props.id
8927
+ }, propTransforms[item.type](item.props))
8928
+ });
8929
+ }
8930
+ return item;
8931
+ };
8932
+ const defaultedData = defaultData(data);
8933
+ const rootProps = defaultedData.root.props || defaultedData.root;
8934
+ let newRoot = __spreadValues({}, defaultedData.root);
8935
+ if (propTransforms["root"]) {
8936
+ newRoot.props = propTransforms["root"](rootProps);
8937
+ }
8938
+ const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
8939
+ const updatedData = walkTree(
8940
+ dataWithUpdatedRoot,
8941
+ config,
8942
+ (content) => content.map(mapItem)
8943
+ );
8944
+ if (!defaultedData.root.props) {
8945
+ updatedData.root = updatedData.root.props;
8946
+ }
8947
+ return updatedData;
8948
+ }
8949
+
8950
+ // lib/resolve-all-data.ts
8951
+ init_react_import();
8952
+
8953
+ // lib/data/to-component.ts
8954
+ init_react_import();
8955
+ var toComponent = (item) => {
8956
+ return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
8957
+ props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
8958
+ type: "root"
8959
+ });
8960
+ };
8961
+
8962
+ // lib/resolve-all-data.ts
8963
+ function resolveAllData(_0, _1) {
8964
+ return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
8965
+ var _a;
8966
+ const defaultedData = defaultData(data);
8967
+ const resolveNode = (_node) => __async(this, null, function* () {
8968
+ const node = toComponent(_node);
8969
+ onResolveStart == null ? void 0 : onResolveStart(node);
8970
+ const resolved = (yield resolveComponentData(
8971
+ node,
8972
+ config,
8973
+ metadata,
8974
+ () => {
8975
+ },
8976
+ () => {
8977
+ },
8978
+ "force"
8979
+ )).node;
8980
+ const resolvedDeep = yield mapSlots(
8981
+ resolved,
8982
+ processContent,
8983
+ config
8984
+ );
8985
+ onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
8986
+ return resolvedDeep;
8987
+ });
8988
+ const processContent = (content) => __async(this, null, function* () {
8989
+ return Promise.all(content.map(resolveNode));
8990
+ });
8991
+ const processZones = () => __async(this, null, function* () {
8992
+ var _a2;
8993
+ const zones = (_a2 = data.zones) != null ? _a2 : {};
8994
+ Object.entries(zones).forEach((_02) => __async(this, [_02], function* ([zoneKey, content]) {
8995
+ zones[zoneKey] = yield Promise.all(content.map(resolveNode));
8996
+ }));
8997
+ return zones;
8998
+ });
8999
+ const dynamic = {
9000
+ root: yield resolveNode(defaultedData.root),
9001
+ content: yield processContent(defaultedData.content),
9002
+ zones: yield processZones()
9003
+ };
9004
+ Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(this, null, function* () {
9005
+ const content = defaultedData.zones[zoneKey];
9006
+ dynamic.zones[zoneKey] = yield processContent(content);
9007
+ }), {});
9008
+ return dynamic;
9009
+ });
9010
+ }
9008
9011
  // Annotate the CommonJS export names for ESM import in node:
9009
9012
  0 && (module.exports = {
9010
9013
  Action,