@domql/utils 3.1.2 → 3.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/array.js +11 -5
  2. package/cache.js +3 -0
  3. package/component.js +3 -4
  4. package/dist/cjs/array.js +11 -5
  5. package/dist/cjs/component.js +4 -6
  6. package/dist/cjs/element.js +6 -6
  7. package/dist/cjs/env.js +1 -1
  8. package/dist/cjs/events.js +3 -3
  9. package/dist/cjs/extends.js +44 -28
  10. package/dist/cjs/function.js +3 -3
  11. package/dist/cjs/index.js +1 -0
  12. package/dist/cjs/key.js +2 -2
  13. package/dist/cjs/keys.js +29 -15
  14. package/dist/cjs/methods.js +88 -33
  15. package/dist/cjs/object.js +154 -141
  16. package/dist/cjs/props.js +43 -34
  17. package/dist/cjs/scope.js +1 -2
  18. package/dist/cjs/state.js +12 -11
  19. package/dist/cjs/string.js +15 -20
  20. package/dist/cjs/tags.js +71 -16
  21. package/dist/cjs/triggerEvent.js +90 -0
  22. package/dist/cjs/types.js +4 -12
  23. package/dist/esm/array.js +11 -5
  24. package/dist/esm/component.js +4 -6
  25. package/dist/esm/element.js +9 -27
  26. package/dist/esm/env.js +1 -1
  27. package/dist/esm/events.js +3 -3
  28. package/dist/esm/extends.js +48 -50
  29. package/dist/esm/function.js +3 -3
  30. package/dist/esm/index.js +1 -0
  31. package/dist/esm/key.js +2 -2
  32. package/dist/esm/keys.js +29 -15
  33. package/dist/esm/methods.js +86 -31
  34. package/dist/esm/object.js +158 -165
  35. package/dist/esm/props.js +43 -50
  36. package/dist/esm/scope.js +1 -2
  37. package/dist/esm/state.js +21 -38
  38. package/dist/esm/string.js +15 -20
  39. package/dist/esm/tags.js +71 -16
  40. package/dist/esm/triggerEvent.js +70 -0
  41. package/dist/esm/types.js +4 -12
  42. package/dist/iife/index.js +2779 -0
  43. package/element.js +2 -2
  44. package/events.js +3 -3
  45. package/extends.js +28 -17
  46. package/function.js +10 -9
  47. package/index.js +1 -0
  48. package/keys.js +25 -15
  49. package/log.js +0 -1
  50. package/methods.js +99 -24
  51. package/object.js +155 -215
  52. package/package.json +34 -13
  53. package/props.js +44 -27
  54. package/state.js +12 -12
  55. package/string.js +20 -38
  56. package/tags.js +45 -16
  57. package/triggerEvent.js +76 -0
  58. package/types.js +8 -25
  59. package/dist/cjs/package.json +0 -4
@@ -0,0 +1,2779 @@
1
+ "use strict";
2
+ var DomqlUtils = (() => {
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // index.js
22
+ var index_exports = {};
23
+ __export(index_exports, {
24
+ DOMQL_EVENTS: () => DOMQL_EVENTS,
25
+ DOMQ_PROPERTIES: () => DOMQ_PROPERTIES,
26
+ ENV: () => ENV2,
27
+ HTML_TAGS: () => HTML_TAGS,
28
+ METHODS: () => METHODS,
29
+ METHODS_EXL: () => METHODS_EXL,
30
+ NODE_ENV: () => NODE_ENV,
31
+ OPTIONS: () => OPTIONS,
32
+ PARSED_DOMQ_PROPERTIES: () => PARSED_DOMQ_PROPERTIES,
33
+ PROPS_METHODS: () => PROPS_METHODS,
34
+ STATE_METHODS: () => STATE_METHODS,
35
+ STATE_PROPERTIES: () => STATE_PROPERTIES,
36
+ SVG_TAGS: () => SVG_TAGS,
37
+ TYPES: () => TYPES,
38
+ addCaching: () => addCaching,
39
+ addContext: () => addContext,
40
+ addExtend: () => addExtend,
41
+ addExtends: () => addExtends,
42
+ addItemAfterEveryElement: () => addItemAfterEveryElement,
43
+ addProtoToArray: () => addProtoToArray,
44
+ addRef: () => addRef,
45
+ applyDependentState: () => applyDependentState,
46
+ applyEvent: () => applyEvent,
47
+ applyEventUpdate: () => applyEventUpdate,
48
+ applyExtends: () => applyExtends,
49
+ applyProps: () => applyProps,
50
+ arrayContainsOtherArray: () => arrayContainsOtherArray,
51
+ arraysEqual: () => arraysEqual,
52
+ cache: () => cache,
53
+ call: () => call,
54
+ captureSnapshot: () => captureSnapshot,
55
+ checkForStateTypes: () => checkForStateTypes,
56
+ checkIfInherits: () => checkIfInherits,
57
+ checkIfStringIsInArray: () => checkIfStringIsInArray,
58
+ clone: () => clone,
59
+ cloneAndMergeArrayExtend: () => cloneAndMergeArrayExtend,
60
+ cloneFunction: () => cloneFunction,
61
+ concatAddExtends: () => concatAddExtends,
62
+ createBasedOnType: () => createBasedOnType,
63
+ createElement: () => createElement,
64
+ createElementExtends: () => createElementExtends,
65
+ createExtends: () => createExtends,
66
+ createExtendsFromKeys: () => createExtendsFromKeys,
67
+ createExtendsStack: () => createExtendsStack,
68
+ createIfConditionFlag: () => createIfConditionFlag,
69
+ createInheritedState: () => createInheritedState,
70
+ createKey: () => createKey,
71
+ createNestedObject: () => createNestedObject,
72
+ createNestedObjectByKeyPath: () => createNestedObjectByKeyPath,
73
+ createObjectWithoutPrototype: () => createObjectWithoutPrototype,
74
+ createParent: () => createParent,
75
+ createPath: () => createPath,
76
+ createProps: () => createProps,
77
+ createPropsStack: () => createPropsStack,
78
+ createRoot: () => createRoot,
79
+ createScope: () => createScope,
80
+ createSnapshotId: () => createSnapshotId,
81
+ customDecodeURIComponent: () => customDecodeURIComponent,
82
+ customEncodeURIComponent: () => customEncodeURIComponent,
83
+ cutArrayAfterValue: () => cutArrayAfterValue,
84
+ cutArrayBeforeValue: () => cutArrayBeforeValue,
85
+ debounce: () => debounce,
86
+ debounceOnContext: () => debounceOnContext,
87
+ decodeNewlines: () => decodeNewlines,
88
+ deepClone: () => deepClone,
89
+ deepContains: () => deepContains,
90
+ deepDestringify: () => deepDestringify,
91
+ deepExtend: () => deepExtend,
92
+ deepMerge: () => deepMerge,
93
+ deepMergeExtends: () => deepMergeExtends,
94
+ deepStringify: () => deepStringify,
95
+ defineSetter: () => defineSetter,
96
+ detectInfiniteLoop: () => detectInfiniteLoop,
97
+ document: () => document2,
98
+ encodeNewlines: () => encodeNewlines,
99
+ error: () => error,
100
+ excludeKeysFromObject: () => excludeKeysFromObject,
101
+ exec: () => exec,
102
+ extendCachedRegistry: () => extendCachedRegistry,
103
+ extendStackRegistry: () => extendStackRegistry,
104
+ extractArrayExtend: () => extractArrayExtend,
105
+ filterArrays: () => filterArrays,
106
+ filterArraysFast: () => filterArraysFast,
107
+ finalizeExtends: () => finalizeExtends,
108
+ findInheritedState: () => findInheritedState,
109
+ findKeyPosition: () => findKeyPosition,
110
+ flattenExtend: () => flattenExtend,
111
+ generateHash: () => generateHash,
112
+ generateKey: () => generateKey,
113
+ get: () => get,
114
+ getCapitalCaseKeys: () => getCapitalCaseKeys,
115
+ getChildStateInKey: () => getChildStateInKey,
116
+ getChildren: () => getChildren,
117
+ getContext: () => getContext,
118
+ getCookie: () => getCookie,
119
+ getExtendsInElement: () => getExtendsInElement,
120
+ getExtendsStack: () => getExtendsStack,
121
+ getExtendsStackRegistry: () => getExtendsStackRegistry,
122
+ getFrequencyInArray: () => getFrequencyInArray,
123
+ getHashedExtend: () => getHashedExtend,
124
+ getInObjectByPath: () => getInObjectByPath,
125
+ getLocalStorage: () => getLocalStorage,
126
+ getNev: () => getNev,
127
+ getParentStateInKey: () => getParentStateInKey,
128
+ getPath: () => getPath,
129
+ getRef: () => getRef,
130
+ getRoot: () => getRoot,
131
+ getRootContext: () => getRootContext,
132
+ getRootData: () => getRootData,
133
+ getRootState: () => getRootState,
134
+ getRootStateInKey: () => getRootStateInKey,
135
+ getSpreadChildren: () => getSpreadChildren,
136
+ global: () => global,
137
+ hasFunction: () => hasFunction,
138
+ hasOwnProperty: () => hasOwnProperty,
139
+ inheritChildExtends: () => inheritChildExtends,
140
+ inheritChildPropsExtends: () => inheritChildPropsExtends,
141
+ inheritParentProps: () => inheritParentProps,
142
+ inheritRecursiveChildExtends: () => inheritRecursiveChildExtends,
143
+ initProps: () => initProps,
144
+ is: () => is,
145
+ isArray: () => isArray,
146
+ isBoolean: () => isBoolean,
147
+ isContextComponent: () => isContextComponent,
148
+ isCyclic: () => isCyclic,
149
+ isDOMNode: () => isDOMNode,
150
+ isDate: () => isDate,
151
+ isDefined: () => isDefined,
152
+ isDevelopment: () => isDevelopment,
153
+ isEmpty: () => isEmpty,
154
+ isEmptyObject: () => isEmptyObject,
155
+ isEqualDeep: () => isEqualDeep,
156
+ isFunction: () => isFunction,
157
+ isHtmlElement: () => isHtmlElement,
158
+ isLocal: () => isLocal,
159
+ isMethod: () => isMethod,
160
+ isMobile: () => isMobile,
161
+ isNode: () => isNode,
162
+ isNot: () => isNot,
163
+ isNotProduction: () => isNotProduction,
164
+ isNull: () => isNull,
165
+ isNumber: () => isNumber,
166
+ isObject: () => isObject,
167
+ isObjectLike: () => isObjectLike,
168
+ isProduction: () => isProduction,
169
+ isStaging: () => isStaging,
170
+ isState: () => isState,
171
+ isString: () => isString,
172
+ isStringFunction: () => isStringFunction,
173
+ isTest: () => isTest,
174
+ isTesting: () => isTesting,
175
+ isUndefined: () => isUndefined,
176
+ isValidHtmlTag: () => isValidHtmlTag,
177
+ joinArrays: () => joinArrays,
178
+ jointStacks: () => jointStacks,
179
+ keys: () => keys,
180
+ log: () => log,
181
+ logGroupIf: () => logGroupIf,
182
+ logIf: () => logIf,
183
+ lookdown: () => lookdown,
184
+ lookdownAll: () => lookdownAll,
185
+ lookup: () => lookup,
186
+ lowercaseFirstLetter: () => lowercaseFirstLetter,
187
+ makeObjectWithoutPrototype: () => makeObjectWithoutPrototype,
188
+ map: () => map,
189
+ mapStringsWithContextComponents: () => mapStringsWithContextComponents,
190
+ matchesComponentNaming: () => matchesComponentNaming,
191
+ memoize: () => memoize,
192
+ merge: () => merge,
193
+ nextElement: () => nextElement,
194
+ objectToString: () => objectToString,
195
+ objectizeStringProperty: () => objectizeStringProperty,
196
+ overwrite: () => overwrite,
197
+ overwriteDeep: () => overwriteDeep,
198
+ overwriteShallow: () => overwriteShallow,
199
+ overwriteState: () => overwriteState,
200
+ parse: () => parse,
201
+ parseDeep: () => parseDeep,
202
+ pickupElementFromProps: () => pickupElementFromProps,
203
+ pickupPropsFromElement: () => pickupPropsFromElement,
204
+ previousElement: () => previousElement,
205
+ propExists: () => propExists,
206
+ propertizeElement: () => propertizeElement,
207
+ propertizeUpdate: () => propertizeUpdate,
208
+ remove: () => remove,
209
+ removeCookie: () => removeCookie,
210
+ removeDuplicateProps: () => removeDuplicateProps,
211
+ removeDuplicatesInArray: () => removeDuplicatesInArray,
212
+ removeFromArray: () => removeFromArray,
213
+ removeFromObject: () => removeFromObject,
214
+ removeNestedKeyByPath: () => removeNestedKeyByPath,
215
+ removeValueFromArray: () => removeValueFromArray,
216
+ removeValueFromArrayAll: () => removeValueFromArrayAll,
217
+ reorderArrayByValues: () => reorderArrayByValues,
218
+ replaceLiteralsWithObjectFields: () => replaceLiteralsWithObjectFields,
219
+ replaceOctalEscapeSequences: () => replaceOctalEscapeSequences,
220
+ returnValueAsText: () => returnValueAsText,
221
+ self: () => self,
222
+ setCookie: () => setCookie,
223
+ setHashedExtend: () => setHashedExtend,
224
+ setInObjectByPath: () => setInObjectByPath,
225
+ setLocalStorage: () => setLocalStorage,
226
+ setNodeStyles: () => setNodeStyles,
227
+ setProps: () => setProps,
228
+ setPropsPrototype: () => setPropsPrototype,
229
+ spotByPath: () => spotByPath,
230
+ stringIncludesAny: () => stringIncludesAny,
231
+ stringToObject: () => stringToObject,
232
+ swapItemsInArray: () => swapItemsInArray,
233
+ syncProps: () => syncProps,
234
+ triggerEventOn: () => triggerEventOn,
235
+ triggerEventOnUpdate: () => triggerEventOnUpdate,
236
+ trimStringFromSymbols: () => trimStringFromSymbols,
237
+ unstackArrayOfObjects: () => unstackArrayOfObjects,
238
+ update: () => update,
239
+ updateProps: () => updateProps,
240
+ variables: () => variables,
241
+ verbose: () => verbose,
242
+ warn: () => warn,
243
+ window: () => window2
244
+ });
245
+
246
+ // globals.js
247
+ var global = globalThis;
248
+ var self = globalThis;
249
+ var window2 = globalThis;
250
+ var document2 = window2.document;
251
+
252
+ // node.js
253
+ var isNode = (obj) => {
254
+ return (typeof Node === "object" ? obj instanceof window2.Node : obj && typeof obj === "object" && typeof obj.nodeType === "number" && typeof obj.nodeName === "string") || false;
255
+ };
256
+ var isHtmlElement = (obj) => {
257
+ return (typeof HTMLElement === "object" ? obj instanceof window2.HTMLElement : obj && typeof obj === "object" && obj !== null && obj.nodeType === 1 && typeof obj.nodeName === "string") || false;
258
+ };
259
+ var isDOMNode = (obj) => {
260
+ return typeof window2 !== "undefined" && (obj instanceof window2.Node || obj instanceof window2.Window || obj === window2 || obj === document);
261
+ };
262
+
263
+ // types.js
264
+ var isObject = (arg) => {
265
+ if (arg === null) return false;
266
+ return typeof arg === "object" && arg.constructor === Object;
267
+ };
268
+ var isString = (arg) => typeof arg === "string";
269
+ var isNumber = (arg) => typeof arg === "number";
270
+ var isFunction = (arg) => typeof arg === "function";
271
+ var isBoolean = (arg) => arg === true || arg === false;
272
+ var isNull = (arg) => arg === null;
273
+ var isArray = (arg) => Array.isArray(arg);
274
+ var isDate = (d) => d instanceof Date;
275
+ var isObjectLike = (arg) => {
276
+ if (arg === null) return false;
277
+ return typeof arg === "object";
278
+ };
279
+ var isDefined = (arg) => arg !== void 0;
280
+ var isUndefined = (arg) => arg === void 0;
281
+ var TYPES = {
282
+ boolean: isBoolean,
283
+ array: isArray,
284
+ object: isObject,
285
+ string: isString,
286
+ date: isDate,
287
+ number: isNumber,
288
+ null: isNull,
289
+ function: isFunction,
290
+ objectLike: isObjectLike,
291
+ node: isNode,
292
+ htmlElement: isHtmlElement,
293
+ defined: isDefined
294
+ };
295
+ var is = (arg) => {
296
+ return (...args) => args.some((val) => TYPES[val](arg));
297
+ };
298
+ var isNot = (arg) => {
299
+ return (...args) => !args.some((val) => TYPES[val](arg));
300
+ };
301
+
302
+ // array.js
303
+ var arrayContainsOtherArray = (arr1, arr2) => {
304
+ return arr2.every((val) => arr1.includes(val));
305
+ };
306
+ var getFrequencyInArray = (arr, value) => {
307
+ let count = 0;
308
+ for (let i = 0; i < arr.length; i++) {
309
+ if (arr[i] === value) count++;
310
+ }
311
+ return count;
312
+ };
313
+ var removeFromArray = (arr, index) => {
314
+ if (isString(index)) index = parseInt(index);
315
+ if (isNumber(index)) {
316
+ if (index < 0 || index >= arr.length || isNaN(index)) {
317
+ throw new Error("Invalid index");
318
+ }
319
+ arr.splice(index, 1);
320
+ } else {
321
+ throw new Error("Invalid index");
322
+ }
323
+ return arr;
324
+ };
325
+ var swapItemsInArray = (arr, i, j) => {
326
+ ;
327
+ [arr[i], arr[j]] = [arr[j], arr[i]];
328
+ };
329
+ var joinArrays = (...arrays) => {
330
+ return [].concat(...arrays);
331
+ };
332
+ var unstackArrayOfObjects = (arr, exclude = []) => {
333
+ return arr.reduce(
334
+ (a, c) => deepMerge(a, deepClone(c, { exclude }), exclude),
335
+ {}
336
+ );
337
+ };
338
+ var cutArrayBeforeValue = (arr, value) => {
339
+ const index = arr.indexOf(value);
340
+ if (index !== -1) {
341
+ return arr.slice(0, index);
342
+ }
343
+ return arr;
344
+ };
345
+ var cutArrayAfterValue = (arr, value) => {
346
+ if (!isArray(arr)) return;
347
+ const index = arr.indexOf(value);
348
+ if (index !== -1) {
349
+ return arr.slice(index + 1);
350
+ }
351
+ return arr;
352
+ };
353
+ var removeValueFromArray = (arr, value) => {
354
+ const index = arr.indexOf(value);
355
+ if (index > -1) {
356
+ const newArray = [...arr];
357
+ newArray.splice(index, 1);
358
+ return newArray;
359
+ }
360
+ return arr;
361
+ };
362
+ var removeValueFromArrayAll = (arr, value) => {
363
+ return arr.filter((item) => item !== value);
364
+ };
365
+ var addItemAfterEveryElement = (array, item) => {
366
+ const result = [];
367
+ for (let i = 0; i < array.length; i++) {
368
+ result.push(array[i]);
369
+ if (i < array.length - 1) {
370
+ result.push(item);
371
+ }
372
+ }
373
+ return result;
374
+ };
375
+ var reorderArrayByValues = (array, valueToMove, insertBeforeValue) => {
376
+ const newArray = [...array];
377
+ const indexToMove = newArray.indexOf(valueToMove);
378
+ const indexToInsertBefore = newArray.indexOf(insertBeforeValue);
379
+ if (indexToMove !== -1 && indexToInsertBefore !== -1) {
380
+ const removedItem = newArray.splice(indexToMove, 1)[0];
381
+ const insertIndex = indexToInsertBefore < indexToMove ? indexToInsertBefore : indexToInsertBefore + 1;
382
+ newArray.splice(insertIndex, 0, removedItem);
383
+ }
384
+ return newArray;
385
+ };
386
+ var arraysEqual = (arr1, arr2) => {
387
+ if (arr1.length !== arr2.length) {
388
+ return false;
389
+ }
390
+ for (let i = 0; i < arr1.length; i++) {
391
+ if (arr1[i] !== arr2[i]) {
392
+ return false;
393
+ }
394
+ }
395
+ return true;
396
+ };
397
+ var filterArrays = (sourceArr, excludeArr) => {
398
+ return sourceArr.filter((item) => !excludeArr.includes(item));
399
+ };
400
+ var filterArraysFast = (sourceArr, excludeArr) => {
401
+ const excludeSet = new Set(excludeArr);
402
+ return sourceArr.filter((item) => !excludeSet.has(item));
403
+ };
404
+ var checkIfStringIsInArray = (string, arr) => {
405
+ if (!string) return 0;
406
+ let count = 0;
407
+ for (let i = 0; i < arr.length; i++) {
408
+ if (string.includes(arr[i])) count++;
409
+ }
410
+ return count;
411
+ };
412
+ var removeDuplicatesInArray = (arr) => {
413
+ if (!isArray(arr)) return arr;
414
+ return [...new Set(arr)];
415
+ };
416
+ var addProtoToArray = (state, proto) => {
417
+ for (const key in proto) {
418
+ Object.defineProperty(state, key, {
419
+ value: proto[key],
420
+ enumerable: false,
421
+ // Set this to true if you want the method to appear in for...in loops
422
+ configurable: true,
423
+ // Set this to true if you want to allow redefining/removing the property later
424
+ writable: true
425
+ // Set this to true if you want to allow changing the function later
426
+ });
427
+ }
428
+ };
429
+
430
+ // string.js
431
+ var stringIncludesAny = (str, characters) => {
432
+ for (const char of characters) {
433
+ if (str.includes(char)) {
434
+ return true;
435
+ }
436
+ }
437
+ return false;
438
+ };
439
+ var trimStringFromSymbols = (str, characters) => {
440
+ const pattern = new RegExp(`[${characters.join("\\")}]`, "g");
441
+ return str.replace(pattern, "");
442
+ };
443
+ var brackRegex = {
444
+ 2: /{{\s*((?:\.\.\/)*)([\w\d.]+)\s*}}/g,
445
+ 3: /{{{(\s*(?:\.\.\/)*)([\w\d.]+)\s*}}}/g
446
+ };
447
+ var getNestedValue = (obj, path) => {
448
+ return path.split(".").reduce((acc, part) => {
449
+ return acc?.[part];
450
+ }, obj);
451
+ };
452
+ function replaceLiteralsWithObjectFields(str, state, options = {}) {
453
+ const { bracketsLength = 2 } = options;
454
+ const bracketPattern = bracketsLength === 3 ? "{{{" : "{{";
455
+ if (!str.includes(bracketPattern)) return str;
456
+ const reg = brackRegex[bracketsLength];
457
+ const obj = state || this.state || {};
458
+ return str.replace(reg, (_, parentPath, variable) => {
459
+ if (parentPath) {
460
+ const parentLevels = (parentPath.match(/\.\.\//g) || []).length;
461
+ let parentState = obj;
462
+ for (let i = 0; i < parentLevels; i++) {
463
+ if (!parentState || !parentState.parent) return "";
464
+ parentState = parentState.parent;
465
+ }
466
+ const key = variable.trim();
467
+ if (key === "parent") {
468
+ return String(parentState.value ?? "");
469
+ }
470
+ const value = getNestedValue(parentState, key);
471
+ return String(value ?? "");
472
+ } else {
473
+ const value = getNestedValue(obj, variable.trim());
474
+ return String(value ?? "");
475
+ }
476
+ });
477
+ }
478
+ var lowercaseFirstLetter = (inputString) => {
479
+ return `${inputString.charAt(0).toLowerCase()}${inputString.slice(1)}`;
480
+ };
481
+ var findKeyPosition = (str, key) => {
482
+ const lines = str.split("\n");
483
+ let startLineNumber = -1;
484
+ let endLineNumber = -1;
485
+ let startColumn = -1;
486
+ let endColumn = -1;
487
+ const keyPattern = new RegExp(`\\b${key}\\b\\s*:\\s*`);
488
+ let braceCount = 0;
489
+ let foundKey = false;
490
+ for (let i = 0; i < lines.length; i++) {
491
+ if (keyPattern.test(lines[i]) && !foundKey) {
492
+ foundKey = true;
493
+ startLineNumber = i + 1;
494
+ startColumn = lines[i].indexOf(key) + 1;
495
+ if (lines[i].includes("{}")) {
496
+ endLineNumber = startLineNumber;
497
+ endColumn = lines[i].indexOf("{}") + 3;
498
+ break;
499
+ }
500
+ const line = lines[i].slice(startColumn + key.length);
501
+ if (line.includes("{") || line.includes("[")) {
502
+ braceCount = 1;
503
+ } else {
504
+ endLineNumber = i + 1;
505
+ endColumn = lines[i].length + 1;
506
+ break;
507
+ }
508
+ } else if (foundKey) {
509
+ braceCount += (lines[i].match(/{/g) || []).length;
510
+ braceCount += (lines[i].match(/\[/g) || []).length;
511
+ braceCount -= (lines[i].match(/}/g) || []).length;
512
+ braceCount -= (lines[i].match(/]/g) || []).length;
513
+ if (braceCount === 0) {
514
+ endLineNumber = i + 1;
515
+ endColumn = lines[i].lastIndexOf("}") !== -1 ? lines[i].lastIndexOf("}") + 2 : lines[i].length + 1;
516
+ break;
517
+ }
518
+ }
519
+ }
520
+ return {
521
+ startColumn,
522
+ endColumn,
523
+ startLineNumber,
524
+ endLineNumber
525
+ };
526
+ };
527
+ var RE_OCTAL = /\\([0-7]{1,3})/g;
528
+ var replaceOctalEscapeSequences = (str) => {
529
+ return str.replace(RE_OCTAL, (_, p1) => String.fromCharCode(parseInt(p1, 8)));
530
+ };
531
+ var encodeNewlines = (str) => {
532
+ return str.replace(/\n/g, "/////n").replace(/`/g, "/////tilde").replace(/\$/g, "/////dlrsgn");
533
+ };
534
+ var decodeNewlines = (encodedStr) => {
535
+ return encodedStr.replace(/\/\/\/\/\/n/g, "\n").replace(/\/\/\/\/\/tilde/g, "`").replace(/\/\/\/\/\/dlrsgn/g, "$");
536
+ };
537
+ var RE_NON_ALNUM = /[^a-zA-Z0-9\s]/g;
538
+ var customEncodeURIComponent = (str) => {
539
+ return str.replace(
540
+ RE_NON_ALNUM,
541
+ (char) => "%" + char.charCodeAt(0).toString(16).toUpperCase()
542
+ );
543
+ };
544
+ var customDecodeURIComponent = (encodedStr) => {
545
+ return encodedStr.replace(
546
+ /%[0-9A-Fa-f]{2}/g,
547
+ (match) => String.fromCharCode(parseInt(match.slice(1), 16))
548
+ );
549
+ };
550
+
551
+ // keys.js
552
+ var DOMQ_PROPERTIES = /* @__PURE__ */ new Set([
553
+ "attr",
554
+ "style",
555
+ "text",
556
+ "html",
557
+ "content",
558
+ "data",
559
+ "classlist",
560
+ "state",
561
+ "scope",
562
+ "root",
563
+ "deps",
564
+ "extend",
565
+ "extends",
566
+ "$router",
567
+ "routes",
568
+ "children",
569
+ "childExtend",
570
+ "childExtends",
571
+ "childExtendRecursive",
572
+ "childExtendsRecursive",
573
+ "props",
574
+ "if",
575
+ "define",
576
+ "__name",
577
+ "__ref",
578
+ "__hash",
579
+ "__text",
580
+ "key",
581
+ "tag",
582
+ "query",
583
+ "parent",
584
+ "node",
585
+ "variables",
586
+ "on",
587
+ "component",
588
+ "context"
589
+ ]);
590
+ var PARSED_DOMQ_PROPERTIES = /* @__PURE__ */ new Set([
591
+ "attr",
592
+ "style",
593
+ "text",
594
+ "html",
595
+ "content",
596
+ "data",
597
+ "class",
598
+ "state",
599
+ "scope",
600
+ "children",
601
+ "props",
602
+ "if",
603
+ "key",
604
+ "tag",
605
+ "query",
606
+ "on",
607
+ "context"
608
+ ]);
609
+ var STATE_PROPERTIES = [
610
+ "ref",
611
+ "parent",
612
+ "__element",
613
+ "__depends",
614
+ "__ref",
615
+ "__children",
616
+ "root"
617
+ ];
618
+ var STATE_METHODS = /* @__PURE__ */ new Set([
619
+ "update",
620
+ "parse",
621
+ "clean",
622
+ "create",
623
+ "destroy",
624
+ "add",
625
+ "toggle",
626
+ "remove",
627
+ "apply",
628
+ "set",
629
+ "reset",
630
+ "replace",
631
+ "quietReplace",
632
+ "quietUpdate",
633
+ "applyReplace",
634
+ "applyFunction",
635
+ "keys",
636
+ "values",
637
+ "ref",
638
+ "rootUpdate",
639
+ "parentUpdate",
640
+ "parent",
641
+ "__element",
642
+ "__depends",
643
+ "__ref",
644
+ "__children",
645
+ "root",
646
+ "setByPath",
647
+ "setPathCollection",
648
+ "removeByPath",
649
+ "removePathCollection",
650
+ "getByPath"
651
+ ]);
652
+ var PROPS_METHODS = /* @__PURE__ */ new Set(["update", "__element"]);
653
+ var METHODS = /* @__PURE__ */ new Set([
654
+ "set",
655
+ "reset",
656
+ "update",
657
+ "remove",
658
+ "updateContent",
659
+ "removeContent",
660
+ "lookup",
661
+ "lookdown",
662
+ "lookdownAll",
663
+ "getRef",
664
+ "getPath",
665
+ "setNodeStyles",
666
+ "spotByPath",
667
+ "keys",
668
+ "parse",
669
+ "setProps",
670
+ "parseDeep",
671
+ "variables",
672
+ "if",
673
+ "log",
674
+ "verbose",
675
+ "warn",
676
+ "error",
677
+ "call",
678
+ "nextElement",
679
+ "previousElement",
680
+ "getRootState",
681
+ "getRoot",
682
+ "getRootData",
683
+ "getRootContext",
684
+ "getContext",
685
+ "getChildren"
686
+ ]);
687
+ var METHODS_EXL = /* @__PURE__ */ new Set([
688
+ "node",
689
+ "context",
690
+ "extends",
691
+ "__element",
692
+ "__ref",
693
+ ...METHODS,
694
+ ...STATE_METHODS,
695
+ ...PROPS_METHODS
696
+ ]);
697
+ var DOMQL_EVENTS = /* @__PURE__ */ new Set([
698
+ "init",
699
+ "beforeClassAssign",
700
+ "render",
701
+ "renderRouter",
702
+ "attachNode",
703
+ "stateInit",
704
+ "stateCreated",
705
+ "beforeStateUpdate",
706
+ "stateUpdate",
707
+ "beforeUpdate",
708
+ "done",
709
+ "create",
710
+ "complete",
711
+ "frame",
712
+ "update"
713
+ ]);
714
+
715
+ // object.js
716
+ var ENV = process.env.NODE_ENV;
717
+ var _startsWithDunder = (e) => e.charCodeAt(0) === 95 && e.charCodeAt(1) === 95;
718
+ var exec = (param, element, state, context) => {
719
+ if (isFunction(param)) {
720
+ if (!element) return;
721
+ const result = param.call(
722
+ element,
723
+ element,
724
+ state || element.state,
725
+ context || element.context
726
+ );
727
+ if (result && typeof result.then === "function") {
728
+ let resolved;
729
+ result.then((value) => {
730
+ resolved = value;
731
+ });
732
+ return resolved;
733
+ }
734
+ return result;
735
+ }
736
+ return param;
737
+ };
738
+ var map = (obj, extention, element) => {
739
+ for (const e in extention) {
740
+ obj[e] = exec(extention[e], element);
741
+ }
742
+ };
743
+ var merge = (element, obj, excludeFrom = []) => {
744
+ const useSet = excludeFrom instanceof Set;
745
+ for (const e in obj) {
746
+ if (!Object.prototype.hasOwnProperty.call(obj, e)) continue;
747
+ if (_startsWithDunder(e)) continue;
748
+ if (useSet ? excludeFrom.has(e) : excludeFrom.includes(e)) continue;
749
+ if (element[e] === void 0) {
750
+ element[e] = obj[e];
751
+ }
752
+ }
753
+ return element;
754
+ };
755
+ var deepMerge = (element, extend, excludeFrom = METHODS_EXL) => {
756
+ const useSet = excludeFrom instanceof Set;
757
+ for (const e in extend) {
758
+ if (!Object.prototype.hasOwnProperty.call(extend, e)) continue;
759
+ if (_startsWithDunder(e)) continue;
760
+ if (useSet ? excludeFrom.has(e) : excludeFrom.includes(e)) continue;
761
+ const elementProp = element[e];
762
+ const extendProp = extend[e];
763
+ if (isObjectLike(elementProp) && isObjectLike(extendProp)) {
764
+ deepMerge(elementProp, extendProp, excludeFrom);
765
+ } else if (elementProp === void 0) {
766
+ element[e] = extendProp;
767
+ }
768
+ }
769
+ return element;
770
+ };
771
+ var clone = (obj, excludeFrom = []) => {
772
+ const useSet = excludeFrom instanceof Set;
773
+ const o = {};
774
+ for (const prop in obj) {
775
+ if (!Object.prototype.hasOwnProperty.call(obj, prop)) continue;
776
+ if (_startsWithDunder(prop)) continue;
777
+ if (useSet ? excludeFrom.has(prop) : excludeFrom.includes(prop)) continue;
778
+ o[prop] = obj[prop];
779
+ }
780
+ return o;
781
+ };
782
+ var deepClone = (obj, options = {}) => {
783
+ const {
784
+ exclude = [],
785
+ cleanUndefined = false,
786
+ cleanNull = false,
787
+ window: targetWindow,
788
+ visited = /* @__PURE__ */ new WeakMap(),
789
+ handleExtends = false
790
+ } = options;
791
+ const contentWindow = targetWindow || window2 || globalThis;
792
+ if (!isObjectLike(obj) || isDOMNode(obj)) {
793
+ return obj;
794
+ }
795
+ if (visited.has(obj)) {
796
+ return visited.get(obj);
797
+ }
798
+ const isArr = isArray(obj);
799
+ const clone2 = isArr ? [] : {};
800
+ visited.set(obj, clone2);
801
+ const excludeSet = exclude instanceof Set ? exclude : exclude.length > 3 ? new Set(exclude) : null;
802
+ for (const key in obj) {
803
+ if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
804
+ if (_startsWithDunder(key) || key === "__proto__") continue;
805
+ if (excludeSet ? excludeSet.has(key) : exclude.includes(key)) continue;
806
+ const value = obj[key];
807
+ if (cleanUndefined && value === void 0) continue;
808
+ if (cleanNull && value === null) continue;
809
+ if (isDOMNode(value)) {
810
+ clone2[key] = value;
811
+ continue;
812
+ }
813
+ if (handleExtends && key === "extends" && isArray(value)) {
814
+ clone2[key] = unstackArrayOfObjects(value, exclude);
815
+ continue;
816
+ }
817
+ if (isFunction(value) && options.window) {
818
+ clone2[key] = contentWindow.eval("(" + value.toString() + ")");
819
+ continue;
820
+ }
821
+ if (isObjectLike(value)) {
822
+ clone2[key] = deepClone(value, {
823
+ ...options,
824
+ visited
825
+ });
826
+ } else {
827
+ clone2[key] = value;
828
+ }
829
+ }
830
+ return clone2;
831
+ };
832
+ var deepStringify = (obj, stringified = {}) => {
833
+ if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
834
+ ;
835
+ (obj.__element || obj.parent?.__element).warn(
836
+ "Trying to clone element or state at",
837
+ obj
838
+ );
839
+ obj = obj.parse?.();
840
+ }
841
+ for (const prop in obj) {
842
+ const objProp = obj[prop];
843
+ if (isFunction(objProp)) {
844
+ stringified[prop] = objProp.toString();
845
+ } else if (isObject(objProp)) {
846
+ stringified[prop] = {};
847
+ deepStringify(objProp, stringified[prop]);
848
+ } else if (isArray(objProp)) {
849
+ const arr = stringified[prop] = [];
850
+ for (let i = 0; i < objProp.length; i++) {
851
+ const v = objProp[i];
852
+ if (isObject(v)) {
853
+ arr[i] = {};
854
+ deepStringify(v, arr[i]);
855
+ } else if (isFunction(v)) {
856
+ arr[i] = v.toString();
857
+ } else {
858
+ arr[i] = v;
859
+ }
860
+ }
861
+ } else {
862
+ stringified[prop] = objProp;
863
+ }
864
+ }
865
+ return stringified;
866
+ };
867
+ var OBJ_TO_STR_SPECIAL_CHARS = /* @__PURE__ */ new Set([
868
+ "&",
869
+ "*",
870
+ "-",
871
+ ":",
872
+ "%",
873
+ "{",
874
+ "}",
875
+ ">",
876
+ "<",
877
+ "@",
878
+ ".",
879
+ "/",
880
+ "!",
881
+ " "
882
+ ]);
883
+ var objectToString = (obj = {}, indent = 0) => {
884
+ if (obj === null || typeof obj !== "object") {
885
+ return String(obj);
886
+ }
887
+ let hasKeys = false;
888
+ for (const _k in obj) {
889
+ hasKeys = true;
890
+ break;
891
+ }
892
+ if (!hasKeys) return "{}";
893
+ const spaces = " ".repeat(indent);
894
+ let str = "{\n";
895
+ for (const key in obj) {
896
+ if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
897
+ const value = obj[key];
898
+ let keyNeedsQuotes = false;
899
+ for (let i = 0; i < key.length; i++) {
900
+ if (OBJ_TO_STR_SPECIAL_CHARS.has(key[i])) {
901
+ keyNeedsQuotes = true;
902
+ break;
903
+ }
904
+ }
905
+ const stringedKey = keyNeedsQuotes ? `'${key}'` : key;
906
+ str += `${spaces} ${stringedKey}: `;
907
+ if (isArray(value)) {
908
+ str += "[\n";
909
+ for (const element of value) {
910
+ if (isObjectLike(element) && element !== null) {
911
+ str += `${spaces} ${objectToString(element, indent + 2)},
912
+ `;
913
+ } else if (isString(element)) {
914
+ str += `${spaces} '${element}',
915
+ `;
916
+ } else {
917
+ str += `${spaces} ${element},
918
+ `;
919
+ }
920
+ }
921
+ str += `${spaces} ]`;
922
+ } else if (isObjectLike(value)) {
923
+ str += objectToString(value, indent + 1);
924
+ } else if (isString(value)) {
925
+ str += stringIncludesAny(value, ["\n", "'"]) ? `\`${value}\`` : `'${value}'`;
926
+ } else {
927
+ str += value;
928
+ }
929
+ str += ",\n";
930
+ }
931
+ str += `${spaces}}`;
932
+ return str;
933
+ };
934
+ var FN_PATTERNS = [
935
+ /^\(\s*\{[^}]*\}\s*\)\s*=>/,
936
+ /^(\([^)]*\)|[^=]*)\s*=>/,
937
+ /^function[\s(]/,
938
+ /^async\s+/,
939
+ /^\(\s*function/,
940
+ /^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/
941
+ ];
942
+ var RE_JSON_LIKE = /^["[{]/;
943
+ var hasFunction = (str) => {
944
+ if (!str) return false;
945
+ const trimmed = str.trim().replace(/\n\s*/g, " ").trim();
946
+ if (trimmed === "" || trimmed === "{}" || trimmed === "[]") return false;
947
+ const isFn = FN_PATTERNS.some((pattern) => pattern.test(trimmed));
948
+ if (!isFn) return false;
949
+ const firstChar = trimmed.charCodeAt(0);
950
+ const hasArrow = trimmed.includes("=>");
951
+ if (firstChar === 123 && !hasArrow) return false;
952
+ if (firstChar === 91) return false;
953
+ if (RE_JSON_LIKE.test(trimmed) && !hasArrow) return false;
954
+ return true;
955
+ };
956
+ var deepDestringify = (obj, destringified = {}) => {
957
+ for (const prop in obj) {
958
+ if (!Object.prototype.hasOwnProperty.call(obj, prop)) continue;
959
+ const objProp = obj[prop];
960
+ if (isString(objProp)) {
961
+ if (hasFunction(objProp)) {
962
+ try {
963
+ destringified[prop] = window2.eval(`(${objProp})`);
964
+ } catch (e) {
965
+ if (e) destringified[prop] = objProp;
966
+ }
967
+ } else {
968
+ destringified[prop] = objProp;
969
+ }
970
+ } else if (isArray(objProp)) {
971
+ const arr = destringified[prop] = [];
972
+ for (let i = 0; i < objProp.length; i++) {
973
+ const arrProp = objProp[i];
974
+ if (isString(arrProp)) {
975
+ if (hasFunction(arrProp)) {
976
+ try {
977
+ arr.push(window2.eval(`(${arrProp})`));
978
+ } catch (e) {
979
+ if (e) arr.push(arrProp);
980
+ }
981
+ } else {
982
+ arr.push(arrProp);
983
+ }
984
+ } else if (isObject(arrProp)) {
985
+ arr.push(deepDestringify(arrProp));
986
+ } else {
987
+ arr.push(arrProp);
988
+ }
989
+ }
990
+ } else if (isObject(objProp)) {
991
+ destringified[prop] = deepDestringify(objProp, destringified[prop]);
992
+ } else {
993
+ destringified[prop] = objProp;
994
+ }
995
+ }
996
+ return destringified;
997
+ };
998
+ var stringToObject = (str, opts = { verbose: true }) => {
999
+ try {
1000
+ return str ? window2.eval("(" + str + ")") : {};
1001
+ } catch (e) {
1002
+ if (opts.verbose) console.warn(e);
1003
+ }
1004
+ };
1005
+ var hasOwnProperty = (o, ...args) => Object.prototype.hasOwnProperty.call(o, ...args);
1006
+ var isEmpty = (o) => {
1007
+ for (const _ in o) return false;
1008
+ return true;
1009
+ };
1010
+ var isEmptyObject = (o) => isObject(o) && isEmpty(o);
1011
+ var makeObjectWithoutPrototype = () => /* @__PURE__ */ Object.create(null);
1012
+ var overwrite = (element, params, opts = {}) => {
1013
+ const excl = opts.exclude || [];
1014
+ const allowUnderscore = opts.preventUnderscore;
1015
+ for (const e in params) {
1016
+ if (excl.includes(e) || !allowUnderscore && _startsWithDunder(e)) continue;
1017
+ if (params[e] !== void 0) {
1018
+ element[e] = params[e];
1019
+ }
1020
+ }
1021
+ return element;
1022
+ };
1023
+ var overwriteShallow = (obj, params, excludeFrom = []) => {
1024
+ const useSet = excludeFrom instanceof Set;
1025
+ for (const e in params) {
1026
+ if (_startsWithDunder(e)) continue;
1027
+ if (useSet ? excludeFrom.has(e) : excludeFrom.includes(e)) continue;
1028
+ obj[e] = params[e];
1029
+ }
1030
+ return obj;
1031
+ };
1032
+ var overwriteDeep = (obj, params, opts = {}, visited = /* @__PURE__ */ new WeakMap()) => {
1033
+ if (!isObjectLike(obj) || !isObjectLike(params) || isDOMNode(obj) || isDOMNode(params)) {
1034
+ return params;
1035
+ }
1036
+ if (visited.has(obj)) return visited.get(obj);
1037
+ visited.set(obj, obj);
1038
+ const excl = opts.exclude;
1039
+ const exclSet = excl ? excl instanceof Set ? excl : new Set(excl) : null;
1040
+ const forcedExclude = !opts.preventForce;
1041
+ for (const e in params) {
1042
+ if (!Object.prototype.hasOwnProperty.call(params, e)) continue;
1043
+ if (exclSet && exclSet.has(e) || forcedExclude && _startsWithDunder(e)) continue;
1044
+ const objProp = obj[e];
1045
+ const paramsProp = params[e];
1046
+ if (isDOMNode(paramsProp)) {
1047
+ obj[e] = paramsProp;
1048
+ } else if (isObjectLike(objProp) && isObjectLike(paramsProp)) {
1049
+ obj[e] = overwriteDeep(objProp, paramsProp, opts, visited);
1050
+ } else if (paramsProp !== void 0) {
1051
+ obj[e] = paramsProp;
1052
+ }
1053
+ }
1054
+ return obj;
1055
+ };
1056
+ var isEqualDeep = (param, element, visited = /* @__PURE__ */ new Set()) => {
1057
+ if (typeof param !== "object" || typeof element !== "object" || param === null || element === null) {
1058
+ return param === element;
1059
+ }
1060
+ if (visited.has(param) || visited.has(element)) {
1061
+ return true;
1062
+ }
1063
+ visited.add(param);
1064
+ visited.add(element);
1065
+ const keysParam = Object.keys(param);
1066
+ const keysElement = Object.keys(element);
1067
+ if (keysParam.length !== keysElement.length) {
1068
+ return false;
1069
+ }
1070
+ for (let i = 0; i < keysParam.length; i++) {
1071
+ const key = keysParam[i];
1072
+ if (!Object.prototype.hasOwnProperty.call(element, key)) {
1073
+ return false;
1074
+ }
1075
+ if (!isEqualDeep(param[key], element[key], visited)) {
1076
+ return false;
1077
+ }
1078
+ }
1079
+ return true;
1080
+ };
1081
+ var DEEP_CONTAINS_IGNORED = /* @__PURE__ */ new Set(["node", "__ref"]);
1082
+ var deepContains = (obj1, obj2, ignoredKeys = DEEP_CONTAINS_IGNORED) => {
1083
+ if (obj1 === obj2) return true;
1084
+ if (!isObjectLike(obj1) || !isObjectLike(obj2)) return obj1 === obj2;
1085
+ if (isDOMNode(obj1) || isDOMNode(obj2)) return obj1 === obj2;
1086
+ const ignored = ignoredKeys instanceof Set ? ignoredKeys : new Set(ignoredKeys);
1087
+ const visited = /* @__PURE__ */ new WeakSet();
1088
+ function checkContains(target, source) {
1089
+ if (visited.has(source)) return true;
1090
+ visited.add(source);
1091
+ for (const key in source) {
1092
+ if (!Object.prototype.hasOwnProperty.call(source, key)) continue;
1093
+ if (ignored.has(key)) continue;
1094
+ if (!Object.prototype.hasOwnProperty.call(target, key)) return false;
1095
+ const sourceValue = source[key];
1096
+ const targetValue = target[key];
1097
+ if (isDOMNode(sourceValue) || isDOMNode(targetValue)) {
1098
+ if (sourceValue !== targetValue) return false;
1099
+ } else if (isObjectLike(sourceValue) && isObjectLike(targetValue)) {
1100
+ if (!checkContains(targetValue, sourceValue)) return false;
1101
+ } else if (sourceValue !== targetValue) {
1102
+ return false;
1103
+ }
1104
+ }
1105
+ return true;
1106
+ }
1107
+ return checkContains(obj1, obj2);
1108
+ };
1109
+ var removeFromObject = (obj, props) => {
1110
+ if (props === void 0 || props === null) return obj;
1111
+ if (is(props)("string", "number")) {
1112
+ delete obj[props];
1113
+ } else if (isArray(props)) {
1114
+ for (let i = 0; i < props.length; i++) delete obj[props[i]];
1115
+ } else {
1116
+ throw new Error(
1117
+ "Invalid input: props must be a string or an array of strings"
1118
+ );
1119
+ }
1120
+ return obj;
1121
+ };
1122
+ var createObjectWithoutPrototype = (obj) => {
1123
+ if (obj === null || typeof obj !== "object") {
1124
+ return obj;
1125
+ }
1126
+ const newObj = /* @__PURE__ */ Object.create(null);
1127
+ for (const key in obj) {
1128
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
1129
+ newObj[key] = createObjectWithoutPrototype(obj[key]);
1130
+ }
1131
+ }
1132
+ return newObj;
1133
+ };
1134
+ var createNestedObject = (arr, lastValue) => {
1135
+ if (arr.length === 0) return lastValue;
1136
+ const nestedObject = {};
1137
+ let current = nestedObject;
1138
+ for (let i = 0; i < arr.length; i++) {
1139
+ if (i === arr.length - 1 && lastValue) {
1140
+ current[arr[i]] = lastValue;
1141
+ } else {
1142
+ current[arr[i]] = {};
1143
+ current = current[arr[i]];
1144
+ }
1145
+ }
1146
+ return nestedObject;
1147
+ };
1148
+ var removeNestedKeyByPath = (obj, path) => {
1149
+ if (!Array.isArray(path)) {
1150
+ throw new Error("Path must be an array.");
1151
+ }
1152
+ let current = obj;
1153
+ for (let i = 0; i < path.length - 1; i++) {
1154
+ if (current[path[i]] === void 0) return;
1155
+ current = current[path[i]];
1156
+ }
1157
+ const lastKey = path[path.length - 1];
1158
+ if (current && Object.prototype.hasOwnProperty.call(current, lastKey)) {
1159
+ delete current[lastKey];
1160
+ }
1161
+ };
1162
+ var setInObjectByPath = (obj, path, value) => {
1163
+ if (!Array.isArray(path)) {
1164
+ throw new Error("Path must be an array.");
1165
+ }
1166
+ let current = obj;
1167
+ for (let i = 0; i < path.length - 1; i++) {
1168
+ if (!current[path[i]] || typeof current[path[i]] !== "object") {
1169
+ current[path[i]] = {};
1170
+ }
1171
+ current = current[path[i]];
1172
+ }
1173
+ current[path[path.length - 1]] = value;
1174
+ return obj;
1175
+ };
1176
+ var getInObjectByPath = (obj, path) => {
1177
+ if (!Array.isArray(path)) {
1178
+ throw new Error("Path must be an array.");
1179
+ }
1180
+ let current = obj;
1181
+ for (let i = 0; i < path.length; i++) {
1182
+ if (current === void 0 || current === null) {
1183
+ return void 0;
1184
+ }
1185
+ current = current[path[i]];
1186
+ }
1187
+ return current;
1188
+ };
1189
+ var detectInfiniteLoop = (arr) => {
1190
+ const maxRepeats = 10;
1191
+ let pattern = [];
1192
+ let repeatCount = 0;
1193
+ for (let i = 0; i < arr.length; i++) {
1194
+ if (pattern.length < 2) {
1195
+ pattern.push(arr[i]);
1196
+ } else {
1197
+ if (arr[i] === pattern[i % 2]) {
1198
+ repeatCount++;
1199
+ } else {
1200
+ pattern = [arr[i - 1], arr[i]];
1201
+ repeatCount = 1;
1202
+ }
1203
+ if (repeatCount >= maxRepeats * 2) {
1204
+ if (ENV === "test" || ENV === "development") {
1205
+ console.warn(
1206
+ "Warning: Potential infinite loop detected due to repeated sequence:",
1207
+ pattern
1208
+ );
1209
+ }
1210
+ return true;
1211
+ }
1212
+ }
1213
+ }
1214
+ };
1215
+ var isCyclic = (obj) => {
1216
+ const seen = /* @__PURE__ */ new WeakSet();
1217
+ function detect(obj2) {
1218
+ if (obj2 && typeof obj2 === "object") {
1219
+ if (seen.has(obj2)) return true;
1220
+ seen.add(obj2);
1221
+ for (const key in obj2) {
1222
+ if (Object.prototype.hasOwnProperty.call(obj2, key) && detect(obj2[key])) {
1223
+ console.log(obj2, "cycle at " + key);
1224
+ return true;
1225
+ }
1226
+ }
1227
+ }
1228
+ return false;
1229
+ }
1230
+ return detect(obj);
1231
+ };
1232
+ var excludeKeysFromObject = (obj, excludedKeys) => {
1233
+ const excluded = excludedKeys instanceof Set ? excludedKeys : new Set(excludedKeys);
1234
+ const result = {};
1235
+ for (const key in obj) {
1236
+ if (Object.prototype.hasOwnProperty.call(obj, key) && !excluded.has(key)) {
1237
+ result[key] = obj[key];
1238
+ }
1239
+ }
1240
+ return result;
1241
+ };
1242
+
1243
+ // key.js
1244
+ var generateKey = /* @__PURE__ */ (function() {
1245
+ let index = 0;
1246
+ function newId() {
1247
+ index++;
1248
+ return index;
1249
+ }
1250
+ return newId;
1251
+ })();
1252
+ var createSnapshotId = generateKey;
1253
+ var createKey = (element, parent, key) => {
1254
+ return (exec(key, element) || key || element.key || generateKey()).toString();
1255
+ };
1256
+
1257
+ // env.js
1258
+ var NODE_ENV = process.env.NODE_ENV;
1259
+ var ENV2 = NODE_ENV;
1260
+ var isProduction = (env = NODE_ENV) => env === "production";
1261
+ var isTest = (env = NODE_ENV) => env === "testing" || env === "test";
1262
+ var isTesting = isTest;
1263
+ var isStaging = (env = NODE_ENV) => env === "staging";
1264
+ var isLocal = (env = NODE_ENV) => env === "local";
1265
+ var isDevelopment = (env = NODE_ENV) => env === "development" || env === "dev" || env === "local";
1266
+ var getNev = (key, env = NODE_ENV) => env[key];
1267
+ var isNotProduction = (env = NODE_ENV) => !isProduction(env);
1268
+
1269
+ // function.js
1270
+ function debounce(func, wait, immediate) {
1271
+ let timeout;
1272
+ return function() {
1273
+ const context = this;
1274
+ const args = arguments;
1275
+ const later = function() {
1276
+ timeout = null;
1277
+ if (!immediate) func.apply(context, args);
1278
+ };
1279
+ const callNow = immediate && !timeout;
1280
+ clearTimeout(timeout);
1281
+ timeout = setTimeout(later, wait);
1282
+ if (callNow) func.apply(context, args);
1283
+ };
1284
+ }
1285
+ var debounceOnContext = (element, func, timeout = 300) => {
1286
+ let timer;
1287
+ return (...args) => {
1288
+ clearTimeout(timer);
1289
+ timer = setTimeout(() => {
1290
+ func.apply(element, args);
1291
+ }, timeout);
1292
+ };
1293
+ };
1294
+ var memoize = (fn) => {
1295
+ const cache2 = {};
1296
+ return (...args) => {
1297
+ const n = args[0];
1298
+ if (n in cache2) {
1299
+ return cache2[n];
1300
+ } else {
1301
+ const result = fn(n);
1302
+ cache2[n] = result;
1303
+ return result;
1304
+ }
1305
+ };
1306
+ };
1307
+ var RE_STRING_FUNCTION = /^((function\s*\([^)]*\)\s*\{[^}]*\})|(\([^)]*\)\s*=>))/;
1308
+ var isStringFunction = (inputString) => {
1309
+ return RE_STRING_FUNCTION.test(inputString);
1310
+ };
1311
+ function cloneFunction(fn, win = window) {
1312
+ const temp = function() {
1313
+ return fn.apply(win, arguments);
1314
+ };
1315
+ for (const key in fn) {
1316
+ if (Object.prototype.hasOwnProperty.call(fn, key)) {
1317
+ temp[key] = fn[key];
1318
+ }
1319
+ }
1320
+ return temp;
1321
+ }
1322
+
1323
+ // if.js
1324
+ var createIfConditionFlag = (element, parent) => {
1325
+ const { __ref: ref } = element;
1326
+ if (isFunction(element.if) && !element.if(element, element.state, element.context)) {
1327
+ delete ref.__if;
1328
+ } else ref.__if = true;
1329
+ };
1330
+
1331
+ // log.js
1332
+ var logIf = (bool, ...arg) => {
1333
+ if (bool) arg.map((v) => console.log(v));
1334
+ };
1335
+ var logGroupIf = (bool, key, ...arg) => {
1336
+ if (bool) {
1337
+ console.group(key);
1338
+ arg.map((v) => console.log(v));
1339
+ console.groupEnd(key);
1340
+ }
1341
+ };
1342
+
1343
+ // cookie.js
1344
+ var isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
1345
+ var setCookie = (cname, cvalue, exdays = 365) => {
1346
+ if (isUndefined(document2) || isUndefined(document2.cookie)) return;
1347
+ const d = /* @__PURE__ */ new Date();
1348
+ d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1e3);
1349
+ const expires = `expires=${d.toUTCString()}`;
1350
+ document2.cookie = `${cname}=${cvalue};${expires};path=/`;
1351
+ };
1352
+ var getCookie = (cname) => {
1353
+ if (isUndefined(document2) || isUndefined(document2.cookie)) return;
1354
+ const name = `${cname}=`;
1355
+ const decodedCookie = decodeURIComponent(document2.cookie);
1356
+ const ca = decodedCookie.split(";");
1357
+ for (let i = 0; i < ca.length; i++) {
1358
+ let c = ca[i];
1359
+ while (c.charAt(0) === " ") c = c.substring(1);
1360
+ if (c.indexOf(name) === 0) return c.substring(name.length, c.length);
1361
+ }
1362
+ return "";
1363
+ };
1364
+ var removeCookie = (cname) => {
1365
+ if (isUndefined(document2) || isUndefined(document2.cookie)) return;
1366
+ document2.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
1367
+ };
1368
+ function getLocalStorage(key) {
1369
+ if (!window.localStorage) {
1370
+ return void 0;
1371
+ }
1372
+ const item = window.localStorage.getItem(key);
1373
+ if (item === null) {
1374
+ return void 0;
1375
+ }
1376
+ try {
1377
+ return JSON.parse(item);
1378
+ } catch (e) {
1379
+ return void 0;
1380
+ }
1381
+ }
1382
+ function setLocalStorage(key, data) {
1383
+ if (!window.localStorage || data === void 0 || data === null) {
1384
+ return;
1385
+ }
1386
+ const value = typeof data === "object" ? JSON.stringify(data) : data;
1387
+ window.localStorage.setItem(key, value);
1388
+ }
1389
+
1390
+ // tags.js
1391
+ var HTML_TAGS = {
1392
+ root: ["body", "html"],
1393
+ head: ["title", "base", "meta", "style", "noscript", "script"],
1394
+ body: /* @__PURE__ */ new Set([
1395
+ "string",
1396
+ "style",
1397
+ "fragment",
1398
+ "a",
1399
+ "abbr",
1400
+ "acronym",
1401
+ "address",
1402
+ "applet",
1403
+ "area",
1404
+ "article",
1405
+ "aside",
1406
+ "audio",
1407
+ "b",
1408
+ "basefont",
1409
+ "bdi",
1410
+ "bdo",
1411
+ "big",
1412
+ "blockquote",
1413
+ "br",
1414
+ "button",
1415
+ "canvas",
1416
+ "caption",
1417
+ "center",
1418
+ "cite",
1419
+ "code",
1420
+ "search",
1421
+ "col",
1422
+ "colgroup",
1423
+ "data",
1424
+ "datalist",
1425
+ "dd",
1426
+ "del",
1427
+ "details",
1428
+ "dfn",
1429
+ "dialog",
1430
+ "dir",
1431
+ "div",
1432
+ "dl",
1433
+ "dt",
1434
+ "em",
1435
+ "embed",
1436
+ "fieldset",
1437
+ "figcaption",
1438
+ "figure",
1439
+ "font",
1440
+ "footer",
1441
+ "form",
1442
+ "frame",
1443
+ "frameset",
1444
+ "h1",
1445
+ "h2",
1446
+ "h3",
1447
+ "h4",
1448
+ "h5",
1449
+ "h6",
1450
+ "head",
1451
+ "header",
1452
+ "hr",
1453
+ "i",
1454
+ "iframe",
1455
+ "img",
1456
+ "input",
1457
+ "ins",
1458
+ "kbd",
1459
+ "label",
1460
+ "legend",
1461
+ "li",
1462
+ "link",
1463
+ "main",
1464
+ "map",
1465
+ "mark",
1466
+ "meter",
1467
+ "nav",
1468
+ "noframes",
1469
+ "noscript",
1470
+ "object",
1471
+ "ol",
1472
+ "optgroup",
1473
+ "option",
1474
+ "output",
1475
+ "p",
1476
+ "param",
1477
+ "picture",
1478
+ "pre",
1479
+ "progress",
1480
+ "hgroup",
1481
+ "q",
1482
+ "rp",
1483
+ "rt",
1484
+ "ruby",
1485
+ "s",
1486
+ "samp",
1487
+ "script",
1488
+ "section",
1489
+ "select",
1490
+ "small",
1491
+ "source",
1492
+ "span",
1493
+ "strike",
1494
+ "strong",
1495
+ "sub",
1496
+ "summary",
1497
+ "sup",
1498
+ "table",
1499
+ "tbody",
1500
+ "td",
1501
+ "template",
1502
+ "hgroup",
1503
+ "textarea",
1504
+ "tfoot",
1505
+ "th",
1506
+ "thead",
1507
+ "time",
1508
+ "tr",
1509
+ "track",
1510
+ "tt",
1511
+ "u",
1512
+ "ul",
1513
+ "var",
1514
+ "video",
1515
+ "wbr",
1516
+ // SVG
1517
+ "svg",
1518
+ "path",
1519
+ "circle",
1520
+ "ellipse",
1521
+ "line",
1522
+ "polygon",
1523
+ "polyline",
1524
+ "rect",
1525
+ "g",
1526
+ "defs",
1527
+ "symbol",
1528
+ "use",
1529
+ "text",
1530
+ "tspan",
1531
+ "image",
1532
+ "clipPath",
1533
+ "mask",
1534
+ "pattern",
1535
+ "marker",
1536
+ "linearGradient",
1537
+ "radialGradient",
1538
+ "stop",
1539
+ "filter",
1540
+ "feGaussianBlur",
1541
+ "feOffset",
1542
+ "feMerge",
1543
+ "feMergeNode",
1544
+ "feBlend",
1545
+ "feColorMatrix",
1546
+ "feFlood",
1547
+ "feComposite",
1548
+ "foreignObject"
1549
+ ])
1550
+ };
1551
+ var SVG_TAGS = /* @__PURE__ */ new Set([
1552
+ "svg",
1553
+ "path",
1554
+ "circle",
1555
+ "ellipse",
1556
+ "line",
1557
+ "polygon",
1558
+ "polyline",
1559
+ "rect",
1560
+ "g",
1561
+ "defs",
1562
+ "symbol",
1563
+ "use",
1564
+ "text",
1565
+ "tspan",
1566
+ "image",
1567
+ "clipPath",
1568
+ "mask",
1569
+ "pattern",
1570
+ "marker",
1571
+ "linearGradient",
1572
+ "radialGradient",
1573
+ "stop",
1574
+ "filter",
1575
+ "feGaussianBlur",
1576
+ "feOffset",
1577
+ "feMerge",
1578
+ "feMergeNode",
1579
+ "feBlend",
1580
+ "feColorMatrix",
1581
+ "feFlood",
1582
+ "feComposite",
1583
+ "foreignObject"
1584
+ ]);
1585
+ var isValidHtmlTag = (arg) => HTML_TAGS.body.has(arg);
1586
+
1587
+ // extends.js
1588
+ var ENV3 = process.env.NODE_ENV;
1589
+ var createExtendsFromKeys = (key) => {
1590
+ if (key.includes("+")) {
1591
+ return key.split("+").filter(matchesComponentNaming);
1592
+ }
1593
+ if (key.includes("_")) {
1594
+ const [first] = key.split("_");
1595
+ return [first];
1596
+ }
1597
+ if (key.includes(".") && !matchesComponentNaming(key.split(".")[1])) {
1598
+ const [first] = key.split(".");
1599
+ return [first];
1600
+ }
1601
+ return [key];
1602
+ };
1603
+ var createExtends = (element, parent, key) => {
1604
+ let __extends = [];
1605
+ const keyExtends = createExtendsFromKeys(key);
1606
+ if (keyExtends) __extends = [...keyExtends];
1607
+ const elementExtends = element.extends;
1608
+ if (elementExtends) {
1609
+ __extends = isArray(elementExtends) ? [...__extends, ...elementExtends] : [...__extends, elementExtends];
1610
+ }
1611
+ return __extends;
1612
+ };
1613
+ var addExtends = (newExtends, element) => {
1614
+ const { __ref: ref } = element;
1615
+ let { __extends } = ref;
1616
+ if (!newExtends) return __extends;
1617
+ const variant = element.props?.variant;
1618
+ const context = element.context;
1619
+ if (variant && context?.components && !Array.isArray(newExtends) && typeof newExtends === "string") {
1620
+ const variantKey = `${newExtends}.${variant}`;
1621
+ if (context.components[variantKey]) {
1622
+ newExtends = variantKey;
1623
+ }
1624
+ }
1625
+ if (!__extends.includes(newExtends)) {
1626
+ __extends = Array.isArray(newExtends) ? [...__extends, ...newExtends] : [...__extends, newExtends];
1627
+ ref.__extends = __extends;
1628
+ }
1629
+ return __extends;
1630
+ };
1631
+ var concatAddExtends = (newExtend, element) => {
1632
+ if (!newExtend) return element;
1633
+ const { extends: elementExtend } = element;
1634
+ const originalArray = isArray(elementExtend) ? elementExtend : [elementExtend];
1635
+ const receivedArray = isArray(newExtend) ? newExtend : [newExtend];
1636
+ return {
1637
+ ...element,
1638
+ extends: joinArrays(receivedArray, originalArray)
1639
+ };
1640
+ };
1641
+ var generateHash = () => Math.random().toString(36).substring(2);
1642
+ var extendStackRegistry = {};
1643
+ var extendCachedRegistry = {};
1644
+ var getHashedExtend = (extend) => {
1645
+ return extendStackRegistry[extend.__hash];
1646
+ };
1647
+ var setHashedExtend = (extend, stack) => {
1648
+ const hash = generateHash();
1649
+ if (!isString(extend)) {
1650
+ extend.__hash = hash;
1651
+ }
1652
+ if (hash !== "__proto__" && hash !== "constructor" && hash !== "prototype") {
1653
+ extendStackRegistry[hash] = stack;
1654
+ }
1655
+ return stack;
1656
+ };
1657
+ var getExtendsStackRegistry = (extend, stack) => {
1658
+ if (extend.__hash) {
1659
+ return stack.concat(getHashedExtend(extend));
1660
+ }
1661
+ return setHashedExtend(extend, stack);
1662
+ };
1663
+ var extractArrayExtend = (extend, stack, context, processed = /* @__PURE__ */ new Set()) => {
1664
+ for (const each of extend) {
1665
+ if (isArray(each)) {
1666
+ extractArrayExtend(each, stack, context, processed);
1667
+ } else {
1668
+ flattenExtend(each, stack, context, processed);
1669
+ }
1670
+ }
1671
+ return stack;
1672
+ };
1673
+ var deepExtend = (extend, stack, context, processed = /* @__PURE__ */ new Set()) => {
1674
+ const extendOflattenExtend = extend.extends || extend.extend;
1675
+ const cleanExtend = { ...extend };
1676
+ delete cleanExtend.extends;
1677
+ delete cleanExtend.extend;
1678
+ let hasKeys = false;
1679
+ for (const _k in cleanExtend) {
1680
+ hasKeys = true;
1681
+ break;
1682
+ }
1683
+ if (hasKeys) {
1684
+ stack.push(cleanExtend);
1685
+ }
1686
+ if (extendOflattenExtend) {
1687
+ flattenExtend(extendOflattenExtend, stack, context, processed);
1688
+ }
1689
+ return stack;
1690
+ };
1691
+ var flattenExtend = (extend, stack, context, processed = /* @__PURE__ */ new Set()) => {
1692
+ if (!extend) return stack;
1693
+ if (processed.has(extend)) return stack;
1694
+ if (isArray(extend)) {
1695
+ return extractArrayExtend(extend, stack, context, processed);
1696
+ }
1697
+ if (isString(extend)) {
1698
+ extend = mapStringsWithContextComponents(extend, context);
1699
+ }
1700
+ processed.add(extend);
1701
+ if (extend?.extends || extend?.extend) {
1702
+ deepExtend(extend, stack, context, processed);
1703
+ } else if (extend) {
1704
+ stack.push(extend);
1705
+ }
1706
+ return stack;
1707
+ };
1708
+ var MERGE_EXTENDS_SKIP = /* @__PURE__ */ new Set([
1709
+ "parent",
1710
+ "node",
1711
+ "__ref",
1712
+ "__proto__",
1713
+ "extend",
1714
+ "childExtend",
1715
+ "childExtendRecursive"
1716
+ ]);
1717
+ var deepMergeExtends = (element, extend) => {
1718
+ extend = deepClone(extend);
1719
+ for (const e in extend) {
1720
+ if (MERGE_EXTENDS_SKIP.has(e)) continue;
1721
+ const elementProp = element[e];
1722
+ const extendProp = extend[e];
1723
+ if (extendProp === void 0) continue;
1724
+ if (Object.prototype.hasOwnProperty.call(extend, e) && e !== "__proto__" && e !== "constructor" && e !== "prototype") {
1725
+ if (elementProp === void 0) {
1726
+ element[e] = extendProp;
1727
+ } else if (isObject(elementProp) && isObject(extendProp)) {
1728
+ if (matchesComponentNaming(e)) {
1729
+ element[e] = deepMergeExtends(elementProp, extendProp);
1730
+ } else {
1731
+ deepMergeExtends(elementProp, extendProp);
1732
+ }
1733
+ }
1734
+ if (e === "extends" || e === "childExtends" || e === "childExtendsRecursive") {
1735
+ if (isArray(elementProp) && isArray(extendProp)) {
1736
+ element[e] = elementProp.concat(extendProp);
1737
+ } else if (isArray(elementProp) && isObject(extendProp)) {
1738
+ const obj = deepMergeExtends({}, elementProp);
1739
+ element[e] = deepMergeExtends(obj, extendProp);
1740
+ }
1741
+ }
1742
+ }
1743
+ }
1744
+ return element;
1745
+ };
1746
+ var cloneAndMergeArrayExtend = (stack) => {
1747
+ return stack.reduce((acc, current) => {
1748
+ const cloned = deepClone(current);
1749
+ return deepMergeExtends(acc, cloned);
1750
+ }, {});
1751
+ };
1752
+ var mapStringsWithContextComponents = (extend, context, options = {}, variant) => {
1753
+ const COMPONENTS = context?.components || options.components;
1754
+ const PAGES = context?.pages || options.pages;
1755
+ if (isString(extend)) {
1756
+ const componentExists = COMPONENTS && (COMPONENTS[extend + "." + variant] || COMPONENTS[extend] || COMPONENTS["smbls." + extend]);
1757
+ const pageExists = PAGES && extend.charCodeAt(0) === 47 && PAGES[extend];
1758
+ if (componentExists) return componentExists;
1759
+ else if (pageExists) return pageExists;
1760
+ else {
1761
+ if (options.verbose && (ENV3 === "test" || ENV3 === "development")) {
1762
+ console.warn("Extend is string but component was not found:", extend);
1763
+ }
1764
+ return;
1765
+ }
1766
+ }
1767
+ return extend;
1768
+ };
1769
+ var jointStacks = (extendStack, childExtendsStack) => {
1770
+ return [].concat(extendStack.slice(0, 1)).concat(childExtendsStack.slice(0, 1)).concat(extendStack.slice(1)).concat(childExtendsStack.slice(1));
1771
+ };
1772
+ var getExtendsStack = (extend, context) => {
1773
+ if (!extend) return [];
1774
+ if (extend.__hash) return getHashedExtend(extend) || [];
1775
+ const processed = /* @__PURE__ */ new Set();
1776
+ const stack = flattenExtend(extend, [], context, processed);
1777
+ return getExtendsStackRegistry(extend, stack);
1778
+ };
1779
+ var addExtend = (newExtends, elementExtends) => {
1780
+ if (!newExtends) return elementExtends;
1781
+ const receivedArray = isArray(newExtends) ? newExtends : [newExtends];
1782
+ return joinArrays(receivedArray, elementExtends);
1783
+ };
1784
+ var getExtendsInElement = (obj) => {
1785
+ let result = [];
1786
+ function traverse(o) {
1787
+ for (const key in o) {
1788
+ if (Object.prototype.hasOwnProperty.call(o, key)) {
1789
+ if (matchesComponentNaming(key)) {
1790
+ result.push(key);
1791
+ }
1792
+ if (key === "extends") {
1793
+ if (typeof o[key] === "string") {
1794
+ result.push(o[key]);
1795
+ } else if (Array.isArray(o[key])) {
1796
+ result = result.concat(o[key]);
1797
+ }
1798
+ }
1799
+ if (typeof o[key] === "object" && o[key] !== null) {
1800
+ traverse(o[key]);
1801
+ }
1802
+ }
1803
+ }
1804
+ }
1805
+ traverse(obj);
1806
+ return result;
1807
+ };
1808
+ var createElementExtends = (element, parent, options = {}) => {
1809
+ const { __ref: ref } = element;
1810
+ const context = element.context || parent.context;
1811
+ const variant = element.props?.variant;
1812
+ if (element.extend && !element.extends) element.extends = element.extend;
1813
+ delete element.extend;
1814
+ if (!element.extends && element.props?.extends) element.extends = element.props.extends;
1815
+ if (element.extends) {
1816
+ if (Array.isArray(element.extends) && element.extends.length > 0) {
1817
+ const [firstExtend, ...restExtends] = element.extends;
1818
+ if (typeof firstExtend === "string" && variant && context?.components) {
1819
+ const variantKey = `${firstExtend}.${variant}`;
1820
+ if (context.components[variantKey]) {
1821
+ addExtends([variantKey, ...restExtends], element);
1822
+ } else {
1823
+ addExtends(element.extends, element);
1824
+ }
1825
+ } else {
1826
+ addExtends(element.extends, element);
1827
+ }
1828
+ } else if (typeof element.extends === "string" && variant && context?.components) {
1829
+ const variantKey = `${element.extends}.${variant}`;
1830
+ if (context.components[variantKey]) {
1831
+ addExtends(variantKey, element);
1832
+ } else {
1833
+ addExtends(element.extends, element);
1834
+ }
1835
+ } else {
1836
+ addExtends(element.extends, element);
1837
+ }
1838
+ }
1839
+ inheritChildPropsExtends(element, parent, options);
1840
+ inheritChildExtends(element, parent, options);
1841
+ inheritRecursiveChildExtends(element, parent, options);
1842
+ if (element.component) {
1843
+ addExtends(exec(element.component, element), element);
1844
+ }
1845
+ if (context.defaultExtends) {
1846
+ addExtends(context.defaultExtends, element);
1847
+ }
1848
+ return removeDuplicatesInArray(ref.__extends);
1849
+ };
1850
+ var inheritChildPropsExtends = (element, parent, options = {}) => {
1851
+ const { props, __ref: ref } = element;
1852
+ const ignoreChildExtends = options.ignoreChildExtends || props?.ignoreChildExtends;
1853
+ if (!ignoreChildExtends) {
1854
+ if (parent.props?.childProps?.extends) {
1855
+ addExtends(parent.props?.childProps.extends, element);
1856
+ }
1857
+ }
1858
+ return ref.__extends;
1859
+ };
1860
+ var inheritChildExtends = (element, parent, options = {}) => {
1861
+ const { props, __ref: ref } = element;
1862
+ const ignoreChildExtends = options.ignoreChildExtends || props?.ignoreChildExtends;
1863
+ const childExtends = parent.childExtends || parent.childExtend;
1864
+ if (!ignoreChildExtends && childExtends) {
1865
+ addExtends(childExtends, element);
1866
+ }
1867
+ return ref.__extends;
1868
+ };
1869
+ var inheritRecursiveChildExtends = (element, parent, options = {}) => {
1870
+ const { props, __ref: ref } = element;
1871
+ const childExtendsRecursive = parent.childExtendsRecursive || parent.childExtendRecursive;
1872
+ const ignoreChildExtendsRecursive = options.ignoreChildExtendsRecursive || props?.ignoreChildExtendsRecursive;
1873
+ const isText = element.key === "__text";
1874
+ if (childExtendsRecursive && !isText && !ignoreChildExtendsRecursive) {
1875
+ addExtends(childExtendsRecursive, element);
1876
+ }
1877
+ return ref.__extends;
1878
+ };
1879
+ var createExtendsStack = (element, parent, options = {}) => {
1880
+ const { props, __ref: ref } = element;
1881
+ const context = element.context || parent.context;
1882
+ const variant = element.variant || props?.variant;
1883
+ const __extends = removeDuplicatesInArray(
1884
+ ref.__extends.map((val, i) => {
1885
+ return mapStringsWithContextComponents(
1886
+ val,
1887
+ context,
1888
+ options,
1889
+ i === 0 && variant
1890
+ );
1891
+ })
1892
+ );
1893
+ const stack = getExtendsStack(__extends, context);
1894
+ ref.__extendsStack = stack;
1895
+ return ref.__extendsStack;
1896
+ };
1897
+ var finalizeExtends = (element, parent, options = {}) => {
1898
+ const { __ref: ref } = element;
1899
+ const { __extendsStack } = ref;
1900
+ const flattenExtends = cloneAndMergeArrayExtend(__extendsStack);
1901
+ return deepMergeExtends(element, flattenExtends);
1902
+ };
1903
+ var applyExtends = (element, parent, options = {}) => {
1904
+ createElementExtends(element, parent, options);
1905
+ createExtendsStack(element, parent, options);
1906
+ finalizeExtends(element, parent, options);
1907
+ return element;
1908
+ };
1909
+
1910
+ // component.js
1911
+ var matchesComponentNaming = (key) => {
1912
+ if (!isString(key) || !key.length) return false;
1913
+ const code = key.charCodeAt(0);
1914
+ return code >= 65 && code <= 90;
1915
+ };
1916
+ function getCapitalCaseKeys(obj) {
1917
+ return Object.keys(obj).filter((key) => /^[A-Z]/.test(key));
1918
+ }
1919
+ function getSpreadChildren(obj) {
1920
+ return Object.keys(obj).filter((key) => /^\d+$/.test(key));
1921
+ }
1922
+ function isContextComponent(element, parent, passedKey) {
1923
+ const { context } = parent || {};
1924
+ const [extendsKey] = createExtendsFromKeys(passedKey);
1925
+ const key = passedKey || extendsKey;
1926
+ return context?.components?.[key] || context?.pages?.[key];
1927
+ }
1928
+
1929
+ // events.js
1930
+ function addEventFromProps(key, obj) {
1931
+ const { props, on } = obj;
1932
+ const eventName = lowercaseFirstLetter(key.split("on")[1]);
1933
+ const origEvent = on[eventName];
1934
+ const funcFromProps = props[key];
1935
+ if (isFunction(origEvent)) {
1936
+ on[eventName] = (...args) => {
1937
+ const originalEventRetunrs = origEvent(...args);
1938
+ if (originalEventRetunrs !== false) funcFromProps(...args);
1939
+ };
1940
+ } else on[eventName] = funcFromProps;
1941
+ }
1942
+
1943
+ // props.js
1944
+ var RE_UPPER = /^[A-Z]/;
1945
+ var RE_DIGITS = /^\d+$/;
1946
+ var createProps = (element, parent, key) => {
1947
+ const { props, __ref: ref } = element;
1948
+ ref.__propsStack = [];
1949
+ if (props) ref.__initialProps = props;
1950
+ else return {};
1951
+ if (!isObjectLike(props)) {
1952
+ ref.__propsStack.push(props);
1953
+ return {};
1954
+ }
1955
+ return { ...props };
1956
+ };
1957
+ function pickupPropsFromElement(obj, opts = {}) {
1958
+ const cachedKeys = opts.cachedKeys || [];
1959
+ for (const key in obj) {
1960
+ const value = obj[key];
1961
+ const isEventHandler = key.length > 2 && key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && key[2] === key[2].toUpperCase() && isFunction(value);
1962
+ if (isEventHandler) {
1963
+ const eventName = lowercaseFirstLetter(key.slice(2));
1964
+ if (obj.on) obj.on[eventName] = value;
1965
+ delete obj[key];
1966
+ continue;
1967
+ }
1968
+ const hasDefine = isObject(this.define?.[key]);
1969
+ const hasGlobalDefine = isObject(this.context?.define?.[key]);
1970
+ const isElement = RE_UPPER.test(key) || RE_DIGITS.test(key);
1971
+ const isBuiltin = DOMQ_PROPERTIES.has(key);
1972
+ if (!isElement && !isBuiltin && !hasDefine && !hasGlobalDefine) {
1973
+ obj.props[key] = value;
1974
+ delete obj[key];
1975
+ cachedKeys.push(key);
1976
+ }
1977
+ }
1978
+ return obj;
1979
+ }
1980
+ function pickupElementFromProps(obj = this, opts) {
1981
+ const cachedKeys = opts.cachedKeys || [];
1982
+ for (const key in obj.props) {
1983
+ const value = obj.props[key];
1984
+ const isEvent = key.length > 2 && key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110;
1985
+ const isFn = isFunction(value);
1986
+ if (isEvent && isFn) {
1987
+ addEventFromProps(key, obj);
1988
+ delete obj.props[key];
1989
+ continue;
1990
+ }
1991
+ if (cachedKeys.includes(key)) continue;
1992
+ const hasDefine = isObject(this.define?.[key]);
1993
+ const hasGlobalDefine = isObject(this.context?.define?.[key]);
1994
+ const isElement = RE_UPPER.test(key) || RE_DIGITS.test(key);
1995
+ const isBuiltin = DOMQ_PROPERTIES.has(key);
1996
+ if (isElement || isBuiltin || hasDefine || hasGlobalDefine) {
1997
+ if (obj[key] === void 0 || value === null) {
1998
+ obj[key] = value;
1999
+ if (obj.props) delete obj.props[key];
2000
+ }
2001
+ }
2002
+ }
2003
+ return obj;
2004
+ }
2005
+ function propertizeElement(element = this) {
2006
+ const cachedKeys = [];
2007
+ pickupPropsFromElement.call(this, element, { cachedKeys });
2008
+ pickupElementFromProps.call(this, element, { cachedKeys });
2009
+ return element;
2010
+ }
2011
+ function propertizeUpdate(params = {}) {
2012
+ if (!params.on) params.on = {};
2013
+ if (!params.props) params.props = {};
2014
+ return propertizeElement.call(this, params);
2015
+ }
2016
+ var objectizeStringProperty = (propValue) => {
2017
+ if (is(propValue)("string", "number")) {
2018
+ return { inheritedString: propValue };
2019
+ }
2020
+ return propValue;
2021
+ };
2022
+ var propExists = (prop, stack) => {
2023
+ if (!prop || !stack.length) return false;
2024
+ return stack.includes(prop);
2025
+ };
2026
+ var inheritParentProps = (element, parent) => {
2027
+ const { __ref: ref } = element;
2028
+ const propsStack = ref.__propsStack || [];
2029
+ const parentProps = parent.props;
2030
+ if (!parentProps) return propsStack;
2031
+ const matchParentKeyProps = parentProps[element.key];
2032
+ const matchParentChildProps = parentProps.childProps;
2033
+ const ignoreChildProps = element.props?.ignoreChildProps;
2034
+ if (matchParentChildProps && !ignoreChildProps) {
2035
+ const childProps = objectizeStringProperty(matchParentChildProps);
2036
+ propsStack.unshift(childProps);
2037
+ }
2038
+ if (matchParentKeyProps) {
2039
+ const keyProps = objectizeStringProperty(matchParentKeyProps);
2040
+ propsStack.unshift(keyProps);
2041
+ }
2042
+ return propsStack;
2043
+ };
2044
+ function update(props, options) {
2045
+ const element = this.__element;
2046
+ element.update({ props }, options);
2047
+ }
2048
+ function setPropsPrototype(element) {
2049
+ const methods = { update: update.bind(element.props), __element: element };
2050
+ Object.setPrototypeOf(element.props, methods);
2051
+ }
2052
+ var removeDuplicateProps = (propsStack) => {
2053
+ const seen = /* @__PURE__ */ new Set();
2054
+ return propsStack.filter((prop) => {
2055
+ if (!prop || PROPS_METHODS.has(prop)) return false;
2056
+ if (seen.has(prop)) return false;
2057
+ seen.add(prop);
2058
+ return true;
2059
+ });
2060
+ };
2061
+ var syncProps = (propsStack, element, opts) => {
2062
+ element.props = propsStack.reduce((mergedProps, v) => {
2063
+ if (PROPS_METHODS.has(v)) return mergedProps;
2064
+ while (isFunction(v)) v = exec(v, element);
2065
+ return deepMerge(mergedProps, deepClone(v, { exclude: PROPS_METHODS }));
2066
+ }, {});
2067
+ setPropsPrototype(element);
2068
+ return element.props;
2069
+ };
2070
+ var createPropsStack = (element, parent) => {
2071
+ const { props, __ref: ref } = element;
2072
+ let propsStack = ref.__propsStack || [];
2073
+ if (parent?.props) {
2074
+ const parentStack = inheritParentProps(element, parent);
2075
+ propsStack = [...parentStack];
2076
+ }
2077
+ if (isObject(props)) propsStack.push(props);
2078
+ else if (props === "inherit" && parent?.props) propsStack.push(parent.props);
2079
+ else if (props) propsStack.push(props);
2080
+ if (isArray(ref.__extendsStack)) {
2081
+ for (let i = 0; i < ref.__extendsStack.length; i++) {
2082
+ const _extends = ref.__extendsStack[i];
2083
+ if (_extends.props && _extends.props !== props) {
2084
+ propsStack.push(_extends.props);
2085
+ }
2086
+ }
2087
+ }
2088
+ ref.__propsStack = removeDuplicateProps(propsStack);
2089
+ return ref.__propsStack;
2090
+ };
2091
+ var applyProps = (element, parent) => {
2092
+ const { __ref: ref } = element;
2093
+ const propsStack = createPropsStack(element, parent);
2094
+ if (propsStack.length) {
2095
+ syncProps(propsStack, element);
2096
+ } else {
2097
+ ref.__propsStack = [];
2098
+ element.props = {};
2099
+ }
2100
+ };
2101
+ var initProps = function(element, parent, options) {
2102
+ const { __ref: ref } = element;
2103
+ if (ref.__if) applyProps(element, parent);
2104
+ else {
2105
+ try {
2106
+ applyProps(element, parent);
2107
+ } catch (e) {
2108
+ if (element.context?.designSystem?.verbose) {
2109
+ console.warn("initProps error at", ref.path?.join("."), e);
2110
+ }
2111
+ element.props = {};
2112
+ ref.__propsStack = [];
2113
+ }
2114
+ }
2115
+ setPropsPrototype(element);
2116
+ return element;
2117
+ };
2118
+ var updateProps = (newProps, element, parent) => {
2119
+ const { __ref: ref } = element;
2120
+ const propsStack = ref.__propsStack || [];
2121
+ let newStack = [...propsStack];
2122
+ const parentProps = inheritParentProps(element, parent);
2123
+ if (parentProps.length) {
2124
+ newStack = [...parentProps, ...newStack];
2125
+ }
2126
+ if (newProps) {
2127
+ newStack = [newProps, ...newStack];
2128
+ }
2129
+ ref.__propsStack = removeDuplicateProps(newStack);
2130
+ if (ref.__propsStack.length) {
2131
+ syncProps(ref.__propsStack, element);
2132
+ }
2133
+ return element;
2134
+ };
2135
+
2136
+ // element.js
2137
+ var ENV4 = process.env.NODE_ENV;
2138
+ var returnValueAsText = (element, parent, key) => {
2139
+ const childExtendsTag = parent.childExtends && parent.childExtends.tag;
2140
+ const childPropsTag = parent.props.childProps && parent.props.childProps.tag;
2141
+ const isKeyValidHTMLTag = HTML_TAGS.body.has(key) && key;
2142
+ return {
2143
+ text: element,
2144
+ tag: childExtendsTag || childPropsTag || isKeyValidHTMLTag || "string"
2145
+ };
2146
+ };
2147
+ var createBasedOnType = (element, parent, key) => {
2148
+ if (element === void 0) {
2149
+ if (ENV4 === "test" || ENV4 === "development") {
2150
+ console.warn(
2151
+ key,
2152
+ "element is undefined in",
2153
+ parent?.__ref?.path
2154
+ );
2155
+ }
2156
+ return {};
2157
+ }
2158
+ if (element === null) return;
2159
+ if (element === true) return {};
2160
+ if (is(element)("string", "number")) {
2161
+ return returnValueAsText(element, parent, key);
2162
+ }
2163
+ if (isFunction(element)) {
2164
+ return { props: element };
2165
+ }
2166
+ return element;
2167
+ };
2168
+ var addRef = (element, parent) => {
2169
+ const ref = {};
2170
+ ref.origin = element;
2171
+ ref.parent = parent;
2172
+ return ref;
2173
+ };
2174
+ var createParent = (element, parent, key, options, root) => {
2175
+ if (!parent) return root;
2176
+ if (isNode(parent)) {
2177
+ const parentNodeWrapper = { key: ":root", node: parent };
2178
+ root[`${key}_parent`] = parentNodeWrapper;
2179
+ return parentNodeWrapper;
2180
+ }
2181
+ return parent;
2182
+ };
2183
+ var createRoot = (element, parent) => {
2184
+ const { __ref: ref } = element;
2185
+ const { __ref: parentRef } = parent;
2186
+ const hasRoot = parent && parent.key === ":root";
2187
+ if (!ref?.root) {
2188
+ ref.root = hasRoot ? element : parentRef?.root;
2189
+ }
2190
+ };
2191
+ var createPath = (element, parent, key) => {
2192
+ let { __ref: parentRef } = parent;
2193
+ if (!parentRef) parentRef = parent.ref = {};
2194
+ if (!parentRef.path) parentRef.path = [];
2195
+ return parentRef.path.concat(key);
2196
+ };
2197
+ var addContext = (element, parent, key, options, root) => {
2198
+ const forcedOptionsContext = options.context && !root.context && !element.context;
2199
+ if (forcedOptionsContext) root.context = options.context;
2200
+ return options.context || parent.context || root.context || element.context;
2201
+ };
2202
+ var addCaching = (element, parent, key) => {
2203
+ const ref = addRef(element, parent);
2204
+ element.__ref = ref;
2205
+ if (!ref.__defineCache) ref.__defineCache = {};
2206
+ if (!ref.__exec) ref.__exec = {};
2207
+ if (!ref.__execProps) ref.__execProps = {};
2208
+ if (!ref.__class) ref.__class = {};
2209
+ if (!ref.__classNames) ref.__classNames = {};
2210
+ if (!ref.__attr) ref.__attr = {};
2211
+ if (!ref.__changes) ref.__changes = [];
2212
+ if (!ref.__children) ref.__children = [];
2213
+ ref.__extends = createExtends(element, parent, key);
2214
+ ref.path = createPath(element, parent, key);
2215
+ return ref;
2216
+ };
2217
+ var createElement = (passedProps, parentEl, passedKey, opts, root) => {
2218
+ const hashed = passedProps?.__hash;
2219
+ const element = hashed ? { extends: [passedProps] } : createBasedOnType(passedProps, parentEl, passedKey);
2220
+ if (!element) return;
2221
+ const parent = createParent(element, parentEl, passedKey, opts, root);
2222
+ const key = createKey(element, parent, passedKey);
2223
+ addCaching(element, parent, key);
2224
+ const props = createProps(element, parent, key);
2225
+ const context = addContext(element, parent, key, opts, root);
2226
+ const on = element.on || {};
2227
+ return {
2228
+ ...element,
2229
+ key,
2230
+ props,
2231
+ parent,
2232
+ context,
2233
+ on
2234
+ };
2235
+ };
2236
+
2237
+ // state.js
2238
+ var checkForStateTypes = (element) => {
2239
+ const { state: orig, props, __ref: ref } = element;
2240
+ const state = props?.state || orig;
2241
+ if (isFunction(state)) {
2242
+ ref.__state = state;
2243
+ return exec(state, element);
2244
+ } else if (is(state)("string", "number")) {
2245
+ ref.__state = state;
2246
+ return { value: state };
2247
+ } else if (state === true) {
2248
+ ref.__state = element.key;
2249
+ return {};
2250
+ } else if (state) {
2251
+ ref.__hasRootState = true;
2252
+ return state;
2253
+ } else {
2254
+ return false;
2255
+ }
2256
+ };
2257
+ var getRootStateInKey = (stateKey, parentState) => {
2258
+ if (!stateKey.includes("~/")) return;
2259
+ const arr = stateKey.split("~/");
2260
+ if (arr.length > 1) return parentState.root;
2261
+ };
2262
+ var getParentStateInKey = (stateKey, parentState) => {
2263
+ if (!stateKey.includes("../")) return;
2264
+ const arr = stateKey.split("../");
2265
+ const arrLength = arr.length - 1;
2266
+ for (let i = 0; i < arrLength; i++) {
2267
+ if (!parentState.parent) return null;
2268
+ parentState = parentState.parent;
2269
+ }
2270
+ return parentState;
2271
+ };
2272
+ var getChildStateInKey = (stateKey, parentState, options = {}) => {
2273
+ const arr = isString(stateKey) ? stateKey.split("/") : [stateKey];
2274
+ const arrLength = arr.length - 1;
2275
+ for (let i = 0; i < arrLength; i++) {
2276
+ const childKey = arr[i];
2277
+ const grandChildKey = arr[i + 1];
2278
+ if (childKey === "__proto__" || grandChildKey === "__proto__") return;
2279
+ let childInParent = parentState[childKey];
2280
+ if (!childInParent) childInParent = parentState[childKey] = {};
2281
+ if (!childInParent[grandChildKey]) childInParent[grandChildKey] = {};
2282
+ stateKey = grandChildKey;
2283
+ parentState = childInParent;
2284
+ }
2285
+ if (options.returnParent) return parentState;
2286
+ return parentState[stateKey];
2287
+ };
2288
+ var findInheritedState = (element, parent, options = {}) => {
2289
+ const ref = element.__ref;
2290
+ let stateKey = ref.__state;
2291
+ if (!checkIfInherits(element)) return;
2292
+ const rootState = getRootStateInKey(stateKey, parent.state);
2293
+ let parentState = parent.state;
2294
+ if (rootState) {
2295
+ parentState = rootState;
2296
+ stateKey = stateKey.replaceAll("~/", "");
2297
+ } else {
2298
+ const findGrandParentState = getParentStateInKey(stateKey, parent.state);
2299
+ if (findGrandParentState) {
2300
+ parentState = findGrandParentState;
2301
+ stateKey = stateKey.replaceAll("../", "");
2302
+ }
2303
+ }
2304
+ if (!parentState) return;
2305
+ return getChildStateInKey(stateKey, parentState, options);
2306
+ };
2307
+ var createInheritedState = (element, parent) => {
2308
+ const ref = element.__ref;
2309
+ const inheritedState = findInheritedState(element, parent);
2310
+ if (inheritedState === void 0) return element.state;
2311
+ if (is(inheritedState)("object", "array")) {
2312
+ return deepClone(inheritedState);
2313
+ } else if (is(inheritedState)("string", "number", "boolean")) {
2314
+ ref.__stateType = typeof inheritedState;
2315
+ return { value: inheritedState };
2316
+ }
2317
+ console.warn(ref.__state, "is not present. Replacing with", {});
2318
+ };
2319
+ var checkIfInherits = (element) => {
2320
+ const { __ref: ref } = element;
2321
+ const stateKey = ref?.__state;
2322
+ if (stateKey && is(stateKey)("number", "string", "boolean")) return true;
2323
+ return false;
2324
+ };
2325
+ var isState = function(state) {
2326
+ if (!isObjectLike(state)) return false;
2327
+ return Boolean(
2328
+ state.update && state.parse && state.clean && state.create && state.parent && state.destroy && state.rootUpdate && state.parentUpdate && state.keys && state.values && state.toggle && state.replace && state.quietUpdate && state.quietReplace && state.add && state.apply && state.applyReplace && state.setByPath && state.setPathCollection && state.removeByPath && state.removePathCollection && state.getByPath && state.applyFunction && state.__element && state.__children
2329
+ );
2330
+ };
2331
+ var createNestedObjectByKeyPath = (path, value) => {
2332
+ if (!path) {
2333
+ return value || {};
2334
+ }
2335
+ const keys2 = path.split("/");
2336
+ const obj = {};
2337
+ let ref = obj;
2338
+ const lastIdx = keys2.length - 1;
2339
+ for (let i = 0; i <= lastIdx; i++) {
2340
+ ref[keys2[i]] = i === lastIdx ? value || {} : {};
2341
+ ref = ref[keys2[i]];
2342
+ }
2343
+ return obj;
2344
+ };
2345
+ var applyDependentState = (element, state) => {
2346
+ const { __element } = state;
2347
+ const origState = exec(__element?.state, element);
2348
+ if (!origState) return;
2349
+ const dependentState = deepClone(origState, STATE_METHODS);
2350
+ const newDepends = { [element.key]: dependentState };
2351
+ const __depends = isObject(origState.__depends) ? { ...origState.__depends, ...newDepends } : newDepends;
2352
+ if (Array.isArray(origState)) {
2353
+ addProtoToArray(origState, {
2354
+ ...Object.getPrototypeOf(origState),
2355
+ __depends
2356
+ });
2357
+ } else {
2358
+ Object.setPrototypeOf(origState, {
2359
+ ...Object.getPrototypeOf(origState),
2360
+ __depends
2361
+ });
2362
+ }
2363
+ return dependentState;
2364
+ };
2365
+ var overwriteState = (state, obj, options = {}) => {
2366
+ const { overwrite: overwrite2 } = options;
2367
+ if (!overwrite2) return;
2368
+ const shallow = overwrite2 === "shallow";
2369
+ const merge2 = overwrite2 === "merge";
2370
+ if (merge2) {
2371
+ deepMerge(state, obj, STATE_METHODS);
2372
+ return;
2373
+ }
2374
+ const overwriteFunc = shallow ? overwriteShallow : overwriteDeep;
2375
+ overwriteFunc(state, obj, STATE_METHODS);
2376
+ };
2377
+
2378
+ // scope.js
2379
+ var createScope = (element, parent) => {
2380
+ const { __ref: ref } = element;
2381
+ if (!element.scope) element.scope = parent.scope || ref.root?.scope || {};
2382
+ };
2383
+
2384
+ // triggerEvent.js
2385
+ var getOnOrPropsEvent = (param, element) => {
2386
+ const onEvent = element.on?.[param];
2387
+ if (onEvent) return onEvent;
2388
+ const props = element.props;
2389
+ if (!props) return;
2390
+ const propKey = "on" + param.charAt(0).toUpperCase() + param.slice(1);
2391
+ return props[propKey];
2392
+ };
2393
+ var applyEvent = (param, element, state, context, options) => {
2394
+ if (!isFunction(param)) return;
2395
+ const result = param.call(
2396
+ element,
2397
+ element,
2398
+ state || element.state,
2399
+ context || element.context,
2400
+ options
2401
+ );
2402
+ if (result && typeof result.then === "function") {
2403
+ result.catch(() => {
2404
+ });
2405
+ }
2406
+ return result;
2407
+ };
2408
+ var triggerEventOn = (param, element, options) => {
2409
+ if (!element) {
2410
+ throw new Error("Element is required");
2411
+ }
2412
+ const appliedFunction = getOnOrPropsEvent(param, element);
2413
+ if (appliedFunction) {
2414
+ const { state, context } = element;
2415
+ return applyEvent(appliedFunction, element, state, context, options);
2416
+ }
2417
+ };
2418
+ var applyEventUpdate = (param, updatedObj, element, state, context, options) => {
2419
+ if (!isFunction(param)) return;
2420
+ const result = param.call(
2421
+ element,
2422
+ updatedObj,
2423
+ element,
2424
+ state || element.state,
2425
+ context || element.context,
2426
+ options
2427
+ );
2428
+ if (result && typeof result.then === "function") {
2429
+ result.catch(() => {
2430
+ });
2431
+ }
2432
+ return result;
2433
+ };
2434
+ var triggerEventOnUpdate = (param, updatedObj, element, options) => {
2435
+ const appliedFunction = getOnOrPropsEvent(param, element);
2436
+ if (appliedFunction) {
2437
+ const { state, context } = element;
2438
+ return applyEventUpdate(
2439
+ appliedFunction,
2440
+ updatedObj,
2441
+ element,
2442
+ state,
2443
+ context,
2444
+ options
2445
+ );
2446
+ }
2447
+ };
2448
+
2449
+ // methods.js
2450
+ var ENV5 = process.env.NODE_ENV;
2451
+ function spotByPath(path) {
2452
+ const element = this;
2453
+ const { __ref: ref } = element;
2454
+ const arr = [].concat(path);
2455
+ let foundelement = ref.root[arr[0]];
2456
+ if (!arr || !arr.length) {
2457
+ return console.log(arr, "on", element.key, "is undefined");
2458
+ }
2459
+ while (foundelement.key === arr[0]) {
2460
+ arr.shift();
2461
+ if (!arr.length) break;
2462
+ foundelement = foundelement[arr[0]];
2463
+ if (!foundelement) return;
2464
+ }
2465
+ return foundelement;
2466
+ }
2467
+ function lookup(param) {
2468
+ const el = this;
2469
+ let { parent } = el;
2470
+ if (isFunction(param)) {
2471
+ if (parent.state && param(parent, parent.state, parent.context)) {
2472
+ return parent;
2473
+ } else if (parent.parent) return parent.lookup(param);
2474
+ else return;
2475
+ }
2476
+ if (el[param]) return el[param];
2477
+ while (parent.param !== param) {
2478
+ if (parent[param]) return parent[param];
2479
+ parent = parent.parent;
2480
+ if (!parent) return;
2481
+ }
2482
+ return parent;
2483
+ }
2484
+ function lookdown(param) {
2485
+ const el = this;
2486
+ const { __ref: ref } = el;
2487
+ const children = ref?.__children;
2488
+ if (!children) return;
2489
+ for (let i = 0; i < children.length; i++) {
2490
+ const v = children[i];
2491
+ const childElem = el[v];
2492
+ if (v === param) return childElem;
2493
+ else if (isFunction(param)) {
2494
+ const exec2 = param(childElem, childElem.state, childElem.context);
2495
+ if (childElem.state && exec2) {
2496
+ return childElem;
2497
+ }
2498
+ }
2499
+ const lookdown2 = childElem?.lookdown?.(param);
2500
+ if (lookdown2) return lookdown2;
2501
+ }
2502
+ }
2503
+ function lookdownAll(param, results = []) {
2504
+ const el = this;
2505
+ const { __ref: ref } = el;
2506
+ const children = ref?.__children;
2507
+ if (!children) return;
2508
+ for (let i = 0; i < children.length; i++) {
2509
+ const v = children[i];
2510
+ const childElem = el[v];
2511
+ if (v === param) results.push(childElem);
2512
+ else if (isFunction(param)) {
2513
+ const exec2 = param(childElem, childElem.state, childElem.context);
2514
+ if (childElem.state && exec2) results.push(childElem);
2515
+ }
2516
+ childElem?.lookdownAll?.(param, results);
2517
+ }
2518
+ return results.length ? results : void 0;
2519
+ }
2520
+ function setNodeStyles(params = {}) {
2521
+ const el = this;
2522
+ if (!el.node?.style) return;
2523
+ for (const param in params) {
2524
+ const value = params[param];
2525
+ const childElem = el[param];
2526
+ if (isObject(value) && childElem) setNodeStyles.call(childElem, value);
2527
+ else el.node.style[param] = value;
2528
+ }
2529
+ return el;
2530
+ }
2531
+ function remove(opts) {
2532
+ const element = this;
2533
+ const beforeRemoveReturns = triggerEventOn("beforeRemove", element, opts);
2534
+ if (beforeRemoveReturns === false) return element;
2535
+ if (isFunction(element.node.remove)) element.node.remove();
2536
+ else if (!isProduction()) {
2537
+ console.warn("This item cant be removed");
2538
+ element.log();
2539
+ }
2540
+ delete element.parent[element.key];
2541
+ if (element.parent.__ref) {
2542
+ element.parent.__ref.__children = removeValueFromArray(
2543
+ element.parent.__ref.__children,
2544
+ element.key
2545
+ );
2546
+ }
2547
+ triggerEventOn("remove", element, opts);
2548
+ }
2549
+ function get(param) {
2550
+ const element = this;
2551
+ return element[param];
2552
+ }
2553
+ function setProps(param, options) {
2554
+ const element = this;
2555
+ if (!param || !element.props) return;
2556
+ element.update({ props: param }, options);
2557
+ return element;
2558
+ }
2559
+ function getRef(key) {
2560
+ if (key) return this.__ref && this.__ref[key];
2561
+ return this.__ref;
2562
+ }
2563
+ function getChildren() {
2564
+ const __children = this.getRef("__children");
2565
+ return __children.map((k) => this[k]);
2566
+ }
2567
+ function getPath() {
2568
+ return this.getRef().path;
2569
+ }
2570
+ function getRootState(param) {
2571
+ let state = null;
2572
+ const hasRootState = (obj) => obj.__element && obj.root?.isRootState;
2573
+ if (!this) {
2574
+ state = window.platformState || window.smblsApp?.state;
2575
+ } else if (hasRootState(this)) {
2576
+ state = this.root;
2577
+ } else if (this.__ref && this.__ref.path) {
2578
+ const hasPlatformState = this.state && hasRootState(this.state);
2579
+ const hasPlatformStateOnParent = isFunction(this.state) && this.parent.state && hasRootState(this.parent.state);
2580
+ if (hasPlatformState || hasPlatformStateOnParent) {
2581
+ state = this.state.root || this.parent.state.root;
2582
+ }
2583
+ }
2584
+ if (!state) {
2585
+ state = window.platformState || window.smblsApp?.state;
2586
+ }
2587
+ return param ? state?.[param] : state;
2588
+ }
2589
+ function getRoot(key) {
2590
+ const rootElem = this.getRootState()?.__element;
2591
+ return rootElem && Object.keys(rootElem).length > 0 && key ? rootElem[key] : rootElem;
2592
+ }
2593
+ function getRootData(key) {
2594
+ return this.getRoot("data") && Object.keys(this.getRoot("data")).length > 0 && key ? this.getRoot("data")[key] : this.getRoot("data");
2595
+ }
2596
+ function getRootContext(key) {
2597
+ const ctx = this.getRoot()?.context;
2598
+ return key ? ctx[key] : ctx;
2599
+ }
2600
+ function getContext(key) {
2601
+ const ctx = this.context;
2602
+ return key ? ctx[key] : ctx;
2603
+ }
2604
+ var defineSetter = (element, key, get2, set) => Object.defineProperty(element, key, { get: get2, set });
2605
+ function keys() {
2606
+ const element = this;
2607
+ const keys2 = [];
2608
+ for (const param in element) {
2609
+ if (
2610
+ // (REGISTRY[param] && !DOMQ_PROPERTIES.has(param)) ||
2611
+ !Object.prototype.hasOwnProperty.call(element, param) || DOMQ_PROPERTIES.has(param) && !PARSED_DOMQ_PROPERTIES.has(param)
2612
+ ) {
2613
+ continue;
2614
+ }
2615
+ keys2.push(param);
2616
+ }
2617
+ return keys2;
2618
+ }
2619
+ function parse(excl = []) {
2620
+ const element = this;
2621
+ const obj = {};
2622
+ const keyList = keys.call(element);
2623
+ const hasChildren = keyList.includes("children");
2624
+ const exclSet = excl.length ? new Set(excl) : null;
2625
+ for (let i = 0; i < keyList.length; i++) {
2626
+ const v = keyList[i];
2627
+ if (exclSet && exclSet.has(v) || !Object.prototype.hasOwnProperty.call(element, v)) continue;
2628
+ if (hasChildren && v === "content") continue;
2629
+ const val = element[v];
2630
+ if (v === "state") {
2631
+ if (element.__ref && !element.__ref.__hasRootState) continue;
2632
+ const parsedVal = isFunction(val && val.parse) ? val.parse() : val;
2633
+ obj[v] = isFunction(parsedVal) ? parsedVal : JSON.parse(JSON.stringify(parsedVal || {}));
2634
+ } else if (v === "scope") {
2635
+ if (element.__ref && !element.__ref.__hasRootScope) continue;
2636
+ obj[v] = JSON.parse(JSON.stringify(val || {}));
2637
+ } else if (v === "props") {
2638
+ const { __element, update: update2, ...props } = element[v];
2639
+ obj[v] = props;
2640
+ } else if (isDefined(val) && Object.prototype.hasOwnProperty.call(element, v)) {
2641
+ obj[v] = val;
2642
+ }
2643
+ }
2644
+ return obj;
2645
+ }
2646
+ function parseDeep(excl = [], visited = /* @__PURE__ */ new WeakSet()) {
2647
+ const element = this;
2648
+ if (visited.has(element)) return void 0;
2649
+ visited.add(element);
2650
+ const obj = parse.call(element, excl);
2651
+ const exclSet = excl.length ? new Set(excl) : null;
2652
+ for (const v in obj) {
2653
+ if (exclSet && exclSet.has(v) || !Object.prototype.hasOwnProperty.call(element, v)) continue;
2654
+ const val = obj[v];
2655
+ if (Array.isArray(val)) {
2656
+ obj[v] = val.map(
2657
+ (item) => isObjectLike(item) ? parseDeep.call(item, excl, visited) : item
2658
+ );
2659
+ } else if (isObjectLike(val)) {
2660
+ obj[v] = parseDeep.call(val, excl, visited);
2661
+ }
2662
+ }
2663
+ return obj;
2664
+ }
2665
+ function verbose(...args) {
2666
+ if (ENV5 !== "test" && ENV5 !== "development") return;
2667
+ const element = this;
2668
+ const { __ref: ref } = element;
2669
+ console.groupCollapsed(element.key);
2670
+ if (args.length) {
2671
+ args.forEach((v) => console.log(`%c${v}:
2672
+ `, "font-weight: bold", element[v]));
2673
+ } else {
2674
+ console.log(ref.path);
2675
+ const keys2 = element.keys();
2676
+ keys2.forEach((v) => console.log(`%c${v}:`, "font-weight: bold", element[v]));
2677
+ }
2678
+ console.log(element);
2679
+ console.groupEnd(element.key);
2680
+ return element;
2681
+ }
2682
+ function log(...params) {
2683
+ if (ENV5 === "test" || ENV5 === "development") {
2684
+ console.log(...params);
2685
+ }
2686
+ }
2687
+ function warn(...params) {
2688
+ if (ENV5 === "test" || ENV5 === "development") {
2689
+ console.warn(...params);
2690
+ }
2691
+ }
2692
+ function error(...params) {
2693
+ if (ENV5 === "test" || ENV5 === "development") {
2694
+ if (params[params.length - 1]?.debugger) debugger;
2695
+ if (params[params.length - 1]?.verbose) verbose.call(this);
2696
+ throw new Error(...params);
2697
+ }
2698
+ }
2699
+ function nextElement() {
2700
+ const element = this;
2701
+ const { key, parent } = element;
2702
+ const { __children } = parent.__ref;
2703
+ const currentIndex = __children.indexOf(key);
2704
+ const nextChild = __children[currentIndex + 1];
2705
+ return parent[nextChild];
2706
+ }
2707
+ function previousElement(el) {
2708
+ const element = el || this;
2709
+ const { key, parent } = element;
2710
+ const { __children } = parent.__ref;
2711
+ if (!__children) return;
2712
+ const currentIndex = __children.indexOf(key);
2713
+ return parent[__children[currentIndex - 1]];
2714
+ }
2715
+ function variables(obj = {}) {
2716
+ const element = this;
2717
+ if (!element.data) element.data = {};
2718
+ if (!element.data.varCaches) element.data.varCaches = {};
2719
+ const varCaches = element.data.varCaches;
2720
+ const changes = {};
2721
+ let changed;
2722
+ for (const key in obj) {
2723
+ if (obj[key] !== varCaches[key]) {
2724
+ changed = true;
2725
+ changes[key] = obj[key];
2726
+ }
2727
+ }
2728
+ return {
2729
+ changed: (cb) => {
2730
+ if (!changed) return;
2731
+ const returns = cb(changes, deepClone(varCaches));
2732
+ for (const key in changes) {
2733
+ varCaches[key] = changes[key];
2734
+ }
2735
+ return returns;
2736
+ },
2737
+ timeout: (cb, timeout) => {
2738
+ if (!changed) return;
2739
+ const t = setTimeout(() => {
2740
+ cb(changes);
2741
+ clearTimeout(t);
2742
+ }, timeout);
2743
+ }
2744
+ };
2745
+ }
2746
+ function call(fnKey, ...args) {
2747
+ const context = this.context;
2748
+ return (context.utils?.[fnKey] || context.functions?.[fnKey] || context.methods?.[fnKey] || context.snippets?.[fnKey])?.call(this, ...args);
2749
+ }
2750
+ function isMethod(param, element) {
2751
+ return Boolean(METHODS.has(param) || element?.context?.methods?.[param]);
2752
+ }
2753
+
2754
+ // cache.js
2755
+ var cache = {};
2756
+ var OPTIONS = {};
2757
+
2758
+ // update.js
2759
+ var snapshot = {
2760
+ snapshotId: createSnapshotId
2761
+ };
2762
+ var captureSnapshot = (element, options) => {
2763
+ const ref = element.__ref;
2764
+ const { currentSnapshot, calleeElement } = options;
2765
+ const isCallee = calleeElement === element;
2766
+ if (!calleeElement || isCallee) {
2767
+ const createdStanpshot = snapshot.snapshotId();
2768
+ ref.__currentSnapshot = createdStanpshot;
2769
+ return [createdStanpshot, element];
2770
+ }
2771
+ const snapshotOnCallee = calleeElement.__ref.__currentSnapshot;
2772
+ if (currentSnapshot < snapshotOnCallee) {
2773
+ return [snapshotOnCallee, calleeElement, true];
2774
+ }
2775
+ return [snapshotOnCallee, calleeElement];
2776
+ };
2777
+ return __toCommonJS(index_exports);
2778
+ })();
2779
+ // @preserve-env