@symbo.ls/utils 2.11.421 → 2.11.434

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,32 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/animationFrame.js
21
+ var animationFrame_exports = {};
22
+ __export(animationFrame_exports, {
23
+ registerFrameListener: () => registerFrameListener
24
+ });
25
+ module.exports = __toCommonJS(animationFrame_exports);
26
+ var registerFrameListener = (el) => {
27
+ const { __ref: ref } = el;
28
+ const { frameListeners } = ref.root.data;
29
+ if (frameListeners && !frameListeners.has(el)) {
30
+ frameListeners.add(el);
31
+ }
32
+ };
@@ -166,6 +166,7 @@ var require_node = __commonJS({
166
166
  var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
167
167
  var node_exports = {};
168
168
  __export2(node_exports, {
169
+ isDOMNode: () => isDOMNode,
169
170
  isHtmlElement: () => isHtmlElement,
170
171
  isNode: () => isNode
171
172
  });
@@ -177,6 +178,9 @@ var require_node = __commonJS({
177
178
  var isHtmlElement = (obj) => {
178
179
  return (typeof HTMLElement === "object" ? obj instanceof import_globals.window.HTMLElement : obj && typeof obj === "object" && obj !== null && obj.nodeType === 1 && typeof obj.nodeName === "string") || false;
179
180
  };
181
+ var isDOMNode = (obj) => {
182
+ return typeof import_globals.window !== "undefined" && (obj instanceof import_globals.window.Node || obj instanceof import_globals.window.Window || obj === import_globals.window || obj === document);
183
+ };
180
184
  }
181
185
  });
182
186
 
@@ -296,7 +300,6 @@ var require_array = __commonJS({
296
300
  addItemAfterEveryElement: () => addItemAfterEveryElement,
297
301
  arrayContainsOtherArray: () => arrayContainsOtherArray,
298
302
  arraysEqual: () => arraysEqual,
299
- createNestedObject: () => createNestedObject,
300
303
  cutArrayAfterValue: () => cutArrayAfterValue,
301
304
  cutArrayBeforeValue: () => cutArrayBeforeValue,
302
305
  getFrequencyInArray: () => getFrequencyInArray,
@@ -342,10 +345,10 @@ var require_array = __commonJS({
342
345
  return [].concat(...arrays);
343
346
  };
344
347
  var mergeArray = (arr, excludeFrom = []) => {
345
- return arr.reduce((a, c) => (0, import_object.deepMerge)(a, (0, import_object.deepClone)(c, excludeFrom), excludeFrom), {});
348
+ return arr.reduce((a, c) => (0, import_object.deepMerge)(a, (0, import_object.deepCloneWithExtend)(c, excludeFrom), excludeFrom), {});
346
349
  };
347
350
  var mergeAndCloneIfArray = (obj) => {
348
- return (0, import_types.isArray)(obj) ? mergeArray(obj) : (0, import_object.deepClone)(obj);
351
+ return (0, import_types.isArray)(obj) ? mergeArray(obj) : (0, import_object.deepCloneWithExtend)(obj);
349
352
  };
350
353
  var cutArrayBeforeValue = (arr, value) => {
351
354
  const index = arr.indexOf(value);
@@ -363,22 +366,6 @@ var require_array = __commonJS({
363
366
  }
364
367
  return arr;
365
368
  };
366
- var createNestedObject = (arr, lastValue) => {
367
- const nestedObject = {};
368
- if (arr.length === 0) {
369
- return lastValue;
370
- }
371
- arr.reduce((obj, value, index) => {
372
- if (!obj[value]) {
373
- obj[value] = {};
374
- }
375
- if (index === arr.length - 1 && lastValue) {
376
- obj[value] = lastValue;
377
- }
378
- return obj[value];
379
- }, nestedObject);
380
- return nestedObject;
381
- };
382
369
  var removeValueFromArray = (arr, value) => {
383
370
  const index = arr.indexOf(value);
384
371
  if (index > -1) {
@@ -451,6 +438,8 @@ var require_string = __commonJS({
451
438
  __export2(string_exports, {
452
439
  customDecodeURIComponent: () => customDecodeURIComponent,
453
440
  customEncodeURIComponent: () => customEncodeURIComponent,
441
+ decodeNewlines: () => decodeNewlines,
442
+ encodeNewlines: () => encodeNewlines,
454
443
  findKeyPosition: () => findKeyPosition,
455
444
  lowercaseFirstLetter: () => lowercaseFirstLetter,
456
445
  replaceLiteralsWithObjectFields: () => replaceLiteralsWithObjectFields,
@@ -554,6 +543,12 @@ var require_string = __commonJS({
554
543
  return char;
555
544
  });
556
545
  };
546
+ var encodeNewlines = (str) => {
547
+ return str.split("\n").join("/////n").split("`").join("/////tilde").split("$").join("/////dlrsgn");
548
+ };
549
+ var decodeNewlines = (encodedStr) => {
550
+ return encodedStr.split("/////n").join("\n").split("/////tilde").join("`").split("/////dlrsgn").join("$");
551
+ };
557
552
  var customEncodeURIComponent = (str) => {
558
553
  return str.split("").map((char) => {
559
554
  if (/[^a-zA-Z0-9\s]/.test(char)) {
@@ -591,8 +586,8 @@ var require_object = __commonJS({
591
586
  var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
592
587
  var object_exports = {};
593
588
  __export2(object_exports, {
594
- checkIfKeyIsComponent: () => checkIfKeyIsComponent,
595
589
  clone: () => clone,
590
+ createNestedObject: () => createNestedObject,
596
591
  createObjectWithoutPrototype: () => createObjectWithoutPrototype,
597
592
  deepClone: () => deepClone,
598
593
  deepCloneExclude: () => deepCloneExclude,
@@ -603,13 +598,12 @@ var require_object = __commonJS({
603
598
  deepMerge: () => deepMerge,
604
599
  deepStringify: () => deepStringify,
605
600
  detachFunctionsFromObject: () => detachFunctionsFromObject,
601
+ detectInfiniteLoop: () => detectInfiniteLoop,
606
602
  diff: () => diff,
607
603
  diffArrays: () => diffArrays,
608
604
  diffObjects: () => diffObjects,
609
605
  exec: () => exec,
610
606
  flattenRecursive: () => flattenRecursive,
611
- getChildrenComponentsByKey: () => getChildrenComponentsByKey,
612
- getExtendsInElement: () => getExtendsInElement,
613
607
  hasOwnProperty: () => hasOwnProperty,
614
608
  isEmpty: () => isEmpty,
615
609
  isEmptyObject: () => isEmptyObject,
@@ -624,6 +618,7 @@ var require_object = __commonJS({
624
618
  overwriteDeep: () => overwriteDeep,
625
619
  overwriteShallow: () => overwriteShallow,
626
620
  removeFromObject: () => removeFromObject,
621
+ removeNestedKeyByPath: () => removeNestedKeyByPath,
627
622
  stringToObject: () => stringToObject
628
623
  });
629
624
  module2.exports = __toCommonJS2(object_exports);
@@ -631,6 +626,8 @@ var require_object = __commonJS({
631
626
  var import_types = require_types();
632
627
  var import_array = require_array();
633
628
  var import_string = require_string();
629
+ var import_node = require_node();
630
+ var ENV = "development";
634
631
  var exec = (param, element, state, context) => {
635
632
  if ((0, import_types.isFunction)(param)) {
636
633
  return param(
@@ -709,27 +706,28 @@ var require_object = __commonJS({
709
706
  var mergeArrayExclude = (arr, excl = []) => {
710
707
  return arr.reduce((acc, curr) => deepMerge(acc, deepCloneExclude(curr, excl)), {});
711
708
  };
712
- var deepClone = (obj, excludeFrom = [], cleanUndefined = false) => {
713
- const o = (0, import_types.isArray)(obj) ? [] : {};
714
- for (const prop in obj) {
715
- if (!Object.prototype.hasOwnProperty.call(obj, prop))
716
- continue;
717
- if (prop === "__proto__")
718
- continue;
719
- if (excludeFrom.includes(prop) || prop.startsWith("__"))
720
- continue;
721
- let objProp = obj[prop];
722
- if (cleanUndefined && (0, import_types.isUndefined)(objProp))
723
- continue;
724
- if (prop === "extend" && (0, import_types.isArray)(objProp)) {
725
- objProp = (0, import_array.mergeArray)(objProp);
709
+ var deepClone = (obj, exclude = [], cleanUndefined = false, visited = /* @__PURE__ */ new WeakMap()) => {
710
+ if (!(0, import_types.isObjectLike)(obj) || (0, import_node.isDOMNode)(obj))
711
+ return obj;
712
+ if (visited.has(obj))
713
+ return visited.get(obj);
714
+ const clone2 = (0, import_types.isArray)(obj) ? [] : {};
715
+ visited.set(obj, clone2);
716
+ for (const key in obj) {
717
+ if (Object.prototype.hasOwnProperty.call(obj, key) && !exclude.includes(key)) {
718
+ const value = obj[key];
719
+ if ((0, import_node.isDOMNode)(value)) {
720
+ clone2[key] = value;
721
+ } else if (key === "extend" && (0, import_types.isArray)(value)) {
722
+ clone2[key] = (0, import_array.mergeArray)(value, exclude);
723
+ } else if ((0, import_types.isObjectLike)(value)) {
724
+ clone2[key] = deepClone(value, exclude, cleanUndefined, visited);
725
+ } else {
726
+ clone2[key] = value;
727
+ }
726
728
  }
727
- if ((0, import_types.isObjectLike)(objProp)) {
728
- o[prop] = deepClone(objProp, excludeFrom, cleanUndefined);
729
- } else
730
- o[prop] = objProp;
731
729
  }
732
- return o;
730
+ return clone2;
733
731
  };
734
732
  var deepCloneWithExtend = (obj, excludeFrom = ["node"], options = {}) => {
735
733
  const o = options.window ? (0, import_types.isArray)(obj) ? new options.window.Array([]) : new options.window.Object({}) : (0, import_types.isArray)(obj) ? [] : {};
@@ -741,6 +739,8 @@ var require_object = __commonJS({
741
739
  continue;
742
740
  if ((0, import_types.isObjectLike)(objProp)) {
743
741
  o[prop] = deepCloneWithExtend(objProp, excludeFrom, options);
742
+ } else if ((0, import_types.isFunction)(objProp) && options.window) {
743
+ o[prop] = (options.window || import_globals.window).eval("(" + objProp.toString() + ")");
744
744
  } else
745
745
  o[prop] = objProp;
746
746
  }
@@ -984,16 +984,23 @@ var require_object = __commonJS({
984
984
  }
985
985
  return obj;
986
986
  };
987
- var overwriteDeep = (obj, params, excludeFrom = []) => {
987
+ var overwriteDeep = (obj, params, excludeFrom = [], visited = /* @__PURE__ */ new WeakMap()) => {
988
+ if (!(0, import_types.isObjectLike)(obj) || !(0, import_types.isObjectLike)(params) || (0, import_node.isDOMNode)(obj) || (0, import_node.isDOMNode)(params)) {
989
+ return params;
990
+ }
991
+ if (visited.has(obj)) {
992
+ return visited.get(obj);
993
+ }
994
+ visited.set(obj, obj);
988
995
  for (const e in params) {
989
- if (e === "__proto__")
990
- continue;
991
- if (excludeFrom.includes(e) || e.startsWith("__"))
996
+ if (e === "__ref" || excludeFrom.includes(e) || e.startsWith("__"))
992
997
  continue;
993
998
  const objProp = obj[e];
994
999
  const paramsProp = params[e];
995
- if ((0, import_types.isObjectLike)(objProp) && (0, import_types.isObjectLike)(paramsProp)) {
996
- overwriteDeep(objProp, paramsProp);
1000
+ if ((0, import_node.isDOMNode)(paramsProp)) {
1001
+ obj[e] = paramsProp;
1002
+ } else if ((0, import_types.isObjectLike)(objProp) && (0, import_types.isObjectLike)(paramsProp)) {
1003
+ obj[e] = overwriteDeep(objProp, paramsProp, excludeFrom, visited);
997
1004
  } else if (paramsProp !== void 0) {
998
1005
  obj[e] = paramsProp;
999
1006
  }
@@ -1040,30 +1047,40 @@ var require_object = __commonJS({
1040
1047
  }
1041
1048
  return true;
1042
1049
  };
1043
- var deepContains = (obj1, obj2) => {
1044
- if (typeof obj1 !== typeof obj2) {
1050
+ var deepContains = (obj1, obj2, ignoredKeys = ["node", "__ref"]) => {
1051
+ if (obj1 === obj2)
1052
+ return true;
1053
+ if (!(0, import_types.isObjectLike)(obj1) || !(0, import_types.isObjectLike)(obj2))
1045
1054
  return false;
1046
- }
1047
- if ((0, import_types.isObjectLike)(obj1)) {
1048
- if (Array.isArray(obj1) && Array.isArray(obj2)) {
1049
- if (obj1.length !== obj2.length) {
1055
+ if ((0, import_node.isDOMNode)(obj1) || (0, import_node.isDOMNode)(obj2))
1056
+ return obj1 === obj2;
1057
+ const stack = [[obj1, obj2]];
1058
+ const visited = /* @__PURE__ */ new WeakSet();
1059
+ while (stack.length > 0) {
1060
+ const [current1, current2] = stack.pop();
1061
+ if (visited.has(current1))
1062
+ continue;
1063
+ visited.add(current1);
1064
+ const keys1 = Object.keys(current1).filter((key) => !ignoredKeys.includes(key));
1065
+ const keys2 = Object.keys(current2).filter((key) => !ignoredKeys.includes(key));
1066
+ if (keys1.length !== keys2.length)
1067
+ return false;
1068
+ for (const key of keys1) {
1069
+ if (!Object.prototype.hasOwnProperty.call(current2, key))
1050
1070
  return false;
1051
- }
1052
- for (let i = 0; i < obj1.length; i++) {
1053
- if (!deepContains(obj1[i], obj2[i])) {
1054
- return false;
1055
- }
1056
- }
1057
- } else if ((0, import_types.isObjectLike)(obj1) && obj2 !== null) {
1058
- for (const key in obj1) {
1059
- const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(obj2, key);
1060
- if (!hasOwnProperty2 || !deepContains(obj1[key], obj2[key])) {
1071
+ const value1 = current1[key];
1072
+ const value2 = current2[key];
1073
+ if ((0, import_node.isDOMNode)(value1) || (0, import_node.isDOMNode)(value2)) {
1074
+ if (value1 !== value2)
1061
1075
  return false;
1076
+ } else if ((0, import_types.isObjectLike)(value1) && (0, import_types.isObjectLike)(value2)) {
1077
+ if (value1 !== value2) {
1078
+ stack.push([value1, value2]);
1062
1079
  }
1080
+ } else if (value1 !== value2) {
1081
+ return false;
1063
1082
  }
1064
1083
  }
1065
- } else {
1066
- return obj2 === obj1;
1067
1084
  }
1068
1085
  return true;
1069
1086
  };
@@ -1091,53 +1108,60 @@ var require_object = __commonJS({
1091
1108
  }
1092
1109
  return newObj;
1093
1110
  };
1094
- var checkIfKeyIsComponent = (key) => {
1095
- const isFirstKeyString = (0, import_types.isString)(key);
1096
- if (!isFirstKeyString)
1097
- return;
1098
- const firstCharKey = key.slice(0, 1);
1099
- return /^[A-Z]*$/.test(firstCharKey);
1111
+ var createNestedObject = (arr, lastValue) => {
1112
+ const nestedObject = {};
1113
+ if (arr.length === 0) {
1114
+ return lastValue;
1115
+ }
1116
+ arr.reduce((obj, value, index) => {
1117
+ if (!obj[value]) {
1118
+ obj[value] = {};
1119
+ }
1120
+ if (index === arr.length - 1 && lastValue) {
1121
+ obj[value] = lastValue;
1122
+ }
1123
+ return obj[value];
1124
+ }, nestedObject);
1125
+ return nestedObject;
1100
1126
  };
1101
- var getChildrenComponentsByKey = (key, el) => {
1102
- if (key === el.key || el.__ref.__componentKey === key) {
1103
- return el;
1127
+ var removeNestedKeyByPath = (obj, path) => {
1128
+ if (!Array.isArray(path)) {
1129
+ throw new Error("Path must be an array.");
1104
1130
  }
1105
- if (el.extend) {
1106
- const foundString = (0, import_types.isString)(el.extend) && el.extend === key;
1107
- const foundInArray = (0, import_types.isArray)(el.extend) && el.extend.filter((v) => v === key).length;
1108
- if (foundString || foundInArray)
1109
- return el;
1131
+ let current = obj;
1132
+ for (let i = 0; i < path.length - 1; i++) {
1133
+ if (current[path[i]] === void 0) {
1134
+ return;
1135
+ }
1136
+ current = current[path[i]];
1110
1137
  }
1111
- if (el.parent && el.parent.childExtend) {
1112
- const foundString = (0, import_types.isString)(el.parent.childExtend) && el.parent.childExtend === key;
1113
- const foundInArray = (0, import_types.isArray)(el.parent.childExtend) && el.parent.childExtend.filter((v) => v === key).length;
1114
- if (foundString || foundInArray)
1115
- return el;
1138
+ const lastKey = path[path.length - 1];
1139
+ if (current && Object.hasOwnProperty.call(current, lastKey)) {
1140
+ delete current[lastKey];
1116
1141
  }
1117
1142
  };
1118
- var getExtendsInElement = (obj) => {
1119
- let result = [];
1120
- function traverse(o) {
1121
- for (const key in o) {
1122
- if (Object.hasOwnProperty.call(o, key)) {
1123
- if (checkIfKeyIsComponent(key)) {
1124
- result.push(key);
1125
- }
1126
- if (key === "extend") {
1127
- if (typeof o[key] === "string") {
1128
- result.push(o[key]);
1129
- } else if (Array.isArray(o[key])) {
1130
- result = result.concat(o[key]);
1131
- }
1132
- }
1133
- if (typeof o[key] === "object" && o[key] !== null) {
1134
- traverse(o[key]);
1143
+ var detectInfiniteLoop = (arr) => {
1144
+ const maxRepeats = 10;
1145
+ let pattern = [];
1146
+ let repeatCount = 0;
1147
+ for (let i = 0; i < arr.length; i++) {
1148
+ if (pattern.length < 2) {
1149
+ pattern.push(arr[i]);
1150
+ } else {
1151
+ if (arr[i] === pattern[i % 2]) {
1152
+ repeatCount++;
1153
+ } else {
1154
+ pattern = [arr[i - 1], arr[i]];
1155
+ repeatCount = 1;
1156
+ }
1157
+ if (repeatCount >= maxRepeats * 2) {
1158
+ if (ENV === "test" || ENV === "development") {
1159
+ console.warn("Warning: Potential infinite loop detected due to repeated sequence:", pattern);
1135
1160
  }
1161
+ return true;
1136
1162
  }
1137
1163
  }
1138
1164
  }
1139
- traverse(obj);
1140
- return result;
1141
1165
  };
1142
1166
  }
1143
1167
  });
@@ -1165,6 +1189,7 @@ var require_function = __commonJS({
1165
1189
  var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
1166
1190
  var function_exports = {};
1167
1191
  __export2(function_exports, {
1192
+ cloneFunction: () => cloneFunction,
1168
1193
  debounce: () => debounce,
1169
1194
  debounceOnContext: () => debounceOnContext,
1170
1195
  isStringFunction: () => isStringFunction,
@@ -1214,6 +1239,17 @@ var require_function = __commonJS({
1214
1239
  const functionRegex = /^((function\s*\([^)]*\)\s*\{[^}]*\})|(\([^)]*\)\s*=>))/;
1215
1240
  return functionRegex.test(inputString);
1216
1241
  };
1242
+ function cloneFunction(fn, win = window) {
1243
+ const temp = function() {
1244
+ return fn.apply(win, arguments);
1245
+ };
1246
+ for (const key in fn) {
1247
+ if (Object.hasOwnProperty.call(fn, key)) {
1248
+ temp[key] = fn[key];
1249
+ }
1250
+ }
1251
+ return temp;
1252
+ }
1217
1253
  }
1218
1254
  });
1219
1255
 
@@ -1483,6 +1519,172 @@ var require_tags = __commonJS({
1483
1519
  }
1484
1520
  });
1485
1521
 
1522
+ // ../../../domql/packages/utils/dist/cjs/component.js
1523
+ var require_component = __commonJS({
1524
+ "../../../domql/packages/utils/dist/cjs/component.js"(exports, module2) {
1525
+ "use strict";
1526
+ var __defProp2 = Object.defineProperty;
1527
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
1528
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
1529
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
1530
+ var __export2 = (target, all) => {
1531
+ for (var name in all)
1532
+ __defProp2(target, name, { get: all[name], enumerable: true });
1533
+ };
1534
+ var __copyProps2 = (to, from, except, desc) => {
1535
+ if (from && typeof from === "object" || typeof from === "function") {
1536
+ for (let key of __getOwnPropNames2(from))
1537
+ if (!__hasOwnProp2.call(to, key) && key !== except)
1538
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
1539
+ }
1540
+ return to;
1541
+ };
1542
+ var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
1543
+ var component_exports = {};
1544
+ __export2(component_exports, {
1545
+ addAdditionalExtend: () => addAdditionalExtend,
1546
+ applyComponentFromContext: () => applyComponentFromContext,
1547
+ applyKeyComponentAsExtend: () => applyKeyComponentAsExtend,
1548
+ checkIfKeyIsComponent: () => checkIfKeyIsComponent,
1549
+ checkIfKeyIsProperty: () => checkIfKeyIsProperty,
1550
+ extendizeByKey: () => extendizeByKey,
1551
+ getChildrenComponentsByKey: () => getChildrenComponentsByKey,
1552
+ getExtendsInElement: () => getExtendsInElement,
1553
+ hasVariantProp: () => hasVariantProp,
1554
+ isVariant: () => isVariant
1555
+ });
1556
+ module2.exports = __toCommonJS2(component_exports);
1557
+ var import__2 = require_cjs();
1558
+ var ENV = "development";
1559
+ var checkIfKeyIsComponent = (key) => {
1560
+ const isFirstKeyString = (0, import__2.isString)(key);
1561
+ if (!isFirstKeyString)
1562
+ return;
1563
+ const firstCharKey = key.slice(0, 1);
1564
+ return /^[A-Z]*$/.test(firstCharKey);
1565
+ };
1566
+ var checkIfKeyIsProperty = (key) => {
1567
+ const isFirstKeyString = (0, import__2.isString)(key);
1568
+ if (!isFirstKeyString)
1569
+ return;
1570
+ const firstCharKey = key.slice(0, 1);
1571
+ return /^[a-z]*$/.test(firstCharKey);
1572
+ };
1573
+ var addAdditionalExtend = (newExtend, element) => {
1574
+ const { extend: elementExtend } = element;
1575
+ const originalArray = (0, import__2.isArray)(elementExtend) ? elementExtend : [elementExtend];
1576
+ const receivedArray = (0, import__2.isArray)(newExtend) ? newExtend : [newExtend];
1577
+ const extend = (0, import__2.joinArrays)(receivedArray, originalArray);
1578
+ return { ...element, extend };
1579
+ };
1580
+ var extendizeByKey = (element, parent, key) => {
1581
+ const { context } = parent;
1582
+ const { tag, extend, props, attr, state, childExtend, childProps, on, if: condition, data } = element;
1583
+ const hasComponentAttrs = extend || childExtend || props || state || on || condition || attr || data;
1584
+ const extendFromKey = key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
1585
+ const isExtendKeyComponent = context && context.components[extendFromKey];
1586
+ if (element === isExtendKeyComponent)
1587
+ return element;
1588
+ else if (!hasComponentAttrs || childProps) {
1589
+ return {
1590
+ extend: extendFromKey,
1591
+ tag,
1592
+ props: { ...element }
1593
+ };
1594
+ } else if (!extend || extend === true) {
1595
+ return {
1596
+ ...element,
1597
+ tag,
1598
+ extend: extendFromKey
1599
+ };
1600
+ } else if (extend) {
1601
+ return addAdditionalExtend(extendFromKey, element);
1602
+ } else if ((0, import__2.isFunction)(element)) {
1603
+ return {
1604
+ extend: extendFromKey,
1605
+ tag,
1606
+ props: { ...(0, import__2.exec)(element, parent) }
1607
+ };
1608
+ }
1609
+ };
1610
+ var applyKeyComponentAsExtend = (element, parent, key) => {
1611
+ return extendizeByKey(element, parent, key) || element;
1612
+ };
1613
+ var applyComponentFromContext = (element, parent, options) => {
1614
+ const { context } = element;
1615
+ if (!context || !context.components)
1616
+ return;
1617
+ const { components } = context;
1618
+ const { extend } = element;
1619
+ const execExtend = (0, import__2.exec)(extend, element);
1620
+ if ((0, import__2.isString)(execExtend)) {
1621
+ const componentExists = components[execExtend] || components["smbls." + execExtend];
1622
+ if (componentExists)
1623
+ element.extend = componentExists;
1624
+ else {
1625
+ if ((ENV === "test" || ENV === "development") && options.verbose) {
1626
+ console.warn(execExtend, "is not in library", components, element);
1627
+ console.warn("replacing with ", {});
1628
+ }
1629
+ element.extend = {};
1630
+ }
1631
+ }
1632
+ };
1633
+ var isVariant = (param) => {
1634
+ if (!(0, import__2.isString)(param))
1635
+ return;
1636
+ const firstCharKey = param.slice(0, 1);
1637
+ return firstCharKey === ".";
1638
+ };
1639
+ var hasVariantProp = (element) => {
1640
+ const { props } = element;
1641
+ if ((0, import__2.isObject)(props) && (0, import__2.isString)(props.variant))
1642
+ return true;
1643
+ };
1644
+ var getChildrenComponentsByKey = (key, el) => {
1645
+ if (key === el.key || el.__ref.__componentKey === key) {
1646
+ return el;
1647
+ }
1648
+ if (el.extend) {
1649
+ const foundString = (0, import__2.isString)(el.extend) && el.extend === key;
1650
+ const foundInArray = (0, import__2.isArray)(el.extend) && el.extend.filter((v) => v === key).length;
1651
+ if (foundString || foundInArray)
1652
+ return el;
1653
+ }
1654
+ if (el.parent && el.parent.childExtend) {
1655
+ const foundString = (0, import__2.isString)(el.parent.childExtend) && el.parent.childExtend === key;
1656
+ const foundInArray = (0, import__2.isArray)(el.parent.childExtend) && el.parent.childExtend.filter((v) => v === key).length;
1657
+ if (foundString || foundInArray)
1658
+ return el;
1659
+ }
1660
+ };
1661
+ var getExtendsInElement = (obj) => {
1662
+ let result = [];
1663
+ function traverse(o) {
1664
+ for (const key in o) {
1665
+ if (Object.hasOwnProperty.call(o, key)) {
1666
+ if (checkIfKeyIsComponent(key)) {
1667
+ result.push(key);
1668
+ }
1669
+ if (key === "extend") {
1670
+ if (typeof o[key] === "string") {
1671
+ result.push(o[key]);
1672
+ } else if (Array.isArray(o[key])) {
1673
+ result = result.concat(o[key]);
1674
+ }
1675
+ }
1676
+ if (typeof o[key] === "object" && o[key] !== null) {
1677
+ traverse(o[key]);
1678
+ }
1679
+ }
1680
+ }
1681
+ }
1682
+ traverse(obj);
1683
+ return result;
1684
+ };
1685
+ }
1686
+ });
1687
+
1486
1688
  // ../../../domql/packages/utils/dist/cjs/index.js
1487
1689
  var require_cjs = __commonJS({
1488
1690
  "../../../domql/packages/utils/dist/cjs/index.js"(exports, module2) {
@@ -1515,6 +1717,7 @@ var require_cjs = __commonJS({
1515
1717
  __reExport(utils_exports, require_globals(), module2.exports);
1516
1718
  __reExport(utils_exports, require_cookie(), module2.exports);
1517
1719
  __reExport(utils_exports, require_tags(), module2.exports);
1720
+ __reExport(utils_exports, require_component(), module2.exports);
1518
1721
  }
1519
1722
  });
1520
1723