@netlisian/softconfig 0.1.8 → 0.1.10

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.
@@ -1,5 +1,6 @@
1
1
  'use client'
2
2
  "use strict";
3
+ "use client";
3
4
  var __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
5
6
  var __defProps = Object.defineProperties;
@@ -69,7 +70,6 @@ var __async = (__this, __arguments, generator) => {
69
70
  var puck_exports = {};
70
71
  __export(puck_exports, {
71
72
  ActionBar: () => ActionBarOverride,
72
- ComponentItem: () => ComponentItem,
73
73
  ComponentList: () => Drawer,
74
74
  Drawer: () => Drawer,
75
75
  DrawerItem: () => DrawerItem,
@@ -105,22 +105,45 @@ __export(puck_exports, {
105
105
  module.exports = __toCommonJS(puck_exports);
106
106
 
107
107
  // src/puck/store/index.tsx
108
- var import_zustand2 = require("zustand");
108
+ var import_zustand = require("zustand");
109
109
  var import_middleware = require("zustand/middleware");
110
110
 
111
- // src/puck/store/slices/builder.tsx
112
- var import_puck4 = require("@measured/puck");
113
-
114
- // src/puck/lib/get-root-props.ts
115
- var getRootProps = (appState) => appState.data.root.props;
116
-
117
- // src/puck/lib/builder/root-config.tsx
118
- var import_react2 = require("react");
111
+ // src/puck/lib/root-action-handler.ts
119
112
  var import_react_fast_compare2 = __toESM(require("react-fast-compare"));
120
- var import_puck2 = require("@measured/puck");
121
113
 
122
- // src/puck/lib/get-field-settings.tsx
123
- var import_puck = require("@measured/puck");
114
+ // src/puck/lib/apply-mapping.ts
115
+ var import_react_fast_compare = __toESM(require("react-fast-compare"));
116
+
117
+ // src/puck/lib/set-prop-by-path.ts
118
+ function setPropertyByPath(props, path, value) {
119
+ const parts = path.replace(/\[(\w+)\]/g, ".$1").split(".");
120
+ const last = parts.pop();
121
+ let cur = props;
122
+ for (const p of parts) {
123
+ if (typeof cur[p] !== "object" || cur[p] === null) cur[p] = {};
124
+ cur = cur[p];
125
+ }
126
+ cur[last] = value;
127
+ }
128
+ function setImmutablePropertyByPath(obj, path, value) {
129
+ if (!path) return value;
130
+ const parts = path.replace(/\[(\w+)\]/g, ".$1").split(".");
131
+ const root = Array.isArray(obj) ? [...obj] : __spreadValues({}, obj);
132
+ let current = root;
133
+ for (let i = 0; i < parts.length - 1; i++) {
134
+ const part = parts[i];
135
+ const nextPart = parts[i + 1];
136
+ const isArrayNext = !isNaN(Number(nextPart));
137
+ if (current[part] === void 0 || current[part] === null) {
138
+ current[part] = isArrayNext ? [] : {};
139
+ } else {
140
+ current[part] = Array.isArray(current[part]) ? [...current[part]] : __spreadValues({}, current[part]);
141
+ }
142
+ current = current[part];
143
+ }
144
+ current[parts[parts.length - 1]] = value;
145
+ return root;
146
+ }
124
147
 
125
148
  // src/puck/lib/get-settings-by-path.ts
126
149
  function getFieldSettingsByPath(fieldSettings, path) {
@@ -128,14 +151,6 @@ function getFieldSettingsByPath(fieldSettings, path) {
128
151
  }
129
152
 
130
153
  // src/puck/lib/array-field-utils.ts
131
- var primitiveFieldTypes = /* @__PURE__ */ new Set([
132
- "text",
133
- "textarea",
134
- "number",
135
- "select",
136
- "radio",
137
- "reference"
138
- ]);
139
154
  var isPrimitiveValue = (value) => ["string", "number", "boolean"].includes(typeof value);
140
155
  var getFallbackValueForField = (type) => {
141
156
  switch (type) {
@@ -167,7 +182,6 @@ var resolveExpressionSummary = (item, index, expression) => {
167
182
  });
168
183
  return isValid ? result : "";
169
184
  };
170
- var isPrimitiveFieldType = (type) => primitiveFieldTypes.has(type);
171
185
  var buildArrayDefaultItemProps = (subFields = [], subFieldSettings = {}) => {
172
186
  if (!subFields.length) return void 0;
173
187
  const item = {};
@@ -220,486 +234,19 @@ var getArrayItemSubPath = (arrayPath) => {
220
234
  return match ? match[1] : null;
221
235
  };
222
236
 
223
- // src/puck/lib/custom-fields.ts
224
- var builtInSoftFieldTypes = /* @__PURE__ */ new Set([
225
- "text",
226
- "textarea",
227
- "number",
228
- "select",
229
- "radio",
230
- "array",
231
- "object",
232
- "reference"
233
- ]);
234
- var warnedMessages = /* @__PURE__ */ new Set();
235
- var warnOnce = (message) => {
236
- if (warnedMessages.has(message)) {
237
- return;
238
- }
239
- warnedMessages.add(message);
240
- console.warn(message);
241
- };
242
- var isBuiltInSoftFieldType = (fieldType) => {
243
- return builtInSoftFieldTypes.has(fieldType);
244
- };
245
- var resolveCustomFieldDefinition = (fieldType, customFields) => {
246
- if (isBuiltInSoftFieldType(fieldType)) {
247
- return void 0;
248
- }
249
- return customFields == null ? void 0 : customFields[fieldType];
250
- };
251
- var resolveCustomFieldReturnType = (fieldType, customFields) => {
252
- const customField = resolveCustomFieldDefinition(fieldType, customFields);
253
- if (!customField) {
254
- return null;
255
- }
256
- if (!customField.returnType) {
257
- warnOnce(
258
- `[soft-config] Custom field "${fieldType}" is missing a required returnType and will be skipped from mapping options.`
259
- );
260
- return null;
261
- }
262
- return customField.returnType;
263
- };
264
- var resolveCustomFieldSchema = (fieldType, customFields) => {
265
- const customField = resolveCustomFieldDefinition(fieldType, customFields);
266
- if (!customField) {
267
- return null;
268
- }
269
- const returnType = resolveCustomFieldReturnType(fieldType, customFields);
270
- if (!returnType) {
271
- return null;
272
- }
273
- if (returnType !== "array" && returnType !== "object") {
274
- return null;
275
- }
276
- const subFields = customField.subFields || [];
277
- if (!subFields.length) {
278
- warnOnce(
279
- `[soft-config] Custom field "${fieldType}" returns ${returnType} but does not define subFields. It will be skipped from mapping options.`
280
- );
281
- return null;
282
- }
283
- return {
284
- subFields,
285
- subFieldSettings: customField.subFieldSettings || {}
286
- };
287
- };
288
- var getCustomFieldTypeOptions = (customFields) => {
289
- if (!customFields) {
290
- return [];
291
- }
292
- return Object.entries(customFields).filter(([fieldType]) => !isBuiltInSoftFieldType(fieldType)).map(([fieldType, definition]) => ({
293
- label: typeof definition.field.label === "string" && definition.field.label ? definition.field.label : fieldType,
294
- value: fieldType
295
- }));
296
- };
297
- var mapCustomReturnTypeToMappingType = (returnType) => {
298
- switch (returnType) {
299
- case "string":
300
- return "textarea";
301
- case "number":
302
- return "number";
303
- case "boolean":
304
- return "select";
305
- case "array":
306
- return "array";
307
- case "object":
308
- return "object";
309
- default:
310
- return "textarea";
311
- }
312
- };
313
-
314
- // src/puck/lib/get-field-settings.tsx
315
- var import_jsx_runtime = require("react/jsx-runtime");
316
- var buildPuckField = (field, fieldSettings, customFields) => {
317
- const customFieldDefinition = resolveCustomFieldDefinition(
318
- field.type,
319
- customFields
320
- );
321
- const customReturnType = resolveCustomFieldReturnType(field.type, customFields);
322
- if (customFieldDefinition && customReturnType) {
323
- return __spreadProps(__spreadValues({}, customFieldDefinition.field), {
324
- type: "custom",
325
- label: customFieldDefinition.field.label || field.name
326
- });
327
- }
328
- const resolvedType = field.type;
329
- switch (resolvedType) {
330
- case "text":
331
- case "textarea":
332
- return { type: resolvedType, label: field.name };
333
- case "number":
334
- return {
335
- type: resolvedType,
336
- label: field.name,
337
- min: fieldSettings == null ? void 0 : fieldSettings.min,
338
- max: fieldSettings == null ? void 0 : fieldSettings.max,
339
- step: fieldSettings == null ? void 0 : fieldSettings.step
340
- };
341
- case "select":
342
- case "radio":
343
- return {
344
- type: resolvedType,
345
- label: field.name,
346
- options: (fieldSettings == null ? void 0 : fieldSettings.options) || []
347
- };
348
- case "array": {
349
- const subFields = (fieldSettings == null ? void 0 : fieldSettings.subFields) || [];
350
- const subFieldSettings = (fieldSettings == null ? void 0 : fieldSettings.subFieldSettings) || {};
351
- return {
352
- type: "array",
353
- label: field.name,
354
- min: fieldSettings == null ? void 0 : fieldSettings.min,
355
- max: fieldSettings == null ? void 0 : fieldSettings.max,
356
- arrayFields: buildDefaultEditorFields(
357
- subFields,
358
- subFieldSettings,
359
- customFields
360
- ),
361
- defaultItemProps: buildArrayDefaultItemProps(subFields, subFieldSettings),
362
- getItemSummary(item, index) {
363
- return getArrayItemSummary(item, index, fieldSettings);
364
- }
365
- };
366
- }
367
- case "object":
368
- return {
369
- type: "object",
370
- label: field.name,
371
- objectFields: buildDefaultEditorFields(
372
- (fieldSettings == null ? void 0 : fieldSettings.subFields) || [],
373
- (fieldSettings == null ? void 0 : fieldSettings.subFieldSettings) || {},
374
- customFields
375
- )
376
- };
377
- default:
378
- return { type: "text", label: field.name };
379
- }
380
- };
381
- var buildDefaultEditorFields = (fields = [], fieldSettings = {}, customFields) => {
382
- return fields.reduce((acc, field) => {
383
- acc[field.name] = buildPuckField(
384
- field,
385
- fieldSettings[field.name],
386
- customFields
387
- );
388
- return acc;
389
- }, {});
390
- };
391
- var getFieldSettings = (_fields, _fieldSettings, customFields, deep) => {
392
- const customTypeOptions = getCustomFieldTypeOptions(customFields);
393
- return (_fields || []).reduce((fields, field) => {
394
- const fieldSettings = {
395
- // placeholder: { type: "text", label: "Placeholder" },
396
- };
397
- const currentFieldSettings = _fieldSettings == null ? void 0 : _fieldSettings[field.name];
398
- const customFieldDefinition = resolveCustomFieldDefinition(
399
- field.type,
400
- customFields
401
- );
402
- const customReturnType = resolveCustomFieldReturnType(
403
- field.type,
404
- customFields
405
- );
406
- const resolvedType = field.type;
407
- const customSchema = resolveCustomFieldSchema(field.type, customFields);
408
- const resolvedSubFields = (customSchema == null ? void 0 : customSchema.subFields) || (currentFieldSettings == null ? void 0 : currentFieldSettings.subFields) || [];
409
- const resolvedSubFieldSettings = (customSchema == null ? void 0 : customSchema.subFieldSettings) || (currentFieldSettings == null ? void 0 : currentFieldSettings.subFieldSettings) || {};
410
- const customDefaultValueField = customFieldDefinition && customReturnType ? __spreadProps(__spreadValues({}, customFieldDefinition.field), {
411
- type: "custom",
412
- label: customFieldDefinition.field.label || "Default Value"
413
- }) : null;
414
- if (customDefaultValueField) {
415
- fieldSettings.defaultValue = customDefaultValueField;
416
- }
417
- switch (resolvedType) {
418
- case "text":
419
- case "textarea":
420
- if (!customDefaultValueField) {
421
- fieldSettings.defaultValue = {
422
- type: resolvedType,
423
- label: "Default Value"
424
- };
425
- }
426
- break;
427
- case "number":
428
- if (!customDefaultValueField) {
429
- fieldSettings.defaultValue = {
430
- type: resolvedType,
431
- label: "Default Value"
432
- };
433
- }
434
- fieldSettings.min = {
435
- type: resolvedType,
436
- label: "Minimum Value"
437
- };
438
- fieldSettings.max = {
439
- type: resolvedType,
440
- label: "Maximum Value"
441
- };
442
- fieldSettings.step = {
443
- type: resolvedType,
444
- label: "Step Size"
445
- };
446
- break;
447
- case "radio":
448
- case "select": {
449
- const selectOptions = (currentFieldSettings == null ? void 0 : currentFieldSettings.options) || [];
450
- if (!customDefaultValueField) {
451
- fieldSettings.defaultValue = {
452
- type: "custom",
453
- label: "Default Value",
454
- render: ({ value, onChange, id }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
455
- import_puck.AutoField,
456
- {
457
- field: {
458
- type: resolvedType,
459
- label: "Default Value",
460
- options: selectOptions
461
- },
462
- value,
463
- onChange,
464
- readOnly: false,
465
- id
466
- }
467
- )
468
- };
469
- }
470
- fieldSettings.options = {
471
- type: "array",
472
- label: "Options",
473
- defaultItemProps: {
474
- label: "New Option",
475
- value: "new"
476
- },
477
- arrayFields: {
478
- label: { type: "text", label: "Label" },
479
- value: {
480
- type: "text",
481
- label: "Value"
482
- }
483
- },
484
- getItemSummary(item, index) {
485
- return item.label || `Option ${(index || 0) + 1}`;
486
- }
487
- };
488
- break;
489
- }
490
- case "array":
491
- case "object":
492
- fieldSettings.subFields = {
493
- type: "array",
494
- label: "Sub Fields",
495
- defaultItemProps: {
496
- name: "New Sub Field",
497
- type: "text"
498
- },
499
- arrayFields: {
500
- name: { type: "text", label: "Name" },
501
- type: {
502
- type: "select",
503
- options: deep ? [
504
- {
505
- label: "Text",
506
- value: "text"
507
- },
508
- {
509
- label: "Number",
510
- value: "number"
511
- },
512
- {
513
- label: "Select",
514
- value: "select"
515
- },
516
- {
517
- label: "Radio",
518
- value: "radio"
519
- },
520
- ...customTypeOptions
521
- ] : [
522
- {
523
- label: "Text",
524
- value: "text"
525
- },
526
- {
527
- label: "Number",
528
- value: "number"
529
- },
530
- {
531
- label: "Select",
532
- value: "select"
533
- },
534
- {
535
- label: "Radio",
536
- value: "radio"
537
- },
538
- {
539
- label: "Array",
540
- value: "array"
541
- },
542
- {
543
- label: "Object",
544
- value: "object"
545
- },
546
- {
547
- label: "Reference",
548
- value: "reference"
549
- },
550
- ...customTypeOptions
551
- ]
552
- }
553
- },
554
- getItemSummary(item, index) {
555
- return item.name || `Field ${(index || 0) + 1}`;
556
- }
557
- };
558
- if (!deep)
559
- fieldSettings.subFieldSettings = {
560
- type: "object",
561
- label: "Sub Field Settings",
562
- objectFields: resolvedSubFields ? getFieldSettings(
563
- resolvedSubFields,
564
- resolvedSubFieldSettings,
565
- customFields,
566
- true
567
- ) : {}
568
- };
569
- if (resolvedType === "array") {
570
- if (!customDefaultValueField) {
571
- fieldSettings.defaultValue = {
572
- type: "array",
573
- label: "Default Items",
574
- arrayFields: buildDefaultEditorFields(
575
- resolvedSubFields,
576
- resolvedSubFieldSettings,
577
- customFields
578
- ),
579
- defaultItemProps: buildArrayDefaultItemProps(
580
- resolvedSubFields,
581
- resolvedSubFieldSettings
582
- ),
583
- getItemSummary(item, index) {
584
- return getArrayItemSummary(item, index, currentFieldSettings);
585
- }
586
- };
587
- }
588
- fieldSettings.min = {
589
- type: "number",
590
- label: "Minimum Items"
591
- };
592
- fieldSettings.max = {
593
- type: "number",
594
- label: "Maximum Items"
595
- };
596
- fieldSettings.summary = {
597
- type: "select",
598
- label: "Summary",
599
- options: [
600
- {
601
- label: "Default Numbering / Count",
602
- value: "count"
603
- },
604
- {
605
- label: "Field",
606
- value: "field"
607
- },
608
- {
609
- label: "Expression",
610
- value: "expression"
611
- }
612
- ]
613
- };
614
- if ((currentFieldSettings == null ? void 0 : currentFieldSettings.summary) === "field") {
615
- fieldSettings.summaryField = {
616
- type: "select",
617
- label: "Summary Field",
618
- options: [
619
- {
620
- label: "Select a field",
621
- value: ""
622
- },
623
- ...resolvedSubFields.filter((subField) => isPrimitiveFieldType(subField.type)).map((subField) => ({
624
- label: subField.name,
625
- value: subField.name
626
- }))
627
- ]
628
- };
629
- }
630
- if ((currentFieldSettings == null ? void 0 : currentFieldSettings.summary) === "expression") {
631
- fieldSettings.summaryExpression = {
632
- type: "text",
633
- label: "Summary Expression"
634
- };
635
- }
636
- }
637
- break;
638
- }
639
- const overriddenFieldSettings = (customFieldDefinition == null ? void 0 : customFieldDefinition.fieldSettingsOverride) ? customFieldDefinition.fieldSettingsOverride({
640
- fieldName: field.name,
641
- fieldType: field.type,
642
- fieldSettings: currentFieldSettings,
643
- originalFieldSettings: fieldSettings
644
- }) : fieldSettings;
645
- fields[field.name] = {
646
- type: "object",
647
- label: field.name,
648
- objectFields: overriddenFieldSettings
649
- };
650
- return fields;
651
- }, {});
652
- };
653
- var get_field_settings_default = getFieldSettings;
654
-
655
- // src/puck/context/useStore.ts
656
- var import_react = require("react");
657
- var import_zustand = require("zustand");
658
- var appStoreContext = (0, import_react.createContext)(null);
659
- var createUseSoftConfig = () => {
660
- return function useSoftConfig2(selector, equalityFn) {
661
- const context = (0, import_react.useContext)(appStoreContext);
662
- if (!context) {
663
- throw new Error(
664
- "useSoftConfig must be used inside a SoftConfigProvider. Wrap your tree with <SoftConfigProvider value={store}>"
665
- );
666
- }
667
- if (equalityFn) {
668
- return (0, import_zustand.useStore)(context, selector, equalityFn);
669
- }
670
- return (0, import_zustand.useStore)(context, selector);
671
- };
672
- };
673
- var useSoftConfig = createUseSoftConfig();
674
- var useSoftConfigStore = () => {
675
- const context = (0, import_react.useContext)(appStoreContext);
676
- if (!context) {
677
- throw new Error(
678
- "useSoftConfigStore must be used inside a SoftConfigProvider."
679
- );
680
- }
681
- return context;
682
- };
683
-
684
237
  // src/puck/lib/apply-mapping.ts
685
- var import_react_fast_compare = __toESM(require("react-fast-compare"));
686
-
687
- // src/puck/lib/set-prop-by-path.ts
688
- function setPropertyByPath(props, path, value) {
689
- const parts = path.split(".");
690
- const last = parts.pop();
691
- let cur = props;
692
- for (const p of parts) {
693
- if (typeof cur[p] !== "object" || cur[p] === null) cur[p] = {};
694
- cur = cur[p];
238
+ var pathSegmentsCache = /* @__PURE__ */ new Map();
239
+ var getPathSegments = (path) => {
240
+ let segments = pathSegmentsCache.get(path);
241
+ if (!segments) {
242
+ segments = path.split(".");
243
+ pathSegmentsCache.set(path, segments);
695
244
  }
696
- cur[last] = value;
697
- }
698
-
699
- // src/puck/lib/apply-mapping.ts
245
+ return segments;
246
+ };
700
247
  var resolveValueByPath = (source, path) => {
701
248
  if (!path) return source;
702
- const segments = path.split(".");
249
+ const segments = getPathSegments(path);
703
250
  const resolveSegments = (current, index) => {
704
251
  if (current === null || current === void 0) return void 0;
705
252
  if (index >= segments.length) return current;
@@ -718,7 +265,7 @@ var resolveValueByPath = (source, path) => {
718
265
  };
719
266
  var resolveFieldSettingEntryByPath = (settings, path) => {
720
267
  if (!path) return void 0;
721
- const segments = path.split(".");
268
+ const segments = getPathSegments(path);
722
269
  let currentSettings = settings;
723
270
  let currentEntry;
724
271
  for (const segmentWithArraySuffix of segments) {
@@ -736,11 +283,11 @@ var resolveFieldSettingEntryByPath = (settings, path) => {
736
283
  };
737
284
  function applyMapping(props, fieldSettings, map, resolveInput = "fieldSettings", options) {
738
285
  var _a, _b, _c;
739
- const newProps = __spreadValues({}, props);
286
+ let newProps = props;
740
287
  const sourceProps = (_a = options == null ? void 0 : options.sourceProps) != null ? _a : props;
741
288
  const mappedArrayPaths = /* @__PURE__ */ new Set();
742
289
  let changed = false;
743
- const changedArrayBases = /* @__PURE__ */ new Set();
290
+ const arrayRulesMap = /* @__PURE__ */ new Map();
744
291
  for (const entry of map) {
745
292
  const { from, to, transform } = entry;
746
293
  if (!from || !to) continue;
@@ -779,43 +326,21 @@ function applyMapping(props, fieldSettings, map, resolveInput = "fieldSettings",
779
326
  if (isSingleArrayTarget) {
780
327
  const toPath = toPaths[0];
781
328
  const arrayBase = getArrayBasePath(toPath);
782
- const subProp = getArrayItemSubPath(toPath) || "";
783
329
  if (!arrayBase) continue;
784
- const defaultArray = Array.isArray((_b = options == null ? void 0 : options.arrayDefaults) == null ? void 0 : _b[arrayBase]) ? (_c = options == null ? void 0 : options.arrayDefaults) == null ? void 0 : _c[arrayBase] : [];
785
- const currentArrayAtPath = resolveValueByPath(newProps, arrayBase);
786
- const currentArray = Array.isArray(currentArrayAtPath) ? currentArrayAtPath : [];
787
- const isFromArrayPath = typeof fromPaths[0] === "string" && isArrayMappingPath(fromPaths[0]);
788
- const sourceArray = isFromArrayPath ? Array.isArray(result) ? result : result !== void 0 ? [result] : [] : Array.isArray(result) ? result : defaultArray.map(() => result);
789
- let defaults = entry.unmappedArrayItemDefaultValues || entry.defaultOverrides || {};
790
- if (typeof defaults === "string") {
791
- try {
792
- defaults = JSON.parse(defaults);
793
- } catch (e) {
794
- defaults = {};
795
- }
796
- }
797
- const targetLength = sourceArray.length;
798
- const constructed = Array.from({ length: targetLength }).map((_, idx) => {
799
- const mappedValue = sourceArray[idx];
800
- const defaultItem = defaultArray[idx] && typeof defaultArray[idx] === "object" ? defaultArray[idx] : {};
801
- const currentItem = currentArray[idx] && typeof currentArray[idx] === "object" ? currentArray[idx] : {};
802
- const item = __spreadValues(__spreadValues(__spreadValues({}, defaultItem), defaults), currentItem);
803
- if (subProp && mappedValue !== void 0) {
804
- setPropertyByPath(item, subProp, mappedValue);
805
- }
806
- return item;
807
- });
808
- const originalArray = resolveValueByPath(newProps, arrayBase);
809
- if (!(0, import_react_fast_compare.default)(originalArray, constructed)) {
810
- setPropertyByPath(newProps, arrayBase, constructed);
811
- changedArrayBases.add(arrayBase);
330
+ let rules = arrayRulesMap.get(arrayBase);
331
+ if (!rules) {
332
+ rules = [];
333
+ arrayRulesMap.set(arrayBase, rules);
812
334
  }
335
+ rules.push({ entry, toPath, fromPaths, result });
813
336
  mappedArrayPaths.add(arrayBase);
814
- } else if (toPaths.length === 1 && Array.isArray(result) && toPaths[0].includes("array")) {
337
+ continue;
338
+ }
339
+ if (toPaths.length === 1 && Array.isArray(result) && toPaths[0].includes("array")) {
815
340
  const toPath = toPaths[0];
816
341
  const original = resolveValueByPath(newProps, toPath);
817
342
  if (!(0, import_react_fast_compare.default)(original, result)) {
818
- setPropertyByPath(newProps, toPath, result);
343
+ newProps = setImmutablePropertyByPath(newProps, toPath, result);
819
344
  changed = true;
820
345
  }
821
346
  } else if (Array.isArray(result) && toPaths.length > 1) {
@@ -823,7 +348,7 @@ function applyMapping(props, fieldSettings, map, resolveInput = "fieldSettings",
823
348
  if (toPaths[idx]) {
824
349
  const orig = resolveValueByPath(newProps, toPaths[idx]);
825
350
  if (!(0, import_react_fast_compare.default)(orig, val)) {
826
- setPropertyByPath(newProps, toPaths[idx], val);
351
+ newProps = setImmutablePropertyByPath(newProps, toPaths[idx], val);
827
352
  changed = true;
828
353
  }
829
354
  }
@@ -832,565 +357,231 @@ function applyMapping(props, fieldSettings, map, resolveInput = "fieldSettings",
832
357
  const finalValue = result;
833
358
  const originalValue = resolveValueByPath(newProps, toPaths[0]);
834
359
  if (!(0, import_react_fast_compare.default)(originalValue, finalValue)) {
835
- setPropertyByPath(newProps, toPaths[0], finalValue);
360
+ newProps = setImmutablePropertyByPath(newProps, toPaths[0], finalValue);
836
361
  changed = true;
837
362
  }
838
363
  }
839
364
  }
840
- const hasNetArrayChanges = Array.from(changedArrayBases).some(
841
- (arrayBase) => !(0, import_react_fast_compare.default)(resolveValueByPath(props, arrayBase), resolveValueByPath(newProps, arrayBase))
842
- );
843
- return { newProps, mappedArrayPaths, changed: changed || hasNetArrayChanges };
844
- }
845
-
846
- // src/puck/lib/builder/root-config.tsx
847
- var import_jsx_runtime2 = require("react/jsx-runtime");
848
- var useCustomPuck = (0, import_puck2.createUsePuck)();
849
- var getSerializableProps = (props) => {
850
- const cleanProps = {
851
- id: props.id
852
- };
853
- for (const key in props) {
854
- const value = props[key];
855
- if (["children", "puck", "editMode"].includes(key)) continue;
856
- if (value && typeof value === "object" && value.$$typeof) continue;
857
- if (typeof value === "function") continue;
858
- cleanProps[key] = value;
859
- }
860
- return cleanProps;
861
- };
862
- var builderRootConfig = (config, overrides, editingComponent, showVersionFields = true, customFields) => {
863
- const customTypeOptions = getCustomFieldTypeOptions(customFields);
864
- return {
865
- fields: __spreadValues({
866
- _name: overrides.name || {
867
- type: "text",
868
- label: "Soft Component Name"
869
- },
870
- _category: overrides.categories || {
871
- type: "select",
872
- label: "Category",
873
- options: [
874
- ...Object.keys(config.categories || {}).map((cat) => {
875
- var _a;
876
- return {
877
- label: ((_a = config.categories) == null ? void 0 : _a[cat].title) || cat,
878
- value: cat
879
- };
880
- }) || [],
881
- {
882
- label: Object.keys(config.categories || {}).length ? "Other" : "Uncategorized",
883
- value: void 0
365
+ for (const [arrayBase, rules] of arrayRulesMap.entries()) {
366
+ const defaultArray = Array.isArray((_b = options == null ? void 0 : options.arrayDefaults) == null ? void 0 : _b[arrayBase]) ? (_c = options == null ? void 0 : options.arrayDefaults) == null ? void 0 : _c[arrayBase] : [];
367
+ const currentArrayAtPath = resolveValueByPath(newProps, arrayBase);
368
+ const currentArray = Array.isArray(currentArrayAtPath) ? currentArrayAtPath : [];
369
+ let targetLength = 0;
370
+ const ruleSourceArrays = rules.map(({ entry, fromPaths, result }) => {
371
+ const isFromArrayPath = typeof fromPaths[0] === "string" && isArrayMappingPath(fromPaths[0]);
372
+ const sourceArray = isFromArrayPath ? Array.isArray(result) ? result : result !== void 0 ? [result] : [] : Array.isArray(result) ? result : defaultArray.map(() => result);
373
+ targetLength = Math.max(targetLength, sourceArray.length);
374
+ return sourceArray;
375
+ });
376
+ const constructed = Array.from({ length: targetLength }).map((_, idx) => {
377
+ const defaultItem = defaultArray[idx] && typeof defaultArray[idx] === "object" ? defaultArray[idx] : {};
378
+ const currentItem = currentArray[idx] && typeof currentArray[idx] === "object" ? currentArray[idx] : {};
379
+ let mergedDefaults = {};
380
+ for (const rule of rules) {
381
+ let ruleDefaults = rule.entry.unmappedArrayItemDefaultValues || rule.entry.defaultOverrides || {};
382
+ if (typeof ruleDefaults === "string") {
383
+ try {
384
+ ruleDefaults = JSON.parse(ruleDefaults);
385
+ } catch (e) {
884
386
  }
885
- ]
886
- },
887
- _fields: {
888
- type: "array",
889
- label: "Fields",
890
- defaultItemProps: {
891
- name: "New Field",
892
- type: "text"
893
- },
894
- getItemSummary(item, index) {
895
- return item.name || `Field ${(index || 0) + 1}`;
896
- },
897
- arrayFields: {
898
- name: { type: "text", label: "Name" },
899
- type: {
900
- type: "select",
901
- label: "Type",
902
- options: [
903
- { label: "Text", value: "text" },
904
- { label: "Textarea", value: "textarea" },
905
- { label: "Number", value: "number" },
906
- { label: "Select", value: "select" },
907
- { label: "Radio", value: "radio" },
908
- { label: "Array", value: "array" },
909
- { label: "Object", value: "object" },
910
- // { label: "Reference", value: "reference" },
911
- ...customTypeOptions
912
- ]
387
+ }
388
+ mergedDefaults = __spreadValues(__spreadValues({}, mergedDefaults), ruleDefaults);
389
+ }
390
+ const baseItem = __spreadValues(__spreadValues({}, defaultItem), mergedDefaults);
391
+ let newItem = void 0;
392
+ for (const key of Object.keys(baseItem)) {
393
+ if (!(key in currentItem) && baseItem[key] !== void 0) {
394
+ if (!newItem) newItem = __spreadValues({}, currentItem);
395
+ if (newItem) {
396
+ newItem[key] = baseItem[key];
913
397
  }
914
398
  }
915
399
  }
916
- }, overrides.additionalRootFields || {}),
917
- resolveFields({ props: data }, { fields, changed }) {
918
- const newFields = __spreadValues({}, fields);
919
- const rootFields = Array.isArray(
920
- data == null ? void 0 : data._fields
921
- ) ? (data == null ? void 0 : data._fields) || [] : [];
922
- const rootFieldSettings = (data == null ? void 0 : data._fieldSettings) || {};
923
- if (changed._fields || changed._fieldSettings) {
924
- if (rootFields.length) {
925
- newFields._fieldSettings = {
926
- type: "object",
927
- label: "Field Settings",
928
- objectFields: get_field_settings_default(
929
- rootFields,
930
- rootFieldSettings,
931
- customFields
932
- )
933
- };
934
- } else {
935
- delete newFields._fieldSettings;
400
+ for (let i = 0; i < rules.length; i++) {
401
+ const { toPath } = rules[i];
402
+ const subProp = getArrayItemSubPath(toPath) || "";
403
+ const mappedValue = ruleSourceArrays[i][idx];
404
+ if (subProp && mappedValue !== void 0) {
405
+ const existingValue = resolveValueByPath(newItem || currentItem, subProp);
406
+ if (!(0, import_react_fast_compare.default)(existingValue, mappedValue)) {
407
+ newItem = setImmutablePropertyByPath(newItem || currentItem, subProp, mappedValue);
408
+ }
936
409
  }
937
410
  }
938
- return newFields;
939
- },
940
- // resolveData: (props, params) => {
941
- // if (overrides.resolveRootData) {
942
- // return overrides.resolveRootData(props, params, { editingComponent });
943
- // }
944
- // const result: {
945
- // props: RootData<AsFieldProps<WithChildren<BuilderRootConfig>>>;
946
- // readOnly: Readonly<Record<string, boolean>> | undefined;
947
- // } = {
948
- // props,
949
- // readOnly: undefined,
950
- // };
951
- // return result;
952
- // },
953
- render: (props) => {
954
- const fieldSettings = props == null ? void 0 : props._fieldSettings;
955
- const data = useCustomPuck((s) => s.appState.data);
956
- const dispatch = useCustomPuck((s) => s.dispatch);
957
- const getSelectorForId = useCustomPuck((s) => s.getSelectorForId);
958
- const setVersion = useSoftConfig((s) => s.builder.setVersion);
959
- const state = useSoftConfig((s) => s.state);
960
- (0, import_react2.useEffect)(() => {
961
- if (!fieldSettings || Object.keys(fieldSettings).length === 0) return;
962
- const replacements = [];
963
- (0, import_puck2.walkTree)(
964
- {
965
- content: (data == null ? void 0 : data.content) || [],
966
- root: (data == null ? void 0 : data.root) || {}
967
- },
968
- {
969
- components: config.components
970
- },
971
- (content) => content.map((child) => {
972
- var _a;
973
- const map = ((_a = child.props) == null ? void 0 : _a._map) || [];
974
- if (!map.length) return child;
975
- const cleanProps = getSerializableProps(child.props);
976
- const { newProps, changed } = applyMapping(
977
- cleanProps,
978
- fieldSettings,
979
- map,
980
- "fieldSettings"
981
- );
982
- if (!changed || (0, import_react_fast_compare2.default)(cleanProps, newProps)) return child;
983
- replacements.push({
984
- id: child.props.id,
985
- data: __spreadProps(__spreadValues({}, child), { props: newProps })
986
- });
987
- return child;
988
- })
989
- );
990
- if (!replacements.length) return;
991
- replacements.forEach((replacement) => {
992
- const itemSelector = getSelectorForId(replacement.id);
993
- if (!itemSelector) return;
994
- dispatch({
995
- type: "replace",
996
- data: replacement.data,
997
- destinationIndex: itemSelector.index,
998
- destinationZone: itemSelector.zone
999
- });
1000
- });
1001
- }, [fieldSettings, data, dispatch, getSelectorForId]);
1002
- (0, import_react2.useEffect)(() => {
1003
- var _a;
1004
- if (state !== "remodeling" || !(props == null ? void 0 : props._version) || !(props == null ? void 0 : props._name)) return;
1005
- const currentVersion = props._version;
1006
- if (((_a = props._versions) == null ? void 0 : _a.includes(currentVersion)) && props._versions.length > 1) {
1007
- setVersion(props._name, currentVersion, props, dispatch);
411
+ return newItem !== void 0 ? newItem : currentItem;
412
+ });
413
+ let arrayChanged = currentArray.length !== constructed.length;
414
+ if (!arrayChanged) {
415
+ for (let i = 0; i < currentArray.length; i++) {
416
+ if (currentArray[i] !== constructed[i]) {
417
+ arrayChanged = true;
418
+ break;
1008
419
  }
1009
- }, [props == null ? void 0 : props._version]);
1010
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: props.children });
1011
- }
1012
- };
1013
- };
1014
-
1015
- // src/puck/lib/builder/generate-field-options.ts
1016
- var hasArrayMappingPath = (value) => value.includes("[]");
1017
- var isBareArrayPath = (value) => !hasArrayMappingPath(value) && !value.includes(".");
1018
- function filterToOptionsForFrom(fromPath, toOptions) {
1019
- if (!fromPath) return toOptions;
1020
- const fromHasArrayMapping = hasArrayMappingPath(fromPath);
1021
- const fromIsBareArray = isBareArrayPath(fromPath);
1022
- return toOptions.filter((option) => {
1023
- const optionHasArrayMapping = hasArrayMappingPath(option.value);
1024
- if (fromHasArrayMapping) {
1025
- return optionHasArrayMapping;
420
+ }
1026
421
  }
1027
- if (fromIsBareArray) {
1028
- return isBareArrayPath(option.value);
422
+ if (arrayChanged) {
423
+ newProps = setImmutablePropertyByPath(newProps, arrayBase, constructed);
424
+ changed = true;
1029
425
  }
1030
- return !optionHasArrayMapping;
1031
- });
1032
- }
1033
- function generateFieldOptions(fields, prefix = "") {
1034
- const opts = [];
1035
- function recurse(current, prefix2) {
1036
- Object.entries(current).forEach(([key, fld]) => {
1037
- if (fld.type === "slot") return;
1038
- if (key === "_map") return;
1039
- if (key === "_slotEnabled") return;
1040
- const path = prefix2 ? `${prefix2}.${key}` : key;
1041
- if (fld.type === "object" && fld.objectFields) {
1042
- recurse(fld.objectFields, path);
1043
- } else if (fld.type === "array" && fld.arrayFields) {
1044
- recurse(
1045
- fld.arrayFields,
1046
- path + "[]"
1047
- );
1048
- } else {
1049
- opts.push({ label: path, value: path, type: fld.type });
1050
- }
1051
- });
1052
426
  }
1053
- recurse(fields, prefix);
1054
- return opts;
427
+ return { newProps, mappedArrayPaths, changed };
1055
428
  }
1056
- function generateDynamicFieldOptions(_fields, _fieldSettings, customFields, prefix = "") {
1057
- const opts = [];
1058
- if (!_fields) return opts;
1059
- function recurse(fields, fieldSettings, currentPrefix) {
1060
- fields.forEach((field) => {
1061
- var _a;
1062
- const settings = fieldSettings[field.name];
1063
- const customReturnType = resolveCustomFieldReturnType(
1064
- field.type,
1065
- customFields
1066
- );
1067
- const path = currentPrefix ? `${currentPrefix}.${field.name}` : field.name;
1068
- if (customReturnType) {
1069
- if (customReturnType === "array" || customReturnType === "object") {
1070
- const customSchema = resolveCustomFieldSchema(field.type, customFields);
1071
- if (!customSchema) {
1072
- return;
1073
- }
1074
- recurse(
1075
- customSchema.subFields,
1076
- customSchema.subFieldSettings,
1077
- path + (customReturnType === "array" ? "[]" : "")
1078
- );
1079
- return;
1080
- }
1081
- opts.push({
1082
- label: path,
1083
- value: path,
1084
- type: mapCustomReturnTypeToMappingType(customReturnType)
1085
- });
1086
- return;
1087
- }
1088
- if (!isBuiltInSoftFieldType(field.type)) {
1089
- return;
1090
- }
1091
- if ((_a = settings == null ? void 0 : settings.subFields) == null ? void 0 : _a.length) {
1092
- recurse(
1093
- settings.subFields,
1094
- settings.subFieldSettings || {},
1095
- path + (field.type === "array" ? "[]" : "")
1096
- );
1097
- } else if (field.type !== "array" && field.type !== "object") {
1098
- opts.push({ label: path, value: path, type: field.type });
429
+
430
+ // src/puck/lib/root-action-handler.ts
431
+ var currentGeneration = 0;
432
+ function hasDefaultValueChanged(prev, curr) {
433
+ var _a, _b;
434
+ if (!prev && !curr) return false;
435
+ if (!prev || !curr) return true;
436
+ if (!(0, import_react_fast_compare2.default)(prev == null ? void 0 : prev.defaultValue, curr == null ? void 0 : curr.defaultValue)) return true;
437
+ if ((prev == null ? void 0 : prev.subFieldSettings) || (curr == null ? void 0 : curr.subFieldSettings)) {
438
+ const subKeys = /* @__PURE__ */ new Set([
439
+ ...Object.keys((prev == null ? void 0 : prev.subFieldSettings) || {}),
440
+ ...Object.keys((curr == null ? void 0 : curr.subFieldSettings) || {})
441
+ ]);
442
+ for (const subKey of subKeys) {
443
+ if (hasDefaultValueChanged(
444
+ (_a = prev == null ? void 0 : prev.subFieldSettings) == null ? void 0 : _a[subKey],
445
+ (_b = curr == null ? void 0 : curr.subFieldSettings) == null ? void 0 : _b[subKey]
446
+ )) {
447
+ return true;
1099
448
  }
1100
- });
449
+ }
1101
450
  }
1102
- recurse(_fields, _fieldSettings || {}, prefix);
1103
- return opts;
451
+ return false;
1104
452
  }
1105
-
1106
- // src/puck/components/error-boundary/index.tsx
1107
- var import_react3 = require("react");
1108
-
1109
- // src/puck/lib/get-class-name-factory.ts
1110
- var import_classnames = __toESM(require("classnames"));
1111
- var getClassNameFactory = (rootClass, styles, config = { baseClass: "" }) => (options = {}) => {
1112
- if (typeof options === "string") {
1113
- const descendant = options;
1114
- const style = styles[`${rootClass}-${descendant}`];
1115
- if (style) {
1116
- return config.baseClass + styles[`${rootClass}-${descendant}`] || "";
453
+ var processReplacements = (appState, get, fieldSettings, changedKeys, zones, nodes) => __async(null, null, function* () {
454
+ var _a, _b;
455
+ const generation = ++currentGeneration;
456
+ yield new Promise((resolve) => setTimeout(resolve, 150));
457
+ if (generation !== currentGeneration) return;
458
+ const { puckDispatch, editableComponentIds } = get();
459
+ if (!puckDispatch) return;
460
+ if (changedKeys.size === 0) return;
461
+ const replacements = [];
462
+ const editableSet = new Set(editableComponentIds || []);
463
+ const hasEditableFilter = editableSet.size > 0;
464
+ const nodeEntries = Object.entries(nodes);
465
+ for (let i = 0; i < nodeEntries.length; i++) {
466
+ if (generation !== currentGeneration) return;
467
+ if (i > 0 && i % 50 === 0) {
468
+ yield new Promise((resolve) => setTimeout(resolve, 0));
469
+ if (generation !== currentGeneration) return;
1117
470
  }
1118
- return "";
1119
- } else if (typeof options === "object") {
1120
- const modifiers = options;
1121
- const prefixedModifiers = {};
1122
- for (let modifier in modifiers) {
1123
- prefixedModifiers[styles[`${rootClass}--${modifier}`]] = modifiers[modifier];
471
+ const [id, node] = nodeEntries[i];
472
+ if (hasEditableFilter && !editableSet.has(id)) {
473
+ continue;
1124
474
  }
1125
- const c = styles[rootClass];
1126
- return config.baseClass + (0, import_classnames.default)(__spreadValues({
1127
- [c]: !!c
1128
- }, prefixedModifiers));
1129
- } else {
1130
- return config.baseClass + styles[rootClass] || "";
1131
- }
1132
- };
1133
- var get_class_name_factory_default = getClassNameFactory;
1134
-
1135
- // css-module:/home/osamu/Documents/netlisian-soft/packages/soft-config/src/puck/components/error-boundary/styles.module.css#css-module
1136
- var styles_module_default = { "ErrorBoundary": "_ErrorBoundary_1xl05_5", "ErrorBoundary-title": "_ErrorBoundary-title_1xl05_21", "ErrorBoundary-details": "_ErrorBoundary-details_1xl05_31", "ErrorBoundary-button": "_ErrorBoundary-button_1xl05_39" };
1137
-
1138
- // src/puck/components/error-boundary/index.tsx
1139
- var import_jsx_runtime3 = require("react/jsx-runtime");
1140
- var getClassName = get_class_name_factory_default("ErrorBoundary", styles_module_default);
1141
- var ErrorBoundary = class extends import_react3.Component {
1142
- constructor(props) {
1143
- super(props);
1144
- this.resetError = () => {
1145
- this.setState({
1146
- hasError: false,
1147
- error: null
1148
- });
1149
- };
1150
- this.state = {
1151
- hasError: false,
1152
- error: null
1153
- };
1154
- }
1155
- static getDerivedStateFromError(error) {
1156
- return {
1157
- hasError: true,
1158
- error
1159
- };
1160
- }
1161
- componentDidCatch(error, errorInfo) {
1162
- console.error("Error caught by ErrorBoundary:", error, errorInfo);
475
+ const map = ((_a = node.data.props) == null ? void 0 : _a._map) || [];
476
+ if (!map.length) continue;
477
+ let isAffected = false;
478
+ const flatProps = ((_b = node.flatData) == null ? void 0 : _b.props) || {};
479
+ for (const [flatKey, flatValue] of Object.entries(flatProps)) {
480
+ if (flatKey.includes("_map") && flatKey.includes("from") && typeof flatValue === "string") {
481
+ if (changedKeys.has(flatValue) || Array.from(changedKeys).some(
482
+ (ck) => flatValue.startsWith(ck + ".") || flatValue.startsWith(ck + "[")
483
+ )) {
484
+ isAffected = true;
485
+ break;
486
+ }
487
+ }
488
+ }
489
+ if (!isAffected) continue;
490
+ const { newProps } = applyMapping(
491
+ __spreadValues({}, node.data.props),
492
+ fieldSettings,
493
+ map,
494
+ "fieldSettings"
495
+ );
496
+ replacements.push({
497
+ id,
498
+ data: __spreadProps(__spreadValues({}, node.data), {
499
+ props: __spreadValues(__spreadValues({}, node.data.props), newProps)
500
+ })
501
+ });
1163
502
  }
1164
- render() {
1165
- if (this.state.hasError) {
1166
- if (typeof this.props.fallback === "function") {
1167
- return this.props.fallback(this.state.error, this.resetError);
503
+ if (!replacements.length) return;
504
+ requestAnimationFrame(() => {
505
+ replacements.forEach((replacement) => {
506
+ var _a2;
507
+ const node = nodes[replacement.id];
508
+ if (!node) return;
509
+ const zoneName = `${node.parentId}:${node.zone}`;
510
+ const index = (_a2 = zones[zoneName]) == null ? void 0 : _a2.contentIds.indexOf(replacement.id);
511
+ if (index !== void 0 && index !== -1) {
512
+ puckDispatch({
513
+ type: "replace",
514
+ destinationIndex: index,
515
+ destinationZone: zoneName,
516
+ data: replacement.data,
517
+ ui: void 0
518
+ });
1168
519
  }
1169
- if (this.props.fallback) {
1170
- return this.props.fallback;
520
+ });
521
+ });
522
+ });
523
+ var processVersionChange = (rootProps, get, zones, nodes) => {
524
+ const currentVersion = rootProps._version;
525
+ const versions = rootProps._versions || [];
526
+ if (versions.includes(currentVersion) && versions.length > 1) {
527
+ const puckDispatch = get().puckDispatch;
528
+ if (puckDispatch) {
529
+ get().builder.setVersion(
530
+ rootProps._name,
531
+ currentVersion,
532
+ rootProps,
533
+ puckDispatch,
534
+ // Mock getItemBySelector using indexes
535
+ (selector) => {
536
+ var _a;
537
+ if (!selector.zone) return void 0;
538
+ const id = (_a = zones[selector.zone]) == null ? void 0 : _a.contentIds[selector.index];
539
+ return id ? nodes[id].data : void 0;
540
+ },
541
+ // Mock getSelectorForId using indexes
542
+ (id) => {
543
+ var _a;
544
+ const node = nodes[id];
545
+ if (!node) return void 0;
546
+ const index = (_a = zones[node.zone]) == null ? void 0 : _a.contentIds.indexOf(id);
547
+ return { zone: node.zone, index };
548
+ }
549
+ );
550
+ }
551
+ }
552
+ };
553
+ var rootActionHandler = (set, get) => (action, appState, previousState) => {
554
+ const storeState = get().state;
555
+ if (storeState !== "building" && storeState !== "remodeling" || action.type !== "replaceRoot") {
556
+ return;
557
+ }
558
+ const { zones, nodes } = appState.indexes;
559
+ const rootProps = appState.data.root.props;
560
+ const previousRootProps = (previousState == null ? void 0 : previousState.data.root).props;
561
+ const fieldSettings = rootProps == null ? void 0 : rootProps._fieldSettings;
562
+ const previousFieldSettings = previousRootProps == null ? void 0 : previousRootProps._fieldSettings;
563
+ if (fieldSettings) {
564
+ const changedKeys = /* @__PURE__ */ new Set();
565
+ const allKeys = /* @__PURE__ */ new Set([
566
+ ...Object.keys(previousFieldSettings || {}),
567
+ ...Object.keys(fieldSettings || {})
568
+ ]);
569
+ for (const key of allKeys) {
570
+ if (hasDefaultValueChanged(previousFieldSettings == null ? void 0 : previousFieldSettings[key], fieldSettings == null ? void 0 : fieldSettings[key])) {
571
+ changedKeys.add(key);
1171
572
  }
1172
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: getClassName(), children: [
1173
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h3", { className: getClassName("title"), children: "Component Error" }),
1174
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("details", { className: getClassName("details"), children: [
1175
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("summary", { children: "Show error details" }),
1176
- this.state.error && this.state.error.toString()
1177
- ] }),
1178
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1179
- "button",
1180
- {
1181
- onClick: this.resetError,
1182
- className: getClassName("button"),
1183
- children: "Try Again"
1184
- }
1185
- )
1186
- ] });
1187
573
  }
1188
- return this.props.children;
574
+ if (changedKeys.size > 0) {
575
+ processReplacements(appState, get, fieldSettings, changedKeys, zones, nodes);
576
+ }
577
+ }
578
+ if (storeState === "remodeling" && (rootProps == null ? void 0 : rootProps._version) && (rootProps == null ? void 0 : rootProps._name) && (rootProps == null ? void 0 : rootProps._version) !== (previousRootProps == null ? void 0 : previousRootProps._version)) {
579
+ processVersionChange(rootProps, get, zones, nodes);
1189
580
  }
1190
581
  };
1191
582
 
1192
- // src/puck/lib/builder/builder-config.tsx
1193
- var import_jsx_runtime4 = require("react/jsx-runtime");
1194
- var builderConfig = (config, overrides, editingComponent, showVersionFields = true, dependents, customFields) => ({
1195
- root: builderRootConfig(
1196
- config,
1197
- overrides,
1198
- editingComponent,
1199
- showVersionFields,
1200
- customFields
1201
- ),
1202
- components: Object.entries(__spreadValues({}, config.components)).reduce(
1203
- (acc, [name, component]) => {
1204
- const tempComponent = __spreadProps(__spreadValues({}, component), {
1205
- permissions: {
1206
- insert: editingComponent !== name && !(dependents == null ? void 0 : dependents.has(name))
1207
- },
1208
- resolveFields(data, params) {
1209
- return __async(this, null, function* () {
1210
- var _a2;
1211
- let fields = {};
1212
- if (!fields._slot) {
1213
- const slotFields = Object.entries(params.fields).filter(
1214
- ([_, field]) => field.type === "slot"
1215
- );
1216
- if (slotFields.length)
1217
- fields._slot = {
1218
- type: "array",
1219
- label: "Enable Dropdown Slots",
1220
- getItemSummary(item, index) {
1221
- return item.slot || `Slot ${(index || 0) + 1}`;
1222
- },
1223
- arrayFields: {
1224
- slot: {
1225
- type: "select",
1226
- label: "Slot",
1227
- options: [
1228
- { label: "Select a slot", value: "" },
1229
- ...slotFields.filter(
1230
- ([fieldName, field]) => {
1231
- var _a3;
1232
- return field.type === "slot" && !(((_a3 = data.props) == null ? void 0 : _a3._slot) || []).some(
1233
- (s) => s.slot === fieldName
1234
- );
1235
- }
1236
- ).map(([fieldName, field]) => ({
1237
- label: field.label || fieldName,
1238
- value: fieldName
1239
- }))
1240
- ]
1241
- },
1242
- name: {
1243
- type: "text",
1244
- label: "Name",
1245
- placeholder: "Optional Slot Name"
1246
- }
1247
- }
1248
- };
1249
- }
1250
- const defaultFields = component.resolveFields ? yield component.resolveFields(data, params) : component.fields || {};
1251
- if (!fields._map || params.changed._map) {
1252
- const rootProps = getRootProps(params.appState);
1253
- const fromOptions = generateDynamicFieldOptions(
1254
- (rootProps == null ? void 0 : rootProps._fields) || [],
1255
- (rootProps == null ? void 0 : rootProps._fieldSettings) || {},
1256
- customFields
1257
- );
1258
- const toOptionsFields = component.resolveFields && ((_a2 = data.props) == null ? void 0 : _a2._map) ? yield component.resolveFields(
1259
- __spreadProps(__spreadValues({}, data), { props: __spreadProps(__spreadValues({}, data.props), { _map: void 0 }) }),
1260
- params
1261
- ) : defaultFields;
1262
- const toOptions = generateFieldOptions(toOptionsFields);
1263
- fields._map = overrides.map ? {
1264
- type: "custom",
1265
- render: ({ value, onChange, id }) => {
1266
- const rootProps2 = getRootProps(params.appState);
1267
- return overrides.map({
1268
- rootProps: rootProps2,
1269
- value,
1270
- onChange,
1271
- id,
1272
- props: data.props || {},
1273
- fromOptions,
1274
- toOptions
1275
- });
1276
- }
1277
- } : (() => {
1278
- var _a3;
1279
- const mapEntries = ((_a3 = data.props) == null ? void 0 : _a3._map) || [];
1280
- const toPaths = mapEntries.flatMap(
1281
- (entry) => Array.isArray(entry.to) ? entry.to : entry.to ? [entry.to] : []
1282
- );
1283
- const toPath = toPaths.find(
1284
- (path) => typeof path === "string" && isArrayMappingPath(path)
1285
- );
1286
- const arrayBaseName = toPath ? getArrayBasePath(toPath) : null;
1287
- const targetArrayField = arrayBaseName ? defaultFields[arrayBaseName] : null;
1288
- const mappedSubProps = /* @__PURE__ */ new Set();
1289
- if (arrayBaseName) {
1290
- toPaths.forEach((path) => {
1291
- if (typeof path !== "string") return;
1292
- if (getArrayBasePath(path) !== arrayBaseName) return;
1293
- const subProp = getArrayItemSubPath(path);
1294
- if (subProp) mappedSubProps.add(subProp);
1295
- });
1296
- }
1297
- const defaultValueFields = {};
1298
- if (targetArrayField && targetArrayField.type === "array" && targetArrayField.arrayFields) {
1299
- const arrayFields = targetArrayField.arrayFields;
1300
- Object.entries(arrayFields).forEach(([key, fld]) => {
1301
- if (mappedSubProps.has(key)) return;
1302
- if (fld.type === "array" || fld.type === "object" || fld.type === "slot") return;
1303
- defaultValueFields[key] = __spreadProps(__spreadValues({}, fld), { label: fld.label || key });
1304
- });
1305
- }
1306
- const baseArrayFields = {
1307
- from: {
1308
- type: "select",
1309
- label: "From",
1310
- options: [
1311
- { label: "Select a field", value: "" },
1312
- ...fromOptions.map(({ label, value }) => ({
1313
- label,
1314
- value
1315
- }))
1316
- ]
1317
- },
1318
- to: {
1319
- type: "select",
1320
- label: "To",
1321
- options: [
1322
- { label: "Select a field", value: "" },
1323
- ...toOptions.map(({ label, value }) => ({
1324
- label,
1325
- value
1326
- }))
1327
- ]
1328
- }
1329
- };
1330
- if (arrayBaseName && Object.keys(defaultValueFields).length > 0) {
1331
- baseArrayFields.unmappedArrayItemDefaultValues = {
1332
- type: "object",
1333
- label: "Default Item Values",
1334
- objectFields: defaultValueFields
1335
- };
1336
- }
1337
- return {
1338
- type: "array",
1339
- label: "Dynamic Field Map",
1340
- arrayFields: baseArrayFields
1341
- };
1342
- })();
1343
- }
1344
- fields = __spreadValues(__spreadValues({}, fields), defaultFields);
1345
- return fields;
1346
- });
1347
- },
1348
- resolveData: ({ props }, { lastData }) => {
1349
- const _map = (props._map || []).map((item) => {
1350
- const newItem = __spreadValues({}, item);
1351
- if (typeof newItem.unmappedArrayItemDefaultValues === "string") {
1352
- try {
1353
- newItem.unmappedArrayItemDefaultValues = JSON.parse(
1354
- newItem.unmappedArrayItemDefaultValues
1355
- );
1356
- } catch (e) {
1357
- newItem.unmappedArrayItemDefaultValues = {};
1358
- }
1359
- } else if (!newItem.unmappedArrayItemDefaultValues) {
1360
- newItem.unmappedArrayItemDefaultValues = {};
1361
- }
1362
- return newItem;
1363
- });
1364
- const readOnlyFields = _map.flatMap((item) => item.to);
1365
- const readOnlyArrayBases = readOnlyFields.filter((field) => typeof field === "string").map(getArrayBasePath).filter((base) => base !== null);
1366
- if (_map.length) {
1367
- return {
1368
- props: __spreadProps(__spreadValues({}, props), { _map }),
1369
- readOnly: [
1370
- ...readOnlyFields.map((f) => String(f)),
1371
- ...readOnlyArrayBases
1372
- ].reduce(
1373
- (acc2, field) => __spreadProps(__spreadValues({}, acc2), { [field]: true }),
1374
- {}
1375
- )
1376
- };
1377
- }
1378
- return {
1379
- props: __spreadProps(__spreadValues({}, props), { _map }),
1380
- readOnly: {}
1381
- };
1382
- },
1383
- render: (props) => {
1384
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ErrorBoundary, { children: component.render(props) });
1385
- }
1386
- });
1387
- acc[name] = tempComponent;
1388
- return acc;
1389
- },
1390
- {}
1391
- ),
1392
- categories: config.categories || {}
1393
- });
583
+ // src/puck/store/slices/builder.tsx
584
+ var import_puck2 = require("@measured/puck");
1394
585
 
1395
586
  // src/puck/lib/soft-component-constants.ts
1396
587
  var TECHNICAL_KEYS = /* @__PURE__ */ new Set(["_map", "_slot", "id", "_version"]);
@@ -1414,6 +605,72 @@ var sanitizeComponent = (component, allowedTypes) => {
1414
605
  });
1415
606
  };
1416
607
 
608
+ // src/puck/lib/custom-fields.ts
609
+ var builtInSoftFieldTypes = /* @__PURE__ */ new Set([
610
+ "text",
611
+ "textarea",
612
+ "number",
613
+ "select",
614
+ "radio",
615
+ "array",
616
+ "object",
617
+ "reference"
618
+ ]);
619
+ var warnedMessages = /* @__PURE__ */ new Set();
620
+ var warnOnce = (message) => {
621
+ if (warnedMessages.has(message)) {
622
+ return;
623
+ }
624
+ warnedMessages.add(message);
625
+ console.warn(message);
626
+ };
627
+ var isBuiltInSoftFieldType = (fieldType) => {
628
+ return builtInSoftFieldTypes.has(fieldType);
629
+ };
630
+ var resolveCustomFieldDefinition = (fieldType, customFields) => {
631
+ if (isBuiltInSoftFieldType(fieldType)) {
632
+ return void 0;
633
+ }
634
+ return customFields == null ? void 0 : customFields[fieldType];
635
+ };
636
+ var resolveCustomFieldReturnType = (fieldType, customFields) => {
637
+ const customField = resolveCustomFieldDefinition(fieldType, customFields);
638
+ if (!customField) {
639
+ return null;
640
+ }
641
+ if (!customField.returnType) {
642
+ warnOnce(
643
+ `[soft-config] Custom field "${fieldType}" is missing a required returnType and will be skipped from mapping options.`
644
+ );
645
+ return null;
646
+ }
647
+ return customField.returnType;
648
+ };
649
+ var resolveCustomFieldSchema = (fieldType, customFields) => {
650
+ const customField = resolveCustomFieldDefinition(fieldType, customFields);
651
+ if (!customField) {
652
+ return null;
653
+ }
654
+ const returnType = resolveCustomFieldReturnType(fieldType, customFields);
655
+ if (!returnType) {
656
+ return null;
657
+ }
658
+ if (returnType !== "array" && returnType !== "object") {
659
+ return null;
660
+ }
661
+ const subFields = customField.subFields || [];
662
+ if (!subFields.length) {
663
+ warnOnce(
664
+ `[soft-config] Custom field "${fieldType}" returns ${returnType} but does not define subFields. It will be skipped from mapping options.`
665
+ );
666
+ return null;
667
+ }
668
+ return {
669
+ subFields,
670
+ subFieldSettings: customField.subFieldSettings || {}
671
+ };
672
+ };
673
+
1417
674
  // src/puck/lib/soft-component-from-appstate.ts
1418
675
  var getSubComponents = (content, componentConfigs, fieldSettings, slots) => {
1419
676
  if (!content || !Array.isArray(content)) return [];
@@ -1569,8 +826,8 @@ var softComponentFromAppState = (appState, configComponents, editedItem, metadat
1569
826
  var _a;
1570
827
  const rootProps = ((_a = appState.data.root) == null ? void 0 : _a.props) || {};
1571
828
  const fields = rootProps._fields || [];
1572
- const field_settings = rootProps._fieldSettings || {};
1573
- const normalizedFieldSettings = __spreadValues({}, field_settings);
829
+ const fieldSettings = rootProps._fieldSettings || {};
830
+ const normalizedFieldSettings = __spreadValues({}, fieldSettings);
1574
831
  (fields || []).forEach((field) => {
1575
832
  const customFieldDefinition = resolveCustomFieldDefinition(
1576
833
  field.type,
@@ -1896,12 +1153,100 @@ var rootZone = "default-zone";
1896
1153
  var rootDroppableId = `${rootAreaId}:${rootZone}`;
1897
1154
 
1898
1155
  // src/puck/components/soft-render/index.tsx
1899
- var import_react4 = __toESM(require("react"));
1156
+ var import_react2 = __toESM(require("react"));
1900
1157
  var import_react_fast_compare3 = __toESM(require("react-fast-compare"));
1901
- var import_jsx_runtime5 = require("react/jsx-runtime");
1158
+
1159
+ // src/puck/components/error-boundary/index.tsx
1160
+ var import_react = require("react");
1161
+
1162
+ // src/puck/lib/get-class-name-factory.ts
1163
+ var import_classnames = __toESM(require("classnames"));
1164
+ var getClassNameFactory = (rootClass, styles, config = { baseClass: "" }) => (options = {}) => {
1165
+ if (typeof options === "string") {
1166
+ const descendant = options;
1167
+ const style = styles[`${rootClass}-${descendant}`];
1168
+ if (style) {
1169
+ return config.baseClass + styles[`${rootClass}-${descendant}`] || "";
1170
+ }
1171
+ return "";
1172
+ } else if (typeof options === "object") {
1173
+ const modifiers = options;
1174
+ const prefixedModifiers = {};
1175
+ for (let modifier in modifiers) {
1176
+ prefixedModifiers[styles[`${rootClass}--${modifier}`]] = modifiers[modifier];
1177
+ }
1178
+ const c = styles[rootClass];
1179
+ return config.baseClass + (0, import_classnames.default)(__spreadValues({
1180
+ [c]: !!c
1181
+ }, prefixedModifiers));
1182
+ } else {
1183
+ return config.baseClass + styles[rootClass] || "";
1184
+ }
1185
+ };
1186
+ var get_class_name_factory_default = getClassNameFactory;
1187
+
1188
+ // css-module:/home/osamu/Documents/netlisian-soft/packages/soft-config/src/puck/components/error-boundary/styles.module.css#css-module
1189
+ var styles_module_default = { "ErrorBoundary": "_ErrorBoundary_1xl05_5", "ErrorBoundary-title": "_ErrorBoundary-title_1xl05_21", "ErrorBoundary-details": "_ErrorBoundary-details_1xl05_31", "ErrorBoundary-button": "_ErrorBoundary-button_1xl05_39" };
1190
+
1191
+ // src/puck/components/error-boundary/index.tsx
1192
+ var import_jsx_runtime = require("react/jsx-runtime");
1193
+ var getClassName = get_class_name_factory_default("ErrorBoundary", styles_module_default);
1194
+ var ErrorBoundary = class extends import_react.Component {
1195
+ constructor(props) {
1196
+ super(props);
1197
+ this.resetError = () => {
1198
+ this.setState({
1199
+ hasError: false,
1200
+ error: null
1201
+ });
1202
+ };
1203
+ this.state = {
1204
+ hasError: false,
1205
+ error: null
1206
+ };
1207
+ }
1208
+ static getDerivedStateFromError(error) {
1209
+ return {
1210
+ hasError: true,
1211
+ error
1212
+ };
1213
+ }
1214
+ componentDidCatch(error, errorInfo) {
1215
+ console.error("Error caught by ErrorBoundary:", error, errorInfo);
1216
+ }
1217
+ render() {
1218
+ if (this.state.hasError) {
1219
+ if (typeof this.props.fallback === "function") {
1220
+ return this.props.fallback(this.state.error, this.resetError);
1221
+ }
1222
+ if (this.props.fallback) {
1223
+ return this.props.fallback;
1224
+ }
1225
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: getClassName(), children: [
1226
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { className: getClassName("title"), children: "Component Error" }),
1227
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("details", { className: getClassName("details"), children: [
1228
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("summary", { children: "Show error details" }),
1229
+ this.state.error && this.state.error.toString()
1230
+ ] }),
1231
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1232
+ "button",
1233
+ {
1234
+ onClick: this.resetError,
1235
+ className: getClassName("button"),
1236
+ children: "Try Again"
1237
+ }
1238
+ )
1239
+ ] });
1240
+ }
1241
+ return this.props.children;
1242
+ }
1243
+ };
1244
+
1245
+ // src/puck/components/soft-render/index.tsx
1246
+ var import_jsx_runtime2 = require("react/jsx-runtime");
1902
1247
  function isPlainObject(val) {
1903
1248
  if (typeof val !== "object" || val === null) return false;
1904
- if (import_react4.default.isValidElement(val)) return false;
1249
+ if (import_react2.default.isValidElement(val)) return false;
1905
1250
  if ("$$typeof" in val) return false;
1906
1251
  const proto = Object.getPrototypeOf(val);
1907
1252
  return proto === Object.prototype || proto === null;
@@ -1909,13 +1254,28 @@ function isPlainObject(val) {
1909
1254
  function cloneData(value) {
1910
1255
  if (value === null || value === void 0) return value;
1911
1256
  if (typeof value === "function") return value;
1912
- if (Array.isArray(value)) return value.map(cloneData);
1257
+ if (Array.isArray(value))
1258
+ return value.map(cloneData);
1913
1259
  if (!isPlainObject(value)) return value;
1914
1260
  return Object.fromEntries(
1915
1261
  Object.entries(value).map(([k, v]) => [k, cloneData(v)])
1916
1262
  );
1917
1263
  }
1918
- var SubComponentRenderer = (0, import_react4.memo)(
1264
+ function shallowEqual(objA, objB) {
1265
+ if (Object.is(objA, objB)) return true;
1266
+ if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null)
1267
+ return false;
1268
+ const keysA = Object.keys(objA);
1269
+ const keysB = Object.keys(objB);
1270
+ if (keysA.length !== keysB.length) return false;
1271
+ for (let i = 0; i < keysA.length; i++) {
1272
+ if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !Object.is(objA[keysA[i]], objB[keysA[i]])) {
1273
+ return false;
1274
+ }
1275
+ }
1276
+ return true;
1277
+ }
1278
+ var SubComponentRenderer = (0, import_react2.memo)(
1919
1279
  ({
1920
1280
  subComponent,
1921
1281
  softComponentFields,
@@ -1927,11 +1287,11 @@ var SubComponentRenderer = (0, import_react4.memo)(
1927
1287
  }) => {
1928
1288
  const { id, puck, editMode } = props;
1929
1289
  const componentConfig = configComponents[subComponent == null ? void 0 : subComponent.type];
1930
- const stableId = (0, import_react4.useMemo)(
1290
+ const stableId = (0, import_react2.useMemo)(
1931
1291
  () => depth === 0 ? id : `${subComponent.type}-${id}-d${depth}-i${index}`,
1932
1292
  [id, depth, subComponent.type, index]
1933
1293
  );
1934
- const finalProps = (0, import_react4.useMemo)(() => {
1294
+ const finalProps = (0, import_react2.useMemo)(() => {
1935
1295
  var _a;
1936
1296
  if (!componentConfig) return {};
1937
1297
  const clonedProps = cloneData(subComponent.fixedProps || {});
@@ -1966,7 +1326,7 @@ var SubComponentRenderer = (0, import_react4.memo)(
1966
1326
  style
1967
1327
  }) => {
1968
1328
  var _a3, _b2;
1969
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className, style, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1329
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className, style, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1970
1330
  SoftRender,
1971
1331
  {
1972
1332
  softComponentFields,
@@ -1993,7 +1353,7 @@ var SubComponentRenderer = (0, import_react4.memo)(
1993
1353
  ]);
1994
1354
  if (!componentConfig) return null;
1995
1355
  const ComponentRender = componentConfig.render;
1996
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1356
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1997
1357
  ComponentRender,
1998
1358
  __spreadValues({
1999
1359
  id: stableId,
@@ -2002,17 +1362,14 @@ var SubComponentRenderer = (0, import_react4.memo)(
2002
1362
  }, finalProps)
2003
1363
  ) });
2004
1364
  },
2005
- // Custom comparator for SubComponentRenderer.
2006
- //
2007
- // Uses deep equality on subComponent (it may be a new reference even when
2008
- // semantically unchanged if the parent SoftRender array is reconstructed)
2009
- // and on props (the primary driver of field-mapping changes).
2010
- // configComponents and softComponentFields are treated as stable config
2011
- // references — reference equality is intentional and fast here.
2012
- (prev, next) => prev.depth === next.depth && prev.index === next.index && prev.configComponents === next.configComponents && prev.softComponentFields === next.softComponentFields && (0, import_react_fast_compare3.default)(prev.props, next.props) && (0, import_react_fast_compare3.default)(prev.subComponent, next.subComponent) && (0, import_react_fast_compare3.default)(prev.softComponentFieldSettings, next.softComponentFieldSettings)
1365
+ (prev, next) => prev.depth === next.depth && prev.index === next.index && prev.configComponents === next.configComponents && prev.softComponentFields === next.softComponentFields && // Shallow compare: props may contain functions/React nodes; deep equality
1366
+ // would risk retaining stale closures and is unnecessarily expensive here.
1367
+ shallowEqual(prev.props, next.props) && // Deep compare: subComponent and fieldSettings are plain JSON configuration
1368
+ // objects with no functions, so structural equality is safe and correct.
1369
+ (0, import_react_fast_compare3.default)(prev.subComponent, next.subComponent) && (0, import_react_fast_compare3.default)(prev.softComponentFieldSettings, next.softComponentFieldSettings)
2013
1370
  );
2014
1371
  SubComponentRenderer.displayName = "SubComponentRenderer";
2015
- var SoftRender = (0, import_react4.memo)(
1372
+ var SoftRender = (0, import_react2.memo)(
2016
1373
  ({
2017
1374
  softComponentFields,
2018
1375
  softComponentFieldSettings,
@@ -2022,9 +1379,9 @@ var SoftRender = (0, import_react4.memo)(
2022
1379
  depth = 0
2023
1380
  }) => {
2024
1381
  if (!(softSubComponent == null ? void 0 : softSubComponent.length)) return null;
2025
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: softSubComponent.map((subComponent, index) => {
1382
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: softSubComponent.map((subComponent, index) => {
2026
1383
  var _a;
2027
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1384
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2028
1385
  SubComponentRenderer,
2029
1386
  {
2030
1387
  subComponent,
@@ -2039,16 +1396,14 @@ var SoftRender = (0, import_react4.memo)(
2039
1396
  );
2040
1397
  }) });
2041
1398
  },
2042
- // Covers all five props not just `props` and `softSubComponent`.
2043
- // configComponents / softComponentFields: reference equality (stable config).
2044
- // softComponentFieldSettings: deep equality (may carry dynamic defaults).
2045
- // props / softSubComponent: deep equality (primary render drivers).
2046
- (prev, next) => prev.configComponents === next.configComponents && prev.softComponentFields === next.softComponentFields && (0, import_react_fast_compare3.default)(prev.props, next.props) && (0, import_react_fast_compare3.default)(prev.softSubComponent, next.softSubComponent) && (0, import_react_fast_compare3.default)(prev.softComponentFieldSettings, next.softComponentFieldSettings)
1399
+ (prev, next) => prev.configComponents === next.configComponents && prev.softComponentFields === next.softComponentFields && // Shallow compare: props may contain functions/React nodes; see shallowEqual.
1400
+ shallowEqual(prev.props, next.props) && // Deep compare: softSubComponent and fieldSettings are plain JSON schemas.
1401
+ (0, import_react_fast_compare3.default)(prev.softSubComponent, next.softSubComponent) && (0, import_react_fast_compare3.default)(prev.softComponentFieldSettings, next.softComponentFieldSettings)
2047
1402
  );
2048
1403
  SoftRender.displayName = "SoftRender";
2049
1404
 
2050
1405
  // src/puck/lib/create-versioned-component-config.tsx
2051
- var import_jsx_runtime6 = require("react/jsx-runtime");
1406
+ var import_jsx_runtime3 = require("react/jsx-runtime");
2052
1407
  var hydrateCustomField = (fieldName, field, fieldSettings, customFields) => {
2053
1408
  var _a;
2054
1409
  if (field.type !== "custom") {
@@ -2106,7 +1461,7 @@ var createVersionedComponentConfig = (componentName, displayName, version, allVe
2106
1461
  var _a2;
2107
1462
  const selectedVersion = props.version || version;
2108
1463
  const versionedComponent = (_a2 = softComponents[componentName]) == null ? void 0 : _a2.versions[selectedVersion];
2109
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1464
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2110
1465
  SoftRender,
2111
1466
  {
2112
1467
  softComponentFields: versionedComponent.fields,
@@ -2121,7 +1476,7 @@ var createVersionedComponentConfig = (componentName, displayName, version, allVe
2121
1476
  };
2122
1477
 
2123
1478
  // src/puck/lib/builder/sub-component-decomposer.tsx
2124
- var subComponentDecomposer = (componentRootData, softSubComponent) => {
1479
+ var subComponentDecomposer = (componentRootData, softSubComponent, keepMapField) => {
2125
1480
  var _a;
2126
1481
  const resolvedProps = __spreadValues({}, softSubComponent.fixedProps);
2127
1482
  (_a = softSubComponent.map) == null ? void 0 : _a.forEach((mapItem) => {
@@ -2144,21 +1499,21 @@ var subComponentDecomposer = (componentRootData, softSubComponent) => {
2144
1499
  Object.entries(softSubComponent.components).forEach(
2145
1500
  ([slotKey, subComponents]) => {
2146
1501
  resolvedProps[slotKey] = subComponents.map(
2147
- (subComponent) => subComponentDecomposer(componentRootData, subComponent)
1502
+ (subComponent) => subComponentDecomposer(componentRootData, subComponent, keepMapField)
2148
1503
  );
2149
1504
  }
2150
1505
  );
2151
1506
  const accItem = {
2152
1507
  type: softSubComponent.type,
2153
- props: __spreadProps(__spreadValues({}, resolvedProps), {
1508
+ props: __spreadValues(__spreadProps(__spreadValues({}, resolvedProps), {
2154
1509
  id: generateId(softSubComponent.type)
2155
- })
1510
+ }), keepMapField ? { _map: softSubComponent.map } : {})
2156
1511
  };
2157
1512
  return accItem;
2158
1513
  };
2159
1514
 
2160
1515
  // src/puck/lib/builder/resolve-soft-component-data.ts
2161
- var resolveSoftComponentData = (props, _fieldSettings = {}) => {
1516
+ var resolveSoftComponentData = (props, _fieldSettings = {}, keepMapField) => {
2162
1517
  const map = props._map;
2163
1518
  if (!(map == null ? void 0 : map.length)) return __spreadValues({}, props);
2164
1519
  const { newProps } = applyMapping(
@@ -2167,11 +1522,16 @@ var resolveSoftComponentData = (props, _fieldSettings = {}) => {
2167
1522
  map,
2168
1523
  "propsFirst"
2169
1524
  );
1525
+ if (keepMapField) {
1526
+ return __spreadProps(__spreadValues({}, newProps), {
1527
+ _map: map
1528
+ });
1529
+ }
2170
1530
  return newProps;
2171
1531
  };
2172
1532
 
2173
1533
  // src/puck/lib/decompose-soft-component.ts
2174
- function decomposeSoftComponent(componentData, softComponents, fieldSettings) {
1534
+ function decomposeSoftComponent(componentData, softComponents, fieldSettings, keepMapField) {
2175
1535
  var _a, _b, _c, _d;
2176
1536
  if (!(componentData == null ? void 0 : componentData.type) || !(componentData == null ? void 0 : componentData.props.id)) {
2177
1537
  throw new Error("Component data must have type and id to decompose.");
@@ -2195,7 +1555,11 @@ function decomposeSoftComponent(componentData, softComponents, fieldSettings) {
2195
1555
  }
2196
1556
  const decomposedComponentData = softComponent.components.map(
2197
1557
  (softSubComponent) => {
2198
- return subComponentDecomposer(resolvedComponentData, softSubComponent);
1558
+ return subComponentDecomposer(
1559
+ resolvedComponentData,
1560
+ softSubComponent,
1561
+ keepMapField
1562
+ );
2199
1563
  }
2200
1564
  );
2201
1565
  return decomposedComponentData;
@@ -2205,9 +1569,9 @@ function isSoftComponent(componentType, softComponents) {
2205
1569
  }
2206
1570
 
2207
1571
  // src/puck/lib/demolish-soft-component.ts
2208
- var import_puck3 = require("@measured/puck");
1572
+ var import_puck = require("@measured/puck");
2209
1573
  function demolishSoftComponent(componentName, data, config, softComponents) {
2210
- const resolvedData = (0, import_puck3.walkTree)(data, config, (components) => {
1574
+ const resolvedData = (0, import_puck.walkTree)(data, config, (components) => {
2211
1575
  components.forEach((componentData, index) => {
2212
1576
  if (componentData.type === componentName) {
2213
1577
  const decomposed = decomposeSoftComponent(componentData, softComponents);
@@ -2294,43 +1658,15 @@ var clearEditVisibility = (doc) => {
2294
1658
  };
2295
1659
 
2296
1660
  // src/puck/store/slices/builder.tsx
2297
- var createBuildersSlice = (set, get, initialConfig) => ({
1661
+ var createBuildersSlice = (set, get) => ({
2298
1662
  build: (history, selectedItem, itemSelector, puckDispatch, name) => {
2299
1663
  if (!selectedItem || !itemSelector) {
2300
1664
  throw new Error("No item selected to build from.");
2301
1665
  }
2302
- puckDispatch({
2303
- type: "set",
2304
- state: (previous) => {
2305
- var _a;
2306
- return {
2307
- ui: __spreadProps(__spreadValues({}, previous.ui), {
2308
- itemSelector: null
2309
- }),
2310
- data: __spreadProps(__spreadValues({}, previous.data), {
2311
- root: __spreadProps(__spreadValues({}, previous.data.root), {
2312
- props: __spreadProps(__spreadValues({}, (_a = previous.data.root) == null ? void 0 : _a.props), {
2313
- _name: name || "New Soft Component"
2314
- })
2315
- })
2316
- // content: [{ ...selectedItem }],
2317
- })
2318
- };
2319
- }
2320
- });
2321
- const config = __spreadValues({}, get().softConfig);
2322
- const overrides = get().overrides;
2323
- const buildConfig = builderConfig(
2324
- config,
2325
- overrides,
2326
- void 0,
2327
- get().showVersionFields,
2328
- void 0,
2329
- get().customFields
2330
- );
1666
+ const config = get().softConfig;
2331
1667
  const editableIds = /* @__PURE__ */ new Set([selectedItem.props.id]);
2332
1668
  const initialContent = [__spreadValues({}, selectedItem)];
2333
- (0, import_puck4.walkTree)(
1669
+ (0, import_puck2.walkTree)(
2334
1670
  {
2335
1671
  root: {},
2336
1672
  content: initialContent
@@ -2350,8 +1686,6 @@ var createBuildersSlice = (set, get, initialConfig) => ({
2350
1686
  })
2351
1687
  );
2352
1688
  set((s) => __spreadProps(__spreadValues({}, s), {
2353
- softConfig: buildConfig,
2354
- storedConfig: config,
2355
1689
  originalHistory: history,
2356
1690
  itemSelector: {
2357
1691
  index: itemSelector.index,
@@ -2361,17 +1695,24 @@ var createBuildersSlice = (set, get, initialConfig) => ({
2361
1695
  editableComponentIds: editableIds,
2362
1696
  state: "building"
2363
1697
  }));
2364
- requestAnimationFrame(
2365
- () => puckDispatch({
1698
+ requestAnimationFrame(() => {
1699
+ puckDispatch({
1700
+ type: "setUi",
1701
+ ui: { itemSelector: null },
1702
+ recordHistory: false
1703
+ });
1704
+ puckDispatch({
2366
1705
  type: "replaceRoot",
2367
1706
  root: {
2368
- title: "Soft Component Builder",
2369
- _name: name || "New Soft Component"
2370
- }
2371
- })
2372
- );
1707
+ props: {
1708
+ _name: name || "New Soft Component"
1709
+ }
1710
+ },
1711
+ recordHistory: false
1712
+ });
1713
+ });
2373
1714
  },
2374
- remodel: (history, selectedItem, itemSelector, puckDispatch) => {
1715
+ remodel: (history, selectedItem, itemSelector, puckDispatch, refreshPermission) => {
2375
1716
  var _a, _b;
2376
1717
  if (!selectedItem || !itemSelector) {
2377
1718
  throw new Error("No item selected to build from.");
@@ -2391,13 +1732,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
2391
1732
  `Soft component "${softComponentName}" with version "${softComponentVersion}" not found.`
2392
1733
  );
2393
1734
  }
2394
- puckDispatch({
2395
- type: "setUi",
2396
- ui: (previous) => __spreadProps(__spreadValues({}, previous), {
2397
- itemSelector: void 0
2398
- })
2399
- });
2400
- const { root, content } = softComponentToAppState(
1735
+ const { root } = softComponentToAppState(
2401
1736
  softComponent,
2402
1737
  softComponentName,
2403
1738
  softComponentVersion,
@@ -2409,82 +1744,104 @@ var createBuildersSlice = (set, get, initialConfig) => ({
2409
1744
  softComponentMeta == null ? void 0 : softComponentMeta.category,
2410
1745
  get().customFields
2411
1746
  );
2412
- const config = __spreadValues({}, get().softConfig);
2413
- const overrides = get().overrides;
1747
+ const config = get().softConfig;
2414
1748
  const dependents = get().dependencyGraph.get(softComponentName) || /* @__PURE__ */ new Set();
2415
- const buildConfig = builderConfig(
2416
- config,
2417
- overrides,
2418
- softComponentName,
2419
- get().showVersionFields,
2420
- dependents,
2421
- get().customFields
2422
- );
2423
- const editableIds = /* @__PURE__ */ new Set([]);
2424
- const decomposedComponents = get().builder.decompose(selectedItem);
2425
- (0, import_puck4.walkTree)(
2426
- { root: {}, content: decomposedComponents || [] },
1749
+ const decomposedComponents = get().builder.decompose(selectedItem, true);
1750
+ const editableIds = /* @__PURE__ */ new Set([decomposedComponents[0].props.id]);
1751
+ const { content: decomposedComponentsWithId } = (0, import_puck2.walkTree)(
1752
+ { root: {}, content: decomposedComponents },
2427
1753
  { components: config.components },
2428
1754
  (components) => {
2429
- components.forEach((comp) => {
2430
- editableIds.add(comp.props.id);
1755
+ components.forEach((comp2) => {
1756
+ const id2 = generateId(comp2.type);
1757
+ comp2.props.id = id2;
1758
+ editableIds.add(id2);
2431
1759
  });
2432
1760
  return components;
2433
1761
  }
2434
1762
  );
2435
- puckDispatch({
2436
- type: "setData",
2437
- data: (prevData) => ({
2438
- root: __spreadProps(__spreadValues({}, root), { _versions: versions }),
2439
- content: (0, import_puck4.walkTree)(__spreadValues({}, prevData), __spreadValues({}, config), (components) => {
2440
- const next = components.map((component) => __spreadProps(__spreadValues({}, component), {
2441
- props: __spreadValues({}, component.props)
2442
- }));
2443
- const index = next.findIndex(
2444
- (component) => component.props.id === selectedItem.props.id
2445
- );
2446
- if (index !== -1) {
2447
- next.splice(
2448
- index,
2449
- 1,
2450
- ...decomposedComponents.map((component) => __spreadProps(__spreadValues({}, component), {
2451
- props: __spreadValues({}, component.props)
2452
- }))
2453
- );
2454
- }
2455
- return next;
2456
- }).content
2457
- })
2458
- });
2459
- requestAnimationFrame(
2460
- () => setEditVisibility(get().iframeDoc, {
2461
- mode: "remodel",
2462
- editableIds
2463
- })
2464
- );
2465
1763
  set((s) => __spreadProps(__spreadValues({}, s), {
2466
- storedConfig: config,
2467
- softConfig: buildConfig,
2468
1764
  originalHistory: history,
2469
1765
  itemSelector: {
2470
1766
  index: itemSelector.index,
2471
1767
  zone: itemSelector.zone || rootDroppableId
2472
1768
  },
2473
- editingComponentId: selectedItem.props.id,
2474
1769
  editingComponent: softComponentName,
1770
+ editingDependents: dependents,
2475
1771
  editableComponentIds: editableIds,
2476
- state: "remodeling"
1772
+ state: "assessing"
2477
1773
  }));
2478
- requestAnimationFrame(
2479
- () => puckDispatch({
2480
- type: "replaceRoot",
2481
- root: {
2482
- title: root.props.title,
2483
- _name: root.props._name,
1774
+ puckDispatch({
1775
+ type: "remove",
1776
+ index: itemSelector.index,
1777
+ zone: itemSelector.zone || rootDroppableId,
1778
+ recordHistory: false
1779
+ });
1780
+ const comp = decomposedComponentsWithId[0];
1781
+ if (!comp) {
1782
+ throw new Error("No decomposed components found.");
1783
+ }
1784
+ const id = comp.props.id;
1785
+ puckDispatch({
1786
+ type: "insert",
1787
+ destinationIndex: itemSelector.index,
1788
+ destinationZone: itemSelector.zone || rootDroppableId,
1789
+ componentType: comp.type,
1790
+ recordHistory: false,
1791
+ id
1792
+ });
1793
+ requestAnimationFrame(() => {
1794
+ var _a2;
1795
+ const _map = ((_a2 = comp.props) == null ? void 0 : _a2._map) || [];
1796
+ const readOnlyFields = _map.flatMap((item) => item.to);
1797
+ const readOnlyArrayBases = readOnlyFields.filter((field) => typeof field === "string").map(getArrayBasePath).filter((base) => base !== null);
1798
+ const readOnly = [
1799
+ ...readOnlyFields.map((f) => String(f)),
1800
+ ...readOnlyArrayBases
1801
+ ].reduce((acc, field) => __spreadProps(__spreadValues({}, acc), { [field]: true }), {});
1802
+ puckDispatch({
1803
+ type: "replace",
1804
+ destinationIndex: itemSelector.index,
1805
+ destinationZone: itemSelector.zone || rootDroppableId,
1806
+ data: __spreadProps(__spreadValues({}, comp), {
1807
+ props: __spreadProps(__spreadValues({}, comp.props), {
1808
+ id
1809
+ }),
1810
+ readOnly
1811
+ }),
1812
+ recordHistory: false
1813
+ });
1814
+ set((s) => __spreadProps(__spreadValues({}, s), {
1815
+ state: "remodeling"
1816
+ }));
1817
+ setEditVisibility(get().iframeDoc, {
1818
+ mode: "remodel",
1819
+ editableIds: new Set(editableIds)
1820
+ });
1821
+ });
1822
+ puckDispatch({
1823
+ type: "replaceRoot",
1824
+ root: {
1825
+ props: __spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, root.props), root.props.title !== void 0 && {
1826
+ title: root.props.title
1827
+ }), root.props._name !== void 0 && {
1828
+ _name: root.props._name
1829
+ }), root.props._category !== void 0 && {
2484
1830
  _category: root.props._category
2485
- }
2486
- })
2487
- );
1831
+ }), {
1832
+ _versions: versions
1833
+ })
1834
+ },
1835
+ recordHistory: false
1836
+ });
1837
+ requestAnimationFrame(() => {
1838
+ puckDispatch({
1839
+ type: "setUi",
1840
+ ui: { itemSelector: null },
1841
+ recordHistory: false
1842
+ });
1843
+ refreshPermission();
1844
+ });
2488
1845
  },
2489
1846
  complete: (appState, setHistories, getItemBySelector) => {
2490
1847
  var _a, _b, _c, _d, _e, _f, _g;
@@ -2524,7 +1881,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
2524
1881
  }
2525
1882
  const storedHistories = get().originalHistory;
2526
1883
  setHistories([...storedHistories]);
2527
- const config = __spreadValues({}, get().softConfig || initialConfig);
1884
+ const config = __spreadValues({}, get().softConfig);
2528
1885
  const mapComponentConfig = get().overrides.mapComponentConfig;
2529
1886
  const newSoftComponentConfig = mapComponentConfig ? mapComponentConfig(componentName, defaultSoftComponentConfig, rootProps) : defaultSoftComponentConfig;
2530
1887
  set((s) => {
@@ -2562,12 +1919,11 @@ var createBuildersSlice = (set, get, initialConfig) => ({
2562
1919
  }) : categories;
2563
1920
  return __spreadProps(__spreadValues({}, s), {
2564
1921
  softConfig: __spreadProps(__spreadValues({}, config), {
2565
- root: __spreadValues({}, initialConfig.root),
2566
1922
  components: nextComponents,
2567
1923
  categories: nextCategories
2568
1924
  }),
2569
- storedConfig: void 0,
2570
1925
  state: "inspecting",
1926
+ // Temporarily shift state to inspect() before finalizing back to ready
2571
1927
  originalHistory: []
2572
1928
  });
2573
1929
  });
@@ -2587,7 +1943,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
2587
1943
  softComponent: completedSoftComponent
2588
1944
  };
2589
1945
  },
2590
- inspect: (componentName, puckDispatch) => {
1946
+ inspect: (componentName, puckDispatch, selectedItemSelector) => {
2591
1947
  if (get().state !== "inspecting") {
2592
1948
  throw new Error("Not in inspecting state.");
2593
1949
  }
@@ -2596,54 +1952,74 @@ var createBuildersSlice = (set, get, initialConfig) => ({
2596
1952
  throw new Error("No selector found for last item.");
2597
1953
  }
2598
1954
  const editableComponentId = get().editingComponentId;
1955
+ const itemSelector = get().itemSelector;
2599
1956
  requestAnimationFrame(() => {
2600
- const config = get().softConfig;
2601
- const newComponent = config.components[componentName];
2602
- const reconstructedTree = (data) => (0, import_puck4.walkTree)(data, config, (components) => {
2603
- return components.map((comp) => {
2604
- if (comp.props.id === editableComponentId) {
2605
- return {
2606
- type: componentName,
2607
- props: __spreadProps(__spreadValues({}, newComponent.defaultProps), {
2608
- id: generateId(componentName)
2609
- })
2610
- };
2611
- }
2612
- return comp;
1957
+ var _a;
1958
+ if (editableComponentId && !Object.keys(get().softComponents).includes(
1959
+ (_a = editableComponentId == null ? void 0 : editableComponentId.split(":")) == null ? void 0 : _a[0].split("-")[0]
1960
+ )) {
1961
+ requestAnimationFrame(() => {
1962
+ puckDispatch({
1963
+ type: "remove",
1964
+ index: itemSelector.index,
1965
+ zone: itemSelector.zone,
1966
+ recordHistory: true
1967
+ });
1968
+ puckDispatch({
1969
+ type: "insert",
1970
+ destinationIndex: itemSelector.index,
1971
+ destinationZone: itemSelector.zone,
1972
+ componentType: componentName,
1973
+ recordHistory: true
1974
+ });
2613
1975
  });
2614
- });
2615
- puckDispatch({
2616
- type: "setData",
2617
- data: (data) => {
2618
- return reconstructedTree(data);
2619
- }
2620
- });
1976
+ }
1977
+ clearEditVisibility(get().iframeDoc);
1978
+ if (!selectedItemSelector && selector.index !== void 0) {
1979
+ puckDispatch({
1980
+ type: "setUi",
1981
+ ui: { itemSelector: selector },
1982
+ recordHistory: false
1983
+ });
1984
+ }
1985
+ set((s) => __spreadProps(__spreadValues({}, s), {
1986
+ state: "ready",
1987
+ setItemSelector: void 0,
1988
+ setOriginalItem: void 0,
1989
+ itemSelector: null,
1990
+ editingComponent: null,
1991
+ editingComponentId: null,
1992
+ editableComponentIds: /* @__PURE__ */ new Set()
1993
+ }));
2621
1994
  });
2622
- requestAnimationFrame(() => clearEditVisibility(get().iframeDoc));
2623
- set((s) => __spreadProps(__spreadValues({}, s), {
2624
- state: "ready",
2625
- setItemSelector: void 0,
2626
- setOriginalItem: void 0,
2627
- editingComponent: null,
2628
- editingComponentId: null,
2629
- editableComponentIds: /* @__PURE__ */ new Set()
2630
- }));
2631
1995
  },
2632
- cancel: (setHistories) => {
1996
+ cancel: (setHistories, puckDispatch, selectedItemSelector) => {
2633
1997
  const storedHistories = get().originalHistory;
2634
- requestAnimationFrame(() => setHistories([...storedHistories]));
2635
- requestAnimationFrame(() => clearEditVisibility(get().iframeDoc));
1998
+ const itemSelector = get().itemSelector;
2636
1999
  set((s) => __spreadProps(__spreadValues({}, s), {
2637
- softConfig: get().storedConfig || initialConfig,
2638
- storedConfig: void 0,
2639
- originalHistory: [],
2640
- itemSelector: null,
2641
- originalItem: null,
2642
- state: "ready",
2643
- editingComponent: null,
2644
- editingComponentId: null,
2645
- editableComponentIds: /* @__PURE__ */ new Set()
2000
+ state: "cancelling"
2646
2001
  }));
2002
+ setHistories([...storedHistories]);
2003
+ requestAnimationFrame(() => {
2004
+ clearEditVisibility(get().iframeDoc);
2005
+ if (!selectedItemSelector && itemSelector) {
2006
+ puckDispatch({
2007
+ type: "setUi",
2008
+ ui: { itemSelector },
2009
+ recordHistory: false
2010
+ });
2011
+ }
2012
+ set((s) => __spreadProps(__spreadValues({}, s), {
2013
+ originalHistory: [],
2014
+ itemSelector: null,
2015
+ originalItem: null,
2016
+ state: "ready",
2017
+ editingComponent: null,
2018
+ editingComponentId: null,
2019
+ editableComponentIds: /* @__PURE__ */ new Set(),
2020
+ editingDependents: /* @__PURE__ */ new Set()
2021
+ }));
2022
+ });
2647
2023
  },
2648
2024
  compose: (appState, componentName, editedItem, displayName, category) => {
2649
2025
  if (!componentName) {
@@ -2688,11 +2064,16 @@ var createBuildersSlice = (set, get, initialConfig) => ({
2688
2064
  get().setSoftComponent(componentName, version, softComponent);
2689
2065
  return [newSoftComponentConfig, version];
2690
2066
  },
2691
- decompose: (componentData) => {
2067
+ decompose: (componentData, keepMapField) => {
2692
2068
  if (!(componentData == null ? void 0 : componentData.type) || !(componentData == null ? void 0 : componentData.props.id)) {
2693
2069
  throw new Error("Component data must have type and id to decompose.");
2694
2070
  }
2695
- return decomposeSoftComponent(componentData, get().softComponents);
2071
+ return decomposeSoftComponent(
2072
+ componentData,
2073
+ get().softComponents,
2074
+ void 0,
2075
+ keepMapField
2076
+ );
2696
2077
  },
2697
2078
  demolish: (componentName, data, puckDispatch) => {
2698
2079
  if (get().state !== "ready") {
@@ -2713,7 +2094,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
2713
2094
  softConfig: result.config
2714
2095
  }));
2715
2096
  },
2716
- setVersion: (componentName, newVersion, currentProps, puckDispatch) => {
2097
+ setVersion: (componentName, newVersion, currentProps, puckDispatch, getItemBySelector, getSelectorForId) => {
2717
2098
  var _a;
2718
2099
  if (get().state !== "remodeling") {
2719
2100
  throw new Error("Can only switch versions during remodeling.");
@@ -2740,12 +2121,91 @@ var createBuildersSlice = (set, get, initialConfig) => ({
2740
2121
  softComponentMeta == null ? void 0 : softComponentMeta.category,
2741
2122
  get().customFields
2742
2123
  );
2743
- puckDispatch({
2744
- type: "setData",
2745
- data: (previous) => __spreadProps(__spreadValues({}, previous), {
2746
- root: __spreadProps(__spreadValues({}, root), { props: __spreadProps(__spreadValues({}, root.props), { _versions: versions }) }),
2747
- content: content || []
2748
- })
2124
+ const editableIds = get().editableComponentIds;
2125
+ if (!editableIds || editableIds.size === 0) return;
2126
+ const firstId = Array.from(editableIds)[0];
2127
+ const itemSelector = getSelectorForId(firstId);
2128
+ if (!itemSelector) return;
2129
+ requestAnimationFrame(() => {
2130
+ const countToRemove = Array.from(editableIds).filter(
2131
+ (id) => {
2132
+ var _a2;
2133
+ return ((_a2 = getSelectorForId(id)) == null ? void 0 : _a2.zone) === itemSelector.zone;
2134
+ }
2135
+ ).length;
2136
+ for (let i = 0; i < countToRemove; i++) {
2137
+ puckDispatch({
2138
+ type: "remove",
2139
+ index: itemSelector.index,
2140
+ zone: itemSelector.zone,
2141
+ recordHistory: false
2142
+ });
2143
+ }
2144
+ const newContent = content || [];
2145
+ const comp = newContent[0];
2146
+ if (comp) {
2147
+ puckDispatch({
2148
+ type: "insert",
2149
+ destinationIndex: itemSelector.index,
2150
+ destinationZone: itemSelector.zone,
2151
+ componentType: comp.type,
2152
+ recordHistory: false
2153
+ });
2154
+ }
2155
+ requestAnimationFrame(() => {
2156
+ if (comp) {
2157
+ const insertedItem = getItemBySelector({
2158
+ index: itemSelector.index,
2159
+ zone: itemSelector.zone
2160
+ });
2161
+ if (insertedItem) {
2162
+ puckDispatch({
2163
+ type: "replace",
2164
+ destinationIndex: itemSelector.index,
2165
+ destinationZone: itemSelector.zone,
2166
+ data: __spreadProps(__spreadValues({}, comp), {
2167
+ props: __spreadProps(__spreadValues({}, comp.props), {
2168
+ id: insertedItem.props.id
2169
+ })
2170
+ }),
2171
+ recordHistory: false
2172
+ });
2173
+ }
2174
+ }
2175
+ puckDispatch({
2176
+ type: "replaceRoot",
2177
+ root: {
2178
+ props: __spreadProps(__spreadValues({}, root.props), {
2179
+ _versions: versions
2180
+ })
2181
+ },
2182
+ recordHistory: false
2183
+ });
2184
+ requestAnimationFrame(() => {
2185
+ const newEditableIds = /* @__PURE__ */ new Set();
2186
+ if (comp) {
2187
+ const finalItem = getItemBySelector({
2188
+ index: itemSelector.index,
2189
+ zone: itemSelector.zone
2190
+ });
2191
+ if (finalItem) {
2192
+ (0, import_puck2.walkTree)(
2193
+ { root: {}, content: [finalItem] },
2194
+ { components: get().softConfig.components },
2195
+ (components) => {
2196
+ components.forEach((c) => newEditableIds.add(c.props.id));
2197
+ return components;
2198
+ }
2199
+ );
2200
+ }
2201
+ }
2202
+ set((s) => __spreadProps(__spreadValues({}, s), { editableComponentIds: newEditableIds }));
2203
+ setEditVisibility(get().iframeDoc, {
2204
+ mode: "remodel",
2205
+ editableIds: newEditableIds
2206
+ });
2207
+ });
2208
+ });
2749
2209
  });
2750
2210
  }
2751
2211
  });
@@ -2962,7 +2422,7 @@ function buildInitialSoftComponents(hardConfig, softComponents, overrides, showV
2962
2422
  }
2963
2423
 
2964
2424
  // src/puck/store/index.tsx
2965
- var createSoftConfigStore = (hardConfig = { components: {} }, softComponents = {}, overrides = {}, onActions, showVersionFields = true, customFields = {}) => {
2425
+ var createSoftConfigStore = (hardConfig = { components: {} }, softComponents = {}, overrides = {}, onActions, showVersionFields = true, customFields = {}, contentAreaNames) => {
2966
2426
  const normalizedSoftComponents = Object.fromEntries(
2967
2427
  Object.entries(softComponents || {}).filter(([key]) => !hardConfig.components || !hardConfig.components[key]).map(([key, value]) => [key, __spreadProps(__spreadValues({}, value), { name: value.name || key })])
2968
2428
  );
@@ -2974,7 +2434,7 @@ var createSoftConfigStore = (hardConfig = { components: {} }, softComponents = {
2974
2434
  const initialDependencyGraph = buildReverseDependencyGraph(
2975
2435
  hydratedSoftComponents
2976
2436
  );
2977
- return (0, import_zustand2.create)()(
2437
+ return (0, import_zustand.create)()(
2978
2438
  (0, import_middleware.subscribeWithSelector)((set, get) => ({
2979
2439
  // ─── Initial State ──────────────────────────────────────────────────────
2980
2440
  state: "ready",
@@ -2992,6 +2452,11 @@ var createSoftConfigStore = (hardConfig = { components: {} }, softComponents = {
2992
2452
  softComponents: hydratedSoftComponents,
2993
2453
  dependencyGraph: initialDependencyGraph,
2994
2454
  showVersionFields,
2455
+ contentAreaNames,
2456
+ setContentAreaNames: (names) => set({ contentAreaNames: names }),
2457
+ puckDispatch: null,
2458
+ setPuckDispatch: (dispatch) => set({ puckDispatch: dispatch }),
2459
+ rootActionHandler: rootActionHandler(set, get),
2995
2460
  // ─── Initial softConfig ─────────────────────────────────────────────────
2996
2461
  softConfig: __spreadProps(__spreadValues({}, hardConfig), {
2997
2462
  components: __spreadValues(__spreadValues({}, hardConfig.components), buildInitialSoftComponents(
@@ -3263,7 +2728,7 @@ var createSoftConfigStore = (hardConfig = { components: {} }, softComponents = {
3263
2728
  })
3264
2729
  })),
3265
2730
  // ─── Builder Slice ────────────────────────────────────────────────────────
3266
- builder: createBuildersSlice(set, get, hardConfig),
2731
+ builder: createBuildersSlice(set, get),
3267
2732
  // ─── Dependency Graph ─────────────────────────────────────────────────────
3268
2733
  rebuildDependents: (componentName) => {
3269
2734
  const state = get();
@@ -3296,8 +2761,39 @@ var createSoftConfigStore = (hardConfig = { components: {} }, softComponents = {
3296
2761
  };
3297
2762
 
3298
2763
  // src/puck/context/storeProvider.tsx
3299
- var import_react5 = require("react");
3300
- var import_jsx_runtime7 = require("react/jsx-runtime");
2764
+ var import_react4 = require("react");
2765
+
2766
+ // src/puck/context/useStore.ts
2767
+ var import_react3 = require("react");
2768
+ var import_zustand2 = require("zustand");
2769
+ var appStoreContext = (0, import_react3.createContext)(null);
2770
+ var createUseSoftConfig = () => {
2771
+ return function useSoftConfig2(selector, equalityFn) {
2772
+ const context = (0, import_react3.useContext)(appStoreContext);
2773
+ if (!context) {
2774
+ throw new Error(
2775
+ "useSoftConfig must be used inside a SoftConfigProvider. Wrap your tree with <SoftConfigProvider value={store}>"
2776
+ );
2777
+ }
2778
+ if (equalityFn) {
2779
+ return (0, import_zustand2.useStore)(context, selector, equalityFn);
2780
+ }
2781
+ return (0, import_zustand2.useStore)(context, selector);
2782
+ };
2783
+ };
2784
+ var useSoftConfig = createUseSoftConfig();
2785
+ var useSoftConfigStore = () => {
2786
+ const context = (0, import_react3.useContext)(appStoreContext);
2787
+ if (!context) {
2788
+ throw new Error(
2789
+ "useSoftConfigStore must be used inside a SoftConfigProvider."
2790
+ );
2791
+ }
2792
+ return context;
2793
+ };
2794
+
2795
+ // src/puck/context/storeProvider.tsx
2796
+ var import_jsx_runtime4 = require("react/jsx-runtime");
3301
2797
  var SoftConfigProvider = ({
3302
2798
  children,
3303
2799
  hardConfig,
@@ -3306,27 +2802,25 @@ var SoftConfigProvider = ({
3306
2802
  overrides,
3307
2803
  value,
3308
2804
  onActions,
3309
- useVersioning = false
2805
+ useVersioning = false,
2806
+ contentAreaNames
3310
2807
  }) => {
3311
- const store = (0, import_react5.useMemo)(
2808
+ const store = (0, import_react4.useMemo)(
3312
2809
  () => value != null ? value : createSoftConfigStore(
3313
2810
  hardConfig,
3314
2811
  softComponents,
3315
2812
  overrides,
3316
2813
  onActions,
3317
2814
  useVersioning,
3318
- customFields
2815
+ customFields,
2816
+ contentAreaNames
3319
2817
  ),
3320
- // eslint-disable-next-line react-hooks/exhaustive-deps
3321
2818
  [value]
3322
- // Intentionally omitting the rest: createSoftConfigStore params are
3323
- // treated as initialisation-time values. If callers need to react to
3324
- // prop changes they should pass a new `value` store instead.
3325
2819
  );
3326
- const [softConfig, setSoftConfig] = (0, import_react5.useState)(
2820
+ const [softConfig, setSoftConfig] = (0, import_react4.useState)(
3327
2821
  () => store.getState().softConfig
3328
2822
  );
3329
- (0, import_react5.useEffect)(() => {
2823
+ (0, import_react4.useEffect)(() => {
3330
2824
  let prev = store.getState().softConfig;
3331
2825
  const unsubscribe = store.subscribe((state) => {
3332
2826
  if (state.softConfig !== prev) {
@@ -3336,17 +2830,17 @@ var SoftConfigProvider = ({
3336
2830
  });
3337
2831
  return unsubscribe;
3338
2832
  }, [store]);
3339
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(appStoreContext.Provider, { value: store, children: children(softConfig) });
2833
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(appStoreContext.Provider, { value: store, children: children(softConfig) });
3340
2834
  };
3341
2835
 
3342
2836
  // src/puck/actions/useBuild.tsx
3343
- var import_puck5 = require("@measured/puck");
2837
+ var import_puck3 = require("@measured/puck");
3344
2838
 
3345
2839
  // src/puck/lib/notify.ts
3346
2840
  var customHandler = null;
3347
2841
  var defaultHandler = (message, type) => {
3348
2842
  if (type === "error") {
3349
- console.error(`[Error] ${message}`);
2843
+ alert(`[Error] ${message}`);
3350
2844
  } else {
3351
2845
  console.log(`[Success] ${message}`);
3352
2846
  }
@@ -3366,10 +2860,10 @@ var notify = {
3366
2860
  };
3367
2861
 
3368
2862
  // src/puck/hooks/useActionEvent.ts
3369
- var import_react6 = require("react");
2863
+ var import_react5 = require("react");
3370
2864
  var useActionEvent = () => {
3371
2865
  const onActions = useSoftConfig((s) => s.onActions);
3372
- const triggerAction = (0, import_react6.useCallback)(
2866
+ const triggerAction = (0, import_react5.useCallback)(
3373
2867
  (event) => __async(null, null, function* () {
3374
2868
  if (onActions) {
3375
2869
  try {
@@ -3385,13 +2879,13 @@ var useActionEvent = () => {
3385
2879
  };
3386
2880
 
3387
2881
  // src/puck/actions/useBuild.tsx
3388
- var useCustomPuck2 = (0, import_puck5.createUsePuck)();
2882
+ var useCustomPuck = (0, import_puck3.createUsePuck)();
3389
2883
  var useBuild = (name) => {
3390
2884
  const build = useSoftConfig((s) => s.builder.build);
3391
- const history = useCustomPuck2((s) => s.history.histories);
3392
- const selectedItem = useCustomPuck2((s) => s.selectedItem);
3393
- const itemSelector = useCustomPuck2((s) => s.appState.ui.itemSelector);
3394
- const dispatch = useCustomPuck2((s) => s.dispatch);
2885
+ const history = useCustomPuck((s) => s.history.histories);
2886
+ const selectedItem = useCustomPuck((s) => s.selectedItem);
2887
+ const itemSelector = useCustomPuck((s) => s.appState.ui.itemSelector);
2888
+ const dispatch = useCustomPuck((s) => s.dispatch);
3395
2889
  const status = useSoftConfig((s) => s.state);
3396
2890
  const { triggerAction } = useActionEvent();
3397
2891
  const handleBuild = () => {
@@ -3410,7 +2904,7 @@ var useBuild = (name) => {
3410
2904
  });
3411
2905
  }
3412
2906
  } catch (error) {
3413
- console.error("Failed to build:", error);
2907
+ alert("Failed to build: " + error);
3414
2908
  notify.error(
3415
2909
  "Failed to build: " + (error instanceof Error ? error.message : String(error))
3416
2910
  );
@@ -3420,17 +2914,17 @@ var useBuild = (name) => {
3420
2914
  };
3421
2915
 
3422
2916
  // src/puck/actions/useRemodel.tsx
3423
- var import_puck6 = require("@measured/puck");
3424
- var useCustomPuck3 = (0, import_puck6.createUsePuck)();
2917
+ var import_puck4 = require("@measured/puck");
2918
+ var useCustomPuck2 = (0, import_puck4.createUsePuck)();
3425
2919
  var useRemodel = () => {
3426
2920
  const remodel = useSoftConfig((s) => s.builder.remodel);
3427
- const history = useCustomPuck3((s) => s.history.histories);
3428
- const selectedItem = useCustomPuck3((s) => s.selectedItem);
3429
- const itemSelector = useCustomPuck3((s) => s.appState.ui.itemSelector);
3430
- const dispatch = useCustomPuck3((s) => s.dispatch);
2921
+ const history = useCustomPuck2((s) => s.history.histories);
2922
+ const selectedItem = useCustomPuck2((s) => s.selectedItem);
2923
+ const itemSelector = useCustomPuck2((s) => s.appState.ui.itemSelector);
2924
+ const dispatch = useCustomPuck2((s) => s.dispatch);
3431
2925
  const status = useSoftConfig((s) => s.state);
3432
2926
  const softComponents = useSoftConfig((s) => s.softComponents);
3433
- const refreshPermissions = useCustomPuck3((s) => s.refreshPermissions);
2927
+ const refreshPermissions = useCustomPuck2((s) => s.refreshPermissions);
3434
2928
  const { triggerAction } = useActionEvent();
3435
2929
  const handleRemodel = (componentName) => {
3436
2930
  var _a, _b, _c;
@@ -3446,7 +2940,13 @@ var useRemodel = () => {
3446
2940
  const selectedVersion = ((_a = selectedItem == null ? void 0 : selectedItem.props) == null ? void 0 : _a.version) || ((_b = softComponents[name]) == null ? void 0 : _b.defaultVersion);
3447
2941
  const selectedSoftComponent = selectedVersion ? (_c = softComponents[name]) == null ? void 0 : _c.versions[selectedVersion] : void 0;
3448
2942
  try {
3449
- remodel(history, selectedItem, itemSelector, dispatch, refreshPermissions);
2943
+ remodel(
2944
+ history,
2945
+ selectedItem,
2946
+ itemSelector,
2947
+ dispatch,
2948
+ refreshPermissions
2949
+ );
3450
2950
  void triggerAction({
3451
2951
  type: "remodel",
3452
2952
  payload: {
@@ -3464,9 +2964,9 @@ var useRemodel = () => {
3464
2964
  }
3465
2965
  return { id: name, version: selectedVersion };
3466
2966
  } catch (error) {
3467
- console.error("Failed to remodel:", error);
2967
+ alert("Failed to remodel: " + error);
3468
2968
  notify.error(
3469
- "Failed to remodel: " + (error instanceof Error ? error.message : String(error))
2969
+ "Failed to remodel: " + (error instanceof Error ? error.message : String(error)) + " " + String()
3470
2970
  );
3471
2971
  return null;
3472
2972
  }
@@ -3479,18 +2979,18 @@ var useRemodel = () => {
3479
2979
  };
3480
2980
 
3481
2981
  // src/puck/actions/useComplete.tsx
3482
- var import_puck7 = require("@measured/puck");
3483
- var import_react7 = require("react");
3484
- var useCustomPuck4 = (0, import_puck7.createUsePuck)();
2982
+ var import_puck5 = require("@measured/puck");
2983
+ var import_react6 = require("react");
2984
+ var useCustomPuck3 = (0, import_puck5.createUsePuck)();
3485
2985
  var useComplete = () => {
3486
2986
  const complete = useSoftConfig((s) => s.builder.complete);
3487
- const appState = useCustomPuck4((s) => s.appState);
3488
- const setHistories = useCustomPuck4((s) => s.history.setHistories);
3489
- const getItemBySelector = useCustomPuck4((s) => s.getItemBySelector);
2987
+ const appState = useCustomPuck3((s) => s.appState);
2988
+ const setHistories = useCustomPuck3((s) => s.history.setHistories);
2989
+ const getItemBySelector = useCustomPuck3((s) => s.getItemBySelector);
3490
2990
  const status = useSoftConfig((s) => s.state);
3491
- const [newComponent, setNewComponent] = (0, import_react7.useState)(null);
2991
+ const [newComponent, setNewComponent] = (0, import_react6.useState)(null);
3492
2992
  const { triggerAction } = useActionEvent();
3493
- const handleComplete = (0, import_react7.useCallback)(() => {
2993
+ const handleComplete = (0, import_react6.useCallback)(() => {
3494
2994
  if (status === "ready") {
3495
2995
  notify.error("Not building or remodeling a component.");
3496
2996
  return null;
@@ -3524,11 +3024,13 @@ var useComplete = () => {
3524
3024
  };
3525
3025
 
3526
3026
  // src/puck/actions/useCancel.tsx
3527
- var import_puck8 = require("@measured/puck");
3528
- var useCustomPuck5 = (0, import_puck8.createUsePuck)();
3027
+ var import_puck6 = require("@measured/puck");
3028
+ var useCustomPuck4 = (0, import_puck6.createUsePuck)();
3529
3029
  var useCancel = () => {
3530
3030
  const cancel = useSoftConfig((s) => s.builder.cancel);
3531
- const setHistories = useCustomPuck5((s) => s.history.setHistories);
3031
+ const setHistories = useCustomPuck4((s) => s.history.setHistories);
3032
+ const puckDispatch = useCustomPuck4((s) => s.dispatch);
3033
+ const selectedItemSelector = useCustomPuck4((s) => s.appState.ui.itemSelector);
3532
3034
  const status = useSoftConfig((s) => s.state);
3533
3035
  const { triggerAction } = useActionEvent();
3534
3036
  const handleCancel = () => {
@@ -3537,13 +3039,13 @@ var useCancel = () => {
3537
3039
  return;
3538
3040
  }
3539
3041
  try {
3540
- cancel(setHistories);
3042
+ cancel(setHistories, puckDispatch, selectedItemSelector);
3541
3043
  void triggerAction({
3542
3044
  type: "cancel",
3543
3045
  payload: {}
3544
3046
  });
3545
3047
  } catch (error) {
3546
- console.error("Failed to cancel:", error);
3048
+ alert("Failed to cancel: " + error);
3547
3049
  notify.error(
3548
3050
  "Failed to cancel: " + (error instanceof Error ? error.message : String(error))
3549
3051
  );
@@ -3554,22 +3056,22 @@ var useCancel = () => {
3554
3056
  };
3555
3057
 
3556
3058
  // src/puck/actions/useInspect.tsx
3557
- var import_puck9 = require("@measured/puck");
3558
- var import_react8 = require("react");
3559
- var useCustomPuck6 = (0, import_puck9.createUsePuck)();
3059
+ var import_puck7 = require("@measured/puck");
3060
+ var import_react7 = require("react");
3061
+ var useCustomPuck5 = (0, import_puck7.createUsePuck)();
3560
3062
  var useInspect = (component) => {
3561
3063
  const inspect = useSoftConfig((s) => s.builder.inspect);
3562
- const dispatch = useCustomPuck6((s) => s.dispatch);
3064
+ const dispatch = useCustomPuck5((s) => s.dispatch);
3563
3065
  const status = useSoftConfig((s) => s.state);
3564
3066
  const { triggerAction } = useActionEvent();
3565
- (0, import_react8.useEffect)(() => {
3067
+ (0, import_react7.useEffect)(() => {
3566
3068
  if (status !== "inspecting") return;
3567
3069
  if (!component) {
3568
3070
  notify.error("No component to inspect.");
3569
3071
  return;
3570
3072
  }
3571
3073
  try {
3572
- inspect(component.id, dispatch);
3074
+ inspect(component.id, dispatch, null);
3573
3075
  void triggerAction({
3574
3076
  type: "inspect",
3575
3077
  payload: {
@@ -3588,16 +3090,24 @@ var useInspect = (component) => {
3588
3090
  };
3589
3091
 
3590
3092
  // src/puck/actions/useDecompose.tsx
3591
- var import_puck10 = require("@measured/puck");
3592
- var useCustomPuck7 = (0, import_puck10.createUsePuck)();
3093
+ var import_puck8 = require("@measured/puck");
3094
+
3095
+ // src/puck/lib/get-prop-by-path.ts
3096
+ function getPropertyByPath(props, path) {
3097
+ return path.replace(/\[(\w+)\]/g, ".$1").split(".").reduce((o, key) => o ? o[key] : void 0, props);
3098
+ }
3099
+
3100
+ // src/puck/actions/useDecompose.tsx
3101
+ var useCustomPuck6 = (0, import_puck8.createUsePuck)();
3593
3102
  var useDecompose = () => {
3594
3103
  const decompose = useSoftConfig((s) => s.builder.decompose);
3595
- const appState = useCustomPuck7((s) => s.appState);
3596
- const dispatch = useCustomPuck7((s) => s.dispatch);
3597
- const selectedItem = useCustomPuck7((s) => s.selectedItem);
3104
+ const appState = useCustomPuck6((s) => s.appState);
3105
+ const dispatch = useCustomPuck6((s) => s.dispatch);
3106
+ const selectedItem = useCustomPuck6((s) => s.selectedItem);
3598
3107
  const status = useSoftConfig((s) => s.state);
3599
3108
  const softComponents = useSoftConfig((s) => s.softComponents);
3600
3109
  const config = useSoftConfig((s) => s.softConfig);
3110
+ const contentAreaNames = useSoftConfig((s) => s.contentAreaNames);
3601
3111
  const { triggerAction } = useActionEvent();
3602
3112
  const handleDecompose = (componentData) => {
3603
3113
  if (status !== "ready") {
@@ -3620,12 +3130,22 @@ var useDecompose = () => {
3620
3130
  notify.error("Nothing to decompose.");
3621
3131
  return;
3622
3132
  }
3623
- const newData = (0, import_puck10.walkTree)(appState.data, config, (components) => {
3624
- const index = components.findIndex((c) => c.props.id === target.props.id);
3625
- if (index !== -1) {
3626
- components.splice(index, 1, ...decomposedComponents);
3627
- }
3628
- return components;
3133
+ let newData = __spreadValues({}, appState.data);
3134
+ const targetAreas = contentAreaNames && contentAreaNames.length > 0 ? contentAreaNames : ["content"];
3135
+ targetAreas.forEach((path) => {
3136
+ const contentArray = getPropertyByPath(newData, path) || [];
3137
+ const walkedData = (0, import_puck8.walkTree)(
3138
+ { content: contentArray, root: newData.root || {} },
3139
+ config,
3140
+ (components) => {
3141
+ const index = components.findIndex((c) => c.props.id === target.props.id);
3142
+ if (index !== -1) {
3143
+ components.splice(index, 1, ...decomposedComponents);
3144
+ }
3145
+ return components;
3146
+ }
3147
+ );
3148
+ setPropertyByPath(newData, path, walkedData.content);
3629
3149
  });
3630
3150
  dispatch({
3631
3151
  type: "setData",
@@ -3638,7 +3158,7 @@ var useDecompose = () => {
3638
3158
  }
3639
3159
  });
3640
3160
  } catch (error) {
3641
- console.error("Failed to decompose:", error);
3161
+ alert("Failed to decompose: " + error);
3642
3162
  notify.error(
3643
3163
  "Failed to decompose: " + (error instanceof Error ? error.message : String(error))
3644
3164
  );
@@ -3652,12 +3172,12 @@ var useDecompose = () => {
3652
3172
  };
3653
3173
 
3654
3174
  // src/puck/actions/useDemolish.tsx
3655
- var import_puck11 = require("@measured/puck");
3656
- var useCustomPuck8 = (0, import_puck11.createUsePuck)();
3175
+ var import_puck9 = require("@measured/puck");
3176
+ var useCustomPuck7 = (0, import_puck9.createUsePuck)();
3657
3177
  var useDemolish = () => {
3658
3178
  const demolish = useSoftConfig((s) => s.builder.demolish);
3659
- const dispatch = useCustomPuck8((s) => s.dispatch);
3660
- const data = useCustomPuck8((s) => s.appState.data);
3179
+ const dispatch = useCustomPuck7((s) => s.dispatch);
3180
+ const data = useCustomPuck7((s) => s.appState.data);
3661
3181
  const status = useSoftConfig((s) => s.state);
3662
3182
  const softComponents = useSoftConfig((s) => s.softComponents);
3663
3183
  const { triggerAction } = useActionEvent();
@@ -3679,7 +3199,7 @@ var useDemolish = () => {
3679
3199
  }
3680
3200
  });
3681
3201
  } catch (error) {
3682
- console.error("Failed to demolish:", error);
3202
+ alert("Failed to demolish: " + error);
3683
3203
  notify.error(
3684
3204
  "Failed to demolish: " + (error instanceof Error ? error.message : String(error))
3685
3205
  );
@@ -3740,17 +3260,17 @@ var useSetDefaultVersion = () => {
3740
3260
  };
3741
3261
 
3742
3262
  // src/puck/overrides/Header.tsx
3743
- var import_puck13 = require("@measured/puck");
3263
+ var import_puck11 = require("@measured/puck");
3744
3264
 
3745
3265
  // css-module:/home/osamu/Documents/netlisian-soft/packages/soft-config/src/puck/overrides/Header.module.css#css-module
3746
3266
  var Header_module_default = { "Header": "_Header_19oj9_1" };
3747
3267
 
3748
3268
  // src/puck/actions/usePublish.tsx
3749
- var import_puck12 = require("@measured/puck");
3750
- var useCustomPuck9 = (0, import_puck12.createUsePuck)();
3269
+ var import_puck10 = require("@measured/puck");
3270
+ var useCustomPuck8 = (0, import_puck10.createUsePuck)();
3751
3271
  var usePublish = () => {
3752
3272
  const components = useSoftConfig((s) => s.softComponents);
3753
- const data = useCustomPuck9((s) => s.appState.data);
3273
+ const data = useCustomPuck8((s) => s.appState.data);
3754
3274
  const status = useSoftConfig((s) => s.state);
3755
3275
  const { triggerAction } = useActionEvent();
3756
3276
  const handlePublish = (publish) => {
@@ -3781,9 +3301,8 @@ var usePublish = () => {
3781
3301
  };
3782
3302
 
3783
3303
  // src/puck/overrides/Header.tsx
3784
- var import_jsx_runtime8 = require("react/jsx-runtime");
3304
+ var import_jsx_runtime5 = require("react/jsx-runtime");
3785
3305
  var getClassName2 = get_class_name_factory_default("Header", Header_module_default);
3786
- var usePuck = (0, import_puck13.createUsePuck)();
3787
3306
  var Header = ({
3788
3307
  onPublish,
3789
3308
  children
@@ -3792,10 +3311,10 @@ var Header = ({
3792
3311
  const { handleCancel, canCancel } = useCancel();
3793
3312
  const { handlePublish } = usePublish();
3794
3313
  useInspect(newComponent);
3795
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName2(), children: canCancel ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
3796
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_puck13.Button, { onClick: handleCancel, children: "Cancel" }),
3797
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3798
- import_puck13.Button,
3314
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: getClassName2(), children: canCancel ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
3315
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_puck11.Button, { onClick: handleCancel, children: "Cancel" }),
3316
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3317
+ import_puck11.Button,
3799
3318
  {
3800
3319
  variant: "primary",
3801
3320
  onClick: () => {
@@ -3807,8 +3326,8 @@ var Header = ({
3807
3326
  children: "Complete"
3808
3327
  }
3809
3328
  )
3810
- ] }) : children ? children : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3811
- import_puck13.Button,
3329
+ ] }) : children ? children : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3330
+ import_puck11.Button,
3812
3331
  {
3813
3332
  variant: "primary",
3814
3333
  onClick: () => {
@@ -3822,8 +3341,8 @@ var Header = ({
3822
3341
  };
3823
3342
 
3824
3343
  // src/puck/overrides/ActionBar.tsx
3825
- var import_react9 = require("react");
3826
- var import_puck14 = require("@measured/puck");
3344
+ var import_react8 = require("react");
3345
+ var import_puck12 = require("@measured/puck");
3827
3346
  var import_lucide_react = require("lucide-react");
3828
3347
 
3829
3348
  // css-module:/home/osamu/Documents/netlisian-soft/packages/soft-config/src/puck/overrides/ActionBar.module.css#css-module
@@ -3831,9 +3350,9 @@ var ActionBar_module_default = { "ActionBar": "_ActionBar_pvuie_5", "ActionBar-l
3831
3350
 
3832
3351
  // src/puck/overrides/ActionBar.tsx
3833
3352
  var import_shallow = require("zustand/shallow");
3834
- var import_jsx_runtime9 = require("react/jsx-runtime");
3353
+ var import_jsx_runtime6 = require("react/jsx-runtime");
3354
+ var useCustomPuck9 = (0, import_puck12.createUsePuck)();
3835
3355
  var getClassName3 = get_class_name_factory_default("ActionBar", ActionBar_module_default);
3836
- var usePuck2 = (0, import_puck14.createUsePuck)();
3837
3356
  var ActionBarOverride = (props) => {
3838
3357
  var _a, _b;
3839
3358
  const { handleBuild } = useBuild(props.label ? props.label + " Soft Component" : "New Soft Component");
@@ -3842,12 +3361,13 @@ var ActionBarOverride = (props) => {
3842
3361
  const overrides = useSoftConfig((s) => s.overrides);
3843
3362
  const softComponents = useSoftConfig((s) => s.softComponents, import_shallow.shallow);
3844
3363
  const editableIds = useSoftConfig((s) => s.editableComponentIds);
3845
- const selectedItem = usePuck2((s) => s.selectedItem);
3846
- const rootProps = usePuck2((s) => s.appState.data.root.props);
3364
+ const selectedItem = useCustomPuck9((s) => s.selectedItem);
3365
+ const appState = useCustomPuck9((s) => s.appState);
3366
+ const rootProps = appState.data.root.props;
3847
3367
  const status = useSoftConfig((s) => s.state);
3848
- const itemSelector = usePuck2((s) => s.appState.ui.itemSelector);
3368
+ const itemSelector = appState.ui.itemSelector;
3849
3369
  const softKeys = Object.keys(softComponents);
3850
- const key = (0, import_react9.useMemo)(() => {
3370
+ const key = (0, import_react8.useMemo)(() => {
3851
3371
  const selectedType = selectedItem == null ? void 0 : selectedItem.type;
3852
3372
  if (selectedType && softKeys.includes(selectedType)) {
3853
3373
  return selectedType;
@@ -3868,42 +3388,42 @@ var ActionBarOverride = (props) => {
3868
3388
  const selectedId = (_a = selectedItem == null ? void 0 : selectedItem.props) == null ? void 0 : _a.id;
3869
3389
  const parentId = (_b = itemSelector == null ? void 0 : itemSelector.zone) == null ? void 0 : _b.split(":")[0];
3870
3390
  const isEditable = Boolean(selectedId && (editableIds.has(selectedId) || parentId && editableIds.has(parentId)));
3871
- const label = (0, import_react9.useMemo)(() => {
3391
+ const label = (0, import_react8.useMemo)(() => {
3872
3392
  var _a2;
3873
3393
  if (isSoftComponent2) {
3874
3394
  return ((_a2 = softComponents[key]) == null ? void 0 : _a2.name) || componentLabelFromName(key, overrides);
3875
3395
  }
3876
3396
  return props.label || "";
3877
3397
  }, [isSoftComponent2, key, props.label, overrides, softComponents]);
3878
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassName3(), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_puck14.ActionBar, { children: [
3879
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_puck14.ActionBar.Group, { children: [
3398
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: getClassName3(), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_puck12.ActionBar, { children: [
3399
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_puck12.ActionBar.Group, { children: [
3880
3400
  props.parentAction,
3881
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_puck14.ActionBar.Label, { label })
3401
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_puck12.ActionBar.Label, { label })
3882
3402
  ] }),
3883
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_puck14.ActionBar.Group, { children: [
3884
- status === "ready" ? isSoftComponent2 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
3885
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3886
- import_puck14.ActionBar.Action,
3403
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_puck12.ActionBar.Group, { children: [
3404
+ status === "ready" ? isSoftComponent2 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
3405
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3406
+ import_puck12.ActionBar.Action,
3887
3407
  {
3888
3408
  onClick: () => handleRemodel(key),
3889
3409
  label: "Remodel Soft Component",
3890
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react.EditIcon, { size: 16 })
3410
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react.EditIcon, { size: 16 })
3891
3411
  }
3892
3412
  ),
3893
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3894
- import_puck14.ActionBar.Action,
3413
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3414
+ import_puck12.ActionBar.Action,
3895
3415
  {
3896
3416
  onClick: () => handleDecompose(),
3897
3417
  label: "Decompose Soft Component",
3898
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react.Combine, { size: 16 })
3418
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react.Combine, { size: 16 })
3899
3419
  }
3900
3420
  )
3901
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3902
- import_puck14.ActionBar.Action,
3421
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3422
+ import_puck12.ActionBar.Action,
3903
3423
  {
3904
3424
  onClick: handleBuild,
3905
3425
  label: "Build Soft Component",
3906
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react.ComponentIcon, { size: 16 })
3426
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react.ComponentIcon, { size: 16 })
3907
3427
  }
3908
3428
  ) : null,
3909
3429
  status !== "ready" && !isEditable ? null : props.children
@@ -3912,8 +3432,8 @@ var ActionBarOverride = (props) => {
3912
3432
  };
3913
3433
 
3914
3434
  // src/puck/overrides/DrawerItem.tsx
3915
- var import_react11 = require("react");
3916
- var import_puck15 = require("@measured/puck");
3435
+ var import_react10 = require("react");
3436
+ var import_puck13 = require("@measured/puck");
3917
3437
  var import_lucide_react2 = require("lucide-react");
3918
3438
 
3919
3439
  // src/puck/lib/confirm.ts
@@ -3928,7 +3448,7 @@ var confirm = (message) => __async(null, null, function* () {
3928
3448
  const result = confirmHandler(message);
3929
3449
  return result instanceof Promise ? yield result : result;
3930
3450
  } catch (error) {
3931
- console.error("Confirm handler error:", error);
3451
+ alert("Confirm handler error: " + error);
3932
3452
  return false;
3933
3453
  }
3934
3454
  });
@@ -3937,25 +3457,25 @@ var confirm = (message) => __async(null, null, function* () {
3937
3457
  var DrawerItem_module_default = { "DrawerItem": "_DrawerItem_182aj_1", "DrawerItem--insertDisabled": "_DrawerItem--insertDisabled_182aj_14", "DrawerItem-content": "_DrawerItem-content_182aj_21", "DrawerItem-name": "_DrawerItem-name_182aj_31", "DrawerItem-version": "_DrawerItem-version_182aj_35", "DrawerItem-actions": "_DrawerItem-actions_182aj_40", "DrawerItem-settingsButton": "_DrawerItem-settingsButton_182aj_46", "DrawerItem-grip": "_DrawerItem-grip_182aj_56", "DrawerItem-modal": "_DrawerItem-modal_182aj_63", "DrawerItem-modalHeader": "_DrawerItem-modalHeader_182aj_71", "DrawerItem-modalTitle": "_DrawerItem-modalTitle_182aj_77", "DrawerItem-modalSubtitle": "_DrawerItem-modalSubtitle_182aj_84", "DrawerItem-modalBody": "_DrawerItem-modalBody_182aj_90", "DrawerItem-section": "_DrawerItem-section_182aj_100", "DrawerItem-sectionTitle": "_DrawerItem-sectionTitle_182aj_106", "DrawerItem-sectionDescription": "_DrawerItem-sectionDescription_182aj_113", "DrawerItem-versionList": "_DrawerItem-versionList_182aj_119", "DrawerItem-versionRow": "_DrawerItem-versionRow_182aj_125", "DrawerItem-versionRow--isDefault": "_DrawerItem-versionRow--isDefault_182aj_136", "DrawerItem-versionRow--isMarkedForDeletion": "_DrawerItem-versionRow--isMarkedForDeletion_182aj_141", "DrawerItem-versionInfo": "_DrawerItem-versionInfo_182aj_146", "DrawerItem-versionNumber": "_DrawerItem-versionNumber_182aj_153", "DrawerItem-defaultBadge": "_DrawerItem-defaultBadge_182aj_159", "DrawerItem-deleteBadge": "_DrawerItem-deleteBadge_182aj_170", "DrawerItem-versionActions": "_DrawerItem-versionActions_182aj_181", "DrawerItem-migrationOptions": "_DrawerItem-migrationOptions_182aj_187", "DrawerItem-migrationList": "_DrawerItem-migrationList_182aj_191", "DrawerItem-migrationOption": "_DrawerItem-migrationOption_182aj_187", "DrawerItem-migrationOption--isSelected": "_DrawerItem-migrationOption--isSelected_182aj_229", "DrawerItem-migrationOptionLabel": "_DrawerItem-migrationOptionLabel_182aj_234", "DrawerItem-modalFooter": "_DrawerItem-modalFooter_182aj_240", "DrawerItem-footerLeft": "_DrawerItem-footerLeft_182aj_250", "DrawerItem-footerRight": "_DrawerItem-footerRight_182aj_255" };
3938
3458
 
3939
3459
  // src/puck/components/modal/index.tsx
3940
- var import_react10 = require("react");
3460
+ var import_react9 = require("react");
3941
3461
  var import_react_dom = require("react-dom");
3942
3462
 
3943
3463
  // css-module:/home/osamu/Documents/netlisian-soft/packages/soft-config/src/puck/components/modal/styles.module.css#css-module
3944
3464
  var styles_module_default2 = { "Modal": "_Modal_1t9ot_1", "Modal--isOpen": "_Modal--isOpen_1t9ot_29", "Modal-inner": "_Modal-inner_1t9ot_37" };
3945
3465
 
3946
3466
  // src/puck/components/modal/index.tsx
3947
- var import_jsx_runtime10 = require("react/jsx-runtime");
3467
+ var import_jsx_runtime7 = require("react/jsx-runtime");
3948
3468
  var getClassName4 = get_class_name_factory_default("Modal", styles_module_default2);
3949
3469
  var Modal = ({
3950
3470
  children,
3951
3471
  onClose,
3952
3472
  isOpen
3953
3473
  }) => {
3954
- const [rootEl, setRootEl] = (0, import_react10.useState)(null);
3955
- (0, import_react10.useEffect)(() => {
3474
+ const [rootEl, setRootEl] = (0, import_react9.useState)(null);
3475
+ (0, import_react9.useEffect)(() => {
3956
3476
  setRootEl(document.getElementById("puck-portal-root"));
3957
3477
  }, []);
3958
- (0, import_react10.useEffect)(() => {
3478
+ (0, import_react9.useEffect)(() => {
3959
3479
  if (!isOpen) {
3960
3480
  return;
3961
3481
  }
@@ -3968,10 +3488,10 @@ var Modal = ({
3968
3488
  return () => document.removeEventListener("keydown", handleEscape);
3969
3489
  }, [isOpen, onClose]);
3970
3490
  if (!rootEl) {
3971
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", {});
3491
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", {});
3972
3492
  }
3973
3493
  return (0, import_react_dom.createPortal)(
3974
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
3494
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3975
3495
  "div",
3976
3496
  {
3977
3497
  className: getClassName4({ isOpen }),
@@ -3980,7 +3500,7 @@ var Modal = ({
3980
3500
  onClose();
3981
3501
  }
3982
3502
  },
3983
- children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
3503
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3984
3504
  "div",
3985
3505
  {
3986
3506
  className: getClassName4("inner"),
@@ -3998,16 +3518,16 @@ var Modal = ({
3998
3518
 
3999
3519
  // src/puck/overrides/DrawerItem.tsx
4000
3520
  var import_shallow2 = require("zustand/shallow");
4001
- var import_jsx_runtime11 = require("react/jsx-runtime");
3521
+ var import_jsx_runtime8 = require("react/jsx-runtime");
3522
+ var useCustomPuck10 = (0, import_puck13.createUsePuck)();
4002
3523
  var getClassName5 = get_class_name_factory_default("DrawerItem", DrawerItem_module_default);
4003
- var usePuck3 = (0, import_puck15.createUsePuck)();
4004
3524
  var DrawerItem = (props) => {
4005
3525
  const componentMeta = useSoftConfig((s) => s.softComponents[props.name]);
4006
3526
  const displayName = props.label || (componentMeta == null ? void 0 : componentMeta.name) || props.name;
4007
3527
  const softComponents = new Set(
4008
3528
  Object.keys(useSoftConfig((s) => s.softComponents, import_shallow2.shallow))
4009
3529
  );
4010
- const getPermissions = usePuck3((s) => s.getPermissions);
3530
+ const getPermissions = useCustomPuck10((s) => s.getPermissions);
4011
3531
  const insertAllowed = getPermissions({ type: props.name }).insert;
4012
3532
  const removeSoftComponentVersion = useSoftConfig(
4013
3533
  (s) => s.removeSoftComponentVersion
@@ -4015,13 +3535,13 @@ var DrawerItem = (props) => {
4015
3535
  const { handleDemolish } = useDemolish();
4016
3536
  const { handleSetDefaultVersion, getVersions, getDefaultVersion } = useSetDefaultVersion();
4017
3537
  const { triggerAction } = useActionEvent();
4018
- const [isEditing, setIsEditing] = (0, import_react11.useState)(false);
4019
- const [isHovering, setIsHovering] = (0, import_react11.useState)(false);
4020
- const [selectedVersion, setSelectedVersion] = (0, import_react11.useState)("");
4021
- const [versionsToDelete, setVersionsToDelete] = (0, import_react11.useState)(
3538
+ const [isEditing, setIsEditing] = (0, import_react10.useState)(false);
3539
+ const [isHovering, setIsHovering] = (0, import_react10.useState)(false);
3540
+ const [selectedVersion, setSelectedVersion] = (0, import_react10.useState)("");
3541
+ const [versionsToDelete, setVersionsToDelete] = (0, import_react10.useState)(
4022
3542
  /* @__PURE__ */ new Set()
4023
3543
  );
4024
- const [migrationTarget, setMigrationTarget] = (0, import_react11.useState)("decompose");
3544
+ const [migrationTarget, setMigrationTarget] = (0, import_react10.useState)("decompose");
4025
3545
  const useVersioning = useSoftConfig((s) => s.showVersionFields);
4026
3546
  const versions = getVersions(props.name);
4027
3547
  const defaultVersion = getDefaultVersion(props.name);
@@ -4091,8 +3611,8 @@ var DrawerItem = (props) => {
4091
3611
  label: `Migrate to Version ${version}`
4092
3612
  }))
4093
3613
  ];
4094
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
4095
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
3614
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
3615
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
4096
3616
  "div",
4097
3617
  {
4098
3618
  className: getClassName5({ insertDisabled: !insertAllowed }),
@@ -4100,71 +3620,70 @@ var DrawerItem = (props) => {
4100
3620
  onMouseLeave: () => setIsHovering(false),
4101
3621
  children: [
4102
3622
  props.label,
4103
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("content"), children: [
4104
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName5("name"), children: displayName }),
4105
- useVersioning && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("version"), children: [
3623
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName5("content"), children: [
3624
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName5("name"), children: displayName }),
3625
+ useVersioning && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName5("version"), children: [
4106
3626
  "v",
4107
3627
  defaultVersion
4108
3628
  ] })
4109
3629
  ] }),
4110
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("actions"), children: [
4111
- isHovering && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName5("settingsButton"), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
4112
- import_puck15.IconButton,
3630
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName5("actions"), children: [
3631
+ isHovering && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName5("settingsButton"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3632
+ import_puck13.IconButton,
4113
3633
  {
4114
3634
  title: "Settings",
4115
- variant: "secondary",
4116
3635
  onClick: (e) => {
4117
3636
  e.stopPropagation();
4118
3637
  setIsEditing(true);
4119
3638
  setSelectedVersion(defaultVersion || "");
4120
3639
  },
4121
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.Cog, { size: 12 })
3640
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react2.Cog, { size: 12 })
4122
3641
  }
4123
3642
  ) }),
4124
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName5("grip"), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.GripVertical, { size: 16 }) })
3643
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName5("grip"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react2.GripVertical, { size: 16 }) })
4125
3644
  ] })
4126
3645
  ]
4127
3646
  }
4128
3647
  ),
4129
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Modal, { isOpen: isEditing, onClose: handleCancel, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("modal"), children: [
4130
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("modalHeader"), children: [
4131
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h2", { className: getClassName5("modalTitle"), children: displayName }),
4132
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: getClassName5("modalSubtitle"), children: "Component Settings" })
3648
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Modal, { isOpen: isEditing, onClose: handleCancel, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName5("modal"), children: [
3649
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName5("modalHeader"), children: [
3650
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h2", { className: getClassName5("modalTitle"), children: displayName }),
3651
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: getClassName5("modalSubtitle"), children: "Component Settings" })
4133
3652
  ] }),
4134
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName5("modalBody"), children: useVersioning ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
4135
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("section"), children: [
4136
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h3", { className: getClassName5("sectionTitle"), children: "Versions" }),
4137
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName5("versionList"), children: versions.map((version) => {
3653
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName5("modalBody"), children: useVersioning ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
3654
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName5("section"), children: [
3655
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h3", { className: getClassName5("sectionTitle"), children: "Versions" }),
3656
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName5("versionList"), children: versions.map((version) => {
4138
3657
  const isDefault = version === (selectedVersion || defaultVersion);
4139
3658
  const isMarkedForDeletion = versionsToDelete.has(version);
4140
3659
  let rowClass = getClassName5("versionRow");
4141
3660
  if (isDefault) rowClass += " " + getClassName5("versionRow--isDefault");
4142
3661
  if (isMarkedForDeletion) rowClass += " " + getClassName5("versionRow--isMarkedForDeletion");
4143
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: rowClass, children: [
4144
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("versionInfo"), children: [
4145
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: getClassName5("versionNumber"), children: [
3662
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: rowClass, children: [
3663
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName5("versionInfo"), children: [
3664
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: getClassName5("versionNumber"), children: [
4146
3665
  "Version ",
4147
3666
  version
4148
3667
  ] }),
4149
- isDefault && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: getClassName5("defaultBadge"), children: "Default" }),
4150
- isMarkedForDeletion && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: getClassName5("deleteBadge"), children: "Marked for deletion" })
3668
+ isDefault && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: getClassName5("defaultBadge"), children: "Default" }),
3669
+ isMarkedForDeletion && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: getClassName5("deleteBadge"), children: "Marked for deletion" })
4151
3670
  ] }),
4152
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("versionActions"), children: [
4153
- !isDefault && !isMarkedForDeletion && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_puck15.Button, { variant: "secondary", onClick: () => setSelectedVersion(version), children: "Set as Default" }),
4154
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_puck15.Button, { variant: "secondary", onClick: () => toggleVersionForDeletion(version), children: isMarkedForDeletion ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
4155
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.X, { size: 14 }),
3671
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName5("versionActions"), children: [
3672
+ !isDefault && !isMarkedForDeletion && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_puck13.Button, { variant: "secondary", onClick: () => setSelectedVersion(version), children: "Set as Default" }),
3673
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_puck13.Button, { variant: "secondary", onClick: () => toggleVersionForDeletion(version), children: isMarkedForDeletion ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
3674
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react2.X, { size: 14 }),
4156
3675
  " Undo"
4157
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
4158
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.Trash2, { size: 14 }),
3676
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
3677
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react2.Trash2, { size: 14 }),
4159
3678
  " Delete"
4160
3679
  ] }) })
4161
3680
  ] })
4162
3681
  ] }, version);
4163
3682
  }) })
4164
3683
  ] }),
4165
- versionsToDelete.size > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("section"), children: [
4166
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h3", { className: getClassName5("sectionTitle"), children: "Migration Settings" }),
4167
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName5("migrationOptions"), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3684
+ versionsToDelete.size > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName5("section"), children: [
3685
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h3", { className: getClassName5("sectionTitle"), children: "Migration Settings" }),
3686
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName5("migrationOptions"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
4168
3687
  "div",
4169
3688
  {
4170
3689
  className: getClassName5("migrationList"),
@@ -4172,7 +3691,7 @@ var DrawerItem = (props) => {
4172
3691
  "aria-label": "Migration target",
4173
3692
  children: migrationTargets.map((target) => {
4174
3693
  const isSelected = migrationTarget === target.value;
4175
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
3694
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
4176
3695
  "button",
4177
3696
  {
4178
3697
  "aria-label": target.label,
@@ -4182,8 +3701,8 @@ var DrawerItem = (props) => {
4182
3701
  className: `${getClassName5("migrationOption")} ${isSelected ? getClassName5("migrationOption--isSelected") : ""}`,
4183
3702
  onClick: () => setMigrationTarget(target.value),
4184
3703
  children: [
4185
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: getClassName5("migrationOptionLabel"), children: target.label }),
4186
- isSelected && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.Check, { size: 14 })
3704
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: getClassName5("migrationOptionLabel"), children: target.label }),
3705
+ isSelected && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react2.Check, { size: 14 })
4187
3706
  ]
4188
3707
  },
4189
3708
  target.value
@@ -4191,49 +3710,48 @@ var DrawerItem = (props) => {
4191
3710
  })
4192
3711
  }
4193
3712
  ) }),
4194
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: getClassName5("helpText"), children: "Choose where to move existing instances of the deleted versions." })
3713
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: getClassName5("helpText"), children: "Choose where to move existing instances of the deleted versions." })
4195
3714
  ] })
4196
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName5("section"), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("p", { children: [
3715
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName5("section"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("p", { children: [
4197
3716
  "Manage high-level settings for the ",
4198
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("strong", { children: displayName }),
3717
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("strong", { children: displayName }),
4199
3718
  " component."
4200
3719
  ] }) }) }),
4201
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("modalFooter"), children: [
4202
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("footerLeft"), children: [
4203
- useVersioning ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_puck15.Button, { size: "medium", onClick: handleApply, children: [
4204
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.Check, { size: 16 }),
3720
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName5("modalFooter"), children: [
3721
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName5("footerLeft"), children: [
3722
+ useVersioning ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_puck13.Button, { size: "medium", onClick: handleApply, children: [
3723
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react2.Check, { size: 16 }),
4205
3724
  " Apply Changes"
4206
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_puck15.Button, { size: "medium", onClick: handleCancel, children: "Close" }),
4207
- useVersioning && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_puck15.Button, { size: "medium", variant: "secondary", onClick: handleCancel, children: [
4208
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.X, { size: 16 }),
3725
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_puck13.Button, { size: "medium", onClick: handleCancel, children: "Close" }),
3726
+ useVersioning && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_puck13.Button, { size: "medium", variant: "secondary", onClick: handleCancel, children: [
3727
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react2.X, { size: 16 }),
4209
3728
  " Cancel"
4210
3729
  ] })
4211
3730
  ] }),
4212
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName5("footerRight"), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_puck15.Button, { size: "medium", variant: "secondary", onClick: handleDemolishClick, children: [
4213
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.Trash2, { size: 16 }),
3731
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName5("footerRight"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_puck13.Button, { size: "medium", variant: "secondary", onClick: handleDemolishClick, children: [
3732
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react2.Trash2, { size: 16 }),
4214
3733
  " Demolish Component"
4215
3734
  ] }) })
4216
3735
  ] })
4217
3736
  ] }) })
4218
3737
  ] });
4219
3738
  }
4220
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children: props.children });
3739
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: props.children });
4221
3740
  };
4222
- var ComponentItem = DrawerItem;
4223
3741
 
4224
3742
  // src/puck/overrides/Drawer.tsx
4225
- var import_react12 = require("react");
4226
- var import_puck16 = require("@measured/puck");
3743
+ var import_react11 = require("react");
3744
+ var import_puck14 = require("@measured/puck");
4227
3745
  var import_lucide_react3 = require("lucide-react");
4228
3746
 
4229
3747
  // css-module:/home/osamu/Documents/netlisian-soft/packages/soft-config/src/puck/overrides/Drawer.module.css#css-module
4230
3748
  var Drawer_module_default = { "Drawer": "_Drawer_12zq5_1", "Drawer-category": "_Drawer-category_12zq5_7", "Drawer-category--isExpanded": "_Drawer-category--isExpanded_12zq5_15", "Drawer-categoryContent": "_Drawer-categoryContent_12zq5_19", "Drawer-categoryTitle": "_Drawer-categoryTitle_12zq5_27", "Drawer-categoryTitleIcon": "_Drawer-categoryTitleIcon_12zq5_63" };
4231
3749
 
4232
3750
  // src/puck/overrides/Drawer.tsx
4233
- var import_jsx_runtime12 = require("react/jsx-runtime");
3751
+ var import_jsx_runtime9 = require("react/jsx-runtime");
3752
+ var useCustomPuck11 = (0, import_puck14.createUsePuck)();
4234
3753
  var getClassName6 = get_class_name_factory_default("Drawer", Drawer_module_default);
4235
3754
  var getCategoryClassName = get_class_name_factory_default("Drawer-category", Drawer_module_default);
4236
- var usePuck4 = (0, import_puck16.createUsePuck)();
4237
3755
  var CategorySection = ({
4238
3756
  id,
4239
3757
  title,
@@ -4241,8 +3759,8 @@ var CategorySection = ({
4241
3759
  getPermissions,
4242
3760
  expanded,
4243
3761
  onToggle
4244
- }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getCategoryClassName({ isExpanded: expanded }), children: [
4245
- title && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
3762
+ }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: getCategoryClassName({ isExpanded: expanded }), children: [
3763
+ title && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
4246
3764
  "button",
4247
3765
  {
4248
3766
  type: "button",
@@ -4250,13 +3768,13 @@ var CategorySection = ({
4250
3768
  onClick: () => onToggle(id),
4251
3769
  title: expanded ? `Collapse ${title}` : `Expand ${title}`,
4252
3770
  children: [
4253
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: title }),
4254
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: getClassName6("categoryTitleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react3.ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react3.ChevronDown, { size: 12 }) })
3771
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: title }),
3772
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: getClassName6("categoryTitleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react3.ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react3.ChevronDown, { size: 12 }) })
4255
3773
  ]
4256
3774
  }
4257
3775
  ),
4258
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassName6("categoryContent"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_puck16.Drawer, { children: componentKeys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
4259
- import_puck16.Drawer.Item,
3776
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassName6("categoryContent"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_puck14.Drawer, { children: componentKeys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3777
+ import_puck14.Drawer.Item,
4260
3778
  {
4261
3779
  name: key,
4262
3780
  isDragDisabled: !getPermissions({ type: key }).insert,
@@ -4267,8 +3785,8 @@ var CategorySection = ({
4267
3785
  ] });
4268
3786
  var Drawer = (_props) => {
4269
3787
  var _a, _b;
4270
- const config = usePuck4((s) => s.config);
4271
- const getPermissions = usePuck4((s) => s.getPermissions);
3788
+ const config = useCustomPuck11((s) => s.config);
3789
+ const getPermissions = useCustomPuck11((s) => s.getPermissions);
4272
3790
  const categories = (_a = config.categories) != null ? _a : {};
4273
3791
  const categorised = new Set(
4274
3792
  Object.values(categories).flatMap((cat) => {
@@ -4285,7 +3803,7 @@ var Drawer = (_props) => {
4285
3803
  const categoryEntries = Object.entries(categories).filter(
4286
3804
  ([, cat]) => cat.visible !== false
4287
3805
  );
4288
- const [expanded, setExpanded] = (0, import_react12.useState)(() => {
3806
+ const [expanded, setExpanded] = (0, import_react11.useState)(() => {
4289
3807
  const init = {};
4290
3808
  categoryEntries.forEach(([id, cat]) => {
4291
3809
  init[id] = cat.defaultExpanded !== false;
@@ -4295,8 +3813,8 @@ var Drawer = (_props) => {
4295
3813
  });
4296
3814
  const toggle = (id) => setExpanded((prev) => __spreadProps(__spreadValues({}, prev), { [id]: !prev[id] }));
4297
3815
  if (categoryEntries.length === 0) {
4298
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_puck16.Drawer, { children: allKeys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
4299
- import_puck16.Drawer.Item,
3816
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_puck14.Drawer, { children: allKeys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3817
+ import_puck14.Drawer.Item,
4300
3818
  {
4301
3819
  name: key,
4302
3820
  label: labels[key],
@@ -4306,10 +3824,10 @@ var Drawer = (_props) => {
4306
3824
  key
4307
3825
  )) });
4308
3826
  }
4309
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassName6(), children: [
3827
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: getClassName6(), children: [
4310
3828
  categoryEntries.map(([id, cat]) => {
4311
3829
  var _a2, _b2, _c;
4312
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3830
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
4313
3831
  CategorySection,
4314
3832
  {
4315
3833
  id,
@@ -4324,7 +3842,7 @@ var Drawer = (_props) => {
4324
3842
  id
4325
3843
  );
4326
3844
  }),
4327
- otherKeys.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3845
+ otherKeys.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
4328
3846
  CategorySection,
4329
3847
  {
4330
3848
  id: "__other__",
@@ -4339,25 +3857,27 @@ var Drawer = (_props) => {
4339
3857
  };
4340
3858
 
4341
3859
  // src/puck/overrides/HeaderActions.tsx
4342
- var import_puck17 = require("@measured/puck");
4343
- var import_jsx_runtime13 = require("react/jsx-runtime");
4344
- var usePuck5 = (0, import_puck17.createUsePuck)();
3860
+ var import_puck15 = require("@measured/puck");
3861
+ var import_jsx_runtime10 = require("react/jsx-runtime");
3862
+ var useCustomPuck12 = (0, import_puck15.createUsePuck)();
4345
3863
  var HeaderActions = ({ children }) => {
4346
3864
  const { handleComplete } = useComplete();
4347
3865
  const { handleCancel, canCancel } = useCancel();
4348
- const dispatch = usePuck5((s) => s.dispatch);
3866
+ const dispatch = useCustomPuck12((s) => s.dispatch);
3867
+ const appState = useCustomPuck12((s) => s.appState);
3868
+ const selectedItemSelector = appState.ui.itemSelector;
4349
3869
  const inspect = useSoftConfig((s) => s.builder.inspect);
4350
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, { children: canCancel ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
4351
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_puck17.Button, { onClick: handleCancel, children: "Cancel" }),
4352
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
4353
- import_puck17.Button,
3870
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: canCancel ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
3871
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_puck15.Button, { onClick: handleCancel, children: "Cancel" }),
3872
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
3873
+ import_puck15.Button,
4354
3874
  {
4355
3875
  variant: "primary",
4356
3876
  onClick: () => {
4357
3877
  const completedComponent = handleComplete();
4358
3878
  if (completedComponent) {
4359
3879
  try {
4360
- inspect(completedComponent.id, dispatch);
3880
+ inspect(completedComponent.id, dispatch, selectedItemSelector);
4361
3881
  } catch (error) {
4362
3882
  notify.error(
4363
3883
  "Failed to inspect after completion: " + (error instanceof Error ? error.message : String(error))
@@ -4580,18 +4100,37 @@ var resolveSoftConfig = (data, softComponents, config) => {
4580
4100
  if (process.env.NODE_ENV === "development") {
4581
4101
  const validation = validateOnlyHardComponents(dissolved, softComponents);
4582
4102
  if (!validation.isValid) {
4583
- console.warn(
4584
- "Warning: Soft components still present after dissolution:",
4585
- validation.softComponentsFound
4103
+ alert(
4104
+ "Warning: Soft components still present after dissolution: " + String(
4105
+ validation.softComponentsFound
4106
+ )
4586
4107
  );
4587
4108
  }
4588
4109
  }
4589
4110
  return dissolved;
4590
4111
  };
4112
+
4113
+ // src/puck/lib/builder/generate-field-options.ts
4114
+ var hasArrayMappingPath = (value) => value.includes("[]");
4115
+ var isBareArrayPath = (value) => !hasArrayMappingPath(value) && !value.includes(".");
4116
+ function filterToOptionsForFrom(fromPath, toOptions) {
4117
+ if (!fromPath) return toOptions;
4118
+ const fromHasArrayMapping = hasArrayMappingPath(fromPath);
4119
+ const fromIsBareArray = isBareArrayPath(fromPath);
4120
+ return toOptions.filter((option) => {
4121
+ const optionHasArrayMapping = hasArrayMappingPath(option.value);
4122
+ if (fromHasArrayMapping) {
4123
+ return optionHasArrayMapping;
4124
+ }
4125
+ if (fromIsBareArray) {
4126
+ return isBareArrayPath(option.value);
4127
+ }
4128
+ return !optionHasArrayMapping;
4129
+ });
4130
+ }
4591
4131
  // Annotate the CommonJS export names for ESM import in node:
4592
4132
  0 && (module.exports = {
4593
4133
  ActionBar,
4594
- ComponentItem,
4595
4134
  ComponentList,
4596
4135
  Drawer,
4597
4136
  DrawerItem,