@symbo.ls/utils 2.33.41 → 2.34.1

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.
@@ -0,0 +1,3838 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/domqlv3hacks.js
20
+ var domqlv3hacks_exports = {};
21
+ __export(domqlv3hacks_exports, {
22
+ temporaryDomqlHack: () => temporaryDomqlHack,
23
+ temporaryDomqlHackReverse: () => temporaryDomqlHackReverse
24
+ });
25
+ module.exports = __toCommonJS(domqlv3hacks_exports);
26
+
27
+ // ../../../domql/packages/utils/dist/esm/key.js
28
+ var generateKey = /* @__PURE__ */ (function() {
29
+ let index = 0;
30
+ function newId() {
31
+ index++;
32
+ return index;
33
+ }
34
+ return newId;
35
+ })();
36
+ var createSnapshotId = generateKey;
37
+
38
+ // ../../../domql/packages/utils/dist/esm/env.js
39
+ var NODE_ENV = "development";
40
+ var isProduction = (env = NODE_ENV) => env === "production";
41
+ var isNotProduction = (env = NODE_ENV) => !isProduction(env);
42
+
43
+ // ../../../domql/packages/utils/dist/esm/globals.js
44
+ var window2 = globalThis;
45
+ var document2 = window2.document;
46
+
47
+ // ../../../domql/packages/utils/dist/esm/node.js
48
+ var isNode = (obj) => {
49
+ return (typeof Node === "object" ? obj instanceof window2.Node : obj && typeof obj === "object" && typeof obj.nodeType === "number" && typeof obj.nodeName === "string") || false;
50
+ };
51
+ var isHtmlElement = (obj) => {
52
+ return (typeof HTMLElement === "object" ? obj instanceof window2.HTMLElement : obj && typeof obj === "object" && obj !== null && obj.nodeType === 1 && typeof obj.nodeName === "string") || false;
53
+ };
54
+ var isDOMNode = (obj) => {
55
+ return typeof window2 !== "undefined" && (obj instanceof window2.Node || obj instanceof window2.Window || obj === window2 || obj === document);
56
+ };
57
+
58
+ // ../../../domql/packages/utils/dist/esm/types.js
59
+ var isObject = (arg) => {
60
+ if (arg === null) return false;
61
+ return typeof arg === "object" && arg.constructor === Object;
62
+ };
63
+ var isString = (arg) => typeof arg === "string";
64
+ var isNumber = (arg) => typeof arg === "number";
65
+ var isFunction = (arg) => typeof arg === "function";
66
+ var isBoolean = (arg) => arg === true || arg === false;
67
+ var isNull = (arg) => arg === null;
68
+ var isArray = (arg) => Array.isArray(arg);
69
+ var isDate = (d) => d instanceof Date;
70
+ var isObjectLike = (arg) => {
71
+ if (arg === null) return false;
72
+ return typeof arg === "object";
73
+ };
74
+ var isDefined = (arg) => {
75
+ return isObject(arg) || isObjectLike(arg) || isString(arg) || isNumber(arg) || isFunction(arg) || isArray(arg) || isObjectLike(arg) || isBoolean(arg) || isDate(arg) || isNull(arg);
76
+ };
77
+ var isUndefined = (arg) => {
78
+ return arg === void 0;
79
+ };
80
+ var TYPES = {
81
+ boolean: isBoolean,
82
+ array: isArray,
83
+ object: isObject,
84
+ string: isString,
85
+ date: isDate,
86
+ number: isNumber,
87
+ null: isNull,
88
+ function: isFunction,
89
+ objectLike: isObjectLike,
90
+ node: isNode,
91
+ htmlElement: isHtmlElement,
92
+ defined: isDefined
93
+ };
94
+ var is = (arg) => {
95
+ return (...args) => {
96
+ return args.map((val) => TYPES[val](arg)).filter((v) => v).length > 0;
97
+ };
98
+ };
99
+ var isNot = (arg) => {
100
+ return (...args) => {
101
+ return args.map((val) => TYPES[val](arg)).filter((v) => v).length === 0;
102
+ };
103
+ };
104
+
105
+ // ../../../domql/packages/utils/dist/esm/array.js
106
+ var removeFromArray = (arr, index) => {
107
+ if (isString(index)) index = parseInt(index);
108
+ if (isNumber(index)) {
109
+ if (index < 0 || index >= arr.length || isNaN(index)) {
110
+ throw new Error("Invalid index");
111
+ }
112
+ arr.splice(index, 1);
113
+ } else if (isArray(index)) {
114
+ index.forEach((idx) => removeFromArray(arr, idx));
115
+ } else {
116
+ throw new Error("Invalid index");
117
+ }
118
+ return arr;
119
+ };
120
+ var joinArrays = (...arrays) => {
121
+ return [].concat(...arrays);
122
+ };
123
+ var mergeArray = (arr, exclude = []) => {
124
+ return arr.reduce(
125
+ (a, c) => deepMerge(a, deepClone(c, { exclude }), exclude),
126
+ {}
127
+ );
128
+ };
129
+ var removeValueFromArray = (arr, value) => {
130
+ const index = arr.indexOf(value);
131
+ if (index > -1) {
132
+ const newArray = [...arr];
133
+ newArray.splice(index, 1);
134
+ return newArray;
135
+ }
136
+ return arr;
137
+ };
138
+
139
+ // ../../../domql/packages/utils/dist/esm/string.js
140
+ var lowercaseFirstLetter = (inputString) => {
141
+ return `${inputString.charAt(0).toLowerCase()}${inputString.slice(1)}`;
142
+ };
143
+
144
+ // ../../../domql/packages/utils/dist/esm/object.js
145
+ var __defProp2 = Object.defineProperty;
146
+ var __defProps = Object.defineProperties;
147
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
148
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
149
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
150
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
151
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
152
+ var __spreadValues = (a, b) => {
153
+ for (var prop in b || (b = {}))
154
+ if (__hasOwnProp2.call(b, prop))
155
+ __defNormalProp(a, prop, b[prop]);
156
+ if (__getOwnPropSymbols)
157
+ for (var prop of __getOwnPropSymbols(b)) {
158
+ if (__propIsEnum.call(b, prop))
159
+ __defNormalProp(a, prop, b[prop]);
160
+ }
161
+ return a;
162
+ };
163
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
164
+ function exec(param, element, state2, context, opts = {}) {
165
+ if (!element) element = this;
166
+ if (isFunction(param)) {
167
+ try {
168
+ const result = param.call(
169
+ element,
170
+ element,
171
+ state2 || element.state,
172
+ context || element.context
173
+ );
174
+ if (result && typeof result.then === "function") {
175
+ return result;
176
+ }
177
+ return result;
178
+ } catch (e) {
179
+ element.log(param);
180
+ element.warn("Error executing function", e, opts);
181
+ }
182
+ }
183
+ return param;
184
+ }
185
+ var map = (obj, extention, element) => {
186
+ for (const e in extention) {
187
+ obj[e] = exec(extention[e], element);
188
+ }
189
+ };
190
+ var merge = (element, obj, excludeFrom = []) => {
191
+ for (const e in obj) {
192
+ const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(obj, e);
193
+ if (!hasOwnProperty2 || excludeFrom.includes(e) || e.startsWith("__"))
194
+ continue;
195
+ const elementProp = element[e];
196
+ const objProp = obj[e];
197
+ if (elementProp === void 0) {
198
+ element[e] = objProp;
199
+ }
200
+ }
201
+ return element;
202
+ };
203
+ var deepMerge = (element, extend, excludeFrom = [], level = Infinity) => {
204
+ for (const e in extend) {
205
+ const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(extend, e);
206
+ if (!hasOwnProperty2 || excludeFrom.includes(e) || e.startsWith("__"))
207
+ continue;
208
+ const elementProp = element[e];
209
+ const extendProp = extend[e];
210
+ if (isObjectLike(elementProp) && isObjectLike(extendProp)) {
211
+ if (level > 0) {
212
+ deepMerge(elementProp, extendProp, excludeFrom, level - 1);
213
+ } else {
214
+ for (const k in extendProp) {
215
+ if (excludeFrom.includes(k) || elementProp[k] === void 0) continue;
216
+ elementProp[k] = extendProp[k];
217
+ }
218
+ }
219
+ } else if (elementProp === void 0) {
220
+ element[e] = extendProp;
221
+ }
222
+ }
223
+ return element;
224
+ };
225
+ var clone = (obj, excludeFrom = []) => {
226
+ const o = {};
227
+ for (const prop in obj) {
228
+ const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(obj, prop);
229
+ if (!hasOwnProperty2 || excludeFrom.includes(prop) || prop.startsWith("__"))
230
+ continue;
231
+ o[prop] = obj[prop];
232
+ }
233
+ return o;
234
+ };
235
+ var deepClone = (obj, options = {}) => {
236
+ const {
237
+ exclude = [],
238
+ cleanUndefined = false,
239
+ cleanNull = false,
240
+ window: targetWindow,
241
+ visited = /* @__PURE__ */ new WeakMap(),
242
+ handleExtend = false
243
+ } = options;
244
+ const contentWindow = targetWindow || window2 || globalThis;
245
+ if (!isObjectLike(obj) || isDOMNode(obj)) {
246
+ return obj;
247
+ }
248
+ if (visited.has(obj)) {
249
+ return visited.get(obj);
250
+ }
251
+ const clone2 = contentWindow ? isArray(obj) ? new contentWindow.Array() : new contentWindow.Object() : isArray(obj) ? [] : {};
252
+ visited.set(obj, clone2);
253
+ for (const key in obj) {
254
+ if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
255
+ if (exclude.includes(key) || key.startsWith("__") || key === "__proto__")
256
+ continue;
257
+ let value = obj[key];
258
+ if (cleanUndefined && isUndefined(value) || cleanNull && isNull(value))
259
+ continue;
260
+ if (isDOMNode(value)) {
261
+ clone2[key] = value;
262
+ continue;
263
+ }
264
+ if (handleExtend && key === "extend" && isArray(value)) {
265
+ clone2[key] = mergeArray(value, exclude);
266
+ continue;
267
+ }
268
+ if (isFunction(value) && options.window) {
269
+ clone2[key] = contentWindow.eval("(" + value.toString() + ")");
270
+ continue;
271
+ }
272
+ if ((value == null ? void 0 : value.__ref) && (value == null ? void 0 : value.node)) {
273
+ value = value.parseDeep();
274
+ }
275
+ if (value == null ? void 0 : value.__element) {
276
+ value = value.parse();
277
+ }
278
+ if (isObjectLike(value)) {
279
+ if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
280
+ clone2[key] = deepClone(value, __spreadProps(__spreadValues({}, options), {
281
+ visited
282
+ }));
283
+ } else {
284
+ clone2[key] = value;
285
+ }
286
+ }
287
+ return clone2;
288
+ };
289
+ var deepStringifyFunctions = (obj, stringified = {}) => {
290
+ var _a, _b;
291
+ if (!obj) return;
292
+ if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
293
+ ;
294
+ (obj.__element || ((_a = obj.parent) == null ? void 0 : _a.__element)).warn(
295
+ "Trying to clone element or state at",
296
+ obj
297
+ );
298
+ obj = (_b = obj.parse) == null ? void 0 : _b.call(obj);
299
+ }
300
+ for (const prop in obj) {
301
+ const objProp = obj[prop];
302
+ if (isFunction(objProp)) {
303
+ stringified[prop] = objProp.toString();
304
+ } else if (isObject(objProp)) {
305
+ stringified[prop] = {};
306
+ deepStringifyFunctions(objProp, stringified[prop]);
307
+ } else if (isArray(objProp)) {
308
+ stringified[prop] = [];
309
+ objProp.forEach((v, i) => {
310
+ if (isObject(v)) {
311
+ stringified[prop][i] = {};
312
+ deepStringifyFunctions(v, stringified[prop][i]);
313
+ } else if (isFunction(v)) {
314
+ stringified[prop][i] = v.toString();
315
+ } else {
316
+ stringified[prop][i] = v;
317
+ }
318
+ });
319
+ } else {
320
+ stringified[prop] = objProp;
321
+ }
322
+ }
323
+ return stringified;
324
+ };
325
+ var diffObjects = (original, objToDiff, cache, opts) => {
326
+ let hasDiff = false;
327
+ const originalKeys = Object.keys(original);
328
+ const diffKeys = Object.keys(objToDiff);
329
+ const allKeys = [.../* @__PURE__ */ new Set([...originalKeys, ...diffKeys])];
330
+ const originalKeyOrder = originalKeys.join(",");
331
+ const diffKeyOrder = diffKeys.filter((k) => originalKeys.includes(k)).join(",");
332
+ if (originalKeyOrder !== diffKeyOrder) {
333
+ hasDiff = true;
334
+ }
335
+ for (const key of allKeys) {
336
+ if (key === "ref") continue;
337
+ const originalProp = original[key];
338
+ const objToDiffProp = objToDiff[key];
339
+ if (!(key in objToDiff)) {
340
+ cache[key] = void 0;
341
+ hasDiff = true;
342
+ continue;
343
+ }
344
+ if (isObject(originalProp) && isObject(objToDiffProp)) {
345
+ const nestedDiff = diff(originalProp, objToDiffProp, {}, opts);
346
+ if (nestedDiff && Object.keys(nestedDiff).length > 0) {
347
+ cache[key] = nestedDiff;
348
+ hasDiff = true;
349
+ }
350
+ } else if (isArray(originalProp) && isArray(objToDiffProp)) {
351
+ const nestedDiff = diffArrays(originalProp, objToDiffProp, [], opts);
352
+ if (nestedDiff && nestedDiff.length > 0) {
353
+ cache[key] = nestedDiff;
354
+ hasDiff = true;
355
+ }
356
+ } else if (objToDiffProp !== originalProp) {
357
+ cache[key] = objToDiffProp;
358
+ hasDiff = true;
359
+ }
360
+ }
361
+ return hasDiff ? cache : void 0;
362
+ };
363
+ var diffArrays = (original, objToDiff, cache, opts) => {
364
+ if (original.length !== objToDiff.length) {
365
+ return objToDiff;
366
+ }
367
+ let hasDiff = false;
368
+ const originalStringified = original.map((item) => JSON.stringify(item));
369
+ const diffStringified = objToDiff.map((item) => JSON.stringify(item));
370
+ if (originalStringified.join(",") !== diffStringified.join(",")) {
371
+ hasDiff = true;
372
+ }
373
+ for (let i = 0; i < original.length; i++) {
374
+ const diffObj = diff(original[i], objToDiff[i], {}, opts);
375
+ if (diffObj && (isObject(diffObj) ? Object.keys(diffObj).length > 0 : true)) {
376
+ cache[i] = diffObj;
377
+ hasDiff = true;
378
+ }
379
+ }
380
+ return hasDiff ? objToDiff : void 0;
381
+ };
382
+ var diff = (original, objToDiff, cache = {}, opts = {}) => {
383
+ if (opts.cloneInstances) {
384
+ original = deepClone(original);
385
+ objToDiff = deepClone(objToDiff);
386
+ }
387
+ original = deepStringifyFunctions(original);
388
+ objToDiff = deepStringifyFunctions(objToDiff);
389
+ if (isArray(original) && isArray(objToDiff)) {
390
+ const result = diffArrays(original, objToDiff, [], opts);
391
+ return result === void 0 ? {} : result;
392
+ }
393
+ if (isObject(original) && isObject(objToDiff)) {
394
+ const result = diffObjects(original, objToDiff, {}, opts);
395
+ return result === void 0 ? {} : result;
396
+ }
397
+ if (original !== objToDiff) {
398
+ return objToDiff;
399
+ }
400
+ return {};
401
+ };
402
+ var overwrite = (element, params, opts = {}) => {
403
+ const { __ref: ref } = element;
404
+ const excl = opts.exclude || [];
405
+ const allowUnderscore = opts.preventUnderscore;
406
+ const preventCaching = opts.preventCaching;
407
+ for (const e in params) {
408
+ if (excl.includes(e) || !allowUnderscore && e.startsWith("__")) continue;
409
+ const elementProp = element[e];
410
+ const paramsProp = params[e];
411
+ if (paramsProp !== void 0) {
412
+ element[e] = paramsProp;
413
+ if (ref && !preventCaching) {
414
+ ref.__cache[e] = elementProp;
415
+ }
416
+ if (isObject(opts.diff)) {
417
+ diff[e] = elementProp;
418
+ }
419
+ }
420
+ }
421
+ return element;
422
+ };
423
+ var overwriteShallow = (obj, params, excludeFrom = []) => {
424
+ for (const e in params) {
425
+ if (excludeFrom.includes(e) || e.startsWith("__")) continue;
426
+ obj[e] = params[e];
427
+ }
428
+ return obj;
429
+ };
430
+ var overwriteDeep = (obj, params, opts = {}, visited = /* @__PURE__ */ new WeakMap()) => {
431
+ const excl = opts.exclude || [];
432
+ const forcedExclude = opts.preventForce ? [] : ["node", "window"];
433
+ if (!isObjectLike(obj) || !isObjectLike(params) || isDOMNode(obj) || isDOMNode(params)) {
434
+ return params;
435
+ }
436
+ if (visited.has(obj)) return visited.get(obj);
437
+ visited.set(obj, obj);
438
+ for (const e in params) {
439
+ if (!Object.hasOwnProperty.call(params, e)) continue;
440
+ if (excl.includes(e) || forcedExclude && e.startsWith("__")) continue;
441
+ const objProp = obj[e];
442
+ const paramsProp = params[e];
443
+ if (isDOMNode(paramsProp)) {
444
+ obj[e] = paramsProp;
445
+ } else if (isObjectLike(objProp) && isObjectLike(paramsProp)) {
446
+ obj[e] = overwriteDeep(objProp, paramsProp, opts, visited);
447
+ } else if (paramsProp !== void 0) {
448
+ obj[e] = paramsProp;
449
+ }
450
+ }
451
+ return obj;
452
+ };
453
+ var deepContains = (obj1, obj2, ignoredKeys = ["node", "__ref"]) => {
454
+ if (obj1 === obj2) return true;
455
+ if (!isObjectLike(obj1) || !isObjectLike(obj2)) return false;
456
+ if (isDOMNode(obj1) || isDOMNode(obj2)) return obj1 === obj2;
457
+ const stack = [[obj1, obj2]];
458
+ const visited = /* @__PURE__ */ new WeakSet();
459
+ while (stack.length > 0) {
460
+ const [current1, current2] = stack.pop();
461
+ if (visited.has(current1)) continue;
462
+ visited.add(current1);
463
+ const keys1 = Object.keys(current1).filter(
464
+ (key) => !ignoredKeys.includes(key)
465
+ );
466
+ const keys22 = Object.keys(current2).filter(
467
+ (key) => !ignoredKeys.includes(key)
468
+ );
469
+ if (keys1.length !== keys22.length) return false;
470
+ for (const key of keys1) {
471
+ if (!Object.prototype.hasOwnProperty.call(current2, key)) return false;
472
+ const value1 = current1[key];
473
+ const value2 = current2[key];
474
+ if (isDOMNode(value1) || isDOMNode(value2)) {
475
+ if (value1 !== value2) return false;
476
+ } else if (isObjectLike(value1) && isObjectLike(value2)) {
477
+ if (value1 !== value2) {
478
+ stack.push([value1, value2]);
479
+ }
480
+ } else if (value1 !== value2) {
481
+ return false;
482
+ }
483
+ }
484
+ }
485
+ return true;
486
+ };
487
+ var removeFromObject = (obj, props) => {
488
+ if (props === void 0 || props === null) return obj;
489
+ if (is(props)("string", "number")) {
490
+ delete obj[props];
491
+ } else if (isArray(props)) {
492
+ props.forEach((prop) => delete obj[prop]);
493
+ } else {
494
+ throw new Error(
495
+ "Invalid input: props must be a string or an array of strings"
496
+ );
497
+ }
498
+ return obj;
499
+ };
500
+ var createNestedObject = (arr, lastValue) => {
501
+ const nestedObject = {};
502
+ if (arr.length === 0) {
503
+ return lastValue;
504
+ }
505
+ arr.reduce((obj, value, index) => {
506
+ if (!obj[value]) {
507
+ obj[value] = {};
508
+ }
509
+ if (index === arr.length - 1 && lastValue !== void 0) {
510
+ obj[value] = lastValue;
511
+ }
512
+ return obj[value];
513
+ }, nestedObject);
514
+ return nestedObject;
515
+ };
516
+ var removeNestedKeyByPath = (obj, path) => {
517
+ if (!Array.isArray(path)) {
518
+ throw new Error("Path must be an array.");
519
+ }
520
+ let current = obj;
521
+ for (let i = 0; i < path.length - 1; i++) {
522
+ if (current[path[i]] === void 0) {
523
+ return;
524
+ }
525
+ current = current[path[i]];
526
+ }
527
+ const lastKey = path[path.length - 1];
528
+ if (current && Object.hasOwnProperty.call(current, lastKey)) {
529
+ delete current[lastKey];
530
+ }
531
+ };
532
+ var setInObjectByPath = (obj, path, value) => {
533
+ if (!Array.isArray(path)) {
534
+ throw new Error("Path must be an array.");
535
+ }
536
+ let current = obj;
537
+ for (let i = 0; i < path.length - 1; i++) {
538
+ if (!current[path[i]] || typeof current[path[i]] !== "object") {
539
+ current[path[i]] = {};
540
+ }
541
+ current = current[path[i]];
542
+ }
543
+ const lastKey = path[path.length - 1];
544
+ current[lastKey] = value;
545
+ return obj;
546
+ };
547
+ var getInObjectByPath = (obj, path) => {
548
+ if (!Array.isArray(path)) {
549
+ throw new Error("Path must be an array.");
550
+ }
551
+ let current = obj;
552
+ for (let i = 0; i < path.length; i++) {
553
+ if (current === void 0 || current === null) {
554
+ return void 0;
555
+ }
556
+ current = current[path[i]];
557
+ }
558
+ return current;
559
+ };
560
+ var detectInfiniteLoop = (arr) => {
561
+ const maxRepeats = 3;
562
+ let pattern = [];
563
+ let repeatCount = 0;
564
+ for (let i = 0; i < arr.length; i++) {
565
+ if (pattern.length < 2) {
566
+ pattern.push(arr[i]);
567
+ } else {
568
+ if (arr[i] === pattern[i % 2]) {
569
+ repeatCount++;
570
+ } else {
571
+ pattern = [arr[i - 1], arr[i]];
572
+ repeatCount = 1;
573
+ }
574
+ if (repeatCount >= maxRepeats * 2) {
575
+ if (isNotProduction()) {
576
+ console.warn(
577
+ "Warning: Potential infinite loop detected due to repeated sequence:",
578
+ pattern
579
+ );
580
+ }
581
+ return true;
582
+ }
583
+ }
584
+ }
585
+ };
586
+
587
+ // ../../../domql/packages/utils/dist/esm/function.js
588
+ function getContextFunction(fnKey) {
589
+ var _a, _b, _c, _d;
590
+ return ((_a = this.context.utils) == null ? void 0 : _a[fnKey]) || ((_b = this.context.functions) == null ? void 0 : _b[fnKey]) || ((_c = this.context.methods) == null ? void 0 : _c[fnKey]) || ((_d = this.context.snippets) == null ? void 0 : _d[fnKey]);
591
+ }
592
+
593
+ // ../../../domql/packages/utils/dist/esm/cookie.js
594
+ var isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
595
+
596
+ // ../../../domql/packages/utils/dist/esm/tags.js
597
+ var HTML_TAGS = {
598
+ root: ["body", "html"],
599
+ head: ["title", "base", "meta", "style", "noscript", "script"],
600
+ body: [
601
+ "string",
602
+ "style",
603
+ "fragment",
604
+ "a",
605
+ "abbr",
606
+ "acronym",
607
+ "address",
608
+ "applet",
609
+ "area",
610
+ "article",
611
+ "aside",
612
+ "audio",
613
+ "b",
614
+ "basefont",
615
+ "bdi",
616
+ "bdo",
617
+ "big",
618
+ "blockquote",
619
+ "br",
620
+ "button",
621
+ "canvas",
622
+ "caption",
623
+ "center",
624
+ "cite",
625
+ "code",
626
+ "search",
627
+ "col",
628
+ "colgroup",
629
+ "data",
630
+ "datalist",
631
+ "dd",
632
+ "del",
633
+ "details",
634
+ "dfn",
635
+ "dialog",
636
+ "dir",
637
+ "div",
638
+ "dl",
639
+ "dt",
640
+ "em",
641
+ "embed",
642
+ "fieldset",
643
+ "figcaption",
644
+ "figure",
645
+ "font",
646
+ "footer",
647
+ "form",
648
+ "frame",
649
+ "frameset",
650
+ "h1",
651
+ "h2",
652
+ "h3",
653
+ "h4",
654
+ "h5",
655
+ "h6",
656
+ "head",
657
+ "header",
658
+ "hr",
659
+ "i",
660
+ "iframe",
661
+ "img",
662
+ "input",
663
+ "ins",
664
+ "kbd",
665
+ "label",
666
+ "legend",
667
+ "li",
668
+ "link",
669
+ "main",
670
+ "map",
671
+ "mark",
672
+ "meter",
673
+ "nav",
674
+ "noframes",
675
+ "noscript",
676
+ "object",
677
+ "ol",
678
+ "optgroup",
679
+ "option",
680
+ "output",
681
+ "p",
682
+ "param",
683
+ "picture",
684
+ "pre",
685
+ "progress",
686
+ "hgroup",
687
+ "q",
688
+ "rp",
689
+ "rt",
690
+ "ruby",
691
+ "s",
692
+ "samp",
693
+ "script",
694
+ "section",
695
+ "select",
696
+ "small",
697
+ "source",
698
+ "span",
699
+ "strike",
700
+ "strong",
701
+ "sub",
702
+ "summary",
703
+ "sup",
704
+ "table",
705
+ "tbody",
706
+ "td",
707
+ "template",
708
+ "hgroup",
709
+ "textarea",
710
+ "tfoot",
711
+ "th",
712
+ "thead",
713
+ "time",
714
+ "tr",
715
+ "track",
716
+ "tt",
717
+ "u",
718
+ "ul",
719
+ "var",
720
+ "video",
721
+ "wbr",
722
+ // SVG
723
+ "svg",
724
+ "path"
725
+ ]
726
+ };
727
+ var isValidHtmlTag = (arg) => HTML_TAGS.body.includes(arg);
728
+
729
+ // ../../../domql/packages/utils/dist/esm/component.js
730
+ var __defProp3 = Object.defineProperty;
731
+ var __defProps2 = Object.defineProperties;
732
+ var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors;
733
+ var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
734
+ var __hasOwnProp3 = Object.prototype.hasOwnProperty;
735
+ var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
736
+ var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
737
+ var __spreadValues2 = (a, b) => {
738
+ for (var prop in b || (b = {}))
739
+ if (__hasOwnProp3.call(b, prop))
740
+ __defNormalProp2(a, prop, b[prop]);
741
+ if (__getOwnPropSymbols2)
742
+ for (var prop of __getOwnPropSymbols2(b)) {
743
+ if (__propIsEnum2.call(b, prop))
744
+ __defNormalProp2(a, prop, b[prop]);
745
+ }
746
+ return a;
747
+ };
748
+ var __spreadProps2 = (a, b) => __defProps2(a, __getOwnPropDescs2(b));
749
+ var checkIfKeyIsComponent = (key) => {
750
+ const isFirstKeyString = isString(key);
751
+ if (!isFirstKeyString) return;
752
+ const firstCharKey = key.slice(0, 1);
753
+ return /^[A-Z]*$/.test(firstCharKey);
754
+ };
755
+ var addAdditionalExtend = (newExtend, element) => {
756
+ if (!newExtend) return element;
757
+ const { extend: elementExtend } = element;
758
+ const originalArray = isArray(elementExtend) ? elementExtend : [elementExtend];
759
+ const receivedArray = isArray(newExtend) ? newExtend : [newExtend];
760
+ const extend = joinArrays(receivedArray, originalArray);
761
+ return __spreadProps2(__spreadValues2({}, element), { extend });
762
+ };
763
+ var checkIfSugar = (element, parent2, key) => {
764
+ var _a;
765
+ const {
766
+ extend,
767
+ props,
768
+ childExtend,
769
+ extends: extendProps,
770
+ childExtends,
771
+ childProps,
772
+ children,
773
+ on,
774
+ $collection,
775
+ $stateCollection,
776
+ $propsCollection
777
+ } = element;
778
+ const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
779
+ if (hasComponentAttrs && (childProps || extendProps || children || childExtends)) {
780
+ const logErr = (_a = parent2 || element) == null ? void 0 : _a.error;
781
+ if (logErr)
782
+ logErr.call(
783
+ parent2,
784
+ element,
785
+ "Sugar component includes params for builtin components",
786
+ { verbose: true }
787
+ );
788
+ }
789
+ return !hasComponentAttrs || childProps || extendProps || children || childExtends;
790
+ };
791
+ var extractComponentKeyFromKey = (key) => {
792
+ return key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
793
+ };
794
+ var extendizeByKey = (element, parent2, key) => {
795
+ const { context } = parent2;
796
+ const { tag, extend, childExtends } = element;
797
+ const isSugar = checkIfSugar(element, parent2, key);
798
+ const extendFromKey = extractComponentKeyFromKey(key);
799
+ const isExtendKeyComponent = context && context.components[extendFromKey];
800
+ if (element === isExtendKeyComponent) return element;
801
+ else if (isSugar) {
802
+ const newElem = addAdditionalExtend(element.extends, {
803
+ extend: extendFromKey,
804
+ tag,
805
+ props: __spreadValues2({}, element)
806
+ });
807
+ if (newElem.props.data) {
808
+ newElem.data = newElem.props.data;
809
+ delete newElem.props.data;
810
+ }
811
+ if (newElem.props.state) {
812
+ newElem.state = newElem.props.state;
813
+ delete newElem.props.state;
814
+ }
815
+ if (newElem.props.attr) {
816
+ newElem.attr = newElem.props.attr;
817
+ delete newElem.props.attr;
818
+ }
819
+ if (newElem.props.if) {
820
+ newElem.if = newElem.props.if;
821
+ delete newElem.props.if;
822
+ }
823
+ if (childExtends) newElem.childExtend = childExtends;
824
+ return newElem;
825
+ } else if (!extend || extend === true) {
826
+ return __spreadProps2(__spreadValues2({}, element), {
827
+ tag,
828
+ extend: extendFromKey
829
+ });
830
+ } else if (extend) {
831
+ return addAdditionalExtend(extendFromKey, element);
832
+ } else if (isFunction(element)) {
833
+ return {
834
+ extend: extendFromKey,
835
+ tag,
836
+ props: __spreadValues2({}, exec(element, parent2))
837
+ };
838
+ }
839
+ };
840
+ function getCapitalCaseKeys(obj) {
841
+ return Object.keys(obj).filter((key) => /^[A-Z]/.test(key));
842
+ }
843
+ var addChildrenIfNotInOriginal = (element, parent2, key) => {
844
+ const childElems = getCapitalCaseKeys(element.props);
845
+ if (!childElems.length) return element;
846
+ for (const i in childElems) {
847
+ const childKey = childElems[i];
848
+ const childElem = element[childKey];
849
+ const newChild = element.props[childKey];
850
+ const assignChild = (val) => {
851
+ element[childKey] = val;
852
+ delete element.props[childKey];
853
+ };
854
+ if (newChild == null ? void 0 : newChild.ignoreExtend) continue;
855
+ if (newChild === null) assignChild(null);
856
+ else if (!childElem) assignChild(deepClone(newChild));
857
+ else {
858
+ const isSugarChildElem = checkIfSugar(childElem, parent2, key);
859
+ if (isSugarChildElem) continue;
860
+ assignChild({
861
+ extend: element[childKey],
862
+ props: newChild
863
+ });
864
+ }
865
+ }
866
+ };
867
+ var applyKeyComponentAsExtend = (element, parent2, key) => {
868
+ return extendizeByKey(element, parent2, key) || element;
869
+ };
870
+ var applyComponentFromContext = (element, parent2, options) => {
871
+ const { context } = element;
872
+ if (!context || !context.components) return;
873
+ const { components } = context;
874
+ const { extend } = element;
875
+ const execExtend = exec(extend, element);
876
+ if (isString(execExtend)) {
877
+ const componentExists = components[execExtend] || components["smbls." + execExtend];
878
+ if (componentExists) element.extend = componentExists;
879
+ else {
880
+ if (isNotProduction() && options.verbose) {
881
+ console.warn(execExtend, "is not in library", components, element);
882
+ console.warn("replacing with ", {});
883
+ }
884
+ element.extend = {};
885
+ }
886
+ }
887
+ };
888
+ var isVariant = (param) => {
889
+ if (!isString(param)) return;
890
+ const firstCharKey = param.slice(0, 1);
891
+ return firstCharKey === ".";
892
+ };
893
+ var hasVariantProp = (element) => {
894
+ const { props } = element;
895
+ if (isObject(props) && isString(props.variant)) return true;
896
+ };
897
+ var setContentKey = (el, opts = {}) => {
898
+ const { __ref: ref } = el;
899
+ const contentElementKey = opts.contentElementKey;
900
+ if (contentElementKey !== "content" && contentElementKey !== ref.contentElementKey || !ref.contentElementKey) {
901
+ ref.contentElementKey = contentElementKey || "content";
902
+ } else ref.contentElementKey = "content";
903
+ if (contentElementKey !== "content") opts.contentElementKey = "content";
904
+ return ref.contentElementKey;
905
+ };
906
+
907
+ // ../../../domql/plugins/report/dist/esm/index.js
908
+ var ERRORS_REGISTRY = {
909
+ en: {
910
+ DocumentNotDefined: {
911
+ title: "Document is undefined",
912
+ description: "To tweak with DOM, you should use browser."
913
+ },
914
+ OverwriteToBuiltin: {
915
+ title: "Overwriting to builtin method",
916
+ description: "Overwriting a builtin method in the window define is not possible, please choose different name"
917
+ },
918
+ BrowserNotDefined: {
919
+ title: "Can't recognize environment",
920
+ description: "Environment should be browser application, that can run Javascript"
921
+ },
922
+ SetQuickPreferancesIsNotObject: {
923
+ title: "Quick preferances object is required",
924
+ description: 'Please pass a plain object with "lang", "culture" and "area" properties'
925
+ },
926
+ InvalidParams: {
927
+ title: "Params are invalid",
928
+ description: 'Please pass a plain object with "lang", "culture" and "area" properties'
929
+ },
930
+ CantCreateWithoutNode: {
931
+ title: "You must provide node",
932
+ description: "Can't create DOM element without setting node or text"
933
+ },
934
+ HTMLInvalidTag: {
935
+ title: "Element tag name (or DOM nodeName) is invalid",
936
+ description: "To create element, you must provide valid DOM node. See full list of them at here: http://www.w3schools.com/tags/"
937
+ },
938
+ HTMLInvalidAttr: {
939
+ title: "Attibutes object is invalid",
940
+ description: "Please pass a valid plain object to apply as an attributes for a DOM node"
941
+ },
942
+ HTMLInvalidData: {
943
+ title: "Data object is invalid",
944
+ description: "Please pass a valid plain object to apply as an dataset for a DOM node"
945
+ },
946
+ HTMLInvalidStyles: {
947
+ title: "Styles object is invalid",
948
+ description: "Please pass a valid plain object to apply as an style for a DOM node"
949
+ },
950
+ HTMLInvalidText: {
951
+ title: "Text string is invalid",
952
+ description: "Please pass a valid string to apply text to DOM node"
953
+ },
954
+ ElementOnStateIsNotDefined: {
955
+ title: "Element on state is not defined",
956
+ description: "Please check the element object"
957
+ }
958
+ }
959
+ };
960
+ var report = (err, arg, element) => {
961
+ const currentLang = "en";
962
+ let errObj;
963
+ if (err && typeof err === "string") errObj = ERRORS_REGISTRY[currentLang][err];
964
+ return new Error(
965
+ `"${err}", "${arg}"
966
+
967
+ `,
968
+ `${errObj.description}`,
969
+ element ? `
970
+
971
+ ${element}` : ""
972
+ );
973
+ };
974
+
975
+ // ../../../domql/packages/element/props/ignore.js
976
+ var IGNORE_PROPS_PARAMS = ["update", "__element"];
977
+
978
+ // ../../../domql/packages/element/props/inherit.js
979
+ var objectizeStringProperty = (propValue) => {
980
+ if (is(propValue)("string", "number")) {
981
+ return { inheritedString: propValue };
982
+ }
983
+ return propValue;
984
+ };
985
+ var inheritParentProps = (element, parent2) => {
986
+ var _a;
987
+ let propsStack = [];
988
+ const parentProps = exec(parent2, parent2.state).props;
989
+ const matchParent = parent2.props && parentProps[element.key];
990
+ const matchParentIsString = isString(matchParent);
991
+ const matchParentChildProps = parentProps && parentProps.childProps;
992
+ if (matchParent) {
993
+ if (matchParentIsString) {
994
+ const inheritedStringExists = propsStack.filter((v) => v.inheritedString)[0];
995
+ if (inheritedStringExists) inheritedStringExists.inheritedString = matchParent;
996
+ else {
997
+ propsStack = [].concat(objectizeStringProperty(matchParent), propsStack);
998
+ }
999
+ } else {
1000
+ propsStack.push(objectizeStringProperty(matchParent));
1001
+ }
1002
+ }
1003
+ if (matchParentChildProps && !((_a = element == null ? void 0 : element.props) == null ? void 0 : _a.ignoreChildProps)) propsStack.push(matchParentChildProps);
1004
+ return propsStack;
1005
+ };
1006
+
1007
+ // ../../../domql/packages/element/props/create.js
1008
+ var createPropsStack = (element, parent2) => {
1009
+ const { props, __ref: ref } = element;
1010
+ const propsStack = ref.__props = inheritParentProps(element, parent2);
1011
+ if (isObject(props)) propsStack.push(props);
1012
+ else if (props === "inherit" && parent2.props) propsStack.push(parent2.props);
1013
+ else if (props) propsStack.push(props);
1014
+ if (isArray(ref.__extend)) {
1015
+ ref.__extend.forEach((extend) => {
1016
+ if (extend.props && extend.props !== props) propsStack.push(extend.props);
1017
+ });
1018
+ }
1019
+ ref.__props = propsStack;
1020
+ return propsStack;
1021
+ };
1022
+ var syncProps = async (props, element, opts) => {
1023
+ element.props = {};
1024
+ const mergedProps = {};
1025
+ props.forEach((v) => {
1026
+ if (IGNORE_PROPS_PARAMS.includes(v)) return;
1027
+ let execProps;
1028
+ try {
1029
+ execProps = exec(v, element, element.state, element.context, opts);
1030
+ } catch (e) {
1031
+ element.error(e, opts);
1032
+ }
1033
+ element.props = deepMerge(
1034
+ mergedProps,
1035
+ deepClone(execProps, { ignore: IGNORE_PROPS_PARAMS }),
1036
+ IGNORE_PROPS_PARAMS
1037
+ );
1038
+ });
1039
+ element.props = mergedProps;
1040
+ const methods = {
1041
+ update: await update.bind(element.props),
1042
+ __element: element
1043
+ };
1044
+ Object.setPrototypeOf(element.props, methods);
1045
+ return element.props;
1046
+ };
1047
+ var createProps = function(element, parent2, options) {
1048
+ const { __ref: ref } = element;
1049
+ const applyProps = () => {
1050
+ const propsStack = options.cachedProps || createPropsStack(element, parent2);
1051
+ if (propsStack.length) {
1052
+ ref.__props = propsStack;
1053
+ syncProps(propsStack, element, options);
1054
+ } else {
1055
+ ref.__props = options.cachedProps || [];
1056
+ element.props = {};
1057
+ }
1058
+ };
1059
+ if (ref.__if) applyProps();
1060
+ else {
1061
+ try {
1062
+ applyProps();
1063
+ } catch (e) {
1064
+ element.props = {};
1065
+ ref.__props = options.cachedProps || [];
1066
+ element.error("Error applying props", e, options);
1067
+ }
1068
+ }
1069
+ const methods = { update: update.bind(element.props), __element: element };
1070
+ Object.setPrototypeOf(element.props, methods);
1071
+ return element;
1072
+ };
1073
+ async function update(props, options) {
1074
+ const element = this.__element;
1075
+ await element.update({ props }, options);
1076
+ }
1077
+
1078
+ // ../../../domql/packages/element/props/update.js
1079
+ var updateProps = (newProps, element, parent2, opts) => {
1080
+ const { __ref } = element;
1081
+ let propsStack = __ref.__props;
1082
+ const parentProps = inheritParentProps(element, parent2);
1083
+ if (parentProps.length)
1084
+ propsStack = __ref.__props = [].concat(parentProps, propsStack);
1085
+ if (newProps) propsStack = __ref.__props = [].concat(newProps, propsStack);
1086
+ if (propsStack) syncProps(propsStack, element, opts);
1087
+ return element;
1088
+ };
1089
+
1090
+ // ../../../domql/packages/element/utils/object.js
1091
+ var IGNORE_STATE_PARAMS = [
1092
+ "update",
1093
+ "parse",
1094
+ "clean",
1095
+ "create",
1096
+ "destroy",
1097
+ "add",
1098
+ "toggle",
1099
+ "remove",
1100
+ "apply",
1101
+ "set",
1102
+ "reset",
1103
+ "replace",
1104
+ "quietReplace",
1105
+ "quietUpdate",
1106
+ "applyReplace",
1107
+ "applyFunction",
1108
+ "rootUpdate",
1109
+ "parentUpdate",
1110
+ "parent",
1111
+ "__element",
1112
+ "__depends",
1113
+ "__ref",
1114
+ "__children",
1115
+ "root",
1116
+ "setByPath",
1117
+ "setPathCollection",
1118
+ "removeByPath",
1119
+ "removePathCollection",
1120
+ "getByPath"
1121
+ ];
1122
+ var METHODS = [
1123
+ "set",
1124
+ "reset",
1125
+ "update",
1126
+ "remove",
1127
+ "updateContent",
1128
+ "removeContent",
1129
+ "lookup",
1130
+ "lookdown",
1131
+ "lookdownAll",
1132
+ "getRef",
1133
+ "getPath",
1134
+ "setNodeStyles",
1135
+ "spotByPath",
1136
+ "append",
1137
+ "keys",
1138
+ "parse",
1139
+ "setProps",
1140
+ "parseDeep",
1141
+ "variables",
1142
+ "if",
1143
+ "log",
1144
+ "nextElement",
1145
+ "previousElement"
1146
+ ];
1147
+ var METHODS_EXL = joinArrays(
1148
+ ["node", "state", "context", "extend", "__element"],
1149
+ METHODS,
1150
+ IGNORE_STATE_PARAMS,
1151
+ IGNORE_PROPS_PARAMS
1152
+ );
1153
+ var deepMerge2 = (element, extend, exclude = METHODS_EXL) => {
1154
+ for (const e in extend) {
1155
+ if (exclude.includes(e)) continue;
1156
+ const elementProp = element[e];
1157
+ const extendProp = extend[e];
1158
+ if (elementProp === void 0) {
1159
+ element[e] = extendProp;
1160
+ } else if (isObjectLike(elementProp) && isObject(extendProp)) {
1161
+ deepMerge2(elementProp, extendProp);
1162
+ }
1163
+ }
1164
+ return element;
1165
+ };
1166
+ var overwrite2 = (element, params, options) => {
1167
+ const changes = {};
1168
+ const { __ref } = element;
1169
+ const { __exec, __cached } = __ref;
1170
+ for (const e in params) {
1171
+ if (e === "props" || e === "state" || e === "__ref") continue;
1172
+ const elementProp = element[e];
1173
+ const paramsProp = params[e];
1174
+ if (paramsProp !== void 0) {
1175
+ __cached[e] = changes[e] = elementProp;
1176
+ element[e] = paramsProp;
1177
+ }
1178
+ if (options.cleanExec) delete __exec[e];
1179
+ }
1180
+ return changes;
1181
+ };
1182
+
1183
+ // ../../../domql/packages/element/utils/extendUtils.js
1184
+ var generateHash = () => Math.random().toString(36).substring(2);
1185
+ var extendStackRegistry = {};
1186
+ var getHashedExtend = (extend) => {
1187
+ return extendStackRegistry[extend.__hash];
1188
+ };
1189
+ var setHashedExtend = (extend, stack) => {
1190
+ const hash = generateHash();
1191
+ if (!isString(extend)) {
1192
+ extend.__hash = hash;
1193
+ }
1194
+ extendStackRegistry[hash] = stack;
1195
+ return stack;
1196
+ };
1197
+ var getExtendStackRegistry = (extend, stack) => {
1198
+ if (extend.__hash) {
1199
+ return stack.concat(getHashedExtend(extend));
1200
+ }
1201
+ return setHashedExtend(extend, stack);
1202
+ };
1203
+ var extractArrayExtend = (extend, stack, context) => {
1204
+ extend.forEach((each) => flattenExtend(each, stack, context));
1205
+ return stack;
1206
+ };
1207
+ var deepExtend = (extend, stack, context) => {
1208
+ const extendOflattenExtend = extend.extend;
1209
+ if (extendOflattenExtend) {
1210
+ flattenExtend(extendOflattenExtend, stack, context);
1211
+ }
1212
+ return stack;
1213
+ };
1214
+ var flattenExtend = (extend, stack, context) => {
1215
+ if (!extend) return stack;
1216
+ if (isArray(extend)) return extractArrayExtend(extend, stack, context);
1217
+ if (isString(extend)) extend = fallbackStringExtend(extend, context);
1218
+ stack.push(extend);
1219
+ if (extend.extend) deepExtend(extend, stack, context);
1220
+ return stack;
1221
+ };
1222
+ var deepMergeExtend = (element, extend) => {
1223
+ for (const e in extend) {
1224
+ if (["parent", "node", "__element"].indexOf(e) > -1) continue;
1225
+ const elementProp = element[e];
1226
+ const extendProp = extend[e];
1227
+ if (elementProp === void 0) {
1228
+ element[e] = extendProp;
1229
+ } else if (isObject(elementProp) && isObject(extendProp)) {
1230
+ deepMergeExtend(elementProp, extendProp);
1231
+ } else if (isArray(elementProp) && isArray(extendProp)) {
1232
+ element[e] = elementProp.concat(extendProp);
1233
+ } else if (isArray(elementProp) && isObject(extendProp)) {
1234
+ const obj = deepMergeExtend({}, elementProp);
1235
+ element[e] = deepMergeExtend(obj, extendProp);
1236
+ } else if (elementProp === void 0 && isFunction(extendProp)) {
1237
+ element[e] = extendProp;
1238
+ }
1239
+ }
1240
+ return element;
1241
+ };
1242
+ var cloneAndMergeArrayExtend = (stack) => {
1243
+ return stack.reduce((a, c) => {
1244
+ return deepMergeExtend(a, deepClone(c));
1245
+ }, {});
1246
+ };
1247
+ var fallbackStringExtend = (extend, context, options = {}, variant) => {
1248
+ const COMPONENTS = context && context.components || options.components;
1249
+ const PAGES = context && context.pages || options.pages;
1250
+ if (isString(extend)) {
1251
+ const componentExists = COMPONENTS && (COMPONENTS[extend + "." + variant] || COMPONENTS[extend] || COMPONENTS["smbls." + extend]);
1252
+ const pageExists = PAGES && extend.startsWith("/") && PAGES[extend];
1253
+ if (componentExists) return componentExists;
1254
+ else if (pageExists) return pageExists;
1255
+ else {
1256
+ if (options.verbose && isNotProduction()) {
1257
+ console.warn("Extend is string but component was not found:", extend);
1258
+ }
1259
+ return {};
1260
+ }
1261
+ }
1262
+ return extend;
1263
+ };
1264
+ var jointStacks = (extendStack, childExtendStack) => {
1265
+ return [].concat(extendStack.slice(0, 1)).concat(childExtendStack.slice(0, 1)).concat(extendStack.slice(1)).concat(childExtendStack.slice(1));
1266
+ };
1267
+ var getExtendStack = (extend, context) => {
1268
+ if (!extend) return [];
1269
+ if (extend.__hash) return getHashedExtend(extend) || [];
1270
+ const stack = flattenExtend(extend, [], context);
1271
+ return getExtendStackRegistry(extend, stack);
1272
+ };
1273
+
1274
+ // ../../../domql/packages/element/extend.js
1275
+ var mainExtend;
1276
+ var applyExtend = (element, parent2, options = {}) => {
1277
+ if (isFunction(element)) element = exec(element, parent2);
1278
+ const { props, __ref } = element;
1279
+ let extend = (props == null ? void 0 : props.extends) || element.extends || element.extend;
1280
+ const variant = props == null ? void 0 : props.variant;
1281
+ const context = element.context || parent2.context;
1282
+ extend = fallbackStringExtend(extend, context, options, variant);
1283
+ const extendStack = getExtendStack(extend, context);
1284
+ delete element.extend;
1285
+ let childExtendStack = [];
1286
+ if (parent2) {
1287
+ element.parent = parent2;
1288
+ if (!options.ignoreChildExtend && !(props && props.ignoreChildExtend)) {
1289
+ childExtendStack = getExtendStack(parent2.childExtend, context);
1290
+ const ignoreChildExtendRecursive = props && props.ignoreChildExtendRecursive;
1291
+ if (parent2.childExtendsRecursive && !ignoreChildExtendRecursive) {
1292
+ const canExtendRecursive = element.key !== "__text";
1293
+ if (canExtendRecursive) {
1294
+ const childExtendsRecursiveStack = getExtendStack(
1295
+ parent2.childExtendsRecursive,
1296
+ context
1297
+ );
1298
+ childExtendStack = childExtendStack.concat(childExtendsRecursiveStack);
1299
+ element.childExtendsRecursive = parent2.childExtendsRecursive;
1300
+ }
1301
+ }
1302
+ }
1303
+ }
1304
+ const extendLength = extendStack.length;
1305
+ const childExtendLength = childExtendStack.length;
1306
+ let stack = [];
1307
+ if (extendLength && childExtendLength) {
1308
+ stack = jointStacks(extendStack, childExtendStack);
1309
+ } else if (extendLength) {
1310
+ stack = extendStack;
1311
+ } else if (childExtendLength) {
1312
+ stack = childExtendStack;
1313
+ } else if (!context.defaultExtends) return element;
1314
+ if (context.defaultExtends) {
1315
+ if (!mainExtend) {
1316
+ const defaultOptionsExtend = getExtendStack(
1317
+ context.defaultExtends,
1318
+ context
1319
+ );
1320
+ mainExtend = cloneAndMergeArrayExtend(defaultOptionsExtend);
1321
+ delete mainExtend.extend;
1322
+ }
1323
+ stack = [].concat(stack, mainExtend);
1324
+ }
1325
+ if (__ref) __ref.__extend = stack;
1326
+ let mergedExtend = cloneAndMergeArrayExtend(stack);
1327
+ const COMPONENTS = context && context.components || options.components;
1328
+ const component = exec(element.component || mergedExtend.component, element);
1329
+ if (component && COMPONENTS && COMPONENTS[component]) {
1330
+ const componentExtend = cloneAndMergeArrayExtend(
1331
+ getExtendStack(COMPONENTS[component])
1332
+ );
1333
+ mergedExtend = deepMergeExtend(componentExtend, mergedExtend);
1334
+ }
1335
+ const merged = deepMergeExtend(element, mergedExtend);
1336
+ return merged;
1337
+ };
1338
+
1339
+ // ../../../domql/packages/element/mixins/classList.js
1340
+ var assignKeyAsClassname = (element) => {
1341
+ const { key } = element;
1342
+ if (element.class === true) element.class = key;
1343
+ else if (!element.class && typeof key === "string" && key.charAt(0) === "_" && key.charAt(1) !== "_") {
1344
+ element.class = key.slice(1);
1345
+ }
1346
+ };
1347
+ var classify = (obj, element, opts) => {
1348
+ let className = "";
1349
+ for (const item in obj) {
1350
+ const param = obj[item];
1351
+ if (typeof param === "boolean" && param) className += ` ${item}`;
1352
+ else if (typeof param === "string") className += ` ${param}`;
1353
+ else if (typeof param === "function") {
1354
+ className += ` ${exec(param, element, element.state, element.context, opts)}`;
1355
+ }
1356
+ }
1357
+ return className;
1358
+ };
1359
+ var classList = (params, element, opts) => {
1360
+ if (!params) return;
1361
+ const { key } = element;
1362
+ if (params === true) params = element.class = { key };
1363
+ if (isString(params)) params = element.class = { default: params };
1364
+ if (isObject(params)) params = classify(params, element, opts);
1365
+ const className = params.replace(/\s+/g, " ").trim();
1366
+ if (element.ref) element.ref.class = className;
1367
+ return className;
1368
+ };
1369
+
1370
+ // ../../../domql/packages/element/cache/options.js
1371
+ var OPTIONS = {};
1372
+
1373
+ // ../../../domql/packages/event/dist/esm/on.js
1374
+ var getOnOrPropsEvent = (param, element) => {
1375
+ var _a, _b;
1376
+ const onEvent = (_a = element.on) == null ? void 0 : _a[param];
1377
+ const onPropEvent = (_b = element.props) == null ? void 0 : _b["on" + param.slice(0, 1).toUpperCase() + param.slice(1)];
1378
+ return onEvent || onPropEvent;
1379
+ };
1380
+ var applyEvent = (fnValue, element, state2, context, options) => {
1381
+ if (isString(fnValue)) fnValue = getContextFunction.call(element, fnValue);
1382
+ if (!fnValue.call) element.warn(`Event is not executable: ${fnValue}`);
1383
+ return fnValue.call(
1384
+ element,
1385
+ element,
1386
+ state2 || element.state,
1387
+ context || element.context,
1388
+ options
1389
+ );
1390
+ };
1391
+ var triggerEventOn = async (param, element, options) => {
1392
+ const appliedFunction = getOnOrPropsEvent(param, element);
1393
+ const ref = element.__ref;
1394
+ if (ref.__stormAbortion) {
1395
+ return;
1396
+ }
1397
+ if (appliedFunction) {
1398
+ const { state: state2, context } = element;
1399
+ return await applyEvent(appliedFunction, element, state2, context, options);
1400
+ }
1401
+ };
1402
+ var applyEventUpdate = (fnValue, updatedObj, element, state2, context, options) => {
1403
+ if (isString(fnValue)) fnValue = getContextFunction.call(element, fnValue);
1404
+ if (!fnValue.call) element.warn(`Event is not executable: ${fnValue}`);
1405
+ return fnValue.call(
1406
+ element,
1407
+ updatedObj,
1408
+ element,
1409
+ state2 || element.state,
1410
+ context || element.context,
1411
+ options
1412
+ );
1413
+ };
1414
+ var triggerEventOnUpdate = async (param, updatedObj, element, options) => {
1415
+ const appliedFunction = getOnOrPropsEvent(param, element);
1416
+ if (appliedFunction) {
1417
+ const { state: state2, context } = element;
1418
+ return await applyEventUpdate(
1419
+ appliedFunction,
1420
+ updatedObj,
1421
+ element,
1422
+ state2,
1423
+ context,
1424
+ options
1425
+ );
1426
+ }
1427
+ };
1428
+ var applyEventsOnNode = (element, options) => {
1429
+ const { node, on } = element;
1430
+ for (const param in on) {
1431
+ if (param === "init" || param === "beforeClassAssign" || param === "render" || param === "renderRouter" || param === "attachNode" || param === "stateInit" || param === "stateCreated" || param === "beforeStateUpdate" || param === "stateUpdate" || param === "beforeUpdate" || param === "done" || param === "create" || param === "complete" || param === "frame" || param === "update")
1432
+ continue;
1433
+ let fnValue = getOnOrPropsEvent(param, element);
1434
+ if (isString(fnValue)) {
1435
+ fnValue = getContextFunction.call(element, fnValue);
1436
+ }
1437
+ if (isFunction(fnValue)) {
1438
+ node.addEventListener(param, async (event) => {
1439
+ const { state: state2, context } = element;
1440
+ await fnValue.call(element, event, element, state2, context, options);
1441
+ });
1442
+ }
1443
+ }
1444
+ };
1445
+
1446
+ // ../../../domql/packages/event/dist/esm/can.js
1447
+ var canRenderTag = (tag) => {
1448
+ return isValidHtmlTag(tag || "div") || report("HTMLInvalidTag");
1449
+ };
1450
+
1451
+ // ../../../domql/packages/event/dist/esm/animationFrame.js
1452
+ var registerFrameListener = (el) => {
1453
+ const { __ref: ref } = el;
1454
+ const { frameListeners } = ref.root.data;
1455
+ if (frameListeners && !frameListeners.has(el)) {
1456
+ frameListeners.add(el);
1457
+ }
1458
+ };
1459
+ var applyAnimationFrame = (element, options) => {
1460
+ const { props, on, __ref: ref } = element;
1461
+ const { frameListeners } = ref.root.data;
1462
+ if (frameListeners && ((on == null ? void 0 : on.frame) || (props == null ? void 0 : props.onFrame))) {
1463
+ registerFrameListener(element);
1464
+ }
1465
+ };
1466
+
1467
+ // ../../../domql/packages/render/dist/esm/cache.js
1468
+ var createHTMLNode = (element) => {
1469
+ const { tag, context } = element;
1470
+ const doc = context.document || document2;
1471
+ if (tag) {
1472
+ if (tag === "string") return doc.createTextNode(element.text);
1473
+ else if (tag === "fragment") {
1474
+ return doc.createDocumentFragment();
1475
+ } else if (tag === "svg" || tag === "path") {
1476
+ return doc.createElementNS("http://www.w3.org/2000/svg", tag);
1477
+ } else return doc.createElement(tag);
1478
+ } else {
1479
+ return doc.createElement("div");
1480
+ }
1481
+ };
1482
+ var detectTag = (element) => {
1483
+ let { tag, key, props } = element;
1484
+ tag = exec(tag, element);
1485
+ if (tag === true) tag = key;
1486
+ if (isObject(props) && isString(props.tag)) {
1487
+ const tagExists = isValidHtmlTag(props.tag);
1488
+ if (tagExists) return props.tag;
1489
+ }
1490
+ if (isString(tag)) {
1491
+ if (isValidHtmlTag(tag)) return tag;
1492
+ } else {
1493
+ let keyAsTag = key.toLowerCase();
1494
+ if (keyAsTag.includes(".")) keyAsTag = keyAsTag.split(".")[0];
1495
+ if (keyAsTag.includes("_")) keyAsTag = keyAsTag.split("_")[0];
1496
+ if (isValidHtmlTag(keyAsTag)) return keyAsTag;
1497
+ }
1498
+ return "div";
1499
+ };
1500
+ var cacheNode = (element) => {
1501
+ const { context } = element;
1502
+ const win = context.window || window;
1503
+ const tag = element.tag = detectTag(element);
1504
+ if (!canRenderTag(tag)) {
1505
+ return report("HTMLInvalidTag", element.tag, element);
1506
+ }
1507
+ if (!win.nodeCaches) win.nodeCaches = {};
1508
+ let cachedTag = win.nodeCaches[tag];
1509
+ if (!cachedTag) cachedTag = win.nodeCaches[tag] = createHTMLNode(element);
1510
+ const clonedNode = cachedTag.cloneNode(true);
1511
+ if (tag === "string") clonedNode.nodeValue = element.text;
1512
+ return clonedNode;
1513
+ };
1514
+
1515
+ // ../../../domql/packages/render/dist/esm/append.js
1516
+ var appendNode = (node, parentNode, el) => {
1517
+ var _a;
1518
+ const win = ((_a = el == null ? void 0 : el.context) == null ? void 0 : _a.window) || window;
1519
+ try {
1520
+ if (parentNode && typeof parentNode.appendChild === "function") {
1521
+ if (parentNode instanceof win.Node && typeof parentNode.appendChild === "function") {
1522
+ parentNode.appendChild(node);
1523
+ } else {
1524
+ throw new Error(
1525
+ "Invalid parentNode: appendChild is not supported on this node type."
1526
+ );
1527
+ }
1528
+ } else {
1529
+ throw new Error(
1530
+ "Invalid parentNode: appendChild is not supported on this node type."
1531
+ );
1532
+ }
1533
+ } catch (e) {
1534
+ if (node && node.parentNode) {
1535
+ node.parentNode.removeChild(node);
1536
+ }
1537
+ if (node && parentNode && parentNode instanceof win.Element) {
1538
+ parentNode.appendChild(node);
1539
+ }
1540
+ }
1541
+ return node;
1542
+ };
1543
+ var insertNodeAfter = (node, siblingNode, parentNode) => {
1544
+ const parent2 = parentNode || siblingNode.parentNode;
1545
+ if (siblingNode.nextSibling) {
1546
+ parent2 && parent2.insertBefore(node, siblingNode.nextSibling);
1547
+ } else if (siblingNode == null ? void 0 : siblingNode.insertAdjacentElement) {
1548
+ siblingNode.insertAdjacentElement("afterend", node);
1549
+ } else {
1550
+ parent2.insertBefore(node, siblingNode);
1551
+ }
1552
+ };
1553
+ var insertNodeBefore = (node, siblingNode, parentNode) => {
1554
+ const parent2 = parentNode || siblingNode.parentNode;
1555
+ parent2 && parent2.insertBefore(node, siblingNode);
1556
+ };
1557
+ var assignNode = (element, parent2, key, attachOptions) => {
1558
+ parent2[key || element.key] = element;
1559
+ if (element.tag !== "shadow") {
1560
+ if (attachOptions && attachOptions.position) {
1561
+ ;
1562
+ (attachOptions.position === "before" ? insertNodeBefore : insertNodeAfter)(element.node, attachOptions.node || parent2.node);
1563
+ } else {
1564
+ appendNode(element.node, parent2.node, element);
1565
+ }
1566
+ }
1567
+ return element;
1568
+ };
1569
+
1570
+ // ../../../domql/packages/element/tree.js
1571
+ var ROOT = {
1572
+ key: ":root",
1573
+ node: document2 ? document2.body : report("DocumentNotDefined", document2)
1574
+ };
1575
+ var TREE = ROOT;
1576
+
1577
+ // ../../../domql/packages/element/methods/index.js
1578
+ function spotByPath(path) {
1579
+ const element = this;
1580
+ const arr = [].concat(path);
1581
+ let active = TREE[arr[0]];
1582
+ if (!arr || !arr.length)
1583
+ return console.log(arr, "on", element.key, "is undefined");
1584
+ while (active.key === arr[0]) {
1585
+ arr.shift();
1586
+ if (!arr.length) break;
1587
+ active = active[arr[0]];
1588
+ if (!active) return;
1589
+ }
1590
+ return active;
1591
+ }
1592
+ function lookup(param) {
1593
+ const el = this;
1594
+ let { parent: parent2 } = el;
1595
+ if (isFunction(param)) {
1596
+ if (parent2.state && param(parent2, parent2.state, parent2.context))
1597
+ return parent2;
1598
+ else if (parent2.parent) return parent2.lookup(param);
1599
+ else return;
1600
+ }
1601
+ if (el[param]) return el[param];
1602
+ while (parent2.param !== param) {
1603
+ if (parent2[param]) return parent2[param];
1604
+ parent2 = parent2.parent;
1605
+ if (!parent2) return;
1606
+ }
1607
+ return parent2;
1608
+ }
1609
+ function lookdown(param) {
1610
+ var _a;
1611
+ const el = this;
1612
+ const { __ref: ref } = el;
1613
+ const children = ref == null ? void 0 : ref.__children;
1614
+ if (!children) return;
1615
+ for (let i = 0; i < children.length; i++) {
1616
+ const v = children[i];
1617
+ const childElem = el[v];
1618
+ if (!childElem)
1619
+ return this.warn(
1620
+ "Element found in children array but it does not exist in parent"
1621
+ );
1622
+ if (v === param) return childElem;
1623
+ else if (isFunction(param)) {
1624
+ if (!childElem) {
1625
+ this.error(
1626
+ `"${v}" found in element __children, but content is not defined`
1627
+ );
1628
+ continue;
1629
+ }
1630
+ const exec2 = param(childElem, childElem.state, childElem.context);
1631
+ if (childElem.state && exec2) {
1632
+ return childElem;
1633
+ }
1634
+ }
1635
+ const lookdown2 = (_a = childElem == null ? void 0 : childElem.lookdown) == null ? void 0 : _a.call(childElem, param);
1636
+ if (lookdown2) return lookdown2;
1637
+ }
1638
+ }
1639
+ function lookdownAll(param, results = []) {
1640
+ var _a;
1641
+ const el = this;
1642
+ const { __ref: ref } = el;
1643
+ const children = ref == null ? void 0 : ref.__children;
1644
+ if (!children) return;
1645
+ for (let i = 0; i < children.length; i++) {
1646
+ const v = children[i];
1647
+ const childElem = el[v];
1648
+ if (v === param) results.push(childElem);
1649
+ else if (isFunction(param)) {
1650
+ if (!childElem) {
1651
+ this.error(
1652
+ `"${v}" found in element __children, but content is not defined`
1653
+ );
1654
+ continue;
1655
+ }
1656
+ const exec2 = param(childElem, childElem.state, childElem.context);
1657
+ if (childElem.state && exec2) results.push(childElem);
1658
+ }
1659
+ (_a = childElem == null ? void 0 : childElem.lookdownAll) == null ? void 0 : _a.call(childElem, param, results);
1660
+ }
1661
+ return results.length ? results : void 0;
1662
+ }
1663
+ function setNodeStyles(params = {}) {
1664
+ var _a;
1665
+ const el = this;
1666
+ if (!((_a = el.node) == null ? void 0 : _a.style)) return;
1667
+ for (const param in params) {
1668
+ const value = params[param];
1669
+ const childElem = el[param];
1670
+ if (isObject(value) && childElem) setNodeStyles.call(childElem, value);
1671
+ else el.node.style[param] = value;
1672
+ }
1673
+ return el;
1674
+ }
1675
+ async function remove(opts = {}) {
1676
+ var _a;
1677
+ const element = this;
1678
+ const beforeRemoveReturns = triggerEventOn("beforeRemove", element, opts);
1679
+ if (beforeRemoveReturns === false) return element;
1680
+ if (isFunction(element.node.remove)) element.node.remove();
1681
+ else if ((_a = element.node) == null ? void 0 : _a.parentNode)
1682
+ element.node.parentNode.removeChild(element.node);
1683
+ else if (!isProduction()) {
1684
+ console.warn("This item cant be removed");
1685
+ element.log();
1686
+ }
1687
+ delete element.parent[element.key];
1688
+ if (element.parent.__ref)
1689
+ element.parent.__ref.__children = removeValueFromArray(
1690
+ element.parent.__ref.__children,
1691
+ element.key
1692
+ );
1693
+ await triggerEventOn("remove", element, opts);
1694
+ }
1695
+ function setProps(param, opts = {}) {
1696
+ const element = this;
1697
+ if (!param || !element.props) return;
1698
+ element.update({ props: param }, opts);
1699
+ return element;
1700
+ }
1701
+ function getRef(key) {
1702
+ if (key) return this.__ref && this.__ref[key];
1703
+ return this.__ref;
1704
+ }
1705
+ function getPath() {
1706
+ return this.getRef().path;
1707
+ }
1708
+ function keys() {
1709
+ const element = this;
1710
+ const keys3 = [];
1711
+ for (const param in element) {
1712
+ if (REGISTRY[param] && !parseFilters.elementKeys.includes(param) || !Object.hasOwnProperty.call(element, param)) {
1713
+ continue;
1714
+ }
1715
+ keys3.push(param);
1716
+ }
1717
+ return keys3;
1718
+ }
1719
+ function parse(excl = []) {
1720
+ const element = this;
1721
+ const obj = {};
1722
+ const keyList = keys.call(element);
1723
+ keyList.forEach((v) => {
1724
+ if (excl.includes(v)) return;
1725
+ const val = element[v];
1726
+ if (v === "state") {
1727
+ if (element.__ref && !element.__ref.__hasRootState) return;
1728
+ const parsedVal = isFunction(val && val.parse) ? val.parse() : val;
1729
+ obj[v] = isFunction(parsedVal) ? parsedVal : JSON.parse(JSON.stringify(parsedVal || {}));
1730
+ } else if (v === "scope") {
1731
+ if (element.__ref && !element.__ref.__hasRootScope) return;
1732
+ obj[v] = JSON.parse(JSON.stringify(val || {}));
1733
+ } else if (v === "props") {
1734
+ const { __element, update: update3, ...props } = element[v];
1735
+ obj[v] = props;
1736
+ } else if (isDefined(val) && Object.hasOwnProperty.call(element, v))
1737
+ obj[v] = val;
1738
+ });
1739
+ return obj;
1740
+ }
1741
+ function parseDeep(excl = []) {
1742
+ const element = this;
1743
+ const obj = parse.call(element, excl);
1744
+ for (const v in obj) {
1745
+ if (excl.includes(v)) return;
1746
+ if (isObjectLike(obj[v])) {
1747
+ obj[v] = parseDeep.call(obj[v], excl);
1748
+ }
1749
+ }
1750
+ return obj;
1751
+ }
1752
+ function verbose(element, ...args) {
1753
+ if (isProduction()) return;
1754
+ const parent2 = this;
1755
+ const { __ref: ref } = parent2;
1756
+ console.groupCollapsed(parent2.key);
1757
+ if (args.length) {
1758
+ args.forEach(
1759
+ (v) => console.log(`%c${v}:
1760
+ `, "font-weight: bold", parent2[v])
1761
+ );
1762
+ } else {
1763
+ console.log(ref.path);
1764
+ const keys3 = parent2.keys();
1765
+ keys3.forEach((v) => console.log(`%c${v}:`, "font-weight: bold", parent2[v]));
1766
+ }
1767
+ console.log(parent2);
1768
+ console.groupEnd(parent2.key);
1769
+ return parent2;
1770
+ }
1771
+ function log(...params) {
1772
+ console.log(...params);
1773
+ }
1774
+ function warn(...params) {
1775
+ console.warn(...params, this);
1776
+ }
1777
+ function error(...params) {
1778
+ var _a, _b, _c, _d;
1779
+ if ((_a = params[params.length - 1]) == null ? void 0 : _a.debugger) debugger;
1780
+ if ((_b = params[params.length - 1]) == null ? void 0 : _b.verbose) verbose.call(this, ...params);
1781
+ if (isFunction((_c = params[params.length - 1]) == null ? void 0 : _c.onError))
1782
+ (_d = params[params.length - 1]) == null ? void 0 : _d.onError.call(this, ...params);
1783
+ console.error(...params, this);
1784
+ }
1785
+ function nextElement() {
1786
+ const element = this;
1787
+ const { key, parent: parent2 } = element;
1788
+ const { __children } = parent2.__ref;
1789
+ const currentIndex = __children.indexOf(key);
1790
+ const nextChild = __children[currentIndex + 1];
1791
+ return parent2[nextChild];
1792
+ }
1793
+ async function append(el, key, opts) {
1794
+ return await create(el, this, key, opts);
1795
+ }
1796
+ function previousElement(el) {
1797
+ const element = el || this;
1798
+ const { key, parent: parent2 } = element;
1799
+ const { __children } = parent2.__ref;
1800
+ if (!__children) return;
1801
+ const currentIndex = __children.indexOf(key);
1802
+ return parent2[__children[currentIndex - 1]];
1803
+ }
1804
+ function variables(obj = {}) {
1805
+ const element = this;
1806
+ if (!element.data) element.data = {};
1807
+ if (!element.data.varCaches) element.data.varCaches = {};
1808
+ const varCaches = element.data.varCaches;
1809
+ const changes = {};
1810
+ let changed;
1811
+ for (const key in obj) {
1812
+ if (obj[key] !== varCaches[key]) {
1813
+ changed = true;
1814
+ changes[key] = obj[key];
1815
+ }
1816
+ }
1817
+ return {
1818
+ changed: (cb) => {
1819
+ if (!changed || !varCaches) return;
1820
+ const returns = cb(changes, clone(varCaches));
1821
+ for (const key in changes) {
1822
+ varCaches[key] = changes[key];
1823
+ }
1824
+ return returns;
1825
+ },
1826
+ timeout: (cb, timeout) => {
1827
+ if (!changed) return;
1828
+ const t = setTimeout(() => {
1829
+ cb(changes);
1830
+ clearTimeout(t);
1831
+ }, timeout);
1832
+ }
1833
+ };
1834
+ }
1835
+ function call(fnKey, ...args) {
1836
+ const fn = getContextFunction.call(this, fnKey);
1837
+ if (!fn) return void 0;
1838
+ try {
1839
+ const result = fn.call(this, ...args);
1840
+ if (result && typeof result.then === "function") {
1841
+ return result;
1842
+ }
1843
+ return result;
1844
+ } catch (error2) {
1845
+ console.error(`Error calling function: '${fnKey}'
1846
+ `, error2);
1847
+ throw new Error(error2);
1848
+ }
1849
+ }
1850
+ var METHODS2 = [
1851
+ "set",
1852
+ "reset",
1853
+ "update",
1854
+ "remove",
1855
+ "updateContent",
1856
+ "removeContent",
1857
+ "lookup",
1858
+ "lookdown",
1859
+ "lookdownAll",
1860
+ "getRef",
1861
+ "getChildren",
1862
+ "getPath",
1863
+ "setNodeStyles",
1864
+ "spotByPath",
1865
+ "keys",
1866
+ "parse",
1867
+ "setProps",
1868
+ "parseDeep",
1869
+ "variables",
1870
+ "if",
1871
+ "log",
1872
+ "verbose",
1873
+ "groupLog",
1874
+ "groupLogEnd",
1875
+ "warn",
1876
+ "error",
1877
+ "call",
1878
+ "nextElement",
1879
+ "append",
1880
+ "previousElement"
1881
+ ];
1882
+ function isMethod(param, element) {
1883
+ var _a, _b;
1884
+ return METHODS2.includes(param) || ((_b = (_a = element == null ? void 0 : element.context) == null ? void 0 : _a.methods) == null ? void 0 : _b[param]);
1885
+ }
1886
+
1887
+ // ../../../domql/packages/element/iterate.js
1888
+ var throughInitialExec = async (element, exclude = {}) => {
1889
+ const { __ref: ref } = element;
1890
+ for (const param in element) {
1891
+ if (exclude[param]) continue;
1892
+ const prop = element[param];
1893
+ if (isFunction(prop) && !isMethod(param, element) && !isVariant(param)) {
1894
+ ref.__exec[param] = prop;
1895
+ element[param] = await prop(element, element.state, element.context);
1896
+ }
1897
+ }
1898
+ };
1899
+ var throughUpdatedExec = async (element, options = { excludes: METHODS_EXL }) => {
1900
+ const { __ref: ref } = element;
1901
+ const changes = {};
1902
+ for (const param in ref.__exec) {
1903
+ const prop = element[param];
1904
+ const isDefinedParam = ref.__defineCache[param];
1905
+ if (isDefinedParam) continue;
1906
+ const newExec = await ref.__exec[param](
1907
+ element,
1908
+ element.state,
1909
+ element.context
1910
+ );
1911
+ const execReturnsString = isString(newExec) || isNumber(newExec);
1912
+ if (prop && prop.node && execReturnsString) {
1913
+ overwrite2(prop, { text: newExec }, options);
1914
+ } else if (newExec !== prop) {
1915
+ if (checkIfKeyIsComponent(param)) {
1916
+ const { extend, ...newElem } = extendizeByKey(newExec, element, param);
1917
+ overwrite2(prop, newElem, options);
1918
+ } else {
1919
+ ref.__cached[param] = changes[param] = prop;
1920
+ element[param] = newExec;
1921
+ }
1922
+ }
1923
+ }
1924
+ return changes;
1925
+ };
1926
+ var throughExecProps = (element, opts) => {
1927
+ const { __ref: ref } = element;
1928
+ const { props } = element;
1929
+ for (const k in props) {
1930
+ const isDefine = k.startsWith("is") || k.startsWith("has") || k.startsWith("use");
1931
+ if (!ref.__execProps)
1932
+ return warn.call(element, "Element was not initiated to execute props");
1933
+ const cachedExecProp = ref.__execProps[k];
1934
+ if (isFunction(cachedExecProp)) {
1935
+ props[k] = exec(
1936
+ cachedExecProp,
1937
+ element,
1938
+ element.state,
1939
+ element.context,
1940
+ opts
1941
+ );
1942
+ } else if (isDefine && isFunction(props[k])) {
1943
+ ref.__execProps[k] = props[k];
1944
+ props[k] = exec(props[k], element, element.state, element.context, opts);
1945
+ }
1946
+ }
1947
+ };
1948
+ var throughInitialDefine = async (element, opts) => {
1949
+ const { define, context, __ref: ref } = element;
1950
+ let defineObj = {};
1951
+ const hasGlobalDefine = context && isObject(context.define);
1952
+ if (isObject(define)) defineObj = { ...define };
1953
+ if (hasGlobalDefine) defineObj = { ...defineObj, ...context.define };
1954
+ for (const param in defineObj) {
1955
+ let elementProp = element[param];
1956
+ if (isFunction(elementProp) && !isMethod(param, element) && !isVariant(param)) {
1957
+ ref.__exec[param] = elementProp;
1958
+ const execParam2 = elementProp = await exec(
1959
+ elementProp,
1960
+ element,
1961
+ element.state,
1962
+ element.context,
1963
+ opts
1964
+ );
1965
+ if (execParam2) {
1966
+ elementProp = element[param] = execParam2.parse ? execParam2.parse() : execParam2;
1967
+ ref.__defineCache[param] = elementProp;
1968
+ }
1969
+ }
1970
+ const execParam = await defineObj[param](
1971
+ elementProp,
1972
+ element,
1973
+ element.state,
1974
+ element.context
1975
+ );
1976
+ if (execParam) element[param] = execParam;
1977
+ }
1978
+ return element;
1979
+ };
1980
+ var throughUpdatedDefine = async (element, opts) => {
1981
+ const { context, define, __ref: ref } = element;
1982
+ const changes = {};
1983
+ let obj = {};
1984
+ if (isObject(define)) obj = { ...define };
1985
+ if (isObject(context && context.define)) obj = { ...obj, ...context.define };
1986
+ for (const param in obj) {
1987
+ const execParam = ref.__exec[param];
1988
+ if (execParam)
1989
+ ref.__defineCache[param] = await execParam(
1990
+ element,
1991
+ element.state,
1992
+ element.context
1993
+ );
1994
+ const cached = await exec(
1995
+ ref.__defineCache[param],
1996
+ element,
1997
+ element.state,
1998
+ element.context,
1999
+ opts
2000
+ );
2001
+ const newExecParam = await obj[param](
2002
+ cached,
2003
+ element,
2004
+ element.state,
2005
+ element.context
2006
+ );
2007
+ if (newExecParam) element[param] = newExecParam;
2008
+ }
2009
+ return changes;
2010
+ };
2011
+
2012
+ // ../../../domql/packages/element/utils/applyParam.js
2013
+ var applyParam = async (param, element, options) => {
2014
+ const { node, context, __ref: ref } = element;
2015
+ const prop = await exec(
2016
+ element[param],
2017
+ element,
2018
+ element.state,
2019
+ element.context,
2020
+ options
2021
+ );
2022
+ const { onlyUpdate } = options;
2023
+ const DOMQLProperty = REGISTRY[param];
2024
+ const DOMQLPropertyFromContext = context && context.registry && context.registry[param];
2025
+ const isGlobalTransformer = DOMQLPropertyFromContext || DOMQLProperty;
2026
+ const hasDefine = element.define && element.define[param];
2027
+ const hasContextDefine = context && context.define && context.define[param];
2028
+ if (!ref.__if) return;
2029
+ const hasOnlyUpdate = onlyUpdate ? onlyUpdate === param || element.lookup(onlyUpdate) : true;
2030
+ if (isGlobalTransformer && !hasContextDefine && hasOnlyUpdate) {
2031
+ if (isFunction(isGlobalTransformer)) {
2032
+ await isGlobalTransformer(prop, element, node, options);
2033
+ }
2034
+ return;
2035
+ }
2036
+ return { hasDefine, hasContextDefine };
2037
+ };
2038
+
2039
+ // ../../../domql/packages/element/utils/propEvents.js
2040
+ var propagateEventsFromProps = (element) => {
2041
+ const { props, on } = element;
2042
+ const eventKeysFromProps = Object.keys(props).filter((key) => key.startsWith("on"));
2043
+ eventKeysFromProps.forEach((v) => {
2044
+ const eventName = lowercaseFirstLetter(v.split("on")[1]);
2045
+ const origEvent = on[eventName];
2046
+ const funcFromProps = props[v];
2047
+ if (isFunction(origEvent)) {
2048
+ on[eventName] = (...args) => {
2049
+ const originalEventRetunrs = origEvent(...args);
2050
+ if (originalEventRetunrs !== false) return funcFromProps(...args);
2051
+ };
2052
+ } else on[eventName] = funcFromProps;
2053
+ });
2054
+ };
2055
+
2056
+ // ../../../domql/packages/element/node.js
2057
+ var createNode = async (element, options) => {
2058
+ let { node, tag, __ref: ref } = element;
2059
+ let isNewNode;
2060
+ if (options.routerContentElement && options.lastElement) {
2061
+ if (options.routerContentElement !== options.lastElement.content) return;
2062
+ }
2063
+ if (!node) {
2064
+ isNewNode = true;
2065
+ if (!ref.__if) return element;
2066
+ if (tag === "shadow") {
2067
+ node = element.node = element.parent.node.attachShadow({ mode: "open" });
2068
+ } else node = element.node = cacheNode(element);
2069
+ await triggerEventOn("attachNode", element, options);
2070
+ }
2071
+ node.ref = element;
2072
+ if (isFunction(node.setAttribute)) node.setAttribute("key", element.key);
2073
+ throughExecProps(element, options);
2074
+ await throughInitialDefine(element, options);
2075
+ await throughInitialExec(element);
2076
+ if (element.tag !== "string" && element.tag !== "fragment") {
2077
+ propagateEventsFromProps(element);
2078
+ if (isNewNode && isObject(element.on)) {
2079
+ applyEventsOnNode(element, options);
2080
+ }
2081
+ }
2082
+ const keys3 = Object.keys(element);
2083
+ for (const param of keys3) {
2084
+ const value = element[param];
2085
+ if (!Object.hasOwnProperty.call(element, param)) continue;
2086
+ if (isUndefined(value) || isMethod(param, element) || isVariant(param) || isObject(REGISTRY[param]))
2087
+ continue;
2088
+ if (param === "onClick") {
2089
+ debugger;
2090
+ }
2091
+ const isElement = await applyParam(param, element, options);
2092
+ if (!isElement) continue;
2093
+ const { hasDefine, hasContextDefine } = isElement;
2094
+ if (value && isElement && !hasDefine && !hasContextDefine) {
2095
+ const createAsync = async () => {
2096
+ try {
2097
+ const val = await exec(value, element);
2098
+ await create(val, element, param, options);
2099
+ } catch (error2) {
2100
+ element.error("An unexpected error occurred:", error2);
2101
+ }
2102
+ };
2103
+ if (element.props && element.props.lazyLoad || options.lazyLoad) {
2104
+ window.requestAnimationFrame(async () => {
2105
+ await createAsync();
2106
+ if (!options.preventUpdateListener) {
2107
+ await triggerEventOn("lazyLoad", element, options);
2108
+ }
2109
+ });
2110
+ } else await createAsync();
2111
+ }
2112
+ }
2113
+ return element;
2114
+ };
2115
+
2116
+ // ../../../domql/packages/state/dist/esm/ignore.js
2117
+ var IGNORE_STATE_PARAMS2 = [
2118
+ "update",
2119
+ "parse",
2120
+ "clean",
2121
+ "create",
2122
+ "destroy",
2123
+ "add",
2124
+ "toggle",
2125
+ "remove",
2126
+ "apply",
2127
+ "set",
2128
+ "reset",
2129
+ "replace",
2130
+ "quietReplace",
2131
+ "quietUpdate",
2132
+ "applyReplace",
2133
+ "applyFunction",
2134
+ "keys",
2135
+ "values",
2136
+ "ref",
2137
+ "rootUpdate",
2138
+ "parentUpdate",
2139
+ "parent",
2140
+ "__element",
2141
+ "__depends",
2142
+ "__ref",
2143
+ "__children",
2144
+ "root",
2145
+ "setByPath",
2146
+ "setPathCollection",
2147
+ "removeByPath",
2148
+ "removePathCollection",
2149
+ "getByPath"
2150
+ ];
2151
+
2152
+ // ../../../domql/packages/state/dist/esm/methods.js
2153
+ var __defProp4 = Object.defineProperty;
2154
+ var __defProps3 = Object.defineProperties;
2155
+ var __getOwnPropDescs3 = Object.getOwnPropertyDescriptors;
2156
+ var __getOwnPropSymbols3 = Object.getOwnPropertySymbols;
2157
+ var __hasOwnProp4 = Object.prototype.hasOwnProperty;
2158
+ var __propIsEnum3 = Object.prototype.propertyIsEnumerable;
2159
+ var __defNormalProp3 = (obj, key, value) => key in obj ? __defProp4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2160
+ var __spreadValues3 = (a, b) => {
2161
+ for (var prop in b || (b = {}))
2162
+ if (__hasOwnProp4.call(b, prop))
2163
+ __defNormalProp3(a, prop, b[prop]);
2164
+ if (__getOwnPropSymbols3)
2165
+ for (var prop of __getOwnPropSymbols3(b)) {
2166
+ if (__propIsEnum3.call(b, prop))
2167
+ __defNormalProp3(a, prop, b[prop]);
2168
+ }
2169
+ return a;
2170
+ };
2171
+ var __spreadProps3 = (a, b) => __defProps3(a, __getOwnPropDescs3(b));
2172
+ var parse2 = function() {
2173
+ const state2 = this;
2174
+ if (isObject(state2)) {
2175
+ const obj = {};
2176
+ for (const param in state2) {
2177
+ if (!IGNORE_STATE_PARAMS2.includes(param)) {
2178
+ obj[param] = state2[param];
2179
+ }
2180
+ }
2181
+ return obj;
2182
+ } else {
2183
+ }
2184
+ };
2185
+ var clean = async function(options = {}) {
2186
+ const state2 = this;
2187
+ for (const param in state2) {
2188
+ if (!IGNORE_STATE_PARAMS2.includes(param) && Object.hasOwnProperty.call(state2, param)) {
2189
+ delete state2[param];
2190
+ }
2191
+ }
2192
+ if (!options.preventStateUpdate) {
2193
+ await state2.update(state2, __spreadValues3({ replace: true }, options));
2194
+ }
2195
+ return state2;
2196
+ };
2197
+ var destroy = async function(options = {}) {
2198
+ const state2 = this;
2199
+ const element = state2.__element;
2200
+ const stateKey = element.__ref.__state;
2201
+ if (isString(stateKey)) {
2202
+ await element.parent.state.remove(stateKey, __spreadValues3({ isHoisted: true }, options));
2203
+ return element.state;
2204
+ }
2205
+ delete element.state;
2206
+ element.state = state2.parent;
2207
+ if (state2.parent) {
2208
+ delete state2.parent.__children[element.key];
2209
+ }
2210
+ if (state2.__children) {
2211
+ for (const key in state2.__children) {
2212
+ const child = state2.__children[key];
2213
+ if (child.state) {
2214
+ if (isArray(child.state)) {
2215
+ Object.defineProperty(child.state, "parent", {
2216
+ value: state2.parent,
2217
+ enumerable: false,
2218
+ // Set this to true if you want the method to appear in for...in loops
2219
+ configurable: true,
2220
+ // Set this to true if you want to allow redefining/removing the property later
2221
+ writable: true
2222
+ // Set this to true if you want to allow changing the function later
2223
+ });
2224
+ } else {
2225
+ Object.setPrototypeOf(child, { parent: state2.parent });
2226
+ }
2227
+ }
2228
+ }
2229
+ }
2230
+ await element.state.update({}, __spreadValues3({ isHoisted: true }, options));
2231
+ return element.state;
2232
+ };
2233
+ var parentUpdate = async function(obj, options = {}) {
2234
+ const state2 = this;
2235
+ if (!state2 || !state2.parent) return;
2236
+ return await state2.parent.update(obj, __spreadValues3({ isHoisted: true }, options));
2237
+ };
2238
+ var rootUpdate = async function(obj, options = {}) {
2239
+ const state2 = this;
2240
+ if (!state2) return;
2241
+ const rootState = state2.__element.__ref.root.state;
2242
+ return await rootState.update(obj, __spreadValues3({ isHoisted: false }, options));
2243
+ };
2244
+ var add = async function(value, options = {}) {
2245
+ const state2 = this;
2246
+ if (isArray(state2)) {
2247
+ await state2.push(value);
2248
+ return await state2.update(state2.parse(), __spreadValues3({ overwrite: true }, options));
2249
+ } else if (isObject(state2)) {
2250
+ const key = Object.keys(state2).length;
2251
+ return await state2.update({ [key]: value }, options);
2252
+ }
2253
+ };
2254
+ var toggle = async function(key, options = {}) {
2255
+ const state2 = this;
2256
+ return await state2.update({ [key]: !Boolean(state2[key]) }, options);
2257
+ };
2258
+ var remove2 = async function(key, options = {}) {
2259
+ const state2 = this;
2260
+ if (isArray(state2)) removeFromArray(state2, key);
2261
+ if (isObject(state2)) removeFromObject(state2, key);
2262
+ if (options.applyReset)
2263
+ return await state2.set(state2.parse(), __spreadValues3({ replace: true }, options));
2264
+ return await state2.update();
2265
+ };
2266
+ var set = async function(val, options = {}) {
2267
+ const state2 = this;
2268
+ const value = deepClone(val);
2269
+ await state2.clean(__spreadValues3({ preventStateUpdate: true }, options));
2270
+ await state2.replace(value, options);
2271
+ return state2;
2272
+ };
2273
+ var setByPath = async function(path, val, options = {}) {
2274
+ const state2 = this;
2275
+ const value = deepClone(val);
2276
+ if (!options.preventReplace) setInObjectByPath(state2, path, val);
2277
+ const update3 = createNestedObject(path, value);
2278
+ if (options.preventStateUpdate) return update3;
2279
+ return await state2.update(update3, options);
2280
+ };
2281
+ var setPathCollection = async function(changes, options = {}) {
2282
+ const state2 = this;
2283
+ const update3 = await changes.reduce(async (promacc, change) => {
2284
+ const acc = await promacc;
2285
+ if (change[0] === "update") {
2286
+ const result = await setByPath.call(state2, change[1], change[2], __spreadProps3(__spreadValues3({}, options), {
2287
+ preventStateUpdate: true
2288
+ }));
2289
+ return overwriteDeep(acc, result);
2290
+ } else if (change[0] === "delete") {
2291
+ await removeByPath.call(state2, change[1], options);
2292
+ const removedFromPath = change[1].slice(0, -1);
2293
+ const removedFromValue = getInObjectByPath(state2, removedFromPath);
2294
+ const result = createNestedObject(
2295
+ removedFromPath,
2296
+ isObject(removedFromValue) ? {} : []
2297
+ );
2298
+ return deepMerge(acc, result);
2299
+ }
2300
+ return acc;
2301
+ }, {});
2302
+ return await state2.update(update3, options);
2303
+ };
2304
+ var removeByPath = async function(path, options = {}) {
2305
+ const state2 = this;
2306
+ removeNestedKeyByPath(state2, path);
2307
+ if (options.preventUpdate) return path;
2308
+ return await state2.update({}, options);
2309
+ };
2310
+ var removePathCollection = async function(changes, options = {}) {
2311
+ const state2 = this;
2312
+ changes.forEach(async (item) => {
2313
+ await removeByPath(item, { preventUpdate: true });
2314
+ });
2315
+ return await state2.update({}, options);
2316
+ };
2317
+ var getByPath = function(path, options = {}) {
2318
+ const state2 = this;
2319
+ return getInObjectByPath(state2, path);
2320
+ };
2321
+ var reset = async function(options = {}) {
2322
+ const state2 = this;
2323
+ const value = deepClone(state2.parse());
2324
+ return await state2.set(value, __spreadValues3({ replace: true }, options));
2325
+ };
2326
+ var apply = async function(func, options = {}) {
2327
+ const state2 = this;
2328
+ if (isFunction(func)) {
2329
+ const value = func(state2);
2330
+ return await state2.update(value, __spreadValues3({ replace: true }, options));
2331
+ }
2332
+ };
2333
+ var applyReplace = async function(func, options = {}) {
2334
+ const state2 = this;
2335
+ if (isFunction(func)) {
2336
+ const value = func(state2);
2337
+ return await state2.replace(value, options);
2338
+ }
2339
+ };
2340
+ var applyFunction = async function(func, options = {}) {
2341
+ const state2 = this;
2342
+ if (isFunction(func)) {
2343
+ const result = func(state2);
2344
+ if (result instanceof Promise) await result;
2345
+ else result;
2346
+ return await state2.update(state2.parse(), __spreadValues3({ replace: true }, options));
2347
+ }
2348
+ };
2349
+ var quietUpdate = async function(obj, options = {}) {
2350
+ const state2 = this;
2351
+ return await state2.update(obj, __spreadValues3({ preventUpdate: true }, options));
2352
+ };
2353
+ var replace = async function(obj, options = {}) {
2354
+ const state2 = this;
2355
+ for (const param in obj) {
2356
+ state2[param] = obj[param];
2357
+ }
2358
+ return await state2.update(obj, options);
2359
+ };
2360
+ var quietReplace = async function(obj, options = {}) {
2361
+ const state2 = this;
2362
+ return await state2.replace(obj, __spreadValues3({ preventUpdate: true }, options));
2363
+ };
2364
+ var keys2 = function(obj, options = {}) {
2365
+ const state2 = this;
2366
+ return Object.keys(state2);
2367
+ };
2368
+ var values = function(obj, options = {}) {
2369
+ const state2 = this;
2370
+ return Object.values(state2);
2371
+ };
2372
+
2373
+ // ../../../domql/packages/state/dist/esm/inherit.js
2374
+ var getRootStateInKey = (stateKey, parentState) => {
2375
+ if (!stateKey.includes("~/")) return;
2376
+ const arr = stateKey.split("~/");
2377
+ if (arr.length > 1) return parentState.root;
2378
+ };
2379
+ var getParentStateInKey = (stateKey, parentState) => {
2380
+ if (!stateKey.includes("../")) return;
2381
+ const arr = stateKey.split("../");
2382
+ const arrLength = arr.length - 1;
2383
+ for (let i = 0; i < arrLength; i++) {
2384
+ if (!parentState.parent) return null;
2385
+ parentState = parentState.parent;
2386
+ }
2387
+ return parentState;
2388
+ };
2389
+ var getChildStateInKey = (stateKey, parentState, options = {}) => {
2390
+ const arr = stateKey.split("/");
2391
+ const arrLength = arr.length - 1;
2392
+ for (let i = 0; i < arrLength; i++) {
2393
+ const childKey = arr[i];
2394
+ const grandChildKey = arr[i + 1];
2395
+ if (childKey === "__proto__" || grandChildKey === "__proto__") return;
2396
+ let childInParent = parentState[childKey];
2397
+ if (!childInParent) childInParent = parentState[childKey] = {};
2398
+ if (!childInParent[grandChildKey]) childInParent[grandChildKey] = {};
2399
+ stateKey = grandChildKey;
2400
+ parentState = childInParent;
2401
+ }
2402
+ if (options.returnParent) return parentState;
2403
+ return parentState[stateKey];
2404
+ };
2405
+ var findInheritedState = (element, parent2, options = {}) => {
2406
+ const ref = element.__ref;
2407
+ let stateKey = ref.__state;
2408
+ if (!checkIfInherits(element)) return;
2409
+ const rootState = getRootStateInKey(stateKey, parent2.state);
2410
+ let parentState = parent2.state;
2411
+ if (rootState) {
2412
+ parentState = rootState;
2413
+ stateKey = stateKey.replaceAll("~/", "");
2414
+ } else {
2415
+ const findGrandParentState = getParentStateInKey(stateKey, parent2.state);
2416
+ if (findGrandParentState) {
2417
+ parentState = findGrandParentState;
2418
+ stateKey = stateKey.replaceAll("../", "");
2419
+ }
2420
+ }
2421
+ if (!parentState) return;
2422
+ return getChildStateInKey(stateKey, parentState, options);
2423
+ };
2424
+ var createInheritedState = (element, parent2) => {
2425
+ const ref = element.__ref;
2426
+ const inheritedState = findInheritedState(element, parent2);
2427
+ if (isUndefined(inheritedState)) return element.state;
2428
+ if (is(inheritedState)("object", "array")) {
2429
+ return deepClone(inheritedState, { exclude: IGNORE_STATE_PARAMS2 });
2430
+ } else if (is(inheritedState)("string", "number", "boolean")) {
2431
+ ref.__stateType = typeof inheritedState;
2432
+ return { value: inheritedState };
2433
+ }
2434
+ console.warn(ref.__state, "is not present. Replacing with", {});
2435
+ };
2436
+ var checkIfInherits = (element) => {
2437
+ const ref = element.__ref;
2438
+ const stateKey = ref.__state;
2439
+ if (stateKey && is(stateKey)("number", "string", "boolean")) return true;
2440
+ return false;
2441
+ };
2442
+ var createNestedObjectByKeyPath = (path, value) => {
2443
+ if (!path) {
2444
+ return value || {};
2445
+ }
2446
+ const keys3 = path.split("/");
2447
+ const obj = {};
2448
+ let ref = obj;
2449
+ keys3.forEach((key, index) => {
2450
+ ref[key] = index === keys3.length - 1 ? value || {} : {};
2451
+ ref = ref[key];
2452
+ });
2453
+ return obj;
2454
+ };
2455
+
2456
+ // ../../../domql/packages/state/dist/esm/updateState.js
2457
+ var __defProp5 = Object.defineProperty;
2458
+ var __defProps4 = Object.defineProperties;
2459
+ var __getOwnPropDescs4 = Object.getOwnPropertyDescriptors;
2460
+ var __getOwnPropSymbols4 = Object.getOwnPropertySymbols;
2461
+ var __hasOwnProp5 = Object.prototype.hasOwnProperty;
2462
+ var __propIsEnum4 = Object.prototype.propertyIsEnumerable;
2463
+ var __defNormalProp4 = (obj, key, value) => key in obj ? __defProp5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2464
+ var __spreadValues4 = (a, b) => {
2465
+ for (var prop in b || (b = {}))
2466
+ if (__hasOwnProp5.call(b, prop))
2467
+ __defNormalProp4(a, prop, b[prop]);
2468
+ if (__getOwnPropSymbols4)
2469
+ for (var prop of __getOwnPropSymbols4(b)) {
2470
+ if (__propIsEnum4.call(b, prop))
2471
+ __defNormalProp4(a, prop, b[prop]);
2472
+ }
2473
+ return a;
2474
+ };
2475
+ var __spreadProps4 = (a, b) => __defProps4(a, __getOwnPropDescs4(b));
2476
+ var STATE_UPDATE_OPTIONS = {
2477
+ overwrite: true,
2478
+ preventHoistElementUpdate: false,
2479
+ updateByState: true,
2480
+ isHoisted: true
2481
+ };
2482
+ var updateState = async function(obj, options = STATE_UPDATE_OPTIONS) {
2483
+ const state2 = this;
2484
+ const element = state2.__element;
2485
+ if (options.onEach) options.onEach(element, state2, element.context, options);
2486
+ if (!options.updateByState) merge(options, STATE_UPDATE_OPTIONS);
2487
+ if (!state2.__element) report("ElementOnStateIsNotDefined");
2488
+ if (options.preventInheritAtCurrentState === true) {
2489
+ options.preventInheritAtCurrentState = state2;
2490
+ } else if (options.preventInheritAtCurrentState) return;
2491
+ if (!options.preventBeforeStateUpdateListener) {
2492
+ const beforeStateUpdateReturns = await triggerEventOnUpdate(
2493
+ "beforeStateUpdate",
2494
+ obj,
2495
+ element,
2496
+ options
2497
+ );
2498
+ if (beforeStateUpdateReturns === false) return element;
2499
+ }
2500
+ applyOverwrite(state2, obj, options);
2501
+ const updateIsHoisted = await hoistStateUpdate(state2, obj, options);
2502
+ if (updateIsHoisted) return state2;
2503
+ await updateDependentState(state2, obj, options);
2504
+ const updated = await applyElementUpdate(state2, obj, options);
2505
+ if (updated === false) return false;
2506
+ if (!options.preventStateUpdateListener) {
2507
+ await triggerEventOnUpdate("stateUpdate", obj, element, options);
2508
+ }
2509
+ return state2;
2510
+ };
2511
+ var applyOverwrite = (state2, obj, options) => {
2512
+ const { overwrite: overwrite3 } = options;
2513
+ if (!overwrite3) return;
2514
+ const shallow = overwrite3 === "shallow" || overwrite3 === "shallow-once";
2515
+ const merge2 = overwrite3 === "merge";
2516
+ if (merge2) {
2517
+ deepMerge(state2, obj, IGNORE_STATE_PARAMS2);
2518
+ return;
2519
+ }
2520
+ const overwriteFunc = shallow ? overwriteShallow : overwriteDeep;
2521
+ if (options.overwrite === "shallow-once") options.overwrite = true;
2522
+ overwriteFunc(state2, obj, IGNORE_STATE_PARAMS2);
2523
+ };
2524
+ var hoistStateUpdate = async (state2, obj, options) => {
2525
+ const element = state2.__element;
2526
+ const { parent: parent2, __ref: ref } = element;
2527
+ const stateKey = ref == null ? void 0 : ref.__state;
2528
+ const stateType = ref == null ? void 0 : ref.__stateType;
2529
+ if (!stateKey) return;
2530
+ const asksForInherit = checkIfInherits(element);
2531
+ const inheritedState = findInheritedState(element, parent2, {
2532
+ returnParent: true
2533
+ });
2534
+ const shouldPropagateState = asksForInherit && inheritedState && !options.stopStatePropagation;
2535
+ if (!shouldPropagateState) return;
2536
+ const isStringState = stateType === "string" || stateType === "number" || stateType === "boolean";
2537
+ const value = isStringState ? state2.value : state2.parse();
2538
+ const passedValue = isStringState ? state2.value : obj;
2539
+ const findRootState = getRootStateInKey(stateKey, parent2.state);
2540
+ const findGrandParentState = getParentStateInKey(stateKey, parent2.state);
2541
+ const changesValue = createNestedObjectByKeyPath(stateKey, passedValue);
2542
+ const targetParent = findRootState || findGrandParentState || parent2.state;
2543
+ if (options.replace) overwriteDeep(targetParent, changesValue || value);
2544
+ await targetParent.update(changesValue, __spreadValues4({
2545
+ isHoisted: true,
2546
+ preventUpdate: options.preventHoistElementUpdate,
2547
+ overwrite: !options.replace
2548
+ }, options));
2549
+ const hasNotUpdated = options.preventUpdate !== true || !options.preventHoistElementUpdate;
2550
+ if (!options.preventStateUpdateListener && hasNotUpdated) {
2551
+ await triggerEventOnUpdate("stateUpdate", obj, element, options);
2552
+ }
2553
+ return true;
2554
+ };
2555
+ var updateDependentState = async (state2, obj, options) => {
2556
+ if (!state2.__depends) return;
2557
+ for (const el in state2.__depends) {
2558
+ const dependentState = state2.__depends[el];
2559
+ await dependentState.set(state2.parse(), options);
2560
+ }
2561
+ };
2562
+ var applyElementUpdate = async (state2, obj, options) => {
2563
+ const element = state2.__element;
2564
+ if (options.preventUpdate !== true) {
2565
+ return await element.update(
2566
+ {},
2567
+ __spreadProps4(__spreadValues4({}, options), {
2568
+ updateByState: true
2569
+ })
2570
+ );
2571
+ } else if (options.preventUpdate === "recursive") {
2572
+ return await element.update(
2573
+ {},
2574
+ __spreadProps4(__spreadValues4({}, options), {
2575
+ isHoisted: false,
2576
+ updateByState: true,
2577
+ preventUpdate: true
2578
+ })
2579
+ );
2580
+ }
2581
+ };
2582
+
2583
+ // ../../../domql/packages/state/dist/esm/create.js
2584
+ var __defProp6 = Object.defineProperty;
2585
+ var __defProps5 = Object.defineProperties;
2586
+ var __getOwnPropDescs5 = Object.getOwnPropertyDescriptors;
2587
+ var __getOwnPropSymbols5 = Object.getOwnPropertySymbols;
2588
+ var __hasOwnProp6 = Object.prototype.hasOwnProperty;
2589
+ var __propIsEnum5 = Object.prototype.propertyIsEnumerable;
2590
+ var __defNormalProp5 = (obj, key, value) => key in obj ? __defProp6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2591
+ var __spreadValues5 = (a, b) => {
2592
+ for (var prop in b || (b = {}))
2593
+ if (__hasOwnProp6.call(b, prop))
2594
+ __defNormalProp5(a, prop, b[prop]);
2595
+ if (__getOwnPropSymbols5)
2596
+ for (var prop of __getOwnPropSymbols5(b)) {
2597
+ if (__propIsEnum5.call(b, prop))
2598
+ __defNormalProp5(a, prop, b[prop]);
2599
+ }
2600
+ return a;
2601
+ };
2602
+ var __spreadProps5 = (a, b) => __defProps5(a, __getOwnPropDescs5(b));
2603
+ var createState = async function(element, parent2, options) {
2604
+ element.state = await applyInitialState(element, parent2, options);
2605
+ return element.state;
2606
+ };
2607
+ var applyInitialState = async function(element, parent2, options) {
2608
+ const objectizeState = await checkForTypes(element);
2609
+ if (objectizeState === false) return parent2.state || {};
2610
+ else element.state = objectizeState;
2611
+ const whatInitReturns = await triggerEventOn("stateInit", element, options);
2612
+ if (whatInitReturns === false) return element.state;
2613
+ if (checkIfInherits(element)) {
2614
+ const inheritedState = createInheritedState(element, parent2);
2615
+ element.state = isUndefined(inheritedState) ? {} : inheritedState;
2616
+ }
2617
+ const dependentState = applyDependentState(
2618
+ element,
2619
+ element.state || parent2.state || {}
2620
+ );
2621
+ if (dependentState) element.state = dependentState;
2622
+ applyMethods(element);
2623
+ await triggerEventOn("stateCreated", element, options);
2624
+ return element.state;
2625
+ };
2626
+ var applyDependentState = (element, state2) => {
2627
+ const { __ref, ref, __element } = state2;
2628
+ const origState = exec(__ref || ref || (__element == null ? void 0 : __element.state), element);
2629
+ if (!origState) return;
2630
+ const dependentState = deepClone(origState, IGNORE_STATE_PARAMS2);
2631
+ const newDepends = { [element.key + Math.random()]: dependentState };
2632
+ const __depends = isObject(origState.__depends) ? __spreadValues5(__spreadValues5({}, origState.__depends), newDepends) : newDepends;
2633
+ if (Array.isArray(origState)) {
2634
+ addProtoToArray(origState, __spreadProps5(__spreadValues5({}, Object.getPrototypeOf(origState)), {
2635
+ __depends
2636
+ }));
2637
+ } else {
2638
+ Object.setPrototypeOf(origState, __spreadProps5(__spreadValues5({}, Object.getPrototypeOf(origState)), {
2639
+ __depends
2640
+ }));
2641
+ }
2642
+ return dependentState;
2643
+ };
2644
+ var checkForTypes = async (element) => {
2645
+ const { state: orig, props, __ref: ref } = element;
2646
+ const state2 = (props == null ? void 0 : props.state) || orig;
2647
+ if (isFunction(state2)) {
2648
+ ref.__state = state2;
2649
+ return await exec(state2, element);
2650
+ } else if (is(state2)("string", "number")) {
2651
+ ref.__state = state2;
2652
+ return { value: state2 };
2653
+ } else if (state2 === true) {
2654
+ ref.__state = element.key;
2655
+ return {};
2656
+ } else if (state2) {
2657
+ ref.__hasRootState = true;
2658
+ return state2;
2659
+ } else {
2660
+ return false;
2661
+ }
2662
+ };
2663
+ var addProtoToArray = (state2, proto) => {
2664
+ for (const key in proto) {
2665
+ Object.defineProperty(state2, key, {
2666
+ value: proto[key],
2667
+ enumerable: false,
2668
+ // Set this to true if you want the method to appear in for...in loops
2669
+ configurable: true,
2670
+ // Set this to true if you want to allow redefining/removing the property later
2671
+ writable: true
2672
+ // Set this to true if you want to allow changing the function later
2673
+ });
2674
+ }
2675
+ };
2676
+ var applyMethods = (element) => {
2677
+ const state2 = element.state;
2678
+ const ref = element.__ref;
2679
+ const proto = {
2680
+ clean: clean.bind(state2),
2681
+ parse: parse2.bind(state2),
2682
+ destroy: destroy.bind(state2),
2683
+ update: updateState.bind(state2),
2684
+ rootUpdate: rootUpdate.bind(state2),
2685
+ parentUpdate: parentUpdate.bind(state2),
2686
+ create: createState.bind(state2),
2687
+ add: add.bind(state2),
2688
+ toggle: toggle.bind(state2),
2689
+ remove: remove2.bind(state2),
2690
+ apply: apply.bind(state2),
2691
+ applyReplace: applyReplace.bind(state2),
2692
+ applyFunction: applyFunction.bind(state2),
2693
+ set: set.bind(state2),
2694
+ quietUpdate: quietUpdate.bind(state2),
2695
+ replace: replace.bind(state2),
2696
+ quietReplace: quietReplace.bind(state2),
2697
+ reset: reset.bind(state2),
2698
+ parent: element.parent.state || state2,
2699
+ setByPath: setByPath.bind(state2),
2700
+ setPathCollection: setPathCollection.bind(state2),
2701
+ removeByPath: removeByPath.bind(state2),
2702
+ removePathCollection: removePathCollection.bind(state2),
2703
+ getByPath: getByPath.bind(state2),
2704
+ keys: keys2.bind(state2),
2705
+ values: values.bind(state2),
2706
+ __element: element,
2707
+ __children: {},
2708
+ root: ref.root ? ref.root.state : state2
2709
+ };
2710
+ if (isArray(state2)) {
2711
+ addProtoToArray(state2, proto);
2712
+ } else {
2713
+ Object.setPrototypeOf(state2, proto);
2714
+ }
2715
+ if (state2.parent && state2.parent.__children) {
2716
+ state2.parent.__children[element.key] = state2;
2717
+ }
2718
+ };
2719
+
2720
+ // ../../../domql/packages/element/update.js
2721
+ var snapshot = {
2722
+ snapshotId: createSnapshotId
2723
+ };
2724
+ var UPDATE_DEFAULT_OPTIONS = {
2725
+ stackChanges: false,
2726
+ cleanExec: true,
2727
+ preventRecursive: false,
2728
+ currentSnapshot: false,
2729
+ calleeElement: false,
2730
+ excludes: METHODS_EXL
2731
+ };
2732
+ var update2 = async function(params = {}, opts) {
2733
+ const calleeElementCache = opts == null ? void 0 : opts.calleeElement;
2734
+ const options = deepClone(
2735
+ typeof opts === "object" ? deepMerge2(opts, UPDATE_DEFAULT_OPTIONS) : UPDATE_DEFAULT_OPTIONS,
2736
+ { exclude: ["calleeElement", "updatingCalleeElement"] }
2737
+ );
2738
+ const element = this;
2739
+ options.calleeElement = calleeElementCache;
2740
+ const { parent: parent2, node, key } = element;
2741
+ const { excludes, preventInheritAtCurrentState } = options;
2742
+ let ref = element.__ref;
2743
+ if (!ref) ref = element.__ref = {};
2744
+ const [snapshotOnCallee, calleeElement, snapshotHasUpdated] = captureSnapshot(
2745
+ element,
2746
+ options
2747
+ );
2748
+ if (snapshotHasUpdated) return false;
2749
+ if (checkIfStorm(element, options)) return false;
2750
+ if (!options.preventListeners)
2751
+ await triggerEventOn("eventStart", element, options);
2752
+ if (!options.preventListeners)
2753
+ await triggerEventOnUpdate("startUpdate", params, element, options);
2754
+ if (preventInheritAtCurrentState && preventInheritAtCurrentState.__element === element)
2755
+ return false;
2756
+ if (!excludes) merge(options, UPDATE_DEFAULT_OPTIONS);
2757
+ if (isString(params) || isNumber(params)) {
2758
+ params = { text: params };
2759
+ }
2760
+ const inheritState = await inheritStateUpdates(element, options);
2761
+ if (inheritState === false) return false;
2762
+ const ifFails = checkIfOnUpdate(element, parent2, options);
2763
+ if (ifFails) return false;
2764
+ if (ref.__if && !options.preventPropsUpdate) {
2765
+ const hasParentProps = parent2.props && (parent2.props[key] || parent2.props.childProps);
2766
+ const hasFunctionInProps = ref.__props.filter((v) => isFunction(v));
2767
+ const props = params.props || hasParentProps || hasFunctionInProps.length;
2768
+ if (props) updateProps(props, element, parent2, options);
2769
+ }
2770
+ if (!options.preventBeforeUpdateListener && !options.preventListeners) {
2771
+ const beforeUpdateReturns = await triggerEventOnUpdate(
2772
+ "beforeUpdate",
2773
+ params,
2774
+ element,
2775
+ options
2776
+ );
2777
+ if (beforeUpdateReturns === false) return element;
2778
+ }
2779
+ overwriteDeep(element, params, { exclude: METHODS_EXL });
2780
+ throughExecProps(element, options);
2781
+ await throughUpdatedExec(element, { ignore: UPDATE_DEFAULT_OPTIONS });
2782
+ await throughUpdatedDefine(element, options);
2783
+ if (!options.isForced && !options.preventListeners) {
2784
+ await triggerEventOn("beforeClassAssign", element, options);
2785
+ }
2786
+ if (!ref.__if) return false;
2787
+ if (!node) {
2788
+ return false;
2789
+ }
2790
+ if (element.tag !== "fragment" && !document.body.contains(node)) {
2791
+ }
2792
+ const {
2793
+ preventUpdate,
2794
+ preventDefineUpdate,
2795
+ preventContentUpdate,
2796
+ preventStateUpdate,
2797
+ preventRecursive,
2798
+ preventUpdateListener,
2799
+ preventUpdateAfter,
2800
+ preventUpdateAfterCount
2801
+ } = options;
2802
+ if (preventUpdateAfter) {
2803
+ if (isNumber(preventUpdateAfterCount) && preventUpdateAfter <= preventUpdateAfterCount)
2804
+ return;
2805
+ else if (options.preventUpdateAfterCount === void 0)
2806
+ options.preventUpdateAfterCount = 1;
2807
+ else options.preventUpdateAfterCount++;
2808
+ }
2809
+ const keys3 = Object.keys(element);
2810
+ for (const param of keys3) {
2811
+ const prop = element[param];
2812
+ if (!Object.hasOwnProperty.call(element, param)) continue;
2813
+ const isInPreventUpdate = isArray(preventUpdate) && preventUpdate.includes(param);
2814
+ const isInPreventDefineUpdate = isArray(preventDefineUpdate) && preventDefineUpdate.includes(param);
2815
+ const hasCollection = element.$collection || element.$stateCollection || element.$propsCollection;
2816
+ if (isUndefined(prop) || isInPreventUpdate || isInPreventDefineUpdate || preventDefineUpdate === true || preventDefineUpdate === param || preventContentUpdate && param === "content" && !hasCollection || (preventStateUpdate && param) === "state" || isMethod(param, element) || isObject(REGISTRY[param]) || isVariant(param))
2817
+ continue;
2818
+ if (preventStateUpdate === "once") options.preventStateUpdate = false;
2819
+ const isElement = await applyParam(param, element, options);
2820
+ if (isElement) {
2821
+ const { hasDefine, hasContextDefine } = isElement;
2822
+ const canUpdate = isObject(prop) && !hasDefine && !hasContextDefine && !preventRecursive;
2823
+ if (!canUpdate) continue;
2824
+ const lazyLoad = element.props.lazyLoad || options.lazyLoad;
2825
+ if (options.onEachUpdate) {
2826
+ options.onEachUpdate(param, element, element.state, element.context);
2827
+ }
2828
+ const childUpdateCall = async () => await update2.call(prop, params[prop], {
2829
+ ...options,
2830
+ currentSnapshot: snapshotOnCallee,
2831
+ calleeElement
2832
+ });
2833
+ lazyLoad ? window2.requestAnimationFrame(async () => {
2834
+ await childUpdateCall();
2835
+ if (!options.preventUpdateListener) {
2836
+ await triggerEventOn("lazyLoad", element, options);
2837
+ }
2838
+ }) : await childUpdateCall();
2839
+ }
2840
+ }
2841
+ if (!options.preventListeners) {
2842
+ if (!preventUpdateListener) await triggerEventOn("update", element, options);
2843
+ await triggerEventOn("eventComplete", element, options);
2844
+ }
2845
+ };
2846
+ var checkIfStorm = (element, options) => {
2847
+ let ref = element.__ref;
2848
+ if (!options.updatingCalleeElement) options.updatingCalleeElement = element;
2849
+ if (ref.__stormAbortion && !options.allowStorm) {
2850
+ const stormAbortion = setTimeout(() => {
2851
+ delete ref.__stormAbortion;
2852
+ clearTimeout(stormAbortion);
2853
+ }, 1e3);
2854
+ element.error("Potential storm update detected", options);
2855
+ return true;
2856
+ }
2857
+ if (element === options.updatingCalleeElement && !options.allowStorm) {
2858
+ if (ref.__selfCallIteration === void 0) ref.__selfCallIteration = 0;
2859
+ else ref.__selfCallIteration++;
2860
+ if (ref.__selfCallIteration > 100) {
2861
+ ref.__selfCallIteration = 0;
2862
+ ref.__stormAbortion = true;
2863
+ element.error("Potential self calling loop in update detected", options);
2864
+ return true;
2865
+ }
2866
+ const stormTimeout = setTimeout(() => {
2867
+ ref.__selfCallIteration = 0;
2868
+ clearTimeout(stormTimeout);
2869
+ }, 350);
2870
+ }
2871
+ };
2872
+ var captureSnapshot = (element, options) => {
2873
+ const ref = element.__ref;
2874
+ const { currentSnapshot, calleeElement } = options;
2875
+ const isCallee = calleeElement === element;
2876
+ if (!calleeElement || isCallee) {
2877
+ const createdStanpshot = snapshot.snapshotId();
2878
+ ref.__currentSnapshot = createdStanpshot;
2879
+ return [createdStanpshot, element];
2880
+ }
2881
+ const snapshotOnCallee = calleeElement.__ref.__currentSnapshot;
2882
+ if (currentSnapshot < snapshotOnCallee) {
2883
+ return [snapshotOnCallee, calleeElement, true];
2884
+ }
2885
+ return [snapshotOnCallee, calleeElement];
2886
+ };
2887
+ var checkIfOnUpdate = (element, parent2, options) => {
2888
+ var _a, _b;
2889
+ const ifFn = ((_a = element.props) == null ? void 0 : _a.if) || element.if;
2890
+ if (!isFunction(ifFn) || !parent2) return;
2891
+ const ref = element.__ref;
2892
+ const ifPassed = ifFn(element, element.state, element.context, options);
2893
+ const itWasFalse = ref.__if !== true;
2894
+ if (ifPassed) {
2895
+ ref.__if = true;
2896
+ if (itWasFalse) {
2897
+ delete element.__hash;
2898
+ delete element.__text;
2899
+ delete element.extend;
2900
+ if (!ref.__hasRootState) {
2901
+ delete element.state;
2902
+ }
2903
+ if (ref.__state) {
2904
+ element.state = ref.__state;
2905
+ } else if (!ref.__hasRootState) {
2906
+ delete element.state;
2907
+ }
2908
+ if (element.node) {
2909
+ element.node.remove();
2910
+ delete element.node;
2911
+ }
2912
+ const contentKey = ref.contentElementKey;
2913
+ if (element.$collection || element.$stateCollection || element.$propsCollection) {
2914
+ element.removeContent();
2915
+ } else if ((_b = element[contentKey]) == null ? void 0 : _b.parseDeep)
2916
+ element[contentKey] = element[contentKey].parseDeep();
2917
+ const previousElement2 = element.previousElement();
2918
+ const previousNode = previousElement2 == null ? void 0 : previousElement2.node;
2919
+ const hasPrevious = previousNode == null ? void 0 : previousNode.parentNode;
2920
+ const nextElement2 = element.nextElement();
2921
+ const nextNode = nextElement2 == null ? void 0 : nextElement2.node;
2922
+ const hasNext = nextNode == null ? void 0 : nextNode.parentNode;
2923
+ const attachOptions = (hasPrevious || hasNext) && {
2924
+ position: hasPrevious ? "after" : hasNext ? "before" : null,
2925
+ node: hasPrevious && previousNode || hasNext && nextNode
2926
+ };
2927
+ delete element.__ref;
2928
+ delete element.parent;
2929
+ const createdElement = create(
2930
+ element,
2931
+ parent2,
2932
+ element.key,
2933
+ OPTIONS.create,
2934
+ attachOptions
2935
+ );
2936
+ if (options.preventUpdate !== true && element.on && isFunction(element.on.update)) {
2937
+ applyEvent(element.on.update, createdElement, createdElement.state);
2938
+ }
2939
+ return createdElement;
2940
+ }
2941
+ } else if (element.node && !ifPassed) {
2942
+ element.node.remove();
2943
+ delete ref.__if;
2944
+ }
2945
+ };
2946
+ var inheritStateUpdates = async (element, options) => {
2947
+ const { __ref: ref } = element;
2948
+ const stateKey = ref.__state;
2949
+ const { parent: parent2 } = element;
2950
+ const { preventUpdateTriggerStateUpdate } = options;
2951
+ if (preventUpdateTriggerStateUpdate) return;
2952
+ if (!stateKey && !ref.__hasRootState) {
2953
+ element.state = parent2 && parent2.state || {};
2954
+ return;
2955
+ }
2956
+ const keyInParentState = findInheritedState(element, element.parent);
2957
+ if (!keyInParentState || options.preventInheritedStateUpdate) return;
2958
+ if (!options.preventBeforeStateUpdateListener && !options.preventListeners) {
2959
+ const initStateReturns = await triggerEventOnUpdate(
2960
+ "beforeStateUpdate",
2961
+ keyInParentState,
2962
+ element,
2963
+ options
2964
+ );
2965
+ if (initStateReturns === false) return element;
2966
+ }
2967
+ const newState = await createStateUpdate(element, parent2, options);
2968
+ if (!options.preventStateUpdateListener && !options.preventListeners) {
2969
+ await triggerEventOnUpdate(
2970
+ "stateUpdate",
2971
+ newState.parse(),
2972
+ element,
2973
+ options
2974
+ );
2975
+ }
2976
+ };
2977
+ var createStateUpdate = async (element, parent2, options) => {
2978
+ const __stateChildren = element.state.__children;
2979
+ const newState = await createState(element, parent2, options);
2980
+ element.state = newState;
2981
+ for (const child in __stateChildren) {
2982
+ if (newState[child]) newState.__children[child] = __stateChildren[child];
2983
+ Object.getPrototypeOf(__stateChildren[child]).parent = newState;
2984
+ }
2985
+ return newState;
2986
+ };
2987
+
2988
+ // ../../../domql/packages/element/methods/set.js
2989
+ var addMethods = (element, parent2, options = {}) => {
2990
+ const proto = {
2991
+ set: set2,
2992
+ reset: reset2,
2993
+ update: update2,
2994
+ variables,
2995
+ remove,
2996
+ updateContent,
2997
+ removeContent,
2998
+ setProps,
2999
+ lookup,
3000
+ lookdown,
3001
+ lookdownAll,
3002
+ getRef,
3003
+ getPath,
3004
+ setNodeStyles,
3005
+ spotByPath,
3006
+ parse,
3007
+ parseDeep,
3008
+ keys,
3009
+ nextElement,
3010
+ previousElement,
3011
+ log,
3012
+ verbose,
3013
+ warn,
3014
+ error,
3015
+ append,
3016
+ call
3017
+ };
3018
+ if (element.context.methods)
3019
+ (options.strict ? merge : overwrite)(proto, element.context.methods);
3020
+ Object.setPrototypeOf(element, proto);
3021
+ };
3022
+
3023
+ // ../../../domql/packages/utils/env.js
3024
+ var NODE_ENV2 = "development";
3025
+ var isProduction2 = (env = NODE_ENV2) => env === "production";
3026
+ var isNotProduction2 = (env = NODE_ENV2) => !isProduction2(env);
3027
+
3028
+ // ../../../domql/packages/element/create.js
3029
+ var create = async (element, parent2, key, options = OPTIONS.create || {}, attachOptions) => {
3030
+ const isValid = validateElement(element, options);
3031
+ if (!isValid) {
3032
+ error.call(
3033
+ element,
3034
+ "Error while creating element: Not valid type",
3035
+ element,
3036
+ options
3037
+ );
3038
+ return;
3039
+ }
3040
+ cacheOptions(element, options);
3041
+ if (checkIfPrimitive(element)) {
3042
+ element = applyValueAsText(element, parent2, key);
3043
+ }
3044
+ element = redefineElement(element, parent2, key, options);
3045
+ parent2 = redefineParent(element, parent2, key);
3046
+ key = createKey(element, parent2, key);
3047
+ const ref = addRef(element, parent2, key);
3048
+ ref.__initialProps = deepClone(element.props);
3049
+ applyContext(element, parent2, options);
3050
+ applyComponentFromContext(element, parent2, options);
3051
+ if (!ref.__skipCreate) {
3052
+ applyExtend(element, parent2, options);
3053
+ }
3054
+ element.key = key;
3055
+ if (options.onlyResolveExtends) {
3056
+ return await onlyResolveExtends(element, parent2, key, options);
3057
+ }
3058
+ await triggerEventOn("eventStart", element, options);
3059
+ await triggerEventOn("start", element, options);
3060
+ switchDefaultOptions(element, parent2, options);
3061
+ addCaching(element, parent2, options);
3062
+ addMethods(element, parent2, options);
3063
+ createScope(element, parent2, options);
3064
+ await createState(element, parent2, options);
3065
+ if (element.scope === "state") element.scope = element.state;
3066
+ createIfConditionFlag(element, parent2);
3067
+ createProps(element, parent2, options);
3068
+ if (element.scope === "props" || element.scope === true)
3069
+ element.scope = element.props;
3070
+ createIfConditionFlag(element, parent2);
3071
+ if (element.node && ref.__if) {
3072
+ return assignNode(element, parent2, key, attachOptions);
3073
+ }
3074
+ applyVariant(element, parent2);
3075
+ addChildrenIfNotInOriginal(element, parent2, key);
3076
+ const onInit = await triggerEventOn("init", element, options);
3077
+ if (onInit === false) return element;
3078
+ const onEventInit = await triggerEventOn("eventInit", element, options);
3079
+ if (onEventInit === false) return element;
3080
+ await triggerEventOn("beforeClassAssign", element, options);
3081
+ assignKeyAsClassname(element);
3082
+ await renderElement(element, parent2, options, attachOptions);
3083
+ addElementIntoParentChildren(element, parent2);
3084
+ await triggerEventOn("complete", element, options);
3085
+ await triggerEventOn("eventComplete", element, options);
3086
+ return element;
3087
+ };
3088
+ var createBasedOnType = (element, parent2, key, options) => {
3089
+ if (element === void 0) {
3090
+ if (isNotProduction2()) {
3091
+ console.warn(
3092
+ key,
3093
+ "element is undefined in",
3094
+ parent2 && parent2.__ref && parent2.__ref.path
3095
+ );
3096
+ }
3097
+ return {};
3098
+ }
3099
+ if (isString(key) && key.slice(0, false)) {
3100
+ if (isNotProduction2()) {
3101
+ console.warn(key, "seems like to be in __ref");
3102
+ }
3103
+ }
3104
+ if (element === null) return;
3105
+ if (element === true) return { text: true };
3106
+ if (element.__hash) {
3107
+ return { extend: element };
3108
+ }
3109
+ if (typeof Node !== "undefined" && element instanceof Node || typeof DocumentFragment !== "undefined" && element instanceof DocumentFragment)
3110
+ return { node: element };
3111
+ return element;
3112
+ };
3113
+ var redefineElement = (element, parent2, key, options) => {
3114
+ const elementWrapper = createBasedOnType(element, parent2, key, options);
3115
+ if (options.syntaxv3 || element.props && element.props.syntaxv3 || parent2 && parent2.props && parent2.props.syntaxv3) {
3116
+ if (element.props) element.props.syntaxv3 = true;
3117
+ else element.syntaxv3 = true;
3118
+ return createValidDomqlObjectFromSugar(element, parent2, key, options);
3119
+ } else if (checkIfKeyIsComponent(key)) {
3120
+ return applyKeyComponentAsExtend(elementWrapper, parent2, key);
3121
+ }
3122
+ if (checkIfMedia(key)) {
3123
+ return applyMediaProps(elementWrapper, parent2, key);
3124
+ }
3125
+ return elementWrapper;
3126
+ };
3127
+ var redefineParent = (element, parent2, key, options) => {
3128
+ if (!parent2) return ROOT;
3129
+ if (isNode(parent2)) {
3130
+ const parentNodeWrapper = { key: ":root", node: parent2 };
3131
+ ROOT[`${key}_parent`] = parentNodeWrapper;
3132
+ return parentNodeWrapper;
3133
+ }
3134
+ return parent2;
3135
+ };
3136
+ var validateElement = (value, options) => {
3137
+ if (value == null) return false;
3138
+ const t = typeof value;
3139
+ if (t === "function" || t === "symbol" || t === "bigint") return false;
3140
+ if (Number.isNaN(value) || value === Infinity || value === -Infinity)
3141
+ return false;
3142
+ const unsafeGlobals = [
3143
+ typeof window !== "undefined" && window,
3144
+ typeof document !== "undefined" && document,
3145
+ typeof globalThis !== "undefined" && globalThis,
3146
+ typeof navigator !== "undefined" && navigator,
3147
+ typeof location !== "undefined" && location,
3148
+ typeof history !== "undefined" && history,
3149
+ typeof screen !== "undefined" && screen,
3150
+ typeof frames !== "undefined" && frames,
3151
+ typeof parent !== "undefined" && parent,
3152
+ typeof self !== "undefined" && self,
3153
+ typeof top !== "undefined" && top,
3154
+ typeof performance !== "undefined" && performance,
3155
+ typeof console !== "undefined" && console,
3156
+ typeof indexedDB !== "undefined" && indexedDB,
3157
+ typeof caches !== "undefined" && caches,
3158
+ typeof localStorage !== "undefined" && localStorage,
3159
+ typeof sessionStorage !== "undefined" && sessionStorage,
3160
+ typeof crypto !== "undefined" && crypto,
3161
+ typeof visualViewport !== "undefined" && visualViewport,
3162
+ typeof customElements !== "undefined" && customElements
3163
+ ].filter(Boolean);
3164
+ if (unsafeGlobals.includes(value)) return false;
3165
+ if (typeof EventTarget !== "undefined" && value instanceof EventTarget)
3166
+ return false;
3167
+ if (typeof Event !== "undefined" && value instanceof Event) return false;
3168
+ if (value === Object.prototype || value === Array.prototype || value === Function.prototype || value === Map.prototype || value === Set.prototype || value === WeakMap.prototype || value === WeakSet.prototype || value === Promise.prototype || value === Symbol.prototype)
3169
+ return false;
3170
+ const unsafeConstructors = [
3171
+ typeof Worker !== "undefined" && Worker,
3172
+ typeof SharedWorker !== "undefined" && SharedWorker,
3173
+ typeof MessagePort !== "undefined" && MessagePort,
3174
+ typeof BroadcastChannel !== "undefined" && BroadcastChannel,
3175
+ typeof ReadableStream !== "undefined" && ReadableStream,
3176
+ typeof WritableStream !== "undefined" && WritableStream,
3177
+ typeof TransformStream !== "undefined" && TransformStream,
3178
+ typeof File !== "undefined" && File,
3179
+ typeof Blob !== "undefined" && Blob,
3180
+ typeof FormData !== "undefined" && FormData,
3181
+ typeof XMLHttpRequest !== "undefined" && XMLHttpRequest,
3182
+ typeof AbortController !== "undefined" && AbortController,
3183
+ typeof AbortSignal !== "undefined" && AbortSignal
3184
+ ].filter(Boolean);
3185
+ for (const Ctor of unsafeConstructors) {
3186
+ if (value instanceof Ctor) return false;
3187
+ }
3188
+ return true;
3189
+ };
3190
+ var cacheOptions = (element, options) => {
3191
+ if (options && !OPTIONS.create) {
3192
+ OPTIONS.create = options;
3193
+ OPTIONS.create.context = element.context || options.context;
3194
+ }
3195
+ };
3196
+ var createKey = (element, parent2, key) => {
3197
+ return (exec(key, element) || key || element.key || generateKey()).toString();
3198
+ };
3199
+ var addRef = (element, parent2) => {
3200
+ if (element.__ref) element.__ref.origin = element;
3201
+ else element.__ref = { origin: element };
3202
+ return element.__ref;
3203
+ };
3204
+ var switchDefaultOptions = (element, parent2, options) => {
3205
+ if (Object.keys(options).length) {
3206
+ REGISTRY.defaultOptions = options;
3207
+ if (options.ignoreChildExtend) delete options.ignoreChildExtend;
3208
+ }
3209
+ };
3210
+ var addElementIntoParentChildren = (element, parent2) => {
3211
+ if (parent2.__ref && parent2.__ref.__children)
3212
+ parent2.__ref.__children.push(element.key);
3213
+ };
3214
+ var visitedElements = /* @__PURE__ */ new WeakMap();
3215
+ var renderElement = async (element, parent2, options, attachOptions) => {
3216
+ var _a, _b, _c, _d;
3217
+ if (visitedElements.has(element)) {
3218
+ if (isNotProduction2())
3219
+ console.warn("Cyclic rendering detected:", element.__ref.path);
3220
+ }
3221
+ visitedElements.set(element, true);
3222
+ const { __ref: ref, key } = element;
3223
+ const createNestedChild = async () => {
3224
+ const isInfiniteLoopDetected = detectInfiniteLoop(ref.path);
3225
+ if (ref.__uniqId || isInfiniteLoopDetected) return;
3226
+ await createNode(element, options);
3227
+ ref.__uniqId = Math.random();
3228
+ };
3229
+ if (isNotProduction2()) {
3230
+ await createNestedChild();
3231
+ } else {
3232
+ try {
3233
+ await createNestedChild();
3234
+ } catch (e) {
3235
+ const path = ref.path;
3236
+ if (path.includes("ComponentsGrid"))
3237
+ path.splice(0, path.indexOf("ComponentsGrid") + 2);
3238
+ if (path.includes("demoComponent"))
3239
+ path.splice(0, path.indexOf("demoComponent") + 1);
3240
+ const isDemoComponent = (_b = (_a = element.lookup((el) => el.state.key)) == null ? void 0 : _a.state) == null ? void 0 : _b.key;
3241
+ element.warn(
3242
+ "Error happened in:",
3243
+ isDemoComponent ? isDemoComponent + " " : "" + path.join(".")
3244
+ );
3245
+ element.verbose();
3246
+ element.error(e, options);
3247
+ if ((_c = element.on) == null ? void 0 : _c.error)
3248
+ element.on.error(e, element, element.state, element.context, options);
3249
+ if ((_d = element.props) == null ? void 0 : _d.onError)
3250
+ element.props.onError(
3251
+ e,
3252
+ element,
3253
+ element.state,
3254
+ element.context,
3255
+ options
3256
+ );
3257
+ }
3258
+ }
3259
+ if (!ref.__if) {
3260
+ parent2[key || element.key] = element;
3261
+ return element;
3262
+ }
3263
+ assignNode(element, parent2, key, attachOptions);
3264
+ applyAnimationFrame(element, options);
3265
+ await triggerEventOn("render", element, options);
3266
+ await triggerEventOn("renderRouter", element, options);
3267
+ await triggerEventOn("done", element, options);
3268
+ await triggerEventOn("create", element, options);
3269
+ };
3270
+ var checkIfPrimitive = (element) => is(element)("string", "number");
3271
+ var applyValueAsText = (element, parent2, key) => {
3272
+ const extendTag = element.extend && element.extend.tag;
3273
+ const childExtendTag = parent2.childExtend && parent2.childExtend.tag;
3274
+ const childPropsTag = parent2.props.childProps && parent2.props.childProps.tag;
3275
+ const isKeyValidHTMLTag = HTML_TAGS.body.indexOf(key) > -1 && key;
3276
+ return {
3277
+ text: element,
3278
+ tag: extendTag || childExtendTag || childPropsTag || isKeyValidHTMLTag || "string"
3279
+ };
3280
+ };
3281
+ var applyContext = (element, parent2, options) => {
3282
+ const forcedOptionsContext = options.context && !ROOT.context && !element.context;
3283
+ if (forcedOptionsContext) ROOT.context = options.context;
3284
+ if (!element.context)
3285
+ element.context = parent2.context || options.context || ROOT.context;
3286
+ };
3287
+ var createScope = (element, parent2) => {
3288
+ const { __ref: ref } = element;
3289
+ if (!element.scope) element.scope = parent2.scope || ref.root.scope || {};
3290
+ };
3291
+ var createIfConditionFlag = (element, parent2) => {
3292
+ var _a;
3293
+ const { __ref: ref } = element;
3294
+ const ifFn = ((_a = element.props) == null ? void 0 : _a.if) || element.if;
3295
+ if (isFunction(ifFn) && !ifFn(element, element.state, element.context)) {
3296
+ delete ref.__if;
3297
+ } else ref.__if = true;
3298
+ };
3299
+ var addCaching = (element, parent2) => {
3300
+ const { __ref: ref, key } = element;
3301
+ let { __ref: parentRef } = parent2;
3302
+ if (!element.transform) element.transform = {};
3303
+ if (!ref.__cached) ref.__cached = {};
3304
+ if (!ref.__cachedContent) ref.__cachedContent = null;
3305
+ if (!ref.__defineCache) ref.__defineCache = {};
3306
+ if (!ref.__exec) ref.__exec = {};
3307
+ if (!ref.__execProps) ref.__execProps = {};
3308
+ if (!ref.__class) ref.__class = {};
3309
+ if (!ref.__classNames) ref.__classNames = {};
3310
+ if (!ref.__attr) ref.__attr = {};
3311
+ if (!ref.__changes) ref.__changes = [];
3312
+ if (!ref.__children) ref.__children = [];
3313
+ if (checkIfKeyIsComponent(key))
3314
+ ref.__componentKey = key.split("_")[0].split(".")[0].split("+")[0];
3315
+ const hasRoot = parent2 && parent2.key === ":root";
3316
+ if (!ref.root) ref.root = hasRoot ? element : parentRef.root;
3317
+ if (!parentRef) parentRef = parent2.ref = {};
3318
+ if (!parentRef.path) parentRef.path = [];
3319
+ ref.path = parentRef.path.concat(element.key);
3320
+ };
3321
+ var onlyResolveExtends = async (element, parent2, key, options) => {
3322
+ const { __ref: ref } = element;
3323
+ if (!ref.__skipCreate) {
3324
+ addCaching(element, parent2);
3325
+ addMethods(element, parent2, options);
3326
+ createScope(element, parent2);
3327
+ createState(element, parent2, options);
3328
+ if (element.scope === "state") element.scope = element.state;
3329
+ createIfConditionFlag(element, parent2);
3330
+ createProps(element, parent2, options);
3331
+ if (element.scope === "props" || element.scope === true)
3332
+ element.scope = element.props;
3333
+ if (element.node && ref.__if) {
3334
+ parent2[key || element.key] = element;
3335
+ }
3336
+ if (!element.props) element.props = {};
3337
+ applyVariant(element, parent2);
3338
+ addElementIntoParentChildren(element, parent2);
3339
+ }
3340
+ if (element.tag !== "string" && element.tag !== "fragment") {
3341
+ await throughInitialDefine(element);
3342
+ await throughInitialExec(element);
3343
+ for (const k in element) {
3344
+ if (isUndefined(element[k]) || isMethod(k, element) || isObject((REGISTRY.default || REGISTRY)[k]) || isVariant(k))
3345
+ continue;
3346
+ const hasDefine = element.define && element.define[k];
3347
+ const contextHasDefine = element.context && element.context.define && element.context.define[k];
3348
+ const optionsHasDefine = options.define && options.define[k];
3349
+ if (!ref.__skipCreate && REGISTRY[k] && !optionsHasDefine) {
3350
+ continue;
3351
+ } else if (element[k] && !hasDefine && !optionsHasDefine && !contextHasDefine) {
3352
+ create(exec(element[k], element), element, k, options);
3353
+ }
3354
+ }
3355
+ }
3356
+ parent2[key || element.key] = element;
3357
+ delete element.update;
3358
+ delete element.__element;
3359
+ if (element.props) {
3360
+ delete element.props.update;
3361
+ delete element.props.__element;
3362
+ }
3363
+ return element;
3364
+ };
3365
+ var checkIfMedia = (key) => key.slice(0, 1) === "@";
3366
+ var applyMediaProps = (element, parent2, key) => {
3367
+ const { props } = element;
3368
+ if (props) {
3369
+ props.display = "none";
3370
+ if (props[key]) props[key].display = props.display;
3371
+ else props[key] = { display: props.display || "block" };
3372
+ return element;
3373
+ } else {
3374
+ return {
3375
+ ...element,
3376
+ props: {
3377
+ display: "none",
3378
+ [key]: { display: "block" }
3379
+ }
3380
+ };
3381
+ }
3382
+ };
3383
+
3384
+ // ../../../domql/packages/element/set.js
3385
+ var resetElement = async (params, element, options) => {
3386
+ if (!options.preventRemove) removeContent(element, options);
3387
+ const { __ref: ref } = element;
3388
+ const newContent = await create(
3389
+ params,
3390
+ element,
3391
+ ref.contentElementKey || "content",
3392
+ {
3393
+ ignoreChildExtend: true,
3394
+ ...REGISTRY.defaultOptions,
3395
+ ...OPTIONS.create,
3396
+ ...options
3397
+ }
3398
+ );
3399
+ ref.__cachedContent = newContent;
3400
+ };
3401
+ var reset2 = async (options) => {
3402
+ const element = void 0;
3403
+ await create(element, element.parent, void 0, {
3404
+ ignoreChildExtend: true,
3405
+ ...REGISTRY.defaultOptions,
3406
+ ...OPTIONS.create,
3407
+ ...options
3408
+ });
3409
+ };
3410
+ var set2 = async function(params, options = {}, el) {
3411
+ var _a, _b, _c, _d;
3412
+ const element = el || this;
3413
+ const { __ref: ref } = element;
3414
+ if (options.preventContentUpdate || options.preventUpdate && ((_b = (_a = options.preventUpdate).includes) == null ? void 0 : _b.call(_a, "content")))
3415
+ return;
3416
+ if (options.routerContentElement && options.lastElement) {
3417
+ if (options.routerContentElement !== options.lastElement.content) return;
3418
+ }
3419
+ const contentKey = setContentKey(element, options);
3420
+ const content = element[contentKey];
3421
+ const __contentRef = content && content.__ref;
3422
+ const lazyLoad = element.props && element.props.lazyLoad;
3423
+ const hasCollection = element.$collection || element.$stateCollection || element.$propsCollection || ((_c = element.props) == null ? void 0 : _c.children);
3424
+ if (options.preventContentUpdate === true && !hasCollection) return;
3425
+ if (options.forceUpdate && !options.forceReset && (ref.__noCollectionDifference || __contentRef && __contentRef.__cached && deepContains(params, content))) {
3426
+ if (!options.preventBeforeUpdateListener && !options.preventListeners) {
3427
+ const beforeUpdateReturns = await triggerEventOnUpdate(
3428
+ "beforeUpdate",
3429
+ params,
3430
+ element,
3431
+ options
3432
+ );
3433
+ if (beforeUpdateReturns === false) return element;
3434
+ }
3435
+ if (content == null ? void 0 : content.update) await content.update({}, options);
3436
+ if (!options.preventUpdateListener)
3437
+ await triggerEventOn("update", element, options);
3438
+ return;
3439
+ }
3440
+ if (params) {
3441
+ let { childExtend, childExtendRecursive, props } = params;
3442
+ if (!props) props = params.props = {};
3443
+ if (!childExtend && element.childExtend) {
3444
+ params.childExtend = element.childExtend;
3445
+ props.ignoreChildExtend = true;
3446
+ }
3447
+ if (!childExtendRecursive && element.childExtendRecursive) {
3448
+ params.childExtendRecursive = element.childExtendRecursive;
3449
+ props.ignoreChildExtendRecursive = true;
3450
+ }
3451
+ if (!(props == null ? void 0 : props.childProps) && ((_d = element.props) == null ? void 0 : _d.childProps)) {
3452
+ props.childProps = element.props.childProps;
3453
+ props.ignoreChildProps = true;
3454
+ }
3455
+ if (lazyLoad) {
3456
+ window.requestAnimationFrame(async () => {
3457
+ await resetElement(params, element, options);
3458
+ if (!options.preventUpdateListener) {
3459
+ await triggerEventOn("lazyLoad", element, options);
3460
+ }
3461
+ });
3462
+ } else await resetElement(params, element, options);
3463
+ } else {
3464
+ if (!options.preventRemove) removeContent(element, options);
3465
+ }
3466
+ return element;
3467
+ };
3468
+
3469
+ // ../../../domql/packages/element/mixins/content.js
3470
+ var updateContent = async function(params, options) {
3471
+ const element = this;
3472
+ const ref = element.__ref;
3473
+ const contentKey = ref.contentElementKey;
3474
+ if (!element[contentKey]) return;
3475
+ if (element[contentKey].update)
3476
+ await element[contentKey].update(params, options);
3477
+ };
3478
+ var removeContent = function(el, opts = {}) {
3479
+ const element = el || this;
3480
+ const { __ref: ref } = element;
3481
+ const contentElementKey = setContentKey(element, opts);
3482
+ if (opts.contentElementKey !== "content") opts.contentElementKey = "content";
3483
+ const contentElement = element[contentElementKey];
3484
+ if (contentElement) {
3485
+ if (contentElement.node && element.node) {
3486
+ if (contentElement.tag === "fragment")
3487
+ element.node.innerHTML = "";
3488
+ else {
3489
+ const contentNode = contentElement.node;
3490
+ if (contentNode.parentNode === element.node)
3491
+ element.node.removeChild(contentElement.node);
3492
+ }
3493
+ }
3494
+ const { __cachedContent } = ref;
3495
+ if (__cachedContent) {
3496
+ if (__cachedContent.tag === "fragment")
3497
+ __cachedContent.parent.node.innerHTML = "";
3498
+ else if (__cachedContent && isFunction(__cachedContent.remove))
3499
+ __cachedContent.remove();
3500
+ delete ref.__cachedContent;
3501
+ }
3502
+ ref.__children.splice(ref.__children.indexOf(contentElementKey), 1);
3503
+ delete element[contentElementKey];
3504
+ }
3505
+ };
3506
+ async function setContent(param, element, node, opts) {
3507
+ var _a;
3508
+ const contentElementKey = setContentKey(element, opts);
3509
+ if (!element) this.warn("No element to set content on");
3510
+ if (param) {
3511
+ if ((_a = element[contentElementKey]) == null ? void 0 : _a.update) {
3512
+ await element[contentElementKey].update({}, opts);
3513
+ } else {
3514
+ await set2.call(element, param, opts);
3515
+ }
3516
+ } else {
3517
+ removeContent(element, opts);
3518
+ }
3519
+ }
3520
+
3521
+ // ../../../domql/packages/element/mixins/data.js
3522
+ function data(params, element, node) {
3523
+ if (params) {
3524
+ if (element.props.data) deepMerge(params, element.props.data);
3525
+ if (params.showOnNode) {
3526
+ if (!isObject(params)) report("HTMLInvalidData", params);
3527
+ for (const dataset in params) {
3528
+ if (dataset !== "showOnNode") {
3529
+ node.dataset[dataset] = exec(params[dataset], element);
3530
+ }
3531
+ }
3532
+ }
3533
+ }
3534
+ }
3535
+
3536
+ // ../../../domql/packages/element/mixins/html.js
3537
+ function html(param, element, node, opts) {
3538
+ var _a;
3539
+ const prop = element.call(
3540
+ "exec",
3541
+ param,
3542
+ element,
3543
+ element.state,
3544
+ element.context,
3545
+ opts
3546
+ ) || element.call(
3547
+ "exec",
3548
+ (_a = element == null ? void 0 : element.props) == null ? void 0 : _a.html,
3549
+ element,
3550
+ element.state,
3551
+ element.context,
3552
+ opts
3553
+ );
3554
+ const { __ref } = element;
3555
+ if (prop !== __ref.__html) {
3556
+ if (node.nodeName === "SVG") node.textContent = prop;
3557
+ else node.innerHTML = prop;
3558
+ __ref.__html = prop;
3559
+ }
3560
+ }
3561
+
3562
+ // ../../../domql/packages/element/mixins/style.js
3563
+ function style(params, element, node) {
3564
+ if (params) {
3565
+ if (isObject(params)) map(node.style, params, element);
3566
+ else report("HTMLInvalidStyles", params);
3567
+ }
3568
+ }
3569
+
3570
+ // ../../../domql/packages/element/mixins/text.js
3571
+ function text(param, element, node, opts) {
3572
+ let prop = exec(param, element, element.state, element.context, opts);
3573
+ if (isString(prop) && prop.includes("{{")) {
3574
+ prop = element.call("replaceLiteralsWithObjectFields", prop);
3575
+ }
3576
+ if (element.tag === "string") {
3577
+ node.nodeValue = prop;
3578
+ } else if (param !== void 0 || param !== null) {
3579
+ if (element.__text) {
3580
+ if (element.__text.text === prop) return;
3581
+ element.__text.text = prop;
3582
+ if (element.__text.node) element.__text.node.nodeValue = prop;
3583
+ } else create({ tag: "string", text: prop }, element, "__text");
3584
+ }
3585
+ }
3586
+
3587
+ // ../../../domql/packages/element/mixins/state.js
3588
+ async function state(params, element, node, opts) {
3589
+ const state2 = exec(params, element, element.state, element.context, opts);
3590
+ if (isObject(state2)) {
3591
+ const keys3 = Object.keys(state2);
3592
+ for (const param of keys3) {
3593
+ if (IGNORE_STATE_PARAMS2.includes(param)) continue;
3594
+ if (!Object.hasOwnProperty.call(state2, param)) continue;
3595
+ }
3596
+ }
3597
+ return element;
3598
+ }
3599
+
3600
+ // ../../../domql/packages/element/mixins/scope.js
3601
+ function scope(params, element, node) {
3602
+ if (!isObject(params)) return;
3603
+ for (const scopeItem in params) {
3604
+ const value = params[scopeItem];
3605
+ if (isFunction(value)) {
3606
+ element.scope[scopeItem] = value.bind(element);
3607
+ } else {
3608
+ element.scope[scopeItem] = value;
3609
+ }
3610
+ }
3611
+ }
3612
+
3613
+ // ../../../domql/packages/element/utils/component.js
3614
+ var createValidDomqlObjectFromSugar = (el, parent2, key, options) => {
3615
+ const newElem = {
3616
+ props: {},
3617
+ define: {}
3618
+ };
3619
+ const allowedKeys = ["data", "state", "attr", "if"];
3620
+ for (const k in el) {
3621
+ const value = el[k];
3622
+ const isComponent = checkIfKeyIsComponent(k);
3623
+ const isRegistry = REGISTRY[k];
3624
+ if (isComponent || isRegistry || allowedKeys.includes(k)) {
3625
+ newElem[k] = value;
3626
+ } else {
3627
+ newElem.props[k] = value;
3628
+ }
3629
+ }
3630
+ return newElem;
3631
+ };
3632
+ var overwriteVariant = (element, variant, variantProps) => {
3633
+ let variantElement = element[variant];
3634
+ if (!variantElement) return;
3635
+ const props = isObject(variantProps) ? variantProps : {};
3636
+ if (isString(variantElement)) {
3637
+ variantElement = {
3638
+ extend: [{ props }, variantElement]
3639
+ };
3640
+ } else if (variantElement.extend) {
3641
+ variantElement = addAdditionalExtend({ props }, variantElement);
3642
+ }
3643
+ const extendedVariant = applyExtend(variantElement, element.parent);
3644
+ const { parent: parent2, ...rest } = extendedVariant;
3645
+ return overwriteDeep(element, rest);
3646
+ };
3647
+ var applyVariant = (element) => {
3648
+ const { props } = element;
3649
+ if (!hasVariantProp(element)) return element;
3650
+ const { variant } = props;
3651
+ overwriteVariant(element, `.${variant}`);
3652
+ const elKeys = Object.keys(element).filter((key) => isVariant(key));
3653
+ elKeys.forEach((variant2) => {
3654
+ const slicedVariantElementKey = variant2.slice(1);
3655
+ const variantElementProps = props[slicedVariantElementKey];
3656
+ if (variantElementProps) overwriteVariant(element, variant2, variantElementProps);
3657
+ });
3658
+ return element;
3659
+ };
3660
+
3661
+ // ../../../domql/packages/element/mixins/attr.js
3662
+ function attr(params, element, node, opts) {
3663
+ const { __ref: ref, props } = element;
3664
+ const { __attr } = ref;
3665
+ if (isNot("object")) report("HTMLInvalidAttr", params);
3666
+ if (params) {
3667
+ if (props.attr) deepMerge2(params, props.attr);
3668
+ for (const attr2 in params) {
3669
+ const val = exec(
3670
+ params[attr2],
3671
+ element,
3672
+ element.state,
3673
+ element.context,
3674
+ opts
3675
+ );
3676
+ if (val !== false && !isUndefined(val) && !isNull(val) && node.setAttribute)
3677
+ node.setAttribute(
3678
+ attr2,
3679
+ exec(val, element, element.state, element.context, opts)
3680
+ );
3681
+ else if (node.removeAttribute) node.removeAttribute(attr2);
3682
+ __attr[attr2] = val;
3683
+ }
3684
+ }
3685
+ }
3686
+
3687
+ // ../../../domql/packages/element/mixins/registry.js
3688
+ var REGISTRY = {
3689
+ attr,
3690
+ style,
3691
+ text,
3692
+ html,
3693
+ content: setContent,
3694
+ data,
3695
+ class: classList,
3696
+ state,
3697
+ scope,
3698
+ deps: (param, el) => param || el.parent.deps,
3699
+ extend: {},
3700
+ extends: {},
3701
+ childExtend: {},
3702
+ childExtends: {},
3703
+ childExtendsRecursive: {},
3704
+ helmet: {},
3705
+ metadata: {},
3706
+ props: {},
3707
+ path: {},
3708
+ if: {},
3709
+ define: {},
3710
+ transform: {},
3711
+ __name: {},
3712
+ __ref: {},
3713
+ __hash: {},
3714
+ __text: {},
3715
+ nextElement: {},
3716
+ previousElement: {},
3717
+ key: {},
3718
+ tag: {},
3719
+ query: {},
3720
+ parent: {},
3721
+ node: {},
3722
+ set: {},
3723
+ reset: {},
3724
+ update: {},
3725
+ error: {},
3726
+ warn: {},
3727
+ call: {},
3728
+ setProps: {},
3729
+ remove: {},
3730
+ updateContent: {},
3731
+ removeContent: {},
3732
+ variables: {},
3733
+ lookup: {},
3734
+ lookdown: {},
3735
+ getRef: {},
3736
+ getPath: {},
3737
+ lookdownAll: {},
3738
+ setNodeStyles: {},
3739
+ spotByPath: {},
3740
+ append: {},
3741
+ routes: {},
3742
+ keys: {},
3743
+ log: {},
3744
+ parse: {},
3745
+ parseDeep: {},
3746
+ on: {},
3747
+ component: {},
3748
+ context: {},
3749
+ $collection: {},
3750
+ $stateCollection: {},
3751
+ $propsCollection: {},
3752
+ $setCollection: {},
3753
+ $setStateCollection: {},
3754
+ $setPropsCollection: {}
3755
+ };
3756
+ var parseFilters = {
3757
+ elementKeys: [
3758
+ "tag",
3759
+ "text",
3760
+ "style",
3761
+ "attr",
3762
+ "class",
3763
+ "state",
3764
+ "props",
3765
+ "data",
3766
+ "content",
3767
+ "html",
3768
+ "on",
3769
+ "key",
3770
+ "extend",
3771
+ "childExtend",
3772
+ "childExtendsRecursive",
3773
+ "scope",
3774
+ "query",
3775
+ "$collection",
3776
+ "$stateCollection",
3777
+ "$propsCollection"
3778
+ ],
3779
+ propsKeys: ["__element", "update"],
3780
+ stateKeys: []
3781
+ };
3782
+
3783
+ // src/domqlv3hacks.js
3784
+ function temporaryDomqlHack(value) {
3785
+ var _a;
3786
+ if (this && !((_a = this.getUserSettings) == null ? void 0 : _a.call(this, "useDomql3"))) return value;
3787
+ let obj = { ...value };
3788
+ const on = obj.on;
3789
+ if (this.call("isObject", on)) {
3790
+ delete obj.on;
3791
+ const transformedOn = {};
3792
+ for (const key in on) {
3793
+ const transformedKey = "on" + key.charAt(0).toUpperCase() + key.slice(1);
3794
+ transformedOn[transformedKey] = on[key];
3795
+ }
3796
+ obj = { ...transformedOn, ...obj };
3797
+ }
3798
+ const props = obj.props;
3799
+ if (this.call("isObject", props)) {
3800
+ delete obj.props;
3801
+ obj = { ...props, ...obj };
3802
+ }
3803
+ const extendObj = {};
3804
+ if (obj.extend) {
3805
+ extendObj.extends = obj.extend;
3806
+ delete obj.extend;
3807
+ }
3808
+ if (obj.childExtend) {
3809
+ extendObj.childExtends = obj.childExtend;
3810
+ delete obj.childExtend;
3811
+ }
3812
+ return { ...extendObj, ...obj };
3813
+ }
3814
+ function temporaryDomqlHackReverse(value) {
3815
+ var _a;
3816
+ if (this && !((_a = this.getUserSettings) == null ? void 0 : _a.call(this, "useDomql3"))) return value;
3817
+ const obj = { ...value };
3818
+ if (obj.extends) {
3819
+ obj.extend = obj.extends;
3820
+ delete obj.extends;
3821
+ }
3822
+ if (obj.childExtends) {
3823
+ obj.childExtend = obj.childExtends;
3824
+ delete obj.childExtends;
3825
+ }
3826
+ for (const key in obj) {
3827
+ const allowed = ["transform", "class"];
3828
+ if (REGISTRY[key] && !allowed.includes(key) || /^[A-Z]/.test(key))
3829
+ continue;
3830
+ else {
3831
+ obj.props = obj.props || {};
3832
+ obj.props[key] = obj[key];
3833
+ delete obj[key];
3834
+ }
3835
+ }
3836
+ return obj;
3837
+ }
3838
+ // @preserve-env