@measured/puck-plugin-heading-analyzer 0.20.0-canary.755737e8 → 0.20.0-canary.77cef35d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -61,6 +61,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
61
61
  mod
62
62
  ));
63
63
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
64
+ var __async = (__this, __arguments, generator) => {
65
+ return new Promise((resolve, reject) => {
66
+ var fulfilled = (value) => {
67
+ try {
68
+ step(generator.next(value));
69
+ } catch (e) {
70
+ reject(e);
71
+ }
72
+ };
73
+ var rejected = (value) => {
74
+ try {
75
+ step(generator.throw(value));
76
+ } catch (e) {
77
+ reject(e);
78
+ }
79
+ };
80
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
81
+ step((generator = generator.apply(__this, __arguments)).next());
82
+ });
83
+ };
64
84
 
65
85
  // ../tsup-config/react-import.js
66
86
  var import_react;
@@ -133,6 +153,156 @@ var require_classnames = __commonJS({
133
153
  }
134
154
  });
135
155
 
156
+ // ../../node_modules/flat/index.js
157
+ var require_flat = __commonJS({
158
+ "../../node_modules/flat/index.js"(exports2, module2) {
159
+ "use strict";
160
+ init_react_import();
161
+ module2.exports = flatten3;
162
+ flatten3.flatten = flatten3;
163
+ flatten3.unflatten = unflatten2;
164
+ function isBuffer(obj) {
165
+ return obj && obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
166
+ }
167
+ function keyIdentity(key) {
168
+ return key;
169
+ }
170
+ function flatten3(target, opts) {
171
+ opts = opts || {};
172
+ const delimiter = opts.delimiter || ".";
173
+ const maxDepth = opts.maxDepth;
174
+ const transformKey = opts.transformKey || keyIdentity;
175
+ const output = {};
176
+ function step(object, prev, currentDepth) {
177
+ currentDepth = currentDepth || 1;
178
+ Object.keys(object).forEach(function(key) {
179
+ const value = object[key];
180
+ const isarray = opts.safe && Array.isArray(value);
181
+ const type = Object.prototype.toString.call(value);
182
+ const isbuffer = isBuffer(value);
183
+ const isobject = type === "[object Object]" || type === "[object Array]";
184
+ const newKey = prev ? prev + delimiter + transformKey(key) : transformKey(key);
185
+ if (!isarray && !isbuffer && isobject && Object.keys(value).length && (!opts.maxDepth || currentDepth < maxDepth)) {
186
+ return step(value, newKey, currentDepth + 1);
187
+ }
188
+ output[newKey] = value;
189
+ });
190
+ }
191
+ step(target);
192
+ return output;
193
+ }
194
+ function unflatten2(target, opts) {
195
+ opts = opts || {};
196
+ const delimiter = opts.delimiter || ".";
197
+ const overwrite = opts.overwrite || false;
198
+ const transformKey = opts.transformKey || keyIdentity;
199
+ const result = {};
200
+ const isbuffer = isBuffer(target);
201
+ if (isbuffer || Object.prototype.toString.call(target) !== "[object Object]") {
202
+ return target;
203
+ }
204
+ function getkey(key) {
205
+ const parsedKey = Number(key);
206
+ return isNaN(parsedKey) || key.indexOf(".") !== -1 || opts.object ? key : parsedKey;
207
+ }
208
+ function addKeys(keyPrefix, recipient, target2) {
209
+ return Object.keys(target2).reduce(function(result2, key) {
210
+ result2[keyPrefix + delimiter + key] = target2[key];
211
+ return result2;
212
+ }, recipient);
213
+ }
214
+ function isEmpty(val) {
215
+ const type = Object.prototype.toString.call(val);
216
+ const isArray = type === "[object Array]";
217
+ const isObject = type === "[object Object]";
218
+ if (!val) {
219
+ return true;
220
+ } else if (isArray) {
221
+ return !val.length;
222
+ } else if (isObject) {
223
+ return !Object.keys(val).length;
224
+ }
225
+ }
226
+ target = Object.keys(target).reduce(function(result2, key) {
227
+ const type = Object.prototype.toString.call(target[key]);
228
+ const isObject = type === "[object Object]" || type === "[object Array]";
229
+ if (!isObject || isEmpty(target[key])) {
230
+ result2[key] = target[key];
231
+ return result2;
232
+ } else {
233
+ return addKeys(
234
+ key,
235
+ result2,
236
+ flatten3(target[key], opts)
237
+ );
238
+ }
239
+ }, {});
240
+ Object.keys(target).forEach(function(key) {
241
+ const split = key.split(delimiter).map(transformKey);
242
+ let key1 = getkey(split.shift());
243
+ let key2 = getkey(split[0]);
244
+ let recipient = result;
245
+ while (key2 !== void 0) {
246
+ if (key1 === "__proto__") {
247
+ return;
248
+ }
249
+ const type = Object.prototype.toString.call(recipient[key1]);
250
+ const isobject = type === "[object Object]" || type === "[object Array]";
251
+ if (!overwrite && !isobject && typeof recipient[key1] !== "undefined") {
252
+ return;
253
+ }
254
+ if (overwrite && !isobject || !overwrite && recipient[key1] == null) {
255
+ recipient[key1] = typeof key2 === "number" && !opts.object ? [] : {};
256
+ }
257
+ recipient = recipient[key1];
258
+ if (split.length > 0) {
259
+ key1 = getkey(split.shift());
260
+ key2 = getkey(split[0]);
261
+ }
262
+ }
263
+ recipient[key1] = unflatten2(target[key], opts);
264
+ });
265
+ return result;
266
+ }
267
+ }
268
+ });
269
+
270
+ // ../../node_modules/fast-deep-equal/index.js
271
+ var require_fast_deep_equal = __commonJS({
272
+ "../../node_modules/fast-deep-equal/index.js"(exports2, module2) {
273
+ "use strict";
274
+ init_react_import();
275
+ module2.exports = function equal(a, b) {
276
+ if (a === b) return true;
277
+ if (a && b && typeof a == "object" && typeof b == "object") {
278
+ if (a.constructor !== b.constructor) return false;
279
+ var length, i, keys;
280
+ if (Array.isArray(a)) {
281
+ length = a.length;
282
+ if (length != b.length) return false;
283
+ for (i = length; i-- !== 0; )
284
+ if (!equal(a[i], b[i])) return false;
285
+ return true;
286
+ }
287
+ if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
288
+ if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
289
+ if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
290
+ keys = Object.keys(a);
291
+ length = keys.length;
292
+ if (length !== Object.keys(b).length) return false;
293
+ for (i = length; i-- !== 0; )
294
+ if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
295
+ for (i = length; i-- !== 0; ) {
296
+ var key = keys[i];
297
+ if (!equal(a[key], b[key])) return false;
298
+ }
299
+ return true;
300
+ }
301
+ return a !== a && b !== b;
302
+ };
303
+ }
304
+ });
305
+
136
306
  // index.ts
137
307
  var plugin_heading_analyzer_exports = {};
138
308
  __export(plugin_heading_analyzer_exports, {
@@ -143,7 +313,7 @@ init_react_import();
143
313
 
144
314
  // src/HeadingAnalyzer.tsx
145
315
  init_react_import();
146
- var import_react4 = require("react");
316
+ var import_react10 = require("react");
147
317
 
148
318
  // css-module:/home/runner/work/puck/puck/packages/plugin-heading-analyzer/src/HeadingAnalyzer.module.css#css-module
149
319
  init_react_import();
@@ -338,6 +508,1652 @@ init_react_import();
338
508
  // ../core/lib/data/replace.ts
339
509
  init_react_import();
340
510
 
511
+ // ../core/lib/use-reset-auto-zoom.ts
512
+ init_react_import();
513
+
514
+ // ../core/store/index.ts
515
+ init_react_import();
516
+
517
+ // ../core/reducer/index.ts
518
+ init_react_import();
519
+
520
+ // ../core/reducer/actions/set.ts
521
+ init_react_import();
522
+
523
+ // ../core/lib/data/walk-app-state.ts
524
+ init_react_import();
525
+
526
+ // ../core/lib/data/for-related-zones.ts
527
+ init_react_import();
528
+
529
+ // ../core/lib/get-zone-id.ts
530
+ init_react_import();
531
+
532
+ // ../core/lib/root-droppable-id.ts
533
+ init_react_import();
534
+ var rootAreaId = "root";
535
+ var rootZone = "default-zone";
536
+ var rootDroppableId = `${rootAreaId}:${rootZone}`;
537
+
538
+ // ../core/lib/get-zone-id.ts
539
+ var getZoneId = (zoneCompound) => {
540
+ if (!zoneCompound) {
541
+ return [];
542
+ }
543
+ if (zoneCompound && zoneCompound.indexOf(":") > -1) {
544
+ return zoneCompound.split(":");
545
+ }
546
+ return [rootDroppableId, zoneCompound];
547
+ };
548
+
549
+ // ../core/lib/data/for-related-zones.ts
550
+ function forRelatedZones(item, data, cb, path = []) {
551
+ Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
552
+ const [parentId] = getZoneId(zoneCompound);
553
+ if (parentId === item.props.id) {
554
+ cb(path, zoneCompound, content);
555
+ }
556
+ });
557
+ }
558
+
559
+ // ../core/lib/data/map-fields.ts
560
+ init_react_import();
561
+
562
+ // ../core/lib/data/default-slots.ts
563
+ init_react_import();
564
+ var defaultSlots = (value, fields) => Object.keys(fields).reduce(
565
+ (acc, fieldName) => fields[fieldName].type === "slot" ? __spreadValues({ [fieldName]: [] }, acc) : acc,
566
+ value
567
+ );
568
+
569
+ // ../core/lib/data/map-fields.ts
570
+ var isPromise = (v) => !!v && typeof v.then === "function";
571
+ var flatten = (values) => values.reduce((acc, item) => __spreadValues(__spreadValues({}, acc), item), {});
572
+ var containsPromise = (arr) => arr.some(isPromise);
573
+ var walkField = ({
574
+ value,
575
+ fields,
576
+ mappers,
577
+ propKey = "",
578
+ propPath = "",
579
+ id = "",
580
+ config,
581
+ recurseSlots = false
582
+ }) => {
583
+ var _a, _b, _c;
584
+ const fieldType = (_a = fields[propKey]) == null ? void 0 : _a.type;
585
+ const map = mappers[fieldType];
586
+ if (map && fieldType === "slot") {
587
+ const content = value || [];
588
+ const mappedContent = recurseSlots ? content.map((el) => {
589
+ var _a2;
590
+ const componentConfig = config.components[el.type];
591
+ if (!componentConfig) {
592
+ throw new Error(`Could not find component config for ${el.type}`);
593
+ }
594
+ const fields2 = (_a2 = componentConfig.fields) != null ? _a2 : {};
595
+ return walkField({
596
+ value: __spreadProps(__spreadValues({}, el), { props: defaultSlots(el.props, fields2) }),
597
+ fields: fields2,
598
+ mappers,
599
+ id: el.props.id,
600
+ config,
601
+ recurseSlots
602
+ });
603
+ }) : content;
604
+ if (containsPromise(mappedContent)) {
605
+ return Promise.all(mappedContent);
606
+ }
607
+ return map({
608
+ value: mappedContent,
609
+ parentId: id,
610
+ propName: propKey,
611
+ field: fields[propKey],
612
+ propPath
613
+ });
614
+ } else if (map && fields[propKey]) {
615
+ return map({
616
+ value,
617
+ parentId: id,
618
+ propName: propKey,
619
+ field: fields[propKey],
620
+ propPath
621
+ });
622
+ }
623
+ if (value && typeof value === "object") {
624
+ if (Array.isArray(value)) {
625
+ const arrayFields = ((_b = fields[propKey]) == null ? void 0 : _b.type) === "array" ? fields[propKey].arrayFields : null;
626
+ if (!arrayFields) return value;
627
+ const newValue = value.map(
628
+ (el, idx) => walkField({
629
+ value: el,
630
+ fields: arrayFields,
631
+ mappers,
632
+ propKey,
633
+ propPath: `${propPath}[${idx}]`,
634
+ id,
635
+ config,
636
+ recurseSlots
637
+ })
638
+ );
639
+ if (containsPromise(newValue)) {
640
+ return Promise.all(newValue);
641
+ }
642
+ return newValue;
643
+ } else if ("$$typeof" in value) {
644
+ return value;
645
+ } else {
646
+ const objectFields = ((_c = fields[propKey]) == null ? void 0 : _c.type) === "object" ? fields[propKey].objectFields : fields;
647
+ return walkObject({
648
+ value,
649
+ fields: objectFields,
650
+ mappers,
651
+ id,
652
+ getPropPath: (k) => `${propPath}.${k}`,
653
+ config,
654
+ recurseSlots
655
+ });
656
+ }
657
+ }
658
+ return value;
659
+ };
660
+ var walkObject = ({
661
+ value,
662
+ fields,
663
+ mappers,
664
+ id,
665
+ getPropPath,
666
+ config,
667
+ recurseSlots
668
+ }) => {
669
+ const newProps = Object.entries(value).map(([k, v]) => {
670
+ const opts = {
671
+ value: v,
672
+ fields,
673
+ mappers,
674
+ propKey: k,
675
+ propPath: getPropPath(k),
676
+ id,
677
+ config,
678
+ recurseSlots
679
+ };
680
+ const newValue = walkField(opts);
681
+ if (isPromise(newValue)) {
682
+ return newValue.then((resolvedValue) => ({
683
+ [k]: resolvedValue
684
+ }));
685
+ }
686
+ return {
687
+ [k]: newValue
688
+ };
689
+ }, {});
690
+ if (containsPromise(newProps)) {
691
+ return Promise.all(newProps).then(flatten);
692
+ }
693
+ return flatten(newProps);
694
+ };
695
+ function mapFields(item, mappers, config, recurseSlots = false) {
696
+ var _a, _b, _c, _d, _e;
697
+ const itemType = "type" in item ? item.type : "root";
698
+ const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
699
+ const newProps = walkObject({
700
+ value: defaultSlots((_b = item.props) != null ? _b : {}, (_c = componentConfig == null ? void 0 : componentConfig.fields) != null ? _c : {}),
701
+ fields: (_d = componentConfig == null ? void 0 : componentConfig.fields) != null ? _d : {},
702
+ mappers,
703
+ id: item.props ? (_e = item.props.id) != null ? _e : "root" : "root",
704
+ getPropPath: (k) => k,
705
+ config,
706
+ recurseSlots
707
+ });
708
+ if (isPromise(newProps)) {
709
+ return newProps.then((resolvedProps) => __spreadProps(__spreadValues({}, item), {
710
+ props: resolvedProps
711
+ }));
712
+ }
713
+ return __spreadProps(__spreadValues({}, item), {
714
+ props: newProps
715
+ });
716
+ }
717
+
718
+ // ../core/lib/data/flatten-node.ts
719
+ init_react_import();
720
+ var import_flat = __toESM(require_flat());
721
+
722
+ // ../core/lib/data/strip-slots.ts
723
+ init_react_import();
724
+ var stripSlots = (data, config) => {
725
+ return mapFields(data, { slot: () => null }, config);
726
+ };
727
+
728
+ // ../core/lib/data/flatten-node.ts
729
+ var { flatten: flatten2, unflatten } = import_flat.default;
730
+ var flattenNode = (node, config) => {
731
+ return __spreadProps(__spreadValues({}, node), {
732
+ props: flatten2(stripSlots(node, config).props)
733
+ });
734
+ };
735
+
736
+ // ../core/lib/data/walk-app-state.ts
737
+ function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
738
+ var _a;
739
+ let newZones = {};
740
+ const newZoneIndex = {};
741
+ const newNodeIndex = {};
742
+ const processContent = (path, zoneCompound, content, zoneType, newId) => {
743
+ var _a2;
744
+ const [parentId] = zoneCompound.split(":");
745
+ const mappedContent = ((_a2 = mapContent(content, zoneCompound, zoneType)) != null ? _a2 : content) || [];
746
+ const [_2, zone] = zoneCompound.split(":");
747
+ const newZoneCompound = `${newId || parentId}:${zone}`;
748
+ const newContent2 = mappedContent.map(
749
+ (zoneChild, index) => processItem(zoneChild, [...path, newZoneCompound], index)
750
+ );
751
+ newZoneIndex[newZoneCompound] = {
752
+ contentIds: newContent2.map((item) => item.props.id),
753
+ type: zoneType
754
+ };
755
+ return [newZoneCompound, newContent2];
756
+ };
757
+ const processRelatedZones = (item, newId, initialPath) => {
758
+ forRelatedZones(
759
+ item,
760
+ state.data,
761
+ (relatedPath, relatedZoneCompound, relatedContent) => {
762
+ const [zoneCompound, newContent2] = processContent(
763
+ relatedPath,
764
+ relatedZoneCompound,
765
+ relatedContent,
766
+ "dropzone",
767
+ newId
768
+ );
769
+ newZones[zoneCompound] = newContent2;
770
+ },
771
+ initialPath
772
+ );
773
+ };
774
+ const processItem = (item, path, index) => {
775
+ const mappedItem = mapNodeOrSkip(item, path, index);
776
+ if (!mappedItem) return item;
777
+ const id = mappedItem.props.id;
778
+ const newProps = __spreadProps(__spreadValues({}, mapFields(
779
+ mappedItem,
780
+ {
781
+ slot: ({ value, parentId: parentId2, propPath }) => {
782
+ const content = value;
783
+ const zoneCompound = `${parentId2}:${propPath}`;
784
+ const [_2, newContent2] = processContent(
785
+ path,
786
+ zoneCompound,
787
+ content,
788
+ "slot",
789
+ parentId2
790
+ );
791
+ return newContent2;
792
+ }
793
+ },
794
+ config
795
+ ).props), {
796
+ id
797
+ });
798
+ processRelatedZones(item, id, path);
799
+ const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
800
+ const thisZoneCompound = path[path.length - 1];
801
+ const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
802
+ newNodeIndex[id] = {
803
+ data: newItem,
804
+ flatData: flattenNode(newItem, config),
805
+ path,
806
+ parentId,
807
+ zone
808
+ };
809
+ const finalData = __spreadProps(__spreadValues({}, newItem), { props: __spreadValues({}, newItem.props) });
810
+ if (newProps.id === "root") {
811
+ delete finalData["type"];
812
+ delete finalData.props["id"];
813
+ }
814
+ return finalData;
815
+ };
816
+ const zones = state.data.zones || {};
817
+ const [_, newContent] = processContent(
818
+ [],
819
+ rootDroppableId,
820
+ state.data.content,
821
+ "root"
822
+ );
823
+ const processedContent = newContent;
824
+ const zonesAlreadyProcessed = Object.keys(newZones);
825
+ Object.keys(zones || {}).forEach((zoneCompound) => {
826
+ const [parentId] = zoneCompound.split(":");
827
+ if (zonesAlreadyProcessed.includes(zoneCompound)) {
828
+ return;
829
+ }
830
+ const [_2, newContent2] = processContent(
831
+ [rootDroppableId],
832
+ zoneCompound,
833
+ zones[zoneCompound],
834
+ "dropzone",
835
+ parentId
836
+ );
837
+ newZones[zoneCompound] = newContent2;
838
+ }, newZones);
839
+ const processedRoot = processItem(
840
+ {
841
+ type: "root",
842
+ props: __spreadProps(__spreadValues({}, (_a = state.data.root.props) != null ? _a : state.data.root), { id: "root" })
843
+ },
844
+ [],
845
+ -1
846
+ );
847
+ const root = __spreadProps(__spreadValues({}, state.data.root), {
848
+ props: processedRoot.props
849
+ });
850
+ return __spreadProps(__spreadValues({}, state), {
851
+ data: {
852
+ root,
853
+ content: processedContent,
854
+ zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
855
+ },
856
+ indexes: {
857
+ nodes: __spreadValues(__spreadValues({}, state.indexes.nodes), newNodeIndex),
858
+ zones: __spreadValues(__spreadValues({}, state.indexes.zones), newZoneIndex)
859
+ }
860
+ });
861
+ }
862
+
863
+ // ../core/reducer/actions/set.ts
864
+ var setAction = (state, action, appStore) => {
865
+ if (typeof action.state === "object") {
866
+ const newState = __spreadValues(__spreadValues({}, state), action.state);
867
+ if (action.state.indexes) {
868
+ return newState;
869
+ }
870
+ console.warn(
871
+ "`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
872
+ );
873
+ return walkAppState(newState, appStore.config);
874
+ }
875
+ return __spreadValues(__spreadValues({}, state), action.state(state));
876
+ };
877
+
878
+ // ../core/reducer/actions/insert.ts
879
+ init_react_import();
880
+
881
+ // ../core/lib/data/insert.ts
882
+ init_react_import();
883
+ var insert = (list, index, item) => {
884
+ const result = Array.from(list || []);
885
+ result.splice(index, 0, item);
886
+ return result;
887
+ };
888
+
889
+ // ../core/lib/generate-id.ts
890
+ init_react_import();
891
+
892
+ // ../../node_modules/uuid/dist/esm-node/index.js
893
+ init_react_import();
894
+
895
+ // ../../node_modules/uuid/dist/esm-node/rng.js
896
+ init_react_import();
897
+ var import_crypto = __toESM(require("crypto"));
898
+ var rnds8Pool = new Uint8Array(256);
899
+ var poolPtr = rnds8Pool.length;
900
+ function rng() {
901
+ if (poolPtr > rnds8Pool.length - 16) {
902
+ import_crypto.default.randomFillSync(rnds8Pool);
903
+ poolPtr = 0;
904
+ }
905
+ return rnds8Pool.slice(poolPtr, poolPtr += 16);
906
+ }
907
+
908
+ // ../../node_modules/uuid/dist/esm-node/stringify.js
909
+ init_react_import();
910
+ var byteToHex = [];
911
+ for (let i = 0; i < 256; ++i) {
912
+ byteToHex.push((i + 256).toString(16).slice(1));
913
+ }
914
+ function unsafeStringify(arr, offset = 0) {
915
+ return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
916
+ }
917
+
918
+ // ../../node_modules/uuid/dist/esm-node/v4.js
919
+ init_react_import();
920
+
921
+ // ../../node_modules/uuid/dist/esm-node/native.js
922
+ init_react_import();
923
+ var import_crypto2 = __toESM(require("crypto"));
924
+ var native_default = {
925
+ randomUUID: import_crypto2.default.randomUUID
926
+ };
927
+
928
+ // ../../node_modules/uuid/dist/esm-node/v4.js
929
+ function v4(options, buf, offset) {
930
+ if (native_default.randomUUID && !buf && !options) {
931
+ return native_default.randomUUID();
932
+ }
933
+ options = options || {};
934
+ const rnds = options.random || (options.rng || rng)();
935
+ rnds[6] = rnds[6] & 15 | 64;
936
+ rnds[8] = rnds[8] & 63 | 128;
937
+ if (buf) {
938
+ offset = offset || 0;
939
+ for (let i = 0; i < 16; ++i) {
940
+ buf[offset + i] = rnds[i];
941
+ }
942
+ return buf;
943
+ }
944
+ return unsafeStringify(rnds);
945
+ }
946
+ var v4_default = v4;
947
+
948
+ // ../core/lib/generate-id.ts
949
+ var generateId = (type) => type ? `${type}-${v4_default()}` : v4_default();
950
+
951
+ // ../core/lib/data/get-ids-for-parent.ts
952
+ init_react_import();
953
+ var getIdsForParent = (zoneCompound, state) => {
954
+ const [parentId] = zoneCompound.split(":");
955
+ const node = state.indexes.nodes[parentId];
956
+ return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
957
+ };
958
+
959
+ // ../core/lib/data/populate-ids.ts
960
+ init_react_import();
961
+
962
+ // ../core/lib/data/walk-tree.ts
963
+ init_react_import();
964
+ function walkTree(data, config, callbackFn) {
965
+ var _a, _b;
966
+ const walkItem = (item) => {
967
+ return mapFields(
968
+ item,
969
+ {
970
+ slot: ({ value, parentId, propName }) => {
971
+ var _a2;
972
+ const content = value;
973
+ return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
974
+ }
975
+ },
976
+ config,
977
+ true
978
+ );
979
+ };
980
+ if ("props" in data) {
981
+ return walkItem(data);
982
+ }
983
+ const _data = data;
984
+ const zones = (_a = _data.zones) != null ? _a : {};
985
+ const mappedContent = _data.content.map(walkItem);
986
+ return {
987
+ root: walkItem(_data.root),
988
+ content: (_b = callbackFn(mappedContent, {
989
+ parentId: "root",
990
+ propName: "default-zone"
991
+ })) != null ? _b : mappedContent,
992
+ zones: Object.keys(zones).reduce(
993
+ (acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
994
+ [zoneCompound]: zones[zoneCompound].map(walkItem)
995
+ }),
996
+ {}
997
+ )
998
+ };
999
+ }
1000
+
1001
+ // ../core/lib/data/populate-ids.ts
1002
+ var populateIds = (data, config, override = false) => {
1003
+ const id = generateId(data.type);
1004
+ return walkTree(
1005
+ __spreadProps(__spreadValues({}, data), {
1006
+ props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({}, data.props)
1007
+ }),
1008
+ config,
1009
+ (contents) => contents.map((item) => {
1010
+ const id2 = generateId(item.type);
1011
+ return __spreadProps(__spreadValues({}, item), {
1012
+ props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
1013
+ });
1014
+ })
1015
+ );
1016
+ };
1017
+
1018
+ // ../core/reducer/actions/insert.ts
1019
+ function insertAction(state, action, appStore) {
1020
+ const id = action.id || generateId(action.componentType);
1021
+ const emptyComponentData = populateIds(
1022
+ {
1023
+ type: action.componentType,
1024
+ props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
1025
+ id
1026
+ })
1027
+ },
1028
+ appStore.config
1029
+ );
1030
+ const [parentId] = action.destinationZone.split(":");
1031
+ const idsInPath = getIdsForParent(action.destinationZone, state);
1032
+ return walkAppState(
1033
+ state,
1034
+ appStore.config,
1035
+ (content, zoneCompound) => {
1036
+ if (zoneCompound === action.destinationZone) {
1037
+ return insert(
1038
+ content || [],
1039
+ action.destinationIndex,
1040
+ emptyComponentData
1041
+ );
1042
+ }
1043
+ return content;
1044
+ },
1045
+ (childItem, path) => {
1046
+ if (childItem.props.id === id || childItem.props.id === parentId) {
1047
+ return childItem;
1048
+ } else if (idsInPath.includes(childItem.props.id)) {
1049
+ return childItem;
1050
+ } else if (path.includes(action.destinationZone)) {
1051
+ return childItem;
1052
+ }
1053
+ return null;
1054
+ }
1055
+ );
1056
+ }
1057
+
1058
+ // ../core/reducer/actions/replace.ts
1059
+ init_react_import();
1060
+ var replaceAction = (state, action, appStore) => {
1061
+ const [parentId] = action.destinationZone.split(":");
1062
+ const idsInPath = getIdsForParent(action.destinationZone, state);
1063
+ const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
1064
+ const idChanged = originalId !== action.data.props.id;
1065
+ if (idChanged) {
1066
+ throw new Error(
1067
+ `Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
1068
+ );
1069
+ }
1070
+ const newSlotIds = [];
1071
+ const data = walkTree(action.data, appStore.config, (contents, opts) => {
1072
+ newSlotIds.push(`${opts.parentId}:${opts.propName}`);
1073
+ return contents.map((item) => {
1074
+ const id = generateId(item.type);
1075
+ return __spreadProps(__spreadValues({}, item), {
1076
+ props: __spreadValues({ id }, item.props)
1077
+ });
1078
+ });
1079
+ });
1080
+ const stateWithDeepSlotsRemoved = __spreadValues({}, state);
1081
+ Object.keys(state.indexes.zones).forEach((zoneCompound) => {
1082
+ const id = zoneCompound.split(":")[0];
1083
+ if (id === originalId) {
1084
+ if (!newSlotIds.includes(zoneCompound)) {
1085
+ delete stateWithDeepSlotsRemoved.indexes.zones[zoneCompound];
1086
+ }
1087
+ }
1088
+ });
1089
+ return walkAppState(
1090
+ stateWithDeepSlotsRemoved,
1091
+ appStore.config,
1092
+ (content, zoneCompound) => {
1093
+ const newContent = [...content];
1094
+ if (zoneCompound === action.destinationZone) {
1095
+ newContent[action.destinationIndex] = data;
1096
+ }
1097
+ return newContent;
1098
+ },
1099
+ (childItem, path) => {
1100
+ const pathIds = path.map((p) => p.split(":")[0]);
1101
+ if (childItem.props.id === data.props.id) {
1102
+ return data;
1103
+ } else if (childItem.props.id === parentId) {
1104
+ return childItem;
1105
+ } else if (idsInPath.indexOf(childItem.props.id) > -1) {
1106
+ return childItem;
1107
+ } else if (pathIds.indexOf(data.props.id) > -1) {
1108
+ return childItem;
1109
+ }
1110
+ return null;
1111
+ }
1112
+ );
1113
+ };
1114
+
1115
+ // ../core/reducer/actions/replace-root.ts
1116
+ init_react_import();
1117
+ var replaceRootAction = (state, action, appStore) => {
1118
+ return walkAppState(
1119
+ state,
1120
+ appStore.config,
1121
+ (content) => content,
1122
+ (childItem) => {
1123
+ if (childItem.props.id === "root") {
1124
+ return __spreadProps(__spreadValues({}, childItem), {
1125
+ props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
1126
+ readOnly: action.root.readOnly
1127
+ });
1128
+ }
1129
+ return childItem;
1130
+ }
1131
+ );
1132
+ };
1133
+
1134
+ // ../core/reducer/actions/duplicate.ts
1135
+ init_react_import();
1136
+
1137
+ // ../core/lib/data/get-item.ts
1138
+ init_react_import();
1139
+ function getItem(selector, state) {
1140
+ var _a, _b;
1141
+ const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
1142
+ return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
1143
+ }
1144
+
1145
+ // ../core/reducer/actions/duplicate.ts
1146
+ function duplicateAction(state, action, appStore) {
1147
+ const item = getItem(
1148
+ { index: action.sourceIndex, zone: action.sourceZone },
1149
+ state
1150
+ );
1151
+ const idsInPath = getIdsForParent(action.sourceZone, state);
1152
+ const newItem = __spreadProps(__spreadValues({}, item), {
1153
+ props: __spreadProps(__spreadValues({}, item.props), {
1154
+ id: generateId(item.type)
1155
+ })
1156
+ });
1157
+ const modified = walkAppState(
1158
+ state,
1159
+ appStore.config,
1160
+ (content, zoneCompound) => {
1161
+ if (zoneCompound === action.sourceZone) {
1162
+ return insert(content, action.sourceIndex + 1, item);
1163
+ }
1164
+ return content;
1165
+ },
1166
+ (childItem, path, index) => {
1167
+ const zoneCompound = path[path.length - 1];
1168
+ const parents = path.map((p) => p.split(":")[0]);
1169
+ if (parents.indexOf(newItem.props.id) > -1) {
1170
+ return __spreadProps(__spreadValues({}, childItem), {
1171
+ props: __spreadProps(__spreadValues({}, childItem.props), {
1172
+ id: generateId(childItem.type)
1173
+ })
1174
+ });
1175
+ }
1176
+ if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
1177
+ return newItem;
1178
+ }
1179
+ const [sourceZoneParent] = action.sourceZone.split(":");
1180
+ if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
1181
+ return childItem;
1182
+ }
1183
+ return null;
1184
+ }
1185
+ );
1186
+ return __spreadProps(__spreadValues({}, modified), {
1187
+ ui: __spreadProps(__spreadValues({}, modified.ui), {
1188
+ itemSelector: {
1189
+ index: action.sourceIndex + 1,
1190
+ zone: action.sourceZone
1191
+ }
1192
+ })
1193
+ });
1194
+ }
1195
+
1196
+ // ../core/reducer/actions/reorder.ts
1197
+ init_react_import();
1198
+
1199
+ // ../core/reducer/actions/move.ts
1200
+ init_react_import();
1201
+
1202
+ // ../core/lib/data/remove.ts
1203
+ init_react_import();
1204
+ var remove = (list, index) => {
1205
+ const result = Array.from(list);
1206
+ result.splice(index, 1);
1207
+ return result;
1208
+ };
1209
+
1210
+ // ../core/reducer/actions/move.ts
1211
+ var moveAction = (state, action, appStore) => {
1212
+ if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
1213
+ return state;
1214
+ }
1215
+ const item = getItem(
1216
+ { zone: action.sourceZone, index: action.sourceIndex },
1217
+ state
1218
+ );
1219
+ if (!item) return state;
1220
+ const idsInSourcePath = getIdsForParent(action.sourceZone, state);
1221
+ const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
1222
+ return walkAppState(
1223
+ state,
1224
+ appStore.config,
1225
+ (content, zoneCompound) => {
1226
+ if (zoneCompound === action.sourceZone && zoneCompound === action.destinationZone) {
1227
+ return insert(
1228
+ remove(content, action.sourceIndex),
1229
+ action.destinationIndex,
1230
+ item
1231
+ );
1232
+ } else if (zoneCompound === action.sourceZone) {
1233
+ return remove(content, action.sourceIndex);
1234
+ } else if (zoneCompound === action.destinationZone) {
1235
+ return insert(content, action.destinationIndex, item);
1236
+ }
1237
+ return content;
1238
+ },
1239
+ (childItem, path) => {
1240
+ const [sourceZoneParent] = action.sourceZone.split(":");
1241
+ const [destinationZoneParent] = action.destinationZone.split(":");
1242
+ const childId = childItem.props.id;
1243
+ if (sourceZoneParent === childId || destinationZoneParent === childId || item.props.id === childId || idsInSourcePath.indexOf(childId) > -1 || idsInDestinationPath.indexOf(childId) > -1 || path.includes(action.destinationZone)) {
1244
+ return childItem;
1245
+ }
1246
+ return null;
1247
+ }
1248
+ );
1249
+ };
1250
+
1251
+ // ../core/reducer/actions/reorder.ts
1252
+ var reorderAction = (state, action, appStore) => {
1253
+ return moveAction(
1254
+ state,
1255
+ {
1256
+ type: "move",
1257
+ sourceIndex: action.sourceIndex,
1258
+ sourceZone: action.destinationZone,
1259
+ destinationIndex: action.destinationIndex,
1260
+ destinationZone: action.destinationZone
1261
+ },
1262
+ appStore
1263
+ );
1264
+ };
1265
+
1266
+ // ../core/reducer/actions/remove.ts
1267
+ init_react_import();
1268
+ var removeAction = (state, action, appStore) => {
1269
+ const item = getItem({ index: action.index, zone: action.zone }, state);
1270
+ const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
1271
+ (acc, [nodeId, nodeData]) => {
1272
+ const pathIds = nodeData.path.map((p) => p.split(":")[0]);
1273
+ if (pathIds.includes(item.props.id)) {
1274
+ return [...acc, nodeId];
1275
+ }
1276
+ return acc;
1277
+ },
1278
+ [item.props.id]
1279
+ );
1280
+ const newState = walkAppState(
1281
+ state,
1282
+ appStore.config,
1283
+ (content, zoneCompound) => {
1284
+ if (zoneCompound === action.zone) {
1285
+ return remove(content, action.index);
1286
+ }
1287
+ return content;
1288
+ }
1289
+ );
1290
+ Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
1291
+ const parentId = zoneCompound.split(":")[0];
1292
+ if (nodesToDelete.includes(parentId) && newState.data.zones) {
1293
+ delete newState.data.zones[zoneCompound];
1294
+ }
1295
+ });
1296
+ Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
1297
+ const parentId = zoneCompound.split(":")[0];
1298
+ if (nodesToDelete.includes(parentId)) {
1299
+ delete newState.indexes.zones[zoneCompound];
1300
+ }
1301
+ });
1302
+ nodesToDelete.forEach((id) => {
1303
+ delete newState.indexes.nodes[id];
1304
+ });
1305
+ return newState;
1306
+ };
1307
+
1308
+ // ../core/reducer/actions/register-zone.ts
1309
+ init_react_import();
1310
+
1311
+ // ../core/lib/data/setup-zone.ts
1312
+ init_react_import();
1313
+ var setupZone = (data, zoneKey) => {
1314
+ if (zoneKey === rootDroppableId) {
1315
+ return data;
1316
+ }
1317
+ const newData = __spreadProps(__spreadValues({}, data), {
1318
+ zones: data.zones ? __spreadValues({}, data.zones) : {}
1319
+ });
1320
+ newData.zones[zoneKey] = newData.zones[zoneKey] || [];
1321
+ return newData;
1322
+ };
1323
+
1324
+ // ../core/reducer/actions/register-zone.ts
1325
+ var zoneCache = {};
1326
+ function registerZoneAction(state, action) {
1327
+ if (zoneCache[action.zone]) {
1328
+ return __spreadProps(__spreadValues({}, state), {
1329
+ data: __spreadProps(__spreadValues({}, state.data), {
1330
+ zones: __spreadProps(__spreadValues({}, state.data.zones), {
1331
+ [action.zone]: zoneCache[action.zone]
1332
+ })
1333
+ }),
1334
+ indexes: __spreadProps(__spreadValues({}, state.indexes), {
1335
+ zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
1336
+ [action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
1337
+ contentIds: zoneCache[action.zone].map((item) => item.props.id),
1338
+ type: "dropzone"
1339
+ })
1340
+ })
1341
+ })
1342
+ });
1343
+ }
1344
+ return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
1345
+ }
1346
+ function unregisterZoneAction(state, action) {
1347
+ const _zones = __spreadValues({}, state.data.zones || {});
1348
+ const zoneIndex = __spreadValues({}, state.indexes.zones || {});
1349
+ if (_zones[action.zone]) {
1350
+ zoneCache[action.zone] = _zones[action.zone];
1351
+ delete _zones[action.zone];
1352
+ }
1353
+ delete zoneIndex[action.zone];
1354
+ return __spreadProps(__spreadValues({}, state), {
1355
+ data: __spreadProps(__spreadValues({}, state.data), {
1356
+ zones: _zones
1357
+ }),
1358
+ indexes: __spreadProps(__spreadValues({}, state.indexes), {
1359
+ zones: zoneIndex
1360
+ })
1361
+ });
1362
+ }
1363
+
1364
+ // ../core/reducer/actions/set-data.ts
1365
+ init_react_import();
1366
+ var setDataAction = (state, action, appStore) => {
1367
+ if (typeof action.data === "object") {
1368
+ console.warn(
1369
+ "`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
1370
+ );
1371
+ return walkAppState(
1372
+ __spreadProps(__spreadValues({}, state), {
1373
+ data: __spreadValues(__spreadValues({}, state.data), action.data)
1374
+ }),
1375
+ appStore.config
1376
+ );
1377
+ }
1378
+ return walkAppState(
1379
+ __spreadProps(__spreadValues({}, state), {
1380
+ data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
1381
+ }),
1382
+ appStore.config
1383
+ );
1384
+ };
1385
+
1386
+ // ../core/reducer/actions/set-ui.ts
1387
+ init_react_import();
1388
+ var setUiAction = (state, action) => {
1389
+ if (typeof action.ui === "object") {
1390
+ return __spreadProps(__spreadValues({}, state), {
1391
+ ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
1392
+ });
1393
+ }
1394
+ return __spreadProps(__spreadValues({}, state), {
1395
+ ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
1396
+ });
1397
+ };
1398
+
1399
+ // ../core/lib/data/make-state-public.ts
1400
+ init_react_import();
1401
+ var makeStatePublic = (state) => {
1402
+ const { data, ui } = state;
1403
+ return { data, ui };
1404
+ };
1405
+
1406
+ // ../core/reducer/actions.tsx
1407
+ init_react_import();
1408
+
1409
+ // ../core/reducer/index.ts
1410
+ function storeInterceptor(reducer, record, onAction) {
1411
+ return (state, action) => {
1412
+ const newAppState = reducer(state, action);
1413
+ const isValidType = ![
1414
+ "registerZone",
1415
+ "unregisterZone",
1416
+ "setData",
1417
+ "setUi",
1418
+ "set"
1419
+ ].includes(action.type);
1420
+ if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
1421
+ if (record) record(newAppState);
1422
+ }
1423
+ onAction == null ? void 0 : onAction(action, makeStatePublic(newAppState), makeStatePublic(state));
1424
+ return newAppState;
1425
+ };
1426
+ }
1427
+ function createReducer({
1428
+ record,
1429
+ onAction,
1430
+ appStore
1431
+ }) {
1432
+ return storeInterceptor(
1433
+ (state, action) => {
1434
+ if (action.type === "set") {
1435
+ return setAction(state, action, appStore);
1436
+ }
1437
+ if (action.type === "insert") {
1438
+ return insertAction(state, action, appStore);
1439
+ }
1440
+ if (action.type === "replace") {
1441
+ return replaceAction(state, action, appStore);
1442
+ }
1443
+ if (action.type === "replaceRoot") {
1444
+ return replaceRootAction(state, action, appStore);
1445
+ }
1446
+ if (action.type === "duplicate") {
1447
+ return duplicateAction(state, action, appStore);
1448
+ }
1449
+ if (action.type === "reorder") {
1450
+ return reorderAction(state, action, appStore);
1451
+ }
1452
+ if (action.type === "move") {
1453
+ return moveAction(state, action, appStore);
1454
+ }
1455
+ if (action.type === "remove") {
1456
+ return removeAction(state, action, appStore);
1457
+ }
1458
+ if (action.type === "registerZone") {
1459
+ return registerZoneAction(state, action);
1460
+ }
1461
+ if (action.type === "unregisterZone") {
1462
+ return unregisterZoneAction(state, action);
1463
+ }
1464
+ if (action.type === "setData") {
1465
+ return setDataAction(state, action, appStore);
1466
+ }
1467
+ if (action.type === "setUi") {
1468
+ return setUiAction(state, action);
1469
+ }
1470
+ return state;
1471
+ },
1472
+ record,
1473
+ onAction
1474
+ );
1475
+ }
1476
+
1477
+ // ../core/components/ViewportControls/default-viewports.ts
1478
+ init_react_import();
1479
+ var defaultViewports = [
1480
+ { width: 360, height: "auto", icon: "Smartphone", label: "Small" },
1481
+ { width: 768, height: "auto", icon: "Tablet", label: "Medium" },
1482
+ { width: 1280, height: "auto", icon: "Monitor", label: "Large" }
1483
+ ];
1484
+
1485
+ // ../../node_modules/zustand/esm/vanilla.mjs
1486
+ init_react_import();
1487
+ var createStoreImpl = (createState) => {
1488
+ let state;
1489
+ const listeners = /* @__PURE__ */ new Set();
1490
+ const setState = (partial, replace) => {
1491
+ const nextState = typeof partial === "function" ? partial(state) : partial;
1492
+ if (!Object.is(nextState, state)) {
1493
+ const previousState = state;
1494
+ state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
1495
+ listeners.forEach((listener) => listener(state, previousState));
1496
+ }
1497
+ };
1498
+ const getState = () => state;
1499
+ const getInitialState = () => initialState;
1500
+ const subscribe = (listener) => {
1501
+ listeners.add(listener);
1502
+ return () => listeners.delete(listener);
1503
+ };
1504
+ const api = { setState, getState, getInitialState, subscribe };
1505
+ const initialState = state = createState(setState, getState, api);
1506
+ return api;
1507
+ };
1508
+ var createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
1509
+
1510
+ // ../../node_modules/zustand/esm/react.mjs
1511
+ init_react_import();
1512
+ var import_react4 = __toESM(require("react"), 1);
1513
+ var identity = (arg) => arg;
1514
+ function useStore(api, selector = identity) {
1515
+ const slice = import_react4.default.useSyncExternalStore(
1516
+ api.subscribe,
1517
+ () => selector(api.getState()),
1518
+ () => selector(api.getInitialState())
1519
+ );
1520
+ import_react4.default.useDebugValue(slice);
1521
+ return slice;
1522
+ }
1523
+ var createImpl = (createState) => {
1524
+ const api = createStore(createState);
1525
+ const useBoundStore = (selector) => useStore(api, selector);
1526
+ Object.assign(useBoundStore, api);
1527
+ return useBoundStore;
1528
+ };
1529
+ var create = (createState) => createState ? createImpl(createState) : createImpl;
1530
+
1531
+ // ../../node_modules/zustand/esm/middleware.mjs
1532
+ init_react_import();
1533
+ var subscribeWithSelectorImpl = (fn) => (set, get, api) => {
1534
+ const origSubscribe = api.subscribe;
1535
+ api.subscribe = (selector, optListener, options) => {
1536
+ let listener = selector;
1537
+ if (optListener) {
1538
+ const equalityFn = (options == null ? void 0 : options.equalityFn) || Object.is;
1539
+ let currentSlice = selector(api.getState());
1540
+ listener = (state) => {
1541
+ const nextSlice = selector(state);
1542
+ if (!equalityFn(currentSlice, nextSlice)) {
1543
+ const previousSlice = currentSlice;
1544
+ optListener(currentSlice = nextSlice, previousSlice);
1545
+ }
1546
+ };
1547
+ if (options == null ? void 0 : options.fireImmediately) {
1548
+ optListener(currentSlice, currentSlice);
1549
+ }
1550
+ }
1551
+ return origSubscribe(listener);
1552
+ };
1553
+ const initialState = fn(set, get, api);
1554
+ return initialState;
1555
+ };
1556
+ var subscribeWithSelector = subscribeWithSelectorImpl;
1557
+
1558
+ // ../core/store/index.ts
1559
+ var import_react9 = require("react");
1560
+
1561
+ // ../core/store/slices/history.ts
1562
+ init_react_import();
1563
+ var import_react6 = require("react");
1564
+
1565
+ // ../core/lib/use-hotkey.ts
1566
+ init_react_import();
1567
+ var import_react5 = require("react");
1568
+ var useHotkeyStore = create()(
1569
+ subscribeWithSelector((set) => ({
1570
+ held: {},
1571
+ hold: (key) => set((s) => s.held[key] ? s : { held: __spreadProps(__spreadValues({}, s.held), { [key]: true }) }),
1572
+ release: (key) => set((s) => s.held[key] ? { held: __spreadProps(__spreadValues({}, s.held), { [key]: false }) } : s),
1573
+ reset: (held = {}) => set(() => ({ held })),
1574
+ triggers: {}
1575
+ }))
1576
+ );
1577
+
1578
+ // ../core/store/slices/history.ts
1579
+ var EMPTY_HISTORY_INDEX = 0;
1580
+ function debounce(func, timeout = 300) {
1581
+ let timer;
1582
+ return (...args) => {
1583
+ clearTimeout(timer);
1584
+ timer = setTimeout(() => {
1585
+ func(...args);
1586
+ }, timeout);
1587
+ };
1588
+ }
1589
+ var tidyState = (state) => {
1590
+ return __spreadProps(__spreadValues({}, state), {
1591
+ ui: __spreadProps(__spreadValues({}, state.ui), {
1592
+ field: {
1593
+ focus: null
1594
+ }
1595
+ })
1596
+ });
1597
+ };
1598
+ var createHistorySlice = (set, get) => {
1599
+ const record = debounce((state) => {
1600
+ const { histories, index } = get().history;
1601
+ const history = {
1602
+ state,
1603
+ id: generateId("history")
1604
+ };
1605
+ const newHistories = [...histories.slice(0, index + 1), history];
1606
+ set({
1607
+ history: __spreadProps(__spreadValues({}, get().history), {
1608
+ histories: newHistories,
1609
+ index: newHistories.length - 1
1610
+ })
1611
+ });
1612
+ }, 250);
1613
+ return {
1614
+ initialAppState: {},
1615
+ index: EMPTY_HISTORY_INDEX,
1616
+ histories: [],
1617
+ hasPast: () => get().history.index > EMPTY_HISTORY_INDEX,
1618
+ hasFuture: () => get().history.index < get().history.histories.length - 1,
1619
+ prevHistory: () => {
1620
+ const { history } = get();
1621
+ return history.hasPast() ? history.histories[history.index - 1] : null;
1622
+ },
1623
+ nextHistory: () => {
1624
+ const s = get().history;
1625
+ return s.hasFuture() ? s.histories[s.index + 1] : null;
1626
+ },
1627
+ currentHistory: () => get().history.histories[get().history.index],
1628
+ back: () => {
1629
+ var _a;
1630
+ const { history, dispatch } = get();
1631
+ if (history.hasPast()) {
1632
+ const state = tidyState(
1633
+ ((_a = history.prevHistory()) == null ? void 0 : _a.state) || history.initialAppState
1634
+ );
1635
+ dispatch({
1636
+ type: "set",
1637
+ state
1638
+ });
1639
+ set({ history: __spreadProps(__spreadValues({}, history), { index: history.index - 1 }) });
1640
+ }
1641
+ },
1642
+ forward: () => {
1643
+ var _a;
1644
+ const { history, dispatch } = get();
1645
+ if (history.hasFuture()) {
1646
+ const state = (_a = history.nextHistory()) == null ? void 0 : _a.state;
1647
+ dispatch({ type: "set", state: state ? tidyState(state) : {} });
1648
+ set({ history: __spreadProps(__spreadValues({}, history), { index: history.index + 1 }) });
1649
+ }
1650
+ },
1651
+ setHistories: (histories) => {
1652
+ var _a;
1653
+ const { dispatch, history } = get();
1654
+ dispatch({
1655
+ type: "set",
1656
+ state: ((_a = histories[histories.length - 1]) == null ? void 0 : _a.state) || history.initialAppState
1657
+ });
1658
+ set({ history: __spreadProps(__spreadValues({}, history), { histories, index: histories.length - 1 }) });
1659
+ },
1660
+ setHistoryIndex: (index) => {
1661
+ var _a;
1662
+ const { dispatch, history } = get();
1663
+ dispatch({
1664
+ type: "set",
1665
+ state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
1666
+ });
1667
+ set({ history: __spreadProps(__spreadValues({}, history), { index }) });
1668
+ },
1669
+ record
1670
+ };
1671
+ };
1672
+
1673
+ // ../core/store/slices/nodes.ts
1674
+ init_react_import();
1675
+ var createNodesSlice = (set, get) => ({
1676
+ nodes: {},
1677
+ registerNode: (id, node) => {
1678
+ const s = get().nodes;
1679
+ const emptyNode = {
1680
+ id,
1681
+ methods: {
1682
+ sync: () => null,
1683
+ hideOverlay: () => null,
1684
+ showOverlay: () => null
1685
+ },
1686
+ element: null
1687
+ };
1688
+ const existingNode = s.nodes[id];
1689
+ set({
1690
+ nodes: __spreadProps(__spreadValues({}, s), {
1691
+ nodes: __spreadProps(__spreadValues({}, s.nodes), {
1692
+ [id]: __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, emptyNode), existingNode), node), {
1693
+ id
1694
+ })
1695
+ })
1696
+ })
1697
+ });
1698
+ },
1699
+ unregisterNode: (id) => {
1700
+ const s = get().nodes;
1701
+ const existingNode = s.nodes[id];
1702
+ if (existingNode) {
1703
+ const newNodes = __spreadValues({}, s.nodes);
1704
+ delete newNodes[id];
1705
+ set({
1706
+ nodes: __spreadProps(__spreadValues({}, s), {
1707
+ nodes: newNodes
1708
+ })
1709
+ });
1710
+ }
1711
+ }
1712
+ });
1713
+
1714
+ // ../core/store/slices/permissions.ts
1715
+ init_react_import();
1716
+ var import_react7 = require("react");
1717
+
1718
+ // ../core/lib/data/flatten-data.ts
1719
+ init_react_import();
1720
+ var flattenData = (state, config) => {
1721
+ const data = [];
1722
+ walkAppState(
1723
+ state,
1724
+ config,
1725
+ (content) => content,
1726
+ (item) => {
1727
+ data.push(item);
1728
+ return null;
1729
+ }
1730
+ );
1731
+ return data;
1732
+ };
1733
+
1734
+ // ../core/lib/get-changed.ts
1735
+ init_react_import();
1736
+ var import_fast_deep_equal = __toESM(require_fast_deep_equal());
1737
+ var getChanged = (newItem, oldItem) => {
1738
+ return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
1739
+ const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
1740
+ const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
1741
+ return __spreadProps(__spreadValues({}, acc), {
1742
+ [item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
1743
+ });
1744
+ }, {}) : {};
1745
+ };
1746
+
1747
+ // ../core/store/slices/permissions.ts
1748
+ var createPermissionsSlice = (set, get) => {
1749
+ const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
1750
+ const { state, permissions, config } = get();
1751
+ const { cache: cache2, globalPermissions } = permissions;
1752
+ const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
1753
+ var _a, _b, _c;
1754
+ const { config: config2, state: appState, setComponentLoading } = get();
1755
+ const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
1756
+ if (!componentConfig) {
1757
+ return;
1758
+ }
1759
+ const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
1760
+ if (componentConfig.resolvePermissions) {
1761
+ const changed = getChanged(item2, (_a = cache2[item2.props.id]) == null ? void 0 : _a.lastData);
1762
+ if (Object.values(changed).some((el) => el === true) || force2) {
1763
+ const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
1764
+ const resolvedPermissions = yield componentConfig.resolvePermissions(
1765
+ item2,
1766
+ {
1767
+ changed,
1768
+ lastPermissions: ((_b = cache2[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
1769
+ permissions: initialPermissions,
1770
+ appState: makeStatePublic(appState),
1771
+ lastData: ((_c = cache2[item2.props.id]) == null ? void 0 : _c.lastData) || null
1772
+ }
1773
+ );
1774
+ const latest = get().permissions;
1775
+ set({
1776
+ permissions: __spreadProps(__spreadValues({}, latest), {
1777
+ cache: __spreadProps(__spreadValues({}, latest.cache), {
1778
+ [item2.props.id]: {
1779
+ lastData: item2,
1780
+ lastPermissions: resolvedPermissions
1781
+ }
1782
+ }),
1783
+ resolvedPermissions: __spreadProps(__spreadValues({}, latest.resolvedPermissions), {
1784
+ [item2.props.id]: resolvedPermissions
1785
+ })
1786
+ })
1787
+ });
1788
+ clearTimeout2();
1789
+ }
1790
+ }
1791
+ });
1792
+ const resolveDataForRoot = (force2 = false) => {
1793
+ const { state: appState } = get();
1794
+ resolveDataForItem(
1795
+ // Shim the root data in by conforming to component data shape
1796
+ {
1797
+ type: "root",
1798
+ props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "root" })
1799
+ },
1800
+ force2
1801
+ );
1802
+ };
1803
+ const { item, type, root } = params;
1804
+ if (item) {
1805
+ yield resolveDataForItem(item, force);
1806
+ } else if (type) {
1807
+ flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(void 0, null, function* () {
1808
+ yield resolveDataForItem(item2, force);
1809
+ }));
1810
+ } else if (root) {
1811
+ resolveDataForRoot(force);
1812
+ } else {
1813
+ flattenData(state, config).map((item2) => __async(void 0, null, function* () {
1814
+ yield resolveDataForItem(item2, force);
1815
+ }));
1816
+ }
1817
+ });
1818
+ const refreshPermissions = (params) => resolvePermissions(params, true);
1819
+ return {
1820
+ cache: {},
1821
+ globalPermissions: {
1822
+ drag: true,
1823
+ edit: true,
1824
+ delete: true,
1825
+ duplicate: true,
1826
+ insert: true
1827
+ },
1828
+ resolvedPermissions: {},
1829
+ getPermissions: ({ item, type, root } = {}) => {
1830
+ const { config, permissions } = get();
1831
+ const { globalPermissions, resolvedPermissions } = permissions;
1832
+ if (item) {
1833
+ const componentConfig = config.components[item.type];
1834
+ const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
1835
+ const resolvedForItem = resolvedPermissions[item.props.id];
1836
+ return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
1837
+ } else if (type) {
1838
+ const componentConfig = config.components[type];
1839
+ return __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
1840
+ } else if (root) {
1841
+ const rootConfig = config.root;
1842
+ const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
1843
+ const resolvedForItem = resolvedPermissions["root"];
1844
+ return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
1845
+ }
1846
+ return globalPermissions;
1847
+ },
1848
+ resolvePermissions,
1849
+ refreshPermissions
1850
+ };
1851
+ };
1852
+
1853
+ // ../core/store/slices/fields.ts
1854
+ init_react_import();
1855
+ var import_react8 = require("react");
1856
+ var createFieldsSlice = (_set, _get) => {
1857
+ return {
1858
+ fields: {},
1859
+ loading: false,
1860
+ lastResolvedData: {},
1861
+ id: void 0
1862
+ };
1863
+ };
1864
+
1865
+ // ../core/lib/resolve-component-data.ts
1866
+ init_react_import();
1867
+ var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
1868
+ var cache = { lastChange: {} };
1869
+ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
1870
+ const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
1871
+ const resolvedItem = __spreadValues({}, item);
1872
+ const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
1873
+ const id = "id" in item.props ? item.props.id : "root";
1874
+ if (shouldRunResolver) {
1875
+ const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
1876
+ if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
1877
+ return { node: resolved, didChange: false };
1878
+ }
1879
+ const changed = getChanged(item, oldItem);
1880
+ if (onResolveStart) {
1881
+ onResolveStart(item);
1882
+ }
1883
+ const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
1884
+ changed,
1885
+ lastData: oldItem,
1886
+ metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
1887
+ trigger
1888
+ });
1889
+ resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
1890
+ if (Object.keys(readOnly).length) {
1891
+ resolvedItem.readOnly = readOnly;
1892
+ }
1893
+ }
1894
+ let itemWithResolvedChildren = yield mapFields(
1895
+ resolvedItem,
1896
+ {
1897
+ slot: (_02) => __async(void 0, [_02], function* ({ value }) {
1898
+ const content = value;
1899
+ return yield Promise.all(
1900
+ content.map(
1901
+ (childItem) => __async(void 0, null, function* () {
1902
+ return (yield resolveComponentData(
1903
+ childItem,
1904
+ config,
1905
+ metadata,
1906
+ onResolveStart,
1907
+ onResolveEnd,
1908
+ trigger
1909
+ )).node;
1910
+ })
1911
+ )
1912
+ );
1913
+ })
1914
+ },
1915
+ config
1916
+ );
1917
+ if (shouldRunResolver && onResolveEnd) {
1918
+ onResolveEnd(resolvedItem);
1919
+ }
1920
+ cache.lastChange[id] = {
1921
+ item,
1922
+ resolved: itemWithResolvedChildren
1923
+ };
1924
+ return {
1925
+ node: itemWithResolvedChildren,
1926
+ didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
1927
+ };
1928
+ });
1929
+
1930
+ // ../core/lib/data/to-root.ts
1931
+ init_react_import();
1932
+ var toRoot = (item) => {
1933
+ if ("type" in item && item.type !== "root") {
1934
+ throw new Error("Converting non-root item to root.");
1935
+ }
1936
+ const { readOnly } = item;
1937
+ if (item.props) {
1938
+ if ("id" in item.props) {
1939
+ const _a = item.props, { id } = _a, props = __objRest(_a, ["id"]);
1940
+ return { props, readOnly };
1941
+ }
1942
+ return { props: item.props, readOnly };
1943
+ }
1944
+ return { props: {}, readOnly };
1945
+ };
1946
+
1947
+ // ../core/store/default-app-state.ts
1948
+ init_react_import();
1949
+ var defaultAppState = {
1950
+ data: { content: [], root: {}, zones: {} },
1951
+ ui: {
1952
+ leftSideBarVisible: true,
1953
+ rightSideBarVisible: true,
1954
+ arrayState: {},
1955
+ itemSelector: null,
1956
+ componentList: {},
1957
+ isDragging: false,
1958
+ previewMode: "edit",
1959
+ viewports: {
1960
+ current: {
1961
+ width: defaultViewports[0].width,
1962
+ height: defaultViewports[0].height || "auto"
1963
+ },
1964
+ options: [],
1965
+ controlsVisible: true
1966
+ },
1967
+ field: { focus: null }
1968
+ },
1969
+ indexes: {
1970
+ nodes: {},
1971
+ zones: {}
1972
+ }
1973
+ };
1974
+
1975
+ // ../core/store/index.ts
1976
+ var defaultPageFields = {
1977
+ title: { type: "text" }
1978
+ };
1979
+ var createAppStore = (initialAppStore) => create()(
1980
+ subscribeWithSelector((set, get) => {
1981
+ var _a, _b;
1982
+ return __spreadProps(__spreadValues({
1983
+ state: defaultAppState,
1984
+ config: { components: {} },
1985
+ componentState: {},
1986
+ plugins: [],
1987
+ overrides: {},
1988
+ viewports: defaultViewports,
1989
+ zoomConfig: {
1990
+ autoZoom: 1,
1991
+ rootHeight: 0,
1992
+ zoom: 1
1993
+ },
1994
+ status: "LOADING",
1995
+ iframe: {},
1996
+ metadata: {},
1997
+ fieldTransforms: {}
1998
+ }, initialAppStore), {
1999
+ fields: createFieldsSlice(set, get),
2000
+ history: createHistorySlice(set, get),
2001
+ nodes: createNodesSlice(set, get),
2002
+ permissions: createPermissionsSlice(set, get),
2003
+ getComponentConfig: (type) => {
2004
+ var _a2;
2005
+ const { config, selectedItem } = get();
2006
+ const rootFields = ((_a2 = config.root) == null ? void 0 : _a2.fields) || defaultPageFields;
2007
+ return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
2008
+ },
2009
+ selectedItem: ((_a = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _a.ui.itemSelector) ? getItem(
2010
+ (_b = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _b.ui.itemSelector,
2011
+ initialAppStore.state
2012
+ ) : null,
2013
+ dispatch: (action) => set((s) => {
2014
+ var _a2, _b2;
2015
+ const { record } = get().history;
2016
+ const dispatch = createReducer({
2017
+ record,
2018
+ appStore: s
2019
+ });
2020
+ const state = dispatch(s.state, action);
2021
+ const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
2022
+ (_b2 = (_a2 = get()).onAction) == null ? void 0 : _b2.call(_a2, action, state, get().state);
2023
+ return __spreadProps(__spreadValues({}, s), { state, selectedItem });
2024
+ }),
2025
+ setZoomConfig: (zoomConfig) => set({ zoomConfig }),
2026
+ setStatus: (status) => set({ status }),
2027
+ setComponentState: (componentState) => set({ componentState }),
2028
+ pendingLoadTimeouts: {},
2029
+ setComponentLoading: (id, loading = true, defer = 0) => {
2030
+ const { setComponentState, pendingLoadTimeouts } = get();
2031
+ const loadId = generateId();
2032
+ const setLoading = () => {
2033
+ var _a2;
2034
+ const { componentState } = get();
2035
+ setComponentState(__spreadProps(__spreadValues({}, componentState), {
2036
+ [id]: __spreadProps(__spreadValues({}, componentState[id]), {
2037
+ loadingCount: (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) + 1
2038
+ })
2039
+ }));
2040
+ };
2041
+ const unsetLoading = () => {
2042
+ var _a2;
2043
+ const { componentState } = get();
2044
+ clearTimeout(timeout);
2045
+ delete pendingLoadTimeouts[loadId];
2046
+ set({ pendingLoadTimeouts });
2047
+ setComponentState(__spreadProps(__spreadValues({}, componentState), {
2048
+ [id]: __spreadProps(__spreadValues({}, componentState[id]), {
2049
+ loadingCount: Math.max(
2050
+ (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) - 1,
2051
+ 0
2052
+ )
2053
+ })
2054
+ }));
2055
+ };
2056
+ const timeout = setTimeout(() => {
2057
+ if (loading) {
2058
+ setLoading();
2059
+ } else {
2060
+ unsetLoading();
2061
+ }
2062
+ delete pendingLoadTimeouts[loadId];
2063
+ set({ pendingLoadTimeouts });
2064
+ }, defer);
2065
+ set({
2066
+ pendingLoadTimeouts: __spreadProps(__spreadValues({}, pendingLoadTimeouts), {
2067
+ [id]: timeout
2068
+ })
2069
+ });
2070
+ return unsetLoading;
2071
+ },
2072
+ unsetComponentLoading: (id) => {
2073
+ const { setComponentLoading } = get();
2074
+ setComponentLoading(id, false);
2075
+ },
2076
+ // Helper
2077
+ setUi: (ui, recordHistory) => set((s) => {
2078
+ const dispatch = createReducer({
2079
+ record: () => {
2080
+ },
2081
+ appStore: s
2082
+ });
2083
+ const state = dispatch(s.state, {
2084
+ type: "setUi",
2085
+ ui,
2086
+ recordHistory
2087
+ });
2088
+ const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
2089
+ return __spreadProps(__spreadValues({}, s), { state, selectedItem });
2090
+ }),
2091
+ resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
2092
+ const { config, metadata, setComponentLoading, permissions } = get();
2093
+ const timeouts = {};
2094
+ return yield resolveComponentData(
2095
+ componentData,
2096
+ config,
2097
+ metadata,
2098
+ (item) => {
2099
+ const id = "id" in item.props ? item.props.id : "root";
2100
+ timeouts[id] = setComponentLoading(id, true, 50);
2101
+ },
2102
+ (item) => __async(void 0, null, function* () {
2103
+ const id = "id" in item.props ? item.props.id : "root";
2104
+ if ("type" in item) {
2105
+ yield permissions.refreshPermissions({ item });
2106
+ } else {
2107
+ yield permissions.refreshPermissions({ root: true });
2108
+ }
2109
+ timeouts[id]();
2110
+ }),
2111
+ trigger
2112
+ );
2113
+ }),
2114
+ resolveAndCommitData: () => __async(void 0, null, function* () {
2115
+ const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
2116
+ walkAppState(
2117
+ state,
2118
+ config,
2119
+ (content) => content,
2120
+ (childItem) => {
2121
+ resolveComponentData2(childItem, "load").then((resolved) => {
2122
+ const { state: state2 } = get();
2123
+ const node = state2.indexes.nodes[resolved.node.props.id];
2124
+ if (node && resolved.didChange) {
2125
+ if (resolved.node.props.id === "root") {
2126
+ dispatch({
2127
+ type: "replaceRoot",
2128
+ root: toRoot(resolved.node)
2129
+ });
2130
+ } else {
2131
+ const zoneCompound = `${node.parentId}:${node.zone}`;
2132
+ const parentZone = state2.indexes.zones[zoneCompound];
2133
+ const index = parentZone.contentIds.indexOf(
2134
+ resolved.node.props.id
2135
+ );
2136
+ dispatch({
2137
+ type: "replace",
2138
+ data: resolved.node,
2139
+ destinationIndex: index,
2140
+ destinationZone: zoneCompound
2141
+ });
2142
+ }
2143
+ }
2144
+ });
2145
+ return childItem;
2146
+ }
2147
+ );
2148
+ })
2149
+ });
2150
+ })
2151
+ );
2152
+ var appStoreContext = (0, import_react9.createContext)(createAppStore());
2153
+
2154
+ // ../core/lib/get-zoom-config.ts
2155
+ init_react_import();
2156
+
341
2157
  // src/HeadingAnalyzer.tsx
342
2158
  var import_react_from_json = __toESM(require("react-from-json"));
343
2159
  var import_jsx_runtime2 = require("react/jsx-runtime");
@@ -396,8 +2212,8 @@ function buildHierarchy(frame) {
396
2212
  var usePuck = (0, import_puck.createUsePuck)();
397
2213
  var HeadingAnalyzer = () => {
398
2214
  const data = usePuck((s) => s.appState.data);
399
- const [hierarchy, setHierarchy] = (0, import_react4.useState)([]);
400
- (0, import_react4.useEffect)(() => {
2215
+ const [hierarchy, setHierarchy] = (0, import_react10.useState)([]);
2216
+ (0, import_react10.useEffect)(() => {
401
2217
  const frame = getFrame();
402
2218
  let entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
403
2219
  const createHierarchy = () => {